mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 16:04:06 +00:00
clean: make toggleMainWindow reasonable
Some checks are pending
SonarCloud / Build and analyze (push) Waiting to run
Some checks are pending
SonarCloud / Build and analyze (push) Waiting to run
This commit is contained in:
parent
acbfef0870
commit
720f66c781
|
@ -402,10 +402,9 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
||||||
connect( wordsZoomBase, &QAction::triggered, this, &MainWindow::doWordsZoomBase );
|
connect( wordsZoomBase, &QAction::triggered, this, &MainWindow::doWordsZoomBase );
|
||||||
|
|
||||||
// tray icon
|
// tray icon
|
||||||
connect( trayIconMenu.addAction( tr( "Show &Main Window" ) ),
|
connect( trayIconMenu.addAction( tr( "Show &Main Window" ) ), &QAction::triggered, this, [ this ] {
|
||||||
&QAction::triggered,
|
this->toggleMainWindow( true );
|
||||||
this,
|
} );
|
||||||
&MainWindow::showMainWindow );
|
|
||||||
trayIconMenu.addAction( enableScanningAction );
|
trayIconMenu.addAction( enableScanningAction );
|
||||||
|
|
||||||
trayIconMenu.addSeparator();
|
trayIconMenu.addSeparator();
|
||||||
|
@ -2532,7 +2531,7 @@ void MainWindow::handleEsc()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( cfg.preferences.escKeyHidesMainWindow ) {
|
if ( cfg.preferences.escKeyHidesMainWindow ) {
|
||||||
toggleMainWindow();
|
toggleMainWindow( false );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
focusTranslateLine();
|
focusTranslateLine();
|
||||||
|
@ -2873,7 +2872,7 @@ void MainWindow::showTranslationForDicts( QString const & inWord,
|
||||||
ignoreDiacritics );
|
ignoreDiacritics );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::toggleMainWindow( bool onlyShow )
|
void MainWindow::toggleMainWindow( bool ensureShow )
|
||||||
{
|
{
|
||||||
bool shown = false;
|
bool shown = false;
|
||||||
|
|
||||||
|
@ -2906,7 +2905,7 @@ void MainWindow::toggleMainWindow( bool onlyShow )
|
||||||
}
|
}
|
||||||
shown = true;
|
shown = true;
|
||||||
}
|
}
|
||||||
else if ( !onlyShow ) {
|
else if ( !ensureShow ) {
|
||||||
|
|
||||||
// On Windows and Linux, a hidden window won't show a task bar icon
|
// On Windows and Linux, a hidden window won't show a task bar icon
|
||||||
// When trayicon is enabled, the duplication is unneeded
|
// When trayicon is enabled, the duplication is unneeded
|
||||||
|
@ -2990,7 +2989,7 @@ void MainWindow::installHotKeys()
|
||||||
void MainWindow::hotKeyActivated( int hk )
|
void MainWindow::hotKeyActivated( int hk )
|
||||||
{
|
{
|
||||||
if ( !hk ) {
|
if ( !hk ) {
|
||||||
toggleMainWindow();
|
toggleMainWindow( false );
|
||||||
}
|
}
|
||||||
else if ( scanPopup ) {
|
else if ( scanPopup ) {
|
||||||
#ifdef HAVE_X11
|
#ifdef HAVE_X11
|
||||||
|
@ -3075,7 +3074,7 @@ void MainWindow::trayIconActivated( QSystemTrayIcon::ActivationReason r )
|
||||||
switch ( r ) {
|
switch ( r ) {
|
||||||
case QSystemTrayIcon::Trigger:
|
case QSystemTrayIcon::Trigger:
|
||||||
// Left click toggles the visibility of main window
|
// Left click toggles the visibility of main window
|
||||||
toggleMainWindow();
|
toggleMainWindow( false );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QSystemTrayIcon::MiddleClick:
|
case QSystemTrayIcon::MiddleClick:
|
||||||
|
@ -3088,10 +3087,6 @@ void MainWindow::trayIconActivated( QSystemTrayIcon::ActivationReason r )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showMainWindow()
|
|
||||||
{
|
|
||||||
toggleMainWindow( true );
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::visitHomepage()
|
void MainWindow::visitHomepage()
|
||||||
{
|
{
|
||||||
|
|
|
@ -225,9 +225,8 @@ private:
|
||||||
/// group, or to all dictionaries if there are no groups.
|
/// group, or to all dictionaries if there are no groups.
|
||||||
vector< sptr< Dictionary::Class > > const & getActiveDicts();
|
vector< sptr< Dictionary::Class > > const & getActiveDicts();
|
||||||
|
|
||||||
/// Brings the main window to front if it's not currently, or hides it
|
/// @param ensureShow only ensure the window will be shown and no "toggling"
|
||||||
/// otherwise. The hiding part is omitted if onlyShow is true.
|
void toggleMainWindow( bool ensureShow );
|
||||||
void toggleMainWindow( bool onlyShow = false );
|
|
||||||
|
|
||||||
/// Creates hotkeyWrapper and hooks the currently set keys for it
|
/// Creates hotkeyWrapper and hooks the currently set keys for it
|
||||||
void installHotKeys();
|
void installHotKeys();
|
||||||
|
@ -397,8 +396,6 @@ private slots:
|
||||||
|
|
||||||
void setAutostart( bool );
|
void setAutostart( bool );
|
||||||
|
|
||||||
void showMainWindow();
|
|
||||||
|
|
||||||
void visitHomepage();
|
void visitHomepage();
|
||||||
void visitForum();
|
void visitForum();
|
||||||
void openConfigFolder();
|
void openConfigFolder();
|
||||||
|
|
Loading…
Reference in a new issue