forked from qt-creator/qt-creator
Fix different UI aggregation styles for widget project wizard
This got lost during the transition to JSON.
Amends 241efa353d
Fixes: QTCREATORBUG-24422
Change-Id: I51dec2e84adb3c5944ecaf83697f3e776bd3d7f1
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -1,24 +1,30 @@
|
|||||||
%{Cpp:LicenseTemplate}\
|
%{Cpp:LicenseTemplate}\
|
||||||
#include "%{JS: Util.relativeFilePath('%{Path}/%{HdrFileName}', '%{Path}' + '/' + Util.path('%{SrcFileName}'))}"
|
#include "%{JS: Util.relativeFilePath('%{Path}/%{HdrFileName}', '%{Path}' + '/' + Util.path('%{SrcFileName}'))}"
|
||||||
@if %{GenerateForm}
|
@if %{GenerateForm} && %{JS: QtSupport.uiAsPointer() }
|
||||||
#include "%{UiHdrFileName}"
|
#include "%{UiHdrFileName}"
|
||||||
@endif
|
@endif
|
||||||
%{JS: Cpp.openNamespaces('%{Class}')}\
|
%{JS: Cpp.openNamespaces('%{Class}')}\
|
||||||
|
|
||||||
%{CN}::%{CN}(QWidget *parent)
|
%{CN}::%{CN}(QWidget *parent)
|
||||||
: %{BaseClass}(parent)
|
: %{BaseClass}(parent)
|
||||||
@if %{GenerateForm}
|
@if %{GenerateForm} && %{JS: QtSupport.uiAsPointer() }
|
||||||
, ui(new Ui::%{CN})
|
, ui(new Ui::%{CN})
|
||||||
@endif
|
@endif
|
||||||
{
|
{
|
||||||
@if %{GenerateForm}
|
@if %{GenerateForm}
|
||||||
|
@if %{JS: QtSupport.uiAsPointer() }
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
@elsif %{JS: QtSupport.uiAsMember() }
|
||||||
|
ui.setupUi(this);
|
||||||
|
@else
|
||||||
|
setupUi(this);
|
||||||
|
@endif
|
||||||
@endif
|
@endif
|
||||||
}
|
}
|
||||||
|
|
||||||
%{CN}::~%{CN}()
|
%{CN}::~%{CN}()
|
||||||
{
|
{
|
||||||
@if %{GenerateForm}
|
@if %{GenerateForm} && %{JS: QtSupport.uiAsPointer() }
|
||||||
delete ui;
|
delete ui;
|
||||||
@endif
|
@endif
|
||||||
}
|
}
|
||||||
|
@@ -6,9 +6,13 @@
|
|||||||
#define %{GUARD}
|
#define %{GUARD}
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if %{GenerateForm} && ! %{JS: QtSupport.uiAsPointer() }
|
||||||
|
#include "%{UiHdrFileName}"
|
||||||
|
|
||||||
|
@endif
|
||||||
%{JS: QtSupport.qtIncludes([ 'QtGui/%{BaseClass}' ], [ 'QtWidgets/%{BaseClass}' ]) }\
|
%{JS: QtSupport.qtIncludes([ 'QtGui/%{BaseClass}' ], [ 'QtWidgets/%{BaseClass}' ]) }\
|
||||||
%{JS: Cpp.openNamespaces('%{Class}')}\
|
%{JS: Cpp.openNamespaces('%{Class}')}\
|
||||||
@if %{GenerateForm}
|
@if %{GenerateForm} && %{JS: QtSupport.uiAsPointer() }
|
||||||
|
|
||||||
@if ! %{JS: Cpp.hasNamespaces('%{Class}')}
|
@if ! %{JS: Cpp.hasNamespaces('%{Class}')}
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@@ -19,7 +23,12 @@ QT_END_NAMESPACE
|
|||||||
@endif
|
@endif
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
class %{CN} : public %{BaseClass}
|
class %{CN} : public %{BaseClass}\
|
||||||
|
@if %{GenerateForm} && %{JS: QtSupport.uiAsInheritance() }
|
||||||
|
, private Ui::%{CN}
|
||||||
|
@else
|
||||||
|
|
||||||
|
@endif
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -27,9 +36,15 @@ public:
|
|||||||
%{CN}(QWidget *parent = nullptr);
|
%{CN}(QWidget *parent = nullptr);
|
||||||
~%{CN}();
|
~%{CN}();
|
||||||
@if %{GenerateForm}
|
@if %{GenerateForm}
|
||||||
|
@if %{JS: QtSupport.uiAsPointer() }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::%{CN} *ui;
|
Ui::%{CN} *ui;
|
||||||
|
@elsif %{JS: QtSupport.uiAsMember() }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::%{CN} ui;
|
||||||
|
@endif
|
||||||
@endif
|
@endif
|
||||||
};
|
};
|
||||||
%{JS: Cpp.closeNamespaces('%{Class}')}\
|
%{JS: Cpp.closeNamespaces('%{Class}')}\
|
||||||
|
@@ -197,4 +197,25 @@ QString CodeGenerator::qtIncludes(const QStringList &qt4, const QStringList &qt5
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CodeGenerator::uiAsPointer()
|
||||||
|
{
|
||||||
|
CodeGenSettings settings;
|
||||||
|
settings.fromSettings(Core::ICore::settings());
|
||||||
|
return settings.embedding == CodeGenSettings::PointerAggregatedUiClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CodeGenerator::uiAsMember()
|
||||||
|
{
|
||||||
|
CodeGenSettings settings;
|
||||||
|
settings.fromSettings(Core::ICore::settings());
|
||||||
|
return settings.embedding == CodeGenSettings::AggregatedUiClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CodeGenerator::uiAsInheritance()
|
||||||
|
{
|
||||||
|
CodeGenSettings settings;
|
||||||
|
settings.fromSettings(Core::ICore::settings());
|
||||||
|
return settings.embedding == CodeGenSettings::InheritedUiClass;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace QtSupport
|
} // namespace QtSupport
|
||||||
|
@@ -50,6 +50,11 @@ public:
|
|||||||
|
|
||||||
// Generic Qt:
|
// Generic Qt:
|
||||||
Q_INVOKABLE static QString qtIncludes(const QStringList &qt4, const QStringList &qt5);
|
Q_INVOKABLE static QString qtIncludes(const QStringList &qt4, const QStringList &qt5);
|
||||||
|
|
||||||
|
// UI file integration
|
||||||
|
Q_INVOKABLE static bool uiAsPointer();
|
||||||
|
Q_INVOKABLE static bool uiAsMember();
|
||||||
|
Q_INVOKABLE static bool uiAsInheritance();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QtSupport
|
} // namespace QtSupport
|
||||||
|
Reference in New Issue
Block a user