Репозиторий ALT Linux backports/2.4
Последнее обновление: 9 июля 2008 | Пакетов: 497 | Посещений: 1652626
 поиск   регистрация   авторизация 
 
Группа :: Графические оболочки/KDE
Пакет: kdebase

 Главная   Изменения   Спек   Патчи   Загрузить   Bugs and FR 

Патч: kdebase-3.3.1-panel-icons-scale-alt.patch


--- kdebase-3.3.1/kicker/buttons/panelbuttonbase.cpp.scale	2004-09-30 13:53:47 +0400
+++ kdebase-3.3.1/kicker/buttons/panelbuttonbase.cpp	2004-11-30 15:12:57 +0300
@@ -42,6 +42,16 @@ CONNECTION WITH THE SOFTWARE OR THE USE 
 #include "panelbuttonbase.moc"
 #include "kicker.h"
 
+bool scale_panel_icons = false;
+
+static QPixmap iconResize(QPixmap pix, int to_size)
+{
+    QImage tmp = pix.convertToImage();
+    tmp = tmp.smoothScale(to_size, to_size);
+    pix.convertFromImage(tmp);
+    return pix;
+}
+
 namespace {
     ZoomButton* zoomButton = 0;
     int zoomDisabled = 0;
@@ -176,6 +186,9 @@ int PanelButtonBase::preferredDimension(
 //      (false if we don't know, because theme couldn't be loaded?)
 bool PanelButtonBase::calculateIconSizes()
 {
+     KConfigGroup config( KGlobal::config(), "buttons" );
+     scale_panel_icons = config.readBoolEntry( "ScaleIconsToPanelSize", false );
+
     std::pair<int,int> new_sizes=preferredIconSizes();
     int sz=new_sizes.first;
     int zoom_sz=new_sizes.second;
@@ -189,7 +202,8 @@ bool PanelButtonBase::calculateIconSizes
         _zoom_size = zoom_sz;
         return true;
      }
-     return false;
+
+     return scale_panel_icons;
 }
 
 void PanelButtonBase::loadIcons()
@@ -198,14 +212,32 @@ void PanelButtonBase::loadIcons()
     QString nm = _iconName;
     _hasAnimation = true;
 
-    _icon = ldr->loadIcon(nm, KIcon::Panel, _size, KIcon::DefaultState, 0L, true);
+    int scale_to_size = (orientation() == Horizontal) ? height()-2 : width()-2;
+    int load_size = _size;
+    if( scale_panel_icons )
+    {
+	load_size = _size + 16;
+    }
+
+    _icon = ldr->loadIcon(nm, KIcon::Panel, load_size, KIcon::DefaultState, 0L, true);
 
     if (_icon.isNull()) {
         nm = defaultIcon();
-        _icon = ldr->loadIcon(nm, KIcon::Panel, _size, KIcon::DefaultState);
+        _icon = ldr->loadIcon(nm, KIcon::Panel, load_size, KIcon::DefaultState);
     }
 
+    if( scale_panel_icons )
+    {
+	_icon = iconResize(_icon, scale_to_size);
+	_iconh = iconResize(
+		    ldr->loadIcon(nm, KIcon::Panel, load_size, KIcon::ActiveState, 0L, true),
+            	    scale_to_size
+		 );
+    }
+    else
+    {
     _iconh = ldr->loadIcon(nm, KIcon::Panel, _size, KIcon::ActiveState, 0L, true);
+    }
     _iconz = ldr->loadIcon(nm, KIcon::Panel, _zoom_size, KIcon::ActiveState, 0L, true );
 }
 
 
design & coding: Vladimir Lettiev aka crux © 2004-2005