diff --git a/src/plugins/qmldesigner/components/componentcore/addsignalhandlerdialog.cpp b/src/plugins/qmldesigner/components/componentcore/addsignalhandlerdialog.cpp new file mode 100644 index 00000000000..050fded7774 --- /dev/null +++ b/src/plugins/qmldesigner/components/componentcore/addsignalhandlerdialog.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "addsignalhandlerdialog.h" +#include "ui_addsignalhandlerdialog.h" + +AddSignalHandlerDialog::AddSignalHandlerDialog(QWidget *parent) : + QDialog(parent), + m_ui(new Ui::AddSignalHandlerDialog) +{ + m_ui->setupUi(this); + + connect(m_ui->all, &QRadioButton::toggled, this, &AddSignalHandlerDialog::updateComboBox); + connect(m_ui->properties, &QRadioButton::toggled, this, &AddSignalHandlerDialog::updateComboBox); + connect(m_ui->frequent, &QRadioButton::toggled, this, &AddSignalHandlerDialog::updateComboBox); + connect(this, &QDialog::accepted, this, &AddSignalHandlerDialog::handleAccepted); +} + +AddSignalHandlerDialog::~AddSignalHandlerDialog() +{ + delete m_ui; +} + +void AddSignalHandlerDialog::setSignals(const QStringList &_signals) +{ + m_signals = _signals; + updateComboBox(); +} + +QString AddSignalHandlerDialog::signal() const +{ + return m_signal; +} + +void AddSignalHandlerDialog::updateComboBox() +{ + m_ui->comboBox->clear(); + foreach (const QString &signal, m_signals) { + if (m_ui->all->isChecked()) { + m_ui->comboBox->addItem(signal); + } else if (m_ui->properties->isChecked()) { + if (signal.contains(QLatin1String("Changed"))) + m_ui->comboBox->addItem(signal); + } else { + if (!signal.contains(QLatin1String("Changed"))) + m_ui->comboBox->addItem(signal); + } + } +} + +void AddSignalHandlerDialog::handleAccepted() +{ + m_signal = m_ui->comboBox->currentText(); + emit done(); +} diff --git a/src/plugins/qmldesigner/components/componentcore/addsignalhandlerdialog.h b/src/plugins/qmldesigner/components/componentcore/addsignalhandlerdialog.h new file mode 100644 index 00000000000..08850df9af0 --- /dev/null +++ b/src/plugins/qmldesigner/components/componentcore/addsignalhandlerdialog.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include +#include + +namespace Ui { +class AddSignalHandlerDialog; +} + +class AddSignalHandlerDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AddSignalHandlerDialog(QWidget *parent = 0); + ~AddSignalHandlerDialog(); + void setSignals(const QStringList &_signals); + QString signal() const; + +signals: + void done(); + +private: + void updateComboBox(); + void handleAccepted(); + + Ui::AddSignalHandlerDialog *m_ui; + QStringList m_signals; + QString m_signal; +}; diff --git a/src/plugins/qmldesigner/components/componentcore/addsignalhandlerdialog.ui b/src/plugins/qmldesigner/components/componentcore/addsignalhandlerdialog.ui new file mode 100644 index 00000000000..9dcb66fce58 --- /dev/null +++ b/src/plugins/qmldesigner/components/componentcore/addsignalhandlerdialog.ui @@ -0,0 +1,150 @@ + + + AddSignalHandlerDialog + + + + 0 + 0 + 440 + 132 + + + + Implement Signal Handler + + + + + + Frequently used signals + + + true + + + false + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + 0 + 0 + + + + + 196 + 0 + + + + + + + + Property changes + + + + + + + All signals + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Signal: + + + + + + + Choose the signal you want to handle: + + + + + + + The item will be exported automatically. + + + + + + + + + buttonBox + accepted() + AddSignalHandlerDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + AddSignalHandlerDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/plugins/qmldesigner/components/componentcore/componentcore.pri b/src/plugins/qmldesigner/components/componentcore/componentcore.pri index 76a46b87835..725cb6be8a7 100644 --- a/src/plugins/qmldesigner/components/componentcore/componentcore.pri +++ b/src/plugins/qmldesigner/components/componentcore/componentcore.pri @@ -2,6 +2,7 @@ VPATH += $$PWD SOURCES += modelnodecontextmenu.cpp SOURCES += findimplementation.cpp +SOURCES += addsignalhandlerdialog.cpp SOURCES += layoutingridlayout.cpp SOURCES += abstractactiongroup.cpp SOURCES += designeractionmanagerview.cpp @@ -14,6 +15,7 @@ SOURCES += crumblebar.cpp HEADERS += modelnodecontextmenu.h HEADERS += findimplementation.h +HEADERS += addsignalhandlerdialog.h HEADERS += layoutingridlayout.h HEADERS += abstractactiongroup.h HEADERS += designeractionmanagerview.h @@ -26,3 +28,6 @@ HEADERS += modelnodeoperations.h HEADERS += actioninterface.h HEADERS += crumblebar.h +FORMS += \ + $$PWD/addsignalhandlerdialog.ui +