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/mainwindow.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/mainwindow.cpp') 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()); -- cgit v1.2.1