From b1e681e129d87cb2f8aab89a734ab7b185975bcd Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Sat, 25 Jul 2020 23:18:47 -0400 Subject: hide tutorial question option --- src/mainwindow.cpp | 30 +++++++++++++++++++++++++----- src/mainwindow.h | 1 + src/settings.cpp | 11 +++++++++++ src/settings.h | 3 +++ 4 files changed, 40 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c2d83e36..60ad77a0 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1334,6 +1334,30 @@ void MainWindow::hookUpWindowTutorials() } } +bool MainWindow::shouldStartTutorial() const +{ + if (GlobalSettings::hideTutorialQuestion()) { + return false; + } + + QMessageBox dlg( + QMessageBox::Question, tr("Show tutorial?"), + tr("You are starting Mod Organizer for the first time. " + "Do you want to show a tutorial of its basic features? If you choose " + "no you can always start the tutorial from the \"Help\"-menu."), + QMessageBox::Yes | QMessageBox::No); + + dlg.setCheckBox(new QCheckBox(tr("Never ask to show tutorials"))); + + const auto r = dlg.exec(); + + if (dlg.checkBox()->isChecked()) { + GlobalSettings::setHideTutorialQuestion(true); + } + + return (r == QMessageBox::Yes); +} + void MainWindow::showEvent(QShowEvent *event) { QMainWindow::showEvent(event); @@ -1360,11 +1384,7 @@ void MainWindow::showEvent(QShowEvent *event) if (m_OrganizerCore.settings().firstStart()) { QString firstStepsTutorial = ToQString(AppConfig::firstStepsTutorial()); if (TutorialManager::instance().hasTutorial(firstStepsTutorial)) { - if (QMessageBox::question(this, tr("Show tutorial?"), - tr("You are starting Mod Organizer for the first time. " - "Do you want to show a tutorial of its basic features? If you choose " - "no you can always start the tutorial from the \"Help\"-menu."), - QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { + if (shouldStartTutorial()) { TutorialManager::instance().activateTutorial("MainWindow", firstStepsTutorial); } } else { diff --git a/src/mainwindow.h b/src/mainwindow.h index 814e0363..8b2188c8 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -506,6 +506,7 @@ private slots: void hideSaveGameInfo(); void hookUpWindowTutorials(); + bool shouldStartTutorial() const; void resumeDownload(int downloadIndex); void endorseMod(ModInfo::Ptr mod); diff --git a/src/settings.cpp b/src/settings.cpp index 4ee4cd81..a0758bd4 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -2212,7 +2212,18 @@ void GlobalSettings::setHideCreateInstanceIntro(bool b) settings().setValue("HideCreateInstanceIntro", b); } +bool GlobalSettings::hideTutorialQuestion() +{ + return settings().value("HideTutorialQuestion", false).toBool(); +} + +void GlobalSettings::setHideTutorialQuestion(bool b) +{ + settings().setValue("HideTutorialQuestion", b); +} + void GlobalSettings::resetDialogs() { setHideCreateInstanceIntro(false); + setHideTutorialQuestion(false); } diff --git a/src/settings.h b/src/settings.h index dd8abf3f..a9501b9d 100644 --- a/src/settings.h +++ b/src/settings.h @@ -841,6 +841,9 @@ public: static bool hideCreateInstanceIntro(); static void setHideCreateInstanceIntro(bool b); + static bool hideTutorialQuestion(); + static void setHideTutorialQuestion(bool b); + // resets anything that the user can disable static void resetDialogs(); -- cgit v1.3.1