|
8 | 8 | #include "qdesigner_settings.h"
|
9 | 9 | #include "qdesigner_workbench.h"
|
10 | 10 | #include "mainwindow.h"
|
11 |
| - |
| 11 | +#include <QtDesigner/abstractintegration.h> |
| 12 | +#include <QtDesigner/abstractformeditor.h> |
12 | 13 | #include <qdesigner_propertysheet_p.h>
|
13 | 14 |
|
14 | 15 | #include <QtGui/qevent.h>
|
|
27 | 28 | #include <QtCore/qdebug.h>
|
28 | 29 | #include <QtCore/qcommandlineparser.h>
|
29 | 30 | #include <QtCore/qcommandlineoption.h>
|
| 31 | +#include <QtCore/qversionnumber.h> |
| 32 | +#include <QtCore/qvariant.h> |
30 | 33 |
|
31 | 34 | #include <QtDesigner/QDesignerComponents>
|
32 | 35 |
|
| 36 | +#include <optional> |
| 37 | + |
33 | 38 | QT_BEGIN_NAMESPACE
|
34 | 39 |
|
35 | 40 | using namespace Qt::StringLiterals;
|
@@ -137,6 +142,7 @@ struct Options
|
137 | 142 | QStringList files;
|
138 | 143 | QString resourceDir{QLibraryInfo::path(QLibraryInfo::TranslationsPath)};
|
139 | 144 | QStringList pluginPaths;
|
| 145 | + std::optional<QVersionNumber> qtVersion; |
140 | 146 | bool server{false};
|
141 | 147 | quint16 clientPort{0};
|
142 | 148 | bool enableInternalDynamicProperties{false};
|
@@ -168,6 +174,11 @@ static inline QDesigner::ParseArgumentsResult
|
168 | 174 | u"path"_s);
|
169 | 175 | parser.addOption(pluginPathsOption);
|
170 | 176 |
|
| 177 | + const QCommandLineOption qtVersionOption(u"qt-version"_s, |
| 178 | + u"Qt Version for writing .ui files"_s, |
| 179 | + u"version"_s); |
| 180 | + parser.addOption(qtVersionOption); |
| 181 | + |
171 | 182 | parser.addPositionalArgument(u"files"_s,
|
172 | 183 | u"The UI files to open."_s);
|
173 | 184 |
|
@@ -197,6 +208,9 @@ static inline QDesigner::ParseArgumentsResult
|
197 | 208 | for (const auto &pluginPath : pluginPathValues)
|
198 | 209 | options->pluginPaths.append(pluginPath.split(QDir::listSeparator(), Qt::SkipEmptyParts));
|
199 | 210 |
|
| 211 | + if (parser.isSet(qtVersionOption)) |
| 212 | + options->qtVersion = QVersionNumber::fromString(parser.value(qtVersionOption)); |
| 213 | + |
200 | 214 | options->enableInternalDynamicProperties = parser.isSet(internalDynamicPropertyOption);
|
201 | 215 | options->files = parser.positionalArguments();
|
202 | 216 | return QDesigner::ParseArgumentsSuccess;
|
@@ -250,6 +264,15 @@ QDesigner::ParseArgumentsResult QDesigner::parseCommandLineArguments()
|
250 | 264 | if (m_workbench->formWindowCount() > 0)
|
251 | 265 | suppressNewFormShow = true;
|
252 | 266 |
|
| 267 | + if (options.qtVersion.has_value()) { |
| 268 | +#if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0) |
| 269 | + m_workbench->core()->integration()->setQtVersion(options.qtVersion.value()); |
| 270 | +#else |
| 271 | + auto version = QVariant::fromValue(options.qtVersion.value()); |
| 272 | + m_workbench->core()->integration()->setProperty("qtVersion", version); |
| 273 | +#endif |
| 274 | + } |
| 275 | + |
253 | 276 | // Show up error box with parent now if something went wrong
|
254 | 277 | if (m_initializationErrors.isEmpty()) {
|
255 | 278 | if (!suppressNewFormShow)
|
|
0 commit comments