diff --git a/src/widgets/settingspages/GeneralPage.cpp b/src/widgets/settingspages/GeneralPage.cpp index 19a8d80b..06288fcd 100644 --- a/src/widgets/settingspages/GeneralPage.cpp +++ b/src/widgets/settingspages/GeneralPage.cpp @@ -23,16 +23,6 @@ #define addTitle addTitle namespace chatterino { -namespace { - QPushButton *makeOpenSettingDirButton() - { - auto button = new QPushButton("Open AppData directory"); - QObject::connect(button, &QPushButton::clicked, [] { - QDesktopServices::openUrl(getPaths()->rootAppDataDirectory); - }); - return button; - } -} // namespace TitleLabel *SettingsLayout::addTitle(const QString &title) { @@ -426,7 +416,9 @@ void GeneralPage::initLayout(SettingsLayout &layout) layout.addTitle("AppData"); layout.addDescription("All local files like settings and cache files are " "store in this directory."); - layout.addWidget(makeOpenSettingDirButton()); + layout.addButton("Open AppData directory", [] { + QDesktopServices::openUrl(getPaths()->rootAppDataDirectory); + }); // invisible element for width auto inv = new BaseWidget(this); diff --git a/src/widgets/settingspages/GeneralPage.hpp b/src/widgets/settingspages/GeneralPage.hpp index 4e0c1e26..650ff942 100644 --- a/src/widgets/settingspages/GeneralPage.hpp +++ b/src/widgets/settingspages/GeneralPage.hpp @@ -68,6 +68,16 @@ public: pajlada::Settings::Setting &setting, bool editable = false); + template + QPushButton *addButton(const QString &text, OnClick onClick) + { + auto button = new QPushButton(text); + this->groups_.back().widgets.push_back({button, {text}}); + QObject::connect(button, &QPushButton::clicked, onClick); + this->addWidget(button); + return button; + } + template ComboBox *addDropdown( const QString &text, const QStringList &items,