summaryrefslogtreecommitdiffstats
path: root/kdebugdialog
diff options
context:
space:
mode:
Diffstat (limited to 'kdebugdialog')
-rw-r--r--kdebugdialog/Makefile.am16
-rw-r--r--kdebugdialog/README12
-rw-r--r--kdebugdialog/kabstractdebugdialog.cpp85
-rw-r--r--kdebugdialog/kabstractdebugdialog.h54
-rw-r--r--kdebugdialog/kdebugdialog.cpp260
-rw-r--r--kdebugdialog/kdebugdialog.h93
-rw-r--r--kdebugdialog/klistdebugdialog.cpp193
-rw-r--r--kdebugdialog/klistdebugdialog.h65
-rw-r--r--kdebugdialog/main.cpp124
9 files changed, 902 insertions, 0 deletions
diff --git a/kdebugdialog/Makefile.am b/kdebugdialog/Makefile.am
new file mode 100644
index 000000000..a301bd54b
--- /dev/null
+++ b/kdebugdialog/Makefile.am
@@ -0,0 +1,16 @@
+## Makefile.am of kdebugdialog
+
+INCLUDES= $(all_includes)
+
+####### Files
+
+bin_PROGRAMS = kdebugdialog
+
+kdebugdialog_SOURCES = main.cpp kabstractdebugdialog.cpp kdebugdialog.cpp klistdebugdialog.cpp
+kdebugdialog_METASOURCES = AUTO
+kdebugdialog_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+kdebugdialog_LDADD = $(LIB_KDEUI)
+
+messages:
+ $(XGETTEXT) *.cpp -o $(podir)/kdebugdialog.pot
+
diff --git a/kdebugdialog/README b/kdebugdialog/README
new file mode 100644
index 000000000..e1d239223
--- /dev/null
+++ b/kdebugdialog/README
@@ -0,0 +1,12 @@
+kdebugdialog
+------------
+
+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/.kde/share/config/kdebugrc
+
diff --git a/kdebugdialog/kabstractdebugdialog.cpp b/kdebugdialog/kabstractdebugdialog.cpp
new file mode 100644
index 000000000..76dca8f61
--- /dev/null
+++ b/kdebugdialog/kabstractdebugdialog.cpp
@@ -0,0 +1,85 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2000 David Faure <[email protected]>
+
+ 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 <kconfig.h>
+#include <kpushbutton.h>
+#include <qlayout.h>
+#include <kapplication.h>
+#include <klocale.h>
+#include <kstdguiitem.h>
+
+KAbstractDebugDialog::KAbstractDebugDialog( QWidget *parent, const char *name, bool modal )
+ : KDialog( parent, name, modal )
+{
+ pConfig = new KConfig( "kdebugrc" );
+}
+
+KAbstractDebugDialog::~KAbstractDebugDialog()
+{
+ delete pConfig;
+}
+
+void KAbstractDebugDialog::buildButtons( QVBoxLayout * topLayout )
+{
+ QHBoxLayout *hbox = new QHBoxLayout( KDialog::spacingHint() );
+ topLayout->addLayout( hbox );
+ pHelpButton = new KPushButton( KStdGuiItem::help(), this );
+ hbox->addWidget( pHelpButton );
+ hbox->addStretch(10);
+ QSpacerItem *spacer = new QSpacerItem(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 = QMAX( w1, QMAX( w2, w3 ) );
+ int w5 = pApplyButton->sizeHint().width();
+ w4 = QMAX(w4, w5);
+
+ pHelpButton->setFixedWidth( w4 );
+ pOKButton->setFixedWidth( w4 );
+ pApplyButton->setFixedWidth( w4 );
+ pCancelButton->setFixedWidth( w4 );
+
+ connect( pHelpButton, SIGNAL( clicked() ), SLOT( slotShowHelp() ) );
+ connect( pOKButton, SIGNAL( clicked() ), SLOT( accept() ) );
+ connect( pApplyButton, SIGNAL( clicked() ), SLOT( slotApply() ) );
+ connect( pCancelButton, SIGNAL( clicked() ), SLOT( reject() ) );
+}
+
+void KAbstractDebugDialog::slotShowHelp()
+{
+ if (kapp)
+ kapp->invokeHelp();
+}
+
+void KAbstractDebugDialog::slotApply()
+{
+ save();
+ pConfig->sync();
+}
+
+#include "kabstractdebugdialog.moc"
diff --git a/kdebugdialog/kabstractdebugdialog.h b/kdebugdialog/kabstractdebugdialog.h
new file mode 100644
index 000000000..d31fb53aa
--- /dev/null
+++ b/kdebugdialog/kabstractdebugdialog.h
@@ -0,0 +1,54 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2000 David Faure <[email protected]>
+
+ 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 KConfig;
+class QVBoxLayout;
+class KPushButton;
+
+class KAbstractDebugDialog : public KDialog
+{
+ Q_OBJECT
+public:
+ KAbstractDebugDialog( QWidget *parent=0, const char *name=0, bool modal=true );
+
+ virtual ~KAbstractDebugDialog();
+
+ virtual void buildButtons(QVBoxLayout * topLayout);
+
+ virtual void save() = 0;
+ KConfig * config() { return pConfig; }
+
+protected slots:
+ void slotShowHelp();
+ void slotApply();
+
+protected:
+ KConfig* pConfig;
+ KPushButton* pOKButton;
+ KPushButton* pCancelButton;
+ KPushButton* pHelpButton;
+ KPushButton* pApplyButton;
+};
+
+#endif
diff --git a/kdebugdialog/kdebugdialog.cpp b/kdebugdialog/kdebugdialog.cpp
new file mode 100644
index 000000000..ae0ef0eaa
--- /dev/null
+++ b/kdebugdialog/kdebugdialog.cpp
@@ -0,0 +1,260 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 1997 Matthias Kalle Dalheimer ([email protected])
+ Copyright (C) 1999 David Faure ([email protected])
+
+ 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 <qlayout.h>
+#include <qlineedit.h>
+#include <qcombobox.h>
+#include <qlabel.h>
+#include <qgroupbox.h>
+#include <qcheckbox.h>
+#include <qpushbutton.h>
+#include <kdebug.h>
+#include <kglobal.h>
+#include <klocale.h>
+#include <kdialog.h>
+#include <kconfig.h>
+#include <kseparator.h>
+#include <kapplication.h>
+#include <dcopclient.h>
+
+#include "kdebugdialog.h"
+
+KDebugDialog::KDebugDialog( QStringList areaList, QWidget *parent, const char *name, bool modal )
+ : KAbstractDebugDialog( parent, name, modal )
+{
+ setCaption(i18n("Debug Settings"));
+
+ QVBoxLayout *topLayout = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
+ if( topLayout == 0 ) { return; } // can this happen ?
+
+ QLabel * tmpLabel = new QLabel( i18n("Debug area:"), this );
+ tmpLabel->setFixedHeight( fontMetrics().lineSpacing() );
+ topLayout->addWidget( tmpLabel );
+
+ // Build combo of debug areas
+ pDebugAreas = new QComboBox( false, this );
+ pDebugAreas->setFixedHeight( pDebugAreas->sizeHint().height() );
+ pDebugAreas->insertStringList( areaList );
+ topLayout->addWidget( pDebugAreas );
+
+ QGridLayout *gbox = new QGridLayout( 2, 2, KDialog::marginHint() );
+ if( gbox == 0 ) { return; }
+ topLayout->addLayout( gbox );
+
+ QStringList 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 QGroupBox( i18n("Information"), this );
+ gbox->addWidget( pInfoGroup, 0, 0 );
+ QVBoxLayout *vbox = new QVBoxLayout( pInfoGroup, KDialog::spacingHint() );
+ vbox->addSpacing( fontMetrics().lineSpacing() );
+ pInfoLabel1 = new QLabel( i18n("Output to:"), pInfoGroup );
+ vbox->addWidget( pInfoLabel1 );
+ pInfoCombo = new QComboBox( false, pInfoGroup );
+ connect(pInfoCombo, SIGNAL(activated(int)),
+ this, SLOT(slotDestinationChanged(int)));
+ vbox->addWidget( pInfoCombo );
+ pInfoCombo->insertStringList( destList );
+ pInfoLabel2 = new QLabel( i18n("Filename:"), pInfoGroup );
+ vbox->addWidget( pInfoLabel2 );
+ pInfoFile = new QLineEdit( pInfoGroup );
+ vbox->addWidget( pInfoFile );
+ /*
+ pInfoLabel3 = new QLabel( i18n("Show only area(s):"), pInfoGroup );
+ vbox->addWidget( pInfoLabel3 );
+ pInfoShow = new QLineEdit( pInfoGroup );
+ vbox->addWidget( pInfoShow );
+ */
+
+ //
+ // Upper right frame
+ //
+ pWarnGroup = new QGroupBox( i18n("Warning"), this );
+ gbox->addWidget( pWarnGroup, 0, 1 );
+ vbox = new QVBoxLayout( pWarnGroup, KDialog::spacingHint() );
+ vbox->addSpacing( fontMetrics().lineSpacing() );
+ pWarnLabel1 = new QLabel( i18n("Output to:"), pWarnGroup );
+ vbox->addWidget( pWarnLabel1 );
+ pWarnCombo = new QComboBox( false, pWarnGroup );
+ connect(pWarnCombo, SIGNAL(activated(int)),
+ this, SLOT(slotDestinationChanged(int)));
+ vbox->addWidget( pWarnCombo );
+ pWarnCombo->insertStringList( destList );
+ pWarnLabel2 = new QLabel( i18n("Filename:"), pWarnGroup );
+ vbox->addWidget( pWarnLabel2 );
+ pWarnFile = new QLineEdit( pWarnGroup );
+ vbox->addWidget( pWarnFile );
+ /*
+ pWarnLabel3 = new QLabel( i18n("Show only area(s):"), pWarnGroup );
+ vbox->addWidget( pWarnLabel3 );
+ pWarnShow = new QLineEdit( pWarnGroup );
+ vbox->addWidget( pWarnShow );
+ */
+
+ //
+ // Lower left frame
+ //
+ pErrorGroup = new QGroupBox( i18n("Error"), this );
+ gbox->addWidget( pErrorGroup, 1, 0 );
+ vbox = new QVBoxLayout( pErrorGroup, KDialog::spacingHint() );
+ vbox->addSpacing( fontMetrics().lineSpacing() );
+ pErrorLabel1 = new QLabel( i18n("Output to:"), pErrorGroup );
+ vbox->addWidget( pErrorLabel1 );
+ pErrorCombo = new QComboBox( false, pErrorGroup );
+ connect(pErrorCombo, SIGNAL(activated(int)),
+ this, SLOT(slotDestinationChanged(int)));
+ vbox->addWidget( pErrorCombo );
+ pErrorCombo->insertStringList( destList );
+ pErrorLabel2 = new QLabel( i18n("Filename:"), pErrorGroup );
+ vbox->addWidget( pErrorLabel2 );
+ pErrorFile = new QLineEdit( pErrorGroup );
+ vbox->addWidget( pErrorFile );
+ /*
+ pErrorLabel3 = new QLabel( i18n("Show only area(s):"), pErrorGroup );
+ vbox->addWidget( pErrorLabel3 );
+ pErrorShow = new QLineEdit( pErrorGroup );
+ vbox->addWidget( pErrorShow );
+ */
+
+ //
+ // Lower right frame
+ //
+ pFatalGroup = new QGroupBox( i18n("Fatal Error"), this );
+ gbox->addWidget( pFatalGroup, 1, 1 );
+ vbox = new QVBoxLayout( pFatalGroup, KDialog::spacingHint() );
+ vbox->addSpacing( fontMetrics().lineSpacing() );
+ pFatalLabel1 = new QLabel( i18n("Output to:"), pFatalGroup );
+ vbox->addWidget( pFatalLabel1 );
+ pFatalCombo = new QComboBox( false, pFatalGroup );
+ connect(pFatalCombo, SIGNAL(activated(int)),
+ this, SLOT(slotDestinationChanged(int)));
+ vbox->addWidget( pFatalCombo );
+ pFatalCombo->insertStringList( destList );
+ pFatalLabel2 = new QLabel( i18n("Filename:"), pFatalGroup );
+ vbox->addWidget( pFatalLabel2 );
+ pFatalFile = new QLineEdit( pFatalGroup );
+ vbox->addWidget( pFatalFile );
+ /*
+ pFatalLabel3 = new QLabel( i18n("Show only area(s):"), pFatalGroup );
+ vbox->addWidget( pFatalLabel3 );
+ pFatalShow = new QLineEdit( pFatalGroup );
+ vbox->addWidget( pFatalShow );
+ */
+
+
+ pAbortFatal = new QCheckBox( 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, SIGNAL( activated( const QString &) ),
+ SLOT( slotDebugAreaChanged( const QString & ) ) );
+
+ // Get initial values ("initial" is understood by the slot)
+ slotDebugAreaChanged( "0 initial" );
+ slotDestinationChanged(0);
+
+ resize( 300, height() );
+}
+
+KDebugDialog::~KDebugDialog()
+{
+}
+
+void KDebugDialog::slotDebugAreaChanged( const QString & text )
+{
+ // Save settings from previous page
+ if ( text != "0 initial" ) // except on first call
+ save();
+
+ QString 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( QString::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 KDebugDialog::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() );
+
+ QByteArray data;
+ if (!kapp->dcopClient()->send("*", "KDebug", "notifyKDebugConfigChanged()", data))
+ {
+ kdError() << "Unable to send DCOP message" << endl;
+ }
+}
+
+void KDebugDialog::slotDestinationChanged(int) {
+ pInfoFile->setEnabled(pInfoCombo->currentItem() == 0);
+ pWarnFile->setEnabled(pWarnCombo->currentItem() == 0);
+ pErrorFile->setEnabled(pErrorCombo->currentItem() == 0);
+ pFatalFile->setEnabled(pFatalCombo->currentItem() == 0);
+}
+
+#include "kdebugdialog.moc"
diff --git a/kdebugdialog/kdebugdialog.h b/kdebugdialog/kdebugdialog.h
new file mode 100644
index 000000000..d0c22fbc1
--- /dev/null
+++ b/kdebugdialog/kdebugdialog.h
@@ -0,0 +1,93 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 1997 Matthias Kalle Dalheimer ([email protected])
+
+ 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 _KDEBUGDIALOG
+#define _KDEBUGDIALOG
+
+#include "kabstractdebugdialog.h"
+
+class QLineEdit;
+class QComboBox;
+class QLabel;
+class QGroupBox;
+class QCheckBox;
+class QPushButton;
+
+class KConfig;
+
+/**
+ * Control debug/warning/error/fatal output of KDE applications
+ *
+ * This dialog allows control of debugging output for all KDE apps.
+ *
+ * @author Kalle Dalheimer ([email protected])
+ */
+class KDebugDialog : public KAbstractDebugDialog
+{
+ Q_OBJECT
+
+public:
+ KDebugDialog( QStringList areaList, QWidget *parent=0, const char *name=0, bool modal=true );
+ virtual ~KDebugDialog();
+
+ void save();
+
+protected slots:
+ void slotDebugAreaChanged( const QString & );
+ void slotDestinationChanged(int);
+
+private:
+ QComboBox* pDebugAreas;
+ QGroupBox* pInfoGroup;
+ QLabel* pInfoLabel1;
+ QComboBox* pInfoCombo;
+ QLabel* pInfoLabel2;
+ QLineEdit* pInfoFile;
+ QLabel* pInfoLabel3;
+ QLineEdit* pInfoShow;
+ QGroupBox* pWarnGroup;
+ QLabel* pWarnLabel1;
+ QComboBox* pWarnCombo;
+ QLabel* pWarnLabel2;
+ QLineEdit* pWarnFile;
+ QLabel* pWarnLabel3;
+ QLineEdit* pWarnShow;
+ QGroupBox* pErrorGroup;
+ QLabel* pErrorLabel1;
+ QComboBox* pErrorCombo;
+ QLabel* pErrorLabel2;
+ QLineEdit* pErrorFile;
+ QLabel* pErrorLabel3;
+ QLineEdit* pErrorShow;
+ QGroupBox* pFatalGroup;
+ QLabel* pFatalLabel1;
+ QComboBox* pFatalCombo;
+ QLabel* pFatalLabel2;
+ QLineEdit* pFatalFile;
+ QLabel* pFatalLabel3;
+ QLineEdit* pFatalShow;
+
+ QCheckBox* pAbortFatal;
+
+private:
+ // Disallow assignment and copy-construction
+ KDebugDialog( const KDebugDialog& );
+ KDebugDialog& operator= ( const KDebugDialog& );
+};
+
+#endif
diff --git a/kdebugdialog/klistdebugdialog.cpp b/kdebugdialog/klistdebugdialog.cpp
new file mode 100644
index 000000000..8dade2895
--- /dev/null
+++ b/kdebugdialog/klistdebugdialog.cpp
@@ -0,0 +1,193 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2000 David Faure <[email protected]>
+
+ 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 "klistdebugdialog.h"
+#include <kconfig.h>
+#include <kapplication.h>
+#include <kdebug.h>
+#include <qlayout.h>
+#include <qscrollview.h>
+#include <qvbox.h>
+#include <klocale.h>
+#include <qpushbutton.h>
+#include <klineedit.h>
+#include <dcopclient.h>
+
+KListDebugDialog::KListDebugDialog( QStringList areaList, QWidget *parent, const char *name, bool modal )
+ : KAbstractDebugDialog( parent, name, modal ),
+ m_areaList( areaList )
+{
+ setCaption(i18n("Debug Settings"));
+
+ QVBoxLayout *lay = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
+
+ m_incrSearch = new KLineEdit( this );
+ lay->addWidget( m_incrSearch );
+ connect( m_incrSearch, SIGNAL( textChanged( const QString& ) ),
+ SLOT( generateCheckBoxes( const QString& ) ) );
+
+ QScrollView * scrollView = new QScrollView( this );
+ scrollView->setResizePolicy( QScrollView::AutoOneFit );
+ lay->addWidget( scrollView );
+
+ m_box = new QVBox( scrollView->viewport() );
+ scrollView->addChild( m_box );
+
+ generateCheckBoxes( QString::null );
+
+ QHBoxLayout* selectButs = new QHBoxLayout( lay );
+ QPushButton* all = new QPushButton( i18n("&Select All"), this );
+ QPushButton* none = new QPushButton( i18n("&Deselect All"), this );
+ selectButs->addWidget( all );
+ selectButs->addWidget( none );
+
+ connect( all, SIGNAL( clicked() ), this, SLOT( selectAll() ) );
+ connect( none, SIGNAL( clicked() ), this, SLOT( deSelectAll() ) );
+
+ buildButtons( lay );
+ resize( 350, 400 );
+}
+
+void KListDebugDialog::generateCheckBoxes( const QString& filter )
+{
+ QPtrListIterator<QCheckBox> cb_it ( boxes );
+ for( ; cb_it.current() ; ++cb_it )
+ {
+ if( (*cb_it)->state() != QButton::NoChange )
+ m_changes.insert( (*cb_it)->name(), (*cb_it)->isChecked() ? 2 : 4 );
+ }
+
+ boxes.setAutoDelete( true );
+ boxes.clear();
+ boxes.setAutoDelete( false );
+
+ QWidget* taborder = m_incrSearch;
+ QStringList::Iterator it = m_areaList.begin();
+ for ( ; it != m_areaList.end() ; ++it )
+ {
+ QString data = (*it).simplifyWhiteSpace();
+ if ( filter.isEmpty() || data.lower().contains( filter.lower() ) )
+ {
+ int space = data.find(" ");
+ if (space == -1)
+ kdError() << "No space:" << data << endl;
+
+ QString areaNumber = data.left(space);
+ //kdDebug() << areaNumber << endl;
+ QCheckBox * cb = new QCheckBox( data, m_box, areaNumber.latin1() );
+ cb->show();
+ boxes.append( cb );
+ setTabOrder( taborder, cb );
+ taborder = cb;
+ }
+ }
+
+ load();
+}
+
+void KListDebugDialog::selectAll()
+{
+ QPtrListIterator<QCheckBox> it ( boxes );
+ for ( ; it.current() ; ++it ) {
+ (*it)->setChecked( true );
+ m_changes.insert( (*it)->name(), 2 );
+ }
+}
+
+void KListDebugDialog::deSelectAll()
+{
+ QPtrListIterator<QCheckBox> it ( boxes );
+ for ( ; it.current() ; ++it ) {
+ (*it)->setChecked( false );
+ m_changes.insert( (*it)->name(), 4 );
+ }
+}
+
+void KListDebugDialog::load()
+{
+ QPtrListIterator<QCheckBox> 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 KListDebugDialog::save()
+{
+ QPtrListIterator<QCheckBox> it ( boxes );
+ for ( ; it.current() ; ++it )
+ {
+ pConfig->setGroup( (*it)->name() ); // Group name = debug area code = cb's name
+ if ( (*it)->state() != QButton::NoChange )
+ {
+ int setting = (*it)->isChecked() ? 2 : 4;
+ pConfig->writeEntry( "InfoOutput", setting );
+ }
+ }
+ //sync done by main.cpp
+
+ // send DCOP message to all clients
+ QByteArray data;
+ if (!kapp->dcopClient()->send("*", "KDebug", "notifyKDebugConfigChanged()", data))
+ {
+ kdError() << "Unable to send DCOP message" << endl;
+ }
+
+ m_changes.clear();
+}
+
+void KListDebugDialog::activateArea( QCString area, bool activate )
+{
+ QPtrListIterator<QCheckBox> it ( boxes );
+ for ( ; it.current() ; ++it )
+ {
+ if ( area == (*it)->name() // debug area code = cb's name
+ || (*it)->text().find( QString::fromLatin1(area) ) != -1 ) // area name included in cb text
+ {
+ (*it)->setChecked( activate );
+ return;
+ }
+ }
+}
+
+#include "klistdebugdialog.moc"
diff --git a/kdebugdialog/klistdebugdialog.h b/kdebugdialog/klistdebugdialog.h
new file mode 100644
index 000000000..97ab73ce6
--- /dev/null
+++ b/kdebugdialog/klistdebugdialog.h
@@ -0,0 +1,65 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2000 David Faure <[email protected]>
+
+ 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 KLISTDEBUGDIALOG__H
+#define KLISTDEBUGDIALOG__H
+
+#include "kabstractdebugdialog.h"
+#include <qcheckbox.h>
+#include <qptrlist.h>
+#include <qstringlist.h>
+
+class QVBox;
+class KLineEdit;
+
+/**
+ * Control debug output of KDE applications
+ * This dialog offers a reduced functionality compared to the full KDebugDialog
+ * class, but allows to set debug output on or off to several areas much more easily.
+ *
+ * @author David Faure <[email protected]>
+ */
+class KListDebugDialog : public KAbstractDebugDialog
+{
+ Q_OBJECT
+
+public:
+ KListDebugDialog( QStringList areaList, QWidget *parent=0, const char *name=0, bool modal=true );
+ virtual ~KListDebugDialog() {}
+
+ void activateArea( QCString area, bool activate );
+
+ virtual void save();
+
+protected slots:
+ void selectAll();
+ void deSelectAll();
+
+ void generateCheckBoxes( const QString& filter );
+
+private:
+ void load();
+ QPtrList<QCheckBox> boxes;
+ QStringList m_areaList;
+ QVBox *m_box;
+ KLineEdit *m_incrSearch;
+ QMap<QCString, int> m_changes;
+};
+
+#endif
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 <[email protected]>
+
+ 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 <kcmdlineargs.h>
+#include <kaboutdata.h>
+#include <kstandarddirs.h>
+#include <qtextstream.h>
+#include <klocale.h>
+#include <kdebug.h>
+#include <kuniqueapplication.h>
+#include <kconfig.h>
+
+#include <qfile.h>
+
+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 <area>", /*I18N_NOOP TODO*/ "Turn area on", 0 },
+ { "off <area>", /*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 <[email protected]>");
+ data.addAuthor("David Faure", I18N_NOOP("Maintainer"), "[email protected]");
+ 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;
+}