diff options
Diffstat (limited to 'tdedebugdialog')
-rw-r--r-- | tdedebugdialog/CMakeLists.txt | 32 | ||||
-rw-r--r-- | tdedebugdialog/Makefile.am | 16 | ||||
-rw-r--r-- | tdedebugdialog/README | 12 | ||||
-rw-r--r-- | tdedebugdialog/kabstractdebugdialog.cpp | 85 | ||||
-rw-r--r-- | tdedebugdialog/kabstractdebugdialog.h | 54 | ||||
-rw-r--r-- | tdedebugdialog/main.cpp | 125 | ||||
-rw-r--r-- | tdedebugdialog/tdedebugdialog.cpp | 260 | ||||
-rw-r--r-- | tdedebugdialog/tdedebugdialog.h | 93 | ||||
-rw-r--r-- | tdedebugdialog/tdelistdebugdialog.cpp | 193 | ||||
-rw-r--r-- | tdedebugdialog/tdelistdebugdialog.h | 65 |
10 files changed, 935 insertions, 0 deletions
diff --git a/tdedebugdialog/CMakeLists.txt b/tdedebugdialog/CMakeLists.txt new file mode 100644 index 000000000..001d5e72c --- /dev/null +++ b/tdedebugdialog/CMakeLists.txt @@ -0,0 +1,32 @@ +################################################# +# +# (C) 2010-2011 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### tdedebugdialog (executable) ################# + +tde_add_executable( tdedebugdialog AUTOMOC + SOURCES + main.cpp kabstractdebugdialog.cpp tdedebugdialog.cpp + tdelistdebugdialog.cpp + LINK tdeui-shared + DESTINATION ${BIN_INSTALL_DIR} +) diff --git a/tdedebugdialog/Makefile.am b/tdedebugdialog/Makefile.am new file mode 100644 index 000000000..d6249afae --- /dev/null +++ b/tdedebugdialog/Makefile.am @@ -0,0 +1,16 @@ +## Makefile.am of tdedebugdialog + +INCLUDES= $(all_includes) + +####### Files + +bin_PROGRAMS = tdedebugdialog + +tdedebugdialog_SOURCES = main.cpp kabstractdebugdialog.cpp tdedebugdialog.cpp tdelistdebugdialog.cpp +tdedebugdialog_METASOURCES = AUTO +tdedebugdialog_LDFLAGS = $(all_libraries) $(KDE_RPATH) +tdedebugdialog_LDADD = $(LIB_TDEUI) + +messages: + $(XGETTEXT) *.cpp -o $(podir)/tdedebugdialog.pot + diff --git a/tdedebugdialog/README b/tdedebugdialog/README new file mode 100644 index 000000000..2ee51ae79 --- /dev/null +++ b/tdedebugdialog/README @@ -0,0 +1,12 @@ +tdedebugdialog +------------ + +In --fullmode, you can choose to dump debug output to a file. +But keep in mind that multiple programs may be writing to that +area (and therefore to that file), so they will always be appending +to it and never clearing it. So don't forget to empty it once in a +while! + +Your configuration will of course be stored in + $HOME/.trinity/share/config/kdebugrc + diff --git a/tdedebugdialog/kabstractdebugdialog.cpp b/tdedebugdialog/kabstractdebugdialog.cpp new file mode 100644 index 000000000..10c0c2a00 --- /dev/null +++ b/tdedebugdialog/kabstractdebugdialog.cpp @@ -0,0 +1,85 @@ +/* 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. +*/ + +#include "kabstractdebugdialog.h" +#include <tdeconfig.h> +#include <kpushbutton.h> +#include <tqlayout.h> +#include <tdeapplication.h> +#include <tdelocale.h> +#include <kstdguiitem.h> + +KAbstractDebugDialog::KAbstractDebugDialog( TQWidget *parent, const char *name, bool modal ) + : KDialog( parent, name, modal ) +{ + pConfig = new TDEConfig( "kdebugrc" ); +} + +KAbstractDebugDialog::~KAbstractDebugDialog() +{ + delete pConfig; +} + +void KAbstractDebugDialog::buildButtons( TQVBoxLayout * topLayout ) +{ + TQHBoxLayout *hbox = new TQHBoxLayout( KDialog::spacingHint() ); + topLayout->addLayout( hbox ); + pHelpButton = new KPushButton( KStdGuiItem::help(), this ); + hbox->addWidget( pHelpButton ); + hbox->addStretch(10); + TQSpacerItem *spacer = new TQSpacerItem(40, 0); + hbox->addItem(spacer); + pOKButton = new KPushButton( KStdGuiItem::ok(), this ); + hbox->addWidget( pOKButton ); + pApplyButton = new KPushButton( KStdGuiItem::apply(), this ); + hbox->addWidget( pApplyButton ); + pCancelButton = new KPushButton( KStdGuiItem::cancel(), this ); + hbox->addWidget( pCancelButton ); + + int w1 = pHelpButton->sizeHint().width(); + int w2 = pOKButton->sizeHint().width(); + int w3 = pCancelButton->sizeHint().width(); + int w4 = TQMAX( w1, TQMAX( w2, w3 ) ); + int w5 = pApplyButton->sizeHint().width(); + w4 = TQMAX(w4, w5); + + pHelpButton->setFixedWidth( w4 ); + pOKButton->setFixedWidth( w4 ); + pApplyButton->setFixedWidth( w4 ); + pCancelButton->setFixedWidth( w4 ); + + connect( pHelpButton, TQT_SIGNAL( clicked() ), TQT_SLOT( slotShowHelp() ) ); + connect( pOKButton, TQT_SIGNAL( clicked() ), TQT_SLOT( accept() ) ); + connect( pApplyButton, TQT_SIGNAL( clicked() ), TQT_SLOT( slotApply() ) ); + connect( pCancelButton, TQT_SIGNAL( clicked() ), TQT_SLOT( reject() ) ); +} + +void KAbstractDebugDialog::slotShowHelp() +{ + if (kapp) + kapp->invokeHelp(); +} + +void KAbstractDebugDialog::slotApply() +{ + save(); + pConfig->sync(); +} + +#include "kabstractdebugdialog.moc" diff --git a/tdedebugdialog/kabstractdebugdialog.h b/tdedebugdialog/kabstractdebugdialog.h new file mode 100644 index 000000000..6e3655973 --- /dev/null +++ b/tdedebugdialog/kabstractdebugdialog.h @@ -0,0 +1,54 @@ +/* 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. +*/ + +#ifndef KABSTRACTDEBUGDIALOG__H +#define KABSTRACTDEBUGDIALOG__H + +#include <kdialog.h> + +class TDEConfig; +class TQVBoxLayout; +class KPushButton; + +class KAbstractDebugDialog : public KDialog +{ + Q_OBJECT +public: + KAbstractDebugDialog( TQWidget *parent=0, const char *name=0, bool modal=true ); + + virtual ~KAbstractDebugDialog(); + + virtual void buildButtons(TQVBoxLayout * topLayout); + + virtual void save() = 0; + TDEConfig * config() { return pConfig; } + +protected slots: + void slotShowHelp(); + void slotApply(); + +protected: + TDEConfig* pConfig; + KPushButton* pOKButton; + KPushButton* pCancelButton; + KPushButton* pHelpButton; + KPushButton* pApplyButton; +}; + +#endif diff --git a/tdedebugdialog/main.cpp b/tdedebugdialog/main.cpp new file mode 100644 index 000000000..f1c463dce --- /dev/null +++ b/tdedebugdialog/main.cpp @@ -0,0 +1,125 @@ +/* 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. +*/ + +#include "tdedebugdialog.h" +#include "tdelistdebugdialog.h" +#include <tdecmdlineargs.h> +#include <tdeaboutdata.h> +#include <kstandarddirs.h> +#include <tqtextstream.h> +#include <tdelocale.h> +#include <kdebug.h> +#include <kuniqueapplication.h> +#include <tdeconfig.h> + +#include <tqfile.h> + +TQStringList readAreaList() +{ + TQStringList lst; + lst.append( "0 (generic)" ); + + TQString confAreasFile = locate( "config", "kdebug.areas" ); + TQFile file( confAreasFile ); + if (!file.open(IO_ReadOnly)) { + kdWarning() << "Couldn't open " << confAreasFile << endl; + file.close(); + } + else + { + TQString data; + + TQTextStream *ts = new TQTextStream(&file); + ts->setEncoding( TQTextStream::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 TDECmdLineOptions options[] = +{ + { "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 }, + TDECmdLineLastOption +}; + +int main(int argc, char ** argv) +{ + TDEAboutData data( "tdedebugdialog", I18N_NOOP( "TDEDebugDialog"), + "1.0", I18N_NOOP("A dialog box for setting preferences for debug output"), + TDEAboutData::License_GPL, "(c) 2009,2010, Timothy Pearson <kb9vqf@pearsoncomputing.net>"); + data.addAuthor("Timothy Pearson", I18N_NOOP("Maintainer"), "kb9vqf@pearsoncomputing.net"); + data.addAuthor("David Faure", I18N_NOOP("Original maintainer/developer"), "faure@kde.org"); + TDECmdLineArgs::init( argc, argv, &data ); + TDECmdLineArgs::addCmdLineOptions( options ); + KUniqueApplication::addCmdLineOptions(); + KUniqueApplication app; + TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); + + TQStringList areaList ( readAreaList() ); + KAbstractDebugDialog * dialog; + if (args->isSet("fullmode")) + dialog = new TDEDebugDialog(areaList, 0L); + else + { + TDEListDebugDialog * listdialog = new TDEListDebugDialog(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 == TQDialog::Accepted ) + { + dialog->save(); + dialog->config()->sync(); + } + else + dialog->config()->rollback( true ); + + return 0; +} diff --git a/tdedebugdialog/tdedebugdialog.cpp b/tdedebugdialog/tdedebugdialog.cpp new file mode 100644 index 000000000..d63fac78b --- /dev/null +++ b/tdedebugdialog/tdedebugdialog.cpp @@ -0,0 +1,260 @@ +/* This file is part of the KDE libraries + Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) + Copyright (C) 1999 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. +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tqlayout.h> +#include <tqlineedit.h> +#include <tqcombobox.h> +#include <tqlabel.h> +#include <tqgroupbox.h> +#include <tqcheckbox.h> +#include <tqpushbutton.h> +#include <kdebug.h> +#include <tdeglobal.h> +#include <tdelocale.h> +#include <kdialog.h> +#include <tdeconfig.h> +#include <kseparator.h> +#include <tdeapplication.h> +#include <dcopclient.h> + +#include "tdedebugdialog.h" + +TDEDebugDialog::TDEDebugDialog( TQStringList areaList, TQWidget *parent, const char *name, bool modal ) + : KAbstractDebugDialog( parent, name, modal ) +{ + setCaption(i18n("Debug Settings")); + + TQVBoxLayout *topLayout = new TQVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() ); + if( topLayout == 0 ) { return; } // can this happen ? + + TQLabel * tmpLabel = new TQLabel( i18n("Debug area:"), this ); + tmpLabel->setFixedHeight( fontMetrics().lineSpacing() ); + topLayout->addWidget( tmpLabel ); + + // Build combo of debug areas + pDebugAreas = new TQComboBox( false, this ); + pDebugAreas->setFixedHeight( pDebugAreas->sizeHint().height() ); + pDebugAreas->insertStringList( areaList ); + topLayout->addWidget( pDebugAreas ); + + TQGridLayout *gbox = new TQGridLayout( 2, 2, KDialog::marginHint() ); + if( gbox == 0 ) { return; } + topLayout->addLayout( TQT_TQLAYOUT(gbox) ); + + TQStringList destList; + destList.append( i18n("File") ); + destList.append( i18n("Message Box") ); + destList.append( i18n("Shell") ); + destList.append( i18n("Syslog") ); + destList.append( i18n("None") ); + + // + // Upper left frame + // + pInfoGroup = new TQGroupBox( i18n("Information"), this ); + gbox->addWidget( pInfoGroup, 0, 0 ); + TQVBoxLayout *vbox = new TQVBoxLayout( pInfoGroup, KDialog::spacingHint() ); + vbox->addSpacing( fontMetrics().lineSpacing() ); + pInfoLabel1 = new TQLabel( i18n("Output to:"), pInfoGroup ); + vbox->addWidget( pInfoLabel1 ); + pInfoCombo = new TQComboBox( false, pInfoGroup ); + connect(pInfoCombo, TQT_SIGNAL(activated(int)), + this, TQT_SLOT(slotDestinationChanged(int))); + vbox->addWidget( pInfoCombo ); + pInfoCombo->insertStringList( destList ); + pInfoLabel2 = new TQLabel( i18n("Filename:"), pInfoGroup ); + vbox->addWidget( pInfoLabel2 ); + pInfoFile = new TQLineEdit( pInfoGroup ); + vbox->addWidget( pInfoFile ); + /* + pInfoLabel3 = new TQLabel( i18n("Show only area(s):"), pInfoGroup ); + vbox->addWidget( pInfoLabel3 ); + pInfoShow = new TQLineEdit( pInfoGroup ); + vbox->addWidget( pInfoShow ); + */ + + // + // Upper right frame + // + pWarnGroup = new TQGroupBox( i18n("Warning"), this ); + gbox->addWidget( pWarnGroup, 0, 1 ); + vbox = new TQVBoxLayout( pWarnGroup, KDialog::spacingHint() ); + vbox->addSpacing( fontMetrics().lineSpacing() ); + pWarnLabel1 = new TQLabel( i18n("Output to:"), pWarnGroup ); + vbox->addWidget( pWarnLabel1 ); + pWarnCombo = new TQComboBox( false, pWarnGroup ); + connect(pWarnCombo, TQT_SIGNAL(activated(int)), + this, TQT_SLOT(slotDestinationChanged(int))); + vbox->addWidget( pWarnCombo ); + pWarnCombo->insertStringList( destList ); + pWarnLabel2 = new TQLabel( i18n("Filename:"), pWarnGroup ); + vbox->addWidget( pWarnLabel2 ); + pWarnFile = new TQLineEdit( pWarnGroup ); + vbox->addWidget( pWarnFile ); + /* + pWarnLabel3 = new TQLabel( i18n("Show only area(s):"), pWarnGroup ); + vbox->addWidget( pWarnLabel3 ); + pWarnShow = new TQLineEdit( pWarnGroup ); + vbox->addWidget( pWarnShow ); + */ + + // + // Lower left frame + // + pErrorGroup = new TQGroupBox( i18n("Error"), this ); + gbox->addWidget( pErrorGroup, 1, 0 ); + vbox = new TQVBoxLayout( pErrorGroup, KDialog::spacingHint() ); + vbox->addSpacing( fontMetrics().lineSpacing() ); + pErrorLabel1 = new TQLabel( i18n("Output to:"), pErrorGroup ); + vbox->addWidget( pErrorLabel1 ); + pErrorCombo = new TQComboBox( false, pErrorGroup ); + connect(pErrorCombo, TQT_SIGNAL(activated(int)), + this, TQT_SLOT(slotDestinationChanged(int))); + vbox->addWidget( pErrorCombo ); + pErrorCombo->insertStringList( destList ); + pErrorLabel2 = new TQLabel( i18n("Filename:"), pErrorGroup ); + vbox->addWidget( pErrorLabel2 ); + pErrorFile = new TQLineEdit( pErrorGroup ); + vbox->addWidget( pErrorFile ); + /* + pErrorLabel3 = new TQLabel( i18n("Show only area(s):"), pErrorGroup ); + vbox->addWidget( pErrorLabel3 ); + pErrorShow = new TQLineEdit( pErrorGroup ); + vbox->addWidget( pErrorShow ); + */ + + // + // Lower right frame + // + pFatalGroup = new TQGroupBox( i18n("Fatal Error"), this ); + gbox->addWidget( pFatalGroup, 1, 1 ); + vbox = new TQVBoxLayout( pFatalGroup, KDialog::spacingHint() ); + vbox->addSpacing( fontMetrics().lineSpacing() ); + pFatalLabel1 = new TQLabel( i18n("Output to:"), pFatalGroup ); + vbox->addWidget( pFatalLabel1 ); + pFatalCombo = new TQComboBox( false, pFatalGroup ); + connect(pFatalCombo, TQT_SIGNAL(activated(int)), + this, TQT_SLOT(slotDestinationChanged(int))); + vbox->addWidget( pFatalCombo ); + pFatalCombo->insertStringList( destList ); + pFatalLabel2 = new TQLabel( i18n("Filename:"), pFatalGroup ); + vbox->addWidget( pFatalLabel2 ); + pFatalFile = new TQLineEdit( pFatalGroup ); + vbox->addWidget( pFatalFile ); + /* + pFatalLabel3 = new TQLabel( i18n("Show only area(s):"), pFatalGroup ); + vbox->addWidget( pFatalLabel3 ); + pFatalShow = new TQLineEdit( pFatalGroup ); + vbox->addWidget( pFatalShow ); + */ + + + pAbortFatal = new TQCheckBox( i18n("Abort on fatal errors"), this ); + topLayout->addWidget(pAbortFatal); + + topLayout->addStretch(); + KSeparator *hline = new KSeparator( KSeparator::HLine, this ); + topLayout->addWidget( hline ); + + buildButtons( topLayout ); + + connect( pDebugAreas, TQT_SIGNAL( activated( const TQString &) ), + TQT_SLOT( slotDebugAreaChanged( const TQString & ) ) ); + + // Get initial values ("initial" is understood by the slot) + slotDebugAreaChanged( "0 initial" ); + slotDestinationChanged(0); + + resize( 300, height() ); +} + +TDEDebugDialog::~TDEDebugDialog() +{ +} + +void TDEDebugDialog::slotDebugAreaChanged( const TQString & text ) +{ + // Save settings from previous page + if ( text != "0 initial" ) // except on first call + save(); + + TQString data = text.simplifyWhiteSpace(); + int space = data.find(" "); + if (space == -1) + kdError() << "No space:" << data << endl; + + bool longOK; + unsigned long number = data.left(space).toULong(&longOK); + if (!longOK) + kdError() << "The first part wasn't a number : " << data << endl; + + /* Fill dialog fields with values from config data */ + pConfig->setGroup( TQString::number( number ) ); // Group name = debug area code + pInfoCombo->setCurrentItem( pConfig->readNumEntry( "InfoOutput", 2 ) ); + pInfoFile->setText( pConfig->readPathEntry( "InfoFilename","kdebug.dbg" ) ); + //pInfoShow->setText( pConfig->readEntry( "InfoShow" ) ); + pWarnCombo->setCurrentItem( pConfig->readNumEntry( "WarnOutput", 2 ) ); + pWarnFile->setText( pConfig->readPathEntry( "WarnFilename","kdebug.dbg" ) ); + //pWarnShow->setText( pConfig->readEntry( "WarnShow" ) ); + pErrorCombo->setCurrentItem( pConfig->readNumEntry( "ErrorOutput", 2 ) ); + pErrorFile->setText( pConfig->readPathEntry( "ErrorFilename","kdebug.dbg") ); + //pErrorShow->setText( pConfig->readEntry( "ErrorShow" ) ); + pFatalCombo->setCurrentItem( pConfig->readNumEntry( "FatalOutput", 2 ) ); + pFatalFile->setText( pConfig->readPathEntry("FatalFilename","kdebug.dbg") ); + //pFatalShow->setText( pConfig->readEntry( "FatalShow" ) ); + pAbortFatal->setChecked( pConfig->readNumEntry( "AbortFatal", 1 ) ); + slotDestinationChanged(0); +} + +void TDEDebugDialog::save() +{ + pConfig->writeEntry( "InfoOutput", pInfoCombo->currentItem() ); + pConfig->writePathEntry( "InfoFilename", pInfoFile->text() ); + //pConfig->writeEntry( "InfoShow", pInfoShow->text() ); + pConfig->writeEntry( "WarnOutput", pWarnCombo->currentItem() ); + pConfig->writePathEntry( "WarnFilename", pWarnFile->text() ); + //pConfig->writeEntry( "WarnShow", pWarnShow->text() ); + pConfig->writeEntry( "ErrorOutput", pErrorCombo->currentItem() ); + pConfig->writePathEntry( "ErrorFilename", pErrorFile->text() ); + //pConfig->writeEntry( "ErrorShow", pErrorShow->text() ); + pConfig->writeEntry( "FatalOutput", pFatalCombo->currentItem() ); + pConfig->writePathEntry( "FatalFilename", pFatalFile->text() ); + //pConfig->writeEntry( "FatalShow", pFatalShow->text() ); + pConfig->writeEntry( "AbortFatal", pAbortFatal->isChecked() ); + + TQByteArray data; + if (!kapp->dcopClient()->send("*", "KDebug", "notifyKDebugConfigChanged()", data)) + { + kdError() << "Unable to send DCOP message" << endl; + } +} + +void TDEDebugDialog::slotDestinationChanged(int) { + pInfoFile->setEnabled(pInfoCombo->currentItem() == 0); + pWarnFile->setEnabled(pWarnCombo->currentItem() == 0); + pErrorFile->setEnabled(pErrorCombo->currentItem() == 0); + pFatalFile->setEnabled(pFatalCombo->currentItem() == 0); +} + +#include "tdedebugdialog.moc" diff --git a/tdedebugdialog/tdedebugdialog.h b/tdedebugdialog/tdedebugdialog.h new file mode 100644 index 000000000..dec300018 --- /dev/null +++ b/tdedebugdialog/tdedebugdialog.h @@ -0,0 +1,93 @@ +/* This file is part of the KDE libraries + Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@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. +*/ +#ifndef _TDEDEBUGDIALOG +#define _TDEDEBUGDIALOG + +#include "kabstractdebugdialog.h" + +class TQLineEdit; +class TQComboBox; +class TQLabel; +class TQGroupBox; +class TQCheckBox; +class TQPushButton; + +class TDEConfig; + +/** + * Control debug/warning/error/fatal output of TDE applications + * + * This dialog allows control of debugging output for all TDE apps. + * + * @author Kalle Dalheimer (kalle@kde.org) + */ +class TDEDebugDialog : public KAbstractDebugDialog +{ + Q_OBJECT + +public: + TDEDebugDialog( TQStringList areaList, TQWidget *parent=0, const char *name=0, bool modal=true ); + virtual ~TDEDebugDialog(); + + void save(); + +protected slots: + void slotDebugAreaChanged( const TQString & ); + void slotDestinationChanged(int); + +private: + TQComboBox* pDebugAreas; + TQGroupBox* pInfoGroup; + TQLabel* pInfoLabel1; + TQComboBox* pInfoCombo; + TQLabel* pInfoLabel2; + TQLineEdit* pInfoFile; + TQLabel* pInfoLabel3; + TQLineEdit* pInfoShow; + TQGroupBox* pWarnGroup; + TQLabel* pWarnLabel1; + TQComboBox* pWarnCombo; + TQLabel* pWarnLabel2; + TQLineEdit* pWarnFile; + TQLabel* pWarnLabel3; + TQLineEdit* pWarnShow; + TQGroupBox* pErrorGroup; + TQLabel* pErrorLabel1; + TQComboBox* pErrorCombo; + TQLabel* pErrorLabel2; + TQLineEdit* pErrorFile; + TQLabel* pErrorLabel3; + TQLineEdit* pErrorShow; + TQGroupBox* pFatalGroup; + TQLabel* pFatalLabel1; + TQComboBox* pFatalCombo; + TQLabel* pFatalLabel2; + TQLineEdit* pFatalFile; + TQLabel* pFatalLabel3; + TQLineEdit* pFatalShow; + + TQCheckBox* pAbortFatal; + +private: + // Disallow assignment and copy-construction + TDEDebugDialog( const TDEDebugDialog& ); + TDEDebugDialog& operator= ( const TDEDebugDialog& ); +}; + +#endif diff --git a/tdedebugdialog/tdelistdebugdialog.cpp b/tdedebugdialog/tdelistdebugdialog.cpp new file mode 100644 index 000000000..d447b3747 --- /dev/null +++ b/tdedebugdialog/tdelistdebugdialog.cpp @@ -0,0 +1,193 @@ +/* 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. +*/ + + +#include "tdelistdebugdialog.h" +#include <tdeconfig.h> +#include <tdeapplication.h> +#include <kdebug.h> +#include <tqlayout.h> +#include <tqscrollview.h> +#include <tqvbox.h> +#include <tdelocale.h> +#include <tqpushbutton.h> +#include <klineedit.h> +#include <dcopclient.h> + +TDEListDebugDialog::TDEListDebugDialog( TQStringList areaList, TQWidget *parent, const char *name, bool modal ) + : KAbstractDebugDialog( parent, name, modal ), + m_areaList( areaList ) +{ + setCaption(i18n("Debug Settings")); + + TQVBoxLayout *lay = new TQVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() ); + + m_incrSearch = new KLineEdit( this ); + lay->addWidget( m_incrSearch ); + connect( m_incrSearch, TQT_SIGNAL( textChanged( const TQString& ) ), + TQT_SLOT( generateCheckBoxes( const TQString& ) ) ); + + TQScrollView * scrollView = new TQScrollView( this ); + scrollView->setResizePolicy( TQScrollView::AutoOneFit ); + lay->addWidget( scrollView ); + + m_box = new TQVBox( scrollView->viewport() ); + scrollView->addChild( m_box ); + + generateCheckBoxes( TQString::null ); + + TQHBoxLayout* selectButs = new TQHBoxLayout( lay ); + TQPushButton* all = new TQPushButton( i18n("&Select All"), this ); + TQPushButton* none = new TQPushButton( i18n("&Deselect All"), this ); + selectButs->addWidget( all ); + selectButs->addWidget( none ); + + connect( all, TQT_SIGNAL( clicked() ), this, TQT_SLOT( selectAll() ) ); + connect( none, TQT_SIGNAL( clicked() ), this, TQT_SLOT( deSelectAll() ) ); + + buildButtons( lay ); + resize( 350, 400 ); +} + +void TDEListDebugDialog::generateCheckBoxes( const TQString& filter ) +{ + TQPtrListIterator<TQCheckBox> cb_it ( boxes ); + for( ; cb_it.current() ; ++cb_it ) + { + if( (*cb_it)->state() != TQButton::NoChange ) + m_changes.insert( (*cb_it)->name(), (*cb_it)->isChecked() ? 2 : 4 ); + } + + boxes.setAutoDelete( true ); + boxes.clear(); + boxes.setAutoDelete( false ); + + TQWidget* taborder = m_incrSearch; + TQStringList::Iterator it = m_areaList.begin(); + for ( ; it != m_areaList.end() ; ++it ) + { + TQString data = (*it).simplifyWhiteSpace(); + if ( filter.isEmpty() || data.lower().contains( filter.lower() ) ) + { + int space = data.find(" "); + if (space == -1) + kdError() << "No space:" << data << endl; + + TQString areaNumber = data.left(space); + //kdDebug() << areaNumber << endl; + TQCheckBox * cb = new TQCheckBox( data, m_box, areaNumber.latin1() ); + cb->show(); + boxes.append( cb ); + setTabOrder( taborder, cb ); + taborder = cb; + } + } + + load(); +} + +void TDEListDebugDialog::selectAll() +{ + TQPtrListIterator<TQCheckBox> it ( boxes ); + for ( ; it.current() ; ++it ) { + (*it)->setChecked( true ); + m_changes.insert( (*it)->name(), 2 ); + } +} + +void TDEListDebugDialog::deSelectAll() +{ + TQPtrListIterator<TQCheckBox> it ( boxes ); + for ( ; it.current() ; ++it ) { + (*it)->setChecked( false ); + m_changes.insert( (*it)->name(), 4 ); + } +} + +void TDEListDebugDialog::load() +{ + TQPtrListIterator<TQCheckBox> it ( boxes ); + for ( ; it.current() ; ++it ) + { + pConfig->setGroup( (*it)->name() ); // Group name = debug area code = cb's name + + int setting = pConfig->readNumEntry( "InfoOutput", 2 ); + // override setting if in m_changes + if( m_changes.find( (*it)->name() ) != m_changes.end() ) { + setting = m_changes[ (*it)->name() ]; + } + + switch (setting) { + case 4: // off + (*it)->setChecked(false); + break; + case 2: //shell + (*it)->setChecked(true); + break; + case 3: //syslog + case 1: //msgbox + case 0: //file + default: + (*it)->setNoChange(); + /////// Uses the triState capability of checkboxes + ////// Note: it seems some styles don't draw that correctly (BUG) + break; + } + } +} + +void TDEListDebugDialog::save() +{ + TQPtrListIterator<TQCheckBox> it ( boxes ); + for ( ; it.current() ; ++it ) + { + pConfig->setGroup( (*it)->name() ); // Group name = debug area code = cb's name + if ( (*it)->state() != TQButton::NoChange ) + { + int setting = (*it)->isChecked() ? 2 : 4; + pConfig->writeEntry( "InfoOutput", setting ); + } + } + //sync done by main.cpp + + // send DCOP message to all clients + TQByteArray data; + if (!kapp->dcopClient()->send("*", "KDebug", "notifyKDebugConfigChanged()", data)) + { + kdError() << "Unable to send DCOP message" << endl; + } + + m_changes.clear(); +} + +void TDEListDebugDialog::activateArea( TQCString area, bool activate ) +{ + TQPtrListIterator<TQCheckBox> it ( boxes ); + for ( ; it.current() ; ++it ) + { + if ( area == (*it)->name() // debug area code = cb's name + || (*it)->text().find( TQString::fromLatin1(area) ) != -1 ) // area name included in cb text + { + (*it)->setChecked( activate ); + return; + } + } +} + +#include "tdelistdebugdialog.moc" diff --git a/tdedebugdialog/tdelistdebugdialog.h b/tdedebugdialog/tdelistdebugdialog.h new file mode 100644 index 000000000..92e68d2be --- /dev/null +++ b/tdedebugdialog/tdelistdebugdialog.h @@ -0,0 +1,65 @@ +/* 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. +*/ + +#ifndef TDELISTDEBUGDIALOG__H +#define TDELISTDEBUGDIALOG__H + +#include "kabstractdebugdialog.h" +#include <tqcheckbox.h> +#include <tqptrlist.h> +#include <tqstringlist.h> + +class TQVBox; +class KLineEdit; + +/** + * Control debug output of TDE applications + * This dialog offers a reduced functionality compared to the full TDEDebugDialog + * class, but allows to set debug output on or off to several areas much more easily. + * + * @author David Faure <faure@kde.org> + */ +class TDEListDebugDialog : public KAbstractDebugDialog +{ + Q_OBJECT + +public: + TDEListDebugDialog( TQStringList areaList, TQWidget *parent=0, const char *name=0, bool modal=true ); + virtual ~TDEListDebugDialog() {} + + void activateArea( TQCString area, bool activate ); + + virtual void save(); + +protected slots: + void selectAll(); + void deSelectAll(); + + void generateCheckBoxes( const TQString& filter ); + +private: + void load(); + TQPtrList<TQCheckBox> boxes; + TQStringList m_areaList; + TQVBox *m_box; + KLineEdit *m_incrSearch; + TQMap<TQCString, int> m_changes; +}; + +#endif |