mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 08:34:08 +00:00
Merge pull request #849 from shenlebantongying/no_SIGNAL
clean: convert `MainWindow::addGlobalAction` SLOT to new syntax
This commit is contained in:
commit
4722193048
|
@ -382,21 +382,31 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
||||||
trayIconMenu.addSeparator();
|
trayIconMenu.addSeparator();
|
||||||
connect( trayIconMenu.addAction( tr( "&Quit" ) ), &QAction::triggered, this, &MainWindow::quitApp );
|
connect( trayIconMenu.addAction( tr( "&Quit" ) ), &QAction::triggered, this, &MainWindow::quitApp );
|
||||||
|
|
||||||
addGlobalAction( &escAction, SLOT( handleEsc() ) );
|
addGlobalAction( &escAction, [ this ]() {
|
||||||
|
handleEsc();
|
||||||
|
} );
|
||||||
escAction.setShortcut( QKeySequence( "Esc" ) );
|
escAction.setShortcut( QKeySequence( "Esc" ) );
|
||||||
|
|
||||||
addGlobalAction( &focusTranslateLineAction, SLOT( focusTranslateLine() ) );
|
addGlobalAction( &focusTranslateLineAction, [ this ]() {
|
||||||
|
focusTranslateLine();
|
||||||
|
} );
|
||||||
focusTranslateLineAction.setShortcuts( QList< QKeySequence >() <<
|
focusTranslateLineAction.setShortcuts( QList< QKeySequence >() <<
|
||||||
QKeySequence( "Alt+D" ) <<
|
QKeySequence( "Alt+D" ) <<
|
||||||
QKeySequence( "Ctrl+L" ) );
|
QKeySequence( "Ctrl+L" ) );
|
||||||
|
|
||||||
addGlobalAction( &focusHeadwordsDlgAction, SLOT( focusHeadwordsDialog() ) );
|
addGlobalAction( &focusHeadwordsDlgAction, [ this ]() {
|
||||||
|
focusHeadwordsDialog();
|
||||||
|
} );
|
||||||
focusHeadwordsDlgAction.setShortcut( QKeySequence( "Ctrl+D" ) );
|
focusHeadwordsDlgAction.setShortcut( QKeySequence( "Ctrl+D" ) );
|
||||||
|
|
||||||
addGlobalAction( &focusArticleViewAction, SLOT( focusArticleView() ) );
|
addGlobalAction( &focusArticleViewAction, [ this ]() {
|
||||||
|
focusArticleView();
|
||||||
|
} );
|
||||||
focusArticleViewAction.setShortcut( QKeySequence( "Ctrl+N" ) );
|
focusArticleViewAction.setShortcut( QKeySequence( "Ctrl+N" ) );
|
||||||
|
|
||||||
addGlobalAction( ui.fullTextSearchAction, SLOT( showFullTextSearchDialog() ) );
|
addGlobalAction( ui.fullTextSearchAction, [ this ]() {
|
||||||
|
showFullTextSearchDialog();
|
||||||
|
} );
|
||||||
|
|
||||||
addTabAction.setShortcutContext( Qt::WidgetWithChildrenShortcut );
|
addTabAction.setShortcutContext( Qt::WidgetWithChildrenShortcut );
|
||||||
addTabAction.setShortcut( QKeySequence( "Ctrl+T" ) );
|
addTabAction.setShortcut( QKeySequence( "Ctrl+T" ) );
|
||||||
|
@ -1122,10 +1132,10 @@ MainWindow::~MainWindow()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::addGlobalAction( QAction * action, const char * slot )
|
void MainWindow::addGlobalAction( QAction * action, const std::function< void() > & slotFunc )
|
||||||
{
|
{
|
||||||
action->setShortcutContext( Qt::WidgetWithChildrenShortcut );
|
action->setShortcutContext( Qt::WidgetWithChildrenShortcut );
|
||||||
connect( action, SIGNAL( triggered() ), this, slot );
|
connect( action, &QAction::triggered, this, slotFunc );
|
||||||
|
|
||||||
ui.centralWidget->addAction( action );
|
ui.centralWidget->addAction( action );
|
||||||
ui.dictsPane->addAction( action );
|
ui.dictsPane->addAction( action );
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QProgressDialog>
|
#include <QProgressDialog>
|
||||||
|
#include <functional>
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include "config.hh"
|
#include "config.hh"
|
||||||
#include "dict/dictionary.hh"
|
#include "dict/dictionary.hh"
|
||||||
|
@ -68,7 +69,7 @@ public slots:
|
||||||
void quitApp();
|
void quitApp();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addGlobalAction( QAction * action, const char * slot );
|
void addGlobalAction( QAction * action, const std::function< void() > & slotFunc );
|
||||||
void addGlobalActionsToDialog( QDialog * dialog );
|
void addGlobalActionsToDialog( QDialog * dialog );
|
||||||
void addGroupComboBoxActionsToDialog( QDialog * dialog, GroupComboBox * pGroupComboBox );
|
void addGroupComboBoxActionsToDialog( QDialog * dialog, GroupComboBox * pGroupComboBox );
|
||||||
void removeGroupComboBoxActionsFromDialog( QDialog * dialog, GroupComboBox * pGroupComboBox );
|
void removeGroupComboBoxActionsFromDialog( QDialog * dialog, GroupComboBox * pGroupComboBox );
|
||||||
|
|
Loading…
Reference in a new issue