diff --git a/src/mainwindow-dtk.cpp b/src/mainwindow-dtk.cpp index 1341d9d..219bec4 100755 --- a/src/mainwindow-dtk.cpp +++ b/src/mainwindow-dtk.cpp @@ -22,9 +22,6 @@ #define AppPageSearchlist 1 #define AppPageAppdetail 2 #define AppPageSettings 3 -#define WaylandSearchCenter 1 -#define OtherSearchCenter 2 -#define RightSearchSpace 1 #define UploadServerUrl "https://upload.deepinos.org.cn/" MainWindow::MainWindow(QWidget *parent) @@ -126,6 +123,16 @@ void MainWindow::closeEvent(QCloseEvent *event) BaseWidgetOpacity::closeEvent(event); } +void MainWindow::changeEvent(QEvent *event) +{ + if (event->type() != QEvent::StyleChange) { + return BaseWidgetOpacity::changeEvent(event); + } + + BaseWidgetOpacity::changeEvent(event); + downloadButton->setFixedSize(searchEdit->sizeHint().height(), searchEdit->sizeHint().height()); +} + void MainWindow::initUI() { QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat); @@ -159,8 +166,9 @@ void MainWindow::initTitleBar() ui->titlebar->setBackgroundTransparent(true); // 初始化标题栏控件 - DLabel *title = new DLabel(ui->titlebar); - title->setText(tr("Spark Store")); + DLabel *titleLabel = new DLabel(ui->titlebar); + titleLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + titleLabel->setText(tr("Spark Store")); backButton = new DPushButton(ui->titlebar); @@ -170,34 +178,36 @@ void MainWindow::initTitleBar() searchEdit->lineEdit()->setFixedWidth(350); downloadButton = new ProgressButton(ui->titlebar); + downloadButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); downloadButton->setDownloadListWidget(downloadlistwidget); downloadButton->setFocusPolicy(Qt::FocusPolicy::ClickFocus); + downloadButton->setFixedSize(searchEdit->sizeHint().height(), searchEdit->sizeHint().height()); downloadlistwidget->setFocusProxy(downloadButton); - QWidget *w_titlebar = new QWidget(ui->titlebar); - QHBoxLayout *ly_titlebar = new QHBoxLayout(w_titlebar); - ly_titlebar->addWidget(title); - ly_titlebar->addWidget(backButton); - // Check wayland configs - QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat); - if (!config.value("runtime/isDDE").toBool() && config.value("runtime/useWayland").toBool()) - { - // Wayland 搜索栏居中 - ly_titlebar->addStretch(WaylandSearchCenter); - } - else - { - // dwayland dxcb 搜索栏顶部右侧居中 - ly_titlebar->addStretch(OtherSearchCenter); - } - ly_titlebar->addWidget(searchEdit); - ly_titlebar->addWidget(downloadButton); - ly_titlebar->addStretch(RightSearchSpace); - ui->titlebar->setCustomWidget(w_titlebar); + QWidget *customWidget = new QWidget(ui->titlebar); + customWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + ui->titlebar->setCustomWidget(customWidget); + + QHBoxLayout *customWidgetLayout = new QHBoxLayout(customWidget); + customWidgetLayout->setContentsMargins(8, 0, 0, 0); + customWidgetLayout->setSpacing(8); + customWidgetLayout->addWidget(titleLabel, 0, Qt::AlignLeft); + customWidgetLayout->addWidget(backButton, 0, Qt::AlignLeft); + QWidget *centralWidget = new QWidget(customWidget); + centralWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + customWidgetLayout->addWidget(centralWidget, 1, Qt::AlignHCenter); + + QHBoxLayout *centralLayout = new QHBoxLayout(centralWidget); + centralLayout->setContentsMargins(0, 0, 10, 0); + centralLayout->setSpacing(0); + + centralLayout->addWidget(searchEdit, 0, Qt::AlignHCenter); + centralLayout->addSpacing(10); + centralLayout->addWidget(downloadButton, 0, Qt::AlignHCenter); initTitleBarMenu(); - backButton->hide(); + backButton->setDisabled(true); downloadlistwidget->hide(); } @@ -353,9 +363,9 @@ void MainWindow::initConnections() ui->stackedWidget->setCurrentIndex(pageHistory.at(pageHistory.count() - 2)); pageHistory.removeLast(); if (pageHistory.count() > 1) { - backButton->show(); + backButton->setEnabled(true); } else { - backButton->hide(); + backButton->setDisabled(true); } }); // 搜索事件 @@ -446,11 +456,11 @@ void MainWindow::switchPage(int now) // 临时方案,回家后修改 qDebug() << pageHistory.count(); if (pageHistory.count() >= 1) { - backButton->show(); + backButton->setEnabled(true); } else { - backButton->hide(); + backButton->setDisabled(true); } ui->stackedWidget->setCurrentIndex(now); ui->stackedWidget->currentWidget()->setFocus(); diff --git a/src/mainwindow-dtk.h b/src/mainwindow-dtk.h index a5621c3..791e885 100755 --- a/src/mainwindow-dtk.h +++ b/src/mainwindow-dtk.h @@ -34,6 +34,7 @@ public: protected: void closeEvent(QCloseEvent *event) override; + void changeEvent(QEvent *event) override; private: void initUI(); diff --git a/src/mainwindow-dtk.ui b/src/mainwindow-dtk.ui index ccccf14..490e700 100644 --- a/src/mainwindow-dtk.ui +++ b/src/mainwindow-dtk.ui @@ -13,7 +13,10 @@ <property name="windowTitle"> <string>MainWindow</string> </property> - <layout class="QGridLayout" name="gridLayout"> + <layout class="QVBoxLayout" name="m_mainWindowLayout"> + <property name="spacing"> + <number>0</number> + </property> <property name="leftMargin"> <number>0</number> </property> @@ -26,560 +29,24 @@ <property name="bottomMargin"> <number>0</number> </property> - <property name="spacing"> - <number>0</number> - </property> - <item row="1" column="1"> - <widget class="QWidget" name="mainpage" native="true"> - <property name="autoFillBackground"> - <bool>true</bool> + <item> + <widget class="DTitlebar" name="titlebar" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> - <property name="styleSheet"> - <string notr="true">.QWidget#mainpage { - background: transparent; - border-radius: 14px; -}</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item row="0" column="0"> - <widget class="QStackedWidget" name="stackedWidget"> - <property name="currentIndex"> - <number>3</number> - </property> - <widget class="QWidget" name="page_1"> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="AppListPage" name="applistpage" native="true"/> - </item> - </layout> - </widget> - <widget class="QWidget" name="page_3"> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="AppListPage" name="applistpage_1" native="true"/> - </item> - </layout> - </widget> - <widget class="QWidget" name="page_2"> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="AppIntoPage" name="appintopage" native="true"/> - </item> - </layout> - </widget> - <widget class="QWidget" name="page_4"> - <layout class="QGridLayout" name="gridLayout_3"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item row="0" column="0"> - <widget class="SettingsPage" name="settingspage" native="true"/> - </item> - </layout> - </widget> - </widget> - </item> - </layout> - </widget> - </item> - <item row="1" column="0"> - <widget class="QWidget" name="leftbar" native="true"> <property name="minimumSize"> <size> - <width>150</width> + <width>0</width> <height>0</height> </size> </property> - <property name="maximumSize"> - <size> - <width>150</width> - <height>16777215</height> - </size> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QPushButton" name="pushButton"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>36</height> - </size> - </property> - <property name="text"> - <string>Home</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="checked"> - <bool>true</bool> - </property> - <property name="autoRepeat"> - <bool>true</bool> - </property> - <property name="autoExclusive"> - <bool>true</bool> - </property> - <property name="autoDefault"> - <bool>true</bool> - </property> - <property name="default"> - <bool>true</bool> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup</string> - </attribute> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton_2"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>36</height> - </size> - </property> - <property name="text"> - <string>Network</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="autoRepeat"> - <bool>true</bool> - </property> - <property name="autoExclusive"> - <bool>true</bool> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup</string> - </attribute> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton_3"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>36</height> - </size> - </property> - <property name="text"> - <string>Chat</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="autoRepeat"> - <bool>true</bool> - </property> - <property name="autoExclusive"> - <bool>true</bool> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup</string> - </attribute> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton_4"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>36</height> - </size> - </property> - <property name="text"> - <string>Music</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="autoRepeat"> - <bool>true</bool> - </property> - <property name="autoExclusive"> - <bool>true</bool> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup</string> - </attribute> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton_5"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>36</height> - </size> - </property> - <property name="text"> - <string>Video</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="autoRepeat"> - <bool>true</bool> - </property> - <property name="autoExclusive"> - <bool>true</bool> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup</string> - </attribute> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton_6"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>36</height> - </size> - </property> - <property name="text"> - <string>Picture</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="autoRepeat"> - <bool>true</bool> - </property> - <property name="autoExclusive"> - <bool>true</bool> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup</string> - </attribute> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton_7"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>36</height> - </size> - </property> - <property name="text"> - <string>Game</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="autoRepeat"> - <bool>true</bool> - </property> - <property name="autoExclusive"> - <bool>true</bool> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup</string> - </attribute> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton_8"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>36</height> - </size> - </property> - <property name="text"> - <string>Office</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="autoRepeat"> - <bool>true</bool> - </property> - <property name="autoExclusive"> - <bool>true</bool> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup</string> - </attribute> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton_9"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>36</height> - </size> - </property> - <property name="text"> - <string>Reading</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="autoRepeat"> - <bool>true</bool> - </property> - <property name="autoExclusive"> - <bool>true</bool> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup</string> - </attribute> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton_10"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>36</height> - </size> - </property> - <property name="text"> - <string>Development</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="autoRepeat"> - <bool>true</bool> - </property> - <property name="autoExclusive"> - <bool>true</bool> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup</string> - </attribute> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton_11"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>36</height> - </size> - </property> - <property name="text"> - <string>Tool</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="autoRepeat"> - <bool>true</bool> - </property> - <property name="autoExclusive"> - <bool>true</bool> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup</string> - </attribute> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton_12"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>36</height> - </size> - </property> - <property name="text"> - <string>Theme</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="autoRepeat"> - <bool>true</bool> - </property> - <property name="autoExclusive"> - <bool>true</bool> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup</string> - </attribute> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton_13"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>36</height> - </size> - </property> - <property name="text"> - <string>Other</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="autoRepeat"> - <bool>true</bool> - </property> - <property name="autoExclusive"> - <bool>true</bool> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <attribute name="buttonGroup"> - <string notr="true">buttonGroup</string> - </attribute> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton_14"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>36</height> - </size> - </property> - <property name="text"> - <string>APP Upgrade</string> - </property> - <property name="checkable"> - <bool>false</bool> - </property> - <property name="autoRepeat"> - <bool>true</bool> - </property> - <property name="autoExclusive"> - <bool>true</bool> - </property> - <property name="flat"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item row="0" column="0" colspan="2"> - <widget class="DTitlebar" name="titlebar" native="true"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>50</height> - </size> - </property> <property name="maximumSize"> <size> <width>16777215</width> - <height>50</height> + <height>16777215</height> </size> </property> <layout class="QHBoxLayout" name="horizontalLayout"> @@ -598,6 +65,572 @@ </layout> </widget> </item> + <item> + <widget class="QWidget" name="centralWidget" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QHBoxLayout" name="m_centralLayout"> + <property name="spacing"> + <number>0</number> + </property> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QWidget" name="leftbar" native="true"> + <property name="minimumSize"> + <size> + <width>150</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>150</width> + <height>16777215</height> + </size> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QPushButton" name="pushButton"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>36</height> + </size> + </property> + <property name="text"> + <string>Home</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="autoRepeat"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup</string> + </attribute> + </widget> + </item> + <item> + <widget class="QPushButton" name="pushButton_2"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>36</height> + </size> + </property> + <property name="text"> + <string>Network</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="autoRepeat"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup</string> + </attribute> + </widget> + </item> + <item> + <widget class="QPushButton" name="pushButton_3"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>36</height> + </size> + </property> + <property name="text"> + <string>Chat</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="autoRepeat"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup</string> + </attribute> + </widget> + </item> + <item> + <widget class="QPushButton" name="pushButton_4"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>36</height> + </size> + </property> + <property name="text"> + <string>Music</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="autoRepeat"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup</string> + </attribute> + </widget> + </item> + <item> + <widget class="QPushButton" name="pushButton_5"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>36</height> + </size> + </property> + <property name="text"> + <string>Video</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="autoRepeat"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup</string> + </attribute> + </widget> + </item> + <item> + <widget class="QPushButton" name="pushButton_6"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>36</height> + </size> + </property> + <property name="text"> + <string>Picture</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="autoRepeat"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup</string> + </attribute> + </widget> + </item> + <item> + <widget class="QPushButton" name="pushButton_7"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>36</height> + </size> + </property> + <property name="text"> + <string>Game</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="autoRepeat"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup</string> + </attribute> + </widget> + </item> + <item> + <widget class="QPushButton" name="pushButton_8"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>36</height> + </size> + </property> + <property name="text"> + <string>Office</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="autoRepeat"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup</string> + </attribute> + </widget> + </item> + <item> + <widget class="QPushButton" name="pushButton_9"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>36</height> + </size> + </property> + <property name="text"> + <string>Reading</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="autoRepeat"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup</string> + </attribute> + </widget> + </item> + <item> + <widget class="QPushButton" name="pushButton_10"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>36</height> + </size> + </property> + <property name="text"> + <string>Development</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="autoRepeat"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup</string> + </attribute> + </widget> + </item> + <item> + <widget class="QPushButton" name="pushButton_11"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>36</height> + </size> + </property> + <property name="text"> + <string>Tool</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="autoRepeat"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup</string> + </attribute> + </widget> + </item> + <item> + <widget class="QPushButton" name="pushButton_12"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>36</height> + </size> + </property> + <property name="text"> + <string>Theme</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="autoRepeat"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup</string> + </attribute> + </widget> + </item> + <item> + <widget class="QPushButton" name="pushButton_13"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>36</height> + </size> + </property> + <property name="text"> + <string>Other</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="autoRepeat"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup</string> + </attribute> + </widget> + </item> + <item> + <widget class="QPushButton" name="pushButton_14"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>36</height> + </size> + </property> + <property name="text"> + <string>APP Upgrade</string> + </property> + <property name="checkable"> + <bool>false</bool> + </property> + <property name="autoRepeat"> + <bool>true</bool> + </property> + <property name="autoExclusive"> + <bool>true</bool> + </property> + <property name="flat"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QWidget" name="mainpage" native="true"> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="styleSheet"> + <string notr="true">.QWidget#mainpage { + background: transparent; + border-radius: 14px; +}</string> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item row="0" column="0"> + <widget class="QStackedWidget" name="stackedWidget"> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="page_1"> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="AppListPage" name="applistpage" native="true"/> + </item> + </layout> + </widget> + <widget class="QWidget" name="page_3"> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="AppListPage" name="applistpage_1" native="true"/> + </item> + </layout> + </widget> + <widget class="QWidget" name="page_2"> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="AppIntoPage" name="appintopage" native="true"/> + </item> + </layout> + </widget> + <widget class="QWidget" name="page_4"> + <layout class="QGridLayout" name="gridLayout_3"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item row="0" column="0"> + <widget class="SettingsPage" name="settingspage" native="true"/> + </item> + </layout> + </widget> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + </item> </layout> </widget> <layoutdefault spacing="6" margin="11"/> diff --git a/src/widgets/common/progressbutton.cpp b/src/widgets/common/progressbutton.cpp index 41a140a..464664e 100644 --- a/src/widgets/common/progressbutton.cpp +++ b/src/widgets/common/progressbutton.cpp @@ -9,10 +9,6 @@ ProgressButton::ProgressButton(QWidget *parent) : QWidget{parent} { - // this->setWindowFlags(Qt::FramelessWindowHint); - // this->setAttribute(Qt::WA_TranslucentBackground, true); - setMinimumSize(36, 36); - svgPath = ""; backColor = Qt::transparent; @@ -77,12 +73,9 @@ void ProgressButton::mousePressEvent(QMouseEvent *event) void ProgressButton::mouseReleaseEvent(QMouseEvent *event) { - if (buttonState == state::hover || buttonState == state::normal) - { - widthChangeValue = (this->width() - 6) / 2; - update(); - } - else if (buttonState == state::closeProgress) + if (buttonState == state::hover + || buttonState == state::normal + || buttonState == state::closeProgress) { update(); } @@ -135,15 +128,11 @@ void ProgressButton::paintEvent(QPaintEvent *event) if (buttonState == state::normal || buttonState == state::hover) { - int radius = (rect.height() - 6) / 2; - painter.translate(rect.center()); + qreal radius = rect.height() / 2.0; + painter.translate(QRectF(rect).center()); painter.setPen(Qt::transparent); - painter.setBrush(QColor(buttonState == state::normal ? color : color.darker())); - // painter.drawEllipse(QPoint(0, 0), radius, radius); - - // radiu -= 3; painter.setBrush(backColor); - painter.drawEllipse(QPoint(0, 0), radius, radius); + painter.drawEllipse(QPointF(0, 0), radius, radius); QSvgRenderer m_svgRender; m_svgRender.load(svgPath); @@ -151,42 +140,34 @@ void ProgressButton::paintEvent(QPaintEvent *event) } else if (buttonState == state::openProgress) { - painter.translate(rect.center()); - int radius = (rect.height() - 6) / 2 - 3; + qreal radius = rect.height() / 2.0 - 1; + painter.translate(QRectF(rect).center()); + painter.setPen(QPen(backColor.darker(), 2)); painter.setBrush(backColor); - painter.setPen(QPen(backColor, 3)); - painter.drawEllipse(QPoint(0, 0), radius, radius); + painter.drawEllipse(QPointF(0, 0), radius, radius); - painter.setPen(QPen(backColor, 3)); + QRectF rectF = QRectF(-radius, -radius, radius * 2, radius * 2); + painter.setPen(QPen(color.darker(100), 2)); + qreal angle = progress * 360 / 100 * 1.0; + painter.drawArc(rectF, 90 * 16, -qIntCast(angle * 16)); QSvgRenderer m_svgRender; m_svgRender.load(svgPath); m_svgRender.render(&painter, QRectF(-radius / 2, -radius / 2, radius, radius)); - - QRect rect = QRect(-radius, -radius, - radius * 2, radius * 2); - - painter.setPen(QPen(color.darker(100), 3)); - qreal angle = progress * 360 / 100 * 1.0; - painter.drawArc(rect.adjusted(-3, -3, 3, 3), 90 * 16, -qIntCast(angle * 16)); } else if (buttonState == state::closeProgress) { - auto radius = (rect.height() - 6) / 2; - painter.translate(rect.center()); - painter.setPen(Qt::transparent); - painter.setBrush(QColor(0, 0, 0, 63)); - painter.drawEllipse(QPoint(0, 0), radius, radius); - - radius -= 3; + qreal radius = rect.height() / 2.0 - 1; + painter.translate(QRectF(rect).center()); + painter.setPen(QPen(color.darker(100), 2)); painter.setBrush(backColor); - painter.drawEllipse(QPoint(0, 0), radius, radius); + painter.drawEllipse(QPointF(0, 0), radius, radius); - painter.setPen(QPen(color, 3, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - painter.drawLine(QPoint(-radius / 3, 0), - QPoint(-radius / 5, radius / 3)); - painter.drawLine(QPoint(-radius / 5, radius / 3), - QPoint(radius / 4, -radius / 4)); + painter.setPen(QPen(color, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + painter.drawLine(QPointF(-radius / 3, 0), + QPointF(-radius / 5, radius / 3)); + painter.drawLine(QPointF(-radius / 5, radius / 3), + QPointF(radius / 4, -radius / 4)); } QWidget::paintEvent(event); } @@ -212,7 +193,7 @@ WaterDrop::WaterDrop(QWidget *parent) // 把鼠标点击的点转换为圆心点坐标 void WaterDrop::move(const QPoint &point) { - QPoint translatePoint = point - QPoint(RADIUS, RADIUS); + QPoint translatePoint = point - rect().center(); QWidget::move(translatePoint); } @@ -223,7 +204,7 @@ void WaterDrop::show() m_waterDropAnimation->setDuration(350); connect(m_waterDropAnimation, &QVariantAnimation::valueChanged, this, &WaterDrop::onRadiusChanged); - connect(m_waterDropAnimation, &QVariantAnimation::finished, this, &WaterDrop::close); + connect(m_waterDropAnimation, &QVariantAnimation::finished, this, &WaterDrop::deleteLater); m_waterDropAnimation->start(QVariantAnimation::DeleteWhenStopped); QWidget::show(); } diff --git a/src/widgets/common/progressbutton.h b/src/widgets/common/progressbutton.h index 1762600..514622f 100644 --- a/src/widgets/common/progressbutton.h +++ b/src/widgets/common/progressbutton.h @@ -52,7 +52,6 @@ private: QColor backColor; QColor color; QString svgPath; - int widthChangeValue{0}; int progress{0};//处理百分比 bool m_mouseMoved = false;