refactor: convert scanflag.ui to plain code

This commit is contained in:
shenleban tongying 2023-02-21 19:45:09 -05:00
parent a7c1589149
commit 38956589a2
5 changed files with 17 additions and 59 deletions

View file

@ -147,7 +147,6 @@ set(UI_SRC
options.ui options.ui
orderandprops.ui orderandprops.ui
preferences.ui preferences.ui
scanflag.ui
scanpopup.ui scanpopup.ui
sources.ui sources.ui
) )

View file

@ -568,7 +568,6 @@ mac {
unix:!mac { unix:!mac {
HEADERS += scanflag.hh HEADERS += scanflag.hh
FORMS += scanflag.ui
SOURCES += scanflag.cc SOURCES += scanflag.cc
} }

View file

@ -1,37 +1,37 @@
#include <QCursor>
#include "scanflag.hh" #include "scanflag.hh"
#include "ui_scanflag.h" #include <QCursor>
#include <QGuiApplication>
#include <QScreen> #include <QScreen>
ScanFlag::ScanFlag(QWidget *parent) : 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 setWindowFlags( Qt::ToolTip
| Qt::FramelessWindowHint | Qt::FramelessWindowHint
| Qt::WindowStaysOnTopHint | Qt::WindowStaysOnTopHint
| Qt::WindowDoesNotAcceptFocus); | Qt::WindowDoesNotAcceptFocus);
setAttribute(Qt::WA_TranslucentBackground);
setAttribute(Qt::WA_X11DoNotAcceptFocus); setAttribute(Qt::WA_X11DoNotAcceptFocus);
hideTimer.setSingleShot( true ); hideTimer.setSingleShot( true );
hideTimer.setInterval( 1000 ); hideTimer.setInterval( 1000 );
connect( &hideTimer, &QTimer::timeout, connect( &hideTimer, &QTimer::timeout,this,&ScanFlag::hideWindow);
this, [=]{ hideWindow(); connect( pushButton, &QPushButton::clicked,
});
connect( ui.pushButton, &QPushButton::clicked,
this, &ScanFlag::pushButtonClicked ); this, &ScanFlag::pushButtonClicked );
} }
ScanFlag::~ScanFlag()
{
}
void ScanFlag::pushButtonClicked() void ScanFlag::pushButtonClicked()
{ {
hideTimer.stop(); hideTimer.stop();

View file

@ -1,10 +1,9 @@
#ifndef SCAN_FLAG_H #ifndef SCAN_FLAG_H
#define SCAN_FLAG_H #define SCAN_FLAG_H
#include <QMainWindow> #include <QMainWindow>
#include <QPushButton>
#include <QTimer> #include <QTimer>
#include "ui_scanflag.h"
class ScanFlag : public QMainWindow class ScanFlag : public QMainWindow
{ {
@ -13,7 +12,7 @@ class ScanFlag : public QMainWindow
public: public:
ScanFlag( QWidget *parent ); ScanFlag( QWidget *parent );
~ScanFlag(); ~ScanFlag()=default;
void showScanFlag(); void showScanFlag();
void pushButtonClicked(); void pushButtonClicked();
@ -23,9 +22,8 @@ signals:
void requestScanPopup (); void requestScanPopup ();
private: private:
Ui::ScanFlag ui;
QTimer hideTimer; QTimer hideTimer;
QPushButton * pushButton;
}; };
#endif // SCAN_FLAG_H #endif // SCAN_FLAG_H

View file

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ScanFlag</class>
<widget class="QMainWindow" name="ScanFlag">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>30</width>
<height>30</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>30</width>
<height>30</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normaloff>:/icons/programicon.png</normaloff>:/icons/programicon.png</iconset>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>