2
kconf_update app for migrating kdevelop's ui settings to the new
3
code that will be in 3.3.
5
Copyright (c) 2005 by Matt Rogers <mattr@kde.org>
6
Based on code Copyright (c) 2003 by Martijn Klingens <klingens@kde.org>
8
*************************************************************************
10
* This program is free software; you can redistribute it and/or *
11
* modify it under the terms of the GNU Lesser General Public *
12
* License as published by the Free Software Foundation; either *
13
* version 2 of the License, or (at your option) any later version. *
15
*************************************************************************
19
#include <qtextstream.h>
22
static QTextStream qcin ( stdin, IO_ReadOnly );
23
static QTextStream qcout( stdout, IO_WriteOnly );
24
static QTextStream qcerr( stderr, IO_WriteOnly );
26
// Group cache. Yes, I know global vars are ugly :)
27
bool needFlush = false;
31
void parseKey( const QString &group, const QString &key,
32
const QString &value, const QString &rawLine )
35
//qcerr << "*** group='" << group << "'" << endl;
36
if ( group == "General Options" && key == "Embed KDevDesigner")
38
newKeyValue = "Designer App";
39
if ( value.lower() == "true" )
43
qcout << newKeyValue << "=" << newDataValue << endl;
44
qcout << "# DELETE [" << key << "]" << endl;
47
else if ( group == "General Options" && key == "Application Font" )
49
newKeyValue = "OutputViewFont";
50
qcout << newKeyValue << "=" << value << endl;
51
qcout << "# DELETE [" << key << "]" << endl;
53
else if ( group == "MakeOutputView" && key == "Messages Font" )
55
qcout << "# DELETE [" << key << "]" << endl;
57
else if ( group == "TerminalEmulator" && key == "UseKDESetting" )
59
newKeyValue = "UseKDESetting";
60
if ( value.lower() == "true" )
64
qcout << newKeyValue << "=" << newDataValue << endl;
68
// keys we don't convert. output the raw line instead.
69
qcout << rawLine << endl;
75
qcin.setEncoding( QTextStream::UnicodeUTF8 );
76
qcout.setEncoding( QTextStream::UnicodeUTF8 );
80
QRegExp groupRegExp( "^\\[(.*)\\]" );
81
QRegExp keyRegExp( "^([a-zA-Z0-9:, _-]*)\\s*=\\s*(.*)\\s*" );
82
QRegExp commentRegExp( "^(#.*)?$" );
84
while ( !qcin.atEnd() )
86
QString line = qcin.readLine();
88
if ( commentRegExp.exactMatch( line ) )
90
// We found a comment, leave unchanged
91
qcout << line << endl;
93
else if ( groupRegExp.exactMatch( line ) )
95
curGroup = groupRegExp.capturedTexts()[ 1 ];
96
qcout << line << endl;
98
else if ( keyRegExp.exactMatch( line ) )
100
// We found the a key line
101
parseKey( curGroup, keyRegExp.capturedTexts()[ 1 ], keyRegExp.capturedTexts()[ 2 ], line );
105
qcout << line << endl;
112
// vim: set noet ts=4 sts=4 sw=4: