refactor:move PlasmaThemeExtended to better path

pull/3/head
Michail Vourlakos 6 years ago
parent efb9414ef9
commit 2244cae8bc

@ -9,9 +9,9 @@ set(lattedock-app_SRCS
launcherssignals.cpp
layout.cpp
layoutmanager.cpp
plasmathemeextended.cpp
schemecolors.cpp
screenpool.cpp
plasma/extended/theme.cpp
packageplugins/shell/lattepackage.cpp
settings/settingsdialog.cpp
settings/sortedactivitiesmodel.cpp

@ -27,9 +27,9 @@
#include "lattedockadaptor.h"
#include "launcherssignals.h"
#include "layoutmanager.h"
#include "plasmathemeextended.h"
#include "screenpool.h"
#include "packageplugins/shell/lattepackage.h"
#include "plasma/extended/theme.h"
#include "settings/universalsettings.h"
#include "view/view.h"
#include "wm/abstractwindowinterface.h"
@ -80,7 +80,7 @@ Corona::Corona(bool defaultLayoutOnStartup, QString layoutNameOnStartUp, int use
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_themeExtended(new PlasmaExtended::Theme(KSharedConfig::openConfig(), this)),
m_layoutManager(new LayoutManager(this))
{
//! create the window manager
@ -377,7 +377,7 @@ AbstractWindowInterface *Corona::wm() const
return m_wm;
}
PlasmaThemeExtended *Corona::themeExtended() const
PlasmaExtended::Theme *Corona::themeExtended() const
{
return m_themeExtended;
}

@ -66,7 +66,9 @@ class GlobalShortcuts;
class UniversalSettings;
class LayoutManager;
class LaunchersSignals;
class PlasmaThemeExtended;
namespace PlasmaExtended{
class Theme;
}
}
namespace Latte {
@ -106,7 +108,7 @@ public:
ScreenPool *screenPool() const;
UniversalSettings *universalSettings() const;
LayoutManager *layoutManager() const;
PlasmaThemeExtended *themeExtended() const;
PlasmaExtended::Theme *themeExtended() const;
KWayland::Client::PlasmaShell *waylandCoronaInterface() const;
@ -174,7 +176,7 @@ private:
GlobalShortcuts *m_globalShortcuts{nullptr};
UniversalSettings *m_universalSettings{nullptr};
LayoutManager *m_layoutManager{nullptr};
PlasmaThemeExtended *m_themeExtended{nullptr};
PlasmaExtended::Theme *m_themeExtended{nullptr};
KWayland::Client::PlasmaShell *m_waylandCorona{nullptr};

@ -18,7 +18,7 @@
*
*/
#include "plasmathemeextended.h"
#include "theme.h"
// local
#include "commontools.h"
@ -39,8 +39,9 @@
#define REVERSEDCOLORSCHEME "reversed.colors"
namespace Latte {
namespace PlasmaExtended {
PlasmaThemeExtended::PlasmaThemeExtended(KSharedConfig::Ptr config, QObject *parent) :
Theme::Theme(KSharedConfig::Ptr config, QObject *parent) :
QObject(parent),
m_themeGroup(KConfigGroup(config, QStringLiteral("PlasmaThemeExtended")))
{
@ -48,18 +49,18 @@ PlasmaThemeExtended::PlasmaThemeExtended(KSharedConfig::Ptr config, QObject *par
loadConfig();
connect(&m_theme, &Plasma::Theme::themeChanged, this, &PlasmaThemeExtended::hasShadowChanged);
connect(&m_theme, &Plasma::Theme::themeChanged, this, &PlasmaThemeExtended::load);
connect(&m_theme, &Plasma::Theme::themeChanged, this, &PlasmaThemeExtended::themeChanged);
connect(&m_theme, &Plasma::Theme::themeChanged, this, &Theme::hasShadowChanged);
connect(&m_theme, &Plasma::Theme::themeChanged, this, &Theme::load);
connect(&m_theme, &Plasma::Theme::themeChanged, this, &Theme::themeChanged);
}
void PlasmaThemeExtended::load()
void Theme::load()
{
loadThemePaths();
loadRoundness();
}
PlasmaThemeExtended::~PlasmaThemeExtended()
Theme::~Theme()
{
saveConfig();
@ -67,47 +68,47 @@ PlasmaThemeExtended::~PlasmaThemeExtended()
m_reversedScheme->deleteLater();
}
bool PlasmaThemeExtended::hasShadow() const
bool Theme::hasShadow() const
{
return PanelShadows::self()->enabled();
}
bool PlasmaThemeExtended::isLightTheme() const
bool Theme::isLightTheme() const
{
return m_isLightTheme;
}
bool PlasmaThemeExtended::isDarkTheme() const
bool Theme::isDarkTheme() const
{
return !m_isLightTheme;
}
int PlasmaThemeExtended::bottomEdgeRoundness() const
int Theme::bottomEdgeRoundness() const
{
return (themeHasExtendedInfo() ? m_bottomEdgeRoundness : userThemeRoundness());
}
int PlasmaThemeExtended::leftEdgeRoundness() const
int Theme::leftEdgeRoundness() const
{
return (themeHasExtendedInfo() ? m_leftEdgeRoundness : userThemeRoundness());
}
int PlasmaThemeExtended::topEdgeRoundness() const
int Theme::topEdgeRoundness() const
{
return (themeHasExtendedInfo() ? m_topEdgeRoundness : userThemeRoundness());
}
int PlasmaThemeExtended::rightEdgeRoundness() const
int Theme::rightEdgeRoundness() const
{
return (themeHasExtendedInfo() ? m_rightEdgeRoundness : userThemeRoundness());
}
int PlasmaThemeExtended::userThemeRoundness() const
int Theme::userThemeRoundness() const
{
return m_userRoundness;
}
void PlasmaThemeExtended::setUserThemeRoundness(int roundness)
void Theme::setUserThemeRoundness(int roundness)
{
if (m_userRoundness == roundness) {
return;
@ -122,28 +123,28 @@ void PlasmaThemeExtended::setUserThemeRoundness(int roundness)
saveConfig();
}
bool PlasmaThemeExtended::themeHasExtendedInfo() const
bool Theme::themeHasExtendedInfo() const
{
return m_themeHasExtendedInfo;
}
SchemeColors *PlasmaThemeExtended::defaultTheme() const
SchemeColors *Theme::defaultTheme() const
{
return m_defaultScheme;
}
SchemeColors *PlasmaThemeExtended::lightTheme() const
SchemeColors *Theme::lightTheme() const
{
return m_isLightTheme ? m_defaultScheme : m_reversedScheme;
}
SchemeColors *PlasmaThemeExtended::darkTheme() const
SchemeColors *Theme::darkTheme() const
{
return !m_isLightTheme ? m_defaultScheme : m_reversedScheme;
}
void PlasmaThemeExtended::setOriginalSchemeFile(const QString &file)
void Theme::setOriginalSchemeFile(const QString &file)
{
if (m_originalSchemePath == file) {
return;
@ -165,7 +166,7 @@ void PlasmaThemeExtended::setOriginalSchemeFile(const QString &file)
//! plasma will use in order to be consistent. Such an example
//! are the Breeze color schemes that have different values for
//! WM and the plasma theme records
void PlasmaThemeExtended::updateDefaultScheme()
void Theme::updateDefaultScheme()
{
QString defaultFilePath = m_extendedThemeDir.path() + "/" + DEFAULTCOLORSCHEME;
if (QFileInfo(defaultFilePath).exists()) {
@ -178,17 +179,17 @@ void PlasmaThemeExtended::updateDefaultScheme()
updateDefaultSchemeValues();
if (m_defaultScheme) {
disconnect(m_defaultScheme, &SchemeColors::colorsChanged, this, &PlasmaThemeExtended::loadThemeLightness);
disconnect(m_defaultScheme, &SchemeColors::colorsChanged, this, &Theme::loadThemeLightness);
m_defaultScheme->deleteLater();
}
m_defaultScheme = new SchemeColors(this, m_defaultSchemePath, true);
connect(m_defaultScheme, &SchemeColors::colorsChanged, this, &PlasmaThemeExtended::loadThemeLightness);
connect(m_defaultScheme, &SchemeColors::colorsChanged, this, &Theme::loadThemeLightness);
qDebug() << "plasma theme default colors ::: " << m_defaultSchemePath;
}
void PlasmaThemeExtended::updateDefaultSchemeValues()
void Theme::updateDefaultSchemeValues()
{
//! update WM values based on original scheme
KSharedConfigPtr originalPtr = KSharedConfig::openConfig(m_originalSchemePath);
@ -205,7 +206,7 @@ void PlasmaThemeExtended::updateDefaultSchemeValues()
}
}
void PlasmaThemeExtended::updateReversedScheme()
void Theme::updateReversedScheme()
{
QString reversedFilePath = m_extendedThemeDir.path() + "/" + REVERSEDCOLORSCHEME;
@ -227,7 +228,7 @@ void PlasmaThemeExtended::updateReversedScheme()
qDebug() << "plasma theme reversed colors ::: " << m_reversedSchemePath;
}
void PlasmaThemeExtended::updateReversedSchemeValues()
void Theme::updateReversedSchemeValues()
{
//! reverse values based on original scheme
KSharedConfigPtr originalPtr = KSharedConfig::openConfig(m_originalSchemePath);
@ -285,7 +286,7 @@ void PlasmaThemeExtended::updateReversedSchemeValues()
}
void PlasmaThemeExtended::loadRoundness()
void Theme::loadRoundness()
{
if (!m_corona) {
return;
@ -327,7 +328,7 @@ void PlasmaThemeExtended::loadRoundness()
emit roundnessChanged();
}
void PlasmaThemeExtended::loadThemePaths()
void Theme::loadThemePaths()
{
m_themePath = "";
@ -376,7 +377,7 @@ void PlasmaThemeExtended::loadThemePaths()
}
}
void PlasmaThemeExtended::loadThemeLightness()
void Theme::loadThemeLightness()
{
float textColorLum = Latte::colorLumina(m_defaultScheme->textColor());
float backColorLum = Latte::colorLumina(m_defaultScheme->backgroundColor());
@ -394,12 +395,12 @@ void PlasmaThemeExtended::loadThemeLightness()
}
}
void PlasmaThemeExtended::loadConfig()
void Theme::loadConfig()
{
m_userRoundness = m_themeGroup.readEntry("userSetPlasmaThemeRoundness", 0);
}
void PlasmaThemeExtended::saveConfig()
void Theme::saveConfig()
{
m_themeGroup.writeEntry("userSetPlasmaThemeRoundness", m_userRoundness);
@ -407,3 +408,4 @@ void PlasmaThemeExtended::saveConfig()
}
}
}

@ -43,8 +43,9 @@ class Corona;
}
namespace Latte {
namespace PlasmaExtended {
class PlasmaThemeExtended: public QObject
class Theme: public QObject
{
Q_OBJECT
Q_PROPERTY(bool hasShadow READ hasShadow NOTIFY hasShadowChanged)
@ -61,8 +62,8 @@ class PlasmaThemeExtended: public QObject
Q_PROPERTY(SchemeColors *darkTheme READ darkTheme NOTIFY themeChanged)
public:
PlasmaThemeExtended(KSharedConfig::Ptr config, QObject *parent);
~PlasmaThemeExtended() override;;
Theme(KSharedConfig::Ptr config, QObject *parent);
~Theme() override;;
bool hasShadow() const;
bool isLightTheme() const;
@ -130,6 +131,7 @@ private:
SchemeColors *m_reversedScheme{nullptr};
};
}
}
#endif

@ -25,11 +25,11 @@
#include "layout.h"
#include "layoutmanager.h"
#include "importer.h"
#include "plasmathemeextended.h"
#include "universalsettings.h"
#include "ui_settingsdialog.h"
#include "../lattecorona.h"
#include "../liblatte2/types.h"
#include "../plasma/extended/theme.h"
#include "delegates/checkboxdelegate.h"
#include "delegates/colorcmbboxdelegate.h"
#include "delegates/activitycmbboxdelegate.h"

@ -29,8 +29,8 @@
#include "../lattecorona.h"
#include "../layout.h"
#include "../layoutmanager.h"
#include "../plasma/extended/theme.h"
#include "../screenpool.h"
#include "../plasmathemeextended.h"
#include "../settings/universalsettings.h"
#include "../../liblatte2/extras.h"

Loading…
Cancel
Save