introduce plasma theme extended

--this is going to be a class that will
provide all the extended info of a plasma
theme such as roundness, dark/light color
schemes
pull/3/head
Michail Vourlakos 6 years ago
parent 0179bc6395
commit 92ce3f15c1

@ -29,6 +29,7 @@
#include "../layout.h" #include "../layout.h"
#include "../layoutmanager.h" #include "../layoutmanager.h"
#include "../screenpool.h" #include "../screenpool.h"
#include "../plasmathemeextended.h"
#include "../universalsettings.h" #include "../universalsettings.h"
#include "../../liblattedock/extras.h" #include "../../liblattedock/extras.h"
@ -256,6 +257,7 @@ void DockView::init()
if (dockCorona) { if (dockCorona) {
rootContext()->setContextProperty(QStringLiteral("universalSettings"), dockCorona->universalSettings()); rootContext()->setContextProperty(QStringLiteral("universalSettings"), dockCorona->universalSettings());
rootContext()->setContextProperty(QStringLiteral("layoutManager"), dockCorona->layoutManager()); rootContext()->setContextProperty(QStringLiteral("layoutManager"), dockCorona->layoutManager());
rootContext()->setContextProperty(QStringLiteral("themeExtended"), dockCorona->themeExtended());
} }
setSource(corona()->kPackage().filePath("lattedockui")); setSource(corona()->kPackage().filePath("lattedockui"));

@ -26,6 +26,7 @@
#include "importer.h" #include "importer.h"
#include "launcherssignals.h" #include "launcherssignals.h"
#include "layoutmanager.h" #include "layoutmanager.h"
#include "plasmathemeextended.h"
#include "screenpool.h" #include "screenpool.h"
#include "universalsettings.h" #include "universalsettings.h"
#include "waylandinterface.h" #include "waylandinterface.h"
@ -79,6 +80,7 @@ DockCorona::DockCorona(bool defaultLayoutOnStartup, QString layoutNameOnStartUp,
m_screenPool(new ScreenPool(KSharedConfig::openConfig(), this)), m_screenPool(new ScreenPool(KSharedConfig::openConfig(), this)),
m_globalShortcuts(new GlobalShortcuts(this)), m_globalShortcuts(new GlobalShortcuts(this)),
m_universalSettings(new UniversalSettings(KSharedConfig::openConfig(), this)), m_universalSettings(new UniversalSettings(KSharedConfig::openConfig(), this)),
m_themeExtended(new PlasmaThemeExtended(KSharedConfig::openConfig(), this)),
m_layoutManager(new LayoutManager(this)) m_layoutManager(new LayoutManager(this))
{ {
//! create the window manager //! create the window manager
@ -163,6 +165,7 @@ DockCorona::~DockCorona()
m_layoutManager->deleteLater(); m_layoutManager->deleteLater();
m_screenPool->deleteLater(); m_screenPool->deleteLater();
m_universalSettings->deleteLater(); m_universalSettings->deleteLater();
m_themeExtended->deleteLater();
disconnect(m_activityConsumer, &KActivities::Consumer::serviceStatusChanged, this, &DockCorona::load); disconnect(m_activityConsumer, &KActivities::Consumer::serviceStatusChanged, this, &DockCorona::load);
delete m_activityConsumer; delete m_activityConsumer;
@ -363,6 +366,11 @@ AbstractWindowInterface *DockCorona::wm() const
return m_wm; return m_wm;
} }
PlasmaThemeExtended *DockCorona::themeExtended() const
{
return m_themeExtended;
}
int DockCorona::numScreens() const int DockCorona::numScreens() const
{ {
return qGuiApp->screens().count(); return qGuiApp->screens().count();
@ -869,8 +877,8 @@ void DockCorona::activateLauncherMenu()
void DockCorona::windowColorScheme(QString windowIdAndScheme) void DockCorona::windowColorScheme(QString windowIdAndScheme)
{ {
int firstSlash = windowIdAndScheme.indexOf("-"); int firstSlash = windowIdAndScheme.indexOf("-");
QString windowIdStr = windowIdAndScheme.mid(0,firstSlash); QString windowIdStr = windowIdAndScheme.mid(0, firstSlash);
QString schemeStr = windowIdAndScheme.mid(firstSlash+1); QString schemeStr = windowIdAndScheme.mid(firstSlash + 1);
m_wm->setColorSchemeForWindow(windowIdStr, schemeStr); m_wm->setColorSchemeForWindow(windowIdStr, schemeStr);
} }

@ -63,6 +63,7 @@ class GlobalShortcuts;
class UniversalSettings; class UniversalSettings;
class LayoutManager; class LayoutManager;
class LaunchersSignals; class LaunchersSignals;
class PlasmaThemeExtended;
} }
namespace Latte { namespace Latte {
@ -102,6 +103,7 @@ public:
ScreenPool *screenPool() const; ScreenPool *screenPool() const;
UniversalSettings *universalSettings() const; UniversalSettings *universalSettings() const;
LayoutManager *layoutManager() const; LayoutManager *layoutManager() const;
PlasmaThemeExtended *themeExtended() const;
KWayland::Client::PlasmaShell *waylandDockCoronaInterface() const; KWayland::Client::PlasmaShell *waylandDockCoronaInterface() const;
@ -170,6 +172,7 @@ private:
GlobalShortcuts *m_globalShortcuts{nullptr}; GlobalShortcuts *m_globalShortcuts{nullptr};
UniversalSettings *m_universalSettings{nullptr}; UniversalSettings *m_universalSettings{nullptr};
LayoutManager *m_layoutManager{nullptr}; LayoutManager *m_layoutManager{nullptr};
PlasmaThemeExtended *m_themeExtended{nullptr};
KWayland::Client::PlasmaShell *m_waylandDockCorona{nullptr}; KWayland::Client::PlasmaShell *m_waylandDockCorona{nullptr};

@ -20,17 +20,72 @@
#include "plasmathemeextended.h" #include "plasmathemeextended.h"
namespace Latte { 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() 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);
} }
} }

@ -23,6 +23,9 @@
#include <QObject> #include <QObject>
#include <KConfigGroup>
#include <KSharedConfig>
#include <Plasma/Theme> #include <Plasma/Theme>
namespace Latte { namespace Latte {
@ -30,16 +33,43 @@ namespace Latte {
class PlasmaThemeExtended: public QObject class PlasmaThemeExtended: public QObject
{ {
Q_OBJECT 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: public:
PlasmaThemeExtended(QObject *parent); PlasmaThemeExtended(KSharedConfig::Ptr config, QObject *parent);
~PlasmaThemeExtended() override;; ~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: 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; Plasma::Theme m_theme;
KConfigGroup m_themeGroup;
}; };
} }

@ -342,11 +342,11 @@ DragDrop.DropArea {
property Item parabolicManager: _parabolicManager property Item parabolicManager: _parabolicManager
property QtObject dock property QtObject dock
property QtObject themeExtended
property QtObject universalSettings property QtObject universalSettings
property QtObject universalLayoutManager property QtObject universalLayoutManager
property QtObject dockManagedLayout: dock && dock.managedLayout ? dock.managedLayout : null property QtObject dockManagedLayout: dock && dock.managedLayout ? dock.managedLayout : null
// TO BE DELETED, if not needed: property int counter:0; // TO BE DELETED, if not needed: property int counter:0;
///BEGIN properties provided to Latte Plasmoid ///BEGIN properties provided to Latte Plasmoid

@ -99,6 +99,7 @@ PlasmaCore.FrameSvgItem {
dockLayout.dock = dock; dockLayout.dock = dock;
dockLayout.universalSettings = universalSettings; dockLayout.universalSettings = universalSettings;
dockLayout.universalLayoutManager = layoutManager; dockLayout.universalLayoutManager = layoutManager;
dockLayout.themeExtended = themeExtended;
} }
} }
} }

Loading…
Cancel
Save