From c2b029e2831853af0829b2df1bd23868b5d57735 Mon Sep 17 00:00:00 2001
From: Jens Bache-Wiig <jens.bache-wiig@nokia.com>
Date: Wed, 2 Mar 2011 15:16:21 +0100
Subject: [PATCH] Toolbar tweaks

---
 components/ToolBar.qml              |  7 ++--
 components/ToolButton.qml           |  4 +-
 components/styleitem/qstyleitem.cpp |  5 +++
 examples/Gallery.qml                | 58 ++++++++++++++++++-----------
 4 files changed, 46 insertions(+), 28 deletions(-)

diff --git a/components/ToolBar.qml b/components/ToolBar.qml
index 095887e2f..f91b72fb9 100644
--- a/components/ToolBar.qml
+++ b/components/ToolBar.qml
@@ -3,10 +3,9 @@ import "custom" as Components
 import "plugin"
 
 QStyleBackground {
-    id:styleitem
+    id:toolbar
     width:200
-    height:60
-
-    style: QStyleItem{elementType:"toolbar"}
+    height: styleitem.sizeFromContents(32, 32).height
+    style: QStyleItem{id:styleitem; elementType:"toolbar"}
 }
 
diff --git a/components/ToolButton.qml b/components/ToolButton.qml
index 658d07a5f..7cabb3d70 100644
--- a/components/ToolButton.qml
+++ b/components/ToolButton.qml
@@ -5,8 +5,8 @@ import "plugin"
 Components.Button {
     id:button
 
-    width: 40
-    height: 40
+    height: 40; //styleitem.sizeFromContents(32, 32).height
+    width: 40; //styleitem.sizeFromContents(32, 32).width
 
     QStyleItem {elementType: "toolbutton"; id:styleitem  }
 
diff --git a/components/styleitem/qstyleitem.cpp b/components/styleitem/qstyleitem.cpp
index 69c031b00..b5589c9da 100644
--- a/components/styleitem/qstyleitem.cpp
+++ b/components/styleitem/qstyleitem.cpp
@@ -166,6 +166,11 @@ QSize QStyleItem::sizeFromContents(int width, int height)
         initStyleOption(&opt);
         opt.text = text();
         return qApp->style()->sizeFromContents(QStyle::CT_CheckBox, &opt, QSize(width,height), widget());
+    } else if (metric == QLatin1String("toolbutton")) {
+        QStyleOptionToolButton opt;
+        initStyleOption(&opt);
+        opt.icon = qApp->style()->standardIcon(QStyle::SP_ArrowBack);
+        return qApp->style()->sizeFromContents(QStyle::CT_ToolButton, &opt, QSize(width,height), widget());
     } else if (metric == QLatin1String("button")) {
         QStyleOptionButton opt;
         initStyleOption(&opt);
diff --git a/examples/Gallery.qml b/examples/Gallery.qml
index 3c73c6faf..97cfef5b7 100644
--- a/examples/Gallery.qml
+++ b/examples/Gallery.qml
@@ -12,28 +12,27 @@ Rectangle {
         height:40
         Row {
             spacing: 2
-            ToolButton{iconSource: "images/folder_new.png"}
-            ToolButton{iconSource: "images/folder_new.png"}
-            ToolButton{iconSource: "images/folder_new.png"}
-            CheckBox{
-                id:enabledCheck
-                text:"Enabled"
-                checked:true
+            anchors.verticalCenter:parent.verticalCenter
+            ToolButton{
+                iconSource: "images/folder_new.png"
                 anchors.verticalCenter:parent.verticalCenter
             }
-            CheckBox{
-                id:animateCheck
-                text:"Animated"
-                checked:false
+            ToolButton{
+                iconSource: "images/folder_new.png"
                 anchors.verticalCenter:parent.verticalCenter
             }
-            CheckBox{
-                text:"South Tab"
-                id:toolBarPosition
-                checked:false
+            ToolButton{
+                iconSource: "images/folder_new.png"
                 anchors.verticalCenter:parent.verticalCenter
             }
         }
+        CheckBox{
+            id:enabledCheck
+            text:"Enabled"
+            checked:true
+            anchors.right:parent.right
+            anchors.verticalCenter:parent.verticalCenter
+        }
     }
 
     SystemPalette{id:syspal}
@@ -63,7 +62,7 @@ Rectangle {
     TabFrame {
         id:frame
         property int margins : styleitem.style == "mac" ? 16 : 0
-        position: toolBarPosition.checked ? "South" : "North"
+        position: tabPositionGroup.checkedButton == r2 ? "South" : "North"
         tabbar: TabBar{parent:frame}
         anchors.top:toolbar.bottom
         anchors.bottom:parent.bottom
@@ -128,7 +127,7 @@ Rectangle {
                         ProgressBar {
                             indeterminate: true
                         }
-                        Slider {id:slider; value:50; KeyNavigation.tab:c1}
+                        Slider {id:slider; value:50; KeyNavigation.tab:enabledCheck}
                         smooth:true
                     }
                     Column {
@@ -140,8 +139,21 @@ Rectangle {
                             Row {
                                 spacing: 6
                                 anchors.fill:parent
-                                CheckBox{id: c1; text:"Check 1"; KeyNavigation.tab:c2; checked:true}
-                                CheckBox{id: c2; text:"Check 2"; KeyNavigation.tab:r1}
+
+                                CheckBox{
+                                    id:frameCheckbox
+                                    text:"Text frame"
+                                    checked:true
+                                    KeyNavigation.tab:animateCheck;
+                                }
+                                CheckBox{
+                                    id:animateCheck
+                                    text:"Animated"
+
+                                    checked:false
+                                    KeyNavigation.tab:r1
+                                }
+
                             }
                             RotationAnimation on rotation {
                                 from:0; to:360;
@@ -153,10 +165,11 @@ Rectangle {
                         }
                         GroupBox{
                             id:group2
-                            text:"Radio Buttons"
+                            text:"Tab Position"
                             ButtonRow {
-                                RadioButton{id:r1; text:"Radio 1"; KeyNavigation.tab:r2; checked:true}
-                                RadioButton{id:r2; text:"Radio 2"; KeyNavigation.tab:area }
+                                id:tabPositionGroup
+                                RadioButton{id:r1; text:"North"; KeyNavigation.tab:r2; checked:true}
+                                RadioButton{id:r2; text:"South"; KeyNavigation.tab:area }
                             }
                             RotationAnimation on rotation {
                                 from:0; to:360;
@@ -169,6 +182,7 @@ Rectangle {
                         }
                         TextScrollArea {
                             id: area
+                            frame:frameCheckbox.checked
                             text: loremIpsum + loremIpsum
                             KeyNavigation.tab:button1
                         }
-- 
GitLab