summaryrefslogtreecommitdiffstats
path: root/ksystemlog/src/generalOptions.cpp
blob: 9f6f642ec9ce5bbb5ca7119c8246c989d59a729b (plain)
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
/***************************************************************************
 *   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 <tqlayout.h>
#include <tqlabel.h>
#include <tqvgroupbox.h>
#include <tqbutton.h>
#include <tqradiobutton.h>
#include <tqwhatsthis.h>
#include <tqtooltip.h>

#include <tdelocale.h>
#include <kdialogbase.h>
#include <kiconloader.h>
#include <tdeapplication.h>
#include <kstandarddirs.h>
#include <kdebug.h>

#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("<qt>Choose here the maximum number of log lines displayed in the main view.</qt>"));
	TQWhatsThis::add(maxLines, i18n("<qt>You can choose here the maximum number of log lines displayed in the main view.</qt>"));

	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("<qt>Select this option if you want to delete duplicated log lines <b>(may be slow)</b>.</qt>"));
	TQWhatsThis::add(deleteDuplicatedLines, i18n("<qt>You can select this option if you want to delete duplicated log lines. <b>This option can slow the reading</b>.</qt>"));


	
	//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("<qt>Choose here the maximum number of characters to read from each log line.</qt>"));
	TQWhatsThis::add(maxCharacters, i18n("<qt>You can choose here the maximum number of characters to read from each log line.</qt>")); 
	

	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("<qt>Delete process identifier from process name.</qt>"));
	TQWhatsThis::add(deleteProcessId, i18n("<qt>You can select this option if you want to delete the process identifier from process name. For example, you will sometimes see in the <b>Process</b> column something like <i>cron<b>[3433]</b></i>. If this option is activated, the annoying bold part will be erased.</qt>"));

	colorizeLogLines=new TQCheckBox(i18n("Colorize log lines"), options);
	connect(colorizeLogLines, TQ_SIGNAL(clicked()), this, TQ_SLOT(onOptionsChanged()));
	
	TQToolTip::add(colorizeLogLines, i18n("<qt>This option allows the colorization of log lines, depending on their log level.</qt>"));
	TQWhatsThis::add(colorizeLogLines, i18n("<qt>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.</qt>"));
	
	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"