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// Qt-Security score:significant reason:default
4
7#include <QtWidgets/qpushbutton.h>
8
10
13{
14 m_ui.setupUi(this);
15 m_ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
16 connect(m_ui.gradientView, &QtGradientView::currentGradientChanged,
17 this, &QtGradientViewDialog::slotGradientSelected);
18 connect(m_ui.gradientView, &QtGradientView::gradientActivated,
19 this, &QtGradientViewDialog::slotGradientActivated);
20}
21
23{
24 m_ui.gradientView->setGradientManager(manager);
25}
26
27QGradient QtGradientViewDialog::getGradient(bool *ok, QtGradientManager *manager, QWidget *parent, const QString &caption)
28{
29 QtGradientViewDialog dlg(parent);
30 dlg.setGradientManager(manager);
31 dlg.setWindowTitle(caption);
32 QGradient grad = QLinearGradient();
33 const int res = dlg.exec();
34 if (res == QDialog::Accepted)
35 grad = dlg.m_ui.gradientView->gradientManager()->gradients().value(dlg.m_ui.gradientView->currentGradient());
36 if (ok)
37 *ok = res == QDialog::Accepted;
38 return grad;
39}
40
41void QtGradientViewDialog::slotGradientSelected(const QString &id)
42{
43 m_ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!id.isEmpty());
44}
45
46void QtGradientViewDialog::slotGradientActivated(const QString &id)
47{
48 Q_UNUSED(id);
49 accept();
50}
51
52QT_END_NAMESPACE
QObject * parent
Definition qobject.h:74
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.