From 8a25a47674088c61d58e166166633e283bbeecd3 Mon Sep 17 00:00:00 2001 From: likehomedream Date: Tue, 19 Dec 2023 15:44:04 +0800 Subject: [PATCH] fix some error --- src/mainwindow.cpp | 11 +++++++++++ src/module/cacheconfirmedwidget.cpp | 6 ++++++ src/module/cacheconfirmedwidget.h | 4 +++- src/module/historywidget.cpp | 20 ++++++++++++++++++-- src/module/historywidget.h | 1 + src/module/infocreatewidget.cpp | 2 ++ 6 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 71e1ec9..b747d1e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -390,6 +390,17 @@ void MainWindow::onGoHomeClicked() connect(m_cacheConfirmedWidget, &cacheConfirmedWidget::cacheCancel, this, [=](){ m_titlebar->setGoHomeBtn(true); }); + connect(m_cacheConfirmedWidget, &cacheConfirmedWidget::visibilityChanged, this, [=](bool visible) { + if (!visible) { + if(m_stackedWidget->currentIndex() == 0){ + m_titlebar->setGoHomeBtn(false); + } else { + m_titlebar->setGoHomeBtn(true); + } + } else { + qDebug() << "m_cacheConfirmedWidget is visible"; + } + }); } else { if(!m_ishistory){ //无修改时,删除时间戳目录 diff --git a/src/module/cacheconfirmedwidget.cpp b/src/module/cacheconfirmedwidget.cpp index 2c68742..225750d 100644 --- a/src/module/cacheconfirmedwidget.cpp +++ b/src/module/cacheconfirmedwidget.cpp @@ -50,3 +50,9 @@ cacheConfirmedWidget::cacheConfirmedWidget(QWidget *parent) this->close(); }); } + +void cacheConfirmedWidget::closeEvent(QCloseEvent *event) +{ + emit visibilityChanged(false); + QWidget::closeEvent(event); +} diff --git a/src/module/cacheconfirmedwidget.h b/src/module/cacheconfirmedwidget.h index e3065ef..5ec8cfa 100644 --- a/src/module/cacheconfirmedwidget.h +++ b/src/module/cacheconfirmedwidget.h @@ -16,11 +16,13 @@ class cacheConfirmedWidget : public QWidget Q_OBJECT public: explicit cacheConfirmedWidget(QWidget *parent = nullptr); - +protected: + void closeEvent(QCloseEvent *event) override; signals: void cacheSave(); void cacheClean(); void cacheCancel(); + void visibilityChanged(bool visible); private: QVBoxLayout *m_cacheConfirmedWidget; QLabel *m_questionMessage; diff --git a/src/module/historywidget.cpp b/src/module/historywidget.cpp index 73e1798..9468046 100644 --- a/src/module/historywidget.cpp +++ b/src/module/historywidget.cpp @@ -170,6 +170,8 @@ HistoryButton::HistoryButton(QWidget* parent): QPushButton(parent) void HistoryButton::setHistoryTime(const QString &text) { m_historytime = text; + QDateTime dateTime = QDateTime::fromString(text, "yyyyMMddhhmmss"); + m_showhistorytime = dateTime.toString("yyyy/MM/dd/hh:mm:ss"); } void HistoryButton::setCover(const QString & covePath) @@ -222,14 +224,28 @@ void HistoryButton::initUI() } layout->addWidget(label1); - QLabel* label2 = new QLabel(m_historytime); + QLabel* label2 = new QLabel(m_showhistorytime); layout->addWidget(label2); QWidget * btnwidget = new QWidget(this); QHBoxLayout * btnwidgetlayout = new QHBoxLayout(btnwidget); btnwidgetlayout->setContentsMargins(0,0,0,0); - QPushButton* button = new QPushButton(m_themetype); + QPushButton* button; + QString buttonText; + if (m_themetype == "globalTheme") { + buttonText = tr("globalTheme"); + } else if (m_themetype == "iconTheme") { + buttonText = tr("iconTheme"); + } else if (m_themetype == "cursorTheme") { + buttonText = tr("cursorTheme"); + } else if (m_themetype == "plymouthTheme") { + buttonText = tr("plymouthTheme"); + } else { + buttonText = tr("grubTheme"); + } + button = new QPushButton(buttonText, this); + QPushButton* btn_menu = new QPushButton("···"); btn_menu->setFixedWidth(50); btnwidgetlayout->addWidget(button); diff --git a/src/module/historywidget.h b/src/module/historywidget.h index 6b98e02..55c55e3 100644 --- a/src/module/historywidget.h +++ b/src/module/historywidget.h @@ -34,6 +34,7 @@ signals: void startBuild(QString &historytime); private: QString m_historytime = nullptr; + QString m_showhistorytime = nullptr; QString m_coverpath = nullptr; QString m_themename = nullptr; QString m_themetype = nullptr; diff --git a/src/module/infocreatewidget.cpp b/src/module/infocreatewidget.cpp index 74a7f71..d76e23c 100644 --- a/src/module/infocreatewidget.cpp +++ b/src/module/infocreatewidget.cpp @@ -297,6 +297,8 @@ void InfoCreateWidget::InfoProcess(){ //创建control/changelog文件 connect(m_recogniseBtn, &QPushButton::clicked,this,[=](){ + //判断是否为空,不为空设置值为未命名x + createControlChangelog(FileProcess::g_date); createMeson(FileProcess::g_date); emit readytoSave();