Only one instance of the settings dialog should be open at once

This commit is contained in:
Rasmus Karlsson 2017-05-27 15:40:06 +02:00
parent 5614322a08
commit 0b2b6a0dc7
4 changed files with 15 additions and 4 deletions

View file

@ -181,9 +181,7 @@ void Notebook::resizeEvent(QResizeEvent *)
void Notebook::settingsButtonClicked() void Notebook::settingsButtonClicked()
{ {
SettingsDialog *a = new SettingsDialog(); SettingsDialog::showDialog();
a->show();
} }
void Notebook::usersButtonClicked() void Notebook::usersButtonClicked()

View file

@ -33,6 +33,7 @@ private:
bool _mouseDown = false; bool _mouseDown = false;
QPoint _mousePos; QPoint _mousePos;
}; };
} // namespace widgets } // namespace widgets
} // namespace chatterino } // namespace chatterino

View file

@ -1,6 +1,6 @@
#include "widgets/settingsdialog.h" #include "widgets/settingsdialog.h"
#include "twitch/twitchaccount.h"
#include "accountmanager.h" #include "accountmanager.h"
#include "twitch/twitchaccount.h"
#include "widgets/settingsdialogtab.h" #include "widgets/settingsdialogtab.h"
#include "windowmanager.h" #include "windowmanager.h"
@ -299,6 +299,16 @@ void SettingsDialog::select(SettingsDialogTab *tab)
_selectedTab = tab; _selectedTab = tab;
} }
void SettingsDialog::showDialog()
{
static SettingsDialog *instance = new SettingsDialog();
instance->show();
instance->activateWindow();
instance->raise();
instance->setFocus();
}
/// Widget creation helpers /// Widget creation helpers
QCheckBox *SettingsDialog::createCheckbox(const QString &title, Setting<bool> &setting) QCheckBox *SettingsDialog::createCheckbox(const QString &title, Setting<bool> &setting)
{ {

View file

@ -26,6 +26,8 @@ public:
void select(SettingsDialogTab *tab); void select(SettingsDialogTab *tab);
static void showDialog();
private: private:
SettingsSnapshot _snapshot; SettingsSnapshot _snapshot;