File indexing completed on 2024-04-28 04:02:32
0001 /*************************************************************************** 0002 dlgtranscript.cpp - Session Transcript dialog 0003 This file is a part of KMuddy distribution. 0004 ------------------- 0005 begin : Pá nov 1 2002 0006 copyright : (C) 2002 by Tomas Mecir 0007 email : kmuddy@kmuddy.com 0008 ***************************************************************************/ 0009 0010 /*************************************************************************** 0011 * * 0012 * This program is free software; you can redistribute it and/or modify * 0013 * it under the terms of the GNU General Public License as published by * 0014 * the Free Software Foundation; either version 2 of the License, or * 0015 * (at your option) any later version. * 0016 * * 0017 ***************************************************************************/ 0018 0019 #include "dlgtranscript.h" 0020 0021 #include <qcheckbox.h> 0022 #include <qcombobox.h> 0023 0024 #include <qlabel.h> 0025 #include <qpushbutton.h> 0026 #include <qgroupbox.h> 0027 #include <QHBoxLayout> 0028 #include <QVBoxLayout> 0029 #include <QFileDialog> 0030 #include <QLineEdit> 0031 0032 #include <KLocalizedString> 0033 0034 dlgTranscript::dlgTranscript (QWidget *parent) : 0035 KPageDialog (parent) 0036 { 0037 //initial dialog size 0038 setWindowTitle (i18n ("Session Transcript")); 0039 setFaceType( KPageDialog::Tabbed ); 0040 setStandardButtons (QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Apply); 0041 0042 //create main dialog's widget 0043 QFrame *page = new QFrame (this); 0044 QFrame *advpage = new QFrame (this); 0045 addPage (page, i18n ("Basic")); 0046 addPage (advpage, i18n ("Advanced")); 0047 0048 QVBoxLayout *layout = new QVBoxLayout (page); 0049 QVBoxLayout *advlayout = new QVBoxLayout (advpage); 0050 0051 //setMainWidget (page); 0052 0053 //enable transcript checkbox 0054 enabletranscript = new QCheckBox (i18n ("&Enable basic transcript"), page); 0055 connect (enabletranscript, &QCheckBox::toggled, this, &dlgTranscript::updateDialog); 0056 enabletranscript->setWhatsThis( i18n ("Enables or disabled the session transcript. " 0057 "Note that session transcript is automatically disabled when you disconnect.")); 0058 0059 //transcript settings 0060 transbox = new QGroupBox (i18n ("Transcript settings"), page); 0061 QVBoxLayout *transboxlayout = new QVBoxLayout (transbox); 0062 0063 QFrame *typebox = new QFrame (transbox); 0064 QHBoxLayout *typeboxLayout = new QHBoxLayout (typebox); 0065 typeboxLayout->setSpacing (5); 0066 QLabel *lbltype = new QLabel (i18n ("Transcript &format"), typebox); 0067 ttype = new QComboBox (typebox); 0068 ttype->addItem ("HTML"); 0069 ttype->addItem ("Plain text"); 0070 ttype->addItem ("Text with ANSI colors"); 0071 lbltype->setBuddy (ttype); 0072 typeboxLayout->addWidget (lbltype); 0073 typeboxLayout->addWidget (ttype); 0074 0075 overwrite = new QCheckBox (i18n ("&Overwrite existing file"), transbox); 0076 overwrite->setWhatsThis( i18n ("If you enable this option, existing " 0077 "transcript file will be overwritten. Otherwise, new transcript will " 0078 "be appended to the end of an existing file (if it exists :)).")); 0079 includedump = new QCheckBox (i18n ("Include buffer &dump"), transbox); 0080 includedump->setWhatsThis( i18n ("This will cause KMuddy to add " 0081 "complete buffer dump to the beginning of the transcript file.")); 0082 0083 //the file name 0084 QFrame *fileframe = new QFrame (transbox); 0085 QVBoxLayout *filelayout = new QVBoxLayout (fileframe); 0086 lblname = new QLabel (i18n ("&File:"), fileframe); 0087 fname = new QLineEdit (fileframe); 0088 lblname->setBuddy (fname); 0089 filebutton = new QPushButton (i18n ("&Browse..."), fileframe); 0090 0091 filelayout->setSpacing (5); 0092 filelayout->addWidget (lblname); 0093 filelayout->addWidget (fname); 0094 filelayout->addWidget (filebutton); 0095 0096 //connect the Browse button! 0097 connect (filebutton, &QPushButton::clicked, this, &dlgTranscript::browseFiles); 0098 0099 transboxlayout->setSpacing (5); 0100 transboxlayout->addWidget (typebox); 0101 transboxlayout->addWidget (overwrite); 0102 transboxlayout->addWidget (includedump); 0103 transboxlayout->addWidget (fileframe); 0104 0105 layout->setSpacing (5); 0106 layout->addWidget (enabletranscript); 0107 layout->addWidget (transbox); 0108 0109 enableadvtranscript = new QCheckBox (i18n ("Enable &advanced transcript"), advpage); 0110 enableadvtranscript->setWhatsThis( i18n ("This will enable advanced transcript, " 0111 "which allows you to have transcript running all the time, rotates it at " 0112 "midnight and so. Note that normal and advanced transcripts can both be " 0113 "running at the same time, if you want.")); 0114 connect (enableadvtranscript, &QCheckBox::toggled, this, &dlgTranscript::updateAdvDialog); 0115 advtrans = new QGroupBox(i18n ("Advanced transcript settings"), advpage); 0116 QVBoxLayout *advtranslayout = new QVBoxLayout (advtrans); 0117 0118 QFrame *advtypebox = new QFrame (advtrans); 0119 QHBoxLayout *advtypeboxlayout = new QHBoxLayout (advtypebox); 0120 advtypeboxlayout->setSpacing (5); 0121 QLabel *lbladvtype = new QLabel (i18n ("Transcript &format"), advtypebox); 0122 advttype = new QComboBox (advtypebox); 0123 advttype->addItem ("HTML"); 0124 advttype->addItem ("Plain text"); 0125 advttype->addItem ("Text with ANSI colors"); 0126 lbladvtype->setBuddy (advttype); 0127 advtypeboxlayout->addWidget (lbladvtype); 0128 advtypeboxlayout->addWidget (advttype); 0129 0130 rotatedaily = new QCheckBox (i18n ("&Rotate log at midnight every day"), advtrans); 0131 rotatedaily->setWhatsThis( i18n ("This will cause KMuddy to rotate session transcript " 0132 "every day at midnight")); 0133 0134 includetimestamp = new QCheckBox (i18n ("Prepend lines with ×tamp"), advtrans); 0135 includetimestamp->setWhatsThis( i18n ("This option will cause KMuddy to insert local " 0136 "timestamp in front of every line of logging")); 0137 0138 QFrame *afileframe = new QFrame (advtrans); 0139 QHBoxLayout *afilelayout = new QHBoxLayout (afileframe); 0140 0141 QLabel *logformat = new QLabel (i18n ("Log name format"), afileframe); 0142 logformat->setWhatsThis( i18n ("Here you can specify log format. You can use the following " 0143 "options: $W - world name, $h - hour, $m - minute, $D - day, $M - month, $Y - year, and " 0144 "any combination of alpha-numeric characters.")); 0145 0146 afname = new QLineEdit (afileframe); 0147 logformat->setBuddy(afname); 0148 0149 afilelayout->setSpacing (5); 0150 afilelayout->addWidget (logformat); 0151 afilelayout->addWidget (afname); 0152 0153 advtranslayout->addWidget (advtypebox); 0154 advtranslayout->addWidget (rotatedaily); 0155 advtranslayout->addWidget (includetimestamp); 0156 advtranslayout->addWidget (afileframe); 0157 0158 advlayout->addWidget (enableadvtranscript); 0159 advlayout->addWidget (advtrans); 0160 0161 //initial dialog settings... 0162 enabletranscript->setChecked (false); 0163 enableadvtranscript->setChecked (false); 0164 ttype->setCurrentIndex (0); 0165 advttype->setCurrentIndex (0); 0166 updateDialog (false); 0167 updateAdvDialog (false); 0168 } 0169 0170 dlgTranscript::~dlgTranscript () 0171 { 0172 0173 } 0174 0175 QSize dlgTranscript::sizeHint() const 0176 { 0177 return QSize (400, 200); 0178 } 0179 0180 void dlgTranscript::updateDialog (bool how) 0181 { 0182 overwrite->setEnabled (how); 0183 fname->setEnabled (how); 0184 transbox->setEnabled (how); 0185 lblname->setEnabled (how); 0186 filebutton->setEnabled (how); 0187 ttype->setEnabled (how); 0188 } 0189 0190 void dlgTranscript::updateAdvDialog (bool how) 0191 { 0192 rotatedaily->setEnabled(how); 0193 includetimestamp->setEnabled(how); 0194 advtrans->setEnabled(how); 0195 afname->setEnabled(how); 0196 advttype->setEnabled (how); 0197 } 0198 0199 void dlgTranscript::browseFiles () 0200 { 0201 fname->setText (QFileDialog::getSaveFileName ()); 0202 } 0203 0204 QString dlgTranscript::getFName () 0205 { 0206 return fname->text (); 0207 } 0208 0209 QString dlgTranscript::getAFName () 0210 { 0211 return afname->text (); 0212 } 0213 0214 void dlgTranscript::setFName (const QString &filename) 0215 { 0216 fname->setText (filename); 0217 } 0218 0219 void dlgTranscript::setAFName (const QString &filename) 0220 { 0221 afname->setText (filename); 0222 } 0223 0224 bool dlgTranscript::isEnabled () 0225 { 0226 return enabletranscript->isChecked (); 0227 } 0228 0229 void dlgTranscript::setEnabled (bool val) 0230 { 0231 enabletranscript->setChecked (val); 0232 } 0233 0234 bool dlgTranscript::isOverwrite () 0235 { 0236 return overwrite->isChecked (); 0237 } 0238 0239 void dlgTranscript::setOverwrite (bool val) 0240 { 0241 overwrite->setChecked (val); 0242 } 0243 0244 bool dlgTranscript::includeDump () 0245 { 0246 return includedump->isChecked (); 0247 } 0248 0249 void dlgTranscript::setIncludeDump (bool val) 0250 { 0251 includedump->setChecked (val); 0252 } 0253 0254 void dlgTranscript::setAdvTranscript(bool val) 0255 { 0256 enableadvtranscript->setChecked(val); 0257 } 0258 0259 bool dlgTranscript::advTranscript() 0260 { 0261 return enableadvtranscript->isChecked(); 0262 } 0263 0264 void dlgTranscript::setRotateDaily(bool val) 0265 { 0266 rotatedaily->setChecked(val); 0267 } 0268 0269 bool dlgTranscript::rotateDaily() 0270 { 0271 return rotatedaily->isChecked(); 0272 } 0273 0274 void dlgTranscript::setIncludeTimestamp(bool val) 0275 { 0276 includetimestamp->setChecked(val); 0277 } 0278 0279 bool dlgTranscript::includeTimestamp() 0280 { 0281 return includetimestamp->isChecked(); 0282 } 0283 0284 void dlgTranscript::setTranscriptType (char type) 0285 { 0286 ttype->setCurrentIndex (type - 1); 0287 } 0288 0289 char dlgTranscript::transcriptType () 0290 { 0291 return ttype->currentIndex() + 1; 0292 } 0293 0294 void dlgTranscript::setAdvTranscriptType (char type) 0295 { 0296 advttype->setCurrentIndex (type - 1); 0297 } 0298 0299 char dlgTranscript::advTranscriptType () 0300 { 0301 return advttype->currentIndex() + 1; 0302 } 0303 0304 #include "moc_dlgtranscript.cpp"