From 56e84d9ab2061588e46dd2448c1fb420d0eafe10 Mon Sep 17 00:00:00 2001 From: Mavridis Philippe Date: Fri, 24 Dec 2021 12:55:58 +0200 Subject: Move useIconTheme DCOP call into kcmweatherservice. This is where it belongs, and thus it can be used by both the applet and sidebar. Signed-off-by: Mavridis Philippe --- kweather/kcmweatherservice.cpp | 17 +++++++++++++++-- kweather/kcmweatherservice.h | 3 +++ kweather/kweather.cpp | 16 ---------------- kweather/kweather.h | 2 -- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/kweather/kcmweatherservice.cpp b/kweather/kcmweatherservice.cpp index cf0828c..4e5c7a7 100644 --- a/kweather/kcmweatherservice.cpp +++ b/kweather/kcmweatherservice.cpp @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include "dockwidget.h" #include "serviceconfig.h" @@ -101,7 +103,8 @@ void KCMWeatherService::load() mWidget->m_logFile->setURL( config.readPathEntry( "log_file_name" ) ); - mWidget->m_iconTheme->setButton( config.readBoolEntry("use_icon_theme", true) ? 0 : 1 ); + mUseIconTheme = config.readBoolEntry("use_icon_theme", true); + mWidget->m_iconTheme->setButton( mUseIconTheme ? 0 : 1 ); emit changed( false ); } @@ -115,7 +118,9 @@ void KCMWeatherService::save() config.writeEntry( "logging", mWidget->m_enableLog->isChecked() ); config.writeEntry( "log_file_name", mWidget->m_logFile->url() ); - config.writeEntry( "use_icon_theme", mWidget->m_iconTheme->selectedId() == 0 ); + mUseIconTheme = (mWidget->m_iconTheme->selectedId() == 0); + config.writeEntry( "use_icon_theme", mUseIconTheme ); + updateIconTheme(mUseIconTheme); config.sync(); @@ -133,4 +138,12 @@ void KCMWeatherService::defaults() emit changed( true ); } +void KCMWeatherService::updateIconTheme( bool useIconTheme ) +{ + DCOPRef ws( "KWeatherService", "WeatherService" ); + DCOPReply reply = ws.call( "useIconTheme", useIconTheme ); + if( ! reply.isValid() ) + kdDebug(12004) << "[kcmweatherservice::updateIconTheme] DCOP call failed" << endl; +} + #include "kcmweatherservice.moc" diff --git a/kweather/kcmweatherservice.h b/kweather/kcmweatherservice.h index 9e61e86..d6dee62 100644 --- a/kweather/kcmweatherservice.h +++ b/kweather/kcmweatherservice.h @@ -46,6 +46,9 @@ class KCMWeatherService : public TDECModule serviceConfig *mWidget; WeatherService_stub *mWeatherService; int mViewMode; + bool mUseIconTheme; + + void updateIconTheme( bool useIconTheme ); }; #endif \ No newline at end of file diff --git a/kweather/kweather.cpp b/kweather/kweather.cpp index 76ffb48..1edc9cd 100644 --- a/kweather/kweather.cpp +++ b/kweather/kweather.cpp @@ -217,7 +217,6 @@ void kweather::loadPrefs(){ fileName = kcConfig->readPathEntry("log_file_name"); reportLocation = kcConfig->readEntry("report_location"); mViewMode = kcConfig->readNumEntry("smallview_mode", dockwidget::ShowAll); - setUseIconTheme(kcConfig->readBoolEntry("use_icon_theme", true)); static TQColor black(TQt::black); mTextColor = kcConfig->readColorEntry("textColor", &black); @@ -233,23 +232,9 @@ void kweather::savePrefs(){ kcConfig->writeEntry("report_location", reportLocation); kcConfig->writeEntry("smallview_mode", mViewMode); kcConfig->writePathEntry("log_file_name", fileName ); - kcConfig->writeEntry("use_icon_theme", useIconTheme ); kcConfig->sync(); } -void kweather::setUseIconTheme( bool use ) -{ - useIconTheme = use; - - if ( !mWeatherService ) - initDCOP(); - - DCOPRef ws( "KWeatherService", "WeatherService" ); - DCOPReply reply = ws.call( "useIconTheme", useIconTheme ); - if( ! reply.isValid() ) - kdDebug() << "[kweather::setUseIconTheme] DCOP call failed" << endl; -} - void kweather::showWeather() { kdDebug(12004) << "Show weather" << endl; @@ -349,7 +334,6 @@ void kweather::slotPrefsAccepted() dockWidget->setLocationCode(reportLocation); dockWidget->setViewMode(mViewMode); - setUseIconTheme(useIconTheme); if ( !mWeatherService ) initDCOP(); mWeatherService->forceUpdateAll(); diff --git a/kweather/kweather.h b/kweather/kweather.h index c8b7113..28c4e25 100644 --- a/kweather/kweather.h +++ b/kweather/kweather.h @@ -68,7 +68,6 @@ private: // Private methods void showWeather(); void writeLogEntry(); void mousePressEvent(TQMouseEvent *e); - void setUseIconTheme(bool use); bool attach(); @@ -76,7 +75,6 @@ private: // Private methods TQString fileName; TQString metarData; bool logOn; - bool useIconTheme; bool mFirstRun; int mViewMode; TQTimer *timeOut; -- cgit v1.2.1