1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of Qt Creator.
7 **
8 ** Commercial License Usage
9 ** Licensees holding valid commercial Qt licenses may use this file in
10 ** accordance with the commercial license agreement provided with the
11 ** Software or, alternatively, in accordance with the terms contained in
12 ** a written agreement between you and The Qt Company. For licensing terms
13 ** and conditions see https://www.qt.io/terms-conditions. For further
14 ** information use the contact form at https://www.qt.io/contact-us.
15 **
16 ** GNU General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU
18 ** General Public License version 3 as published by the Free Software
19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
20 ** included in the packaging of this file. Please review the following
21 ** information to ensure the GNU General Public License requirements will
22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
23 **
24 ****************************************************************************/
25 
26 #include "customwidgetwizard.h"
27 #include "customwidgetwizarddialog.h"
28 #include "plugingenerator.h"
29 #include "filenamingparameters.h"
30 #include "pluginoptions.h"
31 
32 #include <projectexplorer/projectexplorerconstants.h>
33 
34 #include <qtsupport/qtsupportconstants.h>
35 
36 #include <QCoreApplication>
37 
38 namespace QmakeProjectManager {
39 namespace Internal {
40 
CustomWidgetWizard()41 CustomWidgetWizard::CustomWidgetWizard()
42 {
43     setId("P.Qt4CustomWidget");
44     setCategory(QLatin1String(ProjectExplorer::Constants::QT_PROJECT_WIZARD_CATEGORY));
45     setDisplayCategory(QCoreApplication::translate("ProjectExplorer",
46              ProjectExplorer::Constants::QT_PROJECT_WIZARD_CATEGORY_DISPLAY));
47     setDisplayName(tr("Qt Custom Designer Widget"));
48     setDescription(tr("Creates a Qt Custom Designer Widget or a Custom Widget Collection."));
49     setIcon(QIcon(QLatin1String(":/wizards/images/gui.png")));
50     setRequiredFeatures({QtSupport::Constants::FEATURE_QWIDGETS});
51 }
52 
create(QWidget * parent,const Core::WizardDialogParameters & parameters) const53 Core::BaseFileWizard *CustomWidgetWizard::create(QWidget *parent, const Core::WizardDialogParameters &parameters) const
54 {
55     CustomWidgetWizardDialog *rc = new CustomWidgetWizardDialog(this, displayName(),
56                                                                 icon(), parent, parameters);
57     rc->setProjectName(CustomWidgetWizardDialog::uniqueProjectName(parameters.defaultPath()));
58     rc->setFileNamingParameters(FileNamingParameters(headerSuffix(), sourceSuffix(), QtWizard::lowerCaseFiles()));
59     return rc;
60 }
61 
generateFiles(const QWizard * w,QString * errorMessage) const62 Core::GeneratedFiles CustomWidgetWizard::generateFiles(const QWizard *w,
63                                                        QString *errorMessage) const
64 {
65     const auto *cw = qobject_cast<const CustomWidgetWizardDialog *>(w);
66     Q_ASSERT(w);
67     GenerationParameters p;
68     p.fileName = cw->projectName();
69     p.path = cw->path();
70     p.templatePath = QtWizard::templateDir();
71     p.templatePath += QLatin1String("/customwidgetwizard");
72     return PluginGenerator::generatePlugin(p, *(cw->pluginOptions()), errorMessage);
73 }
74 
75 } // namespace Internal
76 } // namespace QmakeProjectManager
77