/*************************************************************************** * Copyright (C) 2005 by Nicolas Ternisien * * nicolas.ternisien@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program 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 General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ksystemlogConfig.h" #include "generalOptions.h" GeneralOptions::GeneralOptions(TQWidget *parent) : TQWidget(parent) { TQVBoxLayout *layout = new TQVBoxLayout(this); layout->setSpacing(10); //Maximum Lines TQVGroupBox* logLinesBox=new TQVGroupBox(i18n("Log Lines List"), this); new TQLabel(i18n("Maximum lines displayed:"), logLinesBox); maxLines=new TQSpinBox(10, 30000, 10, logLinesBox); connect(maxLines, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(onOptionsChanged())); TQToolTip::add(maxLines, i18n("Choose here the maximum number of log lines displayed in the main view.")); TQWhatsThis::add(maxLines, i18n("You can choose here the maximum number of log lines displayed in the main view.")); deleteDuplicatedLines=new TQCheckBox(i18n("Delete duplicated log lines (may be slow)"), logLinesBox); connect(deleteDuplicatedLines, TQ_SIGNAL(clicked()), this, TQ_SLOT(onOptionsChanged())); TQToolTip::add(deleteDuplicatedLines, i18n("Select this option if you want to delete duplicated log lines (may be slow).")); TQWhatsThis::add(deleteDuplicatedLines, i18n("You can select this option if you want to delete duplicated log lines. This option can slow the reading.")); //Maximum Characters per line TQVGroupBox* maxCharBox=new TQVGroupBox(i18n("Maximum Characters to Read per Line"), this); new TQLabel(i18n("Number of characters:"), maxCharBox); maxCharacters=new TQSpinBox(10, 30000, 10, maxCharBox); connect(maxCharacters, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(onOptionsChanged())); TQToolTip::add(maxCharacters, i18n("Choose here the maximum number of characters to read from each log line.")); TQWhatsThis::add(maxCharacters, i18n("You can choose here the maximum number of characters to read from each log line.")); TQVGroupBox* options= new TQVGroupBox( i18n( "Options" ), this ); deleteProcessId=new TQCheckBox(i18n("Delete process identifier from process name"), options); connect(deleteProcessId, TQ_SIGNAL(clicked()), this, TQ_SLOT(onOptionsChanged())); TQToolTip::add(deleteProcessId, i18n("Delete process identifier from process name.")); TQWhatsThis::add(deleteProcessId, i18n("You can select this option if you want to delete the process identifier from process name. For example, you will sometimes see in the Process column something like cron[3433]. If this option is activated, the annoying bold part will be erased.")); colorizeLogLines=new TQCheckBox(i18n("Colorize log lines"), options); connect(colorizeLogLines, TQ_SIGNAL(clicked()), this, TQ_SLOT(onOptionsChanged())); TQToolTip::add(colorizeLogLines, i18n("This option allows the colorization of log lines, depending on their log level.")); TQWhatsThis::add(colorizeLogLines, i18n("This option allows the colorization of log lines, depending on their log level. For example, an error will be in red, a warning in orange... This will help you to better see problems.")); TQSpacerItem* spacer=new TQSpacerItem(0, 0, TQSizePolicy::Preferred, TQSizePolicy::Expanding); layout->addWidget(logLinesBox); layout->addWidget(maxCharBox); layout->addWidget(options); layout->addItem(spacer); readConfig(); } void GeneralOptions::readConfig() { int value; value=KSystemLogConfig::maxLines(); maxLines->setValue(value); value=KSystemLogConfig::maxReadCharacters(); maxCharacters->setValue(value); bool option=KSystemLogConfig::deleteDuplicatedLines(); deleteDuplicatedLines->setChecked(option); option=KSystemLogConfig::deleteProcessIdentifier(); deleteProcessId->setChecked(option); option=KSystemLogConfig::colorizeLogLines(); colorizeLogLines->setChecked(option); } void GeneralOptions::saveConfig() { kdDebug() << "Save config from General preferences" << endl; KSystemLogConfig::setMaxLines(maxLines->value()); KSystemLogConfig::setMaxReadCharacters(maxCharacters->value()); KSystemLogConfig::setDeleteDuplicatedLines(deleteDuplicatedLines->isChecked()); KSystemLogConfig::setDeleteProcessIdentifier(deleteProcessId->isChecked()); KSystemLogConfig::setColorizeLogLines(colorizeLogLines->isChecked()); } bool GeneralOptions::isValid() { return(maxLines->value()>0 && maxCharacters->value()>0); } void GeneralOptions::onOptionsChanged() { emit optionsChanged(true); } #include "generalOptions.moc"