1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
|
/* This file is part of the Boson game. It was originally 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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, 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 <kglobal.h>
#include <klocale.h>
#include <kdialog.h>
#include <kconfig.h>
#include <kseparator.h>
#include <kapplication.h>
#include <kdebug.h>
#include <dcopclient.h>
#include "bodebugdialog.h"
BoDebugDialog::BoDebugDialog( QStringList areaList, QWidget *parent, const char *name, bool modal )
: BoAbstractDebugDialog( 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") );
destList.append( i18n("Application dependant output") );
//
// 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);
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() );
}
BoDebugDialog::~BoDebugDialog()
{
}
void BoDebugDialog::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->readEntry( "InfoFilename","bodebug.dbg" ) );
//pInfoShow->setText( pConfig->readEntry( "InfoShow", "" ) );
pWarnCombo->setCurrentItem( pConfig->readNumEntry( "WarnOutput", 2 ) );
pWarnFile->setText( pConfig->readEntry( "WarnFilename","bodebug.dbg" ) );
//pWarnShow->setText( pConfig->readEntry( "WarnShow", "" ) );
pErrorCombo->setCurrentItem( pConfig->readNumEntry( "ErrorOutput", 2 ) );
pErrorFile->setText( pConfig->readEntry( "ErrorFilename","bodebug.dbg") );
//pErrorShow->setText( pConfig->readEntry( "ErrorShow", "" ) );
pFatalCombo->setCurrentItem( pConfig->readNumEntry( "FatalOutput", 2 ) );
pFatalFile->setText( pConfig->readEntry("FatalFilename","bodebug.dbg") );
//pFatalShow->setText( pConfig->readEntry( "FatalShow", "" ) );
pAbortFatal->setChecked( pConfig->readNumEntry( "AbortFatal", 1 ) );
slotDestinationChanged(0);
}
void BoDebugDialog::save()
{
pConfig->writeEntry( "InfoOutput", pInfoCombo->currentItem() );
pConfig->writeEntry( "InfoFilename", pInfoFile->text() );
//pConfig->writeEntry( "InfoShow", pInfoShow->text() );
pConfig->writeEntry( "WarnOutput", pWarnCombo->currentItem() );
pConfig->writeEntry( "WarnFilename", pWarnFile->text() );
//pConfig->writeEntry( "WarnShow", pWarnShow->text() );
pConfig->writeEntry( "ErrorOutput", pErrorCombo->currentItem() );
pConfig->writeEntry( "ErrorFilename", pErrorFile->text() );
//pConfig->writeEntry( "ErrorShow", pErrorShow->text() );
pConfig->writeEntry( "FatalOutput", pFatalCombo->currentItem() );
pConfig->writeEntry( "FatalFilename", pFatalFile->text() );
//pConfig->writeEntry( "FatalShow", pFatalShow->text() );
pConfig->writeEntry( "AbortFatal", pAbortFatal->isChecked() );
QByteArray data;
if (!kapp->dcopClient()->send("*", "BoDebug-Interface", "notifyBoDebugConfigChanged()", data))
{
kdError() << "Unable to send DCOP message" << endl;
}
}
void BoDebugDialog::slotDestinationChanged(int) {
pInfoFile->setEnabled(pInfoCombo->currentItem() == 0);
pWarnFile->setEnabled(pWarnCombo->currentItem() == 0);
pErrorFile->setEnabled(pErrorCombo->currentItem() == 0);
pFatalFile->setEnabled(pFatalCombo->currentItem() == 0);
}
#include "bodebugdialog.moc"
|