1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-06 07:15:36 +00:00

Merge branch 'autouic' into 'master'

Move from qt_wrap_ui to AUTOUIC for all qt dependant components

See merge request OpenMW/openmw!4446
This commit is contained in:
AnyOldName3 2024-11-10 21:34:24 +00:00
commit 0f0ed5a670
6 changed files with 44 additions and 67 deletions

View file

@ -33,16 +33,6 @@ set(LAUNCHER_HEADER
utils/openalutil.hpp
)
# Headers that must be pre-processed
set(LAUNCHER_UI
${CMAKE_CURRENT_SOURCE_DIR}/ui/datafilespage.ui
${CMAKE_CURRENT_SOURCE_DIR}/ui/graphicspage.ui
${CMAKE_CURRENT_SOURCE_DIR}/ui/mainwindow.ui
${CMAKE_CURRENT_SOURCE_DIR}/ui/importpage.ui
${CMAKE_CURRENT_SOURCE_DIR}/ui/settingspage.ui
${CMAKE_CURRENT_SOURCE_DIR}/ui/directorypicker.ui
)
source_group(launcher FILES ${LAUNCHER} ${LAUNCHER_HEADER})
set(QT_USE_QTGUI 1)
@ -57,9 +47,7 @@ if(WIN32)
endif(WIN32)
QT_ADD_RESOURCES(RCC_SRCS ${LAUNCHER_RES})
QT_WRAP_UI(UI_HDRS ${LAUNCHER_UI})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
if(NOT WIN32)
include_directories(${LIBUNSHIELD_INCLUDE_DIR})
endif(NOT WIN32)
@ -70,8 +58,6 @@ openmw_add_executable(openmw-launcher
${LAUNCHER}
${LAUNCHER_HEADER}
${RCC_SRCS}
${MOC_SRCS}
${UI_HDRS}
)
add_dependencies(openmw-launcher qm-files)
@ -95,6 +81,8 @@ endif()
if(USE_QT)
set_property(TARGET openmw-launcher PROPERTY AUTOMOC ON)
set_property(TARGET openmw-launcher PROPERTY AUTOUIC ON)
set_property(TARGET openmw-launcher PROPERTY AUTOUIC_SEARCH_PATHS ui)
endif(USE_QT)
if (MSVC AND PRECOMPILE_HEADERS_WITH_MSVC)

View file

@ -137,10 +137,6 @@ set (OPENCS_RES ${CMAKE_SOURCE_DIR}/files/opencs/resources.qrc
${CMAKE_SOURCE_DIR}/files/launcher/launcher.qrc
)
set (OPENCS_UI
${CMAKE_CURRENT_SOURCE_DIR}/ui/filedialog.ui
)
source_group (openmw-cs FILES main.cpp ${OPENCS_SRC} ${OPENCS_HDR})
if(WIN32)
@ -151,16 +147,8 @@ else(WIN32)
set(OPENCS_RC_FILE "")
endif(WIN32)
if (QT_VERSION_MAJOR VERSION_EQUAL 5)
qt5_wrap_ui(OPENCS_UI_HDR ${OPENCS_UI})
else ()
qt6_wrap_ui(OPENCS_UI_HDR ${OPENCS_UI})
endif()
qt_add_resources(OPENCS_RES_SRC ${OPENCS_RES})
# for compiled .ui files
include_directories(${CMAKE_CURRENT_BINARY_DIR})
if(APPLE)
set (OPENCS_MAC_ICON "${CMAKE_SOURCE_DIR}/files/mac/openmw-cs.icns")
set (OPENCS_CFG "${OpenMW_BINARY_DIR}/defaults-cs.bin")
@ -193,6 +181,10 @@ if(BUILD_OPENCS)
target_link_libraries(openmw-cs openmw-cs-lib)
set_property(TARGET openmw-cs PROPERTY AUTOMOC ON)
set_property(TARGET openmw-cs PROPERTY AUTOUIC_SEARCH_PATHS ui)
set_property(TARGET openmw-cs PROPERTY AUTOUIC ON)
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-cs PRIVATE --coverage)
target_link_libraries(openmw-cs gcov)
@ -284,6 +276,8 @@ endif()
if(USE_QT)
set_property(TARGET openmw-cs-lib PROPERTY AUTOMOC ON)
set_property(TARGET openmw-cs-lib PROPERTY AUTOUIC_SEARCH_PATHS ui)
set_property(TARGET openmw-cs-lib PROPERTY AUTOUIC ON)
endif(USE_QT)
if (BUILD_WITH_CODE_COVERAGE)

View file

@ -13,22 +13,27 @@
#include "adjusterwidget.hpp"
#include "filewidget.hpp"
#include "ui_filedialog.h"
CSVDoc::FileDialog::FileDialog(QWidget* parent)
: QDialog(parent)
, mSelector(nullptr)
, ui(std::make_unique<Ui::FileDialog>())
, mAction(ContentAction_Undefined)
, mFileWidget(nullptr)
, mAdjusterWidget(nullptr)
, mDialogBuilt(false)
{
ui.setupUi(this);
ui->setupUi(this);
resize(400, 400);
setObjectName("FileDialog");
mSelector = new ContentSelectorView::ContentSelector(ui.contentSelectorWidget, /*showOMWScripts=*/false);
mSelector = new ContentSelectorView::ContentSelector(ui->contentSelectorWidget, /*showOMWScripts=*/false);
mAdjusterWidget = new AdjusterWidget(this);
}
CSVDoc::FileDialog::~FileDialog() = default;
void CSVDoc::FileDialog::addFiles(const std::vector<std::filesystem::path>& dataDirs)
{
for (auto iter = dataDirs.rbegin(); iter != dataDirs.rend(); ++iter)
@ -68,7 +73,7 @@ void CSVDoc::FileDialog::showDialog(ContentAction action)
{
mAction = action;
ui.projectGroupBoxLayout->insertWidget(0, mAdjusterWidget);
ui->projectGroupBoxLayout->insertWidget(0, mAdjusterWidget);
switch (mAction)
{
@ -92,7 +97,7 @@ void CSVDoc::FileDialog::showDialog(ContentAction action)
connect(mSelector, &ContentSelectorView::ContentSelector::signalCurrentGamefileIndexChanged, this,
qOverload<int>(&FileDialog::slotUpdateAcceptButton));
connect(ui.projectButtonBox, &QDialogButtonBox::rejected, this, &FileDialog::slotRejected);
connect(ui->projectButtonBox, &QDialogButtonBox::rejected, this, &FileDialog::slotRejected);
mDialogBuilt = true;
}
@ -105,7 +110,7 @@ void CSVDoc::FileDialog::buildNewFileView()
{
setWindowTitle(tr("Create a new addon"));
QPushButton* createButton = ui.projectButtonBox->button(QDialogButtonBox::Ok);
QPushButton* createButton = ui->projectButtonBox->button(QDialogButtonBox::Ok);
createButton->setText("Create");
createButton->setEnabled(false);
@ -122,27 +127,27 @@ void CSVDoc::FileDialog::buildNewFileView()
qOverload<const QString&, bool>(&FileDialog::slotUpdateAcceptButton));
}
ui.projectGroupBoxLayout->insertWidget(0, mFileWidget);
ui->projectGroupBoxLayout->insertWidget(0, mFileWidget);
connect(ui.projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotNewFile);
connect(ui->projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotNewFile);
}
void CSVDoc::FileDialog::buildOpenFileView()
{
setWindowTitle(tr("Open"));
ui.projectGroupBox->setTitle(QString(""));
ui.projectButtonBox->button(QDialogButtonBox::Ok)->setText("Open");
ui->projectGroupBox->setTitle(QString(""));
ui->projectButtonBox->button(QDialogButtonBox::Ok)->setText("Open");
if (mSelector->isGamefileSelected())
ui.projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
ui->projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
else
ui.projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
ui->projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
if (!mDialogBuilt)
{
connect(mSelector, &ContentSelectorView::ContentSelector::signalAddonDataChanged, this,
&FileDialog::slotAddonDataChanged);
}
connect(ui.projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotOpenFile);
connect(ui->projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotOpenFile);
}
void CSVDoc::FileDialog::slotAddonDataChanged(const QModelIndex& topleft, const QModelIndex& bottomright)
@ -176,7 +181,7 @@ void CSVDoc::FileDialog::slotUpdateAcceptButton(const QString& name, bool)
else
mAdjusterWidget->setName("", true);
ui.projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled(success);
ui->projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled(success);
}
QString CSVDoc::FileDialog::filename() const
@ -190,8 +195,8 @@ QString CSVDoc::FileDialog::filename() const
void CSVDoc::FileDialog::slotRejected()
{
emit rejected();
disconnect(ui.projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotNewFile);
disconnect(ui.projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotOpenFile);
disconnect(ui->projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotNewFile);
disconnect(ui->projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotOpenFile);
if (mFileWidget)
{
delete mFileWidget;
@ -208,7 +213,7 @@ void CSVDoc::FileDialog::slotNewFile()
delete mFileWidget;
mFileWidget = nullptr;
}
disconnect(ui.projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotNewFile);
disconnect(ui->projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotNewFile);
close();
}
@ -219,6 +224,6 @@ void CSVDoc::FileDialog::slotOpenFile()
mAdjusterWidget->setName(file->filePath(), !file->isGameFile());
emit signalOpenFiles(mAdjusterWidget->getPath());
disconnect(ui.projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotOpenFile);
disconnect(ui->projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotOpenFile);
close();
}

View file

@ -14,8 +14,6 @@ Q_DECLARE_METATYPE(std::filesystem::path)
#endif
#include "ui_filedialog.h"
#include <filesystem>
#include <vector>
@ -26,6 +24,11 @@ namespace ContentSelectorView
class ContentSelector;
}
namespace Ui
{
class FileDialog;
}
namespace CSVDoc
{
class FileWidget;
@ -36,7 +39,7 @@ namespace CSVDoc
private:
ContentSelectorView::ContentSelector* mSelector;
Ui::FileDialog ui;
std::unique_ptr<Ui::FileDialog> ui;
ContentAction mAction;
FileWidget* mFileWidget;
AdjusterWidget* mAdjusterWidget;
@ -44,6 +47,9 @@ namespace CSVDoc
public:
explicit FileDialog(QWidget* parent = nullptr);
~FileDialog();
void showDialog(ContentAction action);
void addFiles(const std::vector<std::filesystem::path>& dataDirs);

View file

@ -33,21 +33,9 @@ set(WIZARD_HEADER
utils/componentlistwidget.hpp
)
set(WIZARD_UI
${CMAKE_CURRENT_SOURCE_DIR}/ui/componentselectionpage.ui
${CMAKE_CURRENT_SOURCE_DIR}/ui/conclusionpage.ui
${CMAKE_CURRENT_SOURCE_DIR}/ui/existinginstallationpage.ui
${CMAKE_CURRENT_SOURCE_DIR}/ui/importpage.ui
${CMAKE_CURRENT_SOURCE_DIR}/ui/installationtargetpage.ui
${CMAKE_CURRENT_SOURCE_DIR}/ui/intropage.ui
${CMAKE_CURRENT_SOURCE_DIR}/ui/languageselectionpage.ui
${CMAKE_CURRENT_SOURCE_DIR}/ui/methodselectionpage.ui
)
if (OPENMW_USE_UNSHIELD)
set (WIZARD ${WIZARD} installationpage.cpp unshield/unshieldworker.cpp)
set (WIZARD_HEADER ${WIZARD_HEADER} installationpage.hpp unshield/unshieldworker.hpp)
set (WIZARD_UI ${WIZARD_UI} ${CMAKE_CURRENT_SOURCE_DIR}/ui/installationpage.ui)
add_definitions(-DOPENMW_USE_UNSHIELD)
endif (OPENMW_USE_UNSHIELD)
@ -66,9 +54,6 @@ if(WIN32)
endif(WIN32)
QT_ADD_RESOURCES(RCC_SRCS ${WIZARD_RES})
QT_WRAP_UI(UI_HDRS ${WIZARD_UI})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
if (OPENMW_USE_UNSHIELD)
include_directories(${LIBUNSHIELD_INCLUDE_DIRS})
@ -79,7 +64,6 @@ openmw_add_executable(openmw-wizard
${WIZARD}
${WIZARD_HEADER}
${RCC_SRCS}
${UI_HDRS}
)
add_dependencies(openmw-wizard qm-files)
@ -109,4 +93,6 @@ endif(WIN32)
if(USE_QT)
set_property(TARGET openmw-wizard PROPERTY AUTOMOC ON)
set_property(TARGET openmw-wizard PROPERTY AUTOUIC ON)
set_property(TARGET openmw-wizard PROPERTY AUTOUIC_SEARCH_PATHS ui)
endif(USE_QT)

View file

@ -517,9 +517,6 @@ add_component_dir(testing
util
)
set (ESM_UI ${CMAKE_CURRENT_SOURCE_DIR}/contentselector/contentselector.ui
)
if (USE_QT)
add_component_qt_dir (contentselector
model/modelitem model/esmfile
@ -558,7 +555,6 @@ if (USE_QT)
qtconversion
)
QT_WRAP_UI(ESM_UI_HDR ${ESM_UI})
endif()
include_directories(${BULLET_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR})
@ -619,7 +615,7 @@ endif()
target_link_libraries(components ${BULLET_LIBRARIES})
if (USE_QT)
add_library(components_qt STATIC ${COMPONENT_QT_FILES} ${ESM_UI_HDR})
add_library(components_qt STATIC ${COMPONENT_QT_FILES})
target_link_libraries(components_qt components Qt::Widgets Qt::Core)
if (BUILD_LAUNCHER OR BUILD_WIZARD)
@ -692,6 +688,8 @@ endif(OSG_STATIC)
if(USE_QT)
set_property(TARGET components_qt PROPERTY AUTOMOC ON)
set_property(TARGET components_qt PROPERTY AUTOUIC ON)
set_property(TARGET components_qt PROPERTY AUTOUIC_SEARCH_PATHS contentselector)
endif(USE_QT)
if (MSVC AND PRECOMPILE_HEADERS_WITH_MSVC)