2020-08-12 12:02:46 +03:00
/*
2021-05-27 15:01:00 +00:00
SPDX - FileCopyrightText : 2020 Michail Vourlakos < mvourlakos @ gmail . com >
SPDX - License - Identifier : GPL - 2.0 - or - later
2020-08-12 12:02:46 +03:00
*/
# ifndef TEMPLATESMANAGER_H
# define TEMPLATESMANAGER_H
// local
# include "../lattecorona.h"
2021-02-13 01:43:49 +02:00
# include "../data/appletdata.h"
2020-08-12 12:02:46 +03:00
# include "../data/layoutdata.h"
2020-08-12 12:27:35 +03:00
# include "../data/layoutstable.h"
2021-04-08 12:33:39 +03:00
# include "../data/genericbasictable.h"
2020-08-12 12:02:46 +03:00
// Qt
# include <QObject>
2020-08-13 20:42:38 +03:00
// KDE
# include <KLocalizedString>
2020-08-12 12:02:46 +03:00
namespace Latte {
class Corona ;
2021-02-13 19:52:52 +02:00
class View ;
2020-08-12 12:02:46 +03:00
}
namespace Latte {
namespace Templates {
2020-08-12 12:55:43 +03:00
const char DEFAULTLAYOUTTEMPLATENAME [ ] = " Default " ;
const char EMPTYLAYOUTTEMPLATENAME [ ] = " Empty " ;
2020-08-12 12:02:46 +03:00
class Manager : public QObject
{
Q_OBJECT
public :
Manager ( Latte : : Corona * corona = nullptr ) ;
~ Manager ( ) override ;
Latte : : Corona * corona ( ) ;
void init ( ) ;
2021-02-16 15:23:56 +02:00
bool hasCustomLayoutTemplate ( const QString & templateName ) const ;
bool hasLayoutTemplate ( const QString & templateName ) const ;
bool hasViewTemplate ( const QString & templateName ) const ;
2021-02-12 20:51:27 +02:00
2021-02-13 01:43:49 +02:00
bool exportTemplate ( const QString & originFile , const QString & destinationFile , const Data : : AppletsTable & approvedApplets ) ;
2021-02-13 19:52:52 +02:00
bool exportTemplate ( const Latte : : View * view , const QString & destinationFile , const Data : : AppletsTable & approvedApplets ) ;
2021-02-13 01:43:49 +02:00
2020-08-12 13:42:45 +03:00
Data : : Layout layoutTemplateForName ( const QString & layoutName ) ;
2021-02-16 16:46:52 +02:00
Data : : LayoutsTable layoutTemplates ( ) ;
2021-04-08 12:33:39 +03:00
Data : : GenericBasicTable viewTemplates ( ) ;
2020-08-12 18:56:46 +03:00
2020-08-13 21:28:52 +03:00
//! creates a new layout with layoutName based on specific layout template and returns the new layout path
2020-08-13 20:42:38 +03:00
QString newLayout ( QString layoutName , QString layoutTemplate = i18n ( DEFAULTLAYOUTTEMPLATENAME ) ) ;
2021-02-12 20:51:27 +02:00
QString proposedTemplateAbsolutePath ( QString templateFilename ) ;
2021-06-28 17:07:53 +03:00
QString viewTemplateFilePath ( const QString templateName ) const ;
2021-12-06 19:26:34 +02:00
static QString templateName ( const QString & filePath ) ;
2020-08-14 09:57:39 +03:00
void importSystemLayouts ( ) ;
2021-02-16 16:11:41 +02:00
void installCustomLayoutTemplate ( const QString & templateFilePath ) ;
2020-08-14 09:57:39 +03:00
2020-08-13 21:28:52 +03:00
signals :
void newLayoutAdded ( const QString & path ) ;
2021-02-13 12:38:34 +02:00
void layoutTemplatesChanged ( ) ;
void viewTemplatesChanged ( ) ;
2021-02-13 02:01:13 +02:00
private slots :
2021-02-13 12:38:34 +02:00
void onCustomTemplatesCountChanged ( const QString & file ) ;
2020-08-13 21:28:52 +03:00
2020-08-12 12:02:46 +03:00
private :
2021-02-13 12:38:34 +02:00
void initLayoutTemplates ( ) ;
void initViewTemplates ( ) ;
2021-02-12 21:02:42 +02:00
void initLayoutTemplates ( const QString & path ) ;
void initViewTemplates ( const QString & path ) ;
2020-08-12 12:02:46 +03:00
void exposeTranslatedTemplateNames ( ) ;
2021-02-12 20:51:27 +02:00
QString uniqueLayoutTemplateName ( QString name ) const ;
QString uniqueViewTemplateName ( QString name ) const ;
2020-08-12 12:02:46 +03:00
private :
Latte : : Corona * m_corona ;
2020-08-12 12:27:35 +03:00
Data : : LayoutsTable m_layoutTemplates ;
2021-04-08 12:33:39 +03:00
Data : : GenericBasicTable m_viewTemplates ;
2020-08-12 12:02:46 +03:00
} ;
}
}
# endif //TEMPLATESMANAGER_H