diff --git a/app/dock/dockview.cpp b/app/dock/dockview.cpp index 4eed15e52..6434c92c2 100644 --- a/app/dock/dockview.cpp +++ b/app/dock/dockview.cpp @@ -29,6 +29,7 @@ #include "../layout.h" #include "../layoutmanager.h" #include "../screenpool.h" +#include "../plasmathemeextended.h" #include "../universalsettings.h" #include "../../liblattedock/extras.h" @@ -256,6 +257,7 @@ void DockView::init() if (dockCorona) { rootContext()->setContextProperty(QStringLiteral("universalSettings"), dockCorona->universalSettings()); rootContext()->setContextProperty(QStringLiteral("layoutManager"), dockCorona->layoutManager()); + rootContext()->setContextProperty(QStringLiteral("themeExtended"), dockCorona->themeExtended()); } setSource(corona()->kPackage().filePath("lattedockui")); diff --git a/app/dockcorona.cpp b/app/dockcorona.cpp index bee457e1d..e2d4757bd 100644 --- a/app/dockcorona.cpp +++ b/app/dockcorona.cpp @@ -26,6 +26,7 @@ #include "importer.h" #include "launcherssignals.h" #include "layoutmanager.h" +#include "plasmathemeextended.h" #include "screenpool.h" #include "universalsettings.h" #include "waylandinterface.h" @@ -79,6 +80,7 @@ DockCorona::DockCorona(bool defaultLayoutOnStartup, QString layoutNameOnStartUp, m_screenPool(new ScreenPool(KSharedConfig::openConfig(), this)), m_globalShortcuts(new GlobalShortcuts(this)), m_universalSettings(new UniversalSettings(KSharedConfig::openConfig(), this)), + m_themeExtended(new PlasmaThemeExtended(KSharedConfig::openConfig(), this)), m_layoutManager(new LayoutManager(this)) { //! create the window manager @@ -163,6 +165,7 @@ DockCorona::~DockCorona() m_layoutManager->deleteLater(); m_screenPool->deleteLater(); m_universalSettings->deleteLater(); + m_themeExtended->deleteLater(); disconnect(m_activityConsumer, &KActivities::Consumer::serviceStatusChanged, this, &DockCorona::load); delete m_activityConsumer; @@ -363,6 +366,11 @@ AbstractWindowInterface *DockCorona::wm() const return m_wm; } +PlasmaThemeExtended *DockCorona::themeExtended() const +{ + return m_themeExtended; +} + int DockCorona::numScreens() const { return qGuiApp->screens().count(); @@ -869,8 +877,8 @@ void DockCorona::activateLauncherMenu() void DockCorona::windowColorScheme(QString windowIdAndScheme) { int firstSlash = windowIdAndScheme.indexOf("-"); - QString windowIdStr = windowIdAndScheme.mid(0,firstSlash); - QString schemeStr = windowIdAndScheme.mid(firstSlash+1); + QString windowIdStr = windowIdAndScheme.mid(0, firstSlash); + QString schemeStr = windowIdAndScheme.mid(firstSlash + 1); m_wm->setColorSchemeForWindow(windowIdStr, schemeStr); } diff --git a/app/dockcorona.h b/app/dockcorona.h index 8309a8109..0915ee676 100644 --- a/app/dockcorona.h +++ b/app/dockcorona.h @@ -63,6 +63,7 @@ class GlobalShortcuts; class UniversalSettings; class LayoutManager; class LaunchersSignals; +class PlasmaThemeExtended; } namespace Latte { @@ -102,6 +103,7 @@ public: ScreenPool *screenPool() const; UniversalSettings *universalSettings() const; LayoutManager *layoutManager() const; + PlasmaThemeExtended *themeExtended() const; KWayland::Client::PlasmaShell *waylandDockCoronaInterface() const; @@ -170,6 +172,7 @@ private: GlobalShortcuts *m_globalShortcuts{nullptr}; UniversalSettings *m_universalSettings{nullptr}; LayoutManager *m_layoutManager{nullptr}; + PlasmaThemeExtended *m_themeExtended{nullptr}; KWayland::Client::PlasmaShell *m_waylandDockCorona{nullptr}; diff --git a/app/plasmathemeextended.cpp b/app/plasmathemeextended.cpp index 801aec898..f892bd99d 100644 --- a/app/plasmathemeextended.cpp +++ b/app/plasmathemeextended.cpp @@ -20,17 +20,72 @@ #include "plasmathemeextended.h" - namespace Latte { -PlasmaThemeExtended::PlasmaThemeExtended(QObject *parent) : - QObject(parent) -{ +PlasmaThemeExtended::PlasmaThemeExtended(KSharedConfig::Ptr config, QObject *parent) : + QObject(parent), + m_themeGroup(KConfigGroup(config, QStringLiteral("PlasmaThemeExtended"))) +{ } PlasmaThemeExtended::~PlasmaThemeExtended() { + saveConfig(); +} + +int PlasmaThemeExtended::bottomEdgeRoundness() const +{ + return (themeHasExtendedInfo() ? m_bottomEdgeRoundness : userThemeRoundness()); +} + +int PlasmaThemeExtended::leftEdgeRoundness() const +{ + return (themeHasExtendedInfo() ? m_leftEdgeRoundness : userThemeRoundness()); +} + +int PlasmaThemeExtended::topEdgeRoundness() const +{ + return (themeHasExtendedInfo() ? m_topEdgeRoundness : userThemeRoundness()); +} + +int PlasmaThemeExtended::rightEdgeRoundness() const +{ + return (themeHasExtendedInfo() ? m_rightEdgeRoundness : userThemeRoundness()); +} + +int PlasmaThemeExtended::userThemeRoundness() const +{ + return m_userRoundness; +} + +void PlasmaThemeExtended::setUserThemeRoundness(int roundness) +{ + if (m_userRoundness == roundness) { + return; + } + + m_userRoundness = roundness; + + if (!themeHasExtendedInfo()) { + emit roundnessChanged(); + } + + saveConfig(); +} + +bool PlasmaThemeExtended::themeHasExtendedInfo() const +{ + return false; +} + +void PlasmaThemeExtended::loadConfig() +{ + m_userRoundness = m_themeGroup.readEntry("userSetPlasmaThemeRoundness", 0); +} +void PlasmaThemeExtended::saveConfig() +{ + m_themeGroup.writeEntry("userSetPlasmaThemeRoundness", m_userRoundness); } } diff --git a/app/plasmathemeextended.h b/app/plasmathemeextended.h index 80a13231f..8b86e17b3 100644 --- a/app/plasmathemeextended.h +++ b/app/plasmathemeextended.h @@ -23,6 +23,9 @@ #include +#include +#include + #include namespace Latte { @@ -30,16 +33,43 @@ namespace Latte { class PlasmaThemeExtended: public QObject { Q_OBJECT + Q_PROPERTY(int bottomEdgeRoundness READ bottomEdgeRoundness NOTIFY roundnessChanged) + Q_PROPERTY(int leftEdgeRoundness READ leftEdgeRoundness NOTIFY roundnessChanged) + Q_PROPERTY(int topEdgeRoundness READ topEdgeRoundness NOTIFY roundnessChanged) + Q_PROPERTY(int rightEdgeRoundness READ rightEdgeRoundness NOTIFY roundnessChanged) public: - PlasmaThemeExtended(QObject *parent); + PlasmaThemeExtended(KSharedConfig::Ptr config, QObject *parent); ~PlasmaThemeExtended() override;; + int bottomEdgeRoundness() const; + int leftEdgeRoundness() const; + int topEdgeRoundness() const; + int rightEdgeRoundness() const; + + int userThemeRoundness() const; + void setUserThemeRoundness(int roundness); + +signals: + void roundnessChanged(); +private slots: + void loadConfig(); + void saveConfig(); private: + bool themeHasExtendedInfo() const; + +private: + int m_bottomEdgeRoundness{0}; + int m_leftEdgeRoundness{0}; + int m_topEdgeRoundness{0}; + int m_rightEdgeRoundness{0}; + int m_userRoundness{0}; + Plasma::Theme m_theme; + KConfigGroup m_themeGroup; }; } diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index 3d931510b..bbc03b08c 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -342,11 +342,11 @@ DragDrop.DropArea { property Item parabolicManager: _parabolicManager property QtObject dock + property QtObject themeExtended property QtObject universalSettings property QtObject universalLayoutManager property QtObject dockManagedLayout: dock && dock.managedLayout ? dock.managedLayout : null - // TO BE DELETED, if not needed: property int counter:0; ///BEGIN properties provided to Latte Plasmoid diff --git a/shell/package/contents/views/Panel.qml b/shell/package/contents/views/Panel.qml index 4dd1264bc..b19779802 100644 --- a/shell/package/contents/views/Panel.qml +++ b/shell/package/contents/views/Panel.qml @@ -99,6 +99,7 @@ PlasmaCore.FrameSvgItem { dockLayout.dock = dock; dockLayout.universalSettings = universalSettings; dockLayout.universalLayoutManager = layoutManager; + dockLayout.themeExtended = themeExtended; } } }