mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-02 16:06:39 +00:00
Move from qt_wrap_ui to AUTOUIC for opencs
Set opencs target properties in appropriate section Use forward declaration for Ui::FileDialog (#7348)
This commit is contained in:
parent
05a71e982d
commit
306982cdd1
3 changed files with 37 additions and 32 deletions
|
@ -137,10 +137,6 @@ set (OPENCS_RES ${CMAKE_SOURCE_DIR}/files/opencs/resources.qrc
|
||||||
${CMAKE_SOURCE_DIR}/files/launcher/launcher.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})
|
source_group (openmw-cs FILES main.cpp ${OPENCS_SRC} ${OPENCS_HDR})
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
@ -151,16 +147,8 @@ else(WIN32)
|
||||||
set(OPENCS_RC_FILE "")
|
set(OPENCS_RC_FILE "")
|
||||||
endif(WIN32)
|
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})
|
qt_add_resources(OPENCS_RES_SRC ${OPENCS_RES})
|
||||||
|
|
||||||
# for compiled .ui files
|
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set (OPENCS_MAC_ICON "${CMAKE_SOURCE_DIR}/files/mac/openmw-cs.icns")
|
set (OPENCS_MAC_ICON "${CMAKE_SOURCE_DIR}/files/mac/openmw-cs.icns")
|
||||||
set (OPENCS_CFG "${OpenMW_BINARY_DIR}/defaults-cs.bin")
|
set (OPENCS_CFG "${OpenMW_BINARY_DIR}/defaults-cs.bin")
|
||||||
|
@ -193,6 +181,10 @@ if(BUILD_OPENCS)
|
||||||
|
|
||||||
target_link_libraries(openmw-cs openmw-cs-lib)
|
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)
|
if (BUILD_WITH_CODE_COVERAGE)
|
||||||
target_compile_options(openmw-cs PRIVATE --coverage)
|
target_compile_options(openmw-cs PRIVATE --coverage)
|
||||||
target_link_libraries(openmw-cs gcov)
|
target_link_libraries(openmw-cs gcov)
|
||||||
|
@ -284,6 +276,8 @@ endif()
|
||||||
|
|
||||||
if(USE_QT)
|
if(USE_QT)
|
||||||
set_property(TARGET openmw-cs-lib PROPERTY AUTOMOC ON)
|
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)
|
endif(USE_QT)
|
||||||
|
|
||||||
if (BUILD_WITH_CODE_COVERAGE)
|
if (BUILD_WITH_CODE_COVERAGE)
|
||||||
|
|
|
@ -13,22 +13,27 @@
|
||||||
#include "adjusterwidget.hpp"
|
#include "adjusterwidget.hpp"
|
||||||
#include "filewidget.hpp"
|
#include "filewidget.hpp"
|
||||||
|
|
||||||
|
#include "ui_filedialog.h"
|
||||||
|
|
||||||
CSVDoc::FileDialog::FileDialog(QWidget* parent)
|
CSVDoc::FileDialog::FileDialog(QWidget* parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, mSelector(nullptr)
|
, mSelector(nullptr)
|
||||||
|
, ui(std::make_unique<Ui::FileDialog>())
|
||||||
, mAction(ContentAction_Undefined)
|
, mAction(ContentAction_Undefined)
|
||||||
, mFileWidget(nullptr)
|
, mFileWidget(nullptr)
|
||||||
, mAdjusterWidget(nullptr)
|
, mAdjusterWidget(nullptr)
|
||||||
, mDialogBuilt(false)
|
, mDialogBuilt(false)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui->setupUi(this);
|
||||||
resize(400, 400);
|
resize(400, 400);
|
||||||
|
|
||||||
setObjectName("FileDialog");
|
setObjectName("FileDialog");
|
||||||
mSelector = new ContentSelectorView::ContentSelector(ui.contentSelectorWidget, /*showOMWScripts=*/false);
|
mSelector = new ContentSelectorView::ContentSelector(ui->contentSelectorWidget, /*showOMWScripts=*/false);
|
||||||
mAdjusterWidget = new AdjusterWidget(this);
|
mAdjusterWidget = new AdjusterWidget(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CSVDoc::FileDialog::~FileDialog() = default;
|
||||||
|
|
||||||
void CSVDoc::FileDialog::addFiles(const std::vector<std::filesystem::path>& dataDirs)
|
void CSVDoc::FileDialog::addFiles(const std::vector<std::filesystem::path>& dataDirs)
|
||||||
{
|
{
|
||||||
for (auto iter = dataDirs.rbegin(); iter != dataDirs.rend(); ++iter)
|
for (auto iter = dataDirs.rbegin(); iter != dataDirs.rend(); ++iter)
|
||||||
|
@ -68,7 +73,7 @@ void CSVDoc::FileDialog::showDialog(ContentAction action)
|
||||||
{
|
{
|
||||||
mAction = action;
|
mAction = action;
|
||||||
|
|
||||||
ui.projectGroupBoxLayout->insertWidget(0, mAdjusterWidget);
|
ui->projectGroupBoxLayout->insertWidget(0, mAdjusterWidget);
|
||||||
|
|
||||||
switch (mAction)
|
switch (mAction)
|
||||||
{
|
{
|
||||||
|
@ -92,7 +97,7 @@ void CSVDoc::FileDialog::showDialog(ContentAction action)
|
||||||
connect(mSelector, &ContentSelectorView::ContentSelector::signalCurrentGamefileIndexChanged, this,
|
connect(mSelector, &ContentSelectorView::ContentSelector::signalCurrentGamefileIndexChanged, this,
|
||||||
qOverload<int>(&FileDialog::slotUpdateAcceptButton));
|
qOverload<int>(&FileDialog::slotUpdateAcceptButton));
|
||||||
|
|
||||||
connect(ui.projectButtonBox, &QDialogButtonBox::rejected, this, &FileDialog::slotRejected);
|
connect(ui->projectButtonBox, &QDialogButtonBox::rejected, this, &FileDialog::slotRejected);
|
||||||
mDialogBuilt = true;
|
mDialogBuilt = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +110,7 @@ void CSVDoc::FileDialog::buildNewFileView()
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Create a new addon"));
|
setWindowTitle(tr("Create a new addon"));
|
||||||
|
|
||||||
QPushButton* createButton = ui.projectButtonBox->button(QDialogButtonBox::Ok);
|
QPushButton* createButton = ui->projectButtonBox->button(QDialogButtonBox::Ok);
|
||||||
createButton->setText("Create");
|
createButton->setText("Create");
|
||||||
createButton->setEnabled(false);
|
createButton->setEnabled(false);
|
||||||
|
|
||||||
|
@ -122,27 +127,27 @@ void CSVDoc::FileDialog::buildNewFileView()
|
||||||
qOverload<const QString&, bool>(&FileDialog::slotUpdateAcceptButton));
|
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()
|
void CSVDoc::FileDialog::buildOpenFileView()
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Open"));
|
setWindowTitle(tr("Open"));
|
||||||
ui.projectGroupBox->setTitle(QString(""));
|
ui->projectGroupBox->setTitle(QString(""));
|
||||||
ui.projectButtonBox->button(QDialogButtonBox::Ok)->setText("Open");
|
ui->projectButtonBox->button(QDialogButtonBox::Ok)->setText("Open");
|
||||||
if (mSelector->isGamefileSelected())
|
if (mSelector->isGamefileSelected())
|
||||||
ui.projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
ui->projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||||
else
|
else
|
||||||
ui.projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
ui->projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||||
|
|
||||||
if (!mDialogBuilt)
|
if (!mDialogBuilt)
|
||||||
{
|
{
|
||||||
connect(mSelector, &ContentSelectorView::ContentSelector::signalAddonDataChanged, this,
|
connect(mSelector, &ContentSelectorView::ContentSelector::signalAddonDataChanged, this,
|
||||||
&FileDialog::slotAddonDataChanged);
|
&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)
|
void CSVDoc::FileDialog::slotAddonDataChanged(const QModelIndex& topleft, const QModelIndex& bottomright)
|
||||||
|
@ -176,7 +181,7 @@ void CSVDoc::FileDialog::slotUpdateAcceptButton(const QString& name, bool)
|
||||||
else
|
else
|
||||||
mAdjusterWidget->setName("", true);
|
mAdjusterWidget->setName("", true);
|
||||||
|
|
||||||
ui.projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled(success);
|
ui->projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CSVDoc::FileDialog::filename() const
|
QString CSVDoc::FileDialog::filename() const
|
||||||
|
@ -190,8 +195,8 @@ QString CSVDoc::FileDialog::filename() const
|
||||||
void CSVDoc::FileDialog::slotRejected()
|
void CSVDoc::FileDialog::slotRejected()
|
||||||
{
|
{
|
||||||
emit rejected();
|
emit rejected();
|
||||||
disconnect(ui.projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotNewFile);
|
disconnect(ui->projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotNewFile);
|
||||||
disconnect(ui.projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotOpenFile);
|
disconnect(ui->projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotOpenFile);
|
||||||
if (mFileWidget)
|
if (mFileWidget)
|
||||||
{
|
{
|
||||||
delete mFileWidget;
|
delete mFileWidget;
|
||||||
|
@ -208,7 +213,7 @@ void CSVDoc::FileDialog::slotNewFile()
|
||||||
delete mFileWidget;
|
delete mFileWidget;
|
||||||
mFileWidget = nullptr;
|
mFileWidget = nullptr;
|
||||||
}
|
}
|
||||||
disconnect(ui.projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotNewFile);
|
disconnect(ui->projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotNewFile);
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,6 +224,6 @@ void CSVDoc::FileDialog::slotOpenFile()
|
||||||
mAdjusterWidget->setName(file->filePath(), !file->isGameFile());
|
mAdjusterWidget->setName(file->filePath(), !file->isGameFile());
|
||||||
|
|
||||||
emit signalOpenFiles(mAdjusterWidget->getPath());
|
emit signalOpenFiles(mAdjusterWidget->getPath());
|
||||||
disconnect(ui.projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotOpenFile);
|
disconnect(ui->projectButtonBox, &QDialogButtonBox::accepted, this, &FileDialog::slotOpenFile);
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,6 @@ Q_DECLARE_METATYPE(std::filesystem::path)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ui_filedialog.h"
|
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -26,6 +24,11 @@ namespace ContentSelectorView
|
||||||
class ContentSelector;
|
class ContentSelector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Ui
|
||||||
|
{
|
||||||
|
class FileDialog;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CSVDoc
|
namespace CSVDoc
|
||||||
{
|
{
|
||||||
class FileWidget;
|
class FileWidget;
|
||||||
|
@ -36,7 +39,7 @@ namespace CSVDoc
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ContentSelectorView::ContentSelector* mSelector;
|
ContentSelectorView::ContentSelector* mSelector;
|
||||||
Ui::FileDialog ui;
|
std::unique_ptr<Ui::FileDialog> ui;
|
||||||
ContentAction mAction;
|
ContentAction mAction;
|
||||||
FileWidget* mFileWidget;
|
FileWidget* mFileWidget;
|
||||||
AdjusterWidget* mAdjusterWidget;
|
AdjusterWidget* mAdjusterWidget;
|
||||||
|
@ -44,6 +47,9 @@ namespace CSVDoc
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FileDialog(QWidget* parent = nullptr);
|
explicit FileDialog(QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
~FileDialog();
|
||||||
|
|
||||||
void showDialog(ContentAction action);
|
void showDialog(ContentAction action);
|
||||||
|
|
||||||
void addFiles(const std::vector<std::filesystem::path>& dataDirs);
|
void addFiles(const std::vector<std::filesystem::path>& dataDirs);
|
||||||
|
|
Loading…
Reference in a new issue