mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 21:10:04 +00:00
Merge pull request #415 from AdenKoperczak/add_theme_editor
Add theme editor
This commit is contained in:
commit
b74229a3f4
5 changed files with 64 additions and 20 deletions
2
.gitmodules
vendored
2
.gitmodules
vendored
|
|
@ -39,4 +39,4 @@
|
|||
url = https://github.com/dpaulat/maplibre-gl-native.git
|
||||
[submodule "external/qt6ct"]
|
||||
path = external/qt6ct
|
||||
url = https://github.com/trialuser02/qt6ct.git
|
||||
url = https://github.com/AdenKoperczak/qt6ct.git
|
||||
|
|
|
|||
2
external/qt6ct
vendored
2
external/qt6ct
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit 55dba8704c0a748b0ce9f2d3cc2cf200ca3db464
|
||||
Subproject commit 2c569c6c4776ea5a1299030c079b16f70473c9e6
|
||||
27
external/qt6ct.cmake
vendored
27
external/qt6ct.cmake
vendored
|
|
@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 3.16.0)
|
|||
set(PROJECT_NAME scwx-qt6ct)
|
||||
|
||||
find_package(QT NAMES Qt6
|
||||
COMPONENTS Gui
|
||||
COMPONENTS Gui Widgets
|
||||
REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR}
|
||||
COMPONENTS Gui
|
||||
COMPONENTS Gui Widgets
|
||||
REQUIRED)
|
||||
|
||||
#extract version from qt6ct.h
|
||||
|
|
@ -24,20 +24,39 @@ else()
|
|||
message(FATAL_ERROR "invalid header")
|
||||
endif()
|
||||
|
||||
set(app_SRCS
|
||||
set(qt6ct-common-source
|
||||
qt6ct/src/qt6ct-common/qt6ct.cpp
|
||||
)
|
||||
|
||||
add_library(qt6ct-common STATIC ${app_SRCS})
|
||||
set(qt6ct-widgets-source
|
||||
qt6ct/src/qt6ct/paletteeditdialog.cpp
|
||||
qt6ct/src/qt6ct/paletteeditdialog.ui
|
||||
)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
include_directories(qt6ct/src/qt6ct-common)
|
||||
|
||||
add_library(qt6ct-common STATIC ${qt6ct-common-source})
|
||||
set_target_properties(qt6ct-common PROPERTIES VERSION ${QT6CT_VERSION})
|
||||
target_link_libraries(qt6ct-common PRIVATE Qt6::Gui)
|
||||
target_compile_definitions(qt6ct-common PRIVATE QT6CT_LIBRARY)
|
||||
|
||||
add_library(qt6ct-widgets STATIC ${qt6ct-widgets-source})
|
||||
set_target_properties(qt6ct-widgets PROPERTIES VERSION ${QT6CT_VERSION})
|
||||
target_link_libraries(qt6ct-widgets PRIVATE Qt6::Widgets Qt6::WidgetsPrivate qt6ct-common)
|
||||
target_compile_definitions(qt6ct-widgets PRIVATE QT6CT_LIBRARY)
|
||||
|
||||
if (MSVC)
|
||||
# Produce PDB file for debug
|
||||
target_compile_options(qt6ct-common PRIVATE "$<$<CONFIG:Release>:/Zi>")
|
||||
target_compile_options(qt6ct-widgets PRIVATE "$<$<CONFIG:Release>:/Zi>")
|
||||
else()
|
||||
target_compile_options(qt6ct-common PRIVATE "$<$<CONFIG:Release>:-g>")
|
||||
target_compile_options(qt6ct-widgets PRIVATE "$<$<CONFIG:Release>:-g>")
|
||||
endif()
|
||||
|
||||
target_include_directories( qt6ct-common INTERFACE qt6ct/src )
|
||||
target_include_directories( qt6ct-widgets INTERFACE qt6ct/src )
|
||||
|
|
|
|||
|
|
@ -703,6 +703,7 @@ target_link_libraries(scwx-qt PUBLIC Qt${QT_VERSION_MAJOR}::Widgets
|
|||
glm::glm
|
||||
imgui
|
||||
qt6ct-common
|
||||
qt6ct-widgets
|
||||
SQLite::SQLite3
|
||||
wxdata)
|
||||
|
||||
|
|
|
|||
|
|
@ -45,9 +45,15 @@
|
|||
#include <QGeoPositionInfo>
|
||||
#include <QPushButton>
|
||||
#include <QStandardItemModel>
|
||||
#include <QStandardPaths>
|
||||
#include <QToolButton>
|
||||
#include <utility>
|
||||
|
||||
#define QT6CT_LIBRARY
|
||||
#include <qt6ct-common/qt6ct.h>
|
||||
#include <qt6ct/paletteeditdialog.h>
|
||||
#undef QT6CT_LIBRARY
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
|
|
@ -578,31 +584,49 @@ void SettingsDialogImpl::SetupGeneralTab()
|
|||
self_,
|
||||
[this]()
|
||||
{
|
||||
static const std::string themeFilter = "Qt6Ct Theme File (*.conf)";
|
||||
static const std::string allFilter = "All Files (*)";
|
||||
const settings::GeneralSettings& generalSettings =
|
||||
settings::GeneralSettings::Instance();
|
||||
QString file = generalSettings.theme_file().GetStagedOrValue().c_str();
|
||||
|
||||
QFileDialog* dialog = new QFileDialog(self_);
|
||||
if (file.isEmpty())
|
||||
{
|
||||
const QString appDataPath {QStandardPaths::writableLocation(
|
||||
QStandardPaths::AppLocalDataLocation)};
|
||||
file = appDataPath + "/theme.conf";
|
||||
self_->ui->themeFileLineEdit->setText(file);
|
||||
// setText does not emit the textEdited signal
|
||||
Q_EMIT self_->ui->themeFileLineEdit->textEdited(file);
|
||||
}
|
||||
|
||||
dialog->setFileMode(QFileDialog::ExistingFile);
|
||||
const QPalette palette =
|
||||
Qt6CT::loadColorScheme(file, QApplication::palette());
|
||||
QStyle* style = QApplication::style();
|
||||
|
||||
dialog->setNameFilters(
|
||||
{QObject::tr(themeFilter.c_str()), QObject::tr(allFilter.c_str())});
|
||||
// WA_DeleteOnClose manages memory
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
||||
auto* dialog = new PaletteEditDialog(palette, style, self_);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
QObject::connect(
|
||||
dialog,
|
||||
&QFileDialog::fileSelected,
|
||||
&QDialog::accepted,
|
||||
self_,
|
||||
[this](const QString& file)
|
||||
[dialog]()
|
||||
{
|
||||
QString path = QDir::toNativeSeparators(file);
|
||||
logger_->info("Selected theme file: {}", path.toStdString());
|
||||
self_->ui->themeFileLineEdit->setText(path);
|
||||
const QPalette palette = dialog->selectedPalette();
|
||||
const settings::GeneralSettings& generalSettings =
|
||||
settings::GeneralSettings::Instance();
|
||||
const QString file =
|
||||
generalSettings.theme_file().GetStagedOrValue().c_str();
|
||||
Qt6CT::createColorScheme(file, palette);
|
||||
|
||||
// setText does not emit the textEdited signal
|
||||
Q_EMIT self_->ui->themeFileLineEdit->textEdited(path);
|
||||
auto uiStyle = scwx::qt::types::GetUiStyle(
|
||||
generalSettings.theme().GetValue());
|
||||
if (uiStyle == scwx::qt::types::UiStyle::FusionCustom)
|
||||
{
|
||||
QApplication::setPalette(palette);
|
||||
}
|
||||
});
|
||||
|
||||
dialog->open();
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue