Skip to content

Commit

Permalink
feat: [templates] add template of Qt console
Browse files Browse the repository at this point in the history
Log: as title
  • Loading branch information
LiHua000 authored and deepin-mozart committed Jun 26, 2024
1 parent a40bcb7 commit caffa28
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 1 deletion.
12 changes: 12 additions & 0 deletions assets/templates/projects/qtconsoleapp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.0.0)

project(%{ProjectName} VERSION 0.1 LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)

find_package(Qt5Core)

add_executable(${PROJECT_NAME} main.cpp)

target_link_libraries(${PROJECT_NAME} Qt5::Core)
11 changes: 11 additions & 0 deletions assets/templates/projects/qtconsoleapp/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <QtCore/QCoreApplication>
#include <QDebug>

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);

qInfo() << "hello world";

return a.exec();
}
92 changes: 92 additions & 0 deletions assets/templates/projects/qtconsoleapp/wizard.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"version": 1,
"type":"project",
"wizardType":"QTCtype",
"supportedProjectTypes": [ "CMakeProjectManager.CMakeProject", "Qbs.QbsProject", "Qt4ProjectManager.Qt4Project" ],
"id": "E.QtCore",
"category": "F.Application",
"trDescription": "Creates a project containing a single main.cpp file with a stub implementation.\n\nPreselects a desktop Qt for building the application if available.",
"trDisplayName": "Qt Console Application",
"trDisplayCategory": "Application",
"icon": "../../global/consoleapplication.png",
"featuresRequired": [ "QtSupport.Wizards.FeatureQt" ],
"enabled": "%{JS: [ %{Plugins} ].indexOf('QmakeProjectManager') >= 0 || [ %{Plugins} ].indexOf('QbsProjectManager') >= 0 || [ %{Plugins} ].indexOf('CMakeProjectManager') >= 0}",

"options":
[
{ "key": "ProjectFile", "value": "%{JS: '%{BuildSystem}' === 'qmake' ? '%{ProFile}' : ('%{BuildSystem}' === 'cmake' ? '%{CMakeFile}' : '%{QbsFile}')}" },
{ "key": "ProFile", "value": "%{JS: Util.fileName('%{ProjectDirectory}/%{ProjectName}', 'pro')}" },
{ "key": "QbsFile", "value": "%{JS: Util.fileName('%{ProjectDirectory}/%{ProjectName}', 'qbs')}" },
{ "key": "CMakeFile", "value": "%{ProjectDirectory}/CMakeLists.txt" },
{ "key": "CppFileName", "value": "%{JS: 'main.' + Util.preferredSuffix('text/x-c++src')}" }
],

"pages":
[
{
"trDisplayName": "Project Location",
"trShortTitle": "Location",
"typeId": "Project",
"data": { "trDescription": "This wizard creates a simple Qt-based console application." }
},
{
"trDisplayName": "Define Build System",
"trShortTitle": "Build System",
"typeId": "Fields",
"enabled": "%{JS: ! %{IsSubproject}}",
"data":
[
{
"name": "BuildSystem",
"trDisplayName": "Build system:",
"type": "ComboBox",
"data":
{
"index": 0,
"items":
[
{
"trKey": "CMake",
"value": "cmake",
"condition": "%{JS: [ %{Plugins} ].indexOf('CMakeProjectManager') >= 0}"
}
]
}
}
]
},
{
"trDisplayName": "Kit Selection",
"trShortTitle": "Kits",
"typeId": "Kits",
"enabled": "%{JS: ! %{IsSubproject}}",
"data": { "projectFilePath": "%{ProjectFile}" }
},
{
"trDisplayName": "Project Management",
"trShortTitle": "Summary",
"typeId": "Summary"
}
],
"generators":
[
{
"typeId": "File",
"data":
[
{
"source": "CMakeLists.txt",
"openAsProject": true,
"replaceKeys": ["%{ProjectName}"],
"condition": "%{JS: '%{BuildSystem}' === 'cmake'}"
},

{
"source": "main.cpp",
"target": "%{CppFileName}",
"openInEditor": true
}
]
}
]
}
10 changes: 9 additions & 1 deletion assets/templates/templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,15 @@
"leafNode":true
}
]
}
},
{
"type": "Qt",
"templates":[{
"name": "QtConsoleApplication",
"path": "projects/qtconsoleapp",
"leafNode": true
}]
}
],
"Files": [{
"type": "C++",
Expand Down

0 comments on commit caffa28

Please sign in to comment.