|
Line 0
Link Here
|
|
|
1 |
/* This file is part of the KDE libraries |
| 2 |
Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) |
| 3 |
Copyright (C) 1999 David Faure (faure@kde.org) |
| 4 |
|
| 5 |
This library is free software; you can redistribute it and/or |
| 6 |
modify it under the terms of the GNU Library General Public |
| 7 |
License as published by the Free Software Foundation; either |
| 8 |
version 2 of the License, or (at your option) any later version. |
| 9 |
|
| 10 |
This library is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
Library General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU Library General Public License |
| 16 |
along with this library; see the file COPYING.LIB. If not, write to |
| 17 |
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 |
Boston, MA 02110-1301, USA. |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifdef HAVE_CONFIG_H |
| 22 |
#include "config.h" |
| 23 |
#endif |
| 24 |
|
| 25 |
#include <tqlayout.h> |
| 26 |
#include <tqlineedit.h> |
| 27 |
#include <tqcombobox.h> |
| 28 |
#include <tqlabel.h> |
| 29 |
#include <tqgroupbox.h> |
| 30 |
#include <tqcheckbox.h> |
| 31 |
#include <tqpushbutton.h> |
| 32 |
#include <kdebug.h> |
| 33 |
#include <tdeglobal.h> |
| 34 |
#include <tdelocale.h> |
| 35 |
#include <kdialog.h> |
| 36 |
#include <tdeconfig.h> |
| 37 |
#include <kseparator.h> |
| 38 |
#include <tdeapplication.h> |
| 39 |
#include <dcopclient.h> |
| 40 |
|
| 41 |
#include "tdedebugdialog.h" |
| 42 |
|
| 43 |
TDEDebugDialog::TDEDebugDialog( TQStringList areaList, TQWidget *parent, const char *name, bool modal ) |
| 44 |
: KAbstractDebugDialog( parent, name, modal ) |
| 45 |
{ |
| 46 |
setCaption(i18n("Debug Settings")); |
| 47 |
|
| 48 |
TQVBoxLayout *topLayout = new TQVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() ); |
| 49 |
if( topLayout == 0 ) { return; } // can this happen ? |
| 50 |
|
| 51 |
TQLabel * tmpLabel = new TQLabel( i18n("Debug area:"), this ); |
| 52 |
tmpLabel->setFixedHeight( fontMetrics().lineSpacing() ); |
| 53 |
topLayout->addWidget( tmpLabel ); |
| 54 |
|
| 55 |
// Build combo of debug areas |
| 56 |
pDebugAreas = new TQComboBox( false, this ); |
| 57 |
pDebugAreas->setFixedHeight( pDebugAreas->sizeHint().height() ); |
| 58 |
pDebugAreas->insertStringList( areaList ); |
| 59 |
topLayout->addWidget( pDebugAreas ); |
| 60 |
|
| 61 |
TQGridLayout *gbox = new TQGridLayout( 2, 2, KDialog::marginHint() ); |
| 62 |
if( gbox == 0 ) { return; } |
| 63 |
topLayout->addLayout( TQT_TQLAYOUT(gbox) ); |
| 64 |
|
| 65 |
TQStringList destList; |
| 66 |
destList.append( i18n("File") ); |
| 67 |
destList.append( i18n("Message Box") ); |
| 68 |
destList.append( i18n("Shell") ); |
| 69 |
destList.append( i18n("Syslog") ); |
| 70 |
destList.append( i18n("None") ); |
| 71 |
|
| 72 |
// |
| 73 |
// Upper left frame |
| 74 |
// |
| 75 |
pInfoGroup = new TQGroupBox( i18n("Information"), this ); |
| 76 |
gbox->addWidget( pInfoGroup, 0, 0 ); |
| 77 |
TQVBoxLayout *vbox = new TQVBoxLayout( pInfoGroup, KDialog::spacingHint() ); |
| 78 |
vbox->addSpacing( fontMetrics().lineSpacing() ); |
| 79 |
pInfoLabel1 = new TQLabel( i18n("Output to:"), pInfoGroup ); |
| 80 |
vbox->addWidget( pInfoLabel1 ); |
| 81 |
pInfoCombo = new TQComboBox( false, pInfoGroup ); |
| 82 |
connect(pInfoCombo, TQT_SIGNAL(activated(int)), |
| 83 |
this, TQT_SLOT(slotDestinationChanged(int))); |
| 84 |
vbox->addWidget( pInfoCombo ); |
| 85 |
pInfoCombo->insertStringList( destList ); |
| 86 |
pInfoLabel2 = new TQLabel( i18n("Filename:"), pInfoGroup ); |
| 87 |
vbox->addWidget( pInfoLabel2 ); |
| 88 |
pInfoFile = new TQLineEdit( pInfoGroup ); |
| 89 |
vbox->addWidget( pInfoFile ); |
| 90 |
/* |
| 91 |
pInfoLabel3 = new TQLabel( i18n("Show only area(s):"), pInfoGroup ); |
| 92 |
vbox->addWidget( pInfoLabel3 ); |
| 93 |
pInfoShow = new TQLineEdit( pInfoGroup ); |
| 94 |
vbox->addWidget( pInfoShow ); |
| 95 |
*/ |
| 96 |
|
| 97 |
// |
| 98 |
// Upper right frame |
| 99 |
// |
| 100 |
pWarnGroup = new TQGroupBox( i18n("Warning"), this ); |
| 101 |
gbox->addWidget( pWarnGroup, 0, 1 ); |
| 102 |
vbox = new TQVBoxLayout( pWarnGroup, KDialog::spacingHint() ); |
| 103 |
vbox->addSpacing( fontMetrics().lineSpacing() ); |
| 104 |
pWarnLabel1 = new TQLabel( i18n("Output to:"), pWarnGroup ); |
| 105 |
vbox->addWidget( pWarnLabel1 ); |
| 106 |
pWarnCombo = new TQComboBox( false, pWarnGroup ); |
| 107 |
connect(pWarnCombo, TQT_SIGNAL(activated(int)), |
| 108 |
this, TQT_SLOT(slotDestinationChanged(int))); |
| 109 |
vbox->addWidget( pWarnCombo ); |
| 110 |
pWarnCombo->insertStringList( destList ); |
| 111 |
pWarnLabel2 = new TQLabel( i18n("Filename:"), pWarnGroup ); |
| 112 |
vbox->addWidget( pWarnLabel2 ); |
| 113 |
pWarnFile = new TQLineEdit( pWarnGroup ); |
| 114 |
vbox->addWidget( pWarnFile ); |
| 115 |
/* |
| 116 |
pWarnLabel3 = new TQLabel( i18n("Show only area(s):"), pWarnGroup ); |
| 117 |
vbox->addWidget( pWarnLabel3 ); |
| 118 |
pWarnShow = new TQLineEdit( pWarnGroup ); |
| 119 |
vbox->addWidget( pWarnShow ); |
| 120 |
*/ |
| 121 |
|
| 122 |
// |
| 123 |
// Lower left frame |
| 124 |
// |
| 125 |
pErrorGroup = new TQGroupBox( i18n("Error"), this ); |
| 126 |
gbox->addWidget( pErrorGroup, 1, 0 ); |
| 127 |
vbox = new TQVBoxLayout( pErrorGroup, KDialog::spacingHint() ); |
| 128 |
vbox->addSpacing( fontMetrics().lineSpacing() ); |
| 129 |
pErrorLabel1 = new TQLabel( i18n("Output to:"), pErrorGroup ); |
| 130 |
vbox->addWidget( pErrorLabel1 ); |
| 131 |
pErrorCombo = new TQComboBox( false, pErrorGroup ); |
| 132 |
connect(pErrorCombo, TQT_SIGNAL(activated(int)), |
| 133 |
this, TQT_SLOT(slotDestinationChanged(int))); |
| 134 |
vbox->addWidget( pErrorCombo ); |
| 135 |
pErrorCombo->insertStringList( destList ); |
| 136 |
pErrorLabel2 = new TQLabel( i18n("Filename:"), pErrorGroup ); |
| 137 |
vbox->addWidget( pErrorLabel2 ); |
| 138 |
pErrorFile = new TQLineEdit( pErrorGroup ); |
| 139 |
vbox->addWidget( pErrorFile ); |
| 140 |
/* |
| 141 |
pErrorLabel3 = new TQLabel( i18n("Show only area(s):"), pErrorGroup ); |
| 142 |
vbox->addWidget( pErrorLabel3 ); |
| 143 |
pErrorShow = new TQLineEdit( pErrorGroup ); |
| 144 |
vbox->addWidget( pErrorShow ); |
| 145 |
*/ |
| 146 |
|
| 147 |
// |
| 148 |
// Lower right frame |
| 149 |
// |
| 150 |
pFatalGroup = new TQGroupBox( i18n("Fatal Error"), this ); |
| 151 |
gbox->addWidget( pFatalGroup, 1, 1 ); |
| 152 |
vbox = new TQVBoxLayout( pFatalGroup, KDialog::spacingHint() ); |
| 153 |
vbox->addSpacing( fontMetrics().lineSpacing() ); |
| 154 |
pFatalLabel1 = new TQLabel( i18n("Output to:"), pFatalGroup ); |
| 155 |
vbox->addWidget( pFatalLabel1 ); |
| 156 |
pFatalCombo = new TQComboBox( false, pFatalGroup ); |
| 157 |
connect(pFatalCombo, TQT_SIGNAL(activated(int)), |
| 158 |
this, TQT_SLOT(slotDestinationChanged(int))); |
| 159 |
vbox->addWidget( pFatalCombo ); |
| 160 |
pFatalCombo->insertStringList( destList ); |
| 161 |
pFatalLabel2 = new TQLabel( i18n("Filename:"), pFatalGroup ); |
| 162 |
vbox->addWidget( pFatalLabel2 ); |
| 163 |
pFatalFile = new TQLineEdit( pFatalGroup ); |
| 164 |
vbox->addWidget( pFatalFile ); |
| 165 |
/* |
| 166 |
pFatalLabel3 = new TQLabel( i18n("Show only area(s):"), pFatalGroup ); |
| 167 |
vbox->addWidget( pFatalLabel3 ); |
| 168 |
pFatalShow = new TQLineEdit( pFatalGroup ); |
| 169 |
vbox->addWidget( pFatalShow ); |
| 170 |
*/ |
| 171 |
|
| 172 |
|
| 173 |
pAbortFatal = new TQCheckBox( i18n("Abort on fatal errors"), this ); |
| 174 |
topLayout->addWidget(pAbortFatal); |
| 175 |
|
| 176 |
topLayout->addStretch(); |
| 177 |
KSeparator *hline = new KSeparator( KSeparator::HLine, this ); |
| 178 |
topLayout->addWidget( hline ); |
| 179 |
|
| 180 |
buildButtons( topLayout ); |
| 181 |
|
| 182 |
connect( pDebugAreas, TQT_SIGNAL( activated( const TQString &) ), |
| 183 |
TQT_SLOT( slotDebugAreaChanged( const TQString & ) ) ); |
| 184 |
|
| 185 |
// Get initial values ("initial" is understood by the slot) |
| 186 |
slotDebugAreaChanged( "0 initial" ); |
| 187 |
slotDestinationChanged(0); |
| 188 |
|
| 189 |
resize( 300, height() ); |
| 190 |
} |
| 191 |
|
| 192 |
TDEDebugDialog::~TDEDebugDialog() |
| 193 |
{ |
| 194 |
} |
| 195 |
|
| 196 |
void TDEDebugDialog::slotDebugAreaChanged( const TQString & text ) |
| 197 |
{ |
| 198 |
// Save settings from previous page |
| 199 |
if ( text != "0 initial" ) // except on first call |
| 200 |
save(); |
| 201 |
|
| 202 |
TQString data = text.simplifyWhiteSpace(); |
| 203 |
int space = data.find(" "); |
| 204 |
if (space == -1) |
| 205 |
kdError() << "No space:" << data << endl; |
| 206 |
|
| 207 |
bool longOK; |
| 208 |
unsigned long number = data.left(space).toULong(&longOK); |
| 209 |
if (!longOK) |
| 210 |
kdError() << "The first part wasn't a number : " << data << endl; |
| 211 |
|
| 212 |
/* Fill dialog fields with values from config data */ |
| 213 |
pConfig->setGroup( TQString::number( number ) ); // Group name = debug area code |
| 214 |
pInfoCombo->setCurrentItem( pConfig->readNumEntry( "InfoOutput", 2 ) ); |
| 215 |
pInfoFile->setText( pConfig->readPathEntry( "InfoFilename","kdebug.dbg" ) ); |
| 216 |
//pInfoShow->setText( pConfig->readEntry( "InfoShow" ) ); |
| 217 |
pWarnCombo->setCurrentItem( pConfig->readNumEntry( "WarnOutput", 2 ) ); |
| 218 |
pWarnFile->setText( pConfig->readPathEntry( "WarnFilename","kdebug.dbg" ) ); |
| 219 |
//pWarnShow->setText( pConfig->readEntry( "WarnShow" ) ); |
| 220 |
pErrorCombo->setCurrentItem( pConfig->readNumEntry( "ErrorOutput", 2 ) ); |
| 221 |
pErrorFile->setText( pConfig->readPathEntry( "ErrorFilename","kdebug.dbg") ); |
| 222 |
//pErrorShow->setText( pConfig->readEntry( "ErrorShow" ) ); |
| 223 |
pFatalCombo->setCurrentItem( pConfig->readNumEntry( "FatalOutput", 2 ) ); |
| 224 |
pFatalFile->setText( pConfig->readPathEntry("FatalFilename","kdebug.dbg") ); |
| 225 |
//pFatalShow->setText( pConfig->readEntry( "FatalShow" ) ); |
| 226 |
pAbortFatal->setChecked( pConfig->readNumEntry( "AbortFatal", 1 ) ); |
| 227 |
slotDestinationChanged(0); |
| 228 |
} |
| 229 |
|
| 230 |
void TDEDebugDialog::save() |
| 231 |
{ |
| 232 |
pConfig->writeEntry( "InfoOutput", pInfoCombo->currentItem() ); |
| 233 |
pConfig->writePathEntry( "InfoFilename", pInfoFile->text() ); |
| 234 |
//pConfig->writeEntry( "InfoShow", pInfoShow->text() ); |
| 235 |
pConfig->writeEntry( "WarnOutput", pWarnCombo->currentItem() ); |
| 236 |
pConfig->writePathEntry( "WarnFilename", pWarnFile->text() ); |
| 237 |
//pConfig->writeEntry( "WarnShow", pWarnShow->text() ); |
| 238 |
pConfig->writeEntry( "ErrorOutput", pErrorCombo->currentItem() ); |
| 239 |
pConfig->writePathEntry( "ErrorFilename", pErrorFile->text() ); |
| 240 |
//pConfig->writeEntry( "ErrorShow", pErrorShow->text() ); |
| 241 |
pConfig->writeEntry( "FatalOutput", pFatalCombo->currentItem() ); |
| 242 |
pConfig->writePathEntry( "FatalFilename", pFatalFile->text() ); |
| 243 |
//pConfig->writeEntry( "FatalShow", pFatalShow->text() ); |
| 244 |
pConfig->writeEntry( "AbortFatal", pAbortFatal->isChecked() ); |
| 245 |
|
| 246 |
TQByteArray data; |
| 247 |
if (!kapp->dcopClient()->send("*", "KDebug", "notifyKDebugConfigChanged()", data)) |
| 248 |
{ |
| 249 |
kdError() << "Unable to send DCOP message" << endl; |
| 250 |
} |
| 251 |
} |
| 252 |
|
| 253 |
void TDEDebugDialog::slotDestinationChanged(int) { |
| 254 |
pInfoFile->setEnabled(pInfoCombo->currentItem() == 0); |
| 255 |
pWarnFile->setEnabled(pWarnCombo->currentItem() == 0); |
| 256 |
pErrorFile->setEnabled(pErrorCombo->currentItem() == 0); |
| 257 |
pFatalFile->setEnabled(pFatalCombo->currentItem() == 0); |
| 258 |
} |
| 259 |
|
| 260 |
#include "tdedebugdialog.moc" |