customwidgetwizarddialog.cpp 4.3 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
2
**
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
7
**
hjk's avatar
hjk committed
8
9
10
11
12
13
14
** 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 Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
16
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
18
19
20
21
22
23
24
25
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
29
30
31
32

#include "customwidgetwizarddialog.h"
#include "customwidgetwidgetswizardpage.h"
#include "customwidgetpluginwizardpage.h"
33
#include "pluginoptions.h"
34
#include <projectexplorer/projectexplorerconstants.h>
35

Tobias Hunger's avatar
Tobias Hunger committed
36
#include <qtsupport/qtkitinformation.h>
Tobias Hunger's avatar
Tobias Hunger committed
37
38
39
40
#include <qtsupport/qtsupportconstants.h>

namespace {

Tobias Hunger's avatar
Tobias Hunger committed
41
class DesktopQtKitMatcher : public ProjectExplorer::KitMatcher
Tobias Hunger's avatar
Tobias Hunger committed
42
43
{
public:
Tobias Hunger's avatar
Tobias Hunger committed
44
    bool matches(const ProjectExplorer::Kit *k) const
Tobias Hunger's avatar
Tobias Hunger committed
45
    {
Tobias Hunger's avatar
Tobias Hunger committed
46
        ProjectExplorer::IDevice::ConstPtr dev = ProjectExplorer::DeviceKitInformation::device(k);
47
        if (dev.isNull() || dev->id() != ProjectExplorer::Constants::DESKTOP_DEVICE_ID)
Tobias Hunger's avatar
Tobias Hunger committed
48
            return false;
Tobias Hunger's avatar
Tobias Hunger committed
49
        QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
50
        return version && version->type() == QLatin1String(QtSupport::Constants::DESKTOPQT);
Tobias Hunger's avatar
Tobias Hunger committed
51
52
53
54
55
    }
};

} // namespace

56
57
58
namespace Qt4ProjectManager {
namespace Internal {

59
enum { IntroPageId = 0};
60
61
62

CustomWidgetWizardDialog::CustomWidgetWizardDialog(const QString &templateName,
                                                   const QIcon &icon,
63
64
65
                                                   QWidget *parent,
                                                   const Core::WizardDialogParameters &parameters) :
    BaseQt4ProjectWizardDialog(false, parent, parameters),
66
    m_widgetsPage(new CustomWidgetWidgetsWizardPage),
67
68
    m_pluginPage(new CustomWidgetPluginWizardPage),
    m_widgetPageId(-1), m_pluginPageId(-1)
69
70
71
72
{
    setWindowIcon(icon);
    setWindowTitle(templateName);

Caroline Chao's avatar
Caroline Chao committed
73
74
    setIntroDescription(tr("This wizard generates a Qt Designer Custom Widget "
                           "or a Qt Designer Custom Widget Collection project."));
75

76
    if (!parameters.extraValues().contains(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS)))
77
        addTargetSetupPage();
78
79
    m_widgetPageId = addPage(m_widgetsPage);
    m_pluginPageId = addPage(m_pluginPage);
80
81
    wizardProgress()->item(m_widgetPageId)->setTitle(tr("Custom Widgets"));
    wizardProgress()->item(m_pluginPageId)->setTitle(tr("Plugin Details"));
82

83
    addExtensionPages(parameters.extensionPages());
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
    connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(slotCurrentIdChanged(int)));
}

FileNamingParameters CustomWidgetWizardDialog::fileNamingParameters() const
{
    return m_widgetsPage->fileNamingParameters();
}

void CustomWidgetWizardDialog::setFileNamingParameters(const FileNamingParameters &fnp)
{
    m_widgetsPage->setFileNamingParameters(fnp);
    m_pluginPage->setFileNamingParameters(fnp);
}

void CustomWidgetWizardDialog::slotCurrentIdChanged(int id)
{
100
    if (id == m_pluginPageId)
101
102
103
104
105
106
107
108
109
110
111
112
        m_pluginPage->init(m_widgetsPage);
}

QSharedPointer<PluginOptions> CustomWidgetWizardDialog::pluginOptions() const
{
    QSharedPointer<PluginOptions> rc = m_pluginPage->basicPluginOptions();
    rc->widgetOptions = m_widgetsPage->widgetOptions();
    return rc;
}

} // namespace Internal
} // namespace Qt4ProjectManager