[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/krunner/interfaces/default
From: Aaron J. Seigo <aseigo () kde ! org>
Date: 2010-08-26 18:28:31
Message-ID: 20100826182831.13B71AC857 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1168469 by aseigo:
IMPROVEMENT: support arrow up/down key nav
BUG:245736
M +17 -1 interface.cpp
M +6 -26 resultscene.cpp
--- trunk/KDE/kdebase/workspace/krunner/interfaces/default/interface.cpp #1168468:1168469
@@ -162,6 +162,7 @@
connect(m_singleRunnerSearchTerm, SIGNAL(returnPressed()), this, SLOT(runDefaultResultItem()));
lineEdit->installEventFilter(this);
+ m_searchTerm->installEventFilter(this);
themeUpdated();
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(themeUpdated()));
@@ -208,13 +209,28 @@
bool Interface::eventFilter(QObject *obj, QEvent *event)
{
- if (event->type() == QEvent::MouseButtonPress) {
+ if (obj == m_searchTerm->lineEdit() && event->type() == QEvent::MouseButtonPress) {
if (KWindowSystem::activeWindow() != winId()) {
// this overcomes problems with click-to-focus and being a Dock window
KWindowSystem::forceActiveWindow(winId());
searchTermSetFocus();
}
+ } else if (obj == m_searchTerm && event->type() == QEvent::KeyPress) {
+ QKeyEvent *ke = static_cast<QKeyEvent *>(event);
+ // the comparision between itemText(1) and the currentText is an artifact
+ // of KHistoryComboBox: it sets the combobox to index 1 when using arrow-down
+ // through entries after having arrow-up'd through them and hitting the
+ // last item ... which one would expect to be index 0. index 1 is _also_
+ // the first item in the history at other times, however, so we need to
+ // check if index 1 is indeed the actual item or if item 1 is not the same
+ // the current text. very, very odd. but it works. - aseigo.
+ if (ke->key() == Qt::Key_Down &&
+ (m_searchTerm->currentIndex() < 1 ||
+ (m_searchTerm->currentIndex() == 1 &&
+ m_searchTerm->itemText(1) != m_searchTerm->currentText()))) {
+ m_resultsView->setFocus();
}
+ }
return KRunnerDialog::eventFilter(obj, event);
}
--- trunk/KDE/kdebase/workspace/krunner/interfaces/default/resultscene.cpp #1168468:1168469
@@ -309,25 +309,14 @@
ResultItem *currentFocus = currentlyFocusedItem();
int currentIndex = currentFocus ? currentFocus->index() : 0;
- bool wrapped = false;
- if (currentIndex > 0) {
- currentFocus = m_items.at(currentIndex - 1);
- } else {
- currentIndex = m_items.size();
- do {
- currentFocus = m_items.at(--currentIndex);
- } while (currentIndex > 0 && !currentFocus->isVisible());
- wrapped = currentIndex > 2;
+ if (currentIndex == 0) {
+ m_focusBase->setFocus();
+ return;
}
- if (currentFocus->isVisible()) {
- if (wrapped) {
- // with more than two items, having the selection zoom through the items between looks
- // odd
- m_selectionBar->setTargetItem(0);
- currentFocus->highlight(true);
- }
+ currentFocus = m_items.at(currentIndex - 1);
+ if (currentFocus->isVisible()) {
setFocusItem(currentFocus);
emit ensureVisibility(currentFocus);
}
@@ -337,25 +326,16 @@
{
ResultItem *currentFocus = currentlyFocusedItem();
int currentIndex = currentFocus ? currentFocus->index() : 0;
- const int wasIndex = currentIndex;
- bool wrapped = false;
do {
++currentIndex;
if (currentIndex >= m_items.size()) {
- // with more than two items, having the selection zoom through the items between looks
- // odd
- wrapped = wasIndex > 2;
- currentIndex = 0;
+ return;
}
currentFocus = m_items.at(currentIndex);
} while (!currentFocus->isVisible() && currentIndex < m_items.size());
if (currentFocus->isVisible()) {
- if (wrapped) {
- m_selectionBar->setTargetItem(0);
- currentFocus->highlight(true);
- }
setFocusItem(currentFocus);
emit ensureVisibility(currentFocus);
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic