Skip to content
Snippets Groups Projects
Commit b5e3f2e5 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

CustomWizard: Remove example wizards


We do not want to encourage the use of custom wizards, so
remove the examples. The Json wizard has already enough
real-world examples IMHO.

Change-Id: Ic755e01ce0430b90ad4d5ea3496c11ce162249bf
Reviewed-by: default avatarAlessandro Portale <alessandro.portale@theqtcompany.com>
parent 184695be
No related branches found
No related tags found
No related merge requests found
share/qtcreator/templates/wizards/helloworld/console.png

567 B

#include <cstdio>
int main(int, char **)
{
std::printf("%MESSAGE%\n");
return 0;
}
QT = core
%NETWORK%QT += network
@if "%SCRIPT%" == "true"
QT += script
@endif
CONFIG += console c++11
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
<?xml version="1.0" encoding="UTF-8"?>
<!--
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://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 http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
Custom project wizard configuration example file. Note that by convention,
the project file goes last.
The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and
leave room for the Qt 4 target page.
-->
<wizard version="1" kind="project"
class="qmakeproject" firstpage="10"
id="A.HelloWorld" category="B.CustomProjects">
<icon>console.png</icon>
<description>Creates a hello-world-project with custom message.</description>
<displayname>Hello World</displayname>;
<displaycategory>Custom Projects</displaycategory>
<files>
<file source="main.cpp" openeditor="true"/>
<file source="project.pro" target="%ProjectName%.pro" openproject="true"/>
</files>
<!-- Create a 2nd wizard page with parameters -->
<fieldpagetitle>Hello World Parameters</fieldpagetitle>
<fieldpagetitle xml:lang="de">Hallo Welt Parameter</fieldpagetitle>
<fields>
<field mandatory="true" name="MESSAGE">
<fieldcontrol class="QLineEdit" validator='^[^"]+$'
defaulttext="Hello world from project '%ProjectName:c%'!" placeholdertext="Enter a message"/>
<fielddescription>Hello world message:</fielddescription>
<fielddescription xml:lang="de">Hallo-Welt-Nachricht:</fielddescription>
</field>
<!-- Checkbox technique 1: Comment out network in profile according to user's wishes -->
<field name="NETWORK">
<fieldcontrol class="QCheckBox" truevalue="" falsevalue="# "/>
<fielddescription>Include network module</fielddescription>
<fielddescription xml:lang="de">Netzwerk-Modul verwenden</fielddescription>
</field>
<!-- Checkbox technique 2: Use preprocessor for profile according to user's wishes -->
<field name="SCRIPT">
<fieldcontrol class="QCheckBox"/>
<fielddescription>Include script module</fielddescription>
<fielddescription xml:lang="de">Script-Modul verwenden</fielddescription>
</field>
</fields>
</wizard>
#include "%ClassName:l%.%CppHeaderSuffix%"
%ClassName%::%ClassName%(QObject *parent) :
QAbstractListModel(parent)
{
}
void %ClassName%::addItems(const QList<%Datatype%> &newItems)
{
beginInsertRows(QModelIndex(), items.size(), items.size() + newItems.size());
items.append(newItems);
endInsertRows();
}
int %ClassName%::rowCount(const QModelIndex &) const
{
return items.size();
}
QVariant %ClassName%::data(const QModelIndex &index, int) const
{
return items.at(index.row());
}
#ifndef %ClassName:u%_H
#define %ClassName:u%_H
#include <QAbstractListModel>
#include <QList>
class %ClassName% : public QAbstractListModel {
Q_OBJECT
public:
explicit %ClassName%(QObject *parent);
void addItems(const QList<%Datatype%> &items);
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
private:
QList<%Datatype%> items;
};
#endif // %ClassName:u%_H
<?xml version="1.0" encoding="UTF-8"?>
<!--
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://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 http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
Custom class wizard example configuration file. -->
<wizard version="1" kind="file" id="A.ListModel" category="B.CustomClasses">
<description>Creates a QAbstractListModel implementation.</description>
<description xml:lang="de">Erzeugt eine Implementierung von QAbstractListModel.</description>
<displayname>QAbstractListModel implementation</displayname>;
<displayname xml:lang="de">Implementierung von QAbstractListModel</displayname>;
<displaycategory>Custom Classes</displaycategory>
<displaycategory xml:lang="de">Benutzerdefinierte Klassen</displaycategory>
<files>
<file source="listmodel.cpp" target="%ClassName:l%.%CppSourceSuffix%" openeditor="true"/>
<file source="listmodel.h" target="%ClassName:l%.%CppHeaderSuffix%" openeditor="true"/>
</files>
<!-- Create parameter wizard page -->
<fieldpagetitle>ListModel parameters</fieldpagetitle>
<fieldpagetitle xml:lang="de">Parameter des ListModel</fieldpagetitle>
<fields>
<field name="ClassName">
<fieldcontrol class="QLineEdit" validator="^[a-zA-Z0-9_]+$" defaulttext="MyListModel" placeholdertext="Enter a class name"/>
<fielddescription>Class name:</fielddescription>
<fielddescription xml:lang="de">Klassenname:</fielddescription>
</field>
<field name="Datatype">
<fieldcontrol class="QComboBox" defaultindex="0">
<comboentries>
<comboentry value="QString">
<comboentrytext>class QString</comboentrytext>
<comboentrytext xml:lang="de">Klasse QString</comboentrytext>
</comboentry>
<comboentry value="int">
<comboentrytext>Integer</comboentrytext>
<comboentrytext xml:lang="de">Ganzzahlwert</comboentrytext>
</comboentry>
</comboentries>
</fieldcontrol>
<fielddescription>Data type:</fielddescription>
<fielddescription xml:lang="de">Datentyp:</fielddescription>
</field>
</fields>
<!-- Example of a validation rule -->
<validationrules>
<validationrule condition='"%ClassName%" != "QAbstractListModel"'>
<message>%ClassName% cannot be used as class name.</message>
<message xml:lang="de">%ClassName% kann nicht als Klassenname verwendet werden.</message>
</validationrule>
</validationrules>
</wizard>
#!/usr/bin/perl -w
############################################################################
#
# Copyright (C) 2015 The Qt Company Ltd.
# Contact: http://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 http://www.qt.io/terms-conditions. For further information
# use the contact form at http://www.qt.io/contact-us.
#
# GNU Lesser General Public License Usage
# Alternatively, this file may be used under the terms of the GNU Lesser
# General Public License version 2.1 or version 3 as published by the Free
# Software Foundation and appearing in the file LICENSE.LGPLv21 and
# LICENSE.LGPLv3 included in the packaging of this file. Please review the
# following information to ensure the GNU Lesser General Public License
# requirements will be met: https://www.gnu.org/licenses/lgpl.html and
# http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
#
# In addition, as a special exception, The Qt Company gives you certain additional
# rights. These rights are described in The Qt Company LGPL Exception
# version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
#
############################################################################
use strict;
use Getopt::Long;
use IO::File;
my $optDryRun = 0;
my $optHelp = 0;
my $optClassName = 'MyClass';
my $optProjectName = 'MyProject';
my $optCppHeaderSuffix = 'h';
my $optCppSourceSuffix = 'cpp';
my $optDescription = '';
# -- Read in a file and return its lines
sub readFile
{
my ($fileName) = @_;
my @rc = ();
my $fh = new IO::File('<' . $fileName) or die ('Unable to open for reading ' . $fileName . ' :' . $!);
while (my $line = <$fh>) {
chomp($line);
push (@rc, $line);
}
$fh->close();
return @rc;
}
my $USAGE=<<EOF;
Usage: generate.pl [--help] | [--dry-run]
[--class-name=<class name>]
[--project-name=<project name>]
[--header-suffix=<header suffix>]
[--source-suffix=<source suffix>]
[--description=<description-file>]
Custom wizard project generation example script.
EOF
my $argCount = scalar(@ARGV);
if ($argCount == 0
|| !GetOptions("help" => \$optHelp,
"dry-run" => \$optDryRun,
"class-name:s" => \$optClassName,
"project-name:s" => \$optProjectName,
"header-suffix:s" => \$optCppHeaderSuffix,
"source-suffix:s" => \$optCppSourceSuffix,
"description:s" => \$optDescription)
|| $optHelp != 0) {
print $USAGE;
exit (1);
}
# -- Determine file names
my $baseFileName = lc($optClassName);
my $sourceFileName = $baseFileName . '.' . $optCppSourceSuffix;
my $headerFileName = $baseFileName . '.' . $optCppHeaderSuffix;
my $mainSourceFileName = 'main.' . $optCppSourceSuffix;
my $projectFileName = lc($optProjectName) . '.pro';
if ($optDryRun) {
# -- Step 1) Dry run: Print file names along with attributes
print $sourceFileName,",openeditor\n";
print $headerFileName,",openeditor\n";
print $mainSourceFileName,",openeditor\n";
print $projectFileName,",openproject\n";
} else {
# -- Step 2) Actual file creation
print 'Generating ', $headerFileName, ' ', $sourceFileName, ' ',
$mainSourceFileName, ' ', $projectFileName, "\n";
my $headerFile = new IO::File('>' . $headerFileName) or die ('Unable to open ' . $headerFileName . ' :' . $!);
print $headerFile '#ifndef ', uc($optClassName), "_H\n#define ", uc($optClassName), "_H\n\n",
'class ', $optClassName, "{\npublic:\n ", $optClassName, "();\n\n};\n\n#endif\n";
$headerFile->close();
my $sourceFile = new IO::File('>' . $sourceFileName) or die ('Unable to open ' . $sourceFileName . ' :' . $!);
print $sourceFile '#include "', $headerFileName ,"\"\n\n",
$optClassName,'::', $optClassName, "()\n{\n}\n";
$sourceFile->close();
my $mainSourceFile = new IO::File('>' . $mainSourceFileName) or die ('Unable to open ' . $mainSourceFileName . ' :' . $!);
print $mainSourceFile '#include "', $headerFileName ,"\"\n\n";
# -- Write out description comments
if ($optDescription ne '') {
foreach my $description (readFile($optDescription)) {
print $mainSourceFile '// ', $description, "\n";
}
}
print $mainSourceFile "int main(int argc, char *argv[])\n{\n ", $optClassName,' ', lc($optClassName),
";\n return 0;\n}\n";
$mainSourceFile->close();
my $projectFile = new IO::File('>' . $projectFileName) or die ('Unable to open ' . $projectFileName . ' :' . $!);
print $projectFile "TEMPLATE = app\nQT -= core\nCONFIG += console\nTARGET = ", $optProjectName,
"\nSOURCES += ", $sourceFileName, ' ', $mainSourceFileName,
"\nHEADERS += ", $headerFileName,"\n";
$projectFile->close();
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://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 http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
Custom class wizard example configuration file. -->
<wizard version="1" class="qmakeproject" firstpage="10" kind="project" id="A.ScriptGeneratedProject" category="B.CustomProjects">
<description>Creates a simple project using a generator script</description>
<displayname>Simple Script-Generated Project</displayname>;
<displaycategory>Custom Projects</displaycategory>
<!-- Create parameter wizard page -->
<fieldpagetitle>Simple Script-Generated Project Parameters</fieldpagetitle>
<fields>
<field name="ClassName">
<fieldcontrol class="QLineEdit" validator="^[a-zA-Z0-9_]+$" defaulttext="MyClass" />
<fielddescription>Class name:</fielddescription>
</field>
<!-- Description will be inserted as a multi-line C++-comment -->
<field name="Description">
<fieldcontrol class="QTextEdit" defaulttext="Enter description" />
<fielddescription>Description:</fielddescription>
</field>
</fields>
<!-- Specify the generator script -->
<generatorscript binary="generate.pl">
<argument value="--class-name=%ClassName%"/>
<argument value="--project-name=%ProjectName%"/>
<argument value="--header-suffix=%CppHeaderSuffix%" omit-empty="true"/>
<argument value="--source-suffix=%CppSourceSuffix%" omit-empty="true"/>
<!-- Multi-line description passed as temporary file unless empty -->
<argument value="--description=%Description%" omit-empty="true" write-file="true"/>
</generatorscript>
</wizard>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment