1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-19 10:16:34 +01:00

[WebSearchBar] Ctrl+Up/Down for changing search engines.

Closes #1090
This commit is contained in:
nowrep 2013-11-21 18:23:11 +01:00
parent 479df003a0
commit a49e574f83
4 changed files with 40 additions and 0 deletions

View File

@ -15,6 +15,7 @@ Version 1.5.0
* pagescreen can now save output into number of formats, including PDF
* proxy exceptions now supports wildcards (*, ?)
* cancel upload when trying to upload non-readable files
* select previous / next engines with ctrl+up/down in websearchbar
* GreaseMonkey: added icon in statusbar
* GreaseMonkey: added support for GM_Settings
* GreaseMonkey: fixed userscripts when first loading plugin

View File

@ -377,6 +377,18 @@ void WebSearchBar::keyPressEvent(QKeyEvent* event)
}
break;
case Qt::Key_Up:
if (event->modifiers() == Qt::ControlModifier) {
m_boxSearchType->selectPreviousItem();
}
break;
case Qt::Key_Down:
if (event->modifiers() == Qt::ControlModifier) {
m_boxSearchType->selectNextItem();
}
break;
default:
break;
}

View File

@ -45,6 +45,24 @@ void ButtonWithMenu::clearItems()
m_items.clear();
}
void ButtonWithMenu::selectNextItem()
{
int index = m_items.indexOf(m_currentItem) + 1;
if (index < m_items.size()) {
setCurrentIndex(index);
}
}
void ButtonWithMenu::selectPreviousItem()
{
int index = m_items.indexOf(m_currentItem) - 1;
if (index > 0) {
setCurrentIndex(index);
}
}
void ButtonWithMenu::addItem(const Item &item)
{
m_items.append(item);
@ -99,6 +117,11 @@ void ButtonWithMenu::setCurrentItem(const Item &item, bool emitSignal)
}
}
void ButtonWithMenu::setCurrentIndex(int index, bool emitSignal)
{
setCurrentItem(m_items.at(index), emitSignal);
}
void ButtonWithMenu::wheelEvent(QWheelEvent* event)
{
int currItemIndex = m_items.indexOf(m_currentItem);

View File

@ -57,6 +57,7 @@ public:
void addItems(const QVector<Item> &items);
void removeItem(const Item &item);
void setCurrentItem(const Item &item, bool emitSignal = true);
void setCurrentIndex(int index, bool emitSignal = true);
Item currentItem();
QVector<Item> allItems() { return m_items; }
@ -70,6 +71,9 @@ signals:
public slots:
void clearItems();
void selectNextItem();
void selectPreviousItem();
private slots:
void setCurrentItem();
void generateMenu();