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// Qt-Security score:significant reason:default
4
6#include "ui_preferencesdialog.h"
8
9#include <QtDesigner/abstractoptionspage.h>
10#include <QtDesigner/abstractformeditor.h>
11
12#include <QtWidgets/qfiledialog.h>
13#include <QtWidgets/qpushbutton.h>
14
16
18 QDialog(parentWidget),
19 m_ui(new QT_PREPEND_NAMESPACE(Ui)::PreferencesDialog())
20{
21 m_ui->setupUi(this);
22
23 m_optionsPages = core->optionsPages();
24
25 m_ui->m_optionTabWidget->clear();
26 for (QDesignerOptionsPageInterface *optionsPage : std::as_const(m_optionsPages)) {
27 QWidget *page = optionsPage->createPage(this);
28 m_ui->m_optionTabWidget->addTab(page, optionsPage->name());
29 if (auto *appearanceWidget = qobject_cast<QDesignerAppearanceOptionsWidget *>(page))
30 connect(appearanceWidget, &QDesignerAppearanceOptionsWidget::uiModeChanged,
31 this, &PreferencesDialog::slotUiModeChanged);
32 }
33
34 connect(m_ui->m_dialogButtonBox, &QDialogButtonBox::rejected, this, &PreferencesDialog::slotRejected);
35 connect(m_ui->m_dialogButtonBox, &QDialogButtonBox::accepted, this, &PreferencesDialog::slotAccepted);
36 connect(applyButton(), &QAbstractButton::clicked, this, &PreferencesDialog::slotApply);
37}
38
40{
41 delete m_ui;
42}
43
44QPushButton *PreferencesDialog::applyButton() const
45{
46 return m_ui->m_dialogButtonBox->button(QDialogButtonBox::Apply);
47}
48
49void PreferencesDialog::slotApply()
50{
51 for (QDesignerOptionsPageInterface *optionsPage : std::as_const(m_optionsPages))
52 optionsPage->apply();
53}
54
55void PreferencesDialog::slotAccepted()
56{
57 slotApply();
58 closeOptionPages();
59 accept();
60}
61
62void PreferencesDialog::slotRejected()
63{
64 closeOptionPages();
65 reject();
66}
67
68void PreferencesDialog::slotUiModeChanged(bool modified)
69{
70 // Cannot "apply" a ui mode change (destroy the dialogs parent)
71 applyButton()->setEnabled(!modified);
72}
73
74void PreferencesDialog::closeOptionPages()
75{
76 for (QDesignerOptionsPageInterface *optionsPage : std::as_const(m_optionsPages))
77 optionsPage->finish();
78}
79
80QT_END_NAMESPACE
The QDesignerFormEditorInterface class allows you to access Qt Widgets Designer's various components.
Combined button and popup list for selecting options.