diff --git a/CMakeLists.txt b/CMakeLists.txt index e4973186f2a99856e7654638d880f52397e22c35..33ac19e58ac8fac9852540ec361211f4faa70af2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,7 @@ endif() set(KDECORATION2_INCLUDEDIR "${KDE_INSTALL_INCLUDEDIR}/KDecoration2") find_package(KF5I18n ${KF5_MIN_VERSION} CONFIG REQUIRED) +find_package(KF5CoreAddons ${KF5_MIN_VERSION} CONFIG REQUIRED) add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00) add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x054200) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cd8de05f234e5544c843f0af1bef234459767e88..dbc268ccb711ad0c1d870c9ebfe90e85beeb82f9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,6 +9,7 @@ set(libkdecoration2_SRCS decorationbuttongroup.cpp decorationsettings.cpp decorationshadow.cpp + decorationthemeprovider.cpp ) add_library(kdecorations2 SHARED ${libkdecoration2_SRCS}) @@ -28,6 +29,7 @@ target_link_libraries(kdecorations2 PRIVATE kdecorations2private KF5::I18n + KF5::CoreAddons ) target_include_directories(kdecorations2 INTERFACE "$" ) @@ -45,6 +47,7 @@ ecm_generate_headers(KDecoration2_CamelCase_HEADERS DecorationButtonGroup DecorationSettings DecorationShadow + DecorationThemeProvider PREFIX KDecoration2 REQUIRED_HEADERS KDecoration2_HEADERS diff --git a/src/decorationthemeprovider.cpp b/src/decorationthemeprovider.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5a470e8413578c002afb75e3c175e538101b12e0 --- /dev/null +++ b/src/decorationthemeprovider.cpp @@ -0,0 +1,89 @@ +/* + * SPDX-FileCopyrightText: 2021 Alexander Lohnau + * + * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL + */ + +#include "decorationthemeprovider.h" + +#include + +class DecorationThemeMetaDataPrivate : public QSharedData +{ +public: + QString visibleName; + QString themeName; + QString pluginId; + bool hasConfig = false; + KDecoration2::BorderSize borderSize = KDecoration2::BorderSize::Normal; +}; + +using namespace KDecoration2; + +DecorationThemeMetaData::DecorationThemeMetaData() + : d(new DecorationThemeMetaDataPrivate()) +{ +} + +DecorationThemeMetaData::~DecorationThemeMetaData() = default; + +QString DecorationThemeMetaData::visibleName() const +{ + return d->visibleName; +} + +void DecorationThemeMetaData::setVisibleName(const QString &name) +{ + d->visibleName = name; +} + +bool DecorationThemeMetaData::hasConfiguration() const +{ + return d->hasConfig; +} + +void DecorationThemeMetaData::setHasConfiguration(bool hasConfig) +{ + d->hasConfig = hasConfig; +} + +QString DecorationThemeMetaData::themeName() const +{ + return d->themeName; +} + +void DecorationThemeMetaData::setThemeName(const QString &name) +{ + d->themeName = name; +} + +void DecorationThemeMetaData::setBorderSize(KDecoration2::BorderSize size) +{ + d->borderSize = size; +} + +KDecoration2::BorderSize DecorationThemeMetaData::borderSize() const +{ + return d->borderSize; +} + +QString DecorationThemeMetaData::pluginId() const +{ + return d->pluginId; +} + +void DecorationThemeMetaData::setPluginId(const QString &id) +{ + d->pluginId = id; +} + +DecorationThemeProvider::DecorationThemeProvider(QObject *parent, const KPluginMetaData &data, const QVariantList &args) + : QObject(parent) +{ + Q_UNUSED(data) + Q_UNUSED(args) +} + +DecorationThemeMetaData::DecorationThemeMetaData(const DecorationThemeMetaData &other) = default; + +DecorationThemeMetaData &DecorationThemeMetaData::operator=(const DecorationThemeMetaData &other) = default; diff --git a/src/decorationthemeprovider.h b/src/decorationthemeprovider.h new file mode 100644 index 0000000000000000000000000000000000000000..0c6da3de055491ec9dd7440a2498f77ba9588b9e --- /dev/null +++ b/src/decorationthemeprovider.h @@ -0,0 +1,78 @@ +/* + * SPDX-FileCopyrightText: 2021 Alexander Lohnau + * + * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL + */ + +#ifndef KDECORATION2_DECORATION_THEME_PROVIDER +#define KDECORATION2_DECORATION_THEME_PROVIDER + +#include "decorationdefines.h" +#include +#include +#include + +class KPluginMetaData; +class DecorationThemeMetaDataPrivate; + +namespace KDecoration2 +{ +/** + * Class providing type-safe access to data of themes + * + * @since 5.23 + * @author Alexander Lohnau + */ +class KDECORATIONS2_EXPORT DecorationThemeMetaData +{ +public: + explicit DecorationThemeMetaData(); + virtual ~DecorationThemeMetaData(); + DecorationThemeMetaData(const DecorationThemeMetaData &other); + DecorationThemeMetaData &operator=(const DecorationThemeMetaData &other); + + /// User-visible name of the theme + QString visibleName() const; + void setVisibleName(const QString &name); + + /// Internal name of the theme + QString themeName() const; + void setThemeName(const QString &name); + + /// Indicates that the theme has KCMs + bool hasConfiguration() const; + void setHasConfiguration(bool hasConfig); + + /// Border size of the decoration, this gets set based on the "recommendedBorderSize" key in the json metadata + /// @internal + KDecoration2::BorderSize borderSize() const; + void setBorderSize(KDecoration2::BorderSize size); + + /// plugin id of theme provider + /// @see KPluginMetaData::pluginId + QString pluginId() const; + void setPluginId(const QString &id); + +private: + QSharedDataPointer d; +}; +/** + * Class to give the KWin decorationmodel access to the plugin's themes. + * + * @since 5.23 + * @author Alexander Lohnau + */ +class KDECORATIONS2_EXPORT DecorationThemeProvider : public QObject +{ + Q_OBJECT + +public: + explicit DecorationThemeProvider(QObject *parent, const KPluginMetaData &data, const QVariantList &args); + + /** + * List containing information of supported themes + */ + virtual QList themes() const = 0; +}; +} +#endif