mirror-chatterino2/src/widgets/dialogs/SettingsDialog.hpp
Mm2PL 703f3717e2
Add custom hotkeys. (#2340)
Co-authored-by: LosFarmosCTL <80157503+LosFarmosCTL@users.noreply.github.com>
Co-authored-by: Paweł <zneix@zneix.eu>
Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com>
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
2021-11-21 17:46:21 +00:00

81 lines
1.9 KiB
C++

#pragma once
#include "widgets/BaseWindow.hpp"
#include <QPushButton>
#include <QStackedLayout>
#include <QVBoxLayout>
#include <QWidget>
#include <functional>
#include <pajlada/settings/setting.hpp>
#include "widgets/helper/SettingsDialogTab.hpp"
#include <QFrame>
class QLineEdit;
namespace chatterino {
class SettingsPage;
class SettingsDialogTab;
class ModerationPage;
class PageHeader : public QFrame
{
Q_OBJECT
};
enum class SettingsDialogPreference {
NoPreference,
Accounts,
ModerationActions,
};
class SettingsDialog : public BaseWindow
{
SettingsDialog(QWidget *parent);
public:
static void showDialog(QWidget *parent,
SettingsDialogPreference preferredTab =
SettingsDialogPreference::NoPreference);
protected:
virtual void scaleChangedEvent(float newDpi) override;
virtual void themeChangedEvent() override;
virtual void showEvent(QShowEvent *) override;
private:
void refresh();
void initUi();
SettingsDialogTab *tab(SettingsTabId id);
void addTabs();
void addTab(std::function<SettingsPage *()> page, const QString &name,
const QString &iconPath, SettingsTabId id = {},
Qt::Alignment alignment = Qt::AlignTop);
void selectTab(SettingsDialogTab *tab, const bool byUser = true);
void selectTab(SettingsTabId id);
void filterElements(const QString &query);
void onOkClicked();
void onCancelClicked();
void addShortcuts() override;
struct {
QWidget *tabContainerContainer{};
QVBoxLayout *tabContainer{};
QStackedLayout *pageStack{};
QPushButton *okButton{};
QPushButton *cancelButton{};
QLineEdit *search{};
} ui_;
std::vector<SettingsDialogTab *> tabs_;
SettingsDialogTab *selectedTab_{};
SettingsDialogTab *lastSelectedByUser_{};
friend class SettingsDialogTab;
};
} // namespace chatterino