diff options
author | Timothy Pearson <[email protected]> | 2013-05-09 14:17:33 -0500 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2013-05-09 14:17:33 -0500 |
commit | 77cbd6e9576edc206b1610ea9495e502a3639068 (patch) | |
tree | f1b52c360ea4af6903632bc0169230352ffa0012 | |
parent | f08ddb4652c6658ce3ad294509e101da468c1af6 (diff) | |
download | tdebase-77cbd6e9576edc206b1610ea9495e502a3639068.tar.gz tdebase-77cbd6e9576edc206b1610ea9495e502a3639068.zip |
Fix theme manager overwriting undefined theme settings with garbage
This resolves Bug 1174
Fix tderandrtray displaying profile list when only the default profile is available
-rw-r--r-- | kcontrol/kthememanager/ktheme.cpp | 85 | ||||
-rw-r--r-- | kcontrol/randr/tderandrtray.cpp | 12 |
2 files changed, 50 insertions, 47 deletions
diff --git a/kcontrol/kthememanager/ktheme.cpp b/kcontrol/kthememanager/ktheme.cpp index d5a593727..0dcee8105 100644 --- a/kcontrol/kthememanager/ktheme.cpp +++ b/kcontrol/kthememanager/ktheme.cpp @@ -410,20 +410,19 @@ void KTheme::apply() desktopConf.writeEntry( "DeskNum", desktopElem.attribute( "number", "0" ).toUInt() ); desktopConf.setGroup( TQString( "Desktop%1" ).arg( i ) ); - desktopConf.writeEntry( "BackgroundMode", getProperty( desktopElem, "mode", "id" ) ); - desktopConf.writeEntry( "Color1", TQColor( getProperty( desktopElem, "color1", "rgb" ) ) ); - desktopConf.writeEntry( "Color2", TQColor( getProperty( desktopElem, "color2", "rgb" ) ) ); - desktopConf.writeEntry( "BlendMode", getProperty( desktopElem, "blending", "mode" ) ); - desktopConf.writeEntry( "BlendBalance", getProperty( desktopElem, "blending", "balance" ) ); - desktopConf.writeEntry( "ReverseBlending", - static_cast<bool>( getProperty( desktopElem, "blending", "reverse" ).toUInt() ) ); - desktopConf.writeEntry( "Pattern", getProperty( desktopElem, "pattern", "name" ) ); - desktopConf.writeEntry( "Wallpaper", - unprocessFilePath( "desktop", getProperty( desktopElem, "wallpaper", "url" ) ) ); - desktopConf.writeEntry( "WallpaperMode", getProperty( desktopElem, "wallpaper", "mode" ) ); - - if ( common ) + if (getProperty( desktopElem, "mode", "id" ) != TQString::null) desktopConf.writeEntry( "BackgroundMode", getProperty( desktopElem, "mode", "id" ) ); + if (getProperty( desktopElem, "color1", "rgb" ) != TQString::null) desktopConf.writeEntry( "Color1", TQColor( getProperty( desktopElem, "color1", "rgb" ) ) ); + if (getProperty( desktopElem, "color2", "rgb" ) != TQString::null) desktopConf.writeEntry( "Color2", TQColor( getProperty( desktopElem, "color2", "rgb" ) ) ); + if (getProperty( desktopElem, "blending", "mode" ) != TQString::null) desktopConf.writeEntry( "BlendMode", getProperty( desktopElem, "blending", "mode" ) ); + if (getProperty( desktopElem, "blending", "balance" ) != TQString::null) desktopConf.writeEntry( "BlendBalance", getProperty( desktopElem, "blending", "balance" ) ); + if (getProperty( desktopElem, "blending", "reverse" ) != TQString::null) desktopConf.writeEntry( "ReverseBlending", static_cast<bool>( getProperty( desktopElem, "blending", "reverse" ).toUInt() ) ); + if (getProperty( desktopElem, "pattern", "name" ) != TQString::null) desktopConf.writeEntry( "Pattern", getProperty( desktopElem, "pattern", "name" ) ); + if (getProperty( desktopElem, "wallpaper", "url" ) != TQString::null) desktopConf.writeEntry( "Wallpaper", unprocessFilePath( "desktop", getProperty( desktopElem, "wallpaper", "url" ) ) ); + if (getProperty( desktopElem, "wallpaper", "mode" ) != TQString::null) desktopConf.writeEntry( "WallpaperMode", getProperty( desktopElem, "wallpaper", "mode" ) ); + + if ( common ) { break; // stop here + } } } @@ -439,8 +438,9 @@ void KTheme::apply() desktopConf.sync(); // TODO sync and signal only if <desktop> elem present // reconfigure kdesktop. kdesktop will notify all clients DCOPClient *client = kapp->dcopClient(); - if ( !client->isAttached() ) + if ( !client->isAttached() ) { client->attach(); + } client->send("kdesktop", "KBackgroundIface", "configure()", TQString("")); // FIXME Xinerama @@ -457,29 +457,36 @@ void KTheme::apply() { TQDomElement iconSubElem = iconList.item( i ).toElement(); TQString object = iconSubElem.attribute( "object" ); - if ( object == "desktop" ) + if ( object == "desktop" ) { iconConf->setGroup( "DesktopIcons" ); - else if ( object == "mainToolbar" ) + } + else if ( object == "mainToolbar" ) { iconConf->setGroup( "MainToolbarIcons" ); - else if ( object == "panel" ) + } + else if ( object == "panel" ) { iconConf->setGroup( "PanelIcons" ); - else if ( object == "small" ) + } + else if ( object == "small" ) { iconConf->setGroup( "SmallIcons" ); - else if ( object == "toolbar" ) + } + else if ( object == "toolbar" ) { iconConf->setGroup( "ToolbarIcons" ); + } TQString iconName = iconSubElem.tagName(); - if ( iconName.contains( "Color" ) ) - { + if ( iconName.contains( "Color" ) ) { TQColor iconColor = TQColor( iconSubElem.attribute( "rgb" ) ); iconConf->writeEntry( iconName, iconColor, true, true ); } - else if ( iconName.contains( "Value" ) || iconName == "Size" ) + else if ( iconName.contains( "Value" ) || iconName == "Size" ) { iconConf->writeEntry( iconName, iconSubElem.attribute( "value" ).toUInt(), true, true ); - else if ( iconName.contains( "Effect" ) ) + } + else if ( iconName.contains( "Effect" ) ) { iconConf->writeEntry( iconName, iconSubElem.attribute( "name" ), true, true ); - else + } + else { iconConf->writeEntry( iconName, static_cast<bool>( iconSubElem.attribute( "value" ).toUInt() ), true, true ); + } } iconConf->sync(); @@ -576,21 +583,22 @@ void KTheme::apply() TDEConfig twinConf( "twinrc" ); twinConf.setGroup( "Style" ); TQString type = wmElem.attribute( "type" ); - if ( type == "builtin" ) + if ( type == "builtin" ) { twinConf.writeEntry( "PluginLib", wmElem.attribute( "name" ) ); + } //else // TODO support custom themes TQDomNodeList buttons = wmElem.elementsByTagName ("buttons"); if ( buttons.count() > 0 ) { twinConf.writeEntry( "CustomButtonPositions", true ); - twinConf.writeEntry( "ButtonsOnLeft", getProperty( wmElem, "buttons", "left" ) ); - twinConf.writeEntry( "ButtonsOnRight", getProperty( wmElem, "buttons", "right" ) ); + if (getProperty( wmElem, "buttons", "left" ) != TQString::null) twinConf.writeEntry( "ButtonsOnLeft", getProperty( wmElem, "buttons", "left" ) ); + if (getProperty( wmElem, "buttons", "right" ) != TQString::null) twinConf.writeEntry( "ButtonsOnRight", getProperty( wmElem, "buttons", "right" ) ); } else { twinConf.writeEntry( "CustomButtonPositions", false ); } - twinConf.writeEntry( "BorderSize", getProperty( wmElem, "border", "size" ) ); + if (getProperty( wmElem, "border", "size" ) != TQString::null) twinConf.writeEntry( "BorderSize", getProperty( wmElem, "border", "size" ) ); twinConf.sync(); client->send( "twin", "", "reconfigure()", TQString("") ); @@ -603,8 +611,8 @@ void KTheme::apply() { TDEConfig konqConf( "konquerorrc" ); konqConf.setGroup( "Settings" ); - konqConf.writeEntry( "BgImage", unprocessFilePath( "konqueror", getProperty( konqElem, "wallpaper", "url" ) ) ); - konqConf.writeEntry( "BgColor", TQColor( getProperty( konqElem, "bgcolor", "rgb" ) ) ); + if (getProperty( konqElem, "wallpaper", "url" ) != TQString::null) konqConf.writeEntry( "BgImage", unprocessFilePath( "konqueror", getProperty( konqElem, "wallpaper", "url" ) ) ); + if (getProperty( konqElem, "bgcolor", "rgb" ) != TQString::null) konqConf.writeEntry( "BgColor", TQColor( getProperty( konqElem, "bgcolor", "rgb" ) ) ); konqConf.sync(); client->send("konqueror*", "KonquerorIface", "reparseConfiguration()", TQString("")); // FIXME seems not to work :( @@ -621,18 +629,13 @@ void KTheme::apply() if ( !kickerBgUrl.isEmpty() ) { kickerConf.writeEntry( "UseBackgroundTheme", true ); - kickerConf.writeEntry( "BackgroundTheme", unprocessFilePath( "panel", kickerBgUrl ) ); - kickerConf.writeEntry( "ColorizeBackground", - static_cast<bool>( getProperty( panelElem, "background", "colorize" ).toUInt() ) ); + if (getProperty( panelElem, "panel", kickerBgUrl ) != TQString::null) kickerConf.writeEntry( "BackgroundTheme", unprocessFilePath( "panel", kickerBgUrl ) ); + if (getProperty( panelElem, "background", "colorize" ) != TQString::null) kickerConf.writeEntry( "ColorizeBackground", static_cast<bool>( getProperty( panelElem, "background", "colorize" ).toUInt() ) ); } - kickerConf.writeEntry( "Transparent", - static_cast<bool>( getProperty( panelElem, "transparent", "value" ).toUInt() ) ); - - kickerConf.writeEntry( "Position", static_cast<int> (getProperty( panelElem, "position", "value" ).toUInt() )); - - kickerConf.writeEntry( "ShowLeftHideButton", static_cast<bool>( getProperty( panelElem, "showlefthidebutton", "value").toInt())); - - kickerConf.writeEntry( "ShowRightHideButton", static_cast<bool>( getProperty( panelElem, "showrighthidebutton", "value").toInt())); + if (getProperty( panelElem, "transparent", "value" ) != TQString::null) kickerConf.writeEntry( "Transparent", static_cast<bool>( getProperty( panelElem, "transparent", "value" ).toUInt() ) ); + if (getProperty( panelElem, "position", "value" ) != TQString::null) kickerConf.writeEntry( "Position", static_cast<int> (getProperty( panelElem, "position", "value" ).toUInt() )); + if (getProperty( panelElem, "showlefthidebutton", "value" ) != TQString::null) kickerConf.writeEntry( "ShowLeftHideButton", static_cast<bool>( getProperty( panelElem, "showlefthidebutton", "value").toInt())); + if (getProperty( panelElem, "showrighthidebutton", "value" ) != TQString::null) kickerConf.writeEntry( "ShowRightHideButton", static_cast<bool>( getProperty( panelElem, "showrighthidebutton", "value").toInt())); kickerConf.sync(); client->send("kicker", "Panel", "configure()", TQString("")); diff --git a/kcontrol/randr/tderandrtray.cpp b/kcontrol/randr/tderandrtray.cpp index 87346818c..4d998efd7 100644 --- a/kcontrol/randr/tderandrtray.cpp +++ b/kcontrol/randr/tderandrtray.cpp @@ -280,14 +280,14 @@ void KRandRSystemTray::contextMenuAboutToShow(TDEPopupMenu* menu) // Find any display profiles TQStringList displayProfiles; displayProfiles = getDisplayConfigurationProfiles(locateLocal("config", "/", true)); - if (displayProfiles.isEmpty() == false) { + if (!displayProfiles.isEmpty()) { menu->insertTitle(SmallIcon("background"), i18n("Display Profiles")); - } - lastIndex = menu->insertItem(SmallIcon("bookmark"), "<default>"); - menu->connectItem(lastIndex, this, TQT_SLOT(slotDisplayProfileChanged(int))); - for (TQStringList::Iterator t(displayProfiles.begin()); t != displayProfiles.end(); ++t) { - lastIndex = menu->insertItem(SmallIcon("bookmark"), *t); + lastIndex = menu->insertItem(SmallIcon("bookmark"), "<default>"); menu->connectItem(lastIndex, this, TQT_SLOT(slotDisplayProfileChanged(int))); + for (TQStringList::Iterator t(displayProfiles.begin()); t != displayProfiles.end(); ++t) { + lastIndex = menu->insertItem(SmallIcon("bookmark"), *t); + menu->connectItem(lastIndex, this, TQT_SLOT(slotDisplayProfileChanged(int))); + } } } |