1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 17:52:10 +02: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 * pagescreen can now save output into number of formats, including PDF
* proxy exceptions now supports wildcards (*, ?) * proxy exceptions now supports wildcards (*, ?)
* cancel upload when trying to upload non-readable files * 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 icon in statusbar
* GreaseMonkey: added support for GM_Settings * GreaseMonkey: added support for GM_Settings
* GreaseMonkey: fixed userscripts when first loading plugin * GreaseMonkey: fixed userscripts when first loading plugin

View File

@ -377,6 +377,18 @@ void WebSearchBar::keyPressEvent(QKeyEvent* event)
} }
break; 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: default:
break; break;
} }

View File

@ -45,6 +45,24 @@ void ButtonWithMenu::clearItems()
m_items.clear(); 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) void ButtonWithMenu::addItem(const Item &item)
{ {
m_items.append(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) void ButtonWithMenu::wheelEvent(QWheelEvent* event)
{ {
int currItemIndex = m_items.indexOf(m_currentItem); int currItemIndex = m_items.indexOf(m_currentItem);

View File

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