1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

BookmarksSideBar: Get focus to search line when opening sidebar

- also addeed support for opening bookmarks with Enter
   * Enter - opens bookmark in current tab
   * Ctrl + Enter - opens bookmark in new tab
This commit is contained in:
nowrep 2012-09-02 15:53:00 +02:00
parent 2c57528d29
commit d5e21ab911
3 changed files with 26 additions and 0 deletions

View File

@ -30,6 +30,7 @@
#include <QTimer> #include <QTimer>
#include <QClipboard> #include <QClipboard>
#include <QSqlQuery> #include <QSqlQuery>
#include <QKeyEvent>
BookmarksSideBar::BookmarksSideBar(QupZilla* mainClass, QWidget* parent) BookmarksSideBar::BookmarksSideBar(QupZilla* mainClass, QWidget* parent)
: QWidget(parent) : QWidget(parent)
@ -233,6 +234,24 @@ void BookmarksSideBar::renameFolder(const QString &before, const QString &after)
item->setText(0, after); item->setText(0, after);
} }
void BookmarksSideBar::keyPressEvent(QKeyEvent* event)
{
if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) {
QTreeWidgetItem* item = ui->bookmarksTree->currentItem();
if (event->modifiers() & Qt::ControlModifier) {
itemControlClicked(item);
}
else {
itemDoubleClicked(item);
}
return;
}
QWidget::keyPressEvent(event);
}
void BookmarksSideBar::refreshTable() void BookmarksSideBar::refreshTable()
{ {
m_isRefreshing = true; m_isRefreshing = true;
@ -293,6 +312,8 @@ void BookmarksSideBar::refreshTable()
ui->bookmarksTree->setUpdatesEnabled(true); ui->bookmarksTree->setUpdatesEnabled(true);
m_isRefreshing = false; m_isRefreshing = false;
ui->search->setFocus();
} }
BookmarksSideBar::~BookmarksSideBar() BookmarksSideBar::~BookmarksSideBar()

View File

@ -62,6 +62,8 @@ private slots:
void renameFolder(const QString &before, const QString &after); void renameFolder(const QString &before, const QString &after);
private: private:
void keyPressEvent(QKeyEvent* event);
QupZilla* getQupZilla(); QupZilla* getQupZilla();
bool m_isRefreshing; bool m_isRefreshing;

View File

@ -31,6 +31,9 @@
</item> </item>
<item> <item>
<widget class="QToolButton" name="closeButton"> <widget class="QToolButton" name="closeButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>