Hello community, here is the log from the commit of package applet-window-appmenu for openSUSE:Factory checked in at 2019-11-25 11:25:17 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/applet-window-appmenu (Old) and /work/SRC/openSUSE:Factory/.applet-window-appmenu.new.26869 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "applet-window-appmenu" Mon Nov 25 11:25:17 2019 rev:5 rq:750569 version:0.6.0 Changes: -------- --- /work/SRC/openSUSE:Factory/applet-window-appmenu/applet-window-appmenu.changes 2019-08-13 13:15:52.213497289 +0200 +++ /work/SRC/openSUSE:Factory/.applet-window-appmenu.new.26869/applet-window-appmenu.changes 2019-11-25 11:25:25.914093626 +0100 @@ -1,0 +2,12 @@ +Sun Nov 24 15:53:13 UTC 2019 - Cor Blom <corne...@solcon.nl> + +- Update to version 0.6.0: + * new option to support color schemes for menus. For Latte a new + option to colorize the menus based on the current window color + scheme is already present. + * release menu item hovering when not needed any more + * new option to maximize/restore active window when used in + plasma panels [@ Taras Fomin] +- Add cmake(KDecoration2) >= 5.12 to BuildRequires + +------------------------------------------------------------------- Old: ---- applet-window-appmenu-0.5.1.tar.gz New: ---- applet-window-appmenu-0.6.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ applet-window-appmenu.spec ++++++ --- /var/tmp/diff_new_pack.xU1wpw/_old 2019-11-25 11:25:26.358093546 +0100 +++ /var/tmp/diff_new_pack.xU1wpw/_new 2019-11-25 11:25:26.362093546 +0100 @@ -20,7 +20,7 @@ %define qt5_version 5.9 Name: applet-window-appmenu -Version: 0.5.1 +Version: 0.6.0 Release: 0 Summary: Plasma 5 applet to show the window appmenu License: GPL-2.0-or-later @@ -40,6 +40,7 @@ BuildRequires: libSM-devel BuildRequires: plasma-framework-devel >= %{kf5_version} BuildRequires: plasma5-workspace-devel >= 5.12 +BuildRequires: cmake(KDecoration2) >= 5.12 BuildRequires: cmake(Qt5Core) >= %{qt5_version} BuildRequires: cmake(Qt5DBus) >= %{qt5_version} BuildRequires: cmake(Qt5Quick) >= %{qt5_version} ++++++ applet-window-appmenu-0.5.1.tar.gz -> applet-window-appmenu-0.6.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/CHANGELOG.md new/applet-window-appmenu-0.6.0/CHANGELOG.md --- old/applet-window-appmenu-0.5.1/CHANGELOG.md 2019-08-03 07:36:23.000000000 +0200 +++ new/applet-window-appmenu-0.6.0/CHANGELOG.md 2019-11-24 08:24:26.000000000 +0100 @@ -1,5 +1,11 @@ ### CHANGELOG +#### Version 0.6.0 + +* new option to support color schemes for menus. For Latte a new option to colorize the menus based on the current window color scheme is already present. +* release menu item hovering when not needed any more +* new option to maximize/restore active window when used in plasma panels [@Taras Fomin] + #### Version 0.5.1 * fix buttons vertical positioning. Previously there were cases that the buttons had 1px. difference with the surrounding applets diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/CMakeLists.txt new/applet-window-appmenu-0.6.0/CMakeLists.txt --- old/applet-window-appmenu-0.5.1/CMakeLists.txt 2019-08-03 07:36:23.000000000 +0200 +++ new/applet-window-appmenu-0.6.0/CMakeLists.txt 2019-11-24 08:24:26.000000000 +0100 @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.0 FATAL_ERROR) set(CMAKE_CXX_STANDARD 14) -set(VERSION 0.5.1) +set(VERSION 0.6.0) set(AUTHOR "Michail Vourlakos") set(EMAIL "mvourla...@gmail.com") @@ -16,7 +16,8 @@ set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Quick Widgets DBus) -find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Plasma WindowSystem) +find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Plasma WindowSystem ConfigWidgets) +find_package(KDecoration2 REQUIRED) include(ECMQtDeclareLoggingCategory) include(KDECMakeSettings) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/INSTALLATION.md new/applet-window-appmenu-0.6.0/INSTALLATION.md --- old/applet-window-appmenu-0.5.1/INSTALLATION.md 2019-08-03 07:36:23.000000000 +0200 +++ new/applet-window-appmenu-0.6.0/INSTALLATION.md 2019-11-24 08:24:26.000000000 +0100 @@ -9,7 +9,7 @@ ### KDE Neon ``` -sudo apt install make cmake extra-cmake-modules qtdeclarative5-dev libkf5plasma-dev libqt5x11extras5-dev g++ libsm-dev +sudo apt install make cmake extra-cmake-modules qtdeclarative5-dev libkf5plasma-dev libqt5x11extras5-dev g++ libsm-dev libkf5configwidgets-dev libkdecorations2-dev ``` ### openSUSE Leap 15 / Tumbleweed diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/README.md new/applet-window-appmenu-0.6.0/README.md --- old/applet-window-appmenu-0.5.1/README.md 2019-08-03 07:36:23.000000000 +0200 +++ new/applet-window-appmenu-0.6.0/README.md 2019-11-24 08:24:26.000000000 +0100 @@ -25,7 +25,7 @@ **Qt elements**: Quick Widgets DBus -**KF5 elements**: Plasma WindowSystem extra-cmake-modules +**KF5 elements**: Plasma WindowSystem KDecoration2 extra-cmake-modules **X11 libraries**: XCB RandR diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/lib/CMakeLists.txt new/applet-window-appmenu-0.6.0/lib/CMakeLists.txt --- old/applet-window-appmenu-0.5.1/lib/CMakeLists.txt 2019-08-03 07:36:23.000000000 +0200 +++ new/applet-window-appmenu-0.6.0/lib/CMakeLists.txt 2019-11-24 08:24:26.000000000 +0100 @@ -1,5 +1,6 @@ set(appmenuapplet_SRCS appmenuapplet.cpp + decorationpalette.cpp ) add_library(plasma_applet_windowappmenu MODULE ${appmenuapplet_SRCS}) @@ -10,7 +11,10 @@ Qt5::Widgets Qt5::Quick Qt5::DBus + KF5::ConfigWidgets KF5::Plasma - KF5::WindowSystem) + KF5::WindowSystem + KDecoration2::KDecoration + KDecoration2::KDecoration2Private) install(TARGETS plasma_applet_windowappmenu DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/applets) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/lib/appmenuapplet.cpp new/applet-window-appmenu-0.6.0/lib/appmenuapplet.cpp --- old/applet-window-appmenu-0.5.1/lib/appmenuapplet.cpp 2019-08-03 07:36:23.000000000 +0200 +++ new/applet-window-appmenu-0.6.0/lib/appmenuapplet.cpp 2019-11-24 08:24:26.000000000 +0100 @@ -20,6 +20,7 @@ */ #include "appmenuapplet.h" +#include "decorationpalette.h" #include "../plugin/appmenumodel.h" #include <QAction> @@ -52,8 +53,8 @@ //if we're the first, regster the service if (s_refs == 1) { QDBusConnection::sessionBus().interface()->registerService(viewService(), - QDBusConnectionInterface::QueueService, - QDBusConnectionInterface::DontAllowReplacement); + QDBusConnectionInterface::QueueService, + QDBusConnectionInterface::DontAllowReplacement); } /*it registers or unregisters the service when the destroyed value of the applet change, @@ -73,8 +74,8 @@ //if we're the first, regster the service if (++s_refs == 1) { QDBusConnection::sessionBus().interface()->registerService(viewService(), - QDBusConnectionInterface::QueueService, - QDBusConnectionInterface::DontAllowReplacement); + QDBusConnectionInterface::QueueService, + QDBusConnectionInterface::DontAllowReplacement); } } }); @@ -127,6 +128,29 @@ } } +QString AppMenuApplet::menuColorScheme() const +{ + return m_menuColorScheme; +} + +void AppMenuApplet::setMenuColorScheme(const QString &scheme) +{ + if (m_menuColorScheme == scheme) { + return; + } + + m_menuColorScheme = scheme; + + if (!m_menuColorScheme.isEmpty()) { + m_decorationPalette->deleteLater(); + m_decorationPalette = new DecorationPalette(scheme);\ + } else { + m_decorationPalette->deleteLater(); + } + + emit menuColorSchemeChanged(); +} + QQuickItem *AppMenuApplet::buttonGrid() const { return m_buttonGrid; @@ -166,6 +190,10 @@ } } + if (menu && m_decorationPalette) { + menu->setPalette(m_decorationPalette->palette()); + } + return menu; } @@ -306,6 +334,12 @@ } emit requestActivateIndex(buttonIndex); + } else if (event->type() == QEvent::Leave) { + if (!m_buttonGrid || !m_buttonGrid->window()) { + return false; + } + + m_buttonGrid->setProperty("currentIndex", -1); } return false; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/lib/appmenuapplet.h new/applet-window-appmenu-0.6.0/lib/appmenuapplet.h --- old/applet-window-appmenu-0.5.1/lib/appmenuapplet.h 2019-08-03 07:36:23.000000000 +0200 +++ new/applet-window-appmenu-0.6.0/lib/appmenuapplet.h 2019-11-24 08:24:26.000000000 +0100 @@ -28,6 +28,7 @@ class QQuickItem; class QMenu; class AppMenuModel; +class DecorationPalette; class AppMenuApplet : public Plasma::Applet { @@ -37,6 +38,8 @@ Q_PROPERTY(int currentIndex READ currentIndex NOTIFY currentIndexChanged) + Q_PROPERTY(QString menuColorScheme READ menuColorScheme WRITE setMenuColorScheme NOTIFY menuColorSchemeChanged) + Q_PROPERTY(QQuickItem *buttonGrid READ buttonGrid WRITE setButtonGrid NOTIFY buttonGridChanged) Q_PROPERTY(QObject *model READ model WRITE setModel NOTIFY modelChanged) @@ -64,11 +67,15 @@ int view() const; void setView(int type); + QString menuColorScheme() const; + void setMenuColorScheme(const QString &scheme); + signals: void modelChanged(); void viewChanged(); void currentIndexChanged(); void buttonGridChanged(); + void menuColorSchemeChanged(); void requestActivateIndex(int index); public slots: @@ -82,6 +89,8 @@ void setCurrentIndex(int currentIndex); void onMenuAboutToHide(); + QString m_menuColorScheme; + QPointer<DecorationPalette> m_decorationPalette; int m_currentIndex = -1; int m_viewType = FullView; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/lib/decorationpalette.cpp new/applet-window-appmenu-0.6.0/lib/decorationpalette.cpp --- old/applet-window-appmenu-0.5.1/lib/decorationpalette.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/applet-window-appmenu-0.6.0/lib/decorationpalette.cpp 2019-11-24 08:24:26.000000000 +0100 @@ -0,0 +1,142 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright 2014 Martin Gräßlin <mgraess...@kde.org> +Copyright 2014 Hugo Pereira Da Costa <hugo.pere...@free.fr> +Copyright 2015 Mika Allan Rauhala <mika.allan.rauh...@gmail.com> + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +*********************************************************************/ + +#include "decorationpalette.h" + +#include <KConfigGroup> +#include <KSharedConfig> +#include <KColorScheme> + +#include <QDebug> +#include <QPalette> +#include <QFileInfo> +#include <QStandardPaths> + + +DecorationPalette::DecorationPalette(const QString &colorScheme) + : m_colorScheme(QFileInfo(colorScheme).isAbsolute() + ? colorScheme + : QStandardPaths::locate(QStandardPaths::GenericConfigLocation, colorScheme)) +{ + if (m_colorScheme.isEmpty() && colorScheme == QStringLiteral("kdeglobals")) { + // kdeglobals doesn't exist so create it. This is needed to monitor it using QFileSystemWatcher. + auto config = KSharedConfig::openConfig(colorScheme, KConfig::SimpleConfig); + KConfigGroup wmConfig(config, QStringLiteral("WM")); + wmConfig.writeEntry("FakeEntryToKeepThisGroup", true); + config->sync(); + + m_colorScheme = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, colorScheme); + } + + m_watcher.addPath(m_colorScheme); + connect(&m_watcher, &QFileSystemWatcher::fileChanged, [this]() { + m_watcher.addPath(m_colorScheme); + update(); + emit changed(); + }); + + update(); +} + +bool DecorationPalette::isValid() const +{ + return m_activeTitleBarColor.isValid(); +} + +QColor DecorationPalette::color(KDecoration2::ColorGroup group, KDecoration2::ColorRole role) const +{ + using KDecoration2::ColorRole; + using KDecoration2::ColorGroup; + + switch (role) { + case ColorRole::Frame: + switch (group) { + case ColorGroup::Active: + return m_activeFrameColor; + + case ColorGroup::Inactive: + return m_inactiveFrameColor; + + default: + return QColor(); + } + + case ColorRole::TitleBar: + switch (group) { + case ColorGroup::Active: + return m_activeTitleBarColor; + + case ColorGroup::Inactive: + return m_inactiveTitleBarColor; + + default: + return QColor(); + } + + case ColorRole::Foreground: + switch (group) { + case ColorGroup::Active: + return m_activeForegroundColor; + + case ColorGroup::Inactive: + return m_inactiveForegroundColor; + + case ColorGroup::Warning: + return m_warningForegroundColor; + + default: + return QColor(); + } + + default: + return QColor(); + } +} + +QPalette DecorationPalette::palette() const +{ + return m_palette; +} + +void DecorationPalette::update() +{ + auto config = KSharedConfig::openConfig(m_colorScheme, KConfig::SimpleConfig); + KConfigGroup wmConfig(config, QStringLiteral("WM")); + + if (!wmConfig.exists() && !m_colorScheme.endsWith(QStringLiteral("/kdeglobals"))) { + qDebug() << "Invalid color scheme" << m_colorScheme << "lacks WM group"; + return; + } + + m_palette = KColorScheme::createApplicationPalette(config); + + m_activeFrameColor = wmConfig.readEntry("frame", m_palette.color(QPalette::Active, QPalette::Background)); + m_inactiveFrameColor = wmConfig.readEntry("inactiveFrame", m_activeFrameColor); + m_activeTitleBarColor = wmConfig.readEntry("activeBackground", m_palette.color(QPalette::Active, QPalette::Highlight)); + m_inactiveTitleBarColor = wmConfig.readEntry("inactiveBackground", m_inactiveFrameColor); + m_activeForegroundColor = wmConfig.readEntry("activeForeground", m_palette.color(QPalette::Active, QPalette::HighlightedText)); + m_inactiveForegroundColor = wmConfig.readEntry("inactiveForeground", m_activeForegroundColor.darker()); + + KConfigGroup windowColorsConfig(config, QStringLiteral("Colors:Window")); + m_warningForegroundColor = windowColorsConfig.readEntry("ForegroundNegative", QColor(237, 21, 2)); + +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/lib/decorationpalette.h new/applet-window-appmenu-0.6.0/lib/decorationpalette.h --- old/applet-window-appmenu-0.5.1/lib/decorationpalette.h 1970-01-01 01:00:00.000000000 +0100 +++ new/applet-window-appmenu-0.6.0/lib/decorationpalette.h 2019-11-24 08:24:26.000000000 +0100 @@ -0,0 +1,63 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright 2014 Martin Gräßlin <mgraess...@kde.org> +Copyright 2014 Hugo Pereira Da Costa <hugo.pere...@free.fr> +Copyright 2015 Mika Allan Rauhala <mika.allan.rauh...@gmail.com> + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +*********************************************************************/ + +#ifndef KWIN_DECORATION_PALETTE_H +#define KWIN_DECORATION_PALETTE_H + +#include <KDecoration2/DecorationSettings> +#include <QFileSystemWatcher> +#include <QPalette> + + +class DecorationPalette : public QObject +{ + Q_OBJECT +public: + DecorationPalette(const QString &colorScheme); + + bool isValid() const; + + QColor color(KDecoration2::ColorGroup group, KDecoration2::ColorRole role) const; + QPalette palette() const; + +Q_SIGNALS: + void changed(); +private: + void update(); + + QString m_colorScheme; + QFileSystemWatcher m_watcher; + + QPalette m_palette; + + QColor m_activeTitleBarColor; + QColor m_inactiveTitleBarColor; + + QColor m_activeFrameColor; + QColor m_inactiveFrameColor; + + QColor m_activeForegroundColor; + QColor m_inactiveForegroundColor; + QColor m_warningForegroundColor; +}; + +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/package/contents/config/main.xml new/applet-window-appmenu-0.6.0/package/contents/config/main.xml --- old/applet-window-appmenu-0.5.1/package/contents/config/main.xml 2019-08-03 07:36:23.000000000 +0200 +++ new/applet-window-appmenu-0.6.0/package/contents/config/main.xml 2019-11-24 08:24:26.000000000 +0100 @@ -38,6 +38,15 @@ <default>false</default> <label>will become hidden in favour of appmenu when the mouse hovers the applet</label> </entry> + <entry name="supportsActiveWindowSchemes" type="Bool"> + <default>false</default> + <label>current option will become available in such case</label> + </entry> + <entry name="selectedScheme" type="String"> + <default>_default_</default> + <label>current scheme used</label> + </entry> + <entry name="containmentType" type="Enum"> <choices> <choice name="Loading"/> @@ -47,5 +56,10 @@ <label>it helps to enable/disable options that are specific to plasma or Latte panels</label> <default>0</default> </entry> + + <entry name="toggleMaximizedOnDoubleClick" type="Bool"> + <default>false</default> + <label>If true, toggles active window maximized/restored on double click</label> + </entry> </group> </kcfg> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/package/contents/ui/PaintedToolButton.qml new/applet-window-appmenu-0.6.0/package/contents/ui/PaintedToolButton.qml --- old/applet-window-appmenu-0.5.1/package/contents/ui/PaintedToolButton.qml 2019-08-03 07:36:23.000000000 +0200 +++ new/applet-window-appmenu-0.6.0/package/contents/ui/PaintedToolButton.qml 2019-11-24 08:24:26.000000000 +0100 @@ -36,7 +36,17 @@ //! HACK: in order to identify containsMouse correctly at all cases, //! best way to reproduce the issue is in Unity mode that many buttons //! thought that they containMouse even though they did not - property bool containsMouse: inFullView ? buttonGrid.currentIndex === buttonIndex : buttonMouseArea.containsMouse + property bool containsMouse: { + if (inFullView) { + if (plasmoid.nativeInterface.currentIndex > -1) { + return plasmoid.nativeInterface.currentIndex === buttonIndex; + } + + return buttonGrid.currentIndex === buttonIndex; + } + + return buttonMouseArea.containsMouse; + } readonly property bool menuOpened: plasmoid.nativeInterface.currentIndex === buttonIndex readonly property int shadow: 3 readonly property int implicitWidth: { @@ -67,6 +77,12 @@ signal scrolledUp(int step); signal scrolledDown(int step); + onMenuOpenedChanged: { + if (menuOpened) { + buttonGrid.currentIndex = buttonIndex + } + } + Rectangle { id: button anchors.fill: parent @@ -143,7 +159,7 @@ //! best way to reproduce the issue is in Unity mode that many buttons //! thought that they containMouse even though they did not onExited: { - if (inFullView) { + if (inFullView && buttonGrid.currentIndex === buttonIndex) { buttonGrid.currentIndex = -1; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/package/contents/ui/config/ColorsComboBox.qml new/applet-window-appmenu-0.6.0/package/contents/ui/config/ColorsComboBox.qml --- old/applet-window-appmenu-0.5.1/package/contents/ui/config/ColorsComboBox.qml 1970-01-01 01:00:00.000000000 +0100 +++ new/applet-window-appmenu-0.6.0/package/contents/ui/config/ColorsComboBox.qml 2019-11-24 08:24:26.000000000 +0100 @@ -0,0 +1,98 @@ +/* +* Copyright 2018 Michail Vourlakos <mvourla...@gmail.com> +* +* This file is part of applet-window-buttons +* +* Latte-Dock is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* Latte-Dock 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +import QtQuick 2.0 +import QtQuick.Controls 1.0 +import QtQuick.Controls 2.2 as Controls22 +import QtQuick.Layouts 1.0 + +Controls22.ComboBox{ + id: combobox + + Connections{ + target: popup + onClosed: root.forceActiveFocus(); + } + + delegate: MouseArea{ + width: combobox.width + height: combobox.height + hoverEnabled: true + + onClicked: { + combobox.currentIndex = index; + selectedScheme = model.file; + combobox.popup.close(); + } + + Rectangle{ + id:delegateBackground + anchors.fill: parent + color: { + if (containsMouse) { + return palette.highlight; + } + if (combobox.currentIndex === index) { + return selectedColor; + } + + return "transparent"; + } + + readonly property color selectedColor: Qt.rgba(palette.highlight.r, palette.highlight.g, palette.highlight.b, 0.5); + + RowLayout{ + id: delegateRow + height: parent.height + + Item{ + Layout.leftMargin: 2 + width: 1.25 * label.height + height: label.height + + opacity: file==="_default_" || file==="_current_" ? 0 : 1 + + Rectangle{ + width: height + height: 0.75 * label.height + color: backgroundColor + border.width: 1 + border.color: containsMouse || (combobox.currentIndex === index) ? palette.highlightedText : palette.text + + Rectangle{ + anchors.horizontalCenter: parent.right + anchors.verticalCenter: parent.bottom + width: parent.width + height: parent.height + color: textColor + border.width: parent.border.width + border.color: parent.border.color + } + } + } + + Label{ + id: label + text:display + color: containsMouse ? palette.highlightedText : palette.text + } + } + } + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/package/contents/ui/config/ConfigGeneral.qml new/applet-window-appmenu-0.6.0/package/contents/ui/config/ConfigGeneral.qml --- old/applet-window-appmenu-0.5.1/package/contents/ui/config/ConfigGeneral.qml 2019-08-03 07:36:23.000000000 +0200 +++ new/applet-window-appmenu-0.6.0/package/contents/ui/config/ConfigGeneral.qml 2019-11-24 08:24:26.000000000 +0100 @@ -25,6 +25,8 @@ import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.private.windowAppMenu 0.1 as AppMenuPrivate + Item { id: configGeneral @@ -33,15 +35,26 @@ property alias cfg_filterByActive: activeChk.checked property alias cfg_filterChildrenWindows: childrenChk.checked property alias cfg_filterByScreen: screenAwareChk.checked + property alias cfg_selectedScheme: configGeneral.selectedScheme property alias cfg_spacing: spacingSlider.value property alias cfg_showWindowTitleOnMouseExit: showWindowTitleChk.checked + property alias cfg_toggleMaximizedOnDoubleClick: toggleMaximizedChk.checked property bool disableSetting: plasmoid.formFactor === PlasmaCore.Types.Vertical + // used as bridge to communicate properly between configuration and ui + property string selectedScheme + // used from the ui readonly property real centerFactor: 0.3 readonly property int minimumWidth: 220 + AppMenuPrivate.SchemesModel { + id: schemesModel + + currentOptionIsShown: plasmoid.configuration.supportsActiveWindowSchemes + } + ColumnLayout { id:mainColumn spacing: units.largeSpacing @@ -83,6 +96,30 @@ GridLayout{ columns: 2 + + Controls.Label { + Layout.minimumWidth: Math.max(centerFactor * root.width, minimumWidth) + text: i18n("Menu Colors:") + horizontalAlignment: Text.AlignRight + } + + ColorsComboBox{ + id:colorsCmbBox + Layout.minimumWidth: 250 + Layout.preferredWidth: 0.3 * root.width + Layout.maximumWidth: 380 + + model: schemesModel + textRole: "display" + + Component.onCompleted: { + currentIndex = schemesModel.indexOf(plasmoid.configuration.selectedScheme); + } + } + } + + GridLayout{ + columns: 2 enabled: !compactViewRadioButton.checked Controls.Label{ @@ -129,6 +166,18 @@ visible: plasmoid.configuration.containmentType === 2 /*Latte Containment*/ enabled: plasmoid.configuration.windowTitleIsPresent } + + Controls.Label { + text: "" + visible: toggleMaximizedChk.visible + } + + Controls.CheckBox { + id: toggleMaximizedChk + text: i18n("Maximize/restore active window on double click") + visible: plasmoid.configuration.containmentType !== 2 /*non-Latte Containment*/ + enabled: fillWidthChk.checked + } } GridLayout{ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/package/contents/ui/main.qml new/applet-window-appmenu-0.6.0/package/contents/ui/main.qml --- old/applet-window-appmenu-0.5.1/package/contents/ui/main.qml 2019-08-03 07:36:23.000000000 +0200 +++ new/applet-window-appmenu-0.6.0/package/contents/ui/main.qml 2019-11-24 08:24:26.000000000 +0100 @@ -25,6 +25,7 @@ import org.kde.kquickcontrolsaddons 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.taskmanager 0.1 as TaskManager import org.kde.private.windowAppMenu 0.1 as AppMenuPrivate @@ -42,6 +43,8 @@ readonly property bool inFullView: !plasmoid.configuration.compactView && plasmoid.formFactor === PlasmaCore.Types.Horizontal readonly property bool inCompactView: !inFullView + readonly property string currentScheme: plasmoid.configuration.selectedScheme + Plasmoid.preferredRepresentation: plasmoid.fullRepresentation Plasmoid.status: inFullView ? fullLayout.status : compactLayout.status @@ -83,11 +86,17 @@ //BEGIN Latte Dock Communicator property QtObject latteBridge: null + + property bool latteSupportsActiveWindowSchemes: plasmoid.configuration.supportsActiveWindowSchemes onLatteBridgeChanged: { if (latteBridge) { latteBridge.actions.setProperty(plasmoid.id, "latteSideColoringEnabled", false); latteBridge.actions.setProperty(plasmoid.id, "activeIndicatorEnabled", false); latteBridge.actions.setProperty(plasmoid.id, "windowsTrackingEnabled", true); + + if (latteBridge.version >= latteBridge.actions.version(0,9,4)) { + plasmoid.configuration.supportsActiveWindowSchemes = true; + } } } @@ -104,6 +113,7 @@ } Component.onCompleted: { + plasmoid.configuration.supportsActiveWindowSchemes = false; plasmoid.configuration.windowTitleIsPresent = false; plasmoid.nativeInterface.buttonGrid = buttonGrid; @@ -135,6 +145,29 @@ }); } + Binding { + target: plasmoid.nativeInterface + property: "menuColorScheme" + when: plasmoid.nativeInterface && appMenuModel + + value: { + if (root.currentScheme === "_default_") { + return ""; + } + + if (root.currentScheme === "_current_") { + if (latteSupportsActiveWindowSchemes) { + /* colorScheme value was added after Latte v0.9.4*/ + return appMenuModel.selectedTracker.lastActiveWindow.colorScheme + } else { + return ""; + } + } + + return plasmoid.configuration.selectedScheme + } + } + PaintedToolButton { id: compactLayout anchors.fill: parent @@ -300,6 +333,29 @@ leftIndicatorOpacity: gridFlickable.contentX / gridFlickable.contentsExtraSpace; rightIndicatorOpacity: (gridFlickable.contentsExtraSpace - gridFlickable.contentX) / gridFlickable.contentsExtraSpace } + + //This Loader is to support maximize/restore active window for plasma panels. Latte panels are not and should not be influenced by this implementation + Loader { + active: plasmoid.configuration.fillWidth && plasmoid.configuration.toggleMaximizedOnDoubleClick && containmentType !== 2 + anchors.fill: parent + sourceComponent: Component { + MouseArea { + anchors.right: parent.right + width: parent.width - gridFlickable.contentWidth + height: parent.height + + TaskManager.TasksModel { + id: tasksModel + filterByScreen: plasmoid.configuration.filterByScreen + screenGeometry: plasmoid.screenGeometry + } + + onDoubleClicked: { + tasksModel.requestToggleMaximized(tasksModel.activeTask) + } + } + } + } } AppMenuPrivate.AppMenuModel { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/package/metadata.desktop new/applet-window-appmenu-0.6.0/package/metadata.desktop --- old/applet-window-appmenu-0.5.1/package/metadata.desktop 2019-08-03 07:36:23.000000000 +0200 +++ new/applet-window-appmenu-0.6.0/package/metadata.desktop 2019-11-24 08:24:26.000000000 +0100 @@ -7,7 +7,7 @@ X-KDE-PluginInfo-Email=mvourla...@gmail.com X-KDE-PluginInfo-License=GPL-2.0+ X-KDE-PluginInfo-Name=org.kde.windowappmenu -X-KDE-PluginInfo-Version=0.5.1 +X-KDE-PluginInfo-Version=0.6.0 X-KDE-PluginInfo-Website=https://github.com/psifidotos/applet-window-appmenu X-KDE-ServiceTypes=Plasma/Applet X-Plasma-API=declarativeappletscript diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/plugin/CMakeLists.txt new/applet-window-appmenu-0.6.0/plugin/CMakeLists.txt --- old/applet-window-appmenu-0.5.1/plugin/CMakeLists.txt 2019-08-03 07:36:23.000000000 +0200 +++ new/applet-window-appmenu-0.6.0/plugin/CMakeLists.txt 2019-11-24 08:24:26.000000000 +0100 @@ -1,6 +1,9 @@ set(appmenuapplet_SRCS appmenumodel.cpp appmenuplugin.cpp + commontools.cpp + schemecolors.cpp + schemesmodel.cpp ) add_library(appmenuplugin SHARED ${appmenuapplet_SRCS}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/plugin/appmenuplugin.cpp new/applet-window-appmenu-0.6.0/plugin/appmenuplugin.cpp --- old/applet-window-appmenu-0.5.1/plugin/appmenuplugin.cpp 2019-08-03 07:36:23.000000000 +0200 +++ new/applet-window-appmenu-0.6.0/plugin/appmenuplugin.cpp 2019-11-24 08:24:26.000000000 +0100 @@ -21,6 +21,7 @@ #include "appmenuplugin.h" #include "appmenumodel.h" +#include "schemesmodel.h" #include <QQmlEngine> @@ -28,4 +29,5 @@ { Q_ASSERT(uri == QLatin1String("org.kde.private.windowAppMenu")); qmlRegisterType<AppMenuModel>(uri, 0, 1, "AppMenuModel"); + qmlRegisterType<SchemesModel>(uri, 0, 1, "SchemesModel"); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/plugin/commontools.cpp new/applet-window-appmenu-0.6.0/plugin/commontools.cpp --- old/applet-window-appmenu-0.5.1/plugin/commontools.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/applet-window-appmenu-0.6.0/plugin/commontools.cpp 2019-11-24 08:24:26.000000000 +0100 @@ -0,0 +1,87 @@ +/* + * Copyright 2018 Michail Vourlakos <mvourla...@gmail.com> + * + * This file is part of Latte-Dock + * + * Latte-Dock is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * Latte-Dock 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include "commontools.h" + +// Qt +#include <QFileInfo> +#include <QStandardPaths> + +namespace AppletDecoration { + +QString standardPath(QString subPath, bool localfirst) +{ + QStringList paths = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); + + if (localfirst) { + for (const auto &pt : paths) { + QString ptF = pt + "/" +subPath; + if (QFileInfo(ptF).exists()) { + return ptF; + } + } + } else { + for (int i=paths.count()-1; i>=0; i--) { + QString ptF = paths[i] + "/" +subPath; + if (QFileInfo(ptF).exists()) { + return ptF; + } + } + } + + //! in any case that above fails + if (QFileInfo("/usr/share/"+subPath).exists()) { + return "/usr/share/"+subPath; + } + + return ""; +} + +QStringList standardPaths(bool localfirst) +{ + QStringList paths = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); + + if (localfirst) { + return paths; + } else { + QStringList reversed; + + for (int i=paths.count()-1; i>=0; i--) { + reversed << paths[i]; + } + + return reversed; + } +} + +QStringList standardPathsFor(QString subPath, bool localfirst) +{ + QStringList paths = standardPaths(localfirst); + + QString separator = subPath.startsWith("/") ? "" : "/"; + + for (int i=0; i<paths.count(); ++i) { + paths[i] = paths[i] + separator + subPath; + } + + return paths; +} + +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/plugin/commontools.h new/applet-window-appmenu-0.6.0/plugin/commontools.h --- old/applet-window-appmenu-0.5.1/plugin/commontools.h 1970-01-01 01:00:00.000000000 +0100 +++ new/applet-window-appmenu-0.6.0/plugin/commontools.h 2019-11-24 08:24:26.000000000 +0100 @@ -0,0 +1,32 @@ +/* + * Copyright 2019 Michail Vourlakos <mvourla...@gmail.com> + * + * This file is part of the libappletdecoration library + * + * Latte-Dock is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * Latte-Dock 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include <QString> +#include <QStringList> + +namespace AppletDecoration { + +//! returns the standard path found that contains the subPath +//! local paths have higher priority by default +QString standardPath(QString subPath, bool localFirst = true); + +QStringList standardPaths(bool localfirst = true); +QStringList standardPathsFor(QString subPath, bool localfirst = true); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/plugin/libdbusmenuqt/dbusmenuimporter.cpp new/applet-window-appmenu-0.6.0/plugin/libdbusmenuqt/dbusmenuimporter.cpp --- old/applet-window-appmenu-0.5.1/plugin/libdbusmenuqt/dbusmenuimporter.cpp 2019-08-03 07:36:23.000000000 +0200 +++ new/applet-window-appmenu-0.6.0/plugin/libdbusmenuqt/dbusmenuimporter.cpp 2019-11-24 08:24:26.000000000 +0100 @@ -550,6 +550,17 @@ QMenu *menu = qobject_cast<QMenu *>(sender()); Q_ASSERT(menu); + //! update colors to sub-menus based on the parent menu colors + if (menu && menu->parent()) { + QMenu *parent_menu = qobject_cast<QMenu *>(menu->parent()->parent()); + if (parent_menu) { + QMenu *sub_menu = qobject_cast<QMenu *>(menu->parent()); + if (sub_menu) { + menu->setPalette(sub_menu->palette()); + } + } + } + updateMenu(menu); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/plugin/schemecolors.cpp new/applet-window-appmenu-0.6.0/plugin/schemecolors.cpp --- old/applet-window-appmenu-0.5.1/plugin/schemecolors.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/applet-window-appmenu-0.6.0/plugin/schemecolors.cpp 2019-11-24 08:24:26.000000000 +0100 @@ -0,0 +1,227 @@ +/* + * Copyright 2018 Michail Vourlakos <mvourla...@gmail.com> + * + * This file is part of the libappletdecoration library + * + * Latte-Dock is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * Latte-Dock 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include "schemecolors.h" + +#include "commontools.h" + +#include <QDebug> +#include <QDir> +#include <QFileInfo> + +#include <KConfigGroup> +#include <KDirWatch> +#include <KSharedConfig> + + +SchemeColors::SchemeColors(QObject *parent, QString scheme, bool plasmaTheme) : + QObject(parent), + m_basedOnPlasmaTheme(plasmaTheme) +{ + QString pSchemeFile = possibleSchemeFile(scheme); + + if (QFileInfo(pSchemeFile).exists()) { + setSchemeFile(pSchemeFile); + m_schemeName = schemeName(pSchemeFile); + + //! track scheme file for changes + KDirWatch::self()->addFile(m_schemeFile); + + connect(KDirWatch::self(), &KDirWatch::dirty, this, [ & ](const QString & path) { + if (path == m_schemeFile) { + updateScheme(); + } + }); + } + + updateScheme(); +} + +SchemeColors::~SchemeColors() +{ +} + +QColor SchemeColors::backgroundColor() const +{ + return m_activeBackgroundColor; +} + +QColor SchemeColors::textColor() const +{ + return m_activeTextColor; +} + +QColor SchemeColors::inactiveBackgroundColor() const +{ + return m_inactiveBackgroundColor; +} + +QColor SchemeColors::inactiveTextColor() const +{ + return m_inactiveTextColor; +} + +QColor SchemeColors::highlightColor() const +{ + return m_highlightColor; +} + +QColor SchemeColors::highlightedTextColor() const +{ + return m_highlightedTextColor; +} + +QColor SchemeColors::positiveText() const +{ + return m_positiveColor; +} + +QColor SchemeColors::neutralText() const +{ + return m_neutralText; +} + +QColor SchemeColors::negativeText() const +{ + return m_negativeText; +} + +QColor SchemeColors::buttonTextColor() const +{ + return m_buttonTextColor; +} + +QColor SchemeColors::buttonBackgroundColor() const +{ + return m_buttonBackgroundColor; +} + +QColor SchemeColors::buttonHoverColor() const +{ + return m_buttonHoverColor; +} + +QColor SchemeColors::buttonFocusColor() const +{ + return m_buttonFocusColor; +} + +QString SchemeColors::schemeName() const +{ + return m_schemeName; +} + +QString SchemeColors::SchemeColors::schemeFile() const +{ + return m_schemeFile; +} + +void SchemeColors::setSchemeFile(QString file) +{ + if (m_schemeFile == file) { + return; + } + + m_schemeFile = file; + emit schemeFileChanged(); +} + +QString SchemeColors::possibleSchemeFile(QString scheme) +{ + if (scheme.startsWith("/") && scheme.endsWith("colors") && QFileInfo(scheme).exists()) { + return scheme; + } + + QString tempScheme = scheme; + + if (scheme == "kdeglobals") { + QString settingsFile = QDir::homePath() + "/.config/kdeglobals"; + + if (QFileInfo(settingsFile).exists()) { + KSharedConfigPtr filePtr = KSharedConfig::openConfig(settingsFile); + KConfigGroup generalGroup = KConfigGroup(filePtr, "General"); + tempScheme = generalGroup.readEntry("ColorScheme", ""); + } + } + + //! remove all whitespaces and "-" from scheme in order to access correctly its file + QString schemeNameSimplified = tempScheme.simplified().remove(" ").remove("-"); + + return AppletDecoration::standardPath("color-schemes/" + schemeNameSimplified + ".colors"); +} + +QString SchemeColors::schemeName(QString originalFile) +{ + if (!(originalFile.startsWith("/") && originalFile.endsWith("colors") && QFileInfo(originalFile).exists())) { + return ""; + } + + QString fileNameNoExt = originalFile; + + int lastSlash = originalFile.lastIndexOf("/"); + + if (lastSlash >= 0) { + fileNameNoExt.remove(0, lastSlash + 1); + } + + if (fileNameNoExt.endsWith(".colors")) { + fileNameNoExt.remove(".colors"); + } + + KSharedConfigPtr filePtr = KSharedConfig::openConfig(originalFile); + KConfigGroup generalGroup = KConfigGroup(filePtr, "General"); + + return generalGroup.readEntry("Name", fileNameNoExt); +} + +void SchemeColors::updateScheme() +{ + if (m_schemeFile.isEmpty() || !QFileInfo(m_schemeFile).exists()) { + return; + } + + KSharedConfigPtr filePtr = KSharedConfig::openConfig(m_schemeFile); + KConfigGroup wmGroup = KConfigGroup(filePtr, "WM"); + KConfigGroup selGroup = KConfigGroup(filePtr, "Colors:Selection"); + KConfigGroup viewGroup = KConfigGroup(filePtr, "Colors:View"); + KConfigGroup windowGroup = KConfigGroup(filePtr, "Colors:Window"); + KConfigGroup buttonGroup = KConfigGroup(filePtr, "Colors:Button"); + + m_activeBackgroundColor = windowGroup.readEntry("BackgroundNormal", QColor()); + m_activeTextColor = windowGroup.readEntry("ForegroundNormal", QColor()); + m_inactiveBackgroundColor = windowGroup.readEntry("BackgroundAlternate", QColor()); + m_inactiveTextColor = windowGroup.readEntry("ForegroundInactive", QColor()); + + m_highlightColor = selGroup.readEntry("BackgroundNormal", QColor()); + m_highlightedTextColor = selGroup.readEntry("ForegroundNormal", QColor()); + + m_positiveColor = selGroup.readEntry("ForegroundPositive", QColor()); + m_neutralText = selGroup.readEntry("ForegroundNeutral", QColor());; + m_negativeText = selGroup.readEntry("ForegroundNegative", QColor()); + + m_buttonTextColor = buttonGroup.readEntry("ForegroundNormal", QColor()); + m_buttonBackgroundColor = buttonGroup.readEntry("BackgroundNormal", QColor()); + m_buttonHoverColor = buttonGroup.readEntry("DecorationHover", QColor()); + m_buttonFocusColor = buttonGroup.readEntry("DecorationFocus", QColor()); + + emit colorsChanged(); +} + + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/plugin/schemecolors.h new/applet-window-appmenu-0.6.0/plugin/schemecolors.h --- old/applet-window-appmenu-0.5.1/plugin/schemecolors.h 1970-01-01 01:00:00.000000000 +0100 +++ new/applet-window-appmenu-0.6.0/plugin/schemecolors.h 2019-11-24 08:24:26.000000000 +0100 @@ -0,0 +1,106 @@ +/* + * Copyright 2018 Michail Vourlakos <mvourla...@gmail.com> + * + * This file is part of the libappletdecoration library + * + * Latte-Dock is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * Latte-Dock 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef SCHEMECOLORS_H +#define SCHEMECOLORS_H + +#include <QObject> +#include <QColor> + +class SchemeColors: public QObject +{ + Q_OBJECT + Q_PROPERTY(QString schemeFile READ schemeFile NOTIFY schemeFileChanged) + + Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY colorsChanged) + Q_PROPERTY(QColor textColor READ textColor NOTIFY colorsChanged) + Q_PROPERTY(QColor inactiveBackgroundColor READ inactiveBackgroundColor NOTIFY colorsChanged) + Q_PROPERTY(QColor inactiveTextColor READ inactiveTextColor NOTIFY colorsChanged) + + Q_PROPERTY(QColor highlightColor READ highlightColor NOTIFY colorsChanged) + Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor NOTIFY colorsChanged) + Q_PROPERTY(QColor positiveText READ positiveText NOTIFY colorsChanged) + Q_PROPERTY(QColor neutralText READ neutralText NOTIFY colorsChanged) + Q_PROPERTY(QColor negativeText READ negativeText NOTIFY colorsChanged) + + 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) + +public: + SchemeColors(QObject *parent, QString scheme, bool plasmaTheme = false); + ~SchemeColors() override; + + QString schemeName() const; + + QString schemeFile() const; + void setSchemeFile(QString file); + + QColor backgroundColor() const; + QColor textColor() const; + QColor inactiveBackgroundColor() const; + QColor inactiveTextColor() const; + QColor highlightColor() const; + QColor highlightedTextColor() const; + QColor positiveText() const; + QColor neutralText() const; + QColor negativeText() const; + + QColor buttonTextColor() const; + QColor buttonBackgroundColor() const; + QColor buttonHoverColor() const; + QColor buttonFocusColor() const; + + static QString possibleSchemeFile(QString scheme); + static QString schemeName(QString originalFile); + +signals: + void colorsChanged(); + void schemeFileChanged(); + +private slots: + void updateScheme(); + +private: + bool m_basedOnPlasmaTheme{false}; + + QString m_schemeName; + QString m_schemeFile; + + QColor m_activeBackgroundColor; + QColor m_activeTextColor; + + QColor m_inactiveBackgroundColor; + QColor m_inactiveTextColor; + + QColor m_highlightColor; + QColor m_highlightedTextColor; + QColor m_positiveColor; + QColor m_neutralText; + QColor m_negativeText; + + QColor m_buttonTextColor; + QColor m_buttonBackgroundColor; + QColor m_buttonHoverColor; + QColor m_buttonFocusColor; +}; + +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/plugin/schemesmodel.cpp new/applet-window-appmenu-0.6.0/plugin/schemesmodel.cpp --- old/applet-window-appmenu-0.5.1/plugin/schemesmodel.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/applet-window-appmenu-0.6.0/plugin/schemesmodel.cpp 2019-11-24 08:24:26.000000000 +0100 @@ -0,0 +1,194 @@ +/* + * Copyright 2018 Michail Vourlakos <mvourla...@gmail.com> + * + * This file is part of the libappletdecoration library + * + * Latte-Dock is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * Latte-Dock 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include "schemesmodel.h" + +#include "commontools.h" +#include "schemecolors.h" + +#include <QDebug> +#include <QDir> + +SchemesModel::SchemesModel(QObject *parent) + : QAbstractListModel(parent) +{ + initSchemes(); +} + +SchemesModel::~SchemesModel() +{ + qDeleteAll(m_schemes); +} + +bool SchemesModel::currentOptionIsShown() const +{ + return m_currentOptionIsShown; +} + +void SchemesModel::setCurrentOptionIsShown(bool isShown) +{ + if (m_currentOptionIsShown == isShown) { + return; + } + + m_currentOptionIsShown = isShown; + emit currentOptionIsShownChanged(); +} + +QVariant SchemesModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid() || index.column() != 0 || index.row() < 0 || index.row() >= m_schemes.count()) { + return QVariant(); + } + + const SchemeColors *d = m_schemes[index.row()]; + + switch (role) { + case Qt::DisplayRole: + if (index.row() == 0) { + return "Default"; + } + + if (index.row() == 1 && m_currentOptionIsShown) { + return "Current Window"; + } + + return d->schemeName(); + + case Qt::UserRole + 4: + if (index.row() == 0) { + return "_default_"; + } + + if (index.row() == 1 && m_currentOptionIsShown) { + return "_current_"; + } + + return d->schemeFile(); + + case Qt::UserRole + 5: + return d->backgroundColor(); + + case Qt::UserRole + 6: + return d->textColor(); + } + + return QVariant(); +} + +int SchemesModel::rowCount(const QModelIndex &parent) const +{ + if (parent.isValid()) { + return 0; + } + + return m_schemes.count(); +} + +QHash< int, QByteArray > SchemesModel::roleNames() const +{ + QHash<int, QByteArray> roles({ + {Qt::DisplayRole, QByteArrayLiteral("display")}, + {Qt::UserRole + 4, QByteArrayLiteral("file")}, + {Qt::UserRole + 5, QByteArrayLiteral("backgroundColor")}, + {Qt::UserRole + 6, QByteArrayLiteral("textColor")} + }); + return roles; +} + +QColor SchemesModel::backgroundOf(const int &index) const +{ + if (index>=0 && index<m_schemes.count()) { + return m_schemes[index]->backgroundColor(); + } + + return QColor("transparent"); +} + +void SchemesModel::initSchemes() +{ + qDeleteAll(m_schemes); + m_schemes.clear(); + + QString currentSchemePath = SchemeColors::possibleSchemeFile("kdeglobals"); + insertSchemeInList(currentSchemePath); + + QStringList standardPaths = AppletDecoration::standardPathsFor("color-schemes"); + + QStringList registeredSchemes; + + for(auto path : standardPaths) { + QDir directory(path); + QStringList tempSchemes = directory.entryList(QStringList() << "*.colors" << "*.COLORS", QDir::Files); + + foreach (QString filename, tempSchemes) { + if (!registeredSchemes.contains(filename)) { + QString fullPath = path + "/" + filename; + insertSchemeInList(fullPath); + registeredSchemes << filename; + } + } + } +} + +void SchemesModel::insertSchemeInList(QString file) +{ + SchemeColors *tempScheme = new SchemeColors(this, file); + + int atPos{0}; + + for (int i = 0; i < m_schemes.count(); i++) { + SchemeColors *s = m_schemes[i]; + + int result = QString::compare(tempScheme->schemeName(), s->schemeName(), Qt::CaseInsensitive); + + if (result < 0) { + atPos = i; + break; + } else { + atPos = i + 1; + } + + } + + m_schemes.insert(atPos, tempScheme); +} + +int SchemesModel::indexOf(QString file) +{ + if (file.isEmpty() || file == "_default_") { + return 0; + } + + if (file == "_current_") { + return 1; + } + + for (int i = 0; i < m_schemes.count(); i++) { + SchemeColors *s = m_schemes[i]; + + if (s->schemeFile() == file) { + return i; + } + } + + return -1; +} + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/applet-window-appmenu-0.5.1/plugin/schemesmodel.h new/applet-window-appmenu-0.6.0/plugin/schemesmodel.h --- old/applet-window-appmenu-0.5.1/plugin/schemesmodel.h 1970-01-01 01:00:00.000000000 +0100 +++ new/applet-window-appmenu-0.6.0/plugin/schemesmodel.h 2019-11-24 08:24:26.000000000 +0100 @@ -0,0 +1,62 @@ +/* + * Copyright 2018 Michail Vourlakos <mvourla...@gmail.com> + * + * This file is part of the libappletdecoration library + * + * Latte-Dock is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * Latte-Dock 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef SCHEMESMODEL_H +#define SCHEMESMODEL_H + +#include <QAbstractListModel> + +class SchemeColors; + +class SchemesModel : public QAbstractListModel +{ + Q_OBJECT + Q_PROPERTY(bool currentOptionIsShown READ currentOptionIsShown WRITE setCurrentOptionIsShown NOTIFY currentOptionIsShownChanged) + +public: + explicit SchemesModel(QObject *parent = nullptr); + virtual ~SchemesModel(); + + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + QHash< int, QByteArray > roleNames() const override; + + bool currentOptionIsShown() const; + void setCurrentOptionIsShown(bool isShown); + + Q_INVOKABLE int indexOf(QString file); + Q_INVOKABLE QColor backgroundOf(const int &index) const; + +signals: + void currentOptionIsShownChanged(); + +private slots: + void initSchemes(); + +private: + void insertSchemeInList(QString file); + +private: + bool m_currentOptionIsShown{false}; + + QList<SchemeColors *> m_schemes; +}; + +#endif