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
qtgradientviewdialog.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
6#include <QtWidgets/QPushButton>
7
9
12{
13 m_ui.setupUi(this);
14 m_ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
15 connect(m_ui.gradientView, &QtGradientView::currentGradientChanged,
16 this, &QtGradientViewDialog::slotGradientSelected);
17 connect(m_ui.gradientView, &QtGradientView::gradientActivated,
18 this, &QtGradientViewDialog::slotGradientActivated);
19}
20
22{
23 m_ui.gradientView->setGradientManager(manager);
24}
25
26QGradient QtGradientViewDialog::getGradient(bool *ok, QtGradientManager *manager, QWidget *parent, const QString &caption)
27{
28 QtGradientViewDialog dlg(parent);
29 dlg.setGradientManager(manager);
30 dlg.setWindowTitle(caption);
31 QGradient grad = QLinearGradient();
32 const int res = dlg.exec();
33 if (res == QDialog::Accepted)
34 grad = dlg.m_ui.gradientView->gradientManager()->gradients().value(dlg.m_ui.gradientView->currentGradient());
35 if (ok)
36 *ok = res == QDialog::Accepted;
37 return grad;
38}
39
40void QtGradientViewDialog::slotGradientSelected(const QString &id)
41{
42 m_ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!id.isEmpty());
43}
44
45void QtGradientViewDialog::slotGradientActivated(const QString &id)
46{
47 Q_UNUSED(id);
48 accept();
49}
50
51QT_END_NAMESPACE
QObject * parent
Definition qobject.h:73
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void setGradientManager(QtGradientManager *manager)
Combined button and popup list for selecting options.