[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/plasma/applets/toggle-compositing
From: Martin Gräßlin <ubuntu () martin-graesslin ! com>
Date: 2009-04-18 10:23:25
Message-ID: 1240050205.503237.2636.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 955641 by graesslin:
Offer an update compositing state to context menu. That's a workaround as we don't \
receive the signal when kwin's config is changed, so we don't catch the (unlikely) \
case that compositing was disabled in settings and is enabled, now.
M +32 -8 toggle_compositing.cpp
M +2 -1 toggle_compositing.hpp
--- trunk/playground/base/plasma/applets/toggle-compositing/toggle_compositing.cpp \
#955640:955641 @@ -75,7 +75,12 @@
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->addItem(m_icon);
- readState();
+ m_disabled = !readEnabledState();
+
+ if( !m_disabled && m_kwinInterface->compositingActive() )
+ m_state = true;
+ else
+ m_state = false;
updateIcon();
}
@@ -84,6 +89,9 @@
QAction* configureEffects = new QAction( SmallIcon("configure"), \
i18n("&Configure Desktop Effects..."), this ); m_actions.append( configureEffects );
connect( configureEffects, SIGNAL(triggered(bool)), this, \
SLOT(configureCompositing())); + QAction* updateState = new QAction( \
SmallIcon("view-refresh"), i18n("&Update Compositing State"), this ); + \
m_actions.append( updateState ); + connect( updateState, SIGNAL(triggered(bool)), \
this, SLOT(updateState())); }
QList<QAction*> ToggleCompositing::contextualActions()
@@ -97,18 +105,33 @@
KToolInvocation::startServiceByDesktopName( "kwincompositing", QStringList(), \
&error ); }
-void ToggleCompositing::readState()
+bool ToggleCompositing::readEnabledState()
{
- // TODO: we have to read the state whenever kwin config is changed
+ // TODO: we don't get the signal when config is changed, so we cannot react
KSharedConfigPtr mKWinConfig=KSharedConfig::openConfig("kwinrc");
KConfigGroup config(mKWinConfig, "Compositing");
// TODO: compositing prefs
- m_disabled = !config.readEntry("Enabled", true);
+ return config.readEntry("Enabled", true);
+ }
- if( !m_disabled && m_kwinInterface->compositingActive() )
- m_state = true;
- else
- m_state = false;
+void ToggleCompositing::updateState()
+ {
+ bool state = !readEnabledState();
+ if( state != m_disabled )
+ {
+ m_disabled = state;
+ if( m_disabled)
+ {
+ // was active - now disabled
+ m_state = false;
+ }
+ else
+ {
+ // it was disabled before, so read state from dbus
+ m_state = m_kwinInterface->compositingActive();
+ }
+ updateIcon();
+ }
}
void ToggleCompositing::compositingToggled( bool active )
@@ -132,6 +155,7 @@
{
// Compositing is disabled in settings
data.setSubText( i18n("Compositing is disabled in settings") );
+ m_icon->setIcon( KIcon( "dialog-cancel" ) );
}
else
{
--- trunk/playground/base/plasma/applets/toggle-compositing/toggle_compositing.hpp \
#955640:955641 @@ -56,12 +56,13 @@
private slots:
void compositingToggled( bool active );
+ void updateState();
void clicked();
void updateIcon();
void configureCompositing();
private:
- void readState(void);
+ bool readEnabledState();
bool m_state;
bool m_disabled;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic