Skip to content

Commit

Permalink
feat(Qt): Use qlementine style
Browse files Browse the repository at this point in the history
  • Loading branch information
nlogozzo committed Feb 19, 2025
1 parent a92cd96 commit 05406ed
Show file tree
Hide file tree
Showing 17 changed files with 311 additions and 98 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ jobs:
uses: johnwason/vcpkg-action@v6
id: vcpkg
with:
pkgs: libnick qtbase qtsvg qttools
pkgs: libnick qtbase qtsvg qttools qlementine
triplet: x64-windows
revision: 74ec888e385d189b42d6b398d0bbaa6f1b1d3b0e
revision: f6df7351579d2505357de5876f554e949f953ecc
token: ${{ secrets.GITHUB_TOKEN }}
github-binarycache: true
- name: "Build"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ A C++20 compiler is also required to build Application.
1. Set the `VCPKG_ROOT` environment variable to the path of your vcpkg installation's root directory.
#### Windows
1. Set the `VCPKG_DEFAULT_TRIPLET` environment variable to `x64-windows`
1. Run `vcpkg install libnick qtbase qtsvg qttools`
1. Run `vcpkg install libnick qtbase qtsvg qttools qlementine`
#### Linux (GNOME)
1. Set the `VCPKG_DEFAULT_TRIPLET` environment variable to `x64-linux`
1. Run `vcpkg install libnick libxmlpp`
#### Linux (Qt)
1. Set the `VCPKG_DEFAULT_TRIPLET` environment variable to `x64-linux`
1. Run `vcpkg install libnick qtbase qtsvg qttools`
1. Run `vcpkg install libnick qtbase qtsvg qttools qlementine`

### Building
1. First, clone/download the repo.
Expand Down
16 changes: 16 additions & 0 deletions flatpak/org.nickvision.application.qt.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,22 @@
}
]
},
{
"name": "qlementine",
"buildsystem": "cmake-ninja",
"builddir": true,
"config-opts": [
"-DQLEMENTINE_SANDBOX=OFF",
"-DQLEMENTINE_SHOWCASE=OFF"
],
"sources": [
{
"type": "git",
"url": "https://github.com/oclero/qlementine",
"tag": "v1.0.1"
}
]
},
{
"name": "org.nickvision.application",
"buildsystem": "cmake-ninja",
Expand Down
5 changes: 3 additions & 2 deletions org.nickvision.application.qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set(STARTUP_NOTIFY false)
add_definitions(-DQT_NO_KEYWORDS)

find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Svg)
find_package(Qlementine CONFIG REQUIRED)
qt_standard_project_setup()

qt_add_executable(${OUTPUT_NAME}
Expand All @@ -27,10 +28,10 @@ qt_add_executable(${OUTPUT_NAME}
"src/views/settingsdialog.cpp"
"src/application.cpp"
"src/main.cpp"
"${OUTPUT_NAME}.qrc"
"resources/${OUTPUT_NAME}.qrc"
"../resources/windows/${PROJECT_NAME}.rc")
target_include_directories(${OUTPUT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(${OUTPUT_NAME} PRIVATE libapplication Qt6::Core Qt6::Gui Qt6::Widgets Qt6::Svg)
target_link_libraries(${OUTPUT_NAME} PRIVATE libapplication Qt6::Core Qt6::Gui Qt6::Widgets Qt6::Svg qlementine::qlementine)
if(WIN32)
set_target_properties(${OUTPUT_NAME} PROPERTIES WIN32_EXECUTABLE ON)
endif()
Expand Down
4 changes: 4 additions & 0 deletions org.nickvision.application.qt/include/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <memory>
#include <QApplication>
#include <oclero/qlementine/style/QlementineStyle.hpp>
#include <oclero/qlementine/style/ThemeManager.hpp>
#include "controllers/mainwindowcontroller.h"
#include "views/mainwindow.h"

Expand Down Expand Up @@ -32,6 +34,8 @@ namespace Nickvision::Application::Qt
private:
std::shared_ptr<Shared::Controllers::MainWindowController> m_controller;
std::shared_ptr<Views::MainWindow> m_mainWindow;
oclero::qlementine::QlementineStyle* m_style;
oclero::qlementine::ThemeManager* m_themeManager;
};
}

Expand Down
5 changes: 4 additions & 1 deletion org.nickvision.application.qt/include/views/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QMainWindow>
#include <oclero/qlementine/style/ThemeManager.hpp>
#include "controllers/mainwindowcontroller.h"
#include "controls/infobar.h"

Expand All @@ -24,9 +25,10 @@ namespace Nickvision::Application::Qt::Views
/**
* @brief Constructs a MainWindow.
* @param controller The MainWindowController
* @param themeManager The ThemeManager
* @param parent The parent widget
*/
MainWindow(const std::shared_ptr<Shared::Controllers::MainWindowController>& controller, QWidget* parent = nullptr);
MainWindow(const std::shared_ptr<Shared::Controllers::MainWindowController>& controller, oclero::qlementine::ThemeManager* themeManager, QWidget* parent = nullptr);
/**
* @brief Destructs a MainWindow.
*/
Expand Down Expand Up @@ -112,6 +114,7 @@ namespace Nickvision::Application::Qt::Views
Ui::MainWindow* m_ui;
Controls::InfoBar* m_infoBar;
std::shared_ptr<Shared::Controllers::MainWindowController> m_controller;
oclero::qlementine::ThemeManager* m_themeManager;
};
}

Expand Down
5 changes: 4 additions & 1 deletion org.nickvision.application.qt/include/views/settingsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <memory>
#include <QCloseEvent>
#include <QDialog>
#include <oclero/qlementine/style/ThemeManager.hpp>
#include "controllers/preferencesviewcontroller.h"

namespace Ui { class SettingsDialog; }
Expand All @@ -19,9 +20,10 @@ namespace Nickvision::Application::Qt::Views
/**
* @brief Constructs a SettingsDialog.
* @param controller The PreferencesViewController
* @param themeManager The ThemeManager
* @param parent The parent widget
*/
SettingsDialog(const std::shared_ptr<Shared::Controllers::PreferencesViewController>& controller, QWidget* parent = nullptr);
SettingsDialog(const std::shared_ptr<Shared::Controllers::PreferencesViewController>& controller, oclero::qlementine::ThemeManager* themeManager, QWidget* parent = nullptr);
/**
* @brief Destructs a SettingsDialog.
*/
Expand All @@ -47,6 +49,7 @@ namespace Nickvision::Application::Qt::Views
private:
Ui::SettingsDialog* m_ui;
std::shared_ptr<Shared::Controllers::PreferencesViewController> m_controller;
oclero::qlementine::ThemeManager* m_themeManager;
};
}

Expand Down

This file was deleted.

91 changes: 91 additions & 0 deletions org.nickvision.application.qt/resources/dark-theme.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"meta": {
"author": "Olivier Cléro",
"name": "Dark",
"version": "1.5.0"
},

"backgroundColorMain1": "#1f2127",
"backgroundColorMain2": "#282b33",
"backgroundColorMain3": "#333848",
"backgroundColorMain4": "#333848",

"backgroundColorWorkspace": "#17181c",
"backgroundColorTabBar": "#1e2026",

"borderColor": "#40485a",
"borderColorHovered": "#4a5670",
"borderColorPressed": "#5b6e98",
"borderColorDisabled": "#2f343f",

"focusColor": "#3097ff6a",

"neutralColor": "#4c5368",
"neutralColorHovered": "#535c78",
"neutralColorPressed": "#5b6688",
"neutralColorDisabled": "#2d313b",

"primaryColor": "#5086ff",
"primaryColorHovered": "#6494ff",
"primaryColorPressed": "#7aa3ff",
"primaryColorDisabled": "#2c3448",

"primaryAlternativeColor": "#3161f8",
"primaryAlternativeColorHovered": "#4571fe",
"primaryAlternativeColorPressed": "#5a82ff",
"primaryAlternativeColorDisabled": "#293346",

"primaryColorForeground": "#ffffff",
"primaryColorForegroundHovered": "#ffffff",
"primaryColorForegroundPressed": "#ffffff",
"primaryColorForegroundDisabled": "#455170",

"secondaryColor": "#ffffff",
"secondaryColorHovered": "#d5d5d5",
"secondaryColorPressed": "#ebebeb",
"secondaryColorDisabled": "#ffffff33",

"secondaryAlternativeColor": "#67718d",
"secondaryAlternativeColorHovered": "#8b93ab",
"secondaryAlternativeColorPressed": "#9ca4bc",
"secondaryAlternativeColorDisabled": "#575f763f",

"secondaryColorForeground": "#282b33",
"secondaryColorForegroundHovered": "#282b33",
"secondaryColorForegroundPressed": "#282b33",
"secondaryColorForegroundDisabled": "#282b333f",

"semiTransparentColor1": "#b7c9ff18",
"semiTransparentColor2": "#b7c9ff23",
"semiTransparentColor3": "#b7c9ff28",
"semiTransparentColor4": "#b7c9ff2d",

"shadowColor1": "#00000066",
"shadowColor2": "#000000bb",
"shadowColor3": "#000000ff",

"statusColorForeground": "#ffffff",
"statusColorForegroundHovered": "#ffffff",
"statusColorForegroundPressed": "#ffffff",
"statusColorForegroundDisabled": "#ffffff26",

"statusColorError": "#e96b72",
"statusColorErrorHovered": "#f47c83",
"statusColorErrorPressed": "#ff9197",
"statusColorErrorDisabled": "#3f333b",

"statusColorInfo": "#1ba8d5",
"statusColorInfoHovered": "#1eb5e5",
"statusColorInfoPressed": "#29c0f0",
"statusColorInfoDisabled": "#283345",

"statusColorSuccess": "#2bb5a0",
"statusColorSuccessHovered": "#3cbfab",
"statusColorSuccessPressed": "#4ecdb9",
"statusColorSuccessDisabled": "#28363c",

"statusColorWarning": "#fbc064",
"statusColorWarningHovered": "#ffcf6c",
"statusColorWarningPressed": "#ffd880",
"statusColorWarningDisabled": "#393737"
}
91 changes: 91 additions & 0 deletions org.nickvision.application.qt/resources/light-theme.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"meta": {
"author": "Olivier Cléro",
"name": "Light",
"version": "1.5.0"
},

"backgroundColorMain1": "#ffffff",
"backgroundColorMain2": "#f3f3f3",
"backgroundColorMain3": "#e3e3e3",
"backgroundColorMain4": "#dfdfdf",

"backgroundColorWorkspace": "#b7b7b7",
"backgroundColorTabBar": "#dfdfdf",

"borderColor": "#d3d3d3",
"borderColorDisabled": "#e9e9e9",
"borderColorHovered": "#b3b3b3",
"borderColorPressed": "#a3a3a3",

"focusColor": "#40a9ff66",

"neutralColor": "#d1d1d1",
"neutralColorHovered": "#d3d3d3",
"neutralColorPressed": "#d5d5d5",
"neutralColorDisabled": "#eeeeee",

"primaryColor": "#1890ff",
"primaryColorHovered": "#2c9dff",
"primaryColorPressed": "#40a9ff",
"primaryColorDisabled": "#d1e9ff",

"primaryAlternativeColor": "#106ef9",
"primaryAlternativeColorDisabled": "#a9d6ff",
"primaryAlternativeColorHovered": "#107bfd",
"primaryAlternativeColorPressed": "#108bfd",

"primaryColorForeground": "#ffffff",
"primaryColorForegroundDisabled": "#ecf6ff",
"primaryColorForegroundHovered": "#ffffff",
"primaryColorForegroundPressed": "#ffffff",

"secondaryColor": "#404040",
"secondaryColorHovered": "#333333",
"secondaryColorPressed": "#262626",
"secondaryColorDisabled": "#d4d4d4",

"secondaryAlternativeColor": "#909090",
"secondaryAlternativeColorDisabled": "#c3c3c3",
"secondaryAlternativeColorHovered": "#747474",
"secondaryAlternativeColorPressed": "#828282",

"secondaryColorForeground": "#ffffff",
"secondaryColorForegroundDisabled": "#ededed",
"secondaryColorForegroundHovered": "#ffffff",
"secondaryColorForegroundPressed": "#ffffff",

"semiTransparentColor1": "#0000000a",
"semiTransparentColor2": "#00000019",
"semiTransparentColor3": "#00000021",
"semiTransparentColor4": "#00000028",

"shadowColor1": "#00000020",
"shadowColor2": "#00000040",
"shadowColor3": "#00000060",

"statusColorError": "#e96b72",
"statusColorErrorHovered": "#f47c83",
"statusColorErrorPressed": "#ff9197",
"statusColorErrorDisabled": "#f9dadc",

"statusColorForeground": "#ffffff",
"statusColorForegroundHovered": "#ffffff",
"statusColorForegroundPressed": "#ffffff",
"statusColorForegroundDisabled": "#ffffff99",

"statusColorInfo": "#1ba8d5",
"statusColorInfoHovered": "#1eb5e5",
"statusColorInfoPressed": "#29c0f0",
"statusColorInfoDisabled": "#c7eaf5",

"statusColorSuccess": "#2bb5a0",
"statusColorSuccessHovered": "#3cbfab",
"statusColorSuccessPressed": "#4ecdb9",
"statusColorSuccessDisabled": "#d5f0ec",

"statusColorWarning": "#fbc064",
"statusColorWarningHovered": "#ffcf6c",
"statusColorWarningPressed": "#ffd880",
"statusColorWarningDisabled": "#feefd8"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<RCC>
<qresource>
<file>light-theme.json</file>
<file>dark-theme.json</file>
<file>../../resources/org.nickvision.application.ico</file>
<file>../../resources/org.nickvision.application.svg</file>
<file>../../resources/org.nickvision.application-devel.svg</file>
</qresource>
</RCC>
18 changes: 10 additions & 8 deletions org.nickvision.application.qt/src/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ namespace Nickvision::Application::Qt
Application::Application(int argc, char* argv[])
: QApplication{ argc, argv },
m_controller{ std::make_shared<MainWindowController>(std::vector<std::string>(argv, argv + argc)) },
m_mainWindow{ nullptr }
m_mainWindow{ nullptr },
m_style{ new oclero::qlementine::QlementineStyle(this) },
m_themeManager{ new oclero::qlementine::ThemeManager(m_style) }
{
//Set Fusion style on Windows 10 for dark mode support
if (QSysInfo::productType() == "windows" && QSysInfo::productVersion() == "10")
{
QApplication::setStyle("Fusion");
}
QApplication::setStyle(m_style);
m_themeManager->loadDirectory(":/");
}

int Application::exec()
Expand All @@ -24,15 +23,18 @@ namespace Nickvision::Application::Qt
{
case Theme::Light:
QApplication::styleHints()->setColorScheme(::Qt::ColorScheme::Light);
m_themeManager->setCurrentTheme("Light");
break;
case Theme::Dark:
QApplication::styleHints()->setColorScheme(::Qt::ColorScheme::Dark);
m_themeManager->setCurrentTheme("Dark");
break;
default:
QApplication::styleHints()->setColorScheme(::Qt::ColorScheme::Unknown);
QApplication::styleHints()->unsetColorScheme();
m_themeManager->setCurrentTheme(QApplication::styleHints()->colorScheme() == ::Qt::ColorScheme::Light ? "Light" : "Dark");
break;
}
m_mainWindow = std::make_shared<Views::MainWindow>(m_controller);
m_mainWindow = std::make_shared<Views::MainWindow>(m_controller, m_themeManager);
m_mainWindow->show();
return QApplication::exec();
}
Expand Down
Loading

0 comments on commit 05406ed

Please sign in to comment.