feat: Add crash recovery on Windows (#5012)

This commit is contained in:
nerix
2023-12-24 15:38:58 +01:00
committed by GitHub
parent 2cb965d352
commit 25add89b14
29 changed files with 563 additions and 258 deletions
+9 -2
View File
@@ -8,6 +8,7 @@
#include "controllers/sound/ISoundController.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchIrcServer.hpp"
#include "singletons/CrashHandler.hpp"
#include "singletons/Fonts.hpp"
#include "singletons/NativeMessaging.hpp"
#include "singletons/Paths.hpp"
@@ -875,8 +876,14 @@ void GeneralPage::initLayout(GeneralPageView &layout)
s.openLinksIncognito);
}
layout.addCheckbox(
"Restart on crash", s.restartOnCrash, false,
layout.addCustomCheckbox(
"Restart on crash (requires restart)",
[] {
return getApp()->crashHandler->shouldRecover();
},
[](bool on) {
return getApp()->crashHandler->saveShouldRecover(on);
},
"When possible, restart Chatterino if the program crashes");
#if defined(Q_OS_LINUX) && !defined(NO_QTKEYCHAIN)
@@ -125,6 +125,28 @@ QCheckBox *GeneralPageView::addCheckbox(const QString &text,
return check;
}
QCheckBox *GeneralPageView::addCustomCheckbox(const QString &text,
const std::function<bool()> &load,
std::function<void(bool)> save,
const QString &toolTipText)
{
auto *check = new QCheckBox(text);
this->addToolTip(*check, toolTipText);
check->setChecked(load());
QObject::connect(check, &QCheckBox::toggled, this,
[save = std::move(save)](bool state) {
save(state);
});
this->addWidget(check);
this->groups_.back().widgets.push_back({check, {text}});
return check;
}
ComboBox *GeneralPageView::addDropdown(const QString &text,
const QStringList &list,
QString toolTipText)
@@ -103,6 +103,11 @@ public:
/// @param inverse Inverses true to false and vice versa
QCheckBox *addCheckbox(const QString &text, BoolSetting &setting,
bool inverse = false, QString toolTipText = {});
QCheckBox *addCustomCheckbox(const QString &text,
const std::function<bool()> &load,
std::function<void(bool)> save,
const QString &toolTipText = {});
ComboBox *addDropdown(const QString &text, const QStringList &items,
QString toolTipText = {});
ComboBox *addDropdown(const QString &text, const QStringList &items,