home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / include / scribus-ng / prefsmanager.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-05-12  |  8.3 KB  |  223 lines

  1. /*
  2. For general Scribus (>=1.3.2) copyright and licensing information please refer
  3. to the COPYING file provided with the program. Following this notice may exist
  4. a copyright and/or license notice that predates the release of Scribus 1.3.2
  5. for which a new license (GPL+exception) is in place.
  6. */
  7. /***************************************************************************
  8.     copyright            : (C) 2005 by Craig Bradney
  9.     email                : cbradney@zip.com.au
  10. ***************************************************************************/
  11.  
  12. /***************************************************************************
  13. *                                                                         *
  14. *   This program is free software; you can redistribute it and/or modify  *
  15. *   it under the terms of the GNU General Public License as published by  *
  16. *   the Free Software Foundation; either version 2 of the License, or     *
  17. *   (at your option) any later version.                                   *
  18. *                                                                         *
  19. ***************************************************************************/
  20. #ifndef PREFSMANAGER_H
  21. #define PREFSMANAGER_H
  22.  
  23. #include <QKeySequence>
  24. #include <QMap>
  25. #include <QObject>
  26. #include <QStringList>
  27.  
  28. #include "prefsstructs.h"
  29. #include "scribusapi.h"
  30.  
  31. class PrefsFile;
  32. class ScribusMainWindow;
  33.  
  34.  
  35. /**
  36.   * @author Craig Bradney
  37.   * @brief Manage Scribus preferences here, and here alone
  38.   * Start to move the preferences out of scribus.cpp and provide some
  39.   * more features and hide some of the data within this class
  40.   * TODO Move prefsFile in here from scribus.cpp and stop passing it in for convertOldPreferences
  41.   * TODO Lots more :)
  42.   */
  43. class SCRIBUS_API PrefsManager : public QObject
  44. {
  45. Q_OBJECT
  46. public:
  47.     PrefsManager(QObject *parent = 0);
  48.     ~PrefsManager();
  49.  
  50.     /**
  51.     * @brief Returns a pointer to the PrefsManager instance
  52.     * @return A pointer to the PrefsManager instance
  53.     */
  54.     static PrefsManager* instance();
  55.     /**
  56.     * @brief Deletes the PrefsManager Instance
  57.     * Must be called when PrefsManager is no longer needed.
  58.     */
  59.     static void deleteInstance();
  60.  
  61.     void setup();
  62.     /*!
  63.     \brief Initialise the defaults for prefs in this class
  64.     Only set the GUI font stuff up if we have a GUI!!!
  65.     Must be run after: PrefsManager::GetAllFonts()
  66.     */
  67.     void initDefaults();
  68.     void initDefaultGUIFont(const QFont&);
  69.     void initDefaultCheckerPrefs(CheckerPrefsList* cp);
  70.     void initDefaultActionKeys();
  71.     void applyLoadedShortCuts();
  72.     void initArrowStyles();
  73.     /*!
  74.     \author Craig Bradney
  75.     \date Thu 18 Nov 2004
  76.     \brief Set the user's preference file location. Rename any existing old preferences files
  77.     \retval QString Location of the user's preferences
  78.     */
  79.     QString setupPreferencesLocation();
  80.     /*!
  81.     \author Craig Bradney
  82.     \date Sun 09 Jan 2005
  83.     \brief Copy 1.2 prefs XML before loading, and copy rc files we don't yet convert
  84.     \retval bool true if prefs were imported
  85.     */
  86.     bool copyOldPreferences();
  87.     /*!
  88.     \author Craig Ringer
  89.     \date Sun 26 June 2005
  90.     \brief Move and convert 1.2 style preferences to new XML format
  91.     \retval None
  92.     */
  93.     void convert12Preferences();
  94.     /*!
  95.     \brief Get the prefs location property
  96.     \retval QString Location of the user's preferences
  97.     */
  98.     const QString preferencesLocation();
  99.  
  100.     /*! \brief Read the preferences.
  101.     \param fname optional filename with preferences. If is not given,
  102.     the defualt is used. */
  103.     void ReadPrefs(const QString & fname=QString::null);
  104.     void ReadPrefsXML();
  105.  
  106.     /*! \brief Save the preferences.
  107.     \param fname optional filename with preferences. If is not given,
  108.     the defualt is used. */
  109.     void SavePrefs(const QString & fname=QString::null);
  110.     void SavePrefsXML();
  111.  
  112.     /*! \brief Writes the preferences physically to the file.
  113.     Here is the XML file created itself.
  114.     \param ho a file name to write
  115.     \retval bool true on success, false on write error */
  116.     bool WritePref(QString ho);
  117.     /*! \brief Reads the preferences physically from the file.
  118.     Here is the XML file parsed itself. Returns false on error. 
  119.     It's the caller's job to make sure the prefs file actually exists.
  120.     \param ho a file name to write
  121.     \retval bool true on success, false on write error */
  122.     bool ReadPref(QString ho);
  123.     //! \brief Set up the main window with prefs values, recent files list, main window size etc
  124.     void setupMainWindow(ScribusMainWindow* mw);
  125.     void setGhostscriptExecutable(const QString&);
  126.     void setImageEditorExecutable(const QString&);
  127.     void setExtBrowserExecutable(const QString&);
  128.     void setLatexConfigs(const QStringList&);
  129.     void setLatexCommands(const QMap<QString, QString>& commands) { appPrefs.latexCommands=commands; }
  130.     void setLatexEditorExecutable(const QString&);
  131.     QString ghostscriptExecutable() const {return appPrefs.gs_exe;};
  132.     QString imageEditorExecutable() const {return appPrefs.imageEditorExecutable;};
  133.     QString extBrowserExecutable() const {return appPrefs.extBrowserExecutable;};
  134.     QStringList latexConfigs() const {return appPrefs.latexConfigs;}
  135.     QMap<QString, QString> latexCommands() const {return appPrefs.latexCommands;}
  136.     QString latexEditorExecutable() const {return appPrefs.latexEditorExecutable;}
  137.     bool latexStartWithEmptyFrames() const {return appPrefs.latexStartWithEmptyFrames;}
  138.     //! \brief Get the users preferred preview resolution
  139.     int gsResolution();
  140.     int latexResolution() const {return appPrefs.latexResolution;}
  141.     bool latexForceDpi() const {return appPrefs.latexForceDpi;}
  142.     //! \brief Get the users preferred document directory
  143.     const QString documentDir();
  144.     void setDocumentDir(const QString& dirname);
  145.     int mouseWheelValue() const;
  146.     //! \brief Get the user set display scale
  147.     double displayScale() const;
  148.     //! \brief Get the GUI language from preferences
  149.     const QString& guiLanguage() const;
  150.     //! \brief Get the GUI style from preferences
  151.     const QString& guiStyle() const;
  152.     const QString& guiSystemStyle() const;
  153.     //! \brief Get the GUI style from preferences
  154.     const int& guiFontSize() const;
  155.     const int& paletteFontSize() const;
  156.     void setKeyEntry(const QString&, const QString&, const QKeySequence&, const int&);
  157.     void setShowStartupDialog(const bool);
  158.     bool showPageShadow() const;
  159.     //! \brief Sets the preferences' color set
  160.     void setColorSet(const ColorList&);
  161.     //! \brief Sets the preferences' color set name
  162.     void setColorSetName(const QString&);
  163.     //! \brief Returns the preferences' color set
  164.     const ColorList& colorSet();
  165.     //! \brief Returns a pointer to the preferences' color set. Needed for now until colors are better defined
  166.     ColorList* colorSetPtr();
  167.     //! \brief Returns the preferences' color set name
  168.     const QString& colorSetName();
  169.     /*! \brief Return if a color belongs to tools prefs colors */
  170.     bool isToolColor(const QString& name);
  171.     static bool isToolColor(const struct toolPrefs& settings, const QString& name);
  172.     /*! \brief Return the list of used colors in tool prefs */
  173.     QStringList toolColorNames();
  174.     static QStringList toolColorNames(const struct toolPrefs& settings);
  175.     /*! \brief Replace used colors in tool prefs */
  176.     void replaceToolColors(const QMap<QString, QString> replaceMap);
  177.     static void replaceToolColors(struct toolPrefs& settings, const QMap<QString, QString> replaceMap);
  178.     /*! \brief Finds the fonts on the system
  179.     Must be run after: PrefsManager::setup()
  180.     Must be run before: PrefsManager::initDefaults()
  181.     \param showFontInfo flag to get extended fotn info
  182.     \retval bool true on finding 1 or more fonts */
  183.     bool GetAllFonts(bool showFontInfo);
  184.  
  185.     ApplicationPrefs* applicationPrefs();
  186.     PrefsFile* applicationPrefsFile();
  187.     bool importingFrom12x();
  188.  
  189.     //! \brief Return the last error reported by a PrefsManager method
  190.     const QString & lastError() const;
  191.  
  192.     /*! \brief Display a GUI alert informing the user that saving prefs failed.
  193.     This might want to move to another class later, perhaps being triggered
  194.     by a signal emitted here. */
  195.     void alertSavePrefsFailed() const;
  196.     void alertLoadPrefsFailed() const;
  197.  
  198.     //! \brief Temporarily public while this class takes shape so progress can happen and cvs can build
  199.     struct ApplicationPrefs appPrefs;
  200.     PrefsFile* prefsFile;
  201. private:
  202.     /**
  203.     * @brief The only instance of PrefsManager available.
  204.     *
  205.     * PrefsManager is singleton and the instance can be queried with the method
  206.     * instance().
  207.     */
  208.     static PrefsManager* _instance;
  209.  
  210.     QString prefsLocation;
  211.     bool importingFrom12;
  212.     bool firstTimeIgnoreOldPrefs;
  213.  
  214.     /*! \brief The last error message generated by a method of this class.
  215.     Do not write "success" messages to this. */
  216.     QString m_lastError;
  217.  
  218. signals:
  219.     void prefsChanged();
  220. };
  221.  
  222. #endif
  223.