2020-08-12 12:02:46 +03:00
/*
* Copyright 2020 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 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-02-05 18:38:58 +02:00
# include "../data/genericdata.h"
# include "../data/generictable.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 ;
}
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-12 20:51:27 +02:00
bool layoutTemplateExists ( const QString & templateName ) const ;
bool viewTemplateExists ( const QString & templateName ) const ;
2021-02-13 01:43:49 +02:00
bool exportTemplate ( const QString & originFile , const QString & destinationFile , const Data : : AppletsTable & approvedApplets ) ;
2020-08-12 13:42:45 +03:00
Data : : Layout layoutTemplateForName ( const QString & layoutName ) ;
2020-08-12 18:56:46 +03:00
Data : : LayoutsTable systemLayoutTemplates ( ) ;
2021-02-05 18:38:58 +02:00
Data : : GenericTable < Data : : Generic > 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 ) ;
2020-08-14 09:57:39 +03:00
void importSystemLayouts ( ) ;
2020-08-13 21:28:52 +03:00
signals :
void newLayoutAdded ( const QString & path ) ;
2021-02-13 02:01:13 +02:00
void templatesChanged ( ) ;
private slots :
void onCustomTemplateDeleted ( const QString & file ) ;
2020-08-13 21:28:52 +03:00
2020-08-12 12:02:46 +03:00
private :
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-02-05 18:38:58 +02:00
Data : : GenericTable < Data : : Generic > m_viewTemplates ;
2020-08-12 12:02:46 +03:00
} ;
}
}
# endif //TEMPLATESMANAGER_H