Skip to content

Commit

Permalink
Merge pull request #284 from dpaulat/feature/qt-6.8.0
Browse files Browse the repository at this point in the history
Bump dependency Qt to 6.8.0
  • Loading branch information
dpaulat authored Oct 17, 2024
2 parents 620a0db + 9ee6e2e commit 72a1697
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 45 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ jobs:
compiler: msvc
msvc_arch: x64
msvc_version: 2022
qt_version: 6.7.2
qt_arch_aqt: win64_msvc2019_64
qt_arch_dir: msvc2019_64
qt_version: 6.8.0
qt_arch_aqt: win64_msvc2022_64
qt_arch_dir: msvc2022_64
qt_modules: qtimageformats qtmultimedia qtpositioning qtserialport
qt_tools: ''
conan_arch: x86_64
Expand All @@ -46,7 +46,7 @@ jobs:
env_cc: gcc-11
env_cxx: g++-11
compiler: gcc
qt_version: 6.7.2
qt_version: 6.8.0
qt_arch_aqt: linux_gcc_64
qt_arch_dir: gcc_64
qt_modules: qtimageformats qtmultimedia qtpositioning qtserialport
Expand All @@ -64,7 +64,7 @@ jobs:
env_cc: clang-17
env_cxx: clang++-17
compiler: clang
qt_version: 6.7.2
qt_version: 6.8.0
qt_arch_aqt: linux_gcc_64
qt_arch_dir: gcc_64
qt_modules: qtimageformats qtmultimedia qtpositioning qtserialport
Expand Down
11 changes: 11 additions & 0 deletions external/maplibre-native-qt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ if (MSVC)
target_link_options(MLNQtCore PRIVATE "$<$<CONFIG:Release>:/DEBUG>")
target_link_options(MLNQtCore PRIVATE "$<$<CONFIG:Release>:/OPT:REF>")
target_link_options(MLNQtCore PRIVATE "$<$<CONFIG:Release>:/OPT:ICF>")

# Enable multi-processor compilation
target_compile_options(MLNQtCore PRIVATE "/MP")
target_compile_options(mbgl-core PRIVATE "/MP")
target_compile_options(mbgl-vendor-csscolorparser PRIVATE "/MP")
target_compile_options(mbgl-vendor-nunicode PRIVATE "/MP")
target_compile_options(mbgl-vendor-parsedate PRIVATE "/MP")

if (TARGET mbgl-vendor-sqlite)
target_compile_options(mbgl-vendor-sqlite PRIVATE "/MP")
endif()
else()
target_compile_options(mbgl-core PRIVATE "$<$<CONFIG:Release>:-g>")
target_compile_options(MLNQtCore PRIVATE "$<$<CONFIG:Release>:-g>")
Expand Down
36 changes: 24 additions & 12 deletions scwx-qt/source/scwx/qt/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
#include <fmt/format.h>
#include <QApplication>
#include <QStandardPaths>
#include <QStyleHints>
#include <QTranslator>

static const std::string logPrefix_ = "scwx::main";
static const auto logger_ = scwx::util::Logger::Create(logPrefix_);

static void ConfigureTheme(const std::vector<std::string>& args);
static void OverrideDefaultStyle(const std::vector<std::string>& args);

int main(int argc, char* argv[])
Expand Down Expand Up @@ -103,18 +105,7 @@ int main(int argc, char* argv[])
scwx::qt::manager::ResourceManager::Initialize();

// Theme
auto uiStyle = scwx::qt::types::GetUiStyle(
scwx::qt::settings::GeneralSettings::Instance().theme().GetValue());

if (uiStyle == scwx::qt::types::UiStyle::Default)
{
OverrideDefaultStyle(args);
}
else
{
QApplication::setStyle(
QString::fromStdString(scwx::qt::types::GetUiStyleName(uiStyle)));
}
ConfigureTheme(args);

// Run initial setup if required
if (scwx::qt::ui::setup::SetupWizard::IsSetupRequired())
Expand Down Expand Up @@ -152,6 +143,27 @@ int main(int argc, char* argv[])
return result;
}

static void ConfigureTheme(const std::vector<std::string>& args)
{
auto& generalSettings = scwx::qt::settings::GeneralSettings::Instance();

auto uiStyle =
scwx::qt::types::GetUiStyle(generalSettings.theme().GetValue());
auto qtColorScheme = scwx::qt::types::GetQtColorScheme(uiStyle);

if (uiStyle == scwx::qt::types::UiStyle::Default)
{
OverrideDefaultStyle(args);
}
else
{
QApplication::setStyle(
QString::fromStdString(scwx::qt::types::GetQtStyleName(uiStyle)));
}

QGuiApplication::styleHints()->setColorScheme(qtColorScheme);
}

static void
OverrideDefaultStyle([[maybe_unused]] const std::vector<std::string>& args)
{
Expand Down
4 changes: 2 additions & 2 deletions scwx-qt/source/scwx/qt/main/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1080,9 +1080,9 @@ void MainWindowImpl::ConnectOtherSignals()
}
});
connect(mainWindow_->ui->trackLocationCheckBox,
&QCheckBox::stateChanged,
&QCheckBox::checkStateChanged,
mainWindow_,
[this](int state)
[this](Qt::CheckState state)
{
bool trackingEnabled = (state == Qt::CheckState::Checked);

Expand Down
41 changes: 26 additions & 15 deletions scwx-qt/source/scwx/qt/types/qt_types.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <scwx/qt/types/qt_types.hpp>
#include <scwx/util/enum.hpp>

#include <boost/algorithm/string.hpp>

Expand All @@ -9,27 +10,37 @@ namespace qt
namespace types
{

static const std::unordered_map<UiStyle, std::string> qtStyleName_ {
{UiStyle::Default, "Default"},
{UiStyle::Fusion, "Fusion"},
{UiStyle::FusionLight, "Fusion"},
{UiStyle::FusionDark, "Fusion"},
{UiStyle::Unknown, "?"}};

static const std::unordered_map<UiStyle, std::string> uiStyleName_ {
{UiStyle::Default, "Default"},
{UiStyle::Fusion, "Fusion"},
{UiStyle::FusionLight, "Fusion Light"},
{UiStyle::FusionDark, "Fusion Dark"},
{UiStyle::Unknown, "?"}};

UiStyle GetUiStyle(const std::string& name)
static const std::unordered_map<UiStyle, Qt::ColorScheme> qtColorSchemeMap_ {
{UiStyle::Default, Qt::ColorScheme::Unknown},
{UiStyle::Fusion, Qt::ColorScheme::Unknown},
{UiStyle::FusionLight, Qt::ColorScheme::Light},
{UiStyle::FusionDark, Qt::ColorScheme::Dark},
{UiStyle::Unknown, Qt::ColorScheme::Unknown}};

SCWX_GET_ENUM(UiStyle, GetUiStyle, uiStyleName_)

Qt::ColorScheme GetQtColorScheme(UiStyle uiStyle)
{
return qtColorSchemeMap_.at(uiStyle);
}

std::string GetQtStyleName(UiStyle uiStyle)
{
auto result =
std::find_if(uiStyleName_.cbegin(),
uiStyleName_.cend(),
[&](const std::pair<UiStyle, std::string>& pair) -> bool
{ return boost::iequals(pair.second, name); });

if (result != uiStyleName_.cend())
{
return result->first;
}
else
{
return UiStyle::Unknown;
}
return qtStyleName_.at(uiStyle);
}

std::string GetUiStyleName(UiStyle uiStyle)
Expand Down
11 changes: 8 additions & 3 deletions scwx-qt/source/scwx/qt/types/qt_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,22 @@ enum ItemDataRole
RawDataRole
};

enum UiStyle
enum class UiStyle
{
Default,
Fusion,
FusionLight,
FusionDark,
Unknown
};
typedef scwx::util::Iterator<UiStyle, UiStyle::Default, UiStyle::Fusion>
typedef scwx::util::Iterator<UiStyle, UiStyle::Default, UiStyle::FusionDark>
UiStyleIterator;

Qt::ColorScheme GetQtColorScheme(UiStyle uiStyle);
std::string GetQtStyleName(UiStyle uiStyle);

UiStyle GetUiStyle(const std::string& name);
std::string GetUiStyleName(UiStyle alertAction);
std::string GetUiStyleName(UiStyle uiStyle);

} // namespace types
} // namespace qt
Expand Down
5 changes: 3 additions & 2 deletions setup-debug.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ call tools\setup-common.bat

set build_dir=build-debug
set build_type=Debug
set qt_version=6.7.2
set qt_version=6.8.0
set qt_arch=msvc2022_64

mkdir %build_dir%
cmake -B %build_dir% -S . ^
-DCMAKE_BUILD_TYPE=%build_type% ^
-DCMAKE_CONFIGURATION_TYPES=%build_type% ^
-DCMAKE_PREFIX_PATH=C:/Qt/%qt_version%/msvc2019_64
-DCMAKE_PREFIX_PATH=C:/Qt/%qt_version%/%qt_arch%
pause
5 changes: 3 additions & 2 deletions setup-debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

build_dir=${1:-build-debug}
build_type=Debug
qt_version=6.7.2
qt_version=6.8.0
qt_arch=gcc_64
script_dir="$(dirname "$(readlink -f "$0")")"

mkdir -p ${build_dir}
cmake -B ${build_dir} -S . \
-DCMAKE_BUILD_TYPE=${build_type} \
-DCMAKE_CONFIGURATION_TYPES=${build_type} \
-DCMAKE_INSTALL_PREFIX=${build_dir}/${build_type}/supercell-wx \
-DCMAKE_PREFIX_PATH=/opt/Qt/${qt_version}/gcc_64 \
-DCMAKE_PREFIX_PATH=/opt/Qt/${qt_version}/${qt_arch} \
-G Ninja
5 changes: 3 additions & 2 deletions setup-release.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ call tools\setup-common.bat

set build_dir=build-release
set build_type=Release
set qt_version=6.7.2
set qt_version=6.8.0
set qt_arch=msvc2022_64

mkdir %build_dir%
cmake -B %build_dir% -S . ^
-DCMAKE_BUILD_TYPE=%build_type% ^
-DCMAKE_CONFIGURATION_TYPES=%build_type% ^
-DCMAKE_PREFIX_PATH=C:/Qt/%qt_version%/msvc2019_64
-DCMAKE_PREFIX_PATH=C:/Qt/%qt_version%/%qt_arch%
pause
5 changes: 3 additions & 2 deletions setup-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

build_dir=${1:-build-release}
build_type=Release
qt_version=6.7.2
qt_version=6.8.0
qt_arch=gcc_64
script_dir="$(dirname "$(readlink -f "$0")")"

mkdir -p ${build_dir}
cmake -B ${build_dir} -S . \
-DCMAKE_BUILD_TYPE=${build_type} \
-DCMAKE_CONFIGURATION_TYPES=${build_type} \
-DCMAKE_INSTALL_PREFIX=${build_dir}/${build_type}/supercell-wx \
-DCMAKE_PREFIX_PATH=/opt/Qt/${qt_version}/gcc_64 \
-DCMAKE_PREFIX_PATH=/opt/Qt/${qt_version}/${qt_arch} \
-G Ninja

0 comments on commit 72a1697

Please sign in to comment.