From 1fd5872adea45d6a21020fe1bb6874639eb302bd Mon Sep 17 00:00:00 2001 From: gfdgd_xi <3025613752@qq.com> Date: Mon, 27 Jan 2025 13:37:57 +0800 Subject: [PATCH 1/2] =?UTF-8?q?garma=E4=BB=BB=E5=8A=A1=E6=A0=8F=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E4=B8=8D=E5=86=8D=E6=98=BE=E7=A4=BA=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Garma.cpp | 16 ++++++++++++++++ Garma.h | 2 ++ gmessagebox.cpp | 1 + 3 files changed, 19 insertions(+) diff --git a/Garma.cpp b/Garma.cpp index 8a76bcd..6962cc3 100644 --- a/Garma.cpp +++ b/Garma.cpp @@ -327,6 +327,12 @@ Garma::Garma(int &argc, char **argv) : DApplication(argc, argv) } } +void Garma::setDialogIconWithStandard(int index, QDialog *dialog) +{ + auto icon = (enum QStyle::StandardPixmap)index; + dialog->setWindowIcon(DApplication::style()->standardIcon(icon)); +} + bool Garma::error(const QString message) { printf("Error: %s", qPrintable(message)); @@ -628,6 +634,7 @@ char Garma::showCalendar(const QStringList &args) char Garma::showEntry(const QStringList &args) { DInputDialog *dlg = new DInputDialog; + setDialogIconWithStandard(9, dlg); for (int i = 0; i < args.count(); ++i) { if (args.at(i) == "--text") qDebug() << "a"; @@ -658,6 +665,7 @@ char Garma::showEntry(const QStringList &args) char Garma::showPassword(const QStringList &args) { NEW_DIALOG + setDialogIconWithStandard(58, dlg); QLineEdit *username(NULL), *password(NULL); QString prompt = tr("Enter password"); @@ -744,6 +752,7 @@ char Garma::showMessage(const QStringList &args, char type) char Garma::showFileSelection(const QStringList &args) { DFileDialog *dlg = new DFileDialog; + setDialogIconWithStandard(21, dlg); QSettings settings("Garma"); dlg->setViewMode(settings.value("FileDetails", false).toBool() ? DFileDialog::Detail : DFileDialog::List); dlg->setFileMode(DFileDialog::ExistingFile); @@ -849,6 +858,8 @@ char Garma::showList(const QStringList &args) { NEW_DIALOG + setDialogIconWithStandard(33, dlg); + QLabel *lbl; vl->addWidget(lbl = new QLabel(dlg)); @@ -1255,6 +1266,8 @@ char Garma::showScale(const QStringList &args) { NEW_DIALOG + setDialogIconWithStandard(9, dlg); + QHBoxLayout *hl = new QHBoxLayout; QLabel *lbl, *val; QSlider *sld; @@ -1301,6 +1314,7 @@ char Garma::showScale(const QStringList &args) char Garma::showAbout(const QStringList &args) { DAboutDialog *dlg = new DAboutDialog; + setDialogIconWithStandard(9, dlg); for (int i = 0; i < args.count(); ++i) { QString option = args.at(i); if (option == "--description") { @@ -1338,6 +1352,7 @@ char Garma::showAbout(const QStringList &args) char Garma::showText(const QStringList &args) { NEW_DIALOG + setDialogIconWithStandard(9, dlg); QTextBrowser *te; vl->addWidget(te = new QTextBrowser(dlg)); @@ -1548,6 +1563,7 @@ static void buildList(QTreeWidget **tree, QStringList &values, QStringList &colu char Garma::showForms(const QStringList &args) { NEW_DIALOG + setDialogIconWithStandard(9, dlg); dlg->setProperty("Garma_separator", "|"); QLabel *label; diff --git a/Garma.h b/Garma.h index b009c8b..2d007a6 100644 --- a/Garma.h +++ b/Garma.h @@ -83,6 +83,8 @@ private slots: int m_listPrintColumn = -1; bool m_listCheckable = false; + + void setDialogIconWithStandard(int index, QDialog *dialog); }; #endif //Garma_H diff --git a/gmessagebox.cpp b/gmessagebox.cpp index f24099b..007941b 100644 --- a/gmessagebox.cpp +++ b/gmessagebox.cpp @@ -53,6 +53,7 @@ void GMessageBox::setIcon(Icon icon) QPixmap pixmap = DApplication::style()->standardIcon(dialogIcon).pixmap(iconSize, iconSize); pixmap.setDevicePixelRatio(scaleFactor); // 设置像素比以确保显示清晰 this->setIconPixmap(pixmap); + this->setWindowIcon(DApplication::style()->standardIcon(dialogIcon)); } From fcd55d78bee96c142c28bb5963970f54450e67b0 Mon Sep 17 00:00:00 2001 From: gfdgd_xi <3025613752@qq.com> Date: Mon, 27 Jan 2025 15:31:57 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=9C=80=E5=B0=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- debian/changelog | 6 +++-- garma.pro | 3 +++ gmessagebox.cpp | 1 + gprogressdialog.cpp | 39 +++++++++++++++++++++++++++++ gprogressdialog.h | 10 +++++++- images.qrc | 6 +++++ images/spinner_decrease_hover.png | Bin 0 -> 118 bytes images/spinner_decrease_normal.png | Bin 0 -> 119 bytes 8 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 images.qrc create mode 100644 images/spinner_decrease_hover.png create mode 100644 images/spinner_decrease_normal.png diff --git a/debian/changelog b/debian/changelog index 72e31c5..aafe323 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,9 @@ -garma (1.2.2) UNRELEASED; urgency=medium +garma (1.2.3) UNRELEASED; urgency=medium * 修复 Garma 图标在高分屏模糊 + * 进度窗口支持最小化 + + -- gfdgd_xi <3025613752@qq.com> Mon, 27 Jan 2025 15:31:31 +0800 - -- gfdgd_xi <3025613752@qq.com> Sat, 23 Nov 2024 20:33:15 +0800 garma (1.2.1-2) UNRELEASED; urgency=medium * 修复问题 https://gitee.com/GXDE-OS/GXDE/issues/IAU9XH diff --git a/garma.pro b/garma.pro index 5a1ad29..3256b9b 100644 --- a/garma.pro +++ b/garma.pro @@ -36,3 +36,6 @@ translations.files = translations/*.qm target.path = $$PREFIX/bin INSTALLS += target translations + +RESOURCES += \ + images.qrc diff --git a/gmessagebox.cpp b/gmessagebox.cpp index 007941b..d7978c7 100644 --- a/gmessagebox.cpp +++ b/gmessagebox.cpp @@ -126,6 +126,7 @@ void GMessageBox::setStandardButtonsWithList(QList buttons) void GMessageBox::setText(const QString &text) { + this->setWindowTitle(text); QLabel *label = findChild("MessageLabel"); if (label) { qDebug() << "Find Label"; diff --git a/gprogressdialog.cpp b/gprogressdialog.cpp index 35f749a..3b5e776 100644 --- a/gprogressdialog.cpp +++ b/gprogressdialog.cpp @@ -1,5 +1,7 @@ #include "gprogressdialog.h" #include "dimagebutton.h" +#include "dapplication.h" +#include DWIDGET_USE_NAMESPACE @@ -21,11 +23,47 @@ GProgressDialog::GProgressDialog(QWidget *parent) m_dialogWidget->setLayout(m_layout); this->addContent(m_dialogWidget); + m_closeButton = this->findChild("CloseButton"); + + // 最小化按钮 + m_miniButton = new DImageButton(this); + m_miniButton ->setObjectName("MiniButton"); + m_miniButton ->adjustSize(); + m_miniButton->setStyleSheet("qproperty-normalPic: url(:/images/spinner_decrease_normal.png);" + "qproperty-hoverPic: url(:/images/spinner_decrease_hover.png);"); + //m_miniButton ->setFixedSize(DIALOG::CLOSE_BUTTON_WIDTH, DIALOG::CLOSE_BUTTON_HEIGHT); + m_miniButton ->setAttribute(Qt::WA_NoMousePropagation); + connect(m_miniButton, &DImageButton::clicked, this, &GProgressDialog::showMinimized); + addButton(tr("Cancel"), true, ButtonType::ButtonWarning); installEventFilter(this); setFocusPolicy(Qt::StrongFocus); + + auto dialogIcon = (enum QStyle::StandardPixmap)9; + this->setWindowIcon(DApplication::style()->standardIcon(dialogIcon)); + + resizeMiniButton(); +} + +void GProgressDialog::resizeMiniButton() +{ + // 重新最小化按钮大小 + if (!m_closeButton || !m_miniButton) { + return; + } + m_miniButton->setGeometry(m_closeButton->x() - m_closeButton->width() - m_closeButton->width() / 5, + m_closeButton->y(), + m_closeButton->width(), + m_closeButton->height()); +} + +void GProgressDialog::resizeEvent(QResizeEvent *event) +{ + DDialog::resizeEvent(event); + // 重新计算最小化按钮大小 + resizeMiniButton(); } void GProgressDialog::reject() @@ -45,6 +83,7 @@ void GProgressDialog::setLabelText(QString text) { // 设置文本居中 m_tipsText->setText(" " + text.replace("\\n", "\n")); + this->setWindowTitle(text); } void GProgressDialog::setValue(int value) diff --git a/gprogressdialog.h b/gprogressdialog.h index 5eb40c8..4c62f94 100644 --- a/gprogressdialog.h +++ b/gprogressdialog.h @@ -11,6 +11,8 @@ #include "ddialog.h" #include #include +#include "dimagebutton.h" + DWIDGET_BEGIN_NAMESPACE class GProgressDialog: public DDialog @@ -34,6 +36,9 @@ class GProgressDialog: public DDialog QPushButton *m_cancelButton; QGridLayout *m_layout; QWidget *m_dialogWidget; + DImageButton *m_miniButton; + DImageButton *m_closeButton; + // 需要自行实现范围的计算 int m_maximum = 100; int m_minimum = 0; @@ -42,7 +47,10 @@ class GProgressDialog: public DDialog bool m_isEnabledCloseButton = true; - void reject(); + void reject() override; + + void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; + void resizeMiniButton(); }; DWIDGET_END_NAMESPACE diff --git a/images.qrc b/images.qrc new file mode 100644 index 0000000..076f20b --- /dev/null +++ b/images.qrc @@ -0,0 +1,6 @@ + + + images/spinner_decrease_hover.png + images/spinner_decrease_normal.png + + diff --git a/images/spinner_decrease_hover.png b/images/spinner_decrease_hover.png new file mode 100644 index 0000000000000000000000000000000000000000..d76ea2e5b3a29fdee673979547c5d9233aaf03b2 GIT binary patch literal 118 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1|*Mc$*~4fjKx9jP7LeL$-D$|3_M*NLo5W7 z6C_v{D;h{K9oArxDEzr}_wL{JdX^<0FI@_n^K8Lt*{A(&2QoM=7_l&HJk7#%S1@Q1 PP%ne0tDnm{r-UW|$jBp# literal 0 HcmV?d00001 diff --git a/images/spinner_decrease_normal.png b/images/spinner_decrease_normal.png new file mode 100644 index 0000000000000000000000000000000000000000..09683164dc4c84757bfaa3204f24b82f323a21a0 GIT binary patch literal 119 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1|*Mc$*~4fjKx9jP7LeL$-D$|3_V>OLo5W7 z6C_v{D;h{K9oArxDExW!;K7IXdX^<0nc4Xsn6Ssb)u=aNadU2%rpUn1EziPq^Z9W{ Ppk@Y7S3j3^P6