添加封装好的processbar

qt6
ATTIOT\zhengcy 2021-04-30 16:56:46 +08:00
parent 5407bf8b1e
commit f54bef7ae9
9 changed files with 208 additions and 421 deletions

BIN
.gitignore vendored

Binary file not shown.

View File

@ -85,7 +85,7 @@ QssTtitleBar::QssTtitleBar(QWidget *parent ,
installEventFilter(this); installEventFilter(this);
m_rcValid = QApplication::desktop()->availableGeometry(); m_rcValid = QApplication::desktop()->availableGeometry();
this->setFixedHeight(37); this->setFixedHeight(25);
setWindowFlags(windowFlags()|Qt::MSWindowsFixedSizeDialogHint); setWindowFlags(windowFlags()|Qt::MSWindowsFixedSizeDialogHint);
this->setGeometry(parent->geometry().x(),parent->geometry().y(),0,0); this->setGeometry(parent->geometry().x(),parent->geometry().y(),0,0);
m_rcNormal = parentWidget()->geometry(); m_rcNormal = parentWidget()->geometry();
@ -242,6 +242,8 @@ void QssMainWindow::OnMaxOrRestore(bool max)
this->setFixedHeight(rc.height()); this->setFixedHeight(rc.height());
} }
} }
QssMainWindow::QssMainWindow(QWidget *parent/* = 0*/, Qt::WindowFlags flags/* = 0*/,float scale) QssMainWindow::QssMainWindow(QWidget *parent/* = 0*/, Qt::WindowFlags flags/* = 0*/,float scale)
: QMainWindow(parent, flags), : QMainWindow(parent, flags),
ICallDPIChanged(), ICallDPIChanged(),
@ -1590,7 +1592,7 @@ void QssToastWidget::showTip(const QString& text, QWidget* parent /*= nullptr*/)
QssToastWidget* toast = new QssToastWidget(parent); QssToastWidget* toast = new QssToastWidget(parent);
toast->setWindowFlags(toast->windowFlags() | Qt::WindowStaysOnTopHint); toast->setWindowFlags(toast->windowFlags() | Qt::WindowStaysOnTopHint);
toast->setText(text); toast->setText(text);
toast->setStyleSheet("font:bold;font-size:24px;color:rgb(255,255,255);"); toast->setStyleSheet("font:bold;font-size:10px;color:rgb(255,255,255);");
toast->adjustSize(); toast->adjustSize();
QScreen* pScreen = QGuiApplication::primaryScreen(); QScreen* pScreen = QGuiApplication::primaryScreen();
toast->move((pScreen->size().width() - toast->width()) / 2, toast->move((pScreen->size().width() - toast->width()) / 2,

1
Qss.h
View File

@ -160,7 +160,6 @@ protected:
void mouseMoveEvent(QMouseEvent * ev); void mouseMoveEvent(QMouseEvent * ev);
void mousePressEvent(QMouseEvent * ev); void mousePressEvent(QMouseEvent * ev);
void mouseReleaseEvent(QMouseEvent * ev); void mouseReleaseEvent(QMouseEvent * ev);
bool eventFilter(QObject * obj, QEvent * ev); bool eventFilter(QObject * obj, QEvent * ev);
private: private:

View File

@ -1,26 +1,26 @@
QWidget#qssTitleBar{ QWidget#qssTitleBar{
color: white; color: white;
background: rgb(7,71,166); background: rgb(51,101,177);
border: 0px; border: 0px;
margin: 0px; margin: 0px;
} }
QWidget#qssTitleBar > QPushButton#titlebaricon{ QWidget#qssTitleBar > QPushButton#titlebaricon{
background: rgb(7,71,166); background: rgb(51,101,177);
width: 30px; width: 25px;
height:30px; height:25px;
} }
QWidget#qssTitleBar > QPushButton#titlebarclosebtn{ QWidget#qssTitleBar > QPushButton#titlebarclosebtn{
image: url(":/qss/icon/btn_close_down.svg"); image: url(":/qss/icon/btn_close_down.svg");
background: rgb(7,71,166); background: rgb(51,101,177);
width: 40px; width: 25px;
height:30px; height:25px;
margin-left: 1px; margin-left: 1px;
} }
QWidget#qssTitleBar >QPushButton#titlebarmaxbtn{ QWidget#qssTitleBar >QPushButton#titlebarmaxbtn{
background: rgb(7,71,166); background: rgb(51,101,177);
width: 40px; width: 25px;
height:30px; height:25px;
margin-left: 1px; margin-left: 1px;
image: url(":/qss/icon/btn_max_normal.svg"); image: url(":/qss/icon/btn_max_normal.svg");
@ -30,9 +30,9 @@ QWidget#qssTitleBar >QPushButton#titlebarclosebtn:enabled:hover{
} }
QWidget#qssTitleBar >QPushButton#titlebarminbtn{ QWidget#qssTitleBar >QPushButton#titlebarminbtn{
image: url(":/qss/icon/btn_mini_down.svg"); image: url(":/qss/icon/btn_mini_down.svg");
background: rgb(7,71,166); background: rgb(51,101,177);
width: 40px; width: 25px;
height:30px; height:25px;
margin-left: 1px; margin-left: 1px;
} }
QWidget#qssTitleBar >QPushButton#titlebarminbtn:enabled:hover{ QWidget#qssTitleBar >QPushButton#titlebarminbtn:enabled:hover{
@ -41,8 +41,8 @@ QWidget#qssTitleBar >QPushButton#titlebarminbtn:enabled:hover{
QWidget#qssTitleBar >QPushButton#titlebarrestorebtn{ QWidget#qssTitleBar >QPushButton#titlebarrestorebtn{
image: url(":/qss/icon/btn_max_normal.svg"); image: url(":/qss/icon/btn_max_normal.svg");
background: rgb(187, 212, 238); background: rgb(187, 212, 238);
width: 40px; width: 25px;
height:30px; height:25px;
margin-left: 1px; margin-left: 1px;
margin-right: 2px; margin-right: 2px;
} }
@ -58,7 +58,7 @@ QWidget#qssTitleBar >QPushButton#titlebarmaxbtn:enabled:hover{
} }
QWidget#qssTitleBar > QLabel#title{ QWidget#qssTitleBar > QLabel#title{
color: white; color: white;
font-size:30px; font-size:15px;
font-family:'Courier New', Courier, monospace; font-family:'黑体', Courier, monospace;
} }

View File

@ -1,24 +1,12 @@
QssDockWidget#dialog{
border: 1px solid rgb(111, 156, 207);
font-size : 15px;
padding: 5px;
background: rgb(232, 241, 252);
}
QDialog{ QDialog{
border: 1px solid rgb(rgb(0, 78, 161)); border: 1px solid rgb(rgb(0, 78, 161));
font-size : 15px;
padding: 5px; padding: 5px;
background: rgb(232, 241, 252); background: rgb(232, 241, 252);
} }
QWidget#player{
border: 1px solid rgb(111, 156, 207);
font-size : 15px;
background: rgb(232, 241, 252);
}
QMainWindow{ QMainWindow{
border: none; border: none;
background: rgb(245, 252, 252); background: rgb(255, 255, 255);
} }
QMainWindow::title{ QMainWindow::title{
@ -27,79 +15,17 @@ QMainWindow::title{
padding-left: 5px; padding-left: 5px;
} }
QDialog::title{
text-align: left; /* align the text to the left */
background: lightgray;
padding-left: 5px;
}
QPushButton#btn_serial:enabled {
border-image: url(:/qss/icon/btn_serial.png);
background: rgb(232, 241, 252);
color: white;
margin-left: 10;
margin-top:5;
}
QPushButton#btn_serial:enabled:hover{
background: rgb(100, 160, 220);
}
QPushButton#btn_serial:enabled:pressed{
background: rgb(0, 78, 161);
}
QPushButton#btn_process:enabled {
border-image: url(:/qss/icon/charts.png);
background: rgb(232, 241, 252);
color: white;
margin-left: 10;
margin-top:5;
}
QPushButton#btn_process:!enabled {
background: rgb(180, 180, 180);
color: white;
}
QPushButton#btn_process:enabled:hover{
background: rgb(100, 160, 220);
}
QPushButton#btn_process:enabled:pressed{
background: rgb(0, 78, 161);
}
QWidget { QWidget {
font-size: 20px; /* font-size: 10px;*/
} }
QWidget#customWidget {
background: rgb(173, 202, 232);
}
/**********子界面中央背景**********/
QWidget#centerWidget {
background: rgb(232, 241, 1);
}
/**********主界面样式**********/
QWidget#mainWindow {
background: rgb(232, 241, 252);
}
QWidget#messageWidget {
background: rgba(173, 202, 232);
}
QWidget#loadingWidget {
border: none;
background: rgb(187, 212, 238);
}
QDockWidget{ QDockWidget{
background: rgb(187, 212, 238); background: rgb(187, 212, 238);
} }
QFrame#window{ /*QFrame#window{
background: rgba(244,245,247,100); background: rgba(244,245,247,100);
}*/
}
QWidget#remoteWidget { QWidget#remoteWidget {
border-top-right-radius: 10px; border-top-right-radius: 10px;
@ -133,24 +59,26 @@ QMenuBar {
border: 1px solid rgb(111, 156, 207); border: 1px solid rgb(111, 156, 207);
border-left: none; border-left: none;
border-right: none; border-right: none;
} }
QMenuBar::item { QMenuBar::item {
border: 1px solid transparent; border: 1px solid transparent;
padding: 5px 10px 5px 10px; padding: 5px 10px 5px 10px;
height : 30px; height : 30px;
background: transparent; background: "white";
text-aligin: center; text-aligin: center;
font-size: 15px; font-size: 20px;;
} }
QMenuBar::item:enabled { QMenuBar::item:enabled {
color: rgb(7,71,166); font-size: 20px;;
background: rgb(198, 224, 252);
} }
QMenuBar::item:!enabled { QMenuBar::item:!enabled {
color: rgb(155, 155, 155); font-size: 20px;;
background: rgb(198, 224, 252);
} }
QMenuBar::item:enabled:selected { QMenuBar::item:enabled:selected {
border-top-color: rgb(111, 156, 207); font-size: 20px;;
border-bottom-color: rgb(111, 156, 207);
background: rgb(198, 224, 252); background: rgb(198, 224, 252);
} }
@ -165,89 +93,25 @@ QMenu {
QssMessageBox#messagebox{ QssMessageBox#messagebox{
background: rgb(0, 0, 250); background: rgb(0, 0, 250);
} }
QWidget#titlebar{
color: white;
background: rgb(7,71,166);
border: 0px;
margin: 0px;
}
QPushButton#titlebaricon{
/* image: url(:/qss/icon/logo.png);*/
background: rgb(7,71,166);
width: 30px;
height:30px;
}
QLable#titlebartitle1{
font-family:"微软雅黑";
color: white;
font-size: 16px;
}
QPushButton#titlebarclosebtn{
image: url(":/qss/icon/btn_close_down.svg");
background: rgb(7,71,166);
width: 40px;
height:30px;
margin-left: 1px;
}
QPushButton#titlebarmaxbtn{
background: rgb(7,71,166);
width: 40px;
height:30px;
margin-left: 1px;
image: url(":/qss/icon/btn_max_normal.svg");
}
QPushButton#titlebarclosebtn:enabled:hover{
background: red;
}
QPushButton#titlebarminbtn{
image: url(":/qss/icon/btn_mini_down.svg");
background: rgb(7,71,166);
width: 40px;
height:30px;
margin-left: 1px;
}
QPushButton#titlebarminbtn:enabled:hover{
background: rgb(187, 212, 238);
}
QPushButton#titlebarrestorebtn{
image: url(":/qss/icon/btn_max_normal.svg");
background: rgb(187, 212, 238);
width: 40px;
height:30px;
margin-left: 1px;
}
QPushButton#titlebarrestorebtn:enabled:hover{
background: rgb(187, 212, 238);
}
QPushButton#btn_serial:!enabled {
background: rgb(180, 180, 180);
color: white;
}
QPushButton#titlebarmaxbtn:enabled:hover{
background: rgb(100, 160, 220);
}
QMenu::item { QMenu::item {
height: 22px; height: 22px;
padding: 0px 25px 0px 20px; padding: 0px 25px 0px 20px;
} }
QMenu::item:enabled { QMenu::item:enabled {
color: rgb(84, 84, 84); color: rgb(84, 84, 84);
} }
QMenu::item:!enabled { QMenu::item:!enabled {
color: rgb(155, 155, 155); color: rgb(155, 155, 155);
} }
QMenu::item:enabled:selected { QMenu::item:enabled:selected {
color: rgb(2, 65, 132); color: rgb(2, 65, 132);
background: rgba(255, 255, 255, 200); background: rgba(255, 255, 255, 200);
} }
QMenu::separator { QMenu::separator {
height: 1px; height: 1px;
background: rgb(111, 156, 207); background: rgb(111, 156, 207);
@ -256,6 +120,7 @@ QMenu::indicator {
width: 13px; width: 13px;
height: 13px; height: 13px;
} }
QMenu::icon { QMenu::icon {
padding-left: 2px; padding-left: 2px;
padding-right: 2px; padding-right: 2px;
@ -269,6 +134,7 @@ QStatusBar {
border-right: none; border-right: none;
border-bottom: none; border-bottom: none;
} }
QStatusBar::item { QStatusBar::item {
border: none; border: none;
border-right: 1px solid rgb(111, 156, 207); border-right: 1px solid rgb(111, 156, 207);
@ -276,16 +142,17 @@ QStatusBar::item {
/**********分组框**********/ /**********分组框**********/
QGroupBox { QGroupBox {
font-size: 15px;
border: 1px solid rgb(111, 156, 207); border: 1px solid rgb(111, 156, 207);
border-radius: 4px; border-radius: 4px;
margin-top: 10px; margin-top: 10px;
} }
QGroupBox::title { QGroupBox::title {
color: rgb(56, 99, 154); color: rgb(56, 99, 154);
top: -12px; top: -12px;
left: 10px; left: 10px;
} }
QTabWidget{ QTabWidget{
margin-left:10; margin-left:10;
} }
@ -295,9 +162,11 @@ QTabWidget::pane {
border-top: 3px solid rgb(0, 78, 161); border-top: 3px solid rgb(0, 78, 161);
background: rgb(187, 212, 238); background: rgb(187, 212, 238);
} }
QTabWidget::tab-bar { QTabWidget::tab-bar {
border: none; border: none;
} }
QTabBar::tab { QTabBar::tab {
border: none; border: none;
border-top-left-radius: 4px; border-top-left-radius: 4px;
@ -310,9 +179,11 @@ QTabBar::tab {
padding-left: 5px; padding-left: 5px;
padding-right: 5px; padding-right: 5px;
} }
QTabBar::tab:hover { QTabBar::tab:hover {
background: rgb(0, 78, 161); background: rgb(0, 78, 161);
} }
QTabBar::tab:selected { QTabBar::tab:selected {
color: white; color: white;
background: rgb(0, 78, 161); background: rgb(0, 78, 161);
@ -772,7 +643,6 @@ QLabel#label_3{
} }
QDockWidget *{ QDockWidget *{
font-size: 15px;
} }
/**********标签**********/ /**********标签**********/
QLabel#grayLabel { QLabel#grayLabel {
@ -878,218 +748,32 @@ QToolButton#transferButton {
qproperty-iconSize: 32px 32px; qproperty-iconSize: 32px 32px;
qproperty-toolButtonStyle: ToolButtonTextUnderIcon; qproperty-toolButtonStyle: ToolButtonTextUnderIcon;
} }
QToolButton#transferButton:hover { QToolButton#transferButton:hover {
background: rgb(187, 212, 238); background: rgb(187, 212, 238);
} }
/**********按钮**********/ /**********按钮**********/
QPushButton{ QPushButton{
border: none; border: none; /*去除边框*/
width: 75px; font-size: 15px;
height: 25px;
font-size: 18px;
color: black;
} }
QPushButton:enabled { QPushButton:enabled {
background: rgb(120, 170, 220); background: rgb(0, 78, 161);
color: white; color: white;
} }
QPushButton:!enabled { QPushButton:!enabled {
background: rgb(180, 180, 180); background: rgb(180, 180, 180);
color: white; color: white;
} }
QPushButton:enabled:hover{ QPushButton:enabled:hover{
background: rgb(100, 160, 220); background: rgb(100, 160, 220);
} }
QPushButton:enabled:pressed{ QPushButton:enabled:pressed{
background: rgb(0, 78, 161);
}
QPushButton#blueButton {
color: white;
}
QPushButton#blueButton:enabled {
background: rgb(0, 78, 161);
color: white;
}
QPushButton#blueButton:enabled:hover {
background: rgb(2, 65, 132);
}
QPushButton#blueButton:enabled:pressed {
background: rgb(6, 94, 187);
}
QPushButton#selectButton {
border: none;
border-radius: none;
border-left: 1px solid rgb(111, 156, 207);
background: transparent;
image: url(:/White/scan);
color: rgb(51, 51, 51);
}
QPushButton#selectButton:enabled:hover{
background: rgb(187, 212, 238);
}
QPushButton#selectButton:enabled:pressed{
background: rgb(120, 170, 220); background: rgb(120, 170, 220);
} }
QPushButton#linkButton {
background: transparent;
color: rgb(0, 160, 230);
text-align:left;
}
QPushButton#linkButton:hover {
color: rgb(20, 185, 255);
text-decoration: underline;
}
QPushButton#linkButton:pressed {
color: rgb(0, 160, 230);
}
QPushButton#transparentButton {
background: transparent;
}
/*****************标题栏按钮*******************/
QPushButton#minimizeButton {
border-radius: none;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
background: rgb(120, 170, 220);
image: url(:/White/minimizeHover);
}
QPushButton#minimizeButton:hover {
image: url(:/White/minimize);
}
QPushButton#minimizeButton:pressed {
}
QPushButton#closeButton {
border-radius: none;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
background: rgb(120, 170, 220);
image: url(:/qss/icon/btn_close_normal.png);
}
QPushButton#closeButton:hover {
background: rgb(100, 160, 220);
}
QPushButton#closeButton:pressed {
border-radius: none;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
background: rgb(80, 170, 220);
}
QPushButton#skinButton {
border-radius: none;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
background: rgb(120, 170, 220);
image: url(:/White/skinHover);
}
QPushButton#skinButton:hover {
image: url(:/White/skin);
}
QPushButton#skinButton:pressed {
image: url(:/White/skinPressed);
}
QPushButton#feedbackButton {
border-radius: none;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
background: rgb(120, 170, 220);
image: url(:/White/feedbackHover);
}
QPushButton#feedbackButton:hover {
image: url(:/White/feedback);
}
QPushButton#feedbackButton:pressed {
image: url(:/White/feedbackPressed);
}
QPushButton#closeTipButton {
border-radius: none;
border-image: url(:/White/close);
background: transparent;
}
QPushButton#closeTipButton:hover {
border-image: url(:/White/closeHover);
}
QPushButton#closeTipButton:pressed {
border-image: url(:/White/closePressed);
}
QPushButton#changeSkinButton{
border-radius: 4px;
border: 2px solid rgb(111, 156, 207);
background: rgb(204, 227, 252);
}
QPushButton#changeSkinButton:hover{
border-color: rgb(60, 150, 200);
}
QPushButton#changeSkinButton:pressed, QPushButton#changeSkinButton:checked{
border-color: rgb(0, 160, 230);
}
QPushButton#transferButton {
padding-left: 5px;
padding-right: 5px;
color: white;
background: rgb(0, 78, 161);
}
QPushButton#transferButton:hover {
background: rgb(2, 65, 132);
}
QPushButton#transferButton:pressed {
background: rgb(6, 94, 187);
}
QPushButton#transferButton[iconProperty="left"] {
qproperty-icon: url(:/White/left);
}
QPushButton#transferButton[iconProperty="right"] {
qproperty-icon: url(:/White/right);
}
QPushButton#openButton {
border-radius: none;
image: url(:/White/open);
background: transparent;
}
QPushButton#openButton:hover {
image: url(:/White/openHover);
}
QPushButton#openButton:pressed {
image: url(:/White/openPressed);
}
QPushButton#deleteButton {
border-radius: none;
image: url(:/White/delete);
background: transparent;
}
QPushButton#deleteButton:hover {
image: url(:/White/deleteHover);
}
QPushButton#deleteButton:pressed {
image: url(:/White/deletePressed);
}
QPushButton#menuButton {
height: 50px;
text-align: left center;
padding-left: 3px;
color: rgb(84, 84, 198);
border: 1px solid rgb(111, 156, 207);
background: white;
}
QPushButton#menuButton::menu-indicator{
subcontrol-position: right center;
subcontrol-origin: padding;
padding-right: 3px;
height:50px;
}

28
process.cpp Normal file
View File

@ -0,0 +1,28 @@
#include "process.h"
#include "ui_process.h"
Process::Process(QWidget *parent) :
QDialog(parent),
ui(new Ui::Process)
{
ui->setupUi(this);
ui->progressBar->setValue(1);
setWindowFlags(Qt::FramelessWindowHint);
this->setModal(true);
}
Process::~Process()
{
delete ui;
}
void Process::on_percent(int percent)
{
ui->progressBar->setValue(percent);
}
void Process::on_done_close()
{
this->close();
}

24
process.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef PROCESS_H
#define PROCESS_H
#include "Qss.h"
namespace Ui {
class Process;
}
class Process : public QDialog
{
Q_OBJECT
public:
explicit Process(QWidget *parent = nullptr);
~Process();
public slots:
void on_percent(int);
void on_done_close();
private:
Ui::Process *ui;
};
#endif // PROCESS_H

51
process.ui Normal file
View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Process</class>
<widget class="QDialog" name="Process">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>324</width>
<height>88</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QProgressBar" name="progressBar">
<property name="geometry">
<rect>
<x>30</x>
<y>50</y>
<width>281</width>
<height>31</height>
</rect>
</property>
<property name="value">
<number>24</number>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>120</x>
<y>30</y>
<width>121</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>正在加载数据</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,13 +1,12 @@
INCLUDEPATH += $$PWD INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD DEPENDPATH += $$PWD
HEADERS += $$PWD/Qss.h \
include($$PWD/extserial/src/qextserialport.pri) $$PWD/process.h
SOURCES += $$PWD/Qss.cpp \
HEADERS += $$PWD/Qss.h $$PWD/process.cpp
SOURCES += $$PWD/Qss.cpp
RESOURCES += $$PWD/qss.qrc RESOURCES += $$PWD/qss.qrc
FORMS += $$PWD/forms/qsstoast.ui FORMS += $$PWD/forms/qsstoast.ui \
$$PWD/process.ui