Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / runtime / kdebugdialog / main.cpp
blobfc1a77cda18da13c991689b93873cec9d2e84fd4
1 /* This file is part of the KDE libraries
2 Copyright (C) 2000 David Faure <faure@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #include "kdebugdialog.h"
21 #include "klistdebugdialog.h"
22 #include <kcmdlineargs.h>
23 #include <kaboutdata.h>
24 #include <kstandarddirs.h>
25 #include <QTextStream>
26 #include <klocale.h>
27 #include <kdebug.h>
28 #include <kuniqueapplication.h>
29 #include <kconfig.h>
30 #include <kconfiggroup.h>
32 #include <QFile>
34 QStringList readAreaList()
36 QStringList lst;
37 lst.append( "0 (generic)" );
39 QString confAreasFile = KStandardDirs::locate( "config", "kdebug.areas" );
40 QFile file( confAreasFile );
41 if (!file.open(QIODevice::ReadOnly)) {
42 kWarning() << "Couldn't open " << confAreasFile ;
43 file.close();
45 else
47 QString data;
49 QTextStream *ts = new QTextStream(&file);
50 ts->setCodec( "ISO-8859-1" );
51 while (!ts->atEnd()) {
52 data = ts->readLine().simplified();
54 int pos = data.indexOf("#");
55 if ( pos != -1 )
56 data.truncate( pos );
58 if (data.isEmpty())
59 continue;
61 lst.append( data );
64 delete ts;
65 file.close();
68 return lst;
71 int main(int argc, char ** argv)
73 KAboutData data( "kdebugdialog", 0, ki18n( "KDebugDialog"),
74 "1.0", ki18n("A dialog box for setting preferences for debug output"),
75 KAboutData::License_GPL, ki18n("Copyright 1999-2000, David Faure <email>faure@kde.org</email>"));
76 data.addAuthor(ki18n("David Faure"), ki18n("Maintainer"), "faure@kde.org");
77 KCmdLineArgs::init( argc, argv, &data );
79 KCmdLineOptions options;
80 options.add("fullmode", ki18n("Show the fully-fledged dialog instead of the default list dialog"));
81 options.add("on <area>", ki18n(/*I18N_NOOP TODO*/ "Turn area on"));
82 options.add("off <area>", ki18n(/*I18N_NOOP TODO*/ "Turn area off"));
83 KCmdLineArgs::addCmdLineOptions( options );
84 KUniqueApplication::addCmdLineOptions();
85 KUniqueApplication app;
86 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
88 QStringList areaList ( readAreaList() );
89 KAbstractDebugDialog * dialog;
90 if (args->isSet("fullmode"))
91 dialog = new KDebugDialog(areaList, 0L);
92 else
94 KListDebugDialog * listdialog = new KListDebugDialog(areaList, 0L);
95 if (args->isSet("on"))
97 listdialog->activateArea( args->getOption("on").toUtf8(), true );
98 /*listdialog->save();
99 listdialog->config()->sync();
100 return 0;*/
101 } else if ( args->isSet("off") )
103 listdialog->activateArea( args->getOption("off").toUtf8(), false );
104 /*listdialog->save();
105 listdialog->config()->sync();
106 return 0;*/
108 dialog = listdialog;
111 /* Show dialog */
112 int nRet = dialog->exec();
113 if( nRet == QDialog::Accepted )
115 dialog->save();
116 dialog->config()->sync();
118 else
119 dialog->config()->markAsClean();
121 return 0;