Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 <About> 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."));
Expand Down Expand Up @@ -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 <About> 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;
}
Expand Down
1 change: 1 addition & 0 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Q_OBJECT
void setModeFromSelection(PowerProfile profile);
void realtimeUpdate();
void loadConfigs();
void showMsiEcWarningIfNeeded();

[[nodiscard]] QString intToQString(int value) const;
void updateBatteryCharge();
Expand Down