diff options
author | Thomas Hartmann <Thomas.Hartmann@theqtcompany.com> | 2016-02-24 10:16:26 +0100 |
---|---|---|
committer | Thomas Hartmann <Thomas.Hartmann@theqtcompany.com> | 2016-02-24 09:16:50 +0000 |
commit | 371a80bdfa1dbcc8a3bb1d3f7967bbd5a7622ac8 (patch) | |
tree | ecb9d753a5e94ec6d5037b610000ada103ad287e /src/plugins/qmldesigner/components/componentcore | |
parent | 8810d9d0507010da55ea02c700fd86bc4bd5e578 (diff) | |
download | qt-creator-371a80bdfa1dbcc8a3bb1d3f7967bbd5a7622ac8.tar.gz |
QmlDesigner: Adding AddSignalHandlerDialog
This is a dialog that lets the user choose a possible signal handler.
Change-Id: I22192edf130a96b3b9ffd69346f4df60f4870a69
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@theqtcompany.com>
Diffstat (limited to 'src/plugins/qmldesigner/components/componentcore')
4 files changed, 287 insertions, 0 deletions
diff --git a/src/plugins/qmldesigner/components/componentcore/addsignalhandlerdialog.cpp b/src/plugins/qmldesigner/components/componentcore/addsignalhandlerdialog.cpp new file mode 100644 index 0000000000..050fded777 --- /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 0000000000..08850df9af --- /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 <QDialog> +#include <QStringList> + +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 0000000000..9dcb66fce5 --- /dev/null +++ b/src/plugins/qmldesigner/components/componentcore/addsignalhandlerdialog.ui @@ -0,0 +1,150 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>AddSignalHandlerDialog</class> + <widget class="QDialog" name="AddSignalHandlerDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>440</width> + <height>132</height> + </rect> + </property> + <property name="windowTitle"> + <string>Implement Signal Handler</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="1" column="3"> + <widget class="QRadioButton" name="frequent"> + <property name="text"> + <string>Frequently used signals</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="autoRepeat"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="4" column="0" colspan="4"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="comboBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>196</width> + <height>0</height> + </size> + </property> + </widget> + </item> + <item row="2" column="3"> + <widget class="QRadioButton" name="properties"> + <property name="text"> + <string>Property changes</string> + </property> + </widget> + </item> + <item row="3" column="3"> + <widget class="QRadioButton" name="all"> + <property name="text"> + <string>All signals</string> + </property> + </widget> + </item> + <item row="1" column="2"> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Signal:</string> + </property> + </widget> + </item> + <item row="0" column="0" colspan="4"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Choose the signal you want to handle:</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>The item will be exported automatically.</string> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>AddSignalHandlerDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>AddSignalHandlerDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/src/plugins/qmldesigner/components/componentcore/componentcore.pri b/src/plugins/qmldesigner/components/componentcore/componentcore.pri index 76a46b8783..725cb6be8a 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 + |