~dblsaiko/k90s

b8e1c20040091b023c4eefb3bfb9358d6d95af23 — 2xsaiko 3 years ago fa5c993
Start working on a Qt application style
M CMakeLists.txt => CMakeLists.txt +1 -3
@@ 15,9 15,7 @@ include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings NO_POLICY_SCOPE)

find_package(KF5CoreAddons REQUIRED)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5 REQUIRED COMPONENTS Core Gui)

add_subdirectory(platform)
add_subdirectory(appstyle)

M appstyle/CMakeLists.txt => appstyle/CMakeLists.txt +26 -3
@@ 1,11 1,34 @@
project(k90sstyl)

set(k90sstyl_SRC )
set(k90sstyl_SRC
        k90sstyl.cpp
        stylplug.cpp)

find_package(Qt5 REQUIRED COMPONENTS Widgets)

set(with_kde TRUE)

if (with_kde)
    find_package(KF5 REQUIRED COMPONENTS
            I18n
            GuiAddons
            WindowSystem
            FrameworkIntegration)

    add_definitions("-DUSE_KF5")
endif()


add_library(k90sstyl MODULE
        ${k90sstyl_SRC})

target_link_libraries(k90sstyl
        PUBLIC   Qt5::Core Qt5::Gui k90splat)
        PUBLIC   Qt5::Core Qt5::Gui Qt5::Widgets k90splat)

if (with_kde)
    target_link_libraries(k90sstyl
            PUBLIC   KF5::Style)
endif()

install(TARGETS k90sstyl DESTINATION ${PLUGIN_INSTALL_DIR}/styles)
install(TARGETS k90sstyl DESTINATION ${QT_PLUGIN_INSTALL_DIR}/styles)
install(FILES k90sstyl.themerc DESTINATION ${DATA_INSTALL_DIR}/kstyle/themes)
\ No newline at end of file

A appstyle/k90sstyl.cpp => appstyle/k90sstyl.cpp +53 -0
@@ 0,0 1,53 @@
#include "k90sstyl.h"

K90sStyle::K90sStyle() : STYLE_CLASS() {

}

K90sStyle::~K90sStyle() {

}

void K90sStyle::polish(QWidget* widget) {
    if (!widget) return;

    STYLE_CLASS::polish(widget);
}

void K90sStyle::unpolish(QWidget* widget) {
    if (!widget) return;

    STYLE_CLASS::unpolish(widget);
}

QPalette K90sStyle::standardPalette() const {
    return STYLE_CLASS::standardPalette();
}

void K90sStyle::drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption* opt, QPainter* p, const QWidget* w) const {
    QCommonStyle::drawPrimitive(pe, opt, p, w);
}

void K90sStyle::drawControl(QStyle::ControlElement element, const QStyleOption* opt, QPainter* p, const QWidget* w) const {
    QCommonStyle::drawControl(element, opt, p, w);
}

QRect K90sStyle::subElementRect(QStyle::SubElement r, const QStyleOption* opt, const QWidget* widget) const {
    return QCommonStyle::subElementRect(r, opt, widget);
}

void K90sStyle::drawComplexControl(QStyle::ComplexControl cc, const QStyleOptionComplex* opt, QPainter* p, const QWidget* w) const {
    QCommonStyle::drawComplexControl(cc, opt, p, w);
}

QRect K90sStyle::subControlRect(QStyle::ComplexControl cc, const QStyleOptionComplex* opt, QStyle::SubControl sc, const QWidget* w) const {
    return QCommonStyle::subControlRect(cc, opt, sc, w);
}

QSize K90sStyle::sizeFromContents(QStyle::ContentsType ct, const QStyleOption* opt, const QSize& contentsSize, const QWidget* widget) const {
    return QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget);
}

int K90sStyle::layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption* option, const QWidget* widget) const {
    return QCommonStyle::layoutSpacing(control1, control2, orientation, option, widget);
}

A appstyle/k90sstyl.h => appstyle/k90sstyl.h +53 -0
@@ 0,0 1,53 @@
#ifndef K90S_K90SSTYL_H
#define K90S_K90SSTYL_H

#include <QCommonStyle>

#ifdef USE_KF5

#include <KF5/KStyle/KStyle>

#endif

#ifndef USE_KF5
#define STYLE_CLASS QCommonStyle
#else
#define STYLE_CLASS KStyle
#endif

class K90sStyle : public STYLE_CLASS {
Q_OBJECT

#ifdef USE_KF5
    Q_CLASSINFO("X-KDE-CustomElements", "true")
#endif

public:
    explicit K90sStyle();

    ~K90sStyle() override;

    void polish(QWidget* widget) override;

    void unpolish(QWidget* widget) override;

    QPalette standardPalette() const override;

    void drawPrimitive(PrimitiveElement pe, const QStyleOption* opt, QPainter* p, const QWidget* w) const override;

    void drawControl(ControlElement element, const QStyleOption* opt, QPainter* p, const QWidget* w) const override;

    QRect subElementRect(SubElement r, const QStyleOption* opt, const QWidget* widget) const override;

    void drawComplexControl(ComplexControl cc, const QStyleOptionComplex* opt, QPainter* p, const QWidget* w) const override;

    QRect subControlRect(ComplexControl cc, const QStyleOptionComplex* opt, SubControl sc, const QWidget* w) const override;

    QSize sizeFromContents(ContentsType ct, const QStyleOption* opt, const QSize& contentsSize, const QWidget* widget) const override;

    int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption* option, const QWidget* widget) const override;


};

#endif //K90S_K90SSTYL_H

A appstyle/k90sstyl.json => appstyle/k90sstyl.json +3 -0
@@ 0,0 1,3 @@
{
  "Keys": ["k90sstyl"]
}
\ No newline at end of file

A appstyle/k90sstyl.themerc => appstyle/k90sstyl.themerc +5 -0
@@ 0,0 1,5 @@
[Misc]
Name=k90s
Comment=Windows Classic-like theme for KDE
[KDE]
WidgetStyle=k90sstyl
\ No newline at end of file

A appstyle/stylplug.cpp => appstyle/stylplug.cpp +13 -0
@@ 0,0 1,13 @@
#include "stylplug.h"
#include "k90sstyl.h"

K90sStylePlugin::K90sStylePlugin(QObject* parent) : QStylePlugin(parent) {
}

QStyle* K90sStylePlugin::create(const QString& key) {
    if (key == QStringLiteral("k90sstyl")) {
        return new K90sStyle();
    }

    return nullptr;
}

A appstyle/stylplug.h => appstyle/stylplug.h +17 -0
@@ 0,0 1,17 @@
#ifndef K90S_STYLPLUG_H
#define K90S_STYLPLUG_H

#include <QStylePlugin>

class K90sStylePlugin : public QStylePlugin {
Q_OBJECT

    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "k90sstyl.json")

public:
    explicit K90sStylePlugin(QObject* parent = nullptr);

    QStyle* create(const QString& key) override;
};

#endif //K90S_STYLPLUG_H

M deco/CMakeLists.txt => deco/CMakeLists.txt +1 -0
@@ 5,6 5,7 @@ set(k90sdeco_SRC
        decobutn.cpp
        k90sdeco.cpp)

find_package(KF5CoreAddons REQUIRED)
find_package(KDecoration2 REQUIRED)

add_library(k90sdeco MODULE