From 4aed2c8219774f5d797760606b8489a92ddc5163 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kdebugdialog/main.cpp | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 kdebugdialog/main.cpp (limited to 'kdebugdialog/main.cpp') diff --git a/kdebugdialog/main.cpp b/kdebugdialog/main.cpp new file mode 100644 index 000000000..e2309d586 --- /dev/null +++ b/kdebugdialog/main.cpp @@ -0,0 +1,124 @@ +/* This file is part of the KDE libraries + Copyright (C) 2000 David Faure + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "kdebugdialog.h" +#include "klistdebugdialog.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +QStringList readAreaList() +{ + QStringList lst; + lst.append( "0 (generic)" ); + + QString confAreasFile = locate( "config", "kdebug.areas" ); + QFile file( confAreasFile ); + if (!file.open(IO_ReadOnly)) { + kdWarning() << "Couldn't open " << confAreasFile << endl; + file.close(); + } + else + { + QString data; + + QTextStream *ts = new QTextStream(&file); + ts->setEncoding( QTextStream::Latin1 ); + while (!ts->eof()) { + data = ts->readLine().simplifyWhiteSpace(); + + int pos = data.find("#"); + if ( pos != -1 ) + data.truncate( pos ); + + if (data.isEmpty()) + continue; + + lst.append( data ); + } + + delete ts; + file.close(); + } + + return lst; +} + +static KCmdLineOptions options[] = +{ + { "fullmode", I18N_NOOP("Show the fully-fledged dialog instead of the default list dialog"), 0 }, + { "on ", /*I18N_NOOP TODO*/ "Turn area on", 0 }, + { "off ", /*I18N_NOOP TODO*/ "Turn area off", 0 }, + KCmdLineLastOption +}; + +int main(int argc, char ** argv) +{ + KAboutData data( "kdebugdialog", I18N_NOOP( "KDebugDialog"), + "1.0", I18N_NOOP("A dialog box for setting preferences for debug output"), + KAboutData::License_GPL, "(c) 1999-2000, David Faure "); + data.addAuthor("David Faure", I18N_NOOP("Maintainer"), "faure@kde.org"); + KCmdLineArgs::init( argc, argv, &data ); + KCmdLineArgs::addCmdLineOptions( options ); + KUniqueApplication::addCmdLineOptions(); + KUniqueApplication app; + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + QStringList areaList ( readAreaList() ); + KAbstractDebugDialog * dialog; + if (args->isSet("fullmode")) + dialog = new KDebugDialog(areaList, 0L); + else + { + KListDebugDialog * listdialog = new KListDebugDialog(areaList, 0L); + if (args->isSet("on")) + { + listdialog->activateArea( args->getOption("on"), true ); + /*listdialog->save(); + listdialog->config()->sync(); + return 0;*/ + } else if ( args->isSet("off") ) + { + listdialog->activateArea( args->getOption("off"), false ); + /*listdialog->save(); + listdialog->config()->sync(); + return 0;*/ + } + dialog = listdialog; + } + + /* Show dialog */ + int nRet = dialog->exec(); + if( nRet == QDialog::Accepted ) + { + dialog->save(); + dialog->config()->sync(); + } + else + dialog->config()->rollback( true ); + + return 0; +} -- cgit v1.2.1