From 779441b0928b7f5f75a89cc4ef073e42deab8acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=B0=91=E5=8B=87?= Date: Wed, 12 Apr 2023 12:16:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96=EF=BC=8C?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=99=BA=E8=83=BD=E6=8C=87=E9=92=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kybackup/aboutdialog.cpp | 16 +--------------- kybackup/aboutdialog.h | 3 --- kybackup/messageboxutils.cpp | 21 +++++++-------------- 3 files changed, 8 insertions(+), 32 deletions(-) diff --git a/kybackup/aboutdialog.cpp b/kybackup/aboutdialog.cpp index ff01e21..e67d805 100755 --- a/kybackup/aboutdialog.cpp +++ b/kybackup/aboutdialog.cpp @@ -13,7 +13,7 @@ AboutDialog::AboutDialog(QWidget *parent) : setAppIcon(QIcon::fromTheme(THEME_YHKYLIN_BACKUP_TOOLS, QIcon(":/images/yhkylin-backup-tools.png"))); //setWindowTitle(tr("Backup & Restore")); setAppName(tr("Backup & Restore")); - setAppVersion(tr("version:") + getBackupVersion()); + setAppVersion(tr("version:") + Utils::getBackupVersion()); // 麒麟备份还原工具是一款支持系统备份还原和数据备份还原的工具,当用户数据损坏或系统遭受攻击时能够通过该工具灵活的还原到备份节点的状态。针对国产软硬件平台开展了大量的优化和创新。 setBodyText(tr("The backup tool is a tool that supports system backup and data backup. " "When the user data is damaged or the system is attacked, the tool can flexibly restore " @@ -27,20 +27,6 @@ AboutDialog::AboutDialog(QWidget *parent) : }); } -QString AboutDialog::getBackupVersion() -{ - QString version; - Utils::executeCMD("dpkg -l yhkylin-backup-tools | grep yhkylin-backup-tools", version); - // "ii yhkylin-backup-tools 4.0.13-kylin72 amd64 YHkylin backup tools\n" - QStringList fields = version.split(QRegularExpression("[ \t]+")); - if (fields.size() >= 3) - version = fields.at(2); - else - version = "none"; - - return version; -} - AboutDialog::~AboutDialog() { } diff --git a/kybackup/aboutdialog.h b/kybackup/aboutdialog.h index c82bdeb..374975f 100755 --- a/kybackup/aboutdialog.h +++ b/kybackup/aboutdialog.h @@ -10,9 +10,6 @@ class AboutDialog : public kdk::KAboutDialog public: explicit AboutDialog(QWidget *parent = nullptr); ~AboutDialog(); - -private: - QString getBackupVersion(); }; #endif // ABOUTDIALOG_H diff --git a/kybackup/messageboxutils.cpp b/kybackup/messageboxutils.cpp index e3d60c3..5407cdf 100755 --- a/kybackup/messageboxutils.cpp +++ b/kybackup/messageboxutils.cpp @@ -1,10 +1,11 @@ #include "messageboxutils.h" -#include "xatom-helper.h" +#include +#include #include "gsettingswrapper.h" #include "../common/mydefine.h" #include "globalsignals.h" #include "globalbackupinfo.h" -#include + MyMessageBox::MyMessageBox(QWidget *parent) : QMessageBox(parent) @@ -43,34 +44,29 @@ void MyMessageBox::on_iconChanged() void MessageBoxUtils::QMESSAGE_BOX_INFORMATION(QWidget* q_parent, const QString& typelabel, const QString& message, const QString& label) { - MyMessageBox *box = new MyMessageBox(q_parent); - + QScopedPointer box(new MyMessageBox(q_parent)); box->setMsgIcon(QMessageBox::Information); box->setWindowTitle(typelabel); box->setText(message); box->setStandardButtons(QMessageBox::Ok); box->setButtonText(QMessageBox::Ok, label); box->exec(); - delete box; } void MessageBoxUtils::QMESSAGE_BOX_WARNING(QWidget* q_parent, const QString& typelabel, const QString& message, const QString& label) { - MyMessageBox *box = new MyMessageBox(q_parent); - + QScopedPointer box(new MyMessageBox(q_parent)); box->setMsgIcon(QMessageBox::Warning); box->setWindowTitle(typelabel); box->setText(message); box->setStandardButtons(QMessageBox::Ok); box->setButtonText(QMessageBox::Ok, label); box->exec(); - delete box; } bool MessageBoxUtils::QMESSAGE_BOX_WARNING_CANCEL(QWidget *q_parent, const QString &typelabel, const QString &message, const QString &label_yes, const QString &label_no) { - MyMessageBox *box = new MyMessageBox(q_parent); - + QScopedPointer box(new MyMessageBox(q_parent)); box->setMsgIcon(QMessageBox::Question); box->setWindowTitle(typelabel); box->setText(message); @@ -78,22 +74,19 @@ bool MessageBoxUtils::QMESSAGE_BOX_WARNING_CANCEL(QWidget *q_parent, const QStri box->setButtonText(QMessageBox::Ok, label_yes); box->setButtonText(QMessageBox::Cancel, label_no); if (box->exec() != QMessageBox::Ok) { - delete box; return false; } - delete box; return true; } void MessageBoxUtils::QMESSAGE_BOX_CRITICAL(QWidget* q_parent, const QString& typelabel, const QString& message, const QString& label) { - MyMessageBox *box = new MyMessageBox(q_parent); + QScopedPointer box(new MyMessageBox(q_parent)); box->setMsgIcon(QMessageBox::Critical); box->setWindowTitle(typelabel); box->setText(message); box->setStandardButtons(QMessageBox::Ok); box->setButtonText(QMessageBox::Ok, label); box->exec(); - delete box; }