delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / runtime / kdebugdialog / main.cpp
blob80b0a6af866841d1706497c2040ce4142fbd74cb
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 data.setProgramIconName("tools-report-bug");
78 KCmdLineArgs::init( argc, argv, &data );
80 KCmdLineOptions options;
81 options.add("fullmode", ki18n("Show the fully-fledged dialog instead of the default list dialog"));
82 options.add("on <area>", ki18n(/*I18N_NOOP TODO*/ "Turn area on"));
83 options.add("off <area>", ki18n(/*I18N_NOOP TODO*/ "Turn area off"));
84 KCmdLineArgs::addCmdLineOptions( options );
85 KUniqueApplication::addCmdLineOptions();
86 KUniqueApplication app;
87 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
89 QStringList areaList ( readAreaList() );
90 KAbstractDebugDialog * dialog;
91 if (args->isSet("fullmode"))
92 dialog = new KDebugDialog(areaList, 0L);
93 else
95 KListDebugDialog * listdialog = new KListDebugDialog(areaList, 0L);
96 if (args->isSet("on"))
98 listdialog->activateArea( args->getOption("on").toUtf8(), true );
99 /*listdialog->save();
100 listdialog->config()->sync();
101 return 0;*/
102 } else if ( args->isSet("off") )
104 listdialog->activateArea( args->getOption("off").toUtf8(), false );
105 /*listdialog->save();
106 listdialog->config()->sync();
107 return 0;*/
109 dialog = listdialog;
112 /* Show dialog */
113 int nRet = dialog->exec();
114 if( nRet == QDialog::Accepted )
116 dialog->save();
117 dialog->config()->sync();
119 else
120 dialog->config()->markAsClean();
122 return 0;