fix: settings "Cancel" button doesn't work first time (#5229)
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "controllers/ignores/IgnorePhrase.hpp"
|
||||
#include "controllers/moderationactions/ModerationAction.hpp"
|
||||
#include "controllers/nicknames/Nickname.hpp"
|
||||
#include "debug/Benchmark.hpp"
|
||||
#include "util/Clamp.hpp"
|
||||
#include "util/PersistSignalVector.hpp"
|
||||
#include "util/WindowsHelper.hpp"
|
||||
@@ -195,6 +196,8 @@ Settings::~Settings()
|
||||
|
||||
void Settings::saveSnapshot()
|
||||
{
|
||||
BenchmarkGuard benchmark("Settings::saveSnapshot");
|
||||
|
||||
rapidjson::Document *d = new rapidjson::Document(rapidjson::kObjectType);
|
||||
rapidjson::Document::AllocatorType &a = d->GetAllocator();
|
||||
|
||||
@@ -230,6 +233,8 @@ void Settings::restoreSnapshot()
|
||||
return;
|
||||
}
|
||||
|
||||
BenchmarkGuard benchmark("Settings::restoreSnapshot");
|
||||
|
||||
const auto &snapshot = *(this->snapshot_.get());
|
||||
|
||||
if (!snapshot.IsObject())
|
||||
|
||||
@@ -341,6 +341,9 @@ void SettingsDialog::showDialog(QWidget *parent,
|
||||
}
|
||||
hasShownBefore = true;
|
||||
|
||||
// Resets the cancel button.
|
||||
getSettings()->saveSnapshot();
|
||||
|
||||
switch (preferredTab)
|
||||
{
|
||||
case SettingsDialogPreference::Accounts:
|
||||
@@ -379,9 +382,6 @@ void SettingsDialog::showDialog(QWidget *parent,
|
||||
|
||||
void SettingsDialog::refresh()
|
||||
{
|
||||
// Resets the cancel button.
|
||||
getSettings()->saveSnapshot();
|
||||
|
||||
// Updates tabs.
|
||||
for (auto *tab : this->tabs_)
|
||||
{
|
||||
@@ -440,11 +440,6 @@ void SettingsDialog::onOkClicked()
|
||||
|
||||
void SettingsDialog::onCancelClicked()
|
||||
{
|
||||
for (auto &tab : this->tabs_)
|
||||
{
|
||||
tab->page()->cancel();
|
||||
}
|
||||
|
||||
getSettings()->restoreSnapshot();
|
||||
|
||||
this->close();
|
||||
|
||||
@@ -87,11 +87,6 @@ void SettingsPage::setTab(SettingsDialogTab *tab)
|
||||
this->tab_ = tab;
|
||||
}
|
||||
|
||||
void SettingsPage::cancel()
|
||||
{
|
||||
this->onCancel_.invoke();
|
||||
}
|
||||
|
||||
QCheckBox *SettingsPage::createCheckBox(
|
||||
const QString &text, pajlada::Settings::Setting<bool> &setting)
|
||||
{
|
||||
|
||||
@@ -56,8 +56,6 @@ public:
|
||||
SettingsDialogTab *tab() const;
|
||||
void setTab(SettingsDialogTab *tab);
|
||||
|
||||
void cancel();
|
||||
|
||||
QCheckBox *createCheckBox(const QString &text,
|
||||
pajlada::Settings::Setting<bool> &setting);
|
||||
QComboBox *createComboBox(const QStringList &items,
|
||||
@@ -86,7 +84,6 @@ public:
|
||||
|
||||
protected:
|
||||
SettingsDialogTab *tab_{};
|
||||
pajlada::Signals::NoArgSignal onCancel_;
|
||||
pajlada::Signals::SignalHolder managedConnections_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user