25 #include "krootprop.h"
26 #include "tdeglobal.h"
28 #include "kcharsets.h"
29 #include "tdeapplication.h"
30 #include <tqtextstream.h>
33 #include <X11/Xatom.h>
54 if ( !propDict.isEmpty() )
56 TQMap<TQString,TQString>::Iterator it = propDict.begin();
59 while ( it != propDict.end() )
61 keyvalue = TQString(
"%1=%2\n").arg(it.key()).arg(it.data());
62 propString += keyvalue;
67 XChangeProperty( tqt_xdisplay(), tqt_xrootwin(), atom,
68 XA_STRING, 8, PropModeReplace,
69 (
const unsigned char *)propString.utf8().data(),
71 XFlush( tqt_xdisplay() );
79 unsigned long bytes_after;
92 atom = XInternAtom( tqt_xdisplay(), rProp.utf8(), False);
95 offset = 0; bytes_after = 1;
96 while (bytes_after != 0)
98 unsigned char *buf = 0;
99 if (XGetWindowProperty( tqt_xdisplay(), tqt_xrootwin(), atom, offset, 256,
100 False, XA_STRING, &type, &format, &nitems, &bytes_after,
101 &buf) == Success && buf)
103 s += TQString::fromUtf8((
const char*)buf);
117 while(s.length() >0 )
132 keypair.simplifyWhiteSpace();
134 i = keypair.find(
"=" );
137 key = keypair.left( i );
138 value = keypair.mid( i+1 );
139 propDict.insert( key, value );
155 XDeleteProperty( tqt_xdisplay(), tqt_xrootwin(), atom );
161 const TQString& pDefault )
const
163 if( propDict.contains( rKey ) )
164 return propDict[ rKey ];
173 if( !aValue.isNull() )
177 int rc = aValue.toInt( &ok );
186 const TQFont* pDefault )
const
192 aDefFont = *pDefault;
195 if( aValue.isNull() )
198 if ( !aRetFont.fromString( aValue ) && pDefault )
206 const TQColor* pDefault )
const
209 int nRed = 0, nGreen = 0, nBlue = 0;
212 aRetColor = *pDefault;
215 if( aValue.isNull() )
220 if( aValue.find(
"#") == 0 ) {
221 aRetColor.setNamedColor( aValue );
227 int nIndex1 = aValue.find(
',' );
231 int nIndex2 = aValue.find(
',', nIndex1+1 );
236 nRed = aValue.left( nIndex1 ).toInt( &bOK );
237 nGreen = aValue.mid( nIndex1+1,
238 nIndex2-nIndex1-1 ).toInt( &bOK );
239 nBlue = aValue.mid( nIndex2+1 ).toInt( &bOK );
241 aRetColor.setRgb( nRed, nGreen, nBlue );
249 if ( propDict.contains( rKey ) ) {
250 TQString aValue = propDict[ rKey ];
251 propDict.replace( rKey, rValue );
255 propDict.insert( rKey, rValue );
256 return TQString::null;
264 aValue.setNum( nValue );
271 return writeEntry( rKey, TQString(rFont.toString()) );
276 TQString aValue = TQString(
"%1,%2,%3").arg(rColor.red()).arg(rColor.green()).arg(rColor.blue() );
283 if (propDict.contains(rKey)) {
285 TQString aValue = propDict[rKey];
286 propDict.remove(rKey);
289 return TQString::null;
294 TQMap<TQString,TQString>::ConstIterator it;
297 TQMap<TQString,TQString>::ConstIterator
end(propDict.end());
298 for (it=propDict.begin(); it!=end; ++it)
TQString readEntry(const TQString &rKey, const TQString &pDefault=TQString::null) const
Reads the value of an entry specified by rKey in the current property.
TQColor readColorEntry(const TQString &rKey, const TQColor *pDefault=0) const
Reads a TQColor.
KRootProp(const TQString &rProp=TQString::null)
Constructs a KRootProp object for the property rProp.
int readNumEntry(const TQString &rKey, int nDefault=0) const
Reads a numerical value.
TQString writeEntry(const TQString &rKey, const TQString &rValue)
Writes a (key/value) pair.
~KRootProp()
Destructs the KRootProp object.
void destroy()
Destroys the property completely.
TQString removeEntry(const TQString &rKey)
Removes an entry.
void sync()
Flushes the entry cache.
TQFont readFontEntry(const TQString &rKey, const TQFont *pDefault=0) const
Reads a TQFont value.
TQString prop() const
Returns the name of the property under which keys are searched.
void setProp(const TQString &rProp=TQString())
Sets the property in which keys will be searched.
TQStringList listEntries() const
Returns a list of all keys.
const TDEShortcut & end()
Goto end of the document.