mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
refactor: convert scanflag.ui to plain code (#350)
The .ui file only contains a single widget. The overhead is unnecessary. | Before: There is a weird top edge. | After | |-----------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------| | ![image](https://user-images.githubusercontent.com/20123683/220492330-13502c46-2f0b-4bc3-9462-0f426258dc97.png) | ![image](https://user-images.githubusercontent.com/20123683/220492128-b77bc480-6a08-4ef2-88db-29aef753a3bd.png) | Slightly related to https://github.com/xiaoyifang/goldendict/issues/349#issuecomment-1439224644, we may use a similar flag later.
This commit is contained in:
commit
67d5799708
|
@ -147,7 +147,6 @@ set(UI_SRC
|
|||
options.ui
|
||||
orderandprops.ui
|
||||
preferences.ui
|
||||
scanflag.ui
|
||||
scanpopup.ui
|
||||
sources.ui
|
||||
)
|
||||
|
|
|
@ -568,7 +568,6 @@ mac {
|
|||
|
||||
unix:!mac {
|
||||
HEADERS += scanflag.hh
|
||||
FORMS += scanflag.ui
|
||||
SOURCES += scanflag.cc
|
||||
}
|
||||
|
||||
|
|
28
scanflag.cc
28
scanflag.cc
|
@ -1,37 +1,37 @@
|
|||
#include <QCursor>
|
||||
|
||||
#include "scanflag.hh"
|
||||
#include "ui_scanflag.h"
|
||||
#include <QCursor>
|
||||
#include <QGuiApplication>
|
||||
#include <QScreen>
|
||||
|
||||
|
||||
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();
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
#ifndef SCAN_FLAG_H
|
||||
#define SCAN_FLAG_H
|
||||
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QPushButton>
|
||||
#include <QTimer>
|
||||
#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
|
||||
|
|
38
scanflag.ui
38
scanflag.ui
|
@ -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>
|
Loading…
Reference in a new issue