2019-04-05 19:59:15 +03:00
/*
* Copyright 2019 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 ABSTRACTLAYOUT_H
# define ABSTRACTLAYOUT_H
// Qt
# include <QObject>
2019-04-05 20:39:19 +03:00
// KDE
# include <KConfigGroup>
2019-04-07 23:02:13 +03:00
// Plasma
# include <Plasma>
namespace Plasma {
class Types ;
}
2019-05-02 12:58:56 +03:00
namespace Latte {
namespace Layout {
Q_NAMESPACE
enum Type {
Abstract = 0 ,
Generic ,
2019-05-03 17:01:48 +03:00
Central ,
2019-05-02 12:58:56 +03:00
Shared
} ;
Q_ENUM_NS ( Type ) ;
2020-04-23 19:35:26 +03:00
enum BackgroundStyle
{
ColorBackgroundStyle = 0 ,
PatternBackgroundStyle
} ;
Q_ENUM_NS ( BackgroundStyle ) ;
2019-05-02 12:58:56 +03:00
}
}
2019-04-05 19:59:15 +03:00
namespace Latte {
namespace Layout {
2020-08-14 09:08:01 +03:00
const char MULTIPLELAYOUTSHIDDENNAME [ ] = " .multiple-layouts_hidden " ;
2019-04-05 19:59:15 +03:00
class AbstractLayout : public QObject
{
Q_OBJECT
2019-04-05 20:39:19 +03:00
Q_PROPERTY ( QString name READ name NOTIFY nameChanged )
2019-04-06 02:00:37 +03:00
Q_PROPERTY ( bool preferredForShortcutsTouched READ preferredForShortcutsTouched WRITE setPreferredForShortcutsTouched NOTIFY preferredForShortcutsTouchedChanged )
2020-07-30 23:51:50 +03:00
Q_PROPERTY ( QString icon READ icon NOTIFY iconChanged )
2019-04-05 20:39:19 +03:00
Q_PROPERTY ( QString background READ background NOTIFY backgroundChanged )
Q_PROPERTY ( QString textColor READ textColor NOTIFY textColorChanged )
2019-04-05 19:59:15 +03:00
2019-04-06 02:00:37 +03:00
Q_PROPERTY ( QStringList launchers READ launchers WRITE setLaunchers NOTIFY launchersChanged )
2020-03-25 02:30:30 +03:00
Q_PROPERTY ( QString lastUsedActivity READ lastUsedActivity NOTIFY lastUsedActivityChanged )
2019-04-06 02:00:37 +03:00
2019-04-05 19:59:15 +03:00
public :
2019-04-05 20:39:19 +03:00
AbstractLayout ( QObject * parent , QString layoutFile , QString assignedName = QString ( ) ) ;
2019-04-05 19:59:15 +03:00
~ AbstractLayout ( ) override ;
2019-04-05 20:39:19 +03:00
int version ( ) const ;
void setVersion ( int ver ) ;
2019-04-06 02:00:37 +03:00
bool preferredForShortcutsTouched ( ) const ;
void setPreferredForShortcutsTouched ( bool touched ) ;
2020-08-30 20:32:13 +03:00
QString lastUsedActivity ( ) const ;
2019-04-06 02:00:37 +03:00
void clearLastUsedActivity ( ) ; //!e.g. when we export a layout
2019-04-05 20:39:19 +03:00
QString name ( ) const ;
QString file ( ) const ;
2020-07-30 18:09:49 +03:00
virtual QString background ( ) const ;
2019-04-05 20:39:19 +03:00
QString color ( ) const ;
void setColor ( QString color ) ;
2020-03-25 02:30:30 +03:00
QString customBackground ( ) const ;
void setCustomBackground ( const QString & background ) ;
QString customTextColor ( ) const ;
void setCustomTextColor ( const QString & customColor ) ;
2020-07-30 23:51:50 +03:00
QString icon ( ) const ;
void setIcon ( const QString & icon ) ;
2020-03-25 02:30:30 +03:00
QString predefinedTextColor ( ) const ;
2020-07-30 18:09:49 +03:00
virtual QString textColor ( ) const ;
2019-04-05 20:39:19 +03:00
void setTextColor ( QString color ) ;
2020-04-23 19:35:26 +03:00
BackgroundStyle backgroundStyle ( ) const ;
void setBackgroundStyle ( const BackgroundStyle & style ) ;
2020-03-25 02:30:30 +03:00
2019-04-06 02:00:37 +03:00
QStringList launchers ( ) const ;
void setLaunchers ( QStringList launcherList ) ;
2019-05-02 12:58:56 +03:00
virtual Type type ( ) const ;
2020-08-14 10:52:13 +03:00
void syncSettings ( ) ;
2019-04-05 20:39:19 +03:00
// STATIC
2020-07-30 18:09:49 +03:00
static QString defaultCustomTextColor ( ) ;
static QString defaultCustomBackground ( ) ;
2020-04-14 16:33:55 +03:00
static QString defaultTextColor ( const QString & color ) ;
2019-04-05 20:39:19 +03:00
static QString layoutName ( const QString & fileName ) ;
2019-04-07 23:02:13 +03:00
static QList < Plasma : : Types : : Location > combinedFreeEdges ( const QList < Plasma : : Types : : Location > & edges1 ,
const QList < Plasma : : Types : : Location > & edges2 ) ;
2019-04-05 20:39:19 +03:00
signals :
void backgroundChanged ( ) ;
2020-03-25 02:30:30 +03:00
void backgroundStyleChanged ( ) ;
void customBackgroundChanged ( ) ;
void customTextColorChanged ( ) ;
2019-04-05 20:39:19 +03:00
void colorChanged ( ) ;
void fileChanged ( ) ;
2020-07-30 23:51:50 +03:00
void iconChanged ( ) ;
2019-04-06 02:00:37 +03:00
void lastUsedActivityChanged ( ) ;
void launchersChanged ( ) ;
2019-04-05 20:39:19 +03:00
void nameChanged ( ) ;
2019-04-06 02:00:37 +03:00
void preferredForShortcutsTouchedChanged ( ) ;
2019-04-05 20:39:19 +03:00
void textColorChanged ( ) ;
void versionChanged ( ) ;
protected slots :
void loadConfig ( ) ;
void saveConfig ( ) ;
protected :
void init ( ) ;
void setName ( QString name ) ;
void setFile ( QString file ) ;
2019-04-05 19:59:15 +03:00
protected :
2019-04-05 20:39:19 +03:00
bool m_loadedCorrectly { false } ;
2019-04-06 02:00:37 +03:00
bool m_preferredForShortcutsTouched { false } ;
2019-04-05 20:39:19 +03:00
//if version doesn't exist it is and old layout file
int m_version { 2 } ;
2020-03-25 02:30:30 +03:00
QString m_customBackground ;
QString m_customTextColor ;
2019-04-05 20:39:19 +03:00
QString m_color ;
2019-04-06 02:00:37 +03:00
QString m_lastUsedActivity ; //the last used activity for this layout
2020-07-30 23:51:50 +03:00
QString m_icon ;
2020-03-25 02:30:30 +03:00
2020-04-23 19:35:26 +03:00
BackgroundStyle m_backgroundStyle { ColorBackgroundStyle } ;
2019-04-05 20:39:19 +03:00
QString m_layoutFile ;
QString m_layoutName ;
2019-04-06 02:00:37 +03:00
QStringList m_launchers ;
2019-04-05 20:39:19 +03:00
KConfigGroup m_layoutGroup ;
2020-03-25 02:30:30 +03:00
2019-04-05 19:59:15 +03:00
} ;
}
}
# endif