代码优化,使用智能指针
This commit is contained in:
parent
639fc2fc43
commit
779441b092
|
@ -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()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -10,9 +10,6 @@ class AboutDialog : public kdk::KAboutDialog
|
|||
public:
|
||||
explicit AboutDialog(QWidget *parent = nullptr);
|
||||
~AboutDialog();
|
||||
|
||||
private:
|
||||
QString getBackupVersion();
|
||||
};
|
||||
|
||||
#endif // ABOUTDIALOG_H
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#include "messageboxutils.h"
|
||||
#include "xatom-helper.h"
|
||||
#include <QIcon>
|
||||
#include <QScopedPointer>
|
||||
#include "gsettingswrapper.h"
|
||||
#include "../common/mydefine.h"
|
||||
#include "globalsignals.h"
|
||||
#include "globalbackupinfo.h"
|
||||
#include <QIcon>
|
||||
|
||||
|
||||
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<MyMessageBox> 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<MyMessageBox> 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<MyMessageBox> 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<MyMessageBox> 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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue