3
* Copyright (c) 2000,2001 Carsten Pfeiffer <pfeiffer@kde.org>
4
* Copyright (c) 2002 Stephan Binner <binner@kde.org>
6
* based on kcmtaskbar.cpp
7
* Copyright (c) 2000 Kurt Granroth <granroth@kde.org>
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software
24
#include "kcmhistory.h"
27
#include <QtGui/QCheckBox>
28
#include <QtGui/QComboBox>
29
#include <QtGui/QLayout>
30
#include <QtGui/QPushButton>
31
#include <QtGui/QRadioButton>
34
#include <kapplication.h>
37
#include <kfontdialog.h>
41
#include <kmessagebox.h>
42
#include <knuminput.h>
43
#include <KPluginFactory>
44
#include <KPluginLoader>
46
#include <konq_historyprovider.h>
47
#include <konqhistorysettings.h>
51
K_PLUGIN_FACTORY(KCMHistoryFactory,
52
registerPlugin<HistorySidebarConfig>();
54
K_EXPORT_PLUGIN(KCMHistoryFactory("kcmhistory"))
56
HistorySidebarConfig::HistorySidebarConfig( QWidget *parent, const QVariantList & )
57
: KCModule (KCMHistoryFactory::componentData(), parent, QVariantList())
59
KGlobal::locale()->insertCatalog("konqueror");
61
m_settings = KonqHistorySettings::self();
63
if (!KParts::HistoryProvider::exists())
64
new KonqHistoryProvider(this);
66
QVBoxLayout *topLayout = new QVBoxLayout(this);
67
dialog = new KonqSidebarHistoryDlg(this);
69
dialog->spinEntries->setRange( 0, INT_MAX );
70
dialog->spinExpire->setRange( 0, INT_MAX );
71
dialog->spinExpire->setSuffix( ki18np(" day", " days") );
73
dialog->spinNewer->setRange( 0, INT_MAX );
74
dialog->spinOlder->setRange( 0, INT_MAX );
76
dialog->comboNewer->insertItem( KonqHistorySettings::MINUTES,
77
i18np("Minute", "Minutes", 0) );
78
dialog->comboNewer->insertItem( KonqHistorySettings::DAYS,
79
i18np("Day", "Days", 0) );
81
dialog->comboOlder->insertItem( KonqHistorySettings::MINUTES,
82
i18np("Minute", "Minutes", 0) );
83
dialog->comboOlder->insertItem( KonqHistorySettings::DAYS,
84
i18np("Day", "Days", 0) );
86
connect( dialog->cbExpire, SIGNAL( toggled( bool )),
87
dialog->spinExpire, SLOT( setEnabled( bool )));
88
connect( dialog->spinExpire, SIGNAL( valueChanged( int )),
89
this, SLOT( slotExpireChanged()));
91
connect( dialog->spinNewer, SIGNAL( valueChanged( int )),
92
SLOT( slotNewerChanged( int )));
93
connect( dialog->spinOlder, SIGNAL( valueChanged( int )),
94
SLOT( slotOlderChanged( int )));
96
connect( dialog->btnFontNewer, SIGNAL( clicked() ),
97
SLOT( slotGetFontNewer() ));
98
connect( dialog->btnFontOlder, SIGNAL( clicked() ),
99
SLOT( slotGetFontOlder() ));
100
connect( dialog->btnClearHistory, SIGNAL( clicked() ),
101
SLOT( slotClearHistory() ));
103
connect( dialog->cbDetailedTips, SIGNAL( toggled( bool )),
104
SLOT( configChanged() ));
105
connect( dialog->cbExpire, SIGNAL( toggled( bool )),
106
SLOT( configChanged() ));
107
connect( dialog->spinEntries, SIGNAL( valueChanged( int )),
108
SLOT( configChanged() ));
109
connect( dialog->comboNewer, SIGNAL( currentIndexChanged( int )),
110
SLOT( configChanged() ));
111
connect( dialog->comboOlder, SIGNAL( currentIndexChanged( int )),
112
SLOT( configChanged() ));
115
topLayout->addWidget(dialog);
119
void HistorySidebarConfig::configChanged()
124
void HistorySidebarConfig::load()
126
KConfig _config( "konquerorrc" );
127
KConfigGroup config(&_config, "HistorySettings");
128
dialog->spinExpire->setValue( config.readEntry( "Maximum age of History entries", 90) );
129
dialog->spinEntries->setValue( config.readEntry( "Maximum of History entries", 500 ) );
130
dialog->cbExpire->setChecked( dialog->spinExpire->value() > 0 );
132
dialog->spinNewer->setValue( m_settings->m_valueYoungerThan );
133
dialog->spinOlder->setValue( m_settings->m_valueOlderThan );
135
dialog->comboNewer->setCurrentIndex( m_settings->m_metricYoungerThan );
136
dialog->comboOlder->setCurrentIndex( m_settings->m_metricOlderThan );
138
dialog->cbDetailedTips->setChecked( m_settings->m_detailedTips );
140
m_fontNewer = m_settings->m_fontYoungerThan;
141
m_fontOlder = m_settings->m_fontOlderThan;
143
// enable/disable widgets
144
dialog->spinExpire->setEnabled( dialog->cbExpire->isChecked() );
147
slotNewerChanged( dialog->spinNewer->value() );
148
slotOlderChanged( dialog->spinOlder->value() );
153
void HistorySidebarConfig::save()
155
quint32 age = dialog->cbExpire->isChecked() ? dialog->spinExpire->value() : 0;
156
quint32 count = dialog->spinEntries->value();
158
KonqHistoryProvider::self()->emitSetMaxAge( age );
159
KonqHistoryProvider::self()->emitSetMaxCount( count );
161
m_settings->m_valueYoungerThan = dialog->spinNewer->value();
162
m_settings->m_valueOlderThan = dialog->spinOlder->value();
164
m_settings->m_metricYoungerThan = dialog->comboNewer->currentIndex();
165
m_settings->m_metricOlderThan = dialog->comboOlder->currentIndex();
167
m_settings->m_detailedTips = dialog->cbDetailedTips->isChecked();
169
m_settings->m_fontYoungerThan = m_fontNewer;
170
m_settings->m_fontOlderThan = m_fontOlder;
172
m_settings->applySettings();
177
void HistorySidebarConfig::defaults()
179
dialog->spinEntries->setValue( 500 );
180
dialog->cbExpire->setChecked( true );
181
dialog->spinExpire->setValue( 90 );
183
dialog->spinNewer->setValue( 1 );
184
dialog->spinOlder->setValue( 2 );
186
dialog->comboNewer->setCurrentIndex( KonqHistorySettings::DAYS );
187
dialog->comboOlder->setCurrentIndex( KonqHistorySettings::DAYS );
189
dialog->cbDetailedTips->setChecked( true );
191
m_fontNewer = QFont();
192
m_fontNewer.setItalic( true );
193
m_fontOlder = QFont();
196
QString HistorySidebarConfig::quickHelp() const
198
return i18n("<h1>History Sidebar</h1>"
199
" You can configure the history sidebar here.");
202
void HistorySidebarConfig::slotExpireChanged()
207
// change hour to days, minute to minutes and the other way round,
208
// depending on the value of the spinbox, and synchronize the two spinBoxes
209
// to enfore newer <= older.
210
void HistorySidebarConfig::slotNewerChanged( int value )
212
dialog->comboNewer->setItemText( KonqHistorySettings::DAYS,
213
i18np ( "Day", "Days", value) );
214
dialog->comboNewer->setItemText( KonqHistorySettings::MINUTES,
215
i18np ( "Minute", "Minutes", value) );
217
if ( dialog->spinNewer->value() > dialog->spinOlder->value() )
218
dialog->spinOlder->setValue( dialog->spinNewer->value() );
222
void HistorySidebarConfig::slotOlderChanged( int value )
224
dialog->comboOlder->setItemText( KonqHistorySettings::DAYS,
225
i18np ( "Day", "Days", value) );
226
dialog->comboOlder->setItemText( KonqHistorySettings::MINUTES,
227
i18np ( "Minute", "Minutes", value) );
229
if ( dialog->spinNewer->value() > dialog->spinOlder->value() )
230
dialog->spinNewer->setValue( dialog->spinOlder->value() );
235
void HistorySidebarConfig::slotGetFontNewer()
237
int result = KFontDialog::getFont( m_fontNewer, false, this );
238
if ( result == KFontDialog::Accepted )
242
void HistorySidebarConfig::slotGetFontOlder()
244
int result = KFontDialog::getFont( m_fontOlder, false, this );
245
if ( result == KFontDialog::Accepted )
249
void HistorySidebarConfig::slotClearHistory()
251
KGuiItem guiitem = KStandardGuiItem::clear();
252
guiitem.setIcon( KIcon("edit-clear-history"));
253
if ( KMessageBox::warningContinueCancel( this,
254
i18n("Do you really want to clear "
255
"the entire history?"),
256
i18n("Clear History?"), guiitem )
257
== KMessageBox::Continue ) {
258
KonqHistoryProvider::self()->emitClear();
262
#include "kcmhistory.moc"