• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kde-runtime API Reference
  • KDE Home
  • Contact Us
 

PlasmaComponents

  • sources
  • kde-4.14
  • kde-runtime
  • plasma
  • declarativeimports
  • plasmacomponents
  • qml
TabBar.qml
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright 2011 Marco Martin <mart@kde.org>
4 **
5 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 ** All rights reserved.
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** This file is part of the Qt Components project.
10 **
11 ** $QT_BEGIN_LICENSE:BSD$
12 ** You may use this file under the terms of the BSD license as follows:
13 **
14 ** "Redistribution and use in source and binary forms, with or without
15 ** modification, are permitted provided that the following conditions are
16 ** met:
17 ** * Redistributions of source code must retain the above copyright
18 ** notice, this list of conditions and the following disclaimer.
19 ** * Redistributions in binary form must reproduce the above copyright
20 ** notice, this list of conditions and the following disclaimer in
21 ** the documentation and/or other materials provided with the
22 ** distribution.
23 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
24 ** the names of its contributors may be used to endorse or promote
25 ** products derived from this software without specific prior written
26 ** permission.
27 **
28 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
39 ** $QT_END_LICENSE$
40 **
41 ****************************************************************************/
42 
43 import QtQuick 1.1
44 import org.kde.plasma.core 0.1 as PlasmaCore
45 import "private" as Private
46 
51 FocusScope {
52  id: root
57  default property alias content: tabBarLayout.data
58 
63  property alias layout: tabBarLayout
64 
65  //Plasma extension
69  property Item currentTab
70 
71  implicitWidth: layout.implicitWidth + backgroundFrame.margins.left + backgroundFrame.margins.right
72  implicitHeight: layout.implicitHeight + backgroundFrame.margins.top + backgroundFrame.margins.bottom
73 
74  PlasmaCore.FrameSvgItem {
75  id: backgroundFrame
76 
77  anchors.fill: parent
78  imagePath: "widgets/frame"
79  prefix: "sunken"
80  }
81 
82  Item {
83  id: buttonCutter
84  anchors {
85  fill: parent
86  leftMargin: 1
87  rightMargin: (buttonsLayout.visible ? buttonsLayout.width : 0) + 1
88  }
89  clip: true
90  PlasmaCore.FrameSvgItem {
91  id: buttonFrame
92 
93  visible: currentTab !== null
94  x: tabBarLayout.x + currentTab.x + backgroundFrame.margins.left -1
95  y: backgroundFrame.margins.top
96  width: currentTab.width + margins.left + margins.right -1
97  height: currentTab.height + margins.top + margins.bottom
98  imagePath: "widgets/button"
99  prefix: "normal"
100  Behavior on x {
101  PropertyAnimation {
102  easing.type: Easing.InQuad
103  duration: 250
104  }
105  }
106  }
107  }
108 
109  PlasmaCore.Svg {
110  id: scrollWidgetSvg
111  imagePath: "widgets/scrollwidget"
112  }
113  PlasmaCore.SvgItem {
114  svg: scrollWidgetSvg
115  elementId: "border-left"
116  width: naturalSize.width
117  visible: buttonsLayout.visible
118  anchors {
119  left: buttonCutter.left
120  leftMargin: -1
121  top: buttonCutter.top
122  bottom: buttonCutter.bottom
123  topMargin: backgroundFrame.margins.top
124  bottomMargin: backgroundFrame.margins.bottom
125  }
126  }
127  PlasmaCore.SvgItem {
128  svg: scrollWidgetSvg
129  elementId: "border-right"
130  width: naturalSize.width
131  visible: buttonsLayout.visible
132  anchors {
133  right: buttonCutter.right
134  rightMargin: -1
135  top: buttonCutter.top
136  bottom: buttonCutter.bottom
137  topMargin: backgroundFrame.margins.top
138  bottomMargin: backgroundFrame.margins.bottom
139  }
140  }
141 
142  onCurrentTabChanged: tabBarLayout.x = Math.max(Math.min(0, -(currentTab.x + currentTab.width/2) + tabbarScroller.width/2), -tabBarLayout.width + tabbarScroller.width)
143 
144  onWidthChanged: {
145  if (currentTab) {
146  tabBarLayout.x = Math.max(Math.min(0, -(currentTab.x + currentTab.width/2) + tabbarScroller.width/2), -tabBarLayout.width + tabbarScroller.width)
147  }
148  }
149 
150  Item {
151  id: tabbarScroller
152  clip: true
153  anchors {
154  fill: parent
155  leftMargin: backgroundFrame.margins.left + buttonFrame.margins.left
156  topMargin: backgroundFrame.margins.top + buttonFrame.margins.top
157  rightMargin: backgroundFrame.margins.right + (buttonsLayout.visible ? buttonsLayout.width : buttonFrame.margins.right)
158  bottomMargin: backgroundFrame.margins.bottom + buttonFrame.margins.bottom
159  }
160 
161  Private.TabBarLayout {
162  id: tabBarLayout
163  //A bit of snap before scolling the layout
164  width: (implicitWidth - parent.width < theme.defaultFont.mSize.width*4) ? parent.width : implicitWidth
165  anchors {
166  top: parent.top
167  bottom: parent.bottom
168  }
169  Behavior on x {
170  NumberAnimation {
171  duration: 250
172  easing.type: Easing.InOutQuad
173  }
174  }
175  }
176  }
177  Row {
178  id: buttonsLayout
179  visible: tabBarLayout.width > root.width - backgroundFrame.margins.left - backgroundFrame.margins.right
180  height: Math.min(parent.height, theme.mediumIconSize)
181 
182  anchors {
183  right: parent.right
184  verticalCenter: parent.verticalCenter
185  rightMargin: Math.min(y, backgroundFrame.margins.right)
186  }
187  ToolButton {
188  height: parent.height
189  width: height
190  iconSource: "go-previous"
191  enabled: tabBarLayout.x < 0
192  onClicked: tabBarLayout.x = Math.min(0, tabBarLayout.x + tabBarLayout.width/tabBarLayout.children.length)
193  }
194  ToolButton {
195  height: parent.height
196  width: height
197  iconSource: "go-next"
198  enabled: tabBarLayout.x > -tabBarLayout.width + tabbarScroller.width
199  onClicked: tabBarLayout.x = Math.max(-tabBarLayout.width + tabbarScroller.width, tabBarLayout.x - tabBarLayout.width/tabBarLayout.children.length)
200  }
201  }
202 }
ToolButton
A plasma theme based toolbutton.
Definition: ToolButton.qml:26
Item
FocusScope
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:08:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

PlasmaComponents

Skip menu "PlasmaComponents"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List

kde-runtime API Reference

Skip menu "kde-runtime API Reference"
  • KCMShell
  • KNotify
  • Plasma Runtime
  •     PlasmaCore
  •     DragAndDrop
  •     PlasmaComponents
  •     PlasmaExtraComponents
  •     QtExtraComponents

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal