diff --git a/src/ui/mainwindow.cc b/src/ui/mainwindow.cc index b9042cef..d0fba9d1 100644 --- a/src/ui/mainwindow.cc +++ b/src/ui/mainwindow.cc @@ -382,21 +382,31 @@ MainWindow::MainWindow( Config::Class & cfg_ ): trayIconMenu.addSeparator(); connect( trayIconMenu.addAction( tr( "&Quit" ) ), &QAction::triggered, this, &MainWindow::quitApp ); - addGlobalAction( &escAction, SLOT( handleEsc() ) ); + addGlobalAction( &escAction, [ this ]() { + handleEsc(); + } ); escAction.setShortcut( QKeySequence( "Esc" ) ); - addGlobalAction( &focusTranslateLineAction, SLOT( focusTranslateLine() ) ); + addGlobalAction( &focusTranslateLineAction, [ this ]() { + focusTranslateLine(); + } ); focusTranslateLineAction.setShortcuts( QList< QKeySequence >() << QKeySequence( "Alt+D" ) << QKeySequence( "Ctrl+L" ) ); - addGlobalAction( &focusHeadwordsDlgAction, SLOT( focusHeadwordsDialog() ) ); + addGlobalAction( &focusHeadwordsDlgAction, [ this ]() { + focusHeadwordsDialog(); + } ); focusHeadwordsDlgAction.setShortcut( QKeySequence( "Ctrl+D" ) ); - addGlobalAction( &focusArticleViewAction, SLOT( focusArticleView() ) ); + addGlobalAction( &focusArticleViewAction, [ this ]() { + focusArticleView(); + } ); focusArticleViewAction.setShortcut( QKeySequence( "Ctrl+N" ) ); - addGlobalAction( ui.fullTextSearchAction, SLOT( showFullTextSearchDialog() ) ); + addGlobalAction( ui.fullTextSearchAction, [ this ]() { + showFullTextSearchDialog(); + } ); addTabAction.setShortcutContext( Qt::WidgetWithChildrenShortcut ); addTabAction.setShortcut( QKeySequence( "Ctrl+T" ) ); @@ -1122,10 +1132,10 @@ MainWindow::~MainWindow() #endif } -void MainWindow::addGlobalAction( QAction * action, const char * slot ) +void MainWindow::addGlobalAction( QAction * action, const std::function< void() > & slotFunc ) { action->setShortcutContext( Qt::WidgetWithChildrenShortcut ); - connect( action, SIGNAL( triggered() ), this, slot ); + connect( action, &QAction::triggered, this, slotFunc ); ui.centralWidget->addAction( action ); ui.dictsPane->addAction( action ); diff --git a/src/ui/mainwindow.hh b/src/ui/mainwindow.hh index 569b2ddb..ef2f746d 100644 --- a/src/ui/mainwindow.hh +++ b/src/ui/mainwindow.hh @@ -10,6 +10,7 @@ #include #include #include +#include #include "ui_mainwindow.h" #include "config.hh" #include "dict/dictionary.hh" @@ -68,7 +69,7 @@ public slots: void quitApp(); private: - void addGlobalAction( QAction * action, const char * slot ); + void addGlobalAction( QAction * action, const std::function< void() > & slotFunc ); void addGlobalActionsToDialog( QDialog * dialog ); void addGroupComboBoxActionsToDialog( QDialog * dialog, GroupComboBox * pGroupComboBox ); void removeGroupComboBoxActionsFromDialog( QDialog * dialog, GroupComboBox * pGroupComboBox );