Skip to content

Commit

Permalink
Use cmake configure file (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
AIIX authored Mar 23, 2022
1 parent e399a3c commit 86bc3a8
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 8 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions theme/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define KIRIGAMIPLASMAFACTORY_H

#include <Kirigami/KirigamiPluginFactory>

#include <QObject>
#include <QPluginLoader>

Expand Down
21 changes: 21 additions & 0 deletions theme/kirigamiplasmafactory_kf_legacy.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef KIRIGAMIPLASMAFACTORY_H
#define KIRIGAMIPLASMAFACTORY_H

#include <Kirigami2/KirigamiPluginFactory>
#include <QObject>
#include <QPluginLoader>

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
35 changes: 35 additions & 0 deletions theme/ovostheme_kf.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef OVOSTHEME_H
#define OVOSTHEME_H

#include <Kirigami/KirigamiPluginFactory>
#include <Kirigami/PlatformTheme>

#include <QObject>
#include <QFileSystemWatcher>

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<QWindow> m_window;

QFileSystemWatcher *m_fileWatcher;
};

#endif
5 changes: 0 additions & 5 deletions theme/ovostheme.h → theme/ovostheme_kf_legacy.h.in
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
#ifndef OVOSTHEME_H
#define OVOSTHEME_H

#ifdef KirigamiLegacy
#include <Kirigami2/KirigamiPluginFactory>
#include <Kirigami2/PlatformTheme>
#else
#include <Kirigami/KirigamiPluginFactory>
#include <Kirigami/PlatformTheme>
#endif

#include <QObject>
#include <QFileSystemWatcher>
Expand Down

0 comments on commit 86bc3a8

Please sign in to comment.