1 /*****************************************************************************
2 ** QNapi
3 ** Copyright (C) 2008-2017 Piotr Krzemiński <pio.krzeminski@gmail.com>
4 **
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12 **
13 *****************************************************************************/
14 
15 #ifndef CONFIGREADER_H
16 #define CONFIGREADER_H
17 
18 #include <QMap>
19 #include <QSettings>
20 #include <QSharedPointer>
21 #include <QString>
22 
23 #include <config/engineconfig.h>
24 #include <config/qnapiconfig.h>
25 #include <config/staticconfig.h>
26 
27 #include <engines/subtitledownloadenginesregistry.h>
28 
29 class ConfigReader {
30  public:
31   ConfigReader(const QString& appExecutableDir,
32                const QSharedPointer<const StaticConfig>& staticConfig,
33                const QSharedPointer<const SubtitleDownloadEnginesRegistry>
34                    enginesRegistry);
35 
36   const QNapiConfig readUserConfig() const;
37   const QNapiConfig readPortableConfig(const QString& configFilePath) const;
38   const QNapiConfig readConfig(const QSettings& settings) const;
39 
40  private:
41   const GeneralConfig readGeneralConfig(const QSettings& settings) const;
42   const QList<QPair<QString, bool>> readEnabledEngines(
43       const QSettings& settings) const;
44   const QMap<QString, EngineConfig> readEnginesConfig(
45       const QSettings& settings) const;
46   const EngineConfig readEngineConfig(QString engineName,
47                                       const QSettings& settings) const;
48   const PostProcessingConfig readPostProcessingConfig(
49       const QSettings& settings) const;
50   const ScanConfig readScanConfig(const QSettings& settings) const;
51 
52   const GeneralConfig resolveP7zipPath(const GeneralConfig& config) const;
53   const GeneralConfig resolveTmpPath(const GeneralConfig& config) const;
54 
55   QString appExecutableDir;
56   QSharedPointer<const StaticConfig> staticConfig;
57   QSharedPointer<const SubtitleDownloadEnginesRegistry> enginesRegistry;
58 };
59 
60 #endif  // CONFIGREADER_H
61