Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-09-19 16:40:00 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2022-10-14 10:15:59 +0200
commita68fb1816d3fa67b322bb30f6bdd5347a149aaea (patch)
treec6a8f50121f74418bc031f8157e0b4c568140797 /sources/pyside-tools/project.py
parent7147b48ed466409fda818b2e26f46a36f624c4d3 (diff)
Add project generation to pyside6-project
Add mode keywords "new-quick", "new-ui" and "new-widget" that create simple applications. [ChangeLog][PySide6] pyside6-project can now generate simple project templates. Change-Id: Id4e457ab3592bd9ac4c8c7f45667e8c166ec4754 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside-tools/project.py')
-rw-r--r--sources/pyside-tools/project.py33
1 files changed, 26 insertions, 7 deletions
diff --git a/sources/pyside-tools/project.py b/sources/pyside-tools/project.py
index 0322c3c78..d6ec804d6 100644
--- a/sources/pyside-tools/project.py
+++ b/sources/pyside-tools/project.py
@@ -29,12 +29,17 @@ from argparse import ArgumentParser, RawTextHelpFormatter
from pathlib import Path
from typing import Dict, List, Optional, Tuple
+from project_lib.newproject import new_project, ProjectType
MODE_HELP = """build Builds the project
-run Builds the project and runs the first file")
-clean Cleans the build artifacts")
-qmllint Runs the qmllint tool
-deploy Deploys the application"""
+run Builds the project and runs the first file")
+clean Cleans the build artifacts")
+qmllint Runs the qmllint tool
+deploy Deploys the application
+new-ui Creates a new QtWidgets project with a Qt Designer-based main window
+new-widget Creates a new QtWidgets project with a main window
+new-quick Creates a new QtQuick project
+"""
opt_quiet = False
@@ -65,6 +70,11 @@ QT_MODULES = "QT_MODULES"
METATYPES_JSON_SUFFIX = "_metatypes.json"
+NEW_PROJECT_TYPES = {"new-quick": ProjectType.QUICK,
+ "new-ui": ProjectType.WIDGET_FORM,
+ "new-widget": ProjectType.WIDGET}
+
+
def run_command(command: List[str], cwd: str = None, ignore_fail: bool = False):
"""Run a command observing quiet/dry run"""
if not opt_quiet or opt_dry_run:
@@ -493,9 +503,10 @@ if __name__ == "__main__":
parser.add_argument("--force", "-f", action="store_true", help="Force rebuild")
parser.add_argument("--qml-module", "-Q", action="store_true",
help="Perform check for QML module")
- parser.add_argument("mode",
- choices=["build", "run", "clean", "qmllint", "deploy"],
- default="build", type=str, help=MODE_HELP)
+ mode_choices = ["build", "run", "clean", "qmllint", "deploy"]
+ mode_choices.extend(NEW_PROJECT_TYPES.keys())
+ parser.add_argument("mode", choices=mode_choices, default="build",
+ type=str, help=MODE_HELP)
parser.add_argument("file", help="Project file", nargs="?", type=str)
options = parser.parse_args()
@@ -504,6 +515,14 @@ if __name__ == "__main__":
opt_force = options.force
opt_qml_module = options.qml_module
mode = options.mode
+
+ new_project_type = NEW_PROJECT_TYPES.get(mode)
+ if new_project_type:
+ if not options.file:
+ print(f"{mode} requires a directory name.", file=sys.stderr)
+ sys.exit(1)
+ sys.exit(new_project(options.file, new_project_type))
+
project_file = resolve_project_file(options.file)
if not project_file:
print(f"Cannot determine project_file {options.file}", file=sys.stderr)