UniversalIndentGUI 1.2.0
|
00001 /*************************************************************************** 00002 * Copyright (C) 2006-2012 by Thomas Schweitzer * 00003 * thomas-schweitzer(at)arcor.de * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License version 2.0 as * 00007 * published by the Free Software Foundation. * 00008 * * 00009 * This program is distributed in the hope that it will be useful, * 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00012 * GNU General Public License for more details. * 00013 * * 00014 * You should have received a copy of the GNU General Public License * 00015 * along with this program in the file LICENSE.GPL; if not, write to the * 00016 * Free Software Foundation, Inc., * 00017 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00018 ***************************************************************************/ 00019 00020 #ifndef UIGUISETTINGS_H 00021 #define UIGUISETTINGS_H 00022 00023 #include <QObject> 00024 #include <QStringList> 00025 #include <QMultiMap> 00026 #include <QSharedPointer> 00027 00028 class QSettings; 00029 00030 00031 class UiGuiSettings : public QObject 00032 { 00033 Q_OBJECT 00034 private: 00035 UiGuiSettings(); 00036 static QWeakPointer<UiGuiSettings> _instance; 00037 00038 public: 00039 static QSharedPointer<UiGuiSettings> getInstance(); 00040 ~UiGuiSettings(); 00041 00042 bool registerObjectProperty(QObject *obj, const QString &propertyName, const QString &settingName); 00043 bool registerObjectPropertyRecursive(QObject *obj); 00044 bool setObjectPropertyToSettingValue(QObject *obj, const QString &propertyName, const QString &settingName); 00045 bool setObjectPropertyToSettingValueRecursive(QObject *obj); 00046 bool setSettingToObjectPropertyValue(QObject *obj, const QString &propertyName, const QString &settingName); 00047 bool setSettingToObjectPropertyValueRecursive(QObject *obj); 00048 bool registerObjectSlot(QObject *obj, const QString &slotName, const QString &settingName); 00049 QVariant getValueByName(QString settingName); 00050 QStringList getAvailableTranslations(); 00051 00052 public slots: 00053 void setValueByName(const QString &settingName, const QVariant &value); 00054 void unregisterObjectProperty(QObject *obj); 00055 void unregisterObjectSlot(QObject *obj, const QString &slotName = "", const QString &settingName = ""); 00056 00057 protected: 00058 bool initSettings(); 00059 bool invokeMethodWithValue(QObject *obj, QMetaMethod mMethod, QVariant value); 00060 bool checkCustomPropertiesAndCallFunction(QObject *obj, bool (UiGuiSettings::*callBackFunc)(QObject *obj, const QString &propertyName, const QString &settingName)); 00061 00062 private slots: 00063 void handleObjectPropertyChange(); 00064 00065 private: 00066 void readAvailableTranslations(); 00067 00069 QStringList _availableTranslations; 00070 00072 QSettings *_qsettings; 00073 00075 QMap<QObject*, QStringList> _registeredObjectProperties; 00076 00078 QMultiMap<QObject*, QStringList> _registeredObjectSlots; 00079 00080 QString _indenterDirctoryStr; 00081 }; 00082 00083 #endif // UIGUISETTINGS_H