diff --git a/CMakeLists.txt b/CMakeLists.txt index a11b96e..e251099 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,9 @@ # Set minimum CMake version (required for CMake 3.0 or later) -cmake_minimum_required(VERSION 3.16.0) +cmake_minimum_required(VERSION 3.15.0) set(QT_MIN_VERSION "5.9.0") set(KF5_MIN_VERSION "5.50.0") +set(KIRIGAMI_LEGACY OFF) PROJECT(mycroft-gui) @@ -46,9 +47,9 @@ find_package(KF5DBusAddons ${KF5_MIN_VERSION} REQUIRED) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS I18n Kirigami2 GuiAddons CoreAddons Config ConfigWidgets IconThemes) if(KF5Kirigami2_VERSION VERSION_LESS 5.91.0) - SET(KirigamiLegacy TRUE) + set(KIRIGAMI_LEGACY ON) else() - SET(KirigamiLegacy FALSE) + set(KIRIGAMI_LEGACY OFF) endif() add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0) diff --git a/theme/CMakeLists.txt b/theme/CMakeLists.txt index 449285c..564a7af 100644 --- a/theme/CMakeLists.txt +++ b/theme/CMakeLists.txt @@ -3,6 +3,14 @@ set(OpenVoiceStyle_SRCS kirigamiplasmafactory.cpp ) +if(KIRIGAMI_LEGACY) + configure_file(kirigamiplasmafactory_kf_legacy.h.in ${CMAKE_CURRENT_BINARY_DIR}/kirigamiplasmafactory.h) + configure_file(ovostheme_kf_legacy.h.in ${CMAKE_CURRENT_BINARY_DIR}/ovostheme.h) +else() + configure_file(kirigamiplasmafactory_kf.h.in ${CMAKE_CURRENT_BINARY_DIR}/kirigamiplasmafactory.h) + configure_file(ovostheme_kf.h.in ${CMAKE_CURRENT_BINARY_DIR}/ovostheme.h) +endif() + kcoreaddons_add_plugin(OpenVoiceStyle SOURCES ${OpenVoiceStyle_SRCS} INSTALL_NAMESPACE "kf5/kirigami" JSON ovostheme.json) target_link_libraries(OpenVoiceStyle diff --git a/theme/kirigamiplasmafactory.h b/theme/kirigamiplasmafactory_kf.h.in similarity index 99% rename from theme/kirigamiplasmafactory.h rename to theme/kirigamiplasmafactory_kf.h.in index a708d6d..b6defac 100644 --- a/theme/kirigamiplasmafactory.h +++ b/theme/kirigamiplasmafactory_kf.h.in @@ -2,6 +2,7 @@ #define KIRIGAMIPLASMAFACTORY_H #include + #include #include diff --git a/theme/kirigamiplasmafactory_kf_legacy.h.in b/theme/kirigamiplasmafactory_kf_legacy.h.in new file mode 100644 index 0000000..51973bc --- /dev/null +++ b/theme/kirigamiplasmafactory_kf_legacy.h.in @@ -0,0 +1,21 @@ +#ifndef KIRIGAMIPLASMAFACTORY_H +#define KIRIGAMIPLASMAFACTORY_H + +#include +#include +#include + +class OpenVoiceStyleFactory : public Kirigami::KirigamiPluginFactory +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.ovos.KirigamiPluginFactory") + Q_INTERFACES(Kirigami::KirigamiPluginFactory) + +public: + explicit OpenVoiceStyleFactory(QObject *parent = nullptr); + ~OpenVoiceStyleFactory() override; + + Kirigami::PlatformTheme *createPlatformTheme(QObject *parent) override; +}; + +#endif // KIRIGAMIPLASMAFACTORY_H diff --git a/theme/ovostheme_kf.h.in b/theme/ovostheme_kf.h.in new file mode 100644 index 0000000..57ddc85 --- /dev/null +++ b/theme/ovostheme_kf.h.in @@ -0,0 +1,35 @@ +#ifndef OVOSTHEME_H +#define OVOSTHEME_H + +#include +#include + +#include +#include + +class OvosTheme : public Kirigami::PlatformTheme +{ + Q_OBJECT + QPalette lightPalette; + +public: + explicit OvosTheme(QObject *parent = nullptr); + void syncColors(); + void syncWindow(); + void readConfig(); + void syncConfigChanges(); + void setupFileWatch(); + +protected: + bool event(QEvent *event) override; + +private: + QColor m_primaryColor; + QColor m_secondaryColor; + QColor m_textColor; + QPointer m_window; + + QFileSystemWatcher *m_fileWatcher; +}; + +#endif diff --git a/theme/ovostheme.h b/theme/ovostheme_kf_legacy.h.in similarity index 85% rename from theme/ovostheme.h rename to theme/ovostheme_kf_legacy.h.in index 612e884..25945e4 100644 --- a/theme/ovostheme.h +++ b/theme/ovostheme_kf_legacy.h.in @@ -1,13 +1,8 @@ #ifndef OVOSTHEME_H #define OVOSTHEME_H -#ifdef KirigamiLegacy #include #include -#else -#include -#include -#endif #include #include