D27225: Add support for static platformtheme plugins

Mason McParlane noreply at phabricator.kde.org
Fri Feb 7 19:55:24 GMT 2020


masonm created this revision.
masonm added reviewers: VDG, Kirigami, mart.
masonm added a project: Kirigami.
masonm requested review of this revision.

REVISION SUMMARY
  PlatformTheme::qmlAttachedProperties is currently not looking for static KirigamiPluginFactory plugins. This change will search for static plugins for static builds, otherwise it will search shared object plugins.
  
  It also includes a fix for missing QIcon header.

TEST PLAN
  Register a custom, static KirigamiPluginFactory plugin using Q_IMPORT_PLUGIN and verify the attached properties work as expected. For example, regardless of what the style is set to when building with KIRIGAMI_BUILD_TYPE_STATIC below the theme should load with bright-green components:
  
    // In main.cpp
    
    #ifdef KIRIGAMI_BUILD_TYPE_STATIC
    #include <kirigami/src/kirigamiplugin.h>
    #include <KirigamiThemes/Default/defaulttheme.h>
    Q_IMPORT_PLUGIN(DefaultThemeFactory)
    #endif
    
    int main(int argc, char argv[]) {
    
      // ...
      
    #ifdef KIRIGAMI_BUILD_TYPE_STATIC
        KirigamiPlugin::registerTypes();
    #endif
    
      // ...
      
    }
    
    // In KirigamiThemes/Default/defaulttheme.h
    
    #ifndef DEFAULTTHEME_H
    #define DEFAULTTHEME_H
    
    #include "../KirigamiThemes_global.h"
    #include <KirigamiPluginFactory>
    
    class KIRIGAMITHEMES_EXPORT DefaultTheme : public Kirigami::PlatformTheme
    {
        Q_OBJECT
        QPalette lightPalette;
    
    public:
        explicit DefaultTheme(QObject* parent = nullptr);
    };
    
    class KIRIGAMITHEMES_EXPORT DefaultThemeFactory
            : public Kirigami::KirigamiPluginFactory
    {
        Q_OBJECT
        Q_PLUGIN_METADATA(IID KirigamiPluginFactory_iid)
        Q_INTERFACES(Kirigami::KirigamiPluginFactory)
    
    public:
        explicit DefaultThemeFactory(QObject* parent = nullptr)
            : Kirigami::KirigamiPluginFactory(parent)
        {
        }
    
        Kirigami::PlatformTheme *createPlatformTheme(QObject *parent) override;
    };
    
    #endif
    
    
    // In KirigamiThemes/Default/defaulttheme.cpp
    
    #include "defaulttheme.h"
    
    DefaultTheme::DefaultTheme(QObject* parent) : Kirigami::PlatformTheme(parent)
    {
        for (auto group : {QPalette::Active, QPalette::Inactive, QPalette::Disabled}) {
            lightPalette.setColor(group, QPalette::WindowText, "#00FF00");
            lightPalette.setColor(group, QPalette::Window, "#00FF00");
            lightPalette.setColor(group, QPalette::Base, "#00FF00");
            lightPalette.setColor(group, QPalette::Text, "#00FF00");
            lightPalette.setColor(group, QPalette::Button, "#00FF00");
            lightPalette.setColor(group, QPalette::ButtonText, "#00FF00");
            lightPalette.setColor(group, QPalette::Highlight, "#00FF00");
            lightPalette.setColor(group, QPalette::HighlightedText, "#00FF00");
            lightPalette.setColor(group, QPalette::ToolTipBase, "#00FF00");
            lightPalette.setColor(group, QPalette::ToolTipText, "#00FF00");
            lightPalette.setColor(group, QPalette::Link, "#00FF00");
            lightPalette.setColor(group, QPalette::LinkVisited, "#00FF00");
        }
    
        setTextColor(lightPalette.color(QPalette::Active, QPalette::WindowText));
        setBackgroundColor(lightPalette.color(QPalette::Active, QPalette::Window));
        setHighlightColor(lightPalette.color(QPalette::Active, QPalette::Highlight));
        setHighlightedTextColor(lightPalette.color(QPalette::Active, QPalette::HighlightedText));
        setLinkColor(lightPalette.color(QPalette::Active, QPalette::Link));
        setVisitedLinkColor(lightPalette.color(QPalette::Active, QPalette::LinkVisited));
    }
    
    Kirigami::PlatformTheme *DefaultThemeFactory::createPlatformTheme(QObject *parent)
    {
        return new DefaultTheme(parent);
    }

REPOSITORY
  R169 Kirigami

REVISION DETAIL
  https://phabricator.kde.org/D27225

AFFECTED FILES
  src/libkirigami/platformtheme.cpp
  src/libkirigami/platformtheme.h

To: masonm, #vdg, #kirigami, mart
Cc: plasma-devel, fbampaloukas, GB_2, domson, dkardarakos, ngraham, apol, ahiemstra, davidedmundson, mart, hein
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20200207/3a0f85e4/attachment-0001.html>


More information about the Plasma-devel mailing list