Commit Graph

45 Commits

Author SHA1 Message Date
Christian Kandeler
335c552bda Wizards: Always derive header guard from file name
Fixes: QTCREATORBUG-30140
Change-Id: Iad84bb49b26193f059f729009bc66832939f079c
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-01-10 09:44:54 +00:00
Eike Ziller
c53c9b539e Merge remote-tracking branch 'origin/12.0'
Change-Id: Ib62e4e8fc7776fa194bceced05612ae5eb113df9
2023-10-13 12:02:38 +02:00
Alessandro Portale
f734ba4461 Wizards: Make editable text options with macros/code non-translatable
Options with contain %{Macros} (sometimes with JavaScript code) should
not be translatable, since a translation can easily a prevent a wizard
from successfully working.

This change turns a couple of trText, trDisabledText and trPlaceholder
options into their non-translatable pendants.

Fixes: QTCREATORBUG-29649
Change-Id: Ia46ab7ac35f78d6368868d78e24179197744921d
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-10-12 09:04:01 +00:00
Eike Ziller
60f7b13059 Merge remote-tracking branch 'origin/12.0'
Change-Id: Ia3e89b8e691e1ca74b03e5a8139647bedf5f88b3
2023-10-12 10:37:25 +02:00
Tasuku Suzuki
ef63c39266 Remove QtQuick 1 support from C++ Class wizard
QtQuick 1 is not part of Qt since Qt 5.6

Change-Id: I9fbbafe8a10a81dc6f4833301ecb124d459d5b3b
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2023-10-11 10:33:25 +00:00
Christian Kandeler
e607c5530e Wizards: Fix "pragma once" check
Obviously, boolean functions return a string that you need to compare to
"true" and "false" explicitly.
Amends 8e75381fce.

Fixes: QTCREATORBUG-29713
Change-Id: I19966555badd67f95f51ea1c1757d8b86e727010
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-10-09 15:26:08 +00:00
Christian Kandeler
8e75381fce CppEditor: Give C++ file name settings a per-project variant
Fixes: QTCREATORBUG-22033
Change-Id: If37517bb091438e70c5af5102bf833ed46d0c951
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-06-08 08:23:01 +00:00
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
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 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 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
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
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
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
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
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
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
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
Tobias Hunger
d2eb042676 JsonWizard: Remove empty lines
Task-number: QTCREATORBUG-13289
Change-Id: I2c8d1fc4e2cfcb940e76a6988d35e80703548668
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
2014-11-03 15:38:47 +01:00
Tobias Hunger
cda0320f5b JsonWizard: Match up files generated by the Cpp Class wizard
Change-Id: I407958b02446e81a449a34519a9eb592723a08a5
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
2014-11-03 09:44:08 +01:00
Tobias Hunger
52e31f80ad JsonWizard: Enable validators for lineedits on Fields pages
Make use of a validator when entering C++ class names.

Change-Id: Id7f9c8c2e1fe036397a337595cbe7aa7fd9589d5
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2014-10-15 18:21:55 +02:00
Tobias Hunger
50df8aa984 JsonWizard: Replace CppClassWizard with a JsonWizard
Change-Id: I4e1aeea4ccd1087b5e804e9ba4c2aa8fde4f4fcb
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2014-10-15 18:21:49 +02:00