~ubuntu-branches/ubuntu/quantal/kde-runtime/quantal

« back to all changes in this revision

Viewing changes to plasma/declarativeimports/plasmacomponents/qml/TabButton.qml

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2012-06-03 21:50:00 UTC
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: package-import@ubuntu.com-20120603215000-vn7oarsq0ynrydj5
Tags: upstream-4.8.80
Import upstream version 4.8.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
**
41
41
****************************************************************************/
42
42
 
43
 
/**Documentanted API
 
43
/**Documented API
44
44
Inherits:
45
45
        Item
46
46
 
53
53
 
54
54
Properties:
55
55
        Item tab:
56
 
        TODO
 
56
        The reference to the tab content (one of the children of a TabGroup,
 
57
        usually a Page) that is activated when this TabButton is clicked.
 
58
 
57
59
        bool checked:
58
 
        Returns true if the button is checked,otherwise false.
 
60
        True if the button is checked,otherwise false.
59
61
 
60
62
        bool pressed:
61
 
        Returns true if the button is being pressed,otherwise false.
 
63
        True if the button is being pressed,otherwise false.
62
64
 
63
 
        alias text:
 
65
        string text:
64
66
        Sets the text for the button.
65
67
 
66
 
        alias iconSource:
67
 
        Sets an icon for the button
 
68
        string iconSource:
 
69
        Icon for the button. It can be a Freedesktop icon name, a full path to a ong/svg file,
 
70
        or any name for which the application has an image handler registered.
68
71
 
69
72
Signals:
70
73
        onClicked:
71
 
        The signal is being emmited when the button is being clicked.
 
74
        The signal is emmited when the button is clicked.
72
75
**/
73
76
 
74
77
import QtQuick 1.1
75
 
import "AppManager.js" as Utils
 
78
import "private/AppManager.js" as Utils
 
79
import "private" as Private
76
80
 
77
81
Item {
78
82
    id: root
86
90
 
87
91
    signal clicked
88
92
 
89
 
    implicitWidth: label.paintedWidth + (internal.portrait ? 0 : (iconSource != "" ? 16 : 0))
90
 
    implicitHeight: label.paintedHeight + (internal.portrait ? (iconSource != "" ? 16 : 0) : 0)
 
93
    implicitWidth: label.paintedWidth + (internal.portrait ? 0 : (iconSource != null ? 16 : 0))
 
94
    implicitHeight: label.paintedHeight + (internal.portrait ? (iconSource != null ? 16 : 0) : 0)
91
95
 
92
96
    //long notation to not make it overwritten by implementations
93
97
    Connections {
95
99
        onPressedChanged: {
96
100
            //TabBar is the granparent
97
101
            root.parent.parent.currentTab = root
 
102
            root.parent.parent.forceActiveFocus()
98
103
        }
 
104
        onVisibleChanged: root.parent.childrenChanged()
99
105
    }
100
106
 
101
107
    QtObject {
124
130
        objectName: "label"
125
131
 
126
132
        anchors {
127
 
            top: internal.portrait && iconSource != "" ? imageLoader.bottom : parent.top
128
 
            left: internal.portrait || iconSource == "" ? parent.left : imageLoader.right
 
133
            top: internal.portrait && iconSource != null ? imageLoader.bottom : parent.top
 
134
            left: internal.portrait || iconSource == null ? parent.left : imageLoader.right
 
135
            leftMargin: iconSource == null ? 0 : parent.parent.anchors.leftMargin
129
136
            right: parent.right
130
137
            bottom: parent.bottom
131
138
        }
132
139
 
133
140
        elide: Text.ElideRight
134
 
        horizontalAlignment: !internal.portrait && iconSource != "" ? Text.AlignLeft : Text.AlignHCenter
 
141
        horizontalAlignment: !internal.portrait && iconSource != null ? Text.AlignLeft : Text.AlignHCenter
135
142
        verticalAlignment: Text.AlignVCenter
136
143
    }
137
144
 
138
 
    IconLoader {
 
145
    Private.IconLoader {
139
146
        id: imageLoader
140
147
 
141
 
        implicitWidth: theme.smallIconSize
142
 
        implicitHeight: theme.smallIconSize
 
148
        implicitWidth: internal.portrait ? Math.max(theme.smallIconSize, root.height - (label.text ? label.height : 0)) : Math.max(theme.smallIconSize, root.height)
 
149
        implicitHeight: implicitWidth
143
150
 
144
151
        anchors {
145
152
            left: internal.portrait ? undefined : parent.left