From 38956589a247b4aab8b4673c0fc6d51d1cc1ecb3 Mon Sep 17 00:00:00 2001 From: shenleban tongying Date: Tue, 21 Feb 2023 19:45:09 -0500 Subject: [PATCH] refactor: convert scanflag.ui to plain code --- CMakeLists.txt | 1 - goldendict.pro | 1 - scanflag.cc | 28 ++++++++++++++-------------- scanflag.hh | 8 +++----- scanflag.ui | 38 -------------------------------------- 5 files changed, 17 insertions(+), 59 deletions(-) delete mode 100644 scanflag.ui diff --git a/CMakeLists.txt b/CMakeLists.txt index f26d0525..5b335e47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,7 +147,6 @@ set(UI_SRC options.ui orderandprops.ui preferences.ui - scanflag.ui scanpopup.ui sources.ui ) diff --git a/goldendict.pro b/goldendict.pro index cc17ea5e..ec54b56f 100644 --- a/goldendict.pro +++ b/goldendict.pro @@ -568,7 +568,6 @@ mac { unix:!mac { HEADERS += scanflag.hh - FORMS += scanflag.ui SOURCES += scanflag.cc } diff --git a/scanflag.cc b/scanflag.cc index 7e36bfba..8a85a448 100644 --- a/scanflag.cc +++ b/scanflag.cc @@ -1,37 +1,37 @@ -#include - #include "scanflag.hh" -#include "ui_scanflag.h" +#include +#include #include ScanFlag::ScanFlag(QWidget *parent) : - QMainWindow(parent) + QMainWindow(parent), + pushButton(new QPushButton(this)) { - ui.setupUi( this ); + + pushButton->setIcon(QIcon(":/icons/programicon.png")); + + setCentralWidget(pushButton); + + setFixedSize(30,30); setWindowFlags( Qt::ToolTip | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::WindowDoesNotAcceptFocus); + + setAttribute(Qt::WA_TranslucentBackground); setAttribute(Qt::WA_X11DoNotAcceptFocus); hideTimer.setSingleShot( true ); hideTimer.setInterval( 1000 ); - connect( &hideTimer, &QTimer::timeout, - this, [=]{ hideWindow(); - }); - - connect( ui.pushButton, &QPushButton::clicked, + connect( &hideTimer, &QTimer::timeout,this,&ScanFlag::hideWindow); + connect( pushButton, &QPushButton::clicked, this, &ScanFlag::pushButtonClicked ); } -ScanFlag::~ScanFlag() -{ -} - void ScanFlag::pushButtonClicked() { hideTimer.stop(); diff --git a/scanflag.hh b/scanflag.hh index 1fe04421..7f332608 100644 --- a/scanflag.hh +++ b/scanflag.hh @@ -1,10 +1,9 @@ #ifndef SCAN_FLAG_H #define SCAN_FLAG_H - #include +#include #include -#include "ui_scanflag.h" class ScanFlag : public QMainWindow { @@ -13,7 +12,7 @@ class ScanFlag : public QMainWindow public: ScanFlag( QWidget *parent ); - ~ScanFlag(); + ~ScanFlag()=default; void showScanFlag(); void pushButtonClicked(); @@ -23,9 +22,8 @@ signals: void requestScanPopup (); private: - Ui::ScanFlag ui; QTimer hideTimer; - + QPushButton * pushButton; }; #endif // SCAN_FLAG_H diff --git a/scanflag.ui b/scanflag.ui deleted file mode 100644 index 17142838..00000000 --- a/scanflag.ui +++ /dev/null @@ -1,38 +0,0 @@ - - - ScanFlag - - - - 0 - 0 - 30 - 30 - - - - MainWindow - - - - - - 0 - 0 - 30 - 30 - - - - - - - - :/icons/programicon.png:/icons/programicon.png - - - - - - -