diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,21 @@ find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Gui Widgets) +find_package(KF5 ${KF5_DEP_VERSION} REQUIRED COMPONENTS Kirigami2) + +find_package(KF5 ${KF5_DEP_VERSION} COMPONENTS + IconThemes #KIconLoader + ConfigWidgets #KColorScheme + ) +set_package_properties(IconThemes PROPERTIES DESCRIPTION "KF5 IconThemes framework" + TYPE OPTIONAL + PURPOSE "Optional integration of Kirigami with KIconLoader icons handling for a better integration with Plasma Desktop" + ) +set_package_properties(ConfigWidgets PROPERTIES DESCRIPTION "KF5 WidgetAddons framework" + TYPE OPTIONAL + PURPOSE "Optional integration of Kirigami with KColorScheme for color palettes integration with Plasma Desktop" + ) + find_package(PkgConfig) set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5QQC2DeskopStyle") @@ -62,6 +77,10 @@ add_subdirectory(plugin) +if (KF5IconThemes_FOUND AND KF5WidgetsAddons_FOUND) +add_subdirectory(kirigami-plasmadesktop-integration) +endif(KF5IconThemes_FOUND AND KF5WidgetsAddons_FOUND) + install(DIRECTORY org.kde.desktop DESTINATION ${KDE_INSTALL_QMLDIR}/QtQuick/Controls.2) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/kirigami-plasmadesktop-integration/CMakeLists.txt b/kirigami-plasmadesktop-integration/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/kirigami-plasmadesktop-integration/CMakeLists.txt @@ -0,0 +1,23 @@ + + +set(org.kde.desktop_SRCS + plasmadesktoptheme.cpp + kirigamiplasmafactory.cpp +) + + +add_library(org.kde.desktop MODULE ${org.kde.desktop_SRCS}) + +target_link_libraries(org.kde.desktop + PUBLIC + Qt5::Core + KF5::Kirigami2 + PRIVATE + Qt5::Qml + Qt5::Quick + KF5::ConfigWidgets + KF5::IconThemes +) + +install(TARGETS org.kde.desktop DESTINATION ${KDE_INSTALL_PLUGINDIR}/kf5/kirigami) + diff --git a/kirigami-plasmadesktop-integration/kirigamiplasmafactory.h b/kirigami-plasmadesktop-integration/kirigamiplasmafactory.h new file mode 100644 --- /dev/null +++ b/kirigami-plasmadesktop-integration/kirigamiplasmafactory.h @@ -0,0 +1,43 @@ +/* +* Copyright (C) 2017 by Marco Martin +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Library General Public License as +* published by the Free Software Foundation; either version 2, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Library General Public License for more details +* +* You should have received a copy of the GNU Library General Public +* License along with this program; if not, write to the +* Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef KIRIGAMIPLASMAFACTORY_H +#define KIRIGAMIPLASMAFACTORY_H + +#include +#include + +class KirigamiPlasmaFactory : public Kirigami::KirigamiPluginFactory +{ + Q_OBJECT + + Q_PLUGIN_METADATA(IID "org.kde.kirigami.KirigamiPluginFactory" FILE "kirigamiplasmaintegration.json") + + Q_INTERFACES(Kirigami::KirigamiPluginFactory) + +public: + explicit KirigamiPlasmaFactory(QObject *parent = nullptr); + ~KirigamiPlasmaFactory(); + + Kirigami::PlatformTheme *createPlatformTheme(QObject *parent) Q_DECL_OVERRIDE; +}; + + + +#endif // KIRIGAMIPLASMAFACTORY_H diff --git a/kirigami-plasmadesktop-integration/kirigamiplasmafactory.cpp b/kirigami-plasmadesktop-integration/kirigamiplasmafactory.cpp new file mode 100644 --- /dev/null +++ b/kirigami-plasmadesktop-integration/kirigamiplasmafactory.cpp @@ -0,0 +1,38 @@ +/* +* Copyright (C) 2017 by Marco Martin +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Library General Public License as +* published by the Free Software Foundation; either version 2, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Library General Public License for more details +* +* You should have received a copy of the GNU Library General Public +* License along with this program; if not, write to the +* Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "kirigamiplasmafactory.h" +#include "plasmadesktoptheme.h" + +KirigamiPlasmaFactory::KirigamiPlasmaFactory(QObject *parent) + : Kirigami::KirigamiPluginFactory(parent) +{ +} + +KirigamiPlasmaFactory::~KirigamiPlasmaFactory() +{ +} + +Kirigami::PlatformTheme *KirigamiPlasmaFactory::createPlatformTheme(QObject *parent) +{ + Q_ASSERT(parent); + return new PlasmaDesktopTheme(parent); +} + +#include "moc_kirigamiplasmafactory.cpp" diff --git a/kirigami-plasmadesktop-integration/kirigamiplasmaintegration.json b/kirigami-plasmadesktop-integration/kirigamiplasmaintegration.json new file mode 100644 --- /dev/null +++ b/kirigami-plasmadesktop-integration/kirigamiplasmaintegration.json @@ -0,0 +1 @@ +{} diff --git a/kirigami-plasmadesktop-integration/plasmadesktoptheme.h b/kirigami-plasmadesktop-integration/plasmadesktoptheme.h new file mode 100644 --- /dev/null +++ b/kirigami-plasmadesktop-integration/plasmadesktoptheme.h @@ -0,0 +1,86 @@ +/* +* Copyright (C) 2017 by Marco Martin +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Library General Public License as +* published by the Free Software Foundation; either version 2, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Library General Public License for more details +* +* You should have received a copy of the GNU Library General Public +* License along with this program; if not, write to the +* Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef KIRIGAMIPLASMATHEME_H +#define KIRIGAMIPLASMATHEME_H + +#include +#include +#include +#include +#include + +class PlasmaDesktopTheme; + +class PlasmaDesktopTheme : public Kirigami::PlatformTheme +{ + Q_OBJECT + + // colors + Q_PROPERTY(QColor buttonTextColor READ buttonTextColor NOTIFY colorsChanged) + Q_PROPERTY(QColor buttonBackgroundColor READ buttonBackgroundColor NOTIFY colorsChanged) + Q_PROPERTY(QColor buttonHoverColor READ buttonHoverColor NOTIFY colorsChanged) + Q_PROPERTY(QColor buttonFocusColor READ buttonFocusColor NOTIFY colorsChanged) + + Q_PROPERTY(QColor viewTextColor READ viewTextColor NOTIFY colorsChanged) + Q_PROPERTY(QColor viewBackgroundColor READ viewBackgroundColor NOTIFY colorsChanged) + Q_PROPERTY(QColor viewHoverColor READ viewHoverColor NOTIFY colorsChanged) + Q_PROPERTY(QColor viewFocusColor READ viewFocusColor NOTIFY colorsChanged) + + //FIXME: this is due https://bugreports.qt.io/browse/QTBUG-63089 + Q_PROPERTY(QStringList keys READ keys CONSTANT) + +public: + explicit PlasmaDesktopTheme(QObject *parent = 0); + ~PlasmaDesktopTheme(); + + Q_INVOKABLE QIcon iconFromTheme(const QString &name, const QColor &customColor = Qt::transparent) Q_DECL_OVERRIDE; + + void syncColors(); + + QColor buttonTextColor() const; + QColor buttonBackgroundColor() const; + QColor buttonHoverColor() const; + QColor buttonFocusColor() const; + + QColor viewTextColor() const; + QColor viewBackgroundColor() const; + QColor viewHoverColor() const; + QColor viewFocusColor() const; + + QStringList keys() const; + +Q_SIGNALS: + void colorsChanged(); + +private: + QPointer m_parentItem; + //legacy colors + QColor m_buttonTextColor; + QColor m_buttonBackgroundColor; + QColor m_buttonHoverColor; + QColor m_buttonFocusColor; + QColor m_viewTextColor; + QColor m_viewBackgroundColor; + QColor m_viewHoverColor; + QColor m_viewFocusColor; +}; + + +#endif // KIRIGAMIPLASMATHEME_H diff --git a/kirigami-plasmadesktop-integration/plasmadesktoptheme.cpp b/kirigami-plasmadesktop-integration/plasmadesktoptheme.cpp new file mode 100644 --- /dev/null +++ b/kirigami-plasmadesktop-integration/plasmadesktoptheme.cpp @@ -0,0 +1,249 @@ +/* +* Copyright (C) 2017 by Marco Martin +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Library General Public License as +* published by the Free Software Foundation; either version 2, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Library General Public License for more details +* +* You should have received a copy of the GNU Library General Public +* License along with this program; if not, write to the +* Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "plasmadesktoptheme.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +PlasmaDesktopTheme::PlasmaDesktopTheme(QObject *parent) + : PlatformTheme(parent) +{ + m_parentItem = qobject_cast(parent); + + //null in case parent is a normal QObject + if (m_parentItem) { + connect(m_parentItem.data(), &QQuickItem::enabledChanged, + this, &PlasmaDesktopTheme::syncColors); + if (m_parentItem && m_parentItem->window()) { + connect(m_parentItem->window(), &QWindow::activeChanged, + this, &PlasmaDesktopTheme::syncColors); + } + connect(m_parentItem.data(), &QQuickItem::windowChanged, + this, [this]() { + if (m_parentItem && m_parentItem->window()) { + connect(m_parentItem->window(), &QWindow::activeChanged, + this, &PlasmaDesktopTheme::syncColors); + } + syncColors(); + }); + } + + //TODO: correct? depends from https://codereview.qt-project.org/206889 + connect(qApp, &QGuiApplication::fontDatabaseChanged, this, [this]() {setDefaultFont(qApp->font());}); + + connect(this, &PlasmaDesktopTheme::colorSetChanged, + this, &PlasmaDesktopTheme::syncColors); + connect(qApp, &QGuiApplication::paletteChanged, + this, &PlasmaDesktopTheme::syncColors); + + syncColors(); +} + +PlasmaDesktopTheme::~PlasmaDesktopTheme() +{ +} + +QIcon PlasmaDesktopTheme::iconFromTheme(const QString &name, const QColor &customColor) +{ + QPalette pal = palette(); + if (customColor != Qt::transparent) { + static const QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive, QPalette::Disabled }; + for (int i = 0; i < 3; i++) { + QPalette::ColorGroup state = states[i]; + pal.setBrush(state, QPalette::WindowText, customColor); + } + } + + KIconLoader::global()->setCustomPalette(pal); + + return KDE::icon(name, KIconLoader::global()); +} + +QStringList PlasmaDesktopTheme::keys() const +{ + QStringList props; + for (int i = PlatformTheme::metaObject()->propertyOffset(); i < metaObject()->propertyCount(); ++i) { + const QString prop = QString::fromUtf8(metaObject()->property(i).name()); + if (prop != QStringLiteral("keys")) { + props << prop; + } + } + return props; +} + +void PlasmaDesktopTheme::syncColors() +{ + KColorScheme::ColorSet set; + + switch (colorSet()) { + case PlatformTheme::Button: + set = KColorScheme::ColorSet::Button; + break; + case PlatformTheme::Selection: + set = KColorScheme::ColorSet::Selection; + break; + case PlatformTheme::Tooltip: + set = KColorScheme::ColorSet::Tooltip; + break; + case PlatformTheme::View: + set = KColorScheme::ColorSet::View; + break; + case PlatformTheme::Complementary: + set = KColorScheme::ColorSet::Complementary; + break; + case PlatformTheme::Window: + default: + set = KColorScheme::ColorSet::Window; + } + + QPalette::ColorGroup group = QPalette::Active; + if (m_parentItem) { + if (!m_parentItem->isEnabled()) { + group = QPalette::Disabled; + } else if (m_parentItem->window() && !m_parentItem->window()->isActive()) { + group = QPalette::Inactive; + } + } + + const KColorScheme selectionScheme(group, KColorScheme::ColorSet::Selection); + const KColorScheme scheme(group, set); + + //foreground + setTextColor(scheme.foreground(KColorScheme::NormalText).color()); + setDisabledTextColor(scheme.foreground(KColorScheme::InactiveText).color()); + setHighlightedTextColor(selectionScheme.foreground(KColorScheme::NormalText).color()); + setActiveTextColor(scheme.foreground(KColorScheme::ActiveText).color()); + setLinkColor(scheme.foreground(KColorScheme::LinkText).color()); + setVisitedLinkColor(scheme.foreground(KColorScheme::VisitedText).color()); + setNegativeTextColor(scheme.foreground(KColorScheme::NegativeText).color()); + setNeutralTextColor(scheme.foreground(KColorScheme::NeutralText).color()); + setPositiveTextColor(scheme.foreground(KColorScheme::PositiveText).color()); + + + //background + setBackgroundColor(scheme.background(KColorScheme::NormalBackground).color()); + setHighlightColor(selectionScheme.background(KColorScheme::NormalBackground).color()); + + //decoration + setHoverColor(scheme.decoration(KColorScheme::HoverColor).color()); + setFocusColor(scheme.decoration(KColorScheme::FocusColor).color()); + + QPalette pal = palette(); + static const QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive, QPalette::Disabled }; + for (int i = 0; i < 3; i++) { + QPalette::ColorGroup state = states[i]; + pal.setBrush(state, QPalette::WindowText, scheme.foreground()); + pal.setBrush(state, QPalette::Window, scheme.background()); + pal.setBrush(state, QPalette::Base, scheme.background()); + pal.setBrush(state, QPalette::Text, scheme.foreground()); + pal.setBrush(state, QPalette::Button, scheme.background()); + pal.setBrush(state, QPalette::ButtonText, scheme.foreground()); + pal.setBrush(state, QPalette::Highlight, selectionScheme.background()); + pal.setBrush(state, QPalette::HighlightedText, selectionScheme.foreground()); + pal.setBrush(state, QPalette::ToolTipBase, scheme.background()); + pal.setBrush(state, QPalette::ToolTipText, scheme.foreground()); + + pal.setColor(state, QPalette::Light, scheme.shade(KColorScheme::LightShade)); + pal.setColor(state, QPalette::Midlight, scheme.shade(KColorScheme::MidlightShade)); + pal.setColor(state, QPalette::Mid, scheme.shade(KColorScheme::MidShade)); + pal.setColor(state, QPalette::Dark, scheme.shade(KColorScheme::DarkShade)); + pal.setColor(state, QPalette::Shadow, scheme.shade(KColorScheme::ShadowShade)); + + pal.setBrush(state, QPalette::AlternateBase, scheme.background(KColorScheme::AlternateBackground)); + pal.setBrush(state, QPalette::Link, scheme.foreground(KColorScheme::LinkText)); + pal.setBrush(state, QPalette::LinkVisited, scheme.foreground(KColorScheme::VisitedText)); + } + setPalette(pal); + + + //legacy stuff + const KColorScheme buttonScheme(QPalette::Active, KColorScheme::ColorSet::Button); + m_buttonTextColor = buttonScheme.foreground(KColorScheme::NormalText).color(); + m_buttonBackgroundColor = buttonScheme.background(KColorScheme::NormalBackground).color(); + m_buttonHoverColor = buttonScheme.decoration(KColorScheme::HoverColor).color(); + m_buttonFocusColor = buttonScheme.decoration(KColorScheme::FocusColor).color(); + + const KColorScheme viewScheme(QPalette::Active, KColorScheme::ColorSet::View); + m_viewTextColor = viewScheme.foreground(KColorScheme::NormalText).color(); + m_viewBackgroundColor = viewScheme.background(KColorScheme::NormalBackground).color(); + m_viewHoverColor = viewScheme.decoration(KColorScheme::HoverColor).color(); + m_viewFocusColor = viewScheme.decoration(KColorScheme::FocusColor).color(); + + emit colorsChanged(); +} + +QColor PlasmaDesktopTheme::buttonTextColor() const +{ + qWarning()<<"WARNING: buttonTextColor is deprecated, use textColor with colorSet: Theme.Button instead"; + return m_buttonTextColor; +} + +QColor PlasmaDesktopTheme::buttonBackgroundColor() const +{ + qWarning()<<"WARNING: buttonBackgroundColor is deprecated, use backgroundColor with colorSet: Theme.Button instead"; + return m_buttonBackgroundColor; +} + +QColor PlasmaDesktopTheme::buttonHoverColor() const +{ + qWarning()<<"WARNING: buttonHoverColor is deprecated, use backgroundColor with colorSet: Theme.Button instead"; + return m_buttonHoverColor; +} + +QColor PlasmaDesktopTheme::buttonFocusColor() const +{ + qWarning()<<"WARNING: buttonFocusColor is deprecated, use backgroundColor with colorSet: Theme.Button instead"; + return m_buttonFocusColor; +} + + +QColor PlasmaDesktopTheme::viewTextColor() const +{ + qWarning()<<"WARNING: viewTextColor is deprecated, use backgroundColor with colorSet: Theme.View instead"; + return m_viewTextColor; +} + +QColor PlasmaDesktopTheme::viewBackgroundColor() const +{ + qWarning()<<"WARNING: viewBackgroundColor is deprecated, use backgroundColor with colorSet: Theme.View instead"; + return m_viewBackgroundColor; +} + +QColor PlasmaDesktopTheme::viewHoverColor() const +{ + qWarning()<<"WARNING: viewHoverColor is deprecated, use backgroundColor with colorSet: Theme.View instead"; + return m_viewHoverColor; +} + +QColor PlasmaDesktopTheme::viewFocusColor() const +{ + qWarning()<<"WARNING: viewFocusColor is deprecated, use backgroundColor with colorSet: Theme.View instead"; + return m_viewFocusColor; +} + +#include "moc_plasmadesktoptheme.cpp" diff --git a/org.kde.desktop/Button.qml b/org.kde.desktop/Button.qml --- a/org.kde.desktop/Button.qml +++ b/org.kde.desktop/Button.qml @@ -22,9 +22,12 @@ import QtQuick 2.6 import QtQuick.Templates 2.0 as T import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate +import org.kde.kirigami 2.2 as Kirigami T.Button { id: controlRoot + Kirigami.Theme.colorSet: Kirigami.Theme.Button + Kirigami.Theme.inherit: false implicitWidth: background.implicitWidth implicitHeight: background.implicitHeight diff --git a/org.kde.desktop/CheckBox.qml b/org.kde.desktop/CheckBox.qml --- a/org.kde.desktop/CheckBox.qml +++ b/org.kde.desktop/CheckBox.qml @@ -23,7 +23,7 @@ import QtQuick 2.6 import QtQuick.Templates 2.0 as T import QtQuick.Controls 2.0 -import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate +import org.kde.kirigami 2.2 as Kirigami T.CheckBox { id: controlRoot @@ -36,7 +36,7 @@ baselineOffset: contentItem.y + contentItem.baselineOffset padding: 1 - spacing: Math.round(StylePrivate.TextSingleton.height / 8) + spacing: Kirigami.Units.smallSpacing hoverEnabled: true @@ -56,7 +56,6 @@ opacity: controlRoot.enabled ? 1 : 0.6 text: controlRoot.text font: controlRoot.font - color: StylePrivate.SystemPaletteSingleton.text(controlRoot.enabled) elide: Text.ElideRight visible: controlRoot.text horizontalAlignment: Text.AlignLeft diff --git a/org.kde.desktop/CheckDelegate.qml b/org.kde.desktop/CheckDelegate.qml --- a/org.kde.desktop/CheckDelegate.qml +++ b/org.kde.desktop/CheckDelegate.qml @@ -22,7 +22,7 @@ import QtQuick 2.5 import QtQuick.Templates 2.0 as T -import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate +import org.kde.kirigami 2.2 as Kirigami import "private" T.CheckDelegate { @@ -43,7 +43,7 @@ text: controlRoot.text font: controlRoot.font - color: (controlRoot.pressed && !controlRoot.checked && !controlRoot.sectionDelegate) ? StylePrivate.SystemPaletteSingleton.highlightedText(controlRoot.enabled) : StylePrivate.SystemPaletteSingleton.text(controlRoot.enabled) + color: (controlRoot.pressed && !controlRoot.checked && !controlRoot.sectionDelegate) ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor elide: Text.ElideRight visible: controlRoot.text horizontalAlignment: Text.AlignLeft diff --git a/org.kde.desktop/ComboBox.qml b/org.kde.desktop/ComboBox.qml --- a/org.kde.desktop/ComboBox.qml +++ b/org.kde.desktop/ComboBox.qml @@ -26,9 +26,12 @@ import QtQuick.Controls 2.0 as Controls import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate import QtGraphicalEffects 1.0 +import org.kde.kirigami 2.2 as Kirigami T.ComboBox { id: controlRoot + Kirigami.Theme.colorSet: Kirigami.Theme.Button + Kirigami.Theme.inherit: false implicitWidth: background.implicitWidth + leftPadding + rightPadding implicitHeight: background.implicitHeight @@ -44,6 +47,8 @@ text: controlRoot.textRole ? (Array.isArray(controlRoot.model) ? modelData[controlRoot.textRole] : model[controlRoot.textRole]) : modelData highlighted: controlRoot.highlightedIndex == index property bool separatorVisible: false + Kirigami.Theme.colorSet: controlRoot.Kirigami.Theme.inherit ? controlRoot.Kirigami.Theme.colorSet : Kirigami.Theme.View + Kirigami.Theme.inherit: controlRoot.Kirigami.Theme.inherit } indicator: Item {} @@ -76,6 +81,8 @@ implicitHeight: contentItem.implicitHeight topMargin: 6 bottomMargin: 6 + Kirigami.Theme.colorSet: Kirigami.Theme.View + Kirigami.Theme.inherit: controlRoot.Kirigami.Theme.inherit contentItem: ListView { id: listview @@ -93,8 +100,8 @@ margins: -1 } radius: 2 - color: StylePrivate.SystemPaletteSingleton.base(controlRoot.enabled) - property color borderColor: StylePrivate.SystemPaletteSingleton.text(controlRoot.enabled) + color: Kirigami.Theme.backgroundColor + property color borderColor: Kirigami.Theme.textColor border.color: Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0.3) layer.enabled: true diff --git a/org.kde.desktop/Dial.qml b/org.kde.desktop/Dial.qml --- a/org.kde.desktop/Dial.qml +++ b/org.kde.desktop/Dial.qml @@ -24,7 +24,7 @@ import QtQuick.Controls 2.0 import QtQuick.Controls.impl 2.0 import QtQuick.Templates 2.0 as T -import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate +import org.kde.kirigami 2.2 as Kirigami T.Dial { id: control @@ -35,7 +35,7 @@ background: DialRing { width: control.availableWidth height: control.availableHeight - color: control.visualFocus ? StylePrivate.SystemPaletteSingleton.highlight(control.enabled) : StylePrivate.SystemPaletteSingleton.text(control.enabled) + color: control.visualFocus ? Kirigami.Theme.highlightColor : Kirigami.Theme.textColor progress: control.position opacity: control.enabled ? 0.5 : 0.3 } @@ -46,6 +46,6 @@ width: 18 height: width radius: 8 - color: control.visualFocus ? StylePrivate.SystemPaletteSingleton.highlight(control.enabled) : StylePrivate.SystemPaletteSingleton.text(control.enabled) + color: control.visualFocus ? Kirigami.Theme.highlightColor : Kirigami.Theme.textColor } } diff --git a/org.kde.desktop/Dialog.qml b/org.kde.desktop/Dialog.qml --- a/org.kde.desktop/Dialog.qml +++ b/org.kde.desktop/Dialog.qml @@ -23,7 +23,7 @@ import QtQuick 2.6 import QtGraphicalEffects 1.0 import QtQuick.Templates 2.1 as T -import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate +import org.kde.kirigami 2.2 as Kirigami T.Dialog { id: control @@ -62,8 +62,8 @@ background: Rectangle { radius: 2 - color: StylePrivate.SystemPaletteSingleton.window(control.enabled) - property color borderColor: StylePrivate.SystemPaletteSingleton.text(control.enabled) + color: Kirigami.Theme.backgroundColor + property color borderColor: Kirigami.Theme.textColor border.color: Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0.3) layer.enabled: true diff --git a/org.kde.desktop/Drawer.qml b/org.kde.desktop/Drawer.qml --- a/org.kde.desktop/Drawer.qml +++ b/org.kde.desktop/Drawer.qml @@ -23,7 +23,7 @@ import QtQuick 2.6 import QtQuick.Controls 2.0 import QtQuick.Templates 2.0 as T -import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate +import org.kde.kirigami 2.2 as Kirigami T.Drawer { id: control @@ -42,16 +42,16 @@ bottomPadding: control.edge === Qt.TopEdge ? 1 : 0 background: Rectangle { - color: StylePrivate.SystemPaletteSingleton.window(control.enabled) + color: Kirigami.Theme.backgroundColor Rectangle { readonly property bool horizontal: control.edge === Qt.LeftEdge || control.edge === Qt.RightEdge anchors { left: control.edge !== Qt.LeftEdge ? parent.left : undefined right: control.edge !== Qt.RightEdge ? parent.right : undefined top: control.edge !== Qt.TopEdge ? parent.top : undefined bottom: control.edge !== Qt.BottomEdge ? parent.bottom : undefined } - color: StylePrivate.SystemPaletteSingleton.text(control.enabled) + color: Kirigami.Theme.textColor opacity: 0.3 width: 1 height: 1 diff --git a/org.kde.desktop/Frame.qml b/org.kde.desktop/Frame.qml --- a/org.kde.desktop/Frame.qml +++ b/org.kde.desktop/Frame.qml @@ -23,6 +23,7 @@ import QtQuick 2.6 import QtQuick.Controls 2.0 import QtQuick.Templates 2.0 as T +import org.kde.kirigami 2.2 as Kirigami T.Frame { id: control @@ -37,7 +38,7 @@ background: Rectangle { color: "transparent" - property color borderColor: StylePrivate.SystemPaletteSingleton.text(control.enabled) + property color borderColor: Kirigami.Theme.textColor border.color: Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0.3) } } diff --git a/org.kde.desktop/GroupBox.qml b/org.kde.desktop/GroupBox.qml --- a/org.kde.desktop/GroupBox.qml +++ b/org.kde.desktop/GroupBox.qml @@ -23,7 +23,7 @@ import QtQuick 2.6 import QtQuick.Controls 2.0 import QtQuick.Templates 2.0 as T -import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate +import org.kde.kirigami 2.2 as Kirigami T.GroupBox { id: control @@ -43,15 +43,15 @@ text: control.title font: control.font - color: StylePrivate.SystemPaletteSingleton.text(control.enabled) + color: Kirigami.Theme.textColor elide: Text.ElideRight horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter } background: Rectangle { color: "transparent" - property color borderColor: StylePrivate.SystemPaletteSingleton.text(control.enabled) + property color borderColor: Kirigami.Theme.textColor border.color: Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0.3) } } diff --git a/org.kde.desktop/ItemDelegate.qml b/org.kde.desktop/ItemDelegate.qml --- a/org.kde.desktop/ItemDelegate.qml +++ b/org.kde.desktop/ItemDelegate.qml @@ -21,8 +21,8 @@ import QtQuick 2.5 -import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate import QtQuick.Templates 2.0 as T +import org.kde.kirigami 2.2 as Kirigami import "private" T.ItemDelegate { @@ -43,7 +43,7 @@ text: controlRoot.text font: controlRoot.font - color: controlRoot.highlighted || controlRoot.checked || (controlRoot.pressed && !controlRoot.checked && !controlRoot.sectionDelegate) ? StylePrivate.SystemPaletteSingleton.highlightedText(controlRoot.enabled) : StylePrivate.SystemPaletteSingleton.text(controlRoot.enabled) + color: controlRoot.highlighted || controlRoot.checked || (controlRoot.pressed && !controlRoot.checked && !controlRoot.sectionDelegate) ? Kirigami.Theme.highlightedTextColor : (controlRoot.enabled ? Kirigami.Theme.textColor : Kirigami.Theme.disabledTextColor) elide: Text.ElideRight visible: controlRoot.text horizontalAlignment: Text.AlignLeft diff --git a/org.kde.desktop/Label.qml b/org.kde.desktop/Label.qml --- a/org.kde.desktop/Label.qml +++ b/org.kde.desktop/Label.qml @@ -24,22 +24,30 @@ import QtQuick.Window 2.2 import QtQuick.Templates 2.0 as T import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate +import org.kde.kirigami 2.2 as Kirigami T.Label { id: control - height: Math.round(Math.max(paintedHeight, StylePrivate.TextSingleton.height * 1.6)) + height: Math.round(Math.max(paintedHeight, Kirigami.Units * 1.6)) verticalAlignment: lineCount > 1 ? Text.AlignTop : Text.AlignVCenter activeFocusOnTab: false //Text.NativeRendering is broken on non integer pixel ratios renderType: Window.devicePixelRatio % 1 !== 0 ? Text.QtRendering : Text.NativeRendering - //font data is the system one by default - color: StylePrivate.SystemPaletteSingleton.text(control.enabled) - //StylePrivate.SystemPaletteSingleton doesn't have a link color - linkColor: "#2196F3" + font.capitalization: Kirigami.Theme.defaultFont.capitalization + font.family: Kirigami.Theme.defaultFont.family + font.italic: Kirigami.Theme.defaultFont.italic + font.letterSpacing: Kirigami.Theme.defaultFont.letterSpacing + font.pointSize: Kirigami.Theme.defaultFont.pointSize + font.strikeout: Kirigami.Theme.defaultFont.strikeout + font.underline: Kirigami.Theme.defaultFont.underline + font.weight: Kirigami.Theme.defaultFont.weight + font.wordSpacing: Kirigami.Theme.defaultFont.wordSpacing + color: Kirigami.Theme.textColor + linkColor: Kirigami.Theme.linkColor opacity: enabled? 1 : 0.6 diff --git a/org.kde.desktop/Menu.qml b/org.kde.desktop/Menu.qml --- a/org.kde.desktop/Menu.qml +++ b/org.kde.desktop/Menu.qml @@ -24,7 +24,7 @@ import QtGraphicalEffects 1.0 import QtQuick.Controls 2.0 import QtQuick.Templates 2.0 as T -import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate +import org.kde.kirigami 2.2 as Kirigami T.Menu { id: control @@ -70,8 +70,8 @@ radius: 2 implicitWidth: 150 implicitHeight: 40 - color: StylePrivate.SystemPaletteSingleton.window(control.enabled) - property color borderColor: StylePrivate.SystemPaletteSingleton.text(control.enabled) + color: Kirigami.Theme.backgroundColor + property color borderColor: Kirigami.Theme.textColor border.color: Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0.3) layer.enabled: true diff --git a/org.kde.desktop/MenuItem.qml b/org.kde.desktop/MenuItem.qml --- a/org.kde.desktop/MenuItem.qml +++ b/org.kde.desktop/MenuItem.qml @@ -22,7 +22,7 @@ import QtQuick 2.6 import QtQuick.Templates 2.0 as T -import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate +import org.kde.kirigami 2.2 as Kirigami T.MenuItem { id: controlRoot @@ -43,7 +43,7 @@ text: controlRoot.text font: controlRoot.font - color: controlRoot.hovered && !controlRoot.pressed ? StylePrivate.SystemPaletteSingleton.highlightedText(controlRoot.enabled) : StylePrivate.SystemPaletteSingleton.text(controlRoot.enabled) + color: controlRoot.hovered && !controlRoot.pressed ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor elide: Text.ElideRight visible: controlRoot.text horizontalAlignment: Text.AlignLeft @@ -64,7 +64,7 @@ Rectangle { anchors.fill: parent - color: StylePrivate.SystemPaletteSingleton.highlight(controlRoot.enabled) + color: Kirigami.Theme.highlightColor opacity: controlRoot.hovered && !controlRoot.pressed ? 1 : 0 Behavior on opacity { NumberAnimation { duration: 150 } } } diff --git a/org.kde.desktop/Popup.qml b/org.kde.desktop/Popup.qml --- a/org.kde.desktop/Popup.qml +++ b/org.kde.desktop/Popup.qml @@ -23,7 +23,7 @@ import QtQuick 2.6 import QtGraphicalEffects 1.0 import QtQuick.Templates 2.0 as T -import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate +import org.kde.kirigami 2.2 as Kirigami T.Popup { id: control @@ -62,8 +62,8 @@ background: Rectangle { radius: 2 - color: StylePrivate.SystemPaletteSingleton.window(control.enabled) - property color borderColor: StylePrivate.SystemPaletteSingleton.text(control.enabled) + color: Kirigami.Theme.backgroundColor + property color borderColor: Kirigami.Theme.textColor border.color: Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0.3) layer.enabled: true diff --git a/org.kde.desktop/RadioButton.qml b/org.kde.desktop/RadioButton.qml --- a/org.kde.desktop/RadioButton.qml +++ b/org.kde.desktop/RadioButton.qml @@ -23,7 +23,7 @@ import QtQuick 2.6 import QtQuick.Templates 2.0 as T import QtQuick.Controls 2.0 -import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate +import org.kde.kirigami 2.2 as Kirigami T.CheckBox { id: control @@ -36,7 +36,7 @@ baselineOffset: contentItem.y + contentItem.baselineOffset padding: 1 - spacing: Math.round(StylePrivate.TextSingleton.height / 8) + spacing: Kirigami.Units.smallSpacing hoverEnabled: true @@ -56,7 +56,7 @@ opacity: control.enabled ? 1 : 0.6 text: control.text font: control.font - color: StylePrivate.SystemPaletteSingleton.text(control.enabled) + color: Kirigami.Theme.textColor elide: Text.ElideRight visible: control.text horizontalAlignment: Text.AlignLeft diff --git a/org.kde.desktop/RadioDelegate.qml b/org.kde.desktop/RadioDelegate.qml --- a/org.kde.desktop/RadioDelegate.qml +++ b/org.kde.desktop/RadioDelegate.qml @@ -21,8 +21,8 @@ import QtQuick 2.5 -import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate import QtQuick.Templates 2.0 as T +import org.kde.kirigami 2.2 as Kirigami import "private" T.RadioDelegate { @@ -43,7 +43,7 @@ text: controlRoot.text font: controlRoot.font - color: (controlRoot.pressed && !controlRoot.checked && !controlRoot.sectionDelegate) ? StylePrivate.SystemPaletteSingleton.highlightedText(controlRoot.enabled) : StylePrivate.SystemPaletteSingleton.text(controlRoot.enabled) + color: (controlRoot.pressed && !controlRoot.checked && !controlRoot.sectionDelegate) ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor elide: Text.ElideRight visible: controlRoot.text horizontalAlignment: Text.AlignLeft diff --git a/org.kde.desktop/RangeSlider.qml b/org.kde.desktop/RangeSlider.qml --- a/org.kde.desktop/RangeSlider.qml +++ b/org.kde.desktop/RangeSlider.qml @@ -23,7 +23,7 @@ import QtQuick 2.6 import QtQuick.Controls 2.0 import QtQuick.Templates 2.0 as T -import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate +import org.kde.kirigami 2.2 as Kirigami T.RangeSlider { id: control @@ -44,9 +44,9 @@ implicitWidth: 18 implicitHeight: 18 radius: width / 2 - property color borderColor: StylePrivate.SystemPaletteSingleton.text(control.enabled) - border.color: control.activeFocus ? StylePrivate.SystemPaletteSingleton.highlight(control.enabled) : Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0.3) - color: StylePrivate.SystemPaletteSingleton.window(control.enabled) + property color borderColor: Kirigami.Theme.textColor + border.color: control.activeFocus ? Kirigami.Theme.highlightColor : Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0.3) + color: Kirigami.Theme.backgroundColor Rectangle { z: -1 x: 1 @@ -65,9 +65,9 @@ implicitWidth: 18 implicitHeight: 18 radius: width / 2 - property color borderColor: StylePrivate.SystemPaletteSingleton.text(control.enabled) - border.color: control.activeFocus ? StylePrivate.SystemPaletteSingleton.highlight(control.enabled) : Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0.3) - color: StylePrivate.SystemPaletteSingleton.window(control.enabled) + property color borderColor: Kirigami.Theme.textColor + border.color: control.activeFocus ? Kirigami.Theme.highlightColor : Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0.3) + color: Kirigami.Theme.backgroundColor Rectangle { z: -1 x: 1 @@ -86,16 +86,16 @@ width: horizontal ? control.availableWidth : implicitWidth height: horizontal ? implicitHeight : control.availableHeight radius: Math.round(Math.min(width/2, height/2)) - property color bgColor: StylePrivate.SystemPaletteSingleton.text(control.enabled) + property color bgColor: Kirigami.Theme.textColor color: Qt.rgba(bgColor.r, bgColor.g, bgColor.b, 0.3) anchors.centerIn: parent Rectangle { x: parent.horizontal ? control.first.position * parent.width : 0 y: parent.horizontal ? 0 : control.second.visualPosition * parent.height + 6 width: parent.horizontal ? control.second.position * parent.width - control.first.position * parent.width - 6 : 6 height: parent.horizontal ? 6 : control.second.position * parent.height - control.first.position * parent.height - 6 - color: StylePrivate.SystemPaletteSingleton.highlight(control.enabled) + color: Kirigami.Theme.highlightColor } } } diff --git a/org.kde.desktop/Slider.qml b/org.kde.desktop/Slider.qml --- a/org.kde.desktop/Slider.qml +++ b/org.kde.desktop/Slider.qml @@ -23,9 +23,11 @@ import QtQuick 2.6 import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate import QtQuick.Templates 2.0 as T +import org.kde.kirigami 2.2 as Kirigami T.Slider { id: controlRoot + Kirigami.Theme.colorSet: Kirigami.Theme.Button implicitWidth: background.implicitWidth implicitHeight: background.implicitHeight diff --git a/org.kde.desktop/SpinBox.qml b/org.kde.desktop/SpinBox.qml --- a/org.kde.desktop/SpinBox.qml +++ b/org.kde.desktop/SpinBox.qml @@ -22,10 +22,13 @@ import QtQuick 2.6 import QtQuick.Templates 2.0 as T +import org.kde.kirigami 2.2 as Kirigami import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate T.SpinBox { id: controlRoot + Kirigami.Theme.colorSet: Kirigami.Theme.View + Kirigami.Theme.inherit: false implicitWidth: Math.max(48, contentItem.implicitWidth + 2 * padding + up.indicator.implicitWidth) implicitHeight: contentItem.implicitHeight + topPadding + bottomPadding @@ -49,9 +52,9 @@ opacity: controlRoot.enabled ? 1 : 0.3 font: controlRoot.font - color: StylePrivate.SystemPaletteSingleton.text(controlRoot.enabled) - selectionColor: StylePrivate.SystemPaletteSingleton.highlight(controlRoot.enabled) - selectedTextColor: StylePrivate.SystemPaletteSingleton.highlightedText(controlRoot.enabled) + color: Kirigami.Theme.textColor + selectionColor: Kirigami.Theme.highlightColor + selectedTextColor: Kirigami.Theme.highlightedTextColor horizontalAlignment: Qt.AlignHCenter verticalAlignment: Qt.AlignVCenter diff --git a/org.kde.desktop/Switch.qml b/org.kde.desktop/Switch.qml --- a/org.kde.desktop/Switch.qml +++ b/org.kde.desktop/Switch.qml @@ -22,7 +22,7 @@ import QtQuick 2.6 import QtQuick.Templates 2.0 as T -import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate +import org.kde.kirigami 2.2 as Kirigami T.CheckBox { id: control @@ -33,7 +33,7 @@ baselineOffset: contentItem.y + contentItem.baselineOffset padding: 1 - spacing: Math.round(StylePrivate.TextSingleton.height / 8) + spacing: Kirigami.Units.smallSpacing hoverEnabled: true @@ -54,7 +54,7 @@ opacity: control.enabled ? 1 : 0.6 text: control.text font: control.font - color: StylePrivate.SystemPaletteSingleton.text(control.enabled) + color: Kirigami.Theme.textColor elide: Text.ElideRight visible: control.text horizontalAlignment: Text.AlignLeft diff --git a/org.kde.desktop/SwitchDelegate.qml b/org.kde.desktop/SwitchDelegate.qml --- a/org.kde.desktop/SwitchDelegate.qml +++ b/org.kde.desktop/SwitchDelegate.qml @@ -21,7 +21,7 @@ import QtQuick 2.5 -import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate +import org.kde.kirigami 2.2 as Kirigami import QtQuick.Templates 2.0 as T import "private" @@ -43,7 +43,7 @@ text: controlRoot.text font: controlRoot.font - color: (controlRoot.pressed && !controlRoot.checked && !controlRoot.sectionDelegate) ? StylePrivate.SystemPaletteSingleton.highlightedText(controlRoot.enabled) : StylePrivate.SystemPaletteSingleton.text(controlRoot.enabled) + color: (controlRoot.pressed && !controlRoot.checked && !controlRoot.sectionDelegate) ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor elide: Text.ElideRight visible: controlRoot.text horizontalAlignment: Text.AlignLeft diff --git a/org.kde.desktop/TabBar.qml b/org.kde.desktop/TabBar.qml --- a/org.kde.desktop/TabBar.qml +++ b/org.kde.desktop/TabBar.qml @@ -22,11 +22,15 @@ import QtQuick 2.6 import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate +import org.kde.kirigami 2.2 as Kirigami import QtQuick.Templates 2.0 as T T.TabBar { id: controlRoot + Kirigami.Theme.colorSet: Kirigami.Theme.Button + Kirigami.Theme.inherit: false + implicitWidth: contentItem.implicitWidth implicitHeight: contentItem.implicitHeight @@ -70,7 +74,7 @@ top : controlRoot.position == T.TabBar.Header ? undefined : parent.top } height: 1 - color: StylePrivate.SystemPaletteSingleton.text(controlRoot.enabled) + color: Kirigami.Theme.textColor opacity: 0.4 } } diff --git a/org.kde.desktop/TextArea.qml b/org.kde.desktop/TextArea.qml --- a/org.kde.desktop/TextArea.qml +++ b/org.kde.desktop/TextArea.qml @@ -23,10 +23,13 @@ import QtQuick 2.6 import QtQuick.Window 2.1 import QtQuick.Templates 2.0 as T +import org.kde.kirigami 2.2 as Kirigami import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate T.TextArea { id: controlRoot + Kirigami.Theme.colorSet: Kirigami.Theme.View + Kirigami.Theme.inherit: false implicitWidth: Math.max(contentWidth + leftPadding + rightPadding, background ? background.implicitWidth : 0, @@ -37,9 +40,9 @@ padding: 6 - color: StylePrivate.SystemPaletteSingleton.text(controlRoot.enabled) - selectionColor: StylePrivate.SystemPaletteSingleton.highlight(controlRoot.enabled) - selectedTextColor: StylePrivate.SystemPaletteSingleton.highlightedText(controlRoot.enabled) + color: Kirigami.Theme.textColor + selectionColor: Kirigami.Theme.highlightColor + selectedTextColor: Kirigami.Theme.highlightedTextColor wrapMode: Text.WordWrap verticalAlignment: TextEdit.AlignTop //Text.NativeRendering is broken on non integer pixel ratios @@ -55,7 +58,7 @@ text: controlRoot.placeholderText font: controlRoot.font - color: StylePrivate.SystemPaletteSingleton.text(false) + color: Kirigami.Theme.disabledTextColor horizontalAlignment: controlRoot.horizontalAlignment verticalAlignment: controlRoot.verticalAlignment visible: !controlRoot.length && !controlRoot.preeditText && (!controlRoot.activeFocus || controlRoot.horizontalAlignment !== Qt.AlignHCenter) diff --git a/org.kde.desktop/TextField.qml b/org.kde.desktop/TextField.qml --- a/org.kde.desktop/TextField.qml +++ b/org.kde.desktop/TextField.qml @@ -24,10 +24,13 @@ import QtQuick.Window 2.1 import QtQuick.Controls 2.0 as Controls import QtQuick.Templates 2.0 as T +import org.kde.kirigami 2.2 as Kirigami import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate T.TextField { id: controlRoot + Kirigami.Theme.colorSet: Kirigami.Theme.View + Kirigami.Theme.inherit: false implicitWidth: Math.max(200, placeholderText ? placeholder.implicitWidth + leftPadding + rightPadding : 0) @@ -38,9 +41,9 @@ padding: 6 - color: StylePrivate.SystemPaletteSingleton.text(controlRoot.enabled) - selectionColor: StylePrivate.SystemPaletteSingleton.highlight(controlRoot.enabled) - selectedTextColor: StylePrivate.SystemPaletteSingleton.highlightedText(controlRoot.enabled) + color: controlRoot.enabled ? Kirigami.Theme.textColor : Kirigami.Theme.disabledTextColor + selectionColor: Kirigami.Theme.highlightColor + selectedTextColor: Kirigami.Theme.highlightedTextColor verticalAlignment: TextInput.AlignVCenter //Text.NativeRendering is broken on non integer pixel ratios renderType: Window.devicePixelRatio % 1 !== 0 ? Text.QtRendering : Text.NativeRendering @@ -55,7 +58,7 @@ text: controlRoot.placeholderText font: controlRoot.font - color: StylePrivate.SystemPaletteSingleton.text(false) + color: Kirigami.Theme.disabledTextColor horizontalAlignment: controlRoot.horizontalAlignment verticalAlignment: controlRoot.verticalAlignment visible: !controlRoot.length && !controlRoot.preeditText && (!controlRoot.activeFocus || controlRoot.horizontalAlignment !== Qt.AlignHCenter) diff --git a/org.kde.desktop/ToolBar.qml b/org.kde.desktop/ToolBar.qml --- a/org.kde.desktop/ToolBar.qml +++ b/org.kde.desktop/ToolBar.qml @@ -22,7 +22,7 @@ import QtQuick 2.6 import QtQuick.Templates 2.0 as T -import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate +import org.kde.kirigami 2.2 as Kirigami T.ToolBar { id: controlRoot @@ -37,17 +37,14 @@ background: Rectangle { implicitHeight: 40 - color: StylePrivate.SystemPaletteSingleton.window(controlRoot.enabled) - Rectangle { + color: Kirigami.Theme.backgroundColor + Kirigami.Separator { anchors { left: parent.left right: parent.right top: controlRoot.parent.footer && controlRoot.parent.footer == controlRoot ? parent.top : undefined - bottom: controlRoot.parent.footer && controlRoot.parent.footer == controlRoot ? undefined : parent.top + bottom: controlRoot.parent.footer && controlRoot.parent.footer == controlRoot ? undefined : parent.bottom } - height: 1 - color: StylePrivate.SystemPaletteSingleton.text(controlRoot.enabled) - opacity: 0.3 } } } diff --git a/org.kde.desktop/ToolButton.qml b/org.kde.desktop/ToolButton.qml --- a/org.kde.desktop/ToolButton.qml +++ b/org.kde.desktop/ToolButton.qml @@ -22,10 +22,13 @@ import QtQuick 2.6 import QtQuick.Templates 2.0 as T +import org.kde.kirigami 2.2 as Kirigami import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate T.ToolButton { id: controlRoot + Kirigami.Theme.colorSet: flat ? Kirigami.Theme.Window : Kirigami.Theme.Button + Kirigami.Theme.inherit: flat implicitWidth: background.implicitWidth implicitHeight: background.implicitHeight diff --git a/org.kde.desktop/ToolTip.qml b/org.kde.desktop/ToolTip.qml --- a/org.kde.desktop/ToolTip.qml +++ b/org.kde.desktop/ToolTip.qml @@ -24,11 +24,15 @@ import QtGraphicalEffects 1.0 import QtQuick.Controls 2.0 as Controls import QtQuick.Templates 2.0 as T -import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate +import org.kde.kirigami 2.2 as Kirigami T.ToolTip { id: controlRoot + //TODO: add tooltip to Kirigami Theme + Kirigami.Theme.colorSet: Kirigami.Theme.Button + Kirigami.Theme.inherit: false + x: parent ? (parent.width - implicitWidth) / 2 : 0 y: -implicitHeight - 3 @@ -43,14 +47,14 @@ contentItem: Controls.Label { text: controlRoot.text font: controlRoot.font - color: StylePrivate.SystemPaletteSingleton.base(controlRoot.enabled) + color: Kirigami.Theme.textColor } background: Rectangle { radius: 3 opacity: 0.95 - color: StylePrivate.SystemPaletteSingleton.text(controlRoot.enabled) + color: Kirigami.Theme.backgroundColor layer.enabled: true layer.effect: DropShadow { transparentBorder: true diff --git a/org.kde.desktop/private/DefaultListItemBackground.qml b/org.kde.desktop/private/DefaultListItemBackground.qml --- a/org.kde.desktop/private/DefaultListItemBackground.qml +++ b/org.kde.desktop/private/DefaultListItemBackground.qml @@ -21,16 +21,16 @@ import QtQuick 2.1 -import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate +import org.kde.kirigami 2.2 as Kirigami Rectangle { id: background - color: highlighted || (controlRoot.pressed && !controlRoot.checked && !controlRoot.sectionDelegate) ? StylePrivate.SystemPaletteSingleton.highlight(controlRoot.enabled) : StylePrivate.SystemPaletteSingleton.base(controlRoot.enabled) + color: highlighted || (controlRoot.pressed && !controlRoot.checked && !controlRoot.sectionDelegate) ? Kirigami.Theme.highlightColor : Kirigami.Theme.backgroundColor visible: controlRoot.ListView.view ? controlRoot.ListView.view.highlight === null : true Rectangle { anchors.fill: parent - color: StylePrivate.SystemPaletteSingleton.highlight(controlRoot.enabled) + color: Kirigami.Theme.highlightColor opacity: controlRoot.hovered && !controlRoot.pressed ? 0.2 : 0 Behavior on opacity { NumberAnimation { duration: 150 } } } diff --git a/plugin/CMakeLists.txt b/plugin/CMakeLists.txt --- a/plugin/CMakeLists.txt +++ b/plugin/CMakeLists.txt @@ -15,9 +15,7 @@ endif() add_library(qqc2desktopstyleplugin SHARED ${qqc2desktopstyle_SRCS}) -target_link_libraries(qqc2desktopstyleplugin Qt5::Core Qt5::Qml Qt5::Quick Qt5::Gui Qt5::Widgets) +target_link_libraries(qqc2desktopstyleplugin Qt5::Core Qt5::Qml Qt5::Quick Qt5::Gui Qt5::Widgets KF5::Kirigami2) install(TARGETS qqc2desktopstyleplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/qqc2desktopstyle/private) -install(FILES SystemPaletteSingleton.qml DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/qqc2desktopstyle/private) -install(FILES TextSingleton.qml DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/qqc2desktopstyle/private) install(FILES qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/qqc2desktopstyle/private) diff --git a/plugin/SystemPaletteSingleton.qml b/plugin/SystemPaletteSingleton.qml deleted file mode 100644 --- a/plugin/SystemPaletteSingleton.qml +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2017 Marco Martin - * Copyright 2017 The Qt Company Ltd. - * - * GNU Lesser General Public License Usage - * Alternatively, this file may be used under the terms of the GNU Lesser - * General Public License version 3 as published by the Free Software - * Foundation and appearing in the file LICENSE.LGPLv3 included in the - * packaging of this file. Please review the following information to - * ensure the GNU Lesser General Public License version 3 requirements - * will be met: https://www.gnu.org/licenses/lgpl.html. - * - * GNU General Public License Usage - * Alternatively, this file may be used under the terms of the GNU - * General Public License version 2.0 or later as published by the Free - * Software Foundation and appearing in the file LICENSE.GPL included in - * the packaging of this file. Please review the following information to - * ensure the GNU General Public License version 2.0 requirements will be - * met: http://www.gnu.org/licenses/gpl-2.0.html. - */ - -pragma Singleton -import QtQuick 2.2 - -QtObject { - property SystemPalette active: SystemPalette { colorGroup: SystemPalette.Active } - property SystemPalette disabled: SystemPalette { colorGroup: SystemPalette.Disabled } - - function alternateBase(enabled) { return enabled ? active.alternateBase : disabled.alternateBase } - function base(enabled) { return enabled ? active.base : disabled.base } - function button(enabled) { return enabled ? active.button : disabled.button } - function buttonText(enabled) { return enabled ? active.buttonText : disabled.buttonText } - function dark(enabled) { return enabled ? active.dark : disabled.dark } - function highlight(enabled) { return enabled ? active.highlight : disabled.highlight } - function highlightedText(enabled) { return enabled ? active.highlightedText : disabled.highlightedText } - function light(enabled) { return enabled ? active.light : disabled.light } - function mid(enabled) { return enabled ? active.mid : disabled.mid } - function midlight(enabled) { return enabled ? active.midlight : disabled.midlight } - function shadow(enabled) { return enabled ? active.shadow : disabled.shadow } - function text(enabled) { return enabled ? active.text : disabled.text } - function window(enabled) { return enabled ? active.window : disabled.window } - function windowText(enabled) { return enabled ? active.windowText : disabled.windowText } -} diff --git a/plugin/TextSingleton.qml b/plugin/TextSingleton.qml deleted file mode 100644 --- a/plugin/TextSingleton.qml +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2017 Marco Martin - * Copyright 2017 The Qt Company Ltd. - * - * GNU Lesser General Public License Usage - * Alternatively, this file may be used under the terms of the GNU Lesser - * General Public License version 3 as published by the Free Software - * Foundation and appearing in the file LICENSE.LGPLv3 included in the - * packaging of this file. Please review the following information to - * ensure the GNU Lesser General Public License version 3 requirements - * will be met: https://www.gnu.org/licenses/lgpl.html. - * - * GNU General Public License Usage - * Alternatively, this file may be used under the terms of the GNU - * General Public License version 2.0 or later as published by the Free - * Software Foundation and appearing in the file LICENSE.GPL included in - * the packaging of this file. Please review the following information to - * ensure the GNU General Public License version 2.0 requirements will be - * met: http://www.gnu.org/licenses/gpl-2.0.html. - */ - -pragma Singleton -import QtQuick 2.2 -Text { -} diff --git a/plugin/kquickstyleitem.cpp b/plugin/kquickstyleitem.cpp --- a/plugin/kquickstyleitem.cpp +++ b/plugin/kquickstyleitem.cpp @@ -54,6 +54,7 @@ #include "qsgdefaultninepatchnode_p.h" #endif +#include KQuickStyleItem::KQuickStyleItem(QQuickItem *parent) : QQuickItem(parent), @@ -160,6 +161,18 @@ void KQuickStyleItem::initStyleOption() { + if (!m_theme) { + m_theme = static_cast(qmlAttachedPropertiesObject(this, true)); + Q_ASSERT(m_theme); + + connect(m_theme, &Kirigami::PlatformTheme::colorsChanged, this, [this]() { + //we need to reset the palette event if Qt::AA_SetPalette attribute has been set + m_styleoption->palette = m_theme->palette(); + updateItem(); + }); + } + Q_ASSERT(m_theme); + if (m_styleoption) m_styleoption->state = 0; @@ -694,7 +707,7 @@ if (QCoreApplication::testAttribute(Qt::AA_SetPalette)) return; - m_styleoption->palette = QApplication::palette(classNameForItem()); + m_styleoption->palette = m_theme->palette(); } /* diff --git a/plugin/kquickstyleitem_p.h b/plugin/kquickstyleitem_p.h --- a/plugin/kquickstyleitem_p.h +++ b/plugin/kquickstyleitem_p.h @@ -51,6 +51,10 @@ class QWidget; class QStyleOption; +namespace Kirigami { + class PlatformTheme; +} + class QQuickTableRowImageProvider1 : public QQuickImageProvider { public: @@ -270,6 +274,7 @@ qreal baselineOffset(); protected: + Kirigami::PlatformTheme *m_theme = nullptr; QStyleOption *m_styleoption; QPointer m_control; Type m_itemType; diff --git a/plugin/qmldir b/plugin/qmldir --- a/plugin/qmldir +++ b/plugin/qmldir @@ -1,5 +1,3 @@ module org.kde.qqc2desktopstyle.private plugin qqc2desktopstyleplugin -singleton SystemPaletteSingleton 1.0 SystemPaletteSingleton.qml -singleton TextSingleton 1.0 TextSingleton.qml