[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/workspace/kcontrol/keyboard
From:       Björn Ruberg <bjoern () ruberg-wegener ! de>
Date:       2010-10-16 16:21:39
Message-ID: 20101016162139.96320AC896 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1186479 by ruberg:

Fixed sizing of applet. It now correctly scales in the panel and on the desktop. Text \
size is calculated by height or width (the smaller one) but not only by height \
anymore



 M  +22 -8     keyboard_applet.cpp  
 M  +1 -0      keyboard_applet.h  


--- trunk/KDE/kdebase/workspace/kcontrol/keyboard/keyboard_applet.cpp \
#1186478:1186479 @@ -19,6 +19,7 @@
 #include "keyboard_applet.h"
 
 #include <kglobalsettings.h>
+#include <KIconLoader>
 #include <plasma/theme.h>
 #include <plasma/tooltipmanager.h>
 #include <ktoolinvocation.h>
@@ -51,13 +52,12 @@
 		return;
 	}
 
+	resize(48,48);
+
 	setHasConfigurationInterface(false);
 
-//	resize(32, 32);
-	setMinimumSize(16, 16);
-
 	setAspectRatioMode(Plasma::KeepAspectRatio);
-	setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
+	//setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
 	setBackgroundHints(DefaultBackground);
 
 	rules = Rules::readRules();
@@ -158,10 +158,10 @@
 		p->save();
 		p->setPen(Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor));
 		QFont font = Plasma::Theme::defaultTheme()->font(Plasma::Theme::DesktopFont);
-		int height = contentsRect.height();
+		int height = qMin(contentsRect.height(), contentsRect.width());
 		int fontSize = shortText.length() == 2
-				? height * 7 / 10
-				: height * 5 / 10;
+				? height * 7 / 15
+				: height * 5 / 15;
 
 		int smallestReadableSize = KGlobalSettings::smallestReadableFont().pixelSize();
 		if( fontSize < smallestReadableSize ) {
@@ -169,7 +169,7 @@
 		}
 		font.setPixelSize(fontSize);
 		p->setFont(font);
-		p->drawText(contentsRect, Qt::AlignCenter | Qt::AlignHCenter, shortText);
+		p->drawText(contentsRect, Qt::AlignCenter, shortText);
 		p->restore();
 	}
 }
@@ -224,6 +224,20 @@
 	return actionGroup->actions();
 }
 
+void KeyboardApplet::constraintsEvent(Plasma::Constraints constraints)
+{
+    if (constraints & Plasma::FormFactorConstraint) {
+	int iconSize;
+        if (formFactor() == Plasma::Planar ||
+            formFactor() == Plasma::MediaCenter) {
+            iconSize = IconSize(KIconLoader::Desktop);
+        } else {
+            iconSize = IconSize(KIconLoader::Small);
+        }
+	setMinimumSize(iconSize, iconSize);
+    }
+}
+
 //void KeyboardApplet::createConfigurationInterface(KConfigDialog *parent)
 //{
 ////	Applet::createConfigurationInterface(parent);
--- trunk/KDE/kdebase/workspace/kcontrol/keyboard/keyboard_applet.h #1186478:1186479
@@ -51,6 +51,7 @@
 	KeyboardApplet(QObject *parent, const QVariantList &args);
 	virtual ~KeyboardApplet();
 
+	void constraintsEvent(Plasma::Constraints constraints);
 	void paintInterface(QPainter *p, const QStyleOptionGraphicsItem *option, const \
QRect &contentsRect);  
 protected:


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic