diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-12-18 22:25:40 +0100 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-12-18 22:25:40 +0100 |
commit | 5fc206e11ea83a31e64a0359dc6d78f76d200499 (patch) | |
tree | a997cb1602599766fdaa908453ae2705e0a0691f /src | |
parent | Basic adblock FilterRule (diff) | |
download | smolbote-5fc206e11ea83a31e64a0359dc6d78f76d200499.tar.xz |
Some bugfixes
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/navigation/urllineedit.cpp | 6 | ||||
-rw-r--r-- | src/mainwindow.cpp | 21 | ||||
-rw-r--r-- | src/widgets/webviewtabbar.cpp | 10 | ||||
-rw-r--r-- | src/widgets/webviewtabbar.h | 4 |
4 files changed, 27 insertions, 14 deletions
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<Configuration> 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<Configuration> 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<std::string>("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<Configuration> config, QWidget *parent) : // shortcuts QAction *focusAddressAction = new QAction(this); + focusAddressAction->setShortcut(QKeySequence(QString::fromStdString(m_config->value<std::string>("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<int>("browser.window.width").value(), m_config->value<int>("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 <QAction> #include <QContextMenuEvent> #include <QMenu> - +#include <settings/configuration.h> #include <QShortcut> -WebViewTabBar::WebViewTabBar(WebEngineProfile *profile, QWidget *parent) : +WebViewTabBar::WebViewTabBar(const std::shared_ptr<Configuration> &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<std::string>("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<std::string>("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<std::string>("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 <QTabBar> #include "webengine/webview.h" #include "webengine/webengineprofile.h" +#include <memory> +class Configuration; class WebViewTabBar : public QTabBar { Q_OBJECT public: - explicit WebViewTabBar(WebEngineProfile *profile = nullptr, QWidget *parent = 0); + explicit WebViewTabBar(const std::shared_ptr<Configuration> &config, WebEngineProfile *profile = nullptr, QWidget *parent = 0); ~WebViewTabBar(); void setProfile(WebEngineProfile *profile); |