Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
preferencesdialog.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
5#include "ui_preferencesdialog.h"
7
8#include <QtDesigner/abstractoptionspage.h>
9#include <QtDesigner/abstractformeditor.h>
10
11#include <QtWidgets/qfiledialog.h>
12#include <QtWidgets/qpushbutton.h>
13
15
17 QDialog(parentWidget),
18 m_ui(new QT_PREPEND_NAMESPACE(Ui)::PreferencesDialog())
19{
20 m_ui->setupUi(this);
21
22 m_optionsPages = core->optionsPages();
23
24 m_ui->m_optionTabWidget->clear();
25 for (QDesignerOptionsPageInterface *optionsPage : std::as_const(m_optionsPages)) {
26 QWidget *page = optionsPage->createPage(this);
27 m_ui->m_optionTabWidget->addTab(page, optionsPage->name());
28 if (QDesignerAppearanceOptionsWidget *appearanceWidget = qobject_cast<QDesignerAppearanceOptionsWidget *>(page))
29 connect(appearanceWidget, &QDesignerAppearanceOptionsWidget::uiModeChanged,
30 this, &PreferencesDialog::slotUiModeChanged);
31 }
32
33 connect(m_ui->m_dialogButtonBox, &QDialogButtonBox::rejected, this, &PreferencesDialog::slotRejected);
34 connect(m_ui->m_dialogButtonBox, &QDialogButtonBox::accepted, this, &PreferencesDialog::slotAccepted);
35 connect(applyButton(), &QAbstractButton::clicked, this, &PreferencesDialog::slotApply);
36}
37
39{
40 delete m_ui;
41}
42
43QPushButton *PreferencesDialog::applyButton() const
44{
45 return m_ui->m_dialogButtonBox->button(QDialogButtonBox::Apply);
46}
47
48void PreferencesDialog::slotApply()
49{
50 for (QDesignerOptionsPageInterface *optionsPage : std::as_const(m_optionsPages))
51 optionsPage->apply();
52}
53
54void PreferencesDialog::slotAccepted()
55{
56 slotApply();
57 closeOptionPages();
58 accept();
59}
60
61void PreferencesDialog::slotRejected()
62{
63 closeOptionPages();
64 reject();
65}
66
67void PreferencesDialog::slotUiModeChanged(bool modified)
68{
69 // Cannot "apply" a ui mode change (destroy the dialogs parent)
70 applyButton()->setEnabled(!modified);
71}
72
73void PreferencesDialog::closeOptionPages()
74{
75 for (QDesignerOptionsPageInterface *optionsPage : std::as_const(m_optionsPages))
76 optionsPage->finish();
77}
78
79QT_END_NAMESPACE
The QDesignerFormEditorInterface class allows you to access Qt Widgets Designer's various components.
Combined button and popup list for selecting options.