forked from qt-creator/qt-creator
Wizards: Port "Code Snippet" Project Wizard to .json wizard
Code Snippet is the last .xml-based wizard shipped with Qt Creator. This change ports it to the .json-based wizard format. Instead of supporting just qmake-based projects (like it did), the new version supports just CMake-based projects. Change-Id: Ie64114165fff5d56ddf82041cc4d5f90c44fe77b Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
37
share/qtcreator/templates/wizards/codesnippet/CMakeLists.txt
Normal file
37
share/qtcreator/templates/wizards/codesnippet/CMakeLists.txt
Normal file
@@ -0,0 +1,37 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
project(%{ProjectName} VERSION 0.1 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS %{QtModule})
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS %{QtModule})
|
||||
|
||||
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||
qt_add_executable(%{ProjectName} MANUAL_FINALIZATION %{CppFileName})
|
||||
else()
|
||||
if(ANDROID)
|
||||
add_library(%{ProjectName} SHARED %{CppFileName})
|
||||
else()
|
||||
add_executable(%{ProjectName} %{CppFileName})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries(%{ProjectName} PRIVATE Qt${QT_VERSION_MAJOR}::%{QtModule})
|
||||
|
||||
install(TARGETS %{ProjectName}
|
||||
@if %{MacOSBundle}
|
||||
BUNDLE DESTINATION .
|
||||
@endif
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
set_target_properties(%{ProjectName} PROPERTIES MACOSX_BUNDLE %{MacOSBundleValue})
|
||||
|
||||
if(QT_VERSION_MAJOR EQUAL 6)
|
||||
qt_finalize_executable(%{ProjectName})
|
||||
endif()
|
@@ -1 +1 @@
|
||||
%CODE%
|
||||
%{CodeSnippet}
|
||||
|
@@ -1,17 +0,0 @@
|
||||
TEMPLATE = app
|
||||
@if "%TYPE%" == "core"
|
||||
QT = core
|
||||
@else
|
||||
QT = core gui
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
@endif
|
||||
@if "%CONSOLE%" == "true"
|
||||
CONFIG += console
|
||||
@endif
|
||||
@if "%APP_BUNDLE%" == "false"
|
||||
CONFIG -= app_bundle
|
||||
@endif
|
||||
CONFIG += c++11
|
||||
|
||||
SOURCES += \\
|
||||
main.%CppSourceSuffix%
|
113
share/qtcreator/templates/wizards/codesnippet/wizard.json
Normal file
113
share/qtcreator/templates/wizards/codesnippet/wizard.json
Normal file
@@ -0,0 +1,113 @@
|
||||
{
|
||||
"version": 1,
|
||||
"supportedProjectTypes": [ "CMakeProjectManager.CMakeProject" ],
|
||||
"id": "Z.Snippet",
|
||||
"category": "H.Project",
|
||||
"trDescription": "Creates a CMake-based test project for which a code snippet can be entered.",
|
||||
"trDisplayName": "Code Snippet",
|
||||
"trDisplayCategory": "Other Project",
|
||||
"featuresRequired": [ "QtSupport.Wizards.FeatureQt" ],
|
||||
"enabled": "%{JS: value('Plugins').indexOf('CMakeProjectManager') >= 0}",
|
||||
|
||||
"options":
|
||||
[
|
||||
{ "key": "ProjectFile", "value": "%{ProjectDirectory}/CMakeLists.txt" },
|
||||
{ "key": "CppFileName", "value": "%{JS: 'main.' + Util.preferredSuffix('text/x-c++src')}" },
|
||||
{ "key": "MacOSBundleValue", "value": "%{JS: %{MacOSBundle} ? 'TRUE' : 'FALSE' }" }
|
||||
],
|
||||
"pages":
|
||||
[
|
||||
{
|
||||
"trDisplayName": "Project Location",
|
||||
"trShortTitle": "Location",
|
||||
"typeId": "Project",
|
||||
"data":
|
||||
{
|
||||
"trDescription": "Creates a CMake-based test project for which a code snippet can be entered."
|
||||
}
|
||||
},
|
||||
{
|
||||
"trDisplayName": "Define Code snippet",
|
||||
"trShortTitle": "Code snippet",
|
||||
"typeId": "Fields",
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"name": "CodeSnippet",
|
||||
"trDisplayName": "Code:",
|
||||
"type": "TextEdit",
|
||||
"data":
|
||||
{
|
||||
"trText": "int main(int argc, char *argv[])\n{\n return 0;\n}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "QtModule",
|
||||
"trDisplayName": "Use Qt Modules:",
|
||||
"type": "ComboBox",
|
||||
"persistenceKey": "QtModule",
|
||||
"data":
|
||||
{
|
||||
"index": 1,
|
||||
"items":
|
||||
[
|
||||
{
|
||||
"trKey": "QtCore",
|
||||
"value": "Core"
|
||||
},
|
||||
{
|
||||
"trKey": "QtCore, QtWidgets",
|
||||
"value": "Widgets"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "MacOSBundle",
|
||||
"trDisplayName": "Application bundle (macOS)",
|
||||
"type": "CheckBox",
|
||||
"persistenceKey": "MacOSBundle",
|
||||
"data":
|
||||
{
|
||||
"checked": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"trDisplayName": "Kit Selection",
|
||||
"trShortTitle": "Kits",
|
||||
"typeId": "Kits",
|
||||
"enabled": "%{JS: !value('IsSubproject')}",
|
||||
"data":
|
||||
{
|
||||
"projectFilePath": "%{ProjectFile}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"trDisplayName": "Project Management",
|
||||
"trShortTitle": "Summary",
|
||||
"typeId": "Summary"
|
||||
}
|
||||
],
|
||||
|
||||
"generators":
|
||||
[
|
||||
{
|
||||
"typeId": "File",
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"source": "CMakeLists.txt",
|
||||
"target": "%{ProjectFile}",
|
||||
"openAsProject": true
|
||||
},
|
||||
{
|
||||
"source": "main.cpp",
|
||||
"target": "%{CppFileName}",
|
||||
"openInEditor": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
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="Z.Snippet" category="H.Project">
|
||||
<description>Creates a qmake-based test project for which a code snippet can be entered.</description>
|
||||
<displayname>Code Snippet</displayname>;
|
||||
<displaycategory>Other Project</displaycategory>
|
||||
<files>
|
||||
<file source="main.cpp" target="main.%CppSourceSuffix%" openeditor="true"/>
|
||||
<file source="project.pro" target="%ProjectName%.pro" openproject="true"/>
|
||||
</files>
|
||||
<fieldpagetitle>Snippet Parameters</fieldpagetitle>
|
||||
<fields>
|
||||
<field name="CODE">
|
||||
<fieldcontrol class="QTextEdit" defaulttext="int main(int argc, char *argv[]) { return 0; } "/>
|
||||
<fielddescription>Code:</fielddescription>
|
||||
</field>
|
||||
<field name="TYPE">
|
||||
<fielddescription>Type:</fielddescription>
|
||||
<fieldcontrol class="QComboBox" defaultindex="0">
|
||||
<comboentries>
|
||||
<comboentry value="core">
|
||||
<comboentrytext>Headless (QtCore)</comboentrytext>
|
||||
</comboentry>
|
||||
<comboentry value="gui">
|
||||
<comboentrytext>Gui application (QtCore, QtGui, QtWidgets)</comboentrytext>
|
||||
</comboentry>
|
||||
</comboentries>
|
||||
</fieldcontrol>
|
||||
</field>
|
||||
<field name="CONSOLE">
|
||||
<fieldcontrol class="QCheckBox" defaultvalue="true"/>
|
||||
<fielddescription>Console application</fielddescription>
|
||||
</field>
|
||||
<field name="APP_BUNDLE">
|
||||
<fieldcontrol class="QCheckBox"/>
|
||||
<fielddescription>Application bundle (Mac)</fielddescription>
|
||||
</field>
|
||||
</fields>
|
||||
</wizard>
|
Reference in New Issue
Block a user