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

List:       kde-commits
Subject:    koffice/kexi/kexiutils
From:       Jaroslaw Staniek <js () iidea ! pl>
Date:       2008-11-12 22:12:58
Message-ID: 1226527978.016764.23165.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 883442 by staniek:

Widgets
- small tool button: fix width for the Windows style and substyles



 M  +22 -13    SmallToolButton.cpp  


--- trunk/koffice/kexi/kexiutils/SmallToolButton.cpp #883441:883442
@@ -1,5 +1,5 @@
 /* This file is part of the KDE project
-   Copyright (C) 2005-2007 Jarosław Staniek <staniek@kde.org>
+   Copyright (C) 2005-2008 Jarosław Staniek <staniek@kde.org>
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
@@ -43,8 +43,8 @@
     }
 
     QPointer<QAction> action;
-bool enableSlotButtonToggled : 1;
-bool enableSlotActionToggled : 1;
+    bool enableSlotButtonToggled : 1;
+    bool enableSlotActionToggled : 1;
 };
 
 //--------------------------------
@@ -144,14 +144,19 @@
 
 void KexiSmallToolButton::update(const QString& text, const QIcon& icon, bool tipToo)
 {
-    int width = 0;
+    int width;
+    const bool fixWidth = style()->inherits("QWindowsStyle");
     if (text.isEmpty() || toolButtonStyle() == Qt::ToolButtonIconOnly) {
-        width = 10;
-//  setToolButtonStyle(Qt::ToolButtonIconOnly);
+        if (fixWidth) {
+            width = 10;
+        }
     } else {
-        QFont f(KGlobalSettings::toolBarFont());
-        f.setPixelSize(KexiUtils::smallFont().pixelSize());
-        width += QFontMetrics(f).width(text + " ");
+        if (fixWidth) {
+            QString text2( text + " " );
+            if (d->action && d->action->isCheckable())
+                text2 += "   ";
+            width = fontMetrics().width(text2);
+        }
         if (toolButtonStyle() != Qt::ToolButtonTextOnly)
             QToolButton::setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
         QToolButton::setText(text);
@@ -161,12 +166,16 @@
     if (toolButtonStyle() == Qt::ToolButtonTextOnly) {
         QToolButton::setIcon(QIcon());
     } else if (!icon.isNull()) {
-        width += IconSize(KIconLoader::Small);
+        if (fixWidth) {
+            width = IconSize(KIconLoader::Small);
+        }
         QToolButton::setIcon(icon);
     }
-    QStyleOption opt;
-    width += style()->pixelMetric(QStyle::PM_ButtonMargin, &opt, this);
-    //setFixedWidth( width );
+    if (fixWidth) {
+        QStyleOption opt;
+        width += style()->pixelMetric(QStyle::PM_ButtonMargin, &opt, this);
+        setFixedWidth( width );
+    }
 }
 
 QSize KexiSmallToolButton::sizeHint() const
[prev in list] [next in list] [prev in thread] [next in thread] 

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