feat: Add crash recovery on Windows (#5012)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user