Commit Graph

59 Commits

Author SHA1 Message Date
Christian Kandeler
dbfd378f5c Wizards: Fix "New Class" with QML_ELEMENT and no QQuickItem include
Amends 2f94e93334.

Fixes: QTCREATORBUG-29092
Change-Id: Ic27729a601534f5b4ed98451f637b9d49029a33a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Tasuku Suzuki <tasuku.suzuki@signal-slot.co.jp>
2023-04-28 12:52:46 +00:00
Tasuku Suzuki
2f94e93334 "New Class" wizard: Add QML_ELEMENT checkbox
Change-Id: I219b539ba5f36c895be1042a74571e54a0c67ec6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-01-30 13:46:49 +00:00
Cristián Maureira-Fredes
c926ca2321 python: update wizard code style
- Updated the current code to use recommended code style
- Modify description of current wizards
- Adapt the documentation to reflect the new names of the applications
- Adapt exec() call for PySide6 (and leave exec_() for PySide2)

Change-Id: Iad662523b8a0e56ac622b21cee60f7928d419354
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-06-01 12:06:46 +00:00
David Faure
25d70414ab Improve item model templates
* Add missing "return true" in insert/remove Rows/Columns
* Use C++11 syntax for a vector of ints containing just "role"
* Make items not only editable, but also enabled+selectable, as expected
  by default

Change-Id: I8ed529d2534a495f2c924906fe51ada474f9347e
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-03-16 21:33:04 +00:00
Alessandro Portale
a0d19e088e Wizards: Remove the .ui.qml wizard
Qt Creator does not offer editing .ui.qml documents, so it should not
produce them. For creating and editing .ui.qml, please use Qt Design
Studio.

Fixes: QTCREATORBUG-27085
Change-Id: I8bce9379a4bff8762a694067c25a0b266c41c417
Reviewed-by: Kimmo Leppälä <kimmo.leppala@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-02-18 15:55:22 +00:00
Alessandro Portale
05e89384e2 Wizards: Turn icons into themed icons
Turn the current un-themed icons into icon masks which now get recolored
according to the current theme.

Change-Id: I435f9a43dae04797ad0b948992f77179d93164a8
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-09-28 11:31:16 +00:00
Loren Burkholder
6c0f2b1c63 Use a more logical code style
This adds C++11-style initializers and breaks the initializer list into a new line, since most classes will have other members to be put in new lines as well.

Change-Id: I7b6d6bf6f32dbd58a744405aefabb02be9f45316
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2021-09-22 16:38:41 +00:00
Christian Stenger
2e24d4b0cc Wizards: Fix generation of dynamically populated models
This was implemented for QAbstractItemModel based classes, but
forgotten for QAbstractListModel and QAbstractTableModel based
classes.

Change-Id: I807f445e48d2906580abd0a65bb794d6e766c1a7
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-05-18 09:41:11 +00:00
David Schulz
5860addcd2 Python: Adjust wizards to PySide6
Fixes: QTCREATORBUG-25340
Change-Id: I8f22eac283893b2778b6854e1dcd4ae6048d4c84
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
2021-02-12 10:00:49 +00:00
Christian Kandeler
e735e95f06 "New Class" wizard: Check custom base class for QObject parent
That is, if the user specifies a custom base class, we check whether its
constructor takes a "QObject *parent" parameter, and if it does, we give
the derived class one as well.
This is technically a heuristic, but the pattern is pretty stable in the
Qt world.

Fixes: QTCREATORBUG-25156
Change-Id: Ie64440929df61cca7258d6d692c5de62970f9a65
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-01-25 08:58:24 +00:00
Christian Kandeler
b83bbfa754 Wizards: Add placeholder text
... to class name field in "New Class" wizard.
This way, users understand right away that the class name can include
namespaces.

Change-Id: I84aaf2aca532a97ba40f72fd2385fcab40788970
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-12-10 08:27:23 +00:00
Christian Kandeler
45dd017853 Wizards: Offer auto-completion in "New C++ Class" wizard
That is, offer existing namespaces for the class name line edit and
existing classes for the base class line edit.

Fixes: QTCREATORBUG-10066
Change-Id: I276036864626eff92997e40e4e22ab16c4f4d617
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-21 10:11:37 +00:00
Christian Stenger
5b4b09481a Wizards: Improve python class wizard
Some minor fixes, simplifications and improvements.
In detail:
 * create valid Python code
 * allow creating a Python class also without a Qt package
 * hint about the need for a Qt package depending on the
   base class
 * remove QDeclarativeItem as base class as this is not
   present in recent Qt packages

Change-Id: I7198f315b3a9eec9a04f52d7438d05ccce40c3f7
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-07-02 06:58:51 +00:00
Christian Kandeler
b0779ad5f8 Wizards: Make it more obvious to users that they can create C files
Technically, almost any "new file" wizard could be used to create a C
file, but conceptually, it makes the most sense to turn the "C++"
category into "C/C++".

Fixes: QTCREATORBUG-23621
Change-Id: I002365fa35cc6c9bf7c71039e122f72890f66b1a
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-03-10 13:23:57 +00:00
Christian Kandeler
bcc2b5e08d "New Class" wizard: Try to find a base class header
If the project has a header file whose name suggests that it might
declare the base class, then add an include statement for it.
While we cannot guarantee that the include statement is resolvable as-
is, it's at least a basis for the user to adapt accordingly, while
without any include statement the class will definitely not compile.

Fixes: QTCREATORBUG-3855
Change-Id: I55ec43d58a9a13b9b59a5bbe6415a457b974b654
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-02-27 13:28:23 +00:00
Andy Shaw
e22eea1cf3 Fix the Python templates
This fixes the templates so that they do not produce any warnings
and also includes QQuickItem in the choice of base classes

Change-Id: I58bbd462052f5d2a64bb8c4bea5bbdcd15e66700
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
2020-02-18 16:13:20 +00:00
Tobias Hunger
2751f30c72 Wizards: Use valid Json only
The original version is not valid JSON, even though the QJSON parser
will accept it:-/

Change-Id: Id408e4b83a62bca358191cf6fe4b3a7ce7d7c59e
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2019-09-17 09:30:46 +00:00
Christian Kandeler
6a50abe34f Wizards: Remove "public slots:" segment from class template
Slots have become rather irrelevant with Qt5 and C++11. Let's not annoy
and/or confuse users by reserving a segment for them in our generated
classes.

Change-Id: Ied26bd627c87654ac26f6577387397f39367c0ee
Reviewed-by: hjk <hjk@qt.io>
2019-07-24 15:28:19 +00:00
Christian Kandeler
46ef3f3027 "New class" wizard: Respect the project's "no Qt keywords" setting
Fixes: QTCREATORBUG-6812
Change-Id: I3f51c61f7a1ed1e4626be6bc31fa2e3affed2084
Reviewed-by: hjk <hjk@qt.io>
2019-07-22 15:43:19 +00:00
David Schulz
3213e12ce7 rename PythonEditor plugin to Python
The plugin does not only contain a pure editor, but all kind of support
for a programming language like project and run support.

Change-Id: I1251367c8db2e7a54986415ffc5b860cb210de3c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-07-17 06:21:23 +00:00
Christian Kandeler
dfb6fbed7c "New Class" wizard: Add option for adding the Q_OBJECT macro
This lets users specify that a class derived from a custom base should
have a Q_OBJECT macro, and it also allows them to opt out of it for
classes derived directly from QObject & friends.

Fixes: QTCREATORBUG-21810
Change-Id: I850bd3bcb7b6eb71720afe5fa097178ff5d5c620
Reviewed-by: hjk <hjk@qt.io>
2019-07-01 15:19:18 +00:00
Christian Kandeler
019447c535 New class wizard: Add Qt module dependencies, if necessary
Provide general infrastrucure and implementation for qmake.

Fixes: QTCREATORBUG-16067
Change-Id: I8c6368fe2724c9450dcbc3410b6ca459bbbdc043
Reviewed-by: hjk <hjk@qt.io>
2019-06-19 14:06:49 +00:00
Christian Kandeler
a093dfc65c Wizards: Include namespace in header guards again
This was broken in 63c339ffba while trying to fix a different bug.

Fixes: QTCREATORBUG-18157
Change-Id: Iec7e14de257195ed9bb20314b8031d3ef59df2ae
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-06-12 11:05:12 +00:00
Eike Ziller
e0d38ae414 Export Wizard values to JavaScript macro
Registers a new function "value('name')", available to the wizard json
files, which returns the value of the variable "name" as a JavaScript
object. So, variables with a string value are actual JavaScript strings,
booleans are booleans, lists are lists, and dictionaries are
dictionaries.

The patch also makes it actually possible to assign JSON lists and
dictionaries to values.

This removes some hacks involving creating complex JavaScript objects
through string substitution.

Change-Id: I4ac6da22bc5bccc9fadee97694c2fa14d44c9307
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-05-09 11:19:43 +00:00
Christian Kandeler
c770d3f4a7 Wizards: Allow non-existing base directory for new files
It's a valid use case to put new files into a new directory.

Task-number: QTCREATORBUG-15599
Change-Id: Iea479d7a723302a14ba8cc887c1036ea6a120ced
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-08 09:22:57 +00:00
Christian Kandeler
a296b84dc4 Wizards: Fix include statements
The header file must be referenced relative to the location of the
source file.

Task-number: QTCREATORBUG-15599
Change-Id: Ib7d4aa5a62a94541cbe32cd340a8a1e7d6ef35e5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-04-30 10:47:44 +00:00
Cristian Maureira-Fredes
f7e1354ae5 Add Qt for Python templates and better support
QtCreator:
* Add new icons
* Add support for `.pyproject` files,
* Set `.pyproject` as default, but keep compatibility with `.pyqtc`
    * `.pyproject` is a JSON file, while `.pyqtc` is a plain-text.

Python class:
* Add option to ask if use PySide2 or PyQt5
* Remove the old import try-except structure
* Remove iconText and add icon option
* Remove shebang
* Add utf-8 support

Python file:
* Remove code
* Remove iconText and add icon option
* Remove shebang
* Add utf-8 support

Qt for Python - Empty
* Add file with basic statements to execute a QApplication

Qt for Python - Window
* Add file with basic statements to execute a QApplication,
  which contains a QMainWindow

Task-number: QTCREATORBUG-21824
Change-Id: I4adb3ab6b179f084c7b674a6d4f643445fe24929
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-02-04 09:32:30 +00:00
Filip Bucek
aaa8beab88 Wizards: Support using #pragma once instead of include guards
Allow users to choose #pragma once instead of #ifndef include guards in
generated header files.

Fixes: QTCREATORBUG-12166
Change-Id: I3ba41c7570beb9c5958e174b5581fcc25855050f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Filip Bucek <fbucek@atlas.cz>
2019-01-23 09:10:42 +00:00
Tim Jenssen
2918cc59f8 Wizards: fix wrong json files
Change-Id: I185d1b559f53fa91731783c723bfffb78e93886b
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-10-26 17:48:53 +00:00
Tim Jenssen
bd65ae1def Wizards: remove default values
Change-Id: If58b6b9753ccb3cb3baae8198c6e9e5369840ddb
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-10-26 11:32:40 +00:00
Tim Jenssen
5dbc9cb370 Wizards: remove wrong used wizard.json property
Change-Id: I37fa72cc4283a745a05a55d4c19a31e7ead59557
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-10-26 11:32:28 +00:00
Alessandro Portale
9113125a5e Wizards: Add file extension as text overlay to some wizards
Change-Id: Ibfd1144271c4381c7125db80713cbde431a54cf7
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2017-07-24 15:32:24 +00:00
Orgad Shaneh
9c09ca9e42 Merge remote-tracking branch 'origin/4.2'
Change-Id: Ia98031eb87f1859c3736faa0cdd8b655e8a50689
2016-11-14 11:17:13 +02:00
Tim Jenssen
ffe305527b Wizards: remove default icon
Change-Id: I665ccb887294885758b45b0bd272620e1a796eec
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2016-11-10 15:45:09 +00:00
Tobias Hunger
9e72dc343c Wizards: C++11-ify code generated by JSON wizards
Task-number: QTCREATORBUG-16983
Change-Id: I1f936f25f4e9756239e04d677cec92316e3dc75b
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-10-28 11:07:23 +00:00
Tobias Hunger
63c339ffba Wizards: Generate header guard of cpp classes based on header file name
Generate header guard of cpp classes based on the header file name, not
based on the class name (plus the preferred extension for header files).

Task-number: QTCREATORBUG-15864
Change-Id: I8c2b5d4a78e59a2389091ed5933b5bdeae8e5730
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-10-26 14:05:24 +00:00
Eike Ziller
9142934d8e Merge remote-tracking branch 'origin/4.0' into 4.1
Conflicts:
	share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp
	src/plugins/debugger/debuggerruncontrol.cpp

Change-Id: I0ece46a7df3b5a6e045b30db60e608212a40cc4d
2016-08-15 14:34:25 +02:00
David Faure
252a3f89c6 Fix wrong code in list/table model templates
rowCount should return 0 if the parent *is* valid, and return
the actual number of rows when queried with an invalid index.

Change-Id: I00e3d4ea79e1aaf0be1974da876c5a871d3924e6
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2016-08-10 16:13:40 +00:00
Lorenz Haas
69143bc3a9 Wizards: Fix list model wizard's rowCount()
rowCount() must return 0 when the parent is valid: this indicates that
the list's items has no children and thus it is no tree model. The
list's size has to be returned for an invalid parent (== the invisible
root node).

Change-Id: Ieaa884958ea0094aca2232160b6f769bf90514c4
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2016-07-31 09:23:38 +00:00
Tobias Hunger
adb3a74de9 Wizards: Fix validation of C++ class names
Task-number: QTCREATORBUG-15647
Change-Id: I265a7dbadb2f87e7e44a1770be2af3eb9b9cb53b
Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
2016-03-18 16:26:43 +00:00
Tobias Hunger
aa37df645d JsonWizard: Update to use supportedProjectType
Remove "kind" as that is no longer necessary (even though it is still
handled if that is in the wizard).

Change-Id: I3e56d5e0d936b622dae5091950427f9b2db60695
Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-01-19 15:20:55 +00:00
Tobias Hunger
9035e77800 Wizard: Add a wizard for item models
Task-number: QTCREATORBUG-7
Change-Id: Ibc06eda1b6596b08dd2e3be4e426c8b89be31064
Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
2015-10-21 13:57:24 +00:00
Tobias Hunger
bd5becfe18 JsonWizard: Update wizards to make use of new features
Change-Id: Id8117ba92db46012b536c2af4e62f364631d949a
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2015-09-22 09:16:57 +00:00
Tobias Hunger
438c826859 CppClassWizard: Do not add signal/slot to non-QObject classes
Task-number: QTCREATORBUG-14959
Change-Id: I95920a8cb48facf086fbceae3e029bab30c23821
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
2015-08-27 12:59:24 +00:00
Tobias Hunger
828b0de5db C++ class wizard: Do not add Q_OBJECT macro for non-QObjects
Task-number: QTCREATORBUG-14515
Change-Id: I02e423acc53ae23169399bc9b86b4753cb84f7a2
Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
2015-05-28 15:53:20 +00:00
Tobias Hunger
f1f2475d3e JsonWizard: split plugins and features when considering enabled state
Now that we have the infrastructure to handle both separately it makes
no more sense to merge them.

Change-Id: Ia2694eef60c0fe17b025e4d6766c7a8f775513f5
Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
2015-05-28 15:50:24 +00:00
Tobias Hunger
9c1f96d47a IWizardFactory: Remove class wizard kind
Map existing class wizards to file wizards. The separation has never
been clean anyway. Now "file" wizards create one or more files,
"project" wizards create a complete project (something that can be
opened as a project in Qt Creator).

Change-Id: I0562f26019b54a59d46814a13a0b2fa8995c3e0f
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
2015-05-26 10:17:30 +00:00
Tobias Hunger
8211e6a084 JsonWizard: Simplify handling of bools via JS
Change-Id: I5381e83f6714886b7bf8cbcb859e1dd3b115a6c3
Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
2015-05-11 13:33:10 +00:00
Eike Ziller
4e53c23b4b Mime types: Fix that some QML files were opened as C++
We registered a mime type "application/x-qml" conflicting with "text/x-
qml" from freedesktop.org.xml. The magic matcher of the C++ mime types
might kick in, in that case.

Task-number: QTCREATORBUG-13994
Change-Id: I5900c233b42681d7b7d3af185d6ff3e1c4166e59
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
2015-02-24 09:46:04 +00:00
Marco Bubke
c53a8da3a1 Honor Rule of three (or five) in the class wizard
It is very often a mistake to define a destructor without a copy (and move)
constructor and assignment operator. In C++11 no move constructor and
assignment operator will be generated if a destructor is defined. So it is
better to omit a lonely destructor in out template.

https://en.wikipedia.org/wiki/Rule_of_three_%28C%2B%2B_programming%29

Change-Id: If911556f872d878939f0f2fcaa974494a4df8a8a
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2014-11-27 13:50:35 +01:00