forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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>
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user