You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
126 lines
3.6 KiB
126 lines
3.6 KiB
15 years ago
|
/* This file is part of the KDE libraries
|
||
|
Copyright (C) 2000 David Faure <faure@kde.org>
|
||
|
|
||
|
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.
|
||
|
*/
|
||
|
|
||
11 years ago
|
#include "tdedebugdialog.h"
|
||
12 years ago
|
#include "tdelistdebugdialog.h"
|
||
12 years ago
|
#include <tdecmdlineargs.h>
|
||
|
#include <tdeaboutdata.h>
|
||
15 years ago
|
#include <kstandarddirs.h>
|
||
13 years ago
|
#include <tqtextstream.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
#include <kdebug.h>
|
||
|
#include <kuniqueapplication.h>
|
||
12 years ago
|
#include <tdeconfig.h>
|
||
15 years ago
|
|
||
15 years ago
|
#include <tqfile.h>
|
||
15 years ago
|
|
||
15 years ago
|
TQStringList readAreaList()
|
||
15 years ago
|
{
|
||
15 years ago
|
TQStringList lst;
|
||
15 years ago
|
lst.append( "0 (generic)" );
|
||
|
|
||
15 years ago
|
TQString confAreasFile = locate( "config", "kdebug.areas" );
|
||
|
TQFile file( confAreasFile );
|
||
15 years ago
|
if (!file.open(IO_ReadOnly)) {
|
||
|
kdWarning() << "Couldn't open " << confAreasFile << endl;
|
||
|
file.close();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
15 years ago
|
TQString data;
|
||
15 years ago
|
|
||
15 years ago
|
TQTextStream *ts = new TQTextStream(&file);
|
||
|
ts->setEncoding( TQTextStream::Latin1 );
|
||
15 years ago
|
while (!ts->eof()) {
|
||
|
data = ts->readLine().simplifyWhiteSpace();
|
||
|
|
||
13 years ago
|
int pos = data.find("#");
|
||
15 years ago
|
if ( pos != -1 )
|
||
|
data.truncate( pos );
|
||
|
|
||
|
if (data.isEmpty())
|
||
|
continue;
|
||
|
|
||
|
lst.append( data );
|
||
|
}
|
||
|
|
||
|
delete ts;
|
||
|
file.close();
|
||
|
}
|
||
|
|
||
|
return lst;
|
||
|
}
|
||
|
|
||
12 years ago
|
static TDECmdLineOptions options[] =
|
||
15 years ago
|
{
|
||
|
{ "fullmode", I18N_NOOP("Show the fully-fledged dialog instead of the default list dialog"), 0 },
|
||
|
{ "on <area>", /*I18N_NOOP TODO*/ "Turn area on", 0 },
|
||
|
{ "off <area>", /*I18N_NOOP TODO*/ "Turn area off", 0 },
|
||
12 years ago
|
TDECmdLineLastOption
|
||
15 years ago
|
};
|
||
|
|
||
|
int main(int argc, char ** argv)
|
||
|
{
|
||
11 years ago
|
TDEAboutData data( "tdedebugdialog", I18N_NOOP( "TDEDebugDialog"),
|
||
15 years ago
|
"1.0", I18N_NOOP("A dialog box for setting preferences for debug output"),
|
||
12 years ago
|
TDEAboutData::License_GPL, "(c) 2009,2010, Timothy Pearson <kb9vqf@pearsoncomputing.net>");
|
||
15 years ago
|
data.addAuthor("Timothy Pearson", I18N_NOOP("Maintainer"), "kb9vqf@pearsoncomputing.net");
|
||
|
data.addAuthor("David Faure", I18N_NOOP("Original maintainer/developer"), "faure@kde.org");
|
||
12 years ago
|
TDECmdLineArgs::init( argc, argv, &data );
|
||
|
TDECmdLineArgs::addCmdLineOptions( options );
|
||
15 years ago
|
KUniqueApplication::addCmdLineOptions();
|
||
|
KUniqueApplication app;
|
||
12 years ago
|
TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
|
||
15 years ago
|
|
||
15 years ago
|
TQStringList areaList ( readAreaList() );
|
||
15 years ago
|
KAbstractDebugDialog * dialog;
|
||
|
if (args->isSet("fullmode"))
|
||
11 years ago
|
dialog = new TDEDebugDialog(areaList, 0L);
|
||
15 years ago
|
else
|
||
|
{
|
||
12 years ago
|
TDEListDebugDialog * listdialog = new TDEListDebugDialog(areaList, 0L);
|
||
15 years ago
|
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();
|
||
15 years ago
|
if( nRet == TQDialog::Accepted )
|
||
15 years ago
|
{
|
||
|
dialog->save();
|
||
|
dialog->config()->sync();
|
||
|
}
|
||
|
else
|
||
|
dialog->config()->rollback( true );
|
||
|
|
||
|
return 0;
|
||
|
}
|