2021-12-01 15:12:38 +08:00
|
|
|
#include "messageboxutils.h"
|
2022-04-18 17:26:52 +08:00
|
|
|
#include "xatom-helper.h"
|
2021-12-01 15:12:38 +08:00
|
|
|
#include "gsettingswrapper.h"
|
2022-02-15 16:51:03 +08:00
|
|
|
#include "../common/mydefine.h"
|
2022-03-02 11:24:54 +08:00
|
|
|
#include "globalsignals.h"
|
|
|
|
#include "globalbackupinfo.h"
|
2021-12-01 15:12:38 +08:00
|
|
|
#include <QIcon>
|
|
|
|
|
2022-03-02 11:24:54 +08:00
|
|
|
MyMessageBox::MyMessageBox(QWidget *parent) :
|
|
|
|
QMessageBox(parent)
|
|
|
|
{
|
|
|
|
setThemeIcon(THEME_YHKYLIN_BACKUP_TOOLS);
|
|
|
|
}
|
|
|
|
|
|
|
|
MyMessageBox::~MyMessageBox()
|
|
|
|
{}
|
|
|
|
|
|
|
|
void MyMessageBox::setThemeIcon(const QString& themeIcon)
|
|
|
|
{
|
|
|
|
m_themeIcon = themeIcon;
|
|
|
|
on_themeIconChanged();
|
|
|
|
disconnect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::themeIconChanged, this, &MyMessageBox::on_themeIconChanged);
|
|
|
|
connect(GlobelBackupInfo::inst().getGlobalSignals(), &GlobalSignals::themeIconChanged, this, &MyMessageBox::on_themeIconChanged);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyMessageBox::on_themeIconChanged()
|
|
|
|
{
|
2022-06-29 17:34:08 +08:00
|
|
|
QIcon titleIcon = QIcon::fromTheme(m_themeIcon, QIcon(":/images/yhkylin-backup-tools.png"));
|
2022-03-02 11:24:54 +08:00
|
|
|
setWindowIcon(titleIcon);
|
|
|
|
}
|
|
|
|
|
2022-02-15 16:51:03 +08:00
|
|
|
void MessageBoxUtils::QMESSAGE_BOX_INFORMATION(QWidget* q_parent, const QString& typelabel, const QString& message, const QString& label)
|
|
|
|
{
|
2022-04-18 17:26:52 +08:00
|
|
|
MyMessageBox *box = new MyMessageBox(q_parent);
|
2022-02-15 16:51:03 +08:00
|
|
|
|
2022-04-18 17:26:52 +08:00
|
|
|
box->setIcon(QMessageBox::Information);
|
|
|
|
box->setWindowTitle(typelabel);
|
|
|
|
box->setText(message);
|
|
|
|
box->setStandardButtons(QMessageBox::Ok);
|
|
|
|
box->setButtonText(QMessageBox::Ok, label);
|
|
|
|
box->exec();
|
|
|
|
delete box;
|
2022-02-15 16:51:03 +08:00
|
|
|
}
|
|
|
|
|
2021-12-01 15:12:38 +08:00
|
|
|
void MessageBoxUtils::QMESSAGE_BOX_WARNING(QWidget* q_parent, const QString& typelabel, const QString& message, const QString& label)
|
|
|
|
{
|
2022-04-18 17:26:52 +08:00
|
|
|
MyMessageBox *box = new MyMessageBox(q_parent);
|
2021-12-01 15:12:38 +08:00
|
|
|
|
2022-04-18 17:26:52 +08:00
|
|
|
box->setIcon(QMessageBox::Warning);
|
|
|
|
box->setWindowTitle(typelabel);
|
|
|
|
box->setText(message);
|
|
|
|
box->setStandardButtons(QMessageBox::Ok);
|
|
|
|
box->setButtonText(QMessageBox::Ok, label);
|
|
|
|
box->exec();
|
|
|
|
delete box;
|
2021-12-01 15:12:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MessageBoxUtils::QMESSAGE_BOX_WARNING_CANCEL(QWidget *q_parent, const QString &typelabel, const QString &message, const QString &label_yes, const QString &label_no)
|
|
|
|
{
|
2022-04-18 17:26:52 +08:00
|
|
|
MyMessageBox *box = new MyMessageBox(q_parent);
|
2021-12-01 15:12:38 +08:00
|
|
|
|
2022-04-18 17:26:52 +08:00
|
|
|
box->setIcon(QMessageBox::Question);
|
|
|
|
box->setWindowTitle(typelabel);
|
|
|
|
box->setText(message);
|
|
|
|
box->setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
|
|
|
|
box->setButtonText(QMessageBox::Ok, label_yes);
|
|
|
|
box->setButtonText(QMessageBox::Cancel, label_no);
|
|
|
|
if (box->exec() != QMessageBox::Ok) {
|
|
|
|
delete box;
|
2021-12-01 15:12:38 +08:00
|
|
|
return false;
|
2022-04-18 17:26:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
delete box;
|
2021-12-01 15:12:38 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MessageBoxUtils::QMESSAGE_BOX_CRITICAL(QWidget* q_parent, const QString& typelabel, const QString& message, const QString& label)
|
|
|
|
{
|
2022-04-18 17:26:52 +08:00
|
|
|
MyMessageBox *box = new MyMessageBox(q_parent);
|
|
|
|
box->setIcon(QMessageBox::Critical);
|
|
|
|
box->setWindowTitle(typelabel);
|
|
|
|
box->setText(message);
|
|
|
|
box->setStandardButtons(QMessageBox::Ok);
|
|
|
|
box->setButtonText(QMessageBox::Ok, label);
|
|
|
|
box->exec();
|
|
|
|
delete box;
|
2021-12-01 15:12:38 +08:00
|
|
|
}
|