![]() |
XML Mill
1.0.0
A GUI based XML editor with a memory.
|
00001 /* Copyright (c) 2012 - 2013 by William Hallatt. 00002 * 00003 * This file forms part of "XML Mill". 00004 * 00005 * The official website for this project is <http://www.goblincoding.com> and, 00006 * although not compulsory, it would be appreciated if all works of whatever 00007 * nature using this source code (in whole or in part) include a reference to 00008 * this site. 00009 * 00010 * Should you wish to contact me for whatever reason, please do so via: 00011 * 00012 * <http://www.goblincoding.com/contact> 00013 * 00014 * This program is free software: you can redistribute it and/or modify it under 00015 * the terms of the GNU General Public License as published by the Free Software 00016 * Foundation, either version 3 of the License, or (at your option) any later 00017 * version. 00018 * 00019 * This program is distributed in the hope that it will be useful, but WITHOUT 00020 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00021 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 00022 * 00023 * You should have received a copy of the GNU General Public License along with 00024 * this program (GNUGPL.txt). If not, see 00025 * 00026 * <http://www.gnu.org/licenses/> 00027 */ 00028 00029 #include "utils/gcglobalspace.h" 00030 #include <QSettings> 00031 #include <QDir> 00032 00033 /*--------------------------------------------------------------------------------------*/ 00034 00035 namespace GCGlobalSpace 00036 { 00037 namespace 00038 { 00040 const QString ORGANISATION = "GoblinCoding"; 00041 00043 const QString APPLICATION = "XML Mill"; 00044 00045 const QString HELP = "showHelpButtons"; 00046 const QString VERBOSE = "showTreeItemsVerbose"; 00047 const QString LAST_DIR = "lastDirectory"; 00048 const QString GEOMETRY = "geometry"; 00049 const QString STATE = "windowState"; 00050 const QString USE_DARK = "useDarkTheme"; 00051 const QString SAVE_WINDOW = "saveWindowInformation"; 00052 } 00053 00054 /*--------------------------------------------------------------------------------------*/ 00055 00056 const QString& getOrganisationName() 00057 { 00058 return ORGANISATION; 00059 } 00060 00061 /*--------------------------------------------------------------------------------------*/ 00062 00063 const QString& getApplicationName() 00064 { 00065 return APPLICATION; 00066 } 00067 00068 /*--------------------------------------------------------------------------------------*/ 00069 00070 bool showHelpButtons() 00071 { 00072 QSettings settings( GCGlobalSpace::ORGANISATION, GCGlobalSpace::APPLICATION ); 00073 return settings.value( HELP, true ).toBool(); 00074 } 00075 00076 /*--------------------------------------------------------------------------------------*/ 00077 00078 void setShowHelpButtons( bool show ) 00079 { 00080 QSettings settings( GCGlobalSpace::ORGANISATION, GCGlobalSpace::APPLICATION ); 00081 settings.setValue( HELP, show ); 00082 } 00083 00084 /*--------------------------------------------------------------------------------------*/ 00085 00086 bool showTreeItemsVerbose() 00087 { 00088 QSettings settings( GCGlobalSpace::ORGANISATION, GCGlobalSpace::APPLICATION ); 00089 return settings.value( VERBOSE, false ).toBool(); 00090 } 00091 00092 /*--------------------------------------------------------------------------------------*/ 00093 00094 void setShowTreeItemsVerbose( bool show ) 00095 { 00096 QSettings settings( GCGlobalSpace::ORGANISATION, GCGlobalSpace::APPLICATION ); 00097 settings.setValue( VERBOSE, show ); 00098 } 00099 00100 /*--------------------------------------------------------------------------------------*/ 00101 00102 QString lastUserSelectedDirectory() 00103 { 00104 QSettings settings( GCGlobalSpace::ORGANISATION, GCGlobalSpace::APPLICATION ); 00105 return settings.value( GCGlobalSpace::LAST_DIR, QDir::homePath() ).toString(); 00106 } 00107 00108 /*--------------------------------------------------------------------------------------*/ 00109 00110 void setLastUserSelectedDirectory( const QString& dir ) 00111 { 00112 QSettings settings( GCGlobalSpace::ORGANISATION, GCGlobalSpace::APPLICATION ); 00113 settings.setValue( LAST_DIR, dir ); 00114 } 00115 00116 /*--------------------------------------------------------------------------------------*/ 00117 00118 QByteArray windowGeometry() 00119 { 00120 QSettings settings( GCGlobalSpace::ORGANISATION, GCGlobalSpace::APPLICATION ); 00121 return settings.value( GEOMETRY ).toByteArray(); 00122 } 00123 00124 /*--------------------------------------------------------------------------------------*/ 00125 00126 void setWindowGeometry( const QByteArray& geometry ) 00127 { 00128 QSettings settings( GCGlobalSpace::ORGANISATION, GCGlobalSpace::APPLICATION ); 00129 settings.setValue( GEOMETRY, geometry ); 00130 } 00131 00132 /*--------------------------------------------------------------------------------------*/ 00133 00134 QByteArray windowState() 00135 { 00136 QSettings settings( GCGlobalSpace::ORGANISATION, GCGlobalSpace::APPLICATION ); 00137 return settings.value( STATE ).toByteArray(); 00138 } 00139 00140 /*--------------------------------------------------------------------------------------*/ 00141 00142 void setWindowState( const QByteArray& state ) 00143 { 00144 QSettings settings( GCGlobalSpace::ORGANISATION, GCGlobalSpace::APPLICATION ); 00145 settings.setValue( STATE, state ); 00146 } 00147 00148 /*--------------------------------------------------------------------------------------*/ 00149 00150 void removeWindowInfo() 00151 { 00152 QSettings settings( GCGlobalSpace::ORGANISATION, GCGlobalSpace::APPLICATION ); 00153 00154 if( settings.contains( GEOMETRY ) ) 00155 { 00156 settings.remove( GEOMETRY ); 00157 } 00158 00159 if( settings.contains( STATE ) ) 00160 { 00161 settings.remove( STATE ); 00162 } 00163 } 00164 00165 /*--------------------------------------------------------------------------------------*/ 00166 00167 bool useDarkTheme() 00168 { 00169 QSettings settings( GCGlobalSpace::ORGANISATION, GCGlobalSpace::APPLICATION ); 00170 return settings.value( USE_DARK, false ).toBool(); 00171 } 00172 00173 /*--------------------------------------------------------------------------------------*/ 00174 00175 void setUseDarkTheme( bool use ) 00176 { 00177 QSettings settings( GCGlobalSpace::ORGANISATION, GCGlobalSpace::APPLICATION ); 00178 settings.setValue( USE_DARK, use ); 00179 } 00180 00181 /*--------------------------------------------------------------------------------------*/ 00182 00183 bool useWindowSettings() 00184 { 00185 QSettings settings( GCGlobalSpace::ORGANISATION, GCGlobalSpace::APPLICATION ); 00186 return settings.value( SAVE_WINDOW, true ).toBool(); 00187 } 00188 00189 /*--------------------------------------------------------------------------------------*/ 00190 00191 void setUseWindowSettings( bool use ) 00192 { 00193 QSettings settings( GCGlobalSpace::ORGANISATION, GCGlobalSpace::APPLICATION ); 00194 settings.setValue( SAVE_WINDOW, use ); 00195 } 00196 } 00197 00198 /*--------------------------------------------------------------------------------------*/