diff options
Diffstat (limited to 'src/mainwindow')
-rw-r--r-- | src/mainwindow/mainwindow.cpp | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index e885513..27279c1 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -113,8 +113,9 @@ MainWindow::MainWindow(std::shared_ptr<Configuration> &config, QWidget *parent) }); // search box - auto *searchShortcut = new QShortcut(QKeySequence(config->value<std::string>("mainwindow.shortcuts.search").value().c_str()), this); - connect(searchShortcut, &QShortcut::activated, this, [=]() { + auto *searchAction = new QAction(this); + m_config->setShortcut(searchAction, "mainwindow.shortcuts.search"); + connect(searchAction, &QAction::triggered, this, [=]() { /* QTBUG-18665 * When focusing out of the search box and hiding it, the first * (or earlier?) subwindow gets activated for some reason. @@ -127,6 +128,7 @@ MainWindow::MainWindow(std::shared_ptr<Configuration> &config, QWidget *parent) searchBox->show(); } }); + QMainWindow::addAction(searchAction); } MainWindow::~MainWindow() @@ -142,34 +144,44 @@ void MainWindow::createMenuBar() { Q_CHECK_PTR(mdiArea); + // smolbote menu auto *smolboteMenu = menuBar()->addMenu(qApp->applicationDisplayName()); - smolboteMenu->addAction(tr("New subwindow"), this, [this]() { + + auto *subwindowAction = smolboteMenu->addAction(tr("New subwindow"), this, [this]() { createSubWindow(); - }, - QKeySequence(m_config->value<std::string>("mainwindow.shortcuts.newGroup").value().c_str())); + }); + m_config->setShortcut(subwindowAction, "mainwindow.shortcuts.newGroup"); - smolboteMenu->addAction(tr("New window"), this, []() { + auto *windowAction = smolboteMenu->addAction(tr("New window"), this, []() { auto *browser = qobject_cast<Browser *>(qApp); if(browser) browser->createWindow(); - }, - QKeySequence(m_config->value<std::string>("mainwindow.shortcuts.newWindow").value().c_str())); + }); + m_config->setShortcut(windowAction, "mainwindow.shortcuts.newWindow"); smolboteMenu->addSeparator(); - smolboteMenu->addAction(tr("About"), qobject_cast<Browser *>(qApp), &Browser::about, QKeySequence(m_config->value<std::string>("mainwindow.shortcuts.about").value().c_str())); + auto *aboutAction = smolboteMenu->addAction(tr("About"), qobject_cast<Browser *>(qApp), &Browser::about); + m_config->setShortcut(aboutAction, "mainwindow.shortcuts.about"); smolboteMenu->addAction(tr("About Qt"), qApp, &QApplication::aboutQt); smolboteMenu->addSeparator(); - smolboteMenu->addAction(tr("Quit"), qApp, &QApplication::quit, - QKeySequence(m_config->value<std::string>("mainwindow.shortcuts.quit").value().c_str())); + auto *quitAction = smolboteMenu->addAction(tr("Quit"), qApp, &QApplication::quit); + m_config->setShortcut(quitAction, "mainwindow.shortcuts.quit"); + // window menu auto *windowMenu = menuBar()->addMenu(tr("Window")); - windowMenu->addAction(tr("Tile windows"), mdiArea, &QMdiArea::tileSubWindows, QKeySequence(m_config->value<std::string>("mainwindow.shortcuts.tileWindows").value().c_str())); - windowMenu->addAction(tr("Cascade windows"), mdiArea, &QMdiArea::cascadeSubWindows, QKeySequence(m_config->value<std::string>("mainwindow.shortcuts.cascadeWindows").value().c_str())); + + auto *tileAction = windowMenu->addAction(tr("Tile windows"), mdiArea, &QMdiArea::tileSubWindows); + m_config->setShortcut(tileAction, "mainwindow.shortcuts.tileWindows"); + + auto *cascadeAction = windowMenu->addAction(tr("Cascade windows"), mdiArea, &QMdiArea::cascadeSubWindows); + m_config->setShortcut(cascadeAction, "mainwindow.shortcuts.cascadeWindows"); + subWindowAction = windowMenu->addAction(tr("Current window")); + // tools menu toolsMenu = menuBar()->addMenu(tr("Tools")); } |