Skip to content

Commit 0f0ed5a

Browse files
committed
Merge branch 'autouic' into 'master'
Move from qt_wrap_ui to AUTOUIC for all qt dependant components See merge request OpenMW/openmw!4446
2 parents ac7b54a + 306982c commit 0f0ed5a

File tree

6 files changed

+44
-67
lines changed

6 files changed

+44
-67
lines changed

apps/launcher/CMakeLists.txt

+2-14
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,6 @@ set(LAUNCHER_HEADER
3333
utils/openalutil.hpp
3434
)
3535

36-
# Headers that must be pre-processed
37-
set(LAUNCHER_UI
38-
${CMAKE_CURRENT_SOURCE_DIR}/ui/datafilespage.ui
39-
${CMAKE_CURRENT_SOURCE_DIR}/ui/graphicspage.ui
40-
${CMAKE_CURRENT_SOURCE_DIR}/ui/mainwindow.ui
41-
${CMAKE_CURRENT_SOURCE_DIR}/ui/importpage.ui
42-
${CMAKE_CURRENT_SOURCE_DIR}/ui/settingspage.ui
43-
${CMAKE_CURRENT_SOURCE_DIR}/ui/directorypicker.ui
44-
)
45-
4636
source_group(launcher FILES ${LAUNCHER} ${LAUNCHER_HEADER})
4737

4838
set(QT_USE_QTGUI 1)
@@ -57,9 +47,7 @@ if(WIN32)
5747
endif(WIN32)
5848

5949
QT_ADD_RESOURCES(RCC_SRCS ${LAUNCHER_RES})
60-
QT_WRAP_UI(UI_HDRS ${LAUNCHER_UI})
6150

62-
include_directories(${CMAKE_CURRENT_BINARY_DIR})
6351
if(NOT WIN32)
6452
include_directories(${LIBUNSHIELD_INCLUDE_DIR})
6553
endif(NOT WIN32)
@@ -70,8 +58,6 @@ openmw_add_executable(openmw-launcher
7058
${LAUNCHER}
7159
${LAUNCHER_HEADER}
7260
${RCC_SRCS}
73-
${MOC_SRCS}
74-
${UI_HDRS}
7561
)
7662

7763
add_dependencies(openmw-launcher qm-files)
@@ -95,6 +81,8 @@ endif()
9581

9682
if(USE_QT)
9783
set_property(TARGET openmw-launcher PROPERTY AUTOMOC ON)
84+
set_property(TARGET openmw-launcher PROPERTY AUTOUIC ON)
85+
set_property(TARGET openmw-launcher PROPERTY AUTOUIC_SEARCH_PATHS ui)
9886
endif(USE_QT)
9987

10088
if (MSVC AND PRECOMPILE_HEADERS_WITH_MSVC)

apps/opencs/CMakeLists.txt

+6-12
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,6 @@ set (OPENCS_RES ${CMAKE_SOURCE_DIR}/files/opencs/resources.qrc
137137
${CMAKE_SOURCE_DIR}/files/launcher/launcher.qrc
138138
)
139139

140-
set (OPENCS_UI
141-
${CMAKE_CURRENT_SOURCE_DIR}/ui/filedialog.ui
142-
)
143-
144140
source_group (openmw-cs FILES main.cpp ${OPENCS_SRC} ${OPENCS_HDR})
145141

146142
if(WIN32)
@@ -151,16 +147,8 @@ else(WIN32)
151147
set(OPENCS_RC_FILE "")
152148
endif(WIN32)
153149

154-
if (QT_VERSION_MAJOR VERSION_EQUAL 5)
155-
qt5_wrap_ui(OPENCS_UI_HDR ${OPENCS_UI})
156-
else ()
157-
qt6_wrap_ui(OPENCS_UI_HDR ${OPENCS_UI})
158-
endif()
159150
qt_add_resources(OPENCS_RES_SRC ${OPENCS_RES})
160151

161-
# for compiled .ui files
162-
include_directories(${CMAKE_CURRENT_BINARY_DIR})
163-
164152
if(APPLE)
165153
set (OPENCS_MAC_ICON "${CMAKE_SOURCE_DIR}/files/mac/openmw-cs.icns")
166154
set (OPENCS_CFG "${OpenMW_BINARY_DIR}/defaults-cs.bin")
@@ -193,6 +181,10 @@ if(BUILD_OPENCS)
193181

194182
target_link_libraries(openmw-cs openmw-cs-lib)
195183

184+
set_property(TARGET openmw-cs PROPERTY AUTOMOC ON)
185+
set_property(TARGET openmw-cs PROPERTY AUTOUIC_SEARCH_PATHS ui)
186+
set_property(TARGET openmw-cs PROPERTY AUTOUIC ON)
187+
196188
if (BUILD_WITH_CODE_COVERAGE)
197189
target_compile_options(openmw-cs PRIVATE --coverage)
198190
target_link_libraries(openmw-cs gcov)
@@ -284,6 +276,8 @@ endif()
284276

285277
if(USE_QT)
286278
set_property(TARGET openmw-cs-lib PROPERTY AUTOMOC ON)
279+
set_property(TARGET openmw-cs-lib PROPERTY AUTOUIC_SEARCH_PATHS ui)
280+
set_property(TARGET openmw-cs-lib PROPERTY AUTOUIC ON)
287281
endif(USE_QT)
288282

289283
if (BUILD_WITH_CODE_COVERAGE)

apps/opencs/view/doc/filedialog.cpp

+22-17
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,27 @@
1313
#include "adjusterwidget.hpp"
1414
#include "filewidget.hpp"
1515

16+
#include "ui_filedialog.h"
17+
1618
CSVDoc::FileDialog::FileDialog(QWidget* parent)
1719
: QDialog(parent)
1820
, mSelector(nullptr)
21+
, ui(std::make_unique<Ui::FileDialog>())
1922
, mAction(ContentAction_Undefined)
2023
, mFileWidget(nullptr)
2124
, mAdjusterWidget(nullptr)
2225
, mDialogBuilt(false)
2326
{
24-
ui.setupUi(this);
27+
ui->setupUi(this);
2528
resize(400, 400);
2629

2730
setObjectName("FileDialog");
28-
mSelector = new ContentSelectorView::ContentSelector(ui.contentSelectorWidget, /*showOMWScripts=*/false);
31+
mSelector = new ContentSelectorView::ContentSelector(ui->contentSelectorWidget, /*showOMWScripts=*/false);
2932
mAdjusterWidget = new AdjusterWidget(this);
3033
}
3134

35+
CSVDoc::FileDialog::~FileDialog() = default;
36+
3237
void CSVDoc::FileDialog::addFiles(const std::vector<std::filesystem::path>& dataDirs)
3338
{
3439
for (auto iter = dataDirs.rbegin(); iter != dataDirs.rend(); ++iter)
@@ -68,7 +73,7 @@ void CSVDoc::FileDialog::showDialog(ContentAction action)
6873
{
6974
mAction = action;
7075

71-
ui.projectGroupBoxLayout->insertWidget(0, mAdjusterWidget);
76+
ui->projectGroupBoxLayout->insertWidget(0, mAdjusterWidget);
7277

7378
switch (mAction)
7479
{
@@ -92,7 +97,7 @@ void CSVDoc::FileDialog::showDialog(ContentAction action)
9297
connect(mSelector, &ContentSelectorView::ContentSelector::signalCurrentGamefileIndexChanged, this,
9398
qOverload<int>(&FileDialog::slotUpdateAcceptButton));
9499

95-
connect(ui.projectButtonBox, &QDialogButtonBox::rejected, this, &FileDialog::slotRejected);
100+
connect(ui->projectButtonBox, &QDialogButtonBox::rejected, this, &FileDialog::slotRejected);
96101
mDialogBuilt = true;
97102
}
98103

@@ -105,7 +110,7 @@ void CSVDoc::FileDialog::buildNewFileView()
105110
{
106111
setWindowTitle(tr("Create a new addon"));
107112

108-
QPushButton* createButton = ui.projectButtonBox->button(QDialogButtonBox::Ok);
113+
QPushButton* createButton = ui->projectButtonBox->button(QDialogButtonBox::Ok);
109114
createButton->setText("Create");
110115
createButton->setEnabled(false);
111116

@@ -122,27 +127,27 @@ void CSVDoc::FileDialog::buildNewFileView()
122127
qOverload<const QString&, bool>(&FileDialog::slotUpdateAcceptButton));
123128
}
124129

125-
ui.projectGroupBoxLayout->insertWidget(0, mFileWidget);
130+
ui->projectGroupBoxLayout->insertWidget(0, mFileWidget);
126131

127-
connect(ui.projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotNewFile);
132+
connect(ui->projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotNewFile);
128133
}
129134

130135
void CSVDoc::FileDialog::buildOpenFileView()
131136
{
132137
setWindowTitle(tr("Open"));
133-
ui.projectGroupBox->setTitle(QString(""));
134-
ui.projectButtonBox->button(QDialogButtonBox::Ok)->setText("Open");
138+
ui->projectGroupBox->setTitle(QString(""));
139+
ui->projectButtonBox->button(QDialogButtonBox::Ok)->setText("Open");
135140
if (mSelector->isGamefileSelected())
136-
ui.projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
141+
ui->projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
137142
else
138-
ui.projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
143+
ui->projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
139144

140145
if (!mDialogBuilt)
141146
{
142147
connect(mSelector, &ContentSelectorView::ContentSelector::signalAddonDataChanged, this,
143148
&FileDialog::slotAddonDataChanged);
144149
}
145-
connect(ui.projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotOpenFile);
150+
connect(ui->projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotOpenFile);
146151
}
147152

148153
void CSVDoc::FileDialog::slotAddonDataChanged(const QModelIndex& topleft, const QModelIndex& bottomright)
@@ -176,7 +181,7 @@ void CSVDoc::FileDialog::slotUpdateAcceptButton(const QString& name, bool)
176181
else
177182
mAdjusterWidget->setName("", true);
178183

179-
ui.projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled(success);
184+
ui->projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled(success);
180185
}
181186

182187
QString CSVDoc::FileDialog::filename() const
@@ -190,8 +195,8 @@ QString CSVDoc::FileDialog::filename() const
190195
void CSVDoc::FileDialog::slotRejected()
191196
{
192197
emit rejected();
193-
disconnect(ui.projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotNewFile);
194-
disconnect(ui.projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotOpenFile);
198+
disconnect(ui->projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotNewFile);
199+
disconnect(ui->projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotOpenFile);
195200
if (mFileWidget)
196201
{
197202
delete mFileWidget;
@@ -208,7 +213,7 @@ void CSVDoc::FileDialog::slotNewFile()
208213
delete mFileWidget;
209214
mFileWidget = nullptr;
210215
}
211-
disconnect(ui.projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotNewFile);
216+
disconnect(ui->projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotNewFile);
212217
close();
213218
}
214219

@@ -219,6 +224,6 @@ void CSVDoc::FileDialog::slotOpenFile()
219224
mAdjusterWidget->setName(file->filePath(), !file->isGameFile());
220225

221226
emit signalOpenFiles(mAdjusterWidget->getPath());
222-
disconnect(ui.projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotOpenFile);
227+
disconnect(ui->projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotOpenFile);
223228
close();
224229
}

apps/opencs/view/doc/filedialog.hpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ Q_DECLARE_METATYPE(std::filesystem::path)
1414

1515
#endif
1616

17-
#include "ui_filedialog.h"
18-
1917
#include <filesystem>
2018
#include <vector>
2119

@@ -26,6 +24,11 @@ namespace ContentSelectorView
2624
class ContentSelector;
2725
}
2826

27+
namespace Ui
28+
{
29+
class FileDialog;
30+
}
31+
2932
namespace CSVDoc
3033
{
3134
class FileWidget;
@@ -36,14 +39,17 @@ namespace CSVDoc
3639

3740
private:
3841
ContentSelectorView::ContentSelector* mSelector;
39-
Ui::FileDialog ui;
42+
std::unique_ptr<Ui::FileDialog> ui;
4043
ContentAction mAction;
4144
FileWidget* mFileWidget;
4245
AdjusterWidget* mAdjusterWidget;
4346
bool mDialogBuilt;
4447

4548
public:
4649
explicit FileDialog(QWidget* parent = nullptr);
50+
51+
~FileDialog();
52+
4753
void showDialog(ContentAction action);
4854

4955
void addFiles(const std::vector<std::filesystem::path>& dataDirs);

apps/wizard/CMakeLists.txt

+2-16
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,9 @@ set(WIZARD_HEADER
3333
utils/componentlistwidget.hpp
3434
)
3535

36-
set(WIZARD_UI
37-
${CMAKE_CURRENT_SOURCE_DIR}/ui/componentselectionpage.ui
38-
${CMAKE_CURRENT_SOURCE_DIR}/ui/conclusionpage.ui
39-
${CMAKE_CURRENT_SOURCE_DIR}/ui/existinginstallationpage.ui
40-
${CMAKE_CURRENT_SOURCE_DIR}/ui/importpage.ui
41-
${CMAKE_CURRENT_SOURCE_DIR}/ui/installationtargetpage.ui
42-
${CMAKE_CURRENT_SOURCE_DIR}/ui/intropage.ui
43-
${CMAKE_CURRENT_SOURCE_DIR}/ui/languageselectionpage.ui
44-
${CMAKE_CURRENT_SOURCE_DIR}/ui/methodselectionpage.ui
45-
)
46-
4736
if (OPENMW_USE_UNSHIELD)
4837
set (WIZARD ${WIZARD} installationpage.cpp unshield/unshieldworker.cpp)
4938
set (WIZARD_HEADER ${WIZARD_HEADER} installationpage.hpp unshield/unshieldworker.hpp)
50-
set (WIZARD_UI ${WIZARD_UI} ${CMAKE_CURRENT_SOURCE_DIR}/ui/installationpage.ui)
5139
add_definitions(-DOPENMW_USE_UNSHIELD)
5240
endif (OPENMW_USE_UNSHIELD)
5341

@@ -66,9 +54,6 @@ if(WIN32)
6654
endif(WIN32)
6755

6856
QT_ADD_RESOURCES(RCC_SRCS ${WIZARD_RES})
69-
QT_WRAP_UI(UI_HDRS ${WIZARD_UI})
70-
71-
include_directories(${CMAKE_CURRENT_BINARY_DIR})
7257

7358
if (OPENMW_USE_UNSHIELD)
7459
include_directories(${LIBUNSHIELD_INCLUDE_DIRS})
@@ -79,7 +64,6 @@ openmw_add_executable(openmw-wizard
7964
${WIZARD}
8065
${WIZARD_HEADER}
8166
${RCC_SRCS}
82-
${UI_HDRS}
8367
)
8468

8569
add_dependencies(openmw-wizard qm-files)
@@ -109,4 +93,6 @@ endif(WIN32)
10993

11094
if(USE_QT)
11195
set_property(TARGET openmw-wizard PROPERTY AUTOMOC ON)
96+
set_property(TARGET openmw-wizard PROPERTY AUTOUIC ON)
97+
set_property(TARGET openmw-wizard PROPERTY AUTOUIC_SEARCH_PATHS ui)
11298
endif(USE_QT)

components/CMakeLists.txt

+3-5
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,6 @@ add_component_dir(testing
517517
util
518518
)
519519

520-
set (ESM_UI ${CMAKE_CURRENT_SOURCE_DIR}/contentselector/contentselector.ui
521-
)
522-
523520
if (USE_QT)
524521
add_component_qt_dir (contentselector
525522
model/modelitem model/esmfile
@@ -558,7 +555,6 @@ if (USE_QT)
558555
qtconversion
559556
)
560557

561-
QT_WRAP_UI(ESM_UI_HDR ${ESM_UI})
562558
endif()
563559

564560
include_directories(${BULLET_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR})
@@ -619,7 +615,7 @@ endif()
619615
target_link_libraries(components ${BULLET_LIBRARIES})
620616

621617
if (USE_QT)
622-
add_library(components_qt STATIC ${COMPONENT_QT_FILES} ${ESM_UI_HDR})
618+
add_library(components_qt STATIC ${COMPONENT_QT_FILES})
623619
target_link_libraries(components_qt components Qt::Widgets Qt::Core)
624620

625621
if (BUILD_LAUNCHER OR BUILD_WIZARD)
@@ -692,6 +688,8 @@ endif(OSG_STATIC)
692688

693689
if(USE_QT)
694690
set_property(TARGET components_qt PROPERTY AUTOMOC ON)
691+
set_property(TARGET components_qt PROPERTY AUTOUIC ON)
692+
set_property(TARGET components_qt PROPERTY AUTOUIC_SEARCH_PATHS contentselector)
695693
endif(USE_QT)
696694

697695
if (MSVC AND PRECOMPILE_HEADERS_WITH_MSVC)

0 commit comments

Comments
 (0)