File indexing completed on 2024-04-14 04:00:07

0001 /***************************************************************************
0002                           cglobalsettings.h  -  global application settings
0003     This file is a part of KMuddy distribution.
0004                              -------------------
0005     begin                : St Aug 14 2002
0006     copyright            : (C) 2002-2007 by Tomas Mecir
0007     email                : kmuddy@kmuddy.com
0008  ***************************************************************************/
0009 
0010 /***************************************************************************
0011  *                                                                         *
0012  *   This program is free software; you can redistribute it and/or modify  *
0013  *   it under the terms of the GNU General Public License as published by  *
0014  *   the Free Software Foundation; either version 2 of the License, or     *
0015  *   (at your option) any later version.                                   *
0016  *                                                                         *
0017  ***************************************************************************/
0018 
0019 #ifndef CGLOBALSETTINGS_H
0020 #define CGLOBALSETTINGS_H
0021 
0022 #include <qcolor.h>
0023 #include <qfont.h>
0024 #include <qobject.h>
0025 #include <kmuddy_export.h>
0026 
0027 class dlgAppSettings;
0028 class KActionCollection;
0029 /**
0030 Class that stores and manages global application configuration.
0031   *@author Tomas Mecir
0032   */
0033 
0034 class KMUDDY_EXPORT cGlobalSettings {
0035 public:
0036   static cGlobalSettings *self();
0037   ~cGlobalSettings();
0038 
0039   void setBool (const QString &name, bool value);
0040   void setInt (const QString &name, int value);
0041   void setString (const QString &name, const QString &value);
0042   void setColor (const QString &name, QColor value);
0043   void setFont (const QString &name, QFont value);
0044 
0045   bool getBool (const QString &name);
0046   int getInt (const QString &name);
0047   QString getString (const QString &name);
0048   QColor getColor (const QString &name);
0049   QFont getFont (const QString &name);
0050 
0051   void setDefaultBool (const QString &name, bool val);
0052   void setDefaultInt (const QString &name, int val);
0053   void setDefaultString (const QString &name, const QString &val);
0054   void setDefaultColor (const QString &name, const QColor &val);
0055   void setDefaultFont (const QString &name, const QFont &val);
0056 
0057   /** Returns profile path. Convenience wrapper around getString. */
0058   QString profilePath ();
0059   /** Set profile path. Convenience wrapper around setString.  */
0060   void setProfilePath (const QString &path);
0061 
0062   /** Notify everyone that settings have changed. It should rarely be necessary to call this. */
0063   void notifyChange ();
0064 
0065   /** disable events upon changing settings */
0066   void disableEvents ();
0067   /** enable events upon changing settings */
0068   void enableEvents ();
0069 
0070 private:
0071   cGlobalSettings();
0072   static cGlobalSettings *_self;
0073 
0074   /** Sets default global configuration options. */
0075   void setDefaultOptions ();
0076 
0077   /** load settings from kmuddyrc */
0078   void load ();
0079   /** load old-style settings from kmuddyrc */
0080   void loadOldConfig ();
0081   /** save settings there */
0082   void save ();
0083 
0084   struct Private;
0085   Private *d;
0086 
0087   /** the dialog itself */
0088   dlgAppSettings *sdlg;
0089 };
0090 
0091 
0092 #endif