From 5fc206e11ea83a31e64a0359dc6d78f76d200499 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Mon, 18 Dec 2017 22:25:40 +0100 Subject: Some bugfixes --- src/lib/navigation/urllineedit.cpp | 6 +++++- src/mainwindow.cpp | 21 ++++++++++++++------- src/widgets/webviewtabbar.cpp | 10 +++++----- src/widgets/webviewtabbar.h | 4 +++- 4 files changed, 27 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/lib/navigation/urllineedit.cpp b/src/lib/navigation/urllineedit.cpp index c587f43..f40d240 100644 --- a/src/lib/navigation/urllineedit.cpp +++ b/src/lib/navigation/urllineedit.cpp @@ -80,7 +80,11 @@ UrlLineEdit::UrlLineEdit(QWidget *parent) : // connect signals connect(this, SIGNAL(textEdited(QString)), this, SLOT(showCompleter(QString))); connect(this, &QLineEdit::returnPressed, [this]() { - emit addressEntered(QUrl::fromUserInput(this->text())); + if(this->text().startsWith('#')) { + emit searchTermEntered(this->text().mid(1)); + } else { + emit addressEntered(QUrl::fromUserInput(this->text())); + } m_menu->hide(); this->clearFocus(); }); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 16e0ed0..3dbcbdf 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -44,7 +44,7 @@ MainWindow::MainWindow(std::shared_ptr config, QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), - tabBar(new WebViewTabBar(nullptr, this)), + tabBar(new WebViewTabBar(config, nullptr, this)), menuBar(new MainWindowMenuBar(config, this)), m_addressBar(new UrlLineEdit(this)), m_progressBar(new LoadingBar(this)) @@ -101,11 +101,13 @@ MainWindow::MainWindow(std::shared_ptr config, QWidget *parent) : connect(m_addressBar, &UrlLineEdit::addressEntered, this, [&](const QUrl &url) { tabBar->currentView()->load(url); }); -// connect(m_addressBar, &AddressBar::searchTermEntered, this, [&](const QString &string) { -// QString term = string.mid(1); -// term.replace(' ', '+'); -// //tabBar->currentView()->load(QUrl::fromUserInput(browser->settings()->value("general.search").toString().replace("$term", term))); -// }); + connect(m_addressBar, &UrlLineEdit::searchTermEntered, this, [&](const QString &term) { + QString t = term; + t.replace(' ', '+'); + QString url = QString::fromStdString(m_config->value("profile.search").value()); + url.replace("$term", t); + tabBar->currentView()->load(QUrl::fromUserInput(url)); + }); connect(tabBar, SIGNAL(currentTabChanged(WebView*)), this, SLOT(handleTabChanged(WebView*))); // loading bar @@ -113,8 +115,13 @@ MainWindow::MainWindow(std::shared_ptr config, QWidget *parent) : // shortcuts QAction *focusAddressAction = new QAction(this); + focusAddressAction->setShortcut(QKeySequence(QString::fromStdString(m_config->value("browser.shortcuts.focusAddress").value()))); //focusAddressAction->setShortcut(QKeySequence::fromString(browser->settings()->value("window.shortcuts.focusAddress").toString())); - connect(focusAddressAction, SIGNAL(triggered(bool)), this, SLOT(focusAddress())); + //connect(focusAddressAction, SIGNAL(triggered(bool)), this, SLOT(focusAddress())); + connect(focusAddressAction, &QAction::triggered, this, [this]() { + m_addressBar->setFocus(); + m_addressBar->selectAll(); + }); addAction(focusAddressAction); resize(m_config->value("browser.window.width").value(), m_config->value("browser.window.height").value()); diff --git a/src/widgets/webviewtabbar.cpp b/src/widgets/webviewtabbar.cpp index 0baf68a..81851f3 100644 --- a/src/widgets/webviewtabbar.cpp +++ b/src/widgets/webviewtabbar.cpp @@ -22,10 +22,10 @@ #include #include #include - +#include #include -WebViewTabBar::WebViewTabBar(WebEngineProfile *profile, QWidget *parent) : +WebViewTabBar::WebViewTabBar(const std::shared_ptr &config, WebEngineProfile *profile, QWidget *parent) : QTabBar(parent) { m_profile = profile; @@ -39,19 +39,19 @@ WebViewTabBar::WebViewTabBar(WebEngineProfile *profile, QWidget *parent) : connect(this, SIGNAL(tabMoved(int,int)), this, SLOT(updateVectorArrangement(int,int))); QShortcut *tabCloseShortcut = new QShortcut(this); - //tabCloseShortcut->setKey(QKeySequence::fromString(browser->settings()->value("window.shortcuts.tabClose").toString())); + tabCloseShortcut->setKey(QKeySequence(QString::fromStdString(config->value("browser.shortcuts.tabClose").value()))); connect(tabCloseShortcut, &QShortcut::activated, [this]() { this->removeTab(currentIndex()); }); QShortcut *tabLeftShortcut = new QShortcut(this); - //tabLeftShortcut->setKey(QKeySequence::fromString(browser->settings()->value("window.shortcuts.tabLeft").toString())); + tabLeftShortcut->setKey(QKeySequence(QString::fromStdString(config->value("browser.shortcuts.tabLeft").value()))); connect(tabLeftShortcut, &QShortcut::activated, [this]() { this->setCurrentIndex(currentIndex()-1); }); QShortcut *tabRightShortcut = new QShortcut(this); - //tabRightShortcut->setKey(QKeySequence::fromString(browser->settings()->value("window.shortcuts.tabRight").toString())); + tabRightShortcut->setKey(QKeySequence(QString::fromStdString(config->value("browser.shortcuts.tabRight").value()))); connect(tabRightShortcut, &QShortcut::activated, [this]() { this->setCurrentIndex(currentIndex()+1); }); diff --git a/src/widgets/webviewtabbar.h b/src/widgets/webviewtabbar.h index d73608c..64bb6a2 100644 --- a/src/widgets/webviewtabbar.h +++ b/src/widgets/webviewtabbar.h @@ -24,13 +24,15 @@ #include #include "webengine/webview.h" #include "webengine/webengineprofile.h" +#include +class Configuration; class WebViewTabBar : public QTabBar { Q_OBJECT public: - explicit WebViewTabBar(WebEngineProfile *profile = nullptr, QWidget *parent = 0); + explicit WebViewTabBar(const std::shared_ptr &config, WebEngineProfile *profile = nullptr, QWidget *parent = 0); ~WebViewTabBar(); void setProfile(WebEngineProfile *profile); -- cgit v1.2.1