2018-10-26 22:39:58 +03:00
/*
* Copyright 2018 Michail Vourlakos < mvourlakos @ 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/>.
*
*/
# ifndef PLASMATHEMEEXTENDED_H
# define PLASMATHEMEEXTENDED_H
2018-12-02 02:05:52 +02:00
// local
# include "schemecolors.h"
2018-10-27 12:46:48 +03:00
2018-12-02 02:05:52 +02:00
// C++
2018-10-27 12:16:18 +03:00
# include <array>
2018-12-02 02:05:52 +02:00
// Qt
# include <QObject>
2018-10-27 12:16:18 +03:00
# include <QTemporaryDir>
2018-12-02 02:05:52 +02:00
// KDE
2018-10-26 23:36:40 +03:00
# include <KConfigGroup>
# include <KSharedConfig>
2018-12-02 02:05:52 +02:00
// Plasma
2018-10-26 22:39:58 +03:00
# include <Plasma/Theme>
namespace Latte {
2018-12-06 14:35:34 +02:00
class Corona ;
}
2018-10-26 22:39:58 +03:00
2018-12-06 14:35:34 +02:00
namespace Latte {
2018-12-13 20:03:14 +02:00
namespace PlasmaExtended {
2018-10-27 00:59:36 +03:00
2018-12-13 20:03:14 +02:00
class Theme : public QObject
2018-10-26 22:39:58 +03:00
{
Q_OBJECT
2018-12-01 10:08:19 +02:00
Q_PROPERTY ( bool hasShadow READ hasShadow NOTIFY hasShadowChanged )
2018-12-09 10:52:01 +02:00
Q_PROPERTY ( bool isLightTheme READ isLightTheme NOTIFY themeChanged )
Q_PROPERTY ( bool isDarkTheme READ isDarkTheme NOTIFY themeChanged )
2018-12-01 10:08:19 +02:00
2018-10-26 23:36:40 +03:00
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 )
2018-10-26 22:39:58 +03:00
2018-12-09 10:52:01 +02:00
Q_PROPERTY ( SchemeColors * defaultTheme READ defaultTheme NOTIFY themeChanged )
2018-12-01 10:08:19 +02:00
Q_PROPERTY ( SchemeColors * lightTheme READ lightTheme NOTIFY themeChanged )
Q_PROPERTY ( SchemeColors * darkTheme READ darkTheme NOTIFY themeChanged )
2018-10-27 12:46:48 +03:00
2018-10-26 22:39:58 +03:00
public :
2018-12-13 20:03:14 +02:00
Theme ( KSharedConfig : : Ptr config , QObject * parent ) ;
~ Theme ( ) override ; ;
2018-10-26 22:39:58 +03:00
2018-12-01 10:08:19 +02:00
bool hasShadow ( ) const ;
2018-12-09 10:52:01 +02:00
bool isLightTheme ( ) const ;
bool isDarkTheme ( ) const ;
2018-12-01 10:08:19 +02:00
2018-10-26 23:36:40 +03:00
int bottomEdgeRoundness ( ) const ;
int leftEdgeRoundness ( ) const ;
int topEdgeRoundness ( ) const ;
int rightEdgeRoundness ( ) const ;
int userThemeRoundness ( ) const ;
void setUserThemeRoundness ( int roundness ) ;
2018-12-09 10:52:01 +02:00
SchemeColors * defaultTheme ( ) const ;
2018-10-27 12:46:48 +03:00
SchemeColors * lightTheme ( ) const ;
SchemeColors * darkTheme ( ) const ;
2018-10-27 00:59:36 +03:00
void load ( ) ;
2018-10-26 23:36:40 +03:00
signals :
2018-12-01 10:08:19 +02:00
void hasShadowChanged ( ) ;
2018-10-26 23:36:40 +03:00
void roundnessChanged ( ) ;
2018-12-01 10:08:19 +02:00
void themeChanged ( ) ;
2018-10-26 22:39:58 +03:00
2018-10-26 23:36:40 +03:00
private slots :
void loadConfig ( ) ;
void saveConfig ( ) ;
2018-10-27 12:46:48 +03:00
void loadThemeLightness ( ) ;
2018-10-26 22:39:58 +03:00
private :
2018-10-27 12:16:18 +03:00
void loadThemePaths ( ) ;
2018-10-27 01:16:35 +03:00
void loadRoundness ( ) ;
2018-12-09 18:56:45 +02:00
void setOriginalSchemeFile ( const QString & file ) ;
void updateDefaultScheme ( ) ;
void updateDefaultSchemeValues ( ) ;
2018-10-27 12:16:18 +03:00
void updateReversedScheme ( ) ;
void updateReversedSchemeValues ( ) ;
2018-10-26 23:36:40 +03:00
bool themeHasExtendedInfo ( ) const ;
private :
2018-10-27 12:46:48 +03:00
bool m_isLightTheme { false } ;
2018-10-27 00:59:36 +03:00
bool m_themeHasExtendedInfo { false } ;
2018-10-26 23:36:40 +03:00
int m_bottomEdgeRoundness { 0 } ;
int m_leftEdgeRoundness { 0 } ;
int m_topEdgeRoundness { 0 } ;
int m_rightEdgeRoundness { 0 } ;
int m_userRoundness { 0 } ;
2018-10-27 01:16:35 +03:00
QString m_themePath ;
2018-12-09 18:56:45 +02:00
QString m_defaultSchemePath ;
QString m_originalSchemePath ;
2018-10-27 12:16:18 +03:00
QString m_reversedSchemePath ;
2018-10-27 01:16:35 +03:00
2018-10-27 12:16:18 +03:00
std : : array < QMetaObject : : Connection , 2 > m_kdeConnections ;
2018-10-27 00:59:36 +03:00
2018-10-27 12:16:18 +03:00
QTemporaryDir m_extendedThemeDir ;
KConfigGroup m_themeGroup ;
2018-10-26 22:39:58 +03:00
Plasma : : Theme m_theme ;
2018-12-06 14:35:34 +02:00
Latte : : Corona * m_corona { nullptr } ;
2018-12-09 18:56:45 +02:00
SchemeColors * m_defaultScheme { nullptr } ;
2018-10-27 12:46:48 +03:00
SchemeColors * m_reversedScheme { nullptr } ;
2018-10-26 22:39:58 +03:00
} ;
2018-12-13 20:03:14 +02:00
}
2018-10-26 22:39:58 +03:00
}
# endif