2019-03-17 14:47:39 +03:00
/*
2019-03-23 18:49:09 +03:00
* Copyright 2019 Michail Vourlakos < mvourlakos @ gmail . com >
2019-03-17 14:47:39 +03:00
*
* 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/>.
*/
2019-03-23 18:49:09 +03:00
# ifndef INDICATORFACTORY_H
# define INDICATORFACTORY_H
2019-03-17 14:47:39 +03:00
2019-03-28 22:51:24 +03:00
// local
# include "../../liblatte2/types.h"
2019-03-23 18:49:09 +03:00
// Qt
# include <QHash>
# include <QObject>
2019-03-29 00:18:15 +03:00
# include <QWidget>
2019-03-17 14:47:39 +03:00
2019-03-23 18:49:09 +03:00
class KPluginMetaData ;
2019-03-17 14:47:39 +03:00
2019-03-23 18:49:09 +03:00
namespace Latte {
namespace Indicator {
2019-03-17 14:47:39 +03:00
2019-03-23 18:49:09 +03:00
class Factory : public QObject
{
Q_OBJECT
2019-03-17 14:47:39 +03:00
2019-03-23 18:49:09 +03:00
public :
Factory ( QObject * parent ) ;
~ Factory ( ) override ;
2019-03-26 20:31:52 +03:00
int customPluginsCount ( ) ;
QStringList customPluginIds ( ) ;
QStringList customPluginNames ( ) ;
2019-03-31 14:53:12 +03:00
QStringList customLocalPluginIds ( ) ;
2019-03-26 20:31:52 +03:00
2019-03-23 18:49:09 +03:00
KPluginMetaData metadata ( QString pluginId ) ;
2019-03-29 00:18:15 +03:00
void downloadIndicator ( ) ;
2019-03-31 14:53:12 +03:00
void removeIndicator ( QString id ) ;
bool pluginExists ( QString id ) const ;
2019-12-31 16:49:53 +03:00
bool isCustomType ( const QString & id ) const ;
2019-03-29 00:18:15 +03:00
2019-06-03 19:09:08 +03:00
QString uiPath ( QString pluginName ) const ;
2019-03-28 22:51:24 +03:00
//! metadata record
static bool metadataAreValid ( KPluginMetaData & metadata ) ;
//! metadata file
static bool metadataAreValid ( QString & file ) ;
//! imports an indicator compressed file
static Latte : : Types : : ImportExportState importIndicatorFile ( QString compressedFile ) ;
2019-03-26 20:31:52 +03:00
signals :
2019-12-31 16:49:53 +03:00
void indicatorChanged ( const QString & indicatorId ) ;
void indicatorRemoved ( const QString & indicatorId ) ;
2019-03-26 20:31:52 +03:00
2019-03-31 14:53:12 +03:00
private :
2019-12-31 16:49:53 +03:00
void reload ( const QString & indicatorPath ) ;
void removeIndicatorRecords ( const QString & path ) ;
void discoverNewIndicators ( const QString & main ) ;
2019-03-31 14:53:12 +03:00
2019-03-23 18:49:09 +03:00
private :
QHash < QString , KPluginMetaData > m_plugins ;
2019-06-03 19:09:08 +03:00
QHash < QString , QString > m_pluginUiPaths ;
2019-03-23 18:49:09 +03:00
2019-03-26 20:31:52 +03:00
QStringList m_customPluginIds ;
QStringList m_customPluginNames ;
2019-03-31 14:53:12 +03:00
QStringList m_customLocalPluginIds ;
2019-03-29 00:18:15 +03:00
2019-12-31 16:49:53 +03:00
//! plugins paths
QStringList m_mainPaths ;
QStringList m_indicatorsPaths ;
2019-03-29 22:09:28 +03:00
2019-03-29 00:18:15 +03:00
QWidget * m_parentWidget ;
2019-03-23 18:49:09 +03:00
} ;
}
2019-03-17 14:47:39 +03:00
}
2019-03-23 18:49:09 +03:00
# endif