mirror of
https://github.com/zealdocs/zeal.git
synced 2024-12-02 09:44:14 +03:00
Merge pull request #135 from ZiDoMs/iss71
Change focus on pressing enter
This commit is contained in:
commit
10cb243c53
@ -171,7 +171,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
// (Only the frame is larger than the list item, which is different from default behaviour.)
|
||||
ui->treeView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
#endif
|
||||
bool treeViewClicked = false;
|
||||
|
||||
connect(ui->treeView, &QTreeView::clicked, [&](const QModelIndex& index) {
|
||||
treeViewClicked = true;
|
||||
ui->treeView->activated(index);
|
||||
});
|
||||
connect(ui->treeView, &QTreeView::activated, [&](const QModelIndex& index) {
|
||||
@ -182,6 +185,11 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
url.setFragment(url_l[1]);
|
||||
}
|
||||
ui->webView->load(url);
|
||||
|
||||
if (!treeViewClicked)
|
||||
ui->webView->focus();
|
||||
else
|
||||
treeViewClicked = false;
|
||||
}
|
||||
});
|
||||
connect(ui->forwardButton, &QPushButton::clicked, this, &MainWindow::forward);
|
||||
@ -204,6 +212,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
});
|
||||
|
||||
connect(&zealSearch, &ZealSearchModel::queryCompleted, [&]() {
|
||||
treeViewClicked = true;
|
||||
|
||||
ui->treeView->setModel(&zealSearch);
|
||||
ui->treeView->reset();
|
||||
ui->treeView->setColumnHidden(1, true);
|
||||
|
@ -80,6 +80,11 @@ void SearchableWebView::load(const QUrl &url) {
|
||||
webView.load(url);
|
||||
}
|
||||
|
||||
void SearchableWebView::focus()
|
||||
{
|
||||
webView.setFocus();
|
||||
}
|
||||
|
||||
QWebPage * SearchableWebView::page() const {
|
||||
return webView.page();
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ class SearchableWebView : public QWidget
|
||||
public:
|
||||
explicit SearchableWebView(QWidget *parent = 0);
|
||||
void load(const QUrl& url);
|
||||
void focus();
|
||||
QSize sizeHint() const;
|
||||
QWebSettings * settings() const;
|
||||
QWebPage * page() const;
|
||||
|
@ -37,6 +37,11 @@ bool ZealSearchEdit::eventFilter(QObject *obj, QEvent *ev)
|
||||
return true;
|
||||
}
|
||||
|
||||
if(keyEvent->key() == Qt::Key_Return) {
|
||||
emit treeView->activated(treeView->selectionModel()->currentIndex());
|
||||
return true;
|
||||
}
|
||||
|
||||
if(keyEvent->key() == Qt::Key_Escape) {
|
||||
clearQuery();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user