From 4aed2c8219774f5d797760606b8489a92ddc5163 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- .../trees/history_module/history_settings.cpp | 111 +++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 konqueror/sidebar/trees/history_module/history_settings.cpp (limited to 'konqueror/sidebar/trees/history_module/history_settings.cpp') diff --git a/konqueror/sidebar/trees/history_module/history_settings.cpp b/konqueror/sidebar/trees/history_module/history_settings.cpp new file mode 100644 index 000000000..ed8bc7756 --- /dev/null +++ b/konqueror/sidebar/trees/history_module/history_settings.cpp @@ -0,0 +1,111 @@ + +#include +#include +#include +#include + +#include "history_settings.h" + +KonqSidebarHistorySettings::KonqSidebarHistorySettings( QObject *parent, const char *name ) + : QObject( parent, name ), + DCOPObject( "KonqSidebarHistorySettings" ) +{ + m_fontOlderThan.setItalic( true ); // default +} + +KonqSidebarHistorySettings::KonqSidebarHistorySettings() + : QObject(), + DCOPObject( "KonqSidebarHistorySettings" ) +{ + m_fontOlderThan.setItalic( true ); // default +} + +KonqSidebarHistorySettings::KonqSidebarHistorySettings( const KonqSidebarHistorySettings& s ) + : QObject(), + DCOPObject( "KonqSidebarHistorySettings" ) +{ + m_valueYoungerThan = s.m_valueYoungerThan; + m_valueOlderThan = s.m_valueOlderThan; + + m_metricYoungerThan = s.m_metricYoungerThan; + m_metricOlderThan = s.m_metricOlderThan; + + m_detailedTips = s.m_detailedTips; + + m_fontYoungerThan = s.m_fontYoungerThan; + m_fontOlderThan = s.m_fontOlderThan; +} + +KonqSidebarHistorySettings::~KonqSidebarHistorySettings() +{ +} + +void KonqSidebarHistorySettings::readSettings(bool global) +{ + KConfig *config; + QString oldgroup; + + if (global) { + config = KGlobal::config(); + oldgroup= config->group(); + } + else + config = new KConfig("konquerorrc"); + + config->setGroup("HistorySettings"); + m_valueYoungerThan = config->readNumEntry("Value youngerThan", 1 ); + m_valueOlderThan = config->readNumEntry("Value olderThan", 2 ); + + QString minutes = QString::fromLatin1("minutes"); + QString days = QString::fromLatin1("days"); + QString metric = config->readEntry("Metric youngerThan", days ); + m_metricYoungerThan = (metric == days) ? DAYS : MINUTES; + metric = config->readEntry("Metric olderThan", days ); + m_metricOlderThan = (metric == days) ? DAYS : MINUTES; + + m_detailedTips = config->readBoolEntry("Detailed Tooltips", true); + + m_fontYoungerThan = config->readFontEntry( "Font youngerThan", + &m_fontYoungerThan ); + m_fontOlderThan = config->readFontEntry( "Font olderThan", + &m_fontOlderThan ); + if (global) + config->setGroup( oldgroup ); + else + delete config; +} + +void KonqSidebarHistorySettings::applySettings() +{ + KConfig *config = new KConfig("konquerorrc"); + config->setGroup("HistorySettings"); + + config->writeEntry("Value youngerThan", m_valueYoungerThan ); + config->writeEntry("Value olderThan", m_valueOlderThan ); + + QString minutes = QString::fromLatin1("minutes"); + QString days = QString::fromLatin1("days"); + config->writeEntry("Metric youngerThan", m_metricYoungerThan == DAYS ? + days : minutes ); + config->writeEntry("Metric olderThan", m_metricOlderThan == DAYS ? + days : minutes ); + + config->writeEntry("Detailed Tooltips", m_detailedTips); + + config->writeEntry("Font youngerThan", m_fontYoungerThan ); + config->writeEntry("Font olderThan", m_fontOlderThan ); + + delete config; + + // notify konqueror instances about the new configuration + kapp->dcopClient()->send( "konqueror*", "KonqSidebarHistorySettings", + "notifySettingsChanged()", QByteArray() ); +} + +void KonqSidebarHistorySettings::notifySettingsChanged() +{ + readSettings(false); + emit settingsChanged(); +} + +#include "history_settings.moc" -- cgit v1.2.3