[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/plasma/applets/kickoff/ui
From: Aaron J. Seigo <aseigo () kde ! org>
Date: 2007-10-24 4:42:34
Message-ID: 1193200954.008219.5404.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 728734 by aseigo:
* always focus the search edit on show (not just creation)
* install an event filter on the tabbar so as to allow up/down keys to work on the \
active view properly
* hide on escape key press
M +28 -6 launcher.cpp
M +1 -0 launcher.h
--- trunk/KDE/kdebase/workspace/plasma/applets/kickoff/ui/launcher.cpp #728733:728734
@@ -244,6 +244,7 @@
d->searchBar->installEventFilter(this);
d->contentArea = new QStackedWidget(this);
d->contentSwitcher = new TabBar(this);
+ d->contentSwitcher->installEventFilter(this);
d->contentSwitcher->setIconSize(QSize(48,48));
d->contentSwitcher->setShape(QTabBar::RoundedSouth);
connect( d->contentSwitcher , SIGNAL(currentChanged(int)) , d->contentArea ,
@@ -258,10 +259,8 @@
layout->addWidget(d->contentSwitcher);
setLayout(layout);
+}
- // focus the search bar ready for typing
- d->searchBar->setFocus();
-}
QSize Launcher::sizeHint() const
{
// TODO This is essentially an arbitrarily chosen height which works
@@ -297,14 +296,27 @@
d->contentSwitcher->setCurrentIndex(0);
d->contentArea->setCurrentWidget(d->favoritesView);
}
+
bool Launcher::eventFilter(QObject *object, QEvent *event)
{
// deliver unhandled key presses from the search bar
// (mainly arrow keys, enter) to the active view
- if (object == d->searchBar && event->type() == QEvent::KeyPress) {
+ if ((object == d->contentSwitcher || object == d->searchBar) && event->type() == \
QEvent::KeyPress) { + // we want left/right to still nav the tabbar
+ QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+ if (keyEvent->key() == Qt::Key_Left ||
+ keyEvent->key() == Qt::Key_Right) {
+ if (object == d->contentSwitcher) {
+ return false;
+ } else {
+ QCoreApplication::sendEvent(d->contentSwitcher, event);
+ return true;
+ }
+ }
+
QAbstractItemView *activeView = \
qobject_cast<QAbstractItemView*>(d->contentArea->currentWidget()); if (activeView) {
- QCoreApplication::sendEvent(activeView,event);
+ QCoreApplication::sendEvent(activeView, event);
return true;
}
}
@@ -352,8 +364,11 @@
d->contextMenuFactory->showContextMenu(view,d->contentArea->mapFromParent(pos));
}
}
-void Launcher::keyPressEvent(QKeyEvent *)
+void Launcher::keyPressEvent(QKeyEvent *event)
{
+ if (event->key() == Qt::Key_Escape) {
+ hide();
+ }
#if 0
// allow tab switching by pressing the left or right arrow keys
if (event->key() == Qt::Key_Left && d->contentSwitcher->currentIndex() > 0) {
@@ -364,6 +379,13 @@
}
#endif
}
+
+void Launcher::showEvent(QShowEvent *)
+{
+ // focus the search bar ready for typing
+ d->searchBar->setFocus();
+}
+
void Launcher::paintEvent(QPaintEvent*)
{
// TODO - Draw a pretty background here
--- trunk/KDE/kdebase/workspace/plasma/applets/kickoff/ui/launcher.h #728733:728734
@@ -50,6 +50,7 @@
protected:
virtual void keyPressEvent(QKeyEvent *event);
+ virtual void showEvent(QShowEvent *event);
virtual void paintEvent(QPaintEvent *event);
private Q_SLOTS:
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic