diff --git a/mainwindow.cc b/mainwindow.cc index 46ec26df..82573424 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -940,7 +940,7 @@ void MainWindow::clipboardChange( QClipboard::Mode m) // Show a Flag instead of translate directly. // And hand over the control of showing the popup to scanFlag if ( cfg.preferences.showScanFlag ) { - emit scanPopup->showScanFlag(); + scanPopup->showScanFlag(); return; } diff --git a/scanflag.cc b/scanflag.cc index 99d0459b..7e36bfba 100644 --- a/scanflag.cc +++ b/scanflag.cc @@ -4,29 +4,28 @@ #include "ui_scanflag.h" #include -static Qt::WindowFlags popupWindowFlags = - -Qt::ToolTip | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint - | Qt::WindowDoesNotAcceptFocus -; ScanFlag::ScanFlag(QWidget *parent) : QMainWindow(parent) { ui.setupUi( this ); - setWindowFlags( popupWindowFlags ); + setWindowFlags( Qt::ToolTip + | Qt::FramelessWindowHint + | Qt::WindowStaysOnTopHint + | Qt::WindowDoesNotAcceptFocus); setAttribute(Qt::WA_X11DoNotAcceptFocus); hideTimer.setSingleShot( true ); - hideTimer.setInterval( 1500 ); + hideTimer.setInterval( 1000 ); - connect( &hideTimer, SIGNAL( timeout() ), - this, SLOT( hideWindow() ) ); + connect( &hideTimer, &QTimer::timeout, + this, [=]{ hideWindow(); + }); - connect( ui.pushButton, SIGNAL( clicked( bool ) ), - this, SLOT( pushButtonClicked() ) ); + connect( ui.pushButton, &QPushButton::clicked, + this, &ScanFlag::pushButtonClicked ); } ScanFlag::~ScanFlag() @@ -37,7 +36,7 @@ void ScanFlag::pushButtonClicked() { hideTimer.stop(); hide(); - emit showScanPopup(); + emit requestScanPopup(); } void ScanFlag::hideWindow() diff --git a/scanflag.hh b/scanflag.hh index 71eb0a57..1fe04421 100644 --- a/scanflag.hh +++ b/scanflag.hh @@ -2,7 +2,6 @@ #define SCAN_FLAG_H -#include "config.hh" #include #include #include "ui_scanflag.h" @@ -16,18 +15,17 @@ public: ~ScanFlag(); + void showScanFlag(); + void pushButtonClicked(); + void hideWindow(); + signals: - void showScanPopup (); + void requestScanPopup (); private: Ui::ScanFlag ui; QTimer hideTimer; -private slots: - void showScanFlag(); - void pushButtonClicked(); - void hideWindow(); - }; #endif // SCAN_FLAG_H diff --git a/scanpopup.cc b/scanpopup.cc index 7144304a..a0a7691b 100644 --- a/scanpopup.cc +++ b/scanpopup.cc @@ -317,13 +317,7 @@ ScanPopup::ScanPopup( QWidget * parent, #ifdef HAVE_X11 scanFlag = new ScanFlag( this ); - connect( this, SIGNAL( showScanFlag() ), - scanFlag, SLOT( showScanFlag() ) ); - - connect( this, SIGNAL( hideScanFlag() ), - scanFlag, SLOT( hideWindow() ) ); - - connect( scanFlag, &ScanFlag::showScanPopup, + connect( scanFlag, &ScanFlag::requestScanPopup, this, [=]{ translateWordFromSelection(); }); @@ -1344,3 +1338,12 @@ void ScanPopup::titleChanged( ArticleView *, QString const & title ) ui.sendWordToFavoritesButton->setIcon( isWordPresentedInFavorites( title, groupId ) ? blueStarIcon : starIcon ); } + + +void ScanPopup::showScanFlag(){ + scanFlag->showScanFlag(); +} + +void ScanPopup::hideScanFlag(){ + scanFlag->hideWindow(); +} diff --git a/scanpopup.hh b/scanpopup.hh index 4b874449..dd4f0bc8 100644 --- a/scanpopup.hh +++ b/scanpopup.hh @@ -53,6 +53,13 @@ public: void setDictionaryIconSize(); void saveConfigData(); + +#ifdef HAVE_X11 + /// Interaction with scan flag window + void showScanFlag(); + void hideScanFlag(); +#endif + signals: /// Forwarded from the dictionary bar, so that main window could act on this. @@ -79,12 +86,6 @@ signals: /// Check is word already presented in Favorites bool isWordPresentedInFavorites( QString const & word, unsigned groupId ); -#ifdef HAVE_X11 - /// Interaction with scan flag window - void showScanFlag(); - void hideScanFlag(); -#endif - #ifdef Q_OS_WIN32 /// Ask for source window is current translate tab bool isGoldenDictWindow( HWND hwnd );