Skip to content

Commit

Permalink
feat: add session only checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz committed Jul 7, 2023
1 parent 8f4770a commit 45a7b7d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/widgets/settingspages/GeneralPageView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,28 @@ QCheckBox *GeneralPageView::addCheckbox(const QString &text,
return check;
}

QCheckBox *GeneralPageView::addSessionCheckbox(
const QString &text, bool initialValue, std::function<void(bool)> onUpdated,
QString toolTipText)
{
auto *check = new QCheckBox(text);
this->addToolTip(*check, std::move(toolTipText));
check->setChecked(initialValue);

// update setting on toggle
QObject::connect(check, &QCheckBox::toggled, this,
[onUpdated = std::move(onUpdated)](bool state) {
onUpdated(state);
});

this->addWidget(check);

// groups
this->groups_.back().widgets.push_back({check, {text}});

return check;
}

ComboBox *GeneralPageView::addDropdown(const QString &text,
const QStringList &list,
QString toolTipText)
Expand Down
4 changes: 4 additions & 0 deletions src/widgets/settingspages/GeneralPageView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ class GeneralPageView : public QWidget
/// @param inverse Inverses true to false and vice versa
QCheckBox *addCheckbox(const QString &text, BoolSetting &setting,
bool inverse = false, QString toolTipText = {});
/// Adds a checkbox that only keeps its state for the current session
QCheckBox *addSessionCheckbox(const QString &text, bool initialValue,
std::function<void(bool)> onUpdated,
QString toolTipText = {});
ComboBox *addDropdown(const QString &text, const QStringList &items,
QString toolTipText = {});
ComboBox *addDropdown(const QString &text, const QStringList &items,
Expand Down

0 comments on commit 45a7b7d

Please sign in to comment.