mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
fix: settings "Cancel" button doesn't work first time (#5229)
This commit is contained in:
parent
c50791972d
commit
2e77b47ea1
5 changed files with 9 additions and 16 deletions
|
@ -100,6 +100,7 @@
|
||||||
- Bugfix: Fixed link info not updating without moving the cursor. (#5178)
|
- Bugfix: Fixed link info not updating without moving the cursor. (#5178)
|
||||||
- Bugfix: Fixed an upload sometimes failing when copying an image from a browser if it contained extra properties. (#5156)
|
- Bugfix: Fixed an upload sometimes failing when copying an image from a browser if it contained extra properties. (#5156)
|
||||||
- Bugfix: Fixed tooltips getting out of bounds when loading images. (#5186)
|
- Bugfix: Fixed tooltips getting out of bounds when loading images. (#5186)
|
||||||
|
- Bugfix: Fixed the "Cancel" button in the settings dialog only working after opening the settings dialog twice. (#5229)
|
||||||
- Bugfix: Fixed split header tooltips showing in the wrong position on Windows. (#5230)
|
- Bugfix: Fixed split header tooltips showing in the wrong position on Windows. (#5230)
|
||||||
- Bugfix: Fixed split header tooltips appearing too tall. (#5232)
|
- Bugfix: Fixed split header tooltips appearing too tall. (#5232)
|
||||||
- Dev: Run miniaudio in a separate thread, and simplify it to not manage the device ourselves. There's a chance the simplification is a bad idea. (#4978)
|
- Dev: Run miniaudio in a separate thread, and simplify it to not manage the device ourselves. There's a chance the simplification is a bad idea. (#4978)
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "controllers/ignores/IgnorePhrase.hpp"
|
#include "controllers/ignores/IgnorePhrase.hpp"
|
||||||
#include "controllers/moderationactions/ModerationAction.hpp"
|
#include "controllers/moderationactions/ModerationAction.hpp"
|
||||||
#include "controllers/nicknames/Nickname.hpp"
|
#include "controllers/nicknames/Nickname.hpp"
|
||||||
|
#include "debug/Benchmark.hpp"
|
||||||
#include "util/Clamp.hpp"
|
#include "util/Clamp.hpp"
|
||||||
#include "util/PersistSignalVector.hpp"
|
#include "util/PersistSignalVector.hpp"
|
||||||
#include "util/WindowsHelper.hpp"
|
#include "util/WindowsHelper.hpp"
|
||||||
|
@ -195,6 +196,8 @@ Settings::~Settings()
|
||||||
|
|
||||||
void Settings::saveSnapshot()
|
void Settings::saveSnapshot()
|
||||||
{
|
{
|
||||||
|
BenchmarkGuard benchmark("Settings::saveSnapshot");
|
||||||
|
|
||||||
rapidjson::Document *d = new rapidjson::Document(rapidjson::kObjectType);
|
rapidjson::Document *d = new rapidjson::Document(rapidjson::kObjectType);
|
||||||
rapidjson::Document::AllocatorType &a = d->GetAllocator();
|
rapidjson::Document::AllocatorType &a = d->GetAllocator();
|
||||||
|
|
||||||
|
@ -230,6 +233,8 @@ void Settings::restoreSnapshot()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BenchmarkGuard benchmark("Settings::restoreSnapshot");
|
||||||
|
|
||||||
const auto &snapshot = *(this->snapshot_.get());
|
const auto &snapshot = *(this->snapshot_.get());
|
||||||
|
|
||||||
if (!snapshot.IsObject())
|
if (!snapshot.IsObject())
|
||||||
|
|
|
@ -341,6 +341,9 @@ void SettingsDialog::showDialog(QWidget *parent,
|
||||||
}
|
}
|
||||||
hasShownBefore = true;
|
hasShownBefore = true;
|
||||||
|
|
||||||
|
// Resets the cancel button.
|
||||||
|
getSettings()->saveSnapshot();
|
||||||
|
|
||||||
switch (preferredTab)
|
switch (preferredTab)
|
||||||
{
|
{
|
||||||
case SettingsDialogPreference::Accounts:
|
case SettingsDialogPreference::Accounts:
|
||||||
|
@ -379,9 +382,6 @@ void SettingsDialog::showDialog(QWidget *parent,
|
||||||
|
|
||||||
void SettingsDialog::refresh()
|
void SettingsDialog::refresh()
|
||||||
{
|
{
|
||||||
// Resets the cancel button.
|
|
||||||
getSettings()->saveSnapshot();
|
|
||||||
|
|
||||||
// Updates tabs.
|
// Updates tabs.
|
||||||
for (auto *tab : this->tabs_)
|
for (auto *tab : this->tabs_)
|
||||||
{
|
{
|
||||||
|
@ -440,11 +440,6 @@ void SettingsDialog::onOkClicked()
|
||||||
|
|
||||||
void SettingsDialog::onCancelClicked()
|
void SettingsDialog::onCancelClicked()
|
||||||
{
|
{
|
||||||
for (auto &tab : this->tabs_)
|
|
||||||
{
|
|
||||||
tab->page()->cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
getSettings()->restoreSnapshot();
|
getSettings()->restoreSnapshot();
|
||||||
|
|
||||||
this->close();
|
this->close();
|
||||||
|
|
|
@ -87,11 +87,6 @@ void SettingsPage::setTab(SettingsDialogTab *tab)
|
||||||
this->tab_ = tab;
|
this->tab_ = tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsPage::cancel()
|
|
||||||
{
|
|
||||||
this->onCancel_.invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
QCheckBox *SettingsPage::createCheckBox(
|
QCheckBox *SettingsPage::createCheckBox(
|
||||||
const QString &text, pajlada::Settings::Setting<bool> &setting)
|
const QString &text, pajlada::Settings::Setting<bool> &setting)
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,8 +56,6 @@ public:
|
||||||
SettingsDialogTab *tab() const;
|
SettingsDialogTab *tab() const;
|
||||||
void setTab(SettingsDialogTab *tab);
|
void setTab(SettingsDialogTab *tab);
|
||||||
|
|
||||||
void cancel();
|
|
||||||
|
|
||||||
QCheckBox *createCheckBox(const QString &text,
|
QCheckBox *createCheckBox(const QString &text,
|
||||||
pajlada::Settings::Setting<bool> &setting);
|
pajlada::Settings::Setting<bool> &setting);
|
||||||
QComboBox *createComboBox(const QStringList &items,
|
QComboBox *createComboBox(const QStringList &items,
|
||||||
|
@ -86,7 +84,6 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SettingsDialogTab *tab_{};
|
SettingsDialogTab *tab_{};
|
||||||
pajlada::Signals::NoArgSignal onCancel_;
|
|
||||||
pajlada::Signals::SignalHolder managedConnections_;
|
pajlada::Signals::SignalHolder managedConnections_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue