From 350db32af61a154bcbb4b9c3a544302cf1af188f Mon Sep 17 00:00:00 2001 From: Sherefsiz Date: Mon, 4 May 2026 11:37:26 +0300 Subject: [PATCH] Add dismiss option for msi-ec warning dialog --- src/mainwindow.cpp | 29 +++++++++++++++++++++++++---- src/mainwindow.h | 1 + 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c5f29ba..7577f8f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -31,6 +31,8 @@ bool isUpdateDataError = false; QTimer *realtimeUpdateTimer = new QTimer; +const QString hideMsiEcWarningSettingKey = "Settings/HideMsiEcWarning"; + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); @@ -154,10 +156,7 @@ MainWindow::MainWindow(QWidget *parent) ui->tabWidget->setTabVisible(5, false); setTabsEnabled(false); - if (!operate.isMsiEcLoaded()) { - QMessageBox::critical(nullptr, this->windowTitle(), tr("The msi-ec module is not loaded/installed.\n" - "Check the page for more info.")); - } + showMsiEcWarningIfNeeded(); if (!operate.isEcSysModuleLoaded() && !operate.loadEcSysModule()) QMessageBox::critical(nullptr, this->windowTitle(), tr("The ec_sys module couldn't be detected, it might be required to control the fans.")); @@ -187,6 +186,28 @@ MainWindow::~MainWindow() { delete ui; } +void MainWindow::showMsiEcWarningIfNeeded() { + Settings settings; + if (operate.isMsiEcLoaded() || settings.getValue(hideMsiEcWarningSettingKey).toBool()) + return; + + QMessageBox messageBox(this); + messageBox.setIcon(QMessageBox::Critical); + messageBox.setWindowTitle(this->windowTitle()); + messageBox.setText(tr("The msi-ec module is not loaded/installed.\n" + "Check the page for more info.")); + + QPushButton *okButton = messageBox.addButton(tr("Ok"), QMessageBox::AcceptRole); + QPushButton *doNotShowAgainButton = messageBox.addButton(tr("Do not show again"), QMessageBox::ActionRole); + + messageBox.exec(); + + if (messageBox.clickedButton() == doNotShowAgainButton) + Settings::setValue(hideMsiEcWarningSettingKey, true); + else if (messageBox.clickedButton() == okButton) + Settings::setValue(hideMsiEcWarningSettingKey, false); +} + void MainWindow::setUpdateDataError(bool error) { isUpdateDataError = error; } diff --git a/src/mainwindow.h b/src/mainwindow.h index 83019b0..696d568 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -49,6 +49,7 @@ Q_OBJECT void setModeFromSelection(PowerProfile profile); void realtimeUpdate(); void loadConfigs(); + void showMsiEcWarningIfNeeded(); [[nodiscard]] QString intToQString(int value) const; void updateBatteryCharge();