Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Apply option to preferences dialog #1997

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions app/dialog/configbase/configdialogbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <QDialogButtonBox>
#include <QSplitter>
#include <QVBoxLayout>
#include <QAbstractButton>

#include "core.h"

Expand All @@ -46,20 +47,21 @@ ConfigDialogBase::ConfigDialogBase(QWidget* parent) :

QDialogButtonBox* button_box = new QDialogButtonBox(this);
button_box->setOrientation(Qt::Horizontal);
button_box->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
button_box->setStandardButtons(QDialogButtonBox::Apply | QDialogButtonBox::Cancel|QDialogButtonBox::Ok);

layout->addWidget(button_box);

connect(button_box, &QDialogButtonBox::accepted, this, &ConfigDialogBase::accept);
connect(button_box, &QDialogButtonBox::accepted, this, [this]() {apply(); QDialog::accept();});;
connect(button_box, &QDialogButtonBox::rejected, this, &ConfigDialogBase::reject);
connect(button_box, &QDialogButtonBox::clicked, this, [this, button_box](QAbstractButton* btn) {if (button_box->buttonRole(btn) == QDialogButtonBox::ApplyRole) apply();});

connect(list_widget_,
&QListWidget::currentRowChanged,
preference_pane_stack_,
&QStackedWidget::setCurrentIndex);
}

void ConfigDialogBase::accept()
void ConfigDialogBase::apply()
{
foreach (ConfigDialogBaseTab* tab, tabs_) {
if (!tab->Validate()) {
Expand All @@ -77,7 +79,6 @@ void ConfigDialogBase::accept()

AcceptEvent();

QDialog::accept();
}

void ConfigDialogBase::AddTab(ConfigDialogBaseTab *tab, const QString &title)
Expand Down
3 changes: 2 additions & 1 deletion app/dialog/configbase/configdialogbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ private slots:
/**
* @brief Override of accept to save preferences to Config.
*/
virtual void accept() override;
virtual void apply();


protected:
void AddTab(ConfigDialogBaseTab* tab, const QString& title);
Expand Down