00001 /*************************************************************************** 00002 * file klfconfig.h 00003 * This file is part of the KLatexFormula Project. 00004 * Copyright (C) 2007 by Philippe Faist 00005 * philippe.faist at bluewin.ch 00006 * * 00007 * This program is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU General Public License as published by * 00009 * the Free Software Foundation; either version 2 of the License, or * 00010 * (at your option) any later version. * 00011 * * 00012 * This program is distributed in the hope that it will be useful, * 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00015 * GNU General Public License for more details. * 00016 * * 00017 * You should have received a copy of the GNU General Public License * 00018 * along with this program; if not, write to the * 00019 * Free Software Foundation, Inc., * 00020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00021 ***************************************************************************/ 00022 /* $Id$ */ 00023 00024 #ifndef KLFCONFIG_H 00025 #define KLFCONFIG_H 00026 00027 #include <qglobal.h> 00028 #include <QString> 00029 #include <QFont> 00030 #include <QSize> 00031 #include <QColor> 00032 #include <QSettings> 00033 #include <QTextCharFormat> 00034 #include <QMap> 00035 00036 #include <klfbackend.h> 00037 00038 class KLFConfig; 00039 00061 class KLF_EXPORT KLFPluginConfigAccess 00062 { 00063 KLFConfig *_config; 00064 QString _pluginname; 00065 public: 00066 KLFPluginConfigAccess(); 00067 KLFPluginConfigAccess(KLFConfig *configObject, const QString& pluginName); 00068 KLFPluginConfigAccess(const KLFPluginConfigAccess& other); 00069 virtual ~KLFPluginConfigAccess(); 00070 00074 virtual QString homeConfigDir() const; 00075 00081 virtual QString globalShareDir() const; 00082 00086 virtual QString tempDir() const; 00087 00100 virtual QString homeConfigPluginDataDir(bool createIfNeeded = true) const; 00101 00107 virtual QVariant readValue(const QString& key) const; 00108 00121 virtual QVariant makeDefaultValue(const QString& key, const QVariant& defaultValue); 00122 00130 virtual void writeValue(const QString& key, const QVariant& value); 00131 }; 00132 00133 00135 00141 class KLF_EXPORT KLFConfig { 00142 public: 00143 00148 KLFConfig(); 00149 00150 00151 QString homeConfigDir; 00152 QString globalShareDir; 00153 QString homeConfigSettingsFile; 00154 QString homeConfigSettingsFileIni; 00155 QString homeConfigDirRCCResources; 00156 QString homeConfigDirPlugins; 00157 QString homeConfigDirPluginData; 00158 QString homeConfigDirI18n; 00159 00160 struct { 00161 00162 bool thisVersionMajFirstRun; 00163 bool thisVersionMajMinFirstRun; 00164 bool thisVersionMajMinRelFirstRun; 00165 bool thisVersionExactFirstRun; 00166 00168 QString libraryFileName; 00171 QString libraryLibScheme; 00172 00173 } Core; 00174 00175 struct { 00176 00177 QString locale; 00178 bool useSystemAppFont; 00179 QFont applicationFont; 00180 QFont latexEditFont; 00181 QFont preambleEditFont; 00182 QSize previewTooltipMaxSize; 00183 QSize labelOutputFixedSize; 00184 QString lastSaveDir; 00185 int symbolsPerLine; 00186 QList<QColor> userColorList; 00187 QList<QColor> colorChooseWidgetRecent; 00188 QList<QColor> colorChooseWidgetCustom; 00189 int maxUserColors; 00190 bool enableToolTipPreview; 00191 bool enableRealTimePreview; 00192 int autosaveLibraryMin; 00193 bool showHintPopups; 00194 bool clearLatexOnly; 00195 QString copyExportProfile; 00196 QString dragExportProfile; 00197 bool glowEffect; 00198 QColor glowEffectColor; 00199 int glowEffectRadius; 00200 QStringList customMathModes; 00201 bool showExportProfilesLabel; 00202 bool menuExportProfileAffectsDrag; 00203 bool menuExportProfileAffectsCopy; 00204 00205 } UI; 00206 00207 struct { 00208 00209 unsigned int configFlags; 00210 QTextCharFormat fmtKeyword; 00211 QTextCharFormat fmtComment; 00212 QTextCharFormat fmtParenMatch; 00213 QTextCharFormat fmtParenMismatch; 00214 QTextCharFormat fmtLonelyParen; 00215 00216 } SyntaxHighlighter; 00217 00218 struct { 00219 00220 QString tempDir; 00221 QString execLatex; 00222 QString execDvips; 00223 QString execGs; 00224 QString execEpstopdf; 00225 QStringList execenv; 00226 double lborderoffset; 00227 double tborderoffset; 00228 double rborderoffset; 00229 double bborderoffset; 00230 bool outlineFonts; 00231 00232 } BackendSettings; 00233 00234 struct { 00235 00236 QColor colorFound; 00237 QColor colorNotFound; 00238 00239 bool restoreURLs; 00240 bool confirmClose; 00241 bool groupSubCategories; 00242 int iconViewFlow; 00243 bool historyTagCopyToArchive; 00244 QString lastFileDialogPath; 00245 00246 int treePreviewSizePercent; 00247 int listPreviewSizePercent; 00248 int iconPreviewSizePercent; 00249 00250 } LibraryBrowser; 00251 00252 struct { 00253 00254 QMap<QString, QMap<QString, QVariant> > pluginConfig; 00255 00256 } Plugins; 00257 00259 QFont defaultCMUFont; 00261 QFont defaultStdFont; 00263 QFont defaultTTFont; 00264 00265 KLFPluginConfigAccess getPluginConfigAccess(const QString& name); 00266 00277 void loadDefaults(); 00278 int readFromConfig(); 00279 void detectMissingSettings(); 00280 00281 int ensureHomeConfigDir(); 00282 00283 int writeToConfig(); 00284 00285 00287 bool checkExePaths(); 00288 00289 private: 00290 int readFromConfig_v2(const QString& fname); 00291 int readFromConfig_v1(); 00292 00293 }; 00294 00295 00296 00297 00298 KLF_EXPORT extern KLFConfig klfconfig; 00299 00300 00301 00302 00303 00304 #endif