1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-12 01:17:55 +03:00

load roundness theme info properly

This commit is contained in:
Michail Vourlakos 2018-10-27 00:59:36 +03:00
parent 0cea7e8622
commit 3553415c59
6 changed files with 102 additions and 4 deletions

View File

@ -94,6 +94,7 @@ DockCorona::DockCorona(bool defaultLayoutOnStartup, QString layoutNameOnStartUp,
setupWaylandIntegration();
KPackage::Package package(new DockPackage(this));
m_screenPool->load();
if (!package.isValid()) {
@ -106,8 +107,9 @@ DockCorona::DockCorona(bool defaultLayoutOnStartup, QString layoutNameOnStartUp,
}
setKPackage(package);
//! universal settings must be loaded after the package has been set
//! universal settings / extendedtheme must be loaded after the package has been set
m_universalSettings->load();
m_themeExtended->load();
qmlRegisterTypes();

View File

@ -62,6 +62,8 @@ void DockPackage::initPackage(KPackage::Package *package)
package->addFileDefinition("preset4", QStringLiteral("presets/Extended.layout.latte"), i18n("extended preset file"));
package->addFileDefinition("preset10", QStringLiteral("presets/multiple-layouts_hidden.layout.latte"), i18n("multiple layouts hidden file"));
package->addFileDefinition("themesExtendedInfo", QStringLiteral("themes/themesExtendedInforc"), i18n("a file that contains extended information for plasma themes"));
package->setFallbackPackage(fallback);
qDebug() << "package is valid" << package->isValid();
}

View File

@ -18,14 +18,28 @@
*
*/
#include "dockcorona.h"
#include "plasmathemeextended.h"
#include <QDebug>
#include <KSharedConfig>
namespace Latte {
PlasmaThemeExtended::PlasmaThemeExtended(KSharedConfig::Ptr config, QObject *parent) :
QObject(parent),
m_themeGroup(KConfigGroup(config, QStringLiteral("PlasmaThemeExtended")))
{
m_corona = qobject_cast<DockCorona *>(parent);
loadConfig();
connect(&m_theme, &Plasma::Theme::themeChanged, this, &PlasmaThemeExtended::load);
}
void PlasmaThemeExtended::load()
{
loadRoundness();
}
PlasmaThemeExtended::~PlasmaThemeExtended()
@ -75,9 +89,56 @@ void PlasmaThemeExtended::setUserThemeRoundness(int roundness)
bool PlasmaThemeExtended::themeHasExtendedInfo() const
{
return false;
return m_themeHasExtendedInfo;
}
void PlasmaThemeExtended::loadRoundness()
{
if (!m_corona) {
return;
}
QString extendedInfoFilePath = m_corona->kPackage().filePath("themesExtendedInfo");
KSharedConfigPtr extInfoPtr = KSharedConfig::openConfig(extendedInfoFilePath);
KConfigGroup roundGroup(extInfoPtr, "Roundness");
m_themeHasExtendedInfo = false;
qDebug() << "current theme ::: " << m_theme.themeName();
foreach (auto key, roundGroup.keyList()) {
qDebug() << "key ::: " << key;
if (m_theme.themeName().toUpper().startsWith(key.toUpper())) {
QStringList rs = roundGroup.readEntry(key, QStringList());
qDebug() << "rounds ::: " << rs;
if (rs.size() > 0) {
m_themeHasExtendedInfo = true;
if (rs.size() <= 3) {
//assign same roundness for all edges
m_bottomEdgeRoundness = rs[0].toInt();
m_leftEdgeRoundness = m_bottomEdgeRoundness;
m_topEdgeRoundness = m_bottomEdgeRoundness;
m_rightEdgeRoundness = m_bottomEdgeRoundness;
} else if (rs.size() >= 4) {
m_bottomEdgeRoundness = rs[0].toInt();
m_leftEdgeRoundness = rs[1].toInt();
m_topEdgeRoundness = rs[2].toInt();
m_rightEdgeRoundness = rs[3].toInt();
}
}
break;
}
}
emit roundnessChanged();
}
void PlasmaThemeExtended::loadConfig()
{
m_userRoundness = m_themeGroup.readEntry("userSetPlasmaThemeRoundness", 0);

View File

@ -30,6 +30,8 @@
namespace Latte {
class DockCorona;
class PlasmaThemeExtended: public QObject
{
Q_OBJECT
@ -50,10 +52,14 @@ public:
int userThemeRoundness() const;
void setUserThemeRoundness(int roundness);
void load();
signals:
void roundnessChanged();
private slots:
void loadRoundness();
void loadConfig();
void saveConfig();
@ -61,15 +67,19 @@ private:
bool themeHasExtendedInfo() const;
private:
bool m_themeHasExtendedInfo{false};
int m_bottomEdgeRoundness{0};
int m_leftEdgeRoundness{0};
int m_topEdgeRoundness{0};
int m_rightEdgeRoundness{0};
int m_userRoundness{0};
KConfigGroup m_themeGroup;
Plasma::Theme m_theme;
KConfigGroup m_themeGroup;
DockCorona *m_corona;
};
}

View File

@ -479,7 +479,21 @@ Item{
anchors.fill: solidBackground
opacity: root.forceColorizeFromActiveWindowScheme ? solidBackground.opacity : 0
backgroundColor: root.forceColorizeFromActiveWindowScheme ? dock.visibility.touchingWindowScheme.backgroundColor : "transparent"
roundness: universalSettings ? universalSettings.plasmaThemeRoundness : 0
roundness: {
if (themeExtended) {
switch(plasmoid.location) {
case PlasmaCore.Types.BottomEdge: return themeExtended.bottomEdgeRoundness;
case PlasmaCore.Types.LeftEdge: return themeExtended.leftEdgeRoundness;
case PlasmaCore.Types.TopEdge: return themeExtended.topEdgeRoundness;
case PlasmaCore.Types.RightEdge: return themeExtended.rightEdgeRoundness;
default: return 0;
}
}
return 0;
}
}
PlasmaCore.FrameSvgItem{

View File

@ -0,0 +1,9 @@
[Roundness]
Breeze=0
Air=6
Oxygen=6
Arc=4
Materia=4
Adapta=4
Elegant=3
UnityAmbiance=0