2017-07-02 15:02:07 +03:00
/*
* Copyright 2017 Smith AR < audoban @ openmailbox . org >
* 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 IMPORTER_H
# define IMPORTER_H
# include <QObject>
2018-02-03 11:34:13 +02:00
namespace Latte {
2017-07-02 21:02:27 +03:00
class LayoutManager ;
2018-02-03 11:34:13 +02:00
}
2017-07-02 21:02:27 +03:00
2017-07-02 15:02:07 +03:00
namespace Latte {
2017-07-02 15:06:35 +03:00
//! This class is responsible to import/export configurations
//! and of course to import old configuration to new architecture
2018-07-03 22:15:45 +03:00
class Importer : public QObject
{
2017-07-02 15:02:07 +03:00
Q_OBJECT
public :
2018-07-03 22:15:45 +03:00
enum LatteFileVersion
{
2017-07-22 17:59:23 +03:00
UnknownFileType = - 1 ,
LayoutVersion1 = 0 ,
ConfigVersion1 = 1 ,
LayoutVersion2 = 2 ,
ConfigVersion2 = 3
} ;
Q_ENUM ( LatteFileVersion ) ;
2017-07-02 15:02:07 +03:00
Importer ( QObject * parent = nullptr ) ;
~ Importer ( ) override ;
2017-07-02 20:19:18 +03:00
//! updates the old configuration to version: 2
bool updateOldConfiguration ( ) ;
//! imports an old layout file,
//! newName: the layout new name, if it is empty the original is used
//! alternative: old files can contain both a Default and an Alternative layout
//! false: imports only Default layout
//! true: imports only Alternative layout
2017-07-22 19:49:28 +03:00
bool importOldLayout ( QString oldAppletsPath , QString newName , bool alternative = false , QString exportDirectory = QString ( ) ) ;
2017-07-02 20:19:18 +03:00
2017-07-03 00:34:59 +03:00
//! imports and old configuration file (tar archive) that contains
//! both an applets file and a latterc file with the screens
//! newName: if it is empty the name is extracted from the old config file name
bool importOldConfiguration ( QString oldConfigPath , QString newName = QString ( ) ) ;
2017-07-22 22:52:31 +03:00
bool exportFullConfiguration ( QString file ) ;
2017-07-22 17:59:23 +03:00
static Importer : : LatteFileVersion fileVersion ( QString file ) ;
2017-12-17 17:42:49 +02:00
2017-07-22 23:15:54 +03:00
static bool importHelper ( QString fileName ) ;
2017-12-17 18:34:50 +02:00
//! check if this layout exists already in the latte directory
static bool layoutExists ( QString layoutName ) ;
2017-12-17 19:08:35 +02:00
//! imports the specific layout and return the new layout name.
2018-08-30 08:47:53 +03:00
//! if the function didn't succeed return an empty string
2017-12-17 19:08:35 +02:00
static QString importLayoutHelper ( QString fileName ) ;
2017-12-17 18:34:50 +02:00
2018-01-15 14:09:41 +02:00
//! return the file path of a layout either existing or not
static QString layoutFilePath ( QString layoutName ) ;
2017-12-17 17:42:49 +02:00
static QString nameOfConfigFile ( const QString & fileName ) ;
static QString uniqueLayoutName ( QString name ) ;
2018-01-15 14:09:41 +02:00
2017-12-17 18:13:26 +02:00
static QStringList availableLayouts ( ) ;
2018-01-15 14:09:41 +02:00
//! it checks the linked file if there are Containments in it that belong
//! to Original Layouts and moves them accordingly. This is used mainly on
2018-08-30 08:47:53 +03:00
//! startup and if such state occurs, it basically means that the app didn't
2018-01-15 14:09:41 +02:00
//! close correctly, e.g. there was a crash.
static QStringList checkRepairMultipleLayoutsLinkedFile ( ) ;
2017-12-17 17:42:49 +02:00
2017-07-02 20:19:18 +03:00
private :
//! checks if this old layout can be imported. If it can it returns
//! the new layout path and an empty string if it cant
2017-07-22 19:49:28 +03:00
QString layoutCanBeImported ( QString oldAppletsPath , QString newName , QString exportDirectory = QString ( ) ) ;
2017-07-02 21:02:27 +03:00
LayoutManager * m_manager ;
2017-07-02 15:02:07 +03:00
} ;
}
# endif // IMPORTER_H