diff options
Diffstat (limited to 'src/mainwindow')
-rw-r--r-- | src/mainwindow/addressbar.cpp | 6 | ||||
-rw-r--r-- | src/mainwindow/mainwindow.cpp | 6 | ||||
-rw-r--r-- | src/mainwindow/menubar.cpp | 38 | ||||
-rw-r--r-- | src/mainwindow/widgets/completer.cpp | 2 | ||||
-rw-r--r-- | src/mainwindow/widgets/navigationbar.cpp | 8 | ||||
-rw-r--r-- | src/mainwindow/widgets/urllineedit.cpp | 4 |
6 files changed, 32 insertions, 32 deletions
diff --git a/src/mainwindow/addressbar.cpp b/src/mainwindow/addressbar.cpp index 42fa890..b1d005a 100644 --- a/src/mainwindow/addressbar.cpp +++ b/src/mainwindow/addressbar.cpp @@ -21,17 +21,17 @@ AddressBar::AddressBar(QWidget *parent) ui->urlBar->menuAction->setShortcut(QKeySequence(conf.value<QString>("shortcuts.address.menu").value())); auto *focusShortcut = new QShortcut(QKeySequence(conf.value<QString>("shortcuts.address.focus").value()), parent); - connect(focusShortcut, &QShortcut::activated, ui->urlBar, [=]() { + connect(focusShortcut, &QShortcut::activated, ui->urlBar, [this]() { ui->urlBar->setFocus(); ui->urlBar->selectAll(); }); - connect(ui->urlBar, &UrlLineEdit::textEdited, [=](const QString &text) { + connect(ui->urlBar, &UrlLineEdit::textEdited, [this](const QString &text) { std::function<void(QStringList &)> callback = std::bind(&UrlLineEdit::updateCompleter, ui->urlBar, std::placeholders::_1); emit complete(text, callback); }); - connect(ui->urlBar, &UrlLineEdit::returnPressed, [=]() { + connect(ui->urlBar, &UrlLineEdit::returnPressed, [this]() { const QUrl url = QUrl::fromUserInput(ui->urlBar->text()); // check if url contains \w+:// (matches protocol://) or contains a '.' (matches site.domain) diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index e03ec46..36f2759 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -56,7 +56,7 @@ MainWindow::MainWindow(QWidget *parent) { QAction *subwindowMenuAction = new QAction(this); QMainWindow::addAction(subwindowMenuAction); - setShortcut(subwindowMenuAction, "shortcuts.subwindow.menu"); + config.shortcut<QAction>(*subwindowMenuAction, "shortcuts.subwindow.menu"); connect(subwindowMenuAction, &QAction::triggered, this, [this]() { QMdiSubWindow *window = mdiArea->currentSubWindow(); if(window != nullptr) { @@ -131,8 +131,8 @@ MainWindow::MainWindow(QWidget *parent) // search box auto *searchAction = new QAction(this); - setShortcut(searchAction, "shortcuts.window.search"); - connect(searchAction, &QAction::triggered, this, [=]() { + config.shortcut<QAction>(*searchAction, "shortcuts.window.search"); + connect(searchAction, &QAction::triggered, this, [this]() { /* QTBUG-18665 * When focusing out of the search box and hiding it, the first * (or earlier?) subwindow gets activated for some reason. diff --git a/src/mainwindow/menubar.cpp b/src/mainwindow/menubar.cpp index b695a20..7a2bedc 100644 --- a/src/mainwindow/menubar.cpp +++ b/src/mainwindow/menubar.cpp @@ -73,6 +73,7 @@ MenuBar::MenuBar(MainWindow *parent) { auto *browser = qobject_cast<Browser *>(qApp); Q_CHECK_PTR(browser); + Configuration conf; smolbote = this->addMenu(qApp->applicationName()); { @@ -109,31 +110,30 @@ MenuBar::MenuBar(MainWindow *parent) smolbote->addSeparator(); - Configuration conf; const QString sessionPath = conf.value<QString>("session.path").value(); auto *actionSaveSession = smolbote->addAction(tr("Save Session"), parent, [sessionPath]() { auto *sessionDialog = new SaveSessionDialog(nullptr); if(sessionDialog->exec() == QDialog::Accepted) sessionDialog->save(sessionPath); }); - setShortcut(actionSaveSession, "shortcuts.session.save"); + conf.shortcut<QAction>(*actionSaveSession, "shortcuts.session.save"); auto *actionOpenSession = smolbote->addAction(tr("Open Session"), parent, [parent]() { auto *sessionDialog = new SessionDialog(parent); sessionDialog->exec(); }); - setShortcut(actionOpenSession, "shortcuts.session.open"); + conf.shortcut<QAction>(*actionOpenSession, "shortcuts.session.open"); smolbote->addSeparator(); auto *actionBookmarks = smolbote->addAction(tr("Bookmarks"), browser, [browser, parent]() { browser->showWidget(browser->bookmarks(), parent); }); - setShortcut(actionBookmarks, "shortcuts.window.bookmarks.show"); + conf.shortcut<QAction>(*actionBookmarks, "shortcuts.window.bookmarks.show"); auto *actionDownloads = smolbote->addAction(tr("Downloads"), browser, [browser, parent]() { browser->showWidget(browser->downloads(), parent); }); - setShortcut(actionDownloads, "shortcuts.window.downloads.show"); + conf.shortcut<QAction>(*actionDownloads, "shortcuts.window.downloads.show"); smolbote->addSeparator(); smolbote->addAction(tr("Load Plugin"), browser, [browser]() { @@ -144,29 +144,29 @@ MenuBar::MenuBar(MainWindow *parent) pluginInsertLocation = smolbote->addSeparator(); auto *actionAbout = smolbote->addAction(tr("About"), browser, &Browser::about); - setShortcut(actionAbout, "shortcuts.window.about"); + conf.shortcut<QAction>(*actionAbout, "shortcuts.window.about"); smolbote->addSeparator(); auto *actionQuit = smolbote->addAction(tr("Quit"), qApp, &QApplication::quit); - setShortcut(actionQuit, "shortcuts.window.quit"); + conf.shortcut<QAction>(*actionQuit, "shortcuts.window.quit"); } window = this->addMenu(tr("&Window")); { auto *actionNewWindow = window->addAction(tr("New Window"), browser, &Browser::createWindow); - setShortcut(actionNewWindow, "shortcuts.window.newwindow"); + conf.shortcut<QAction>(*actionNewWindow, "shortcuts.window.newwindow"); auto *actionNewSubwindow = window->addAction(tr("New Subwindow"), parent, [parent]() { parent->createSubWindow(nullptr, true); }); - setShortcut(actionNewSubwindow, "shortcuts.window.newgroup"); + conf.shortcut<QAction>(*actionNewSubwindow, "shortcuts.window.newgroup"); auto *actionTileSubwindows = window->addAction(tr("Tile Subwindows"), parent->mdiArea, &QMdiArea::tileSubWindows); - setShortcut(actionTileSubwindows, "shortcuts.subwindow.tile"); + conf.shortcut<QAction>(*actionTileSubwindows, "shortcuts.subwindow.tile"); auto *actionCascadeSubwindows = window->addAction(tr("Cascade Subwindows"), parent->mdiArea, &QMdiArea::cascadeSubWindows); - setShortcut(actionCascadeSubwindows, "shortcuts.subwindow.cascade"); + conf.shortcut<QAction>(*actionCascadeSubwindows, "shortcuts.subwindow.cascade"); window->addSeparator()->setText(tr("Toolbars")); @@ -178,7 +178,7 @@ MenuBar::MenuBar(MainWindow *parent) action->setChecked(toolbar->isVisible()); connect(toolbar, &QToolBar::visibilityChanged, action, &QAction::setChecked); connect(action, &QAction::triggered, toolbar, &QToolBar::setVisible); - setShortcut(action, qUtf8Printable(toolbar->objectName() + ".show")); + conf.shortcut<QAction>(*action, qUtf8Printable(toolbar->objectName() + ".show")); if(toolbar->isMovable()) hasMovableToolbar = true; @@ -204,7 +204,7 @@ MenuBar::MenuBar(MainWindow *parent) _subwindow->setCurrentTab(index); }); }); - setShortcut(actionNewTab, "shortcuts.subwindow.newtab"); + conf.shortcut<QAction>(*actionNewTab, "shortcuts.subwindow.newtab"); subwindow->addSeparator(); @@ -214,7 +214,7 @@ MenuBar::MenuBar(MainWindow *parent) _subwindow->setCurrentTab(index); }); }); - setShortcut(actionRestoreTab, "shortcuts.subwindow.restoretab"); + conf.shortcut<QAction>(*actionRestoreTab, "shortcuts.subwindow.restoretab"); auto *restoreTabsMenu = subwindow->addMenu(tr("Restore previous tab")); connect(restoreTabsMenu, &QMenu::aboutToShow, parent, [parent, restoreTabsMenu]() { @@ -264,28 +264,28 @@ MenuBar::MenuBar(MainWindow *parent) _subwindow->setCurrentTab(qMax(0, currentIdx - 1)); }); }); - setShortcut(leftTab, "shortcuts.subwindow.tableft"); + conf.shortcut<QAction>(*leftTab, "shortcuts.subwindow.tableft"); auto *moveTabLeft = subwindow->addAction(tr("Move tab left"), parent, [parent]() { run_if(parent->currentSubWindow(), [](SubWindow *_subwindow, int currentIdx) { _subwindow->moveTab(currentIdx, currentIdx - 1); }); }); - setShortcut(moveTabLeft, "shortcuts.subwindow.movetableft"); + conf.shortcut<QAction>(*moveTabLeft, "shortcuts.subwindow.movetableft"); auto *rightTab = subwindow->addAction(tr("Switch to tab on the right"), parent, [parent]() { run_if(parent->currentSubWindow(), [](SubWindow *_subwindow, int currentIdx) { _subwindow->setCurrentTab(qMin(currentIdx + 1, _subwindow->tabCount() - 1)); }); }); - setShortcut(rightTab, "shortcuts.subwindow.tabright"); + conf.shortcut<QAction>(*rightTab, "shortcuts.subwindow.tabright"); auto *moveTabRight = subwindow->addAction(tr("Move tab right"), parent, [parent]() { run_if(parent->currentSubWindow(), [](SubWindow *_subwindow, int currentIdx) { _subwindow->moveTab(currentIdx, currentIdx + 1); }); }); - setShortcut(moveTabRight, "shortcuts.subwindow.movetabright"); + conf.shortcut<QAction>(*moveTabRight, "shortcuts.subwindow.movetabright"); subwindow->addSeparator(); @@ -294,7 +294,7 @@ MenuBar::MenuBar(MainWindow *parent) _subwindow->closeTab(currentIdx); }); }); - setShortcut(closeTab, "shortcuts.subwindow.closetab"); + conf.shortcut<QAction>(*closeTab, "shortcuts.subwindow.closetab"); subwindow->addAction(tr("Close tabs to the left"), parent, [parent]() { run_if(parent->currentSubWindow(), [](SubWindow *_subwindow, int currentIdx) { diff --git a/src/mainwindow/widgets/completer.cpp b/src/mainwindow/widgets/completer.cpp index 1295fa3..15cc8b1 100644 --- a/src/mainwindow/widgets/completer.cpp +++ b/src/mainwindow/widgets/completer.cpp @@ -16,7 +16,7 @@ Completer::Completer(QWidget *parent) setWindowFlags(Qt::ToolTip); setEditTriggers(QAbstractItemView::NoEditTriggers); - connect(this, &Completer::activated, [=](const QModelIndex &index) { + connect(this, &Completer::activated, [this](const QModelIndex &index) { hide(); emit completionActivated(index.data().toString()); }); diff --git a/src/mainwindow/widgets/navigationbar.cpp b/src/mainwindow/widgets/navigationbar.cpp index 725003d..799ebec 100644 --- a/src/mainwindow/widgets/navigationbar.cpp +++ b/src/mainwindow/widgets/navigationbar.cpp @@ -29,7 +29,7 @@ NavigationBar::NavigationBar(QWidget *parent) // Back button backAction = addAction(Util::icon(QStyle::SP_ArrowBack), tr("Back")); - setShortcut(backAction, "shortcuts.navigation.back"); + config.shortcut<QAction>(*backAction, "shortcuts.navigation.back"); connect(backAction, &QAction::triggered, this, [this]() { m_view->history()->back(); }); @@ -57,7 +57,7 @@ NavigationBar::NavigationBar(QWidget *parent) // Forward button forwardAction = addAction(Util::icon(QStyle::SP_ArrowForward), tr("Forward")); - setShortcut(forwardAction, "shortcuts.navigation.forward"); + config.shortcut<QAction>(*forwardAction, "shortcuts.navigation.forward"); connect(forwardAction, &QAction::triggered, this, [this]() { m_view->history()->forward(); }); @@ -85,7 +85,7 @@ NavigationBar::NavigationBar(QWidget *parent) // Stop/Refresh button stopReloadAction = addAction(Util::icon(QStyle::SP_BrowserReload), tr("Refresh")); - setShortcut(stopReloadAction, "shortcuts.navigation.refresh"); + config.shortcut<QAction>(*stopReloadAction, "shortcuts.navigation.refresh"); connect(stopReloadAction, &QAction::triggered, this, [this]() { if(m_view->isLoaded()) m_view->reload(); @@ -100,7 +100,7 @@ NavigationBar::NavigationBar(QWidget *parent) // Home button homeAction = addAction(Util::icon(QStyle::SP_DirHomeIcon), tr("Home")); - setShortcut(homeAction, "shortcuts.navigation.home"); + config.shortcut<QAction>(*homeAction, "shortcuts.navigation.home"); connect(homeAction, &QAction::triggered, this, [this]() { m_view->load(m_view->profile()->homepage()); }); diff --git a/src/mainwindow/widgets/urllineedit.cpp b/src/mainwindow/widgets/urllineedit.cpp index 378945f..5216f31 100644 --- a/src/mainwindow/widgets/urllineedit.cpp +++ b/src/mainwindow/widgets/urllineedit.cpp @@ -40,13 +40,13 @@ UrlLineEdit::UrlLineEdit(QWidget *parent) actions.append(pasteAction); auto *loadAction = new QAction(tr("Paste and load"), this); - connect(loadAction, &QAction::triggered, this, [=]() { + connect(loadAction, &QAction::triggered, this, [this]() { emit addressbar->load(QUrl::fromUserInput(qApp->clipboard()->text())); }); actions.append(loadAction); auto *searchAction = new QAction(tr("Paste and search"), this); - connect(searchAction, &QAction::triggered, this, [=]() { + connect(searchAction, &QAction::triggered, this, [this]() { emit addressbar->search(qApp->clipboard()->text()); }); actions.append(searchAction); |