Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix kirigami version target and use configure file #5

Merged
merged 1 commit into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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