Subversion Repositories Scribus

Rev

Rev 3171 | Rev 3931 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2834 cbradney 1
/***************************************************************************
2
        copyright            : (C) 2005 by Craig Bradney
3
        email                : cbradney@zip.com.au
4
***************************************************************************/
5
 
6
/***************************************************************************
7
*                                                                         *
8
*   This program is free software; you can redistribute it and/or modify  *
9
*   it under the terms of the GNU General Public License as published by  *
10
*   the Free Software Foundation; either version 2 of the License, or     *
11
*   (at your option) any later version.                                   *
12
*                                                                         *
13
***************************************************************************/
14
#ifndef PREFSMANAGER_H
15
#define PREFSMANAGER_H
16
 
17
#include <qobject.h>
18
 
2969 craig 19
#include "scribusapi.h"
2834 cbradney 20
#include "prefsstructs.h"
21
 
2835 cbradney 22
class PrefsFile;
23
 
2834 cbradney 24
/**
25
  * @author Craig Bradney
26
  * @brief Manage Scribus preferences here, and here alone
27
  * Start to move the preferences out of scribus.cpp and provide some
28
  * more features and hide some of the data within this class
2835 cbradney 29
  * TODO Move prefsFile in here from scribus.cpp and stop passing it in for convert12Preferences
30
  * TODO Lots more :)
2834 cbradney 31
  */
2969 craig 32
class SCRIBUS_API PrefsManager : public QObject
2834 cbradney 33
{
34
Q_OBJECT
35
public:
36
        PrefsManager(QObject *parent = 0, const char *name = 0);
37
        ~PrefsManager();
38
 
2835 cbradney 39
        /**
40
        * @brief Returns a pointer to the PrefsManager instance
41
        * @return A pointer to the PrefsManager instance
42
        */
43
        static PrefsManager* instance();
44
        /**
45
        * @brief Deletes the PrefsManager Instance
46
        * Must be called when PrefsManager is no longer needed.
47
        */
48
        static void deleteInstance();
2834 cbradney 49
 
2856 cbradney 50
        void setup();
2834 cbradney 51
        /**
2835 cbradney 52
        * @brief Initialise the defaults for prefs in this class
53
        * Only set the GUI font stuff up if we have a GUI!!!
54
        */
55
        void initDefaults();
56
        void initDefaultGUIFont(const QFont&);
3097 cbradney 57
        void initDefaultCheckerPrefs(CheckerPrefsList* cp);
2835 cbradney 58
        void initArrowStyles();
59
        ///Locate our preferences
60
        QString setupPreferencesLocation();
2856 cbradney 61
        /// copy 1.2 prefs XML before loading, and old .rc files that we do not yet convert
2835 cbradney 62
        bool copy12Preferences();
63
        /// convert 1.2 style preferences to new XML format
2856 cbradney 64
        void convert12Preferences();
2835 cbradney 65
        const QString preferencesLocation();
2859 cbradney 66
        void ReadPrefs();
67
        void ReadPrefsXML();
68
        void SavePrefs();
2862 cbradney 69
        void SavePrefsXML();
2889 cbradney 70
        //Moved from scribusXml.cpp
3170 craig 71
        bool WritePref(QString ho);
2889 cbradney 72
        bool ReadPref(QString ho);
2862 cbradney 73
 
74
        void setGhostscriptExecutable(const QString&);
75
        void setImageEditorExecutable(const QString&);
76
        const QString ghostscriptExecutable();
77
        const QString imageEditorExecutable();
3302 cbradney 78
        const int gsResolution(); //Get the users preferred preview resolution
2871 cbradney 79
        const QString documentDir(); // Get the users preferred document directory
80
        const int mouseWheelValue();
2873 cbradney 81
        const double displayScale(); // Get the user set display scale
82
        const QString& guiLanguage(); // Get the GUI language from preferences
83
        const QString& guiStyle(); // Get the GUI style from preferences
84
        const int& guiFontSize(); // Get the GUI style from preferences
85
        void setKeyEntry(const QString&, const QString&, const QString&, const int&);  
2871 cbradney 86
        void setShowStartupDialog(const bool);
87
        void setColorSet(const ColorList&); // Sets the preferences' color set
88
        void setColorSetName(const QString&); // Sets the preferences' color set name
89
        const ColorList& colorSet(); // Returns the preferences' color set
90
        ColorList* colorSetPtr(); // Returns a pointer to the preferences' color set. Needed for now until colors are better defined
91
        const QString& colorSetName(); // Returns the preferences' color set name
2870 cbradney 92
        const bool GetAllFonts(bool showFontInfo);
2835 cbradney 93
 
94
        ApplicationPrefs* applicationPrefs();
2856 cbradney 95
        PrefsFile* applicationPrefsFile();
96
        const bool importingFrom12x();
3170 craig 97
 
98
        // Return the last error reported by a PrefsManager method
99
        const QString & lastError() const;
100
 
101
        // Display a GUI alert informing the user that saving prefs failed.
102
        // This might want to move to another class later, perhaps being triggered
103
        // by a signal emitted here.
104
        void alertSavePrefsFailed() const;
3171 craig 105
        void alertLoadPrefsFailed() const;
2835 cbradney 106
 
2856 cbradney 107
        //Temporarily public while this class takes shape so progress can happen and cvs can build
2835 cbradney 108
        struct ApplicationPrefs appPrefs;
2856 cbradney 109
        PrefsFile* prefsFile;
2835 cbradney 110
private:
111
        /**
2834 cbradney 112
        * @brief The only instance of PrefsManager available.
113
        *
114
        * PrefsManager is singleton and the instance can be queried with the method
115
        * instance().
116
        */
117
        static PrefsManager* _instance;
2835 cbradney 118
 
119
        QString prefsLocation;
2856 cbradney 120
        bool importingFrom12;
2834 cbradney 121
 
3170 craig 122
        /// The last error message generated by a method of this class. Do not write "success" messages to this.
123
        QString m_lastError;
124
 
2834 cbradney 125
};
126
 
127
#endif