internal api is internal

This commit is contained in:
Marco Martin 2011-11-09 17:05:21 +01:00
parent 7cb7c0e276
commit a4cc8972bb
5 changed files with 59 additions and 65 deletions

View File

@ -43,12 +43,8 @@ Item {
property bool pressed: internalLoader.item.mouseArea?internalLoader.item.mouseArea.pressed:false property bool pressed: internalLoader.item.mouseArea?internalLoader.item.mouseArea.pressed:false
property real scrollButtonInterval: 50 property real scrollButtonInterval: 50
// Convinience API implicitWidth: internalLoader.isVertical ? (interactive ? 22 : 12) : 200
property bool _isVertical: orientation == Qt.Vertical implicitHeight: internalLoader.isVertical ? 200 : (interactive ? 22 : 12)
property bool _showButtons: stepSize != 0
implicitWidth: _isVertical ? (interactive ? 22 : 12) : 200
implicitHeight: _isVertical ? 200 : (interactive ? 22 : 12)
// TODO: needs to define if there will be specific graphics for // TODO: needs to define if there will be specific graphics for
// disabled scroll bars // disabled scroll bars
opacity: enabled ? 1.0 : 0.5 opacity: enabled ? 1.0 : 0.5
@ -65,15 +61,16 @@ Item {
Loader { Loader {
id: internalLoader id: internalLoader
anchors.fill: parent anchors.fill: parent
//property bool handleEnabled: _isVertical ? item.handle.height < item.contents.height : item.handle.width < item.contents.width //property bool handleEnabled: internalLoader.isVertical ? item.handle.height < item.contents.height : item.handle.width < item.contents.width
property bool handleEnabled: _isVertical ? flickableItem.contentHeight > flickableItem.height : flickableItem.contentWidth > flickableItem.width property bool handleEnabled: internalLoader.isVertical ? flickableItem.contentHeight > flickableItem.height : flickableItem.contentWidth > flickableItem.width
property bool isVertical: orientation == Qt.Vertical
function incrementValue(increment) function incrementValue(increment)
{ {
if (!flickableItem) if (!flickableItem)
return; return;
if (_isVertical) { if (internalLoader.isVertical) {
flickableItem.contentY = Math.max(0, Math.min(flickableItem.contentHeight, flickableItem.contentY = Math.max(0, Math.min(flickableItem.contentHeight,
flickableItem.contentY + increment)) flickableItem.contentY + increment))
} else { } else {
@ -88,7 +85,7 @@ Item {
minimumValue: 0 minimumValue: 0
maximumValue: { maximumValue: {
var diff; var diff;
if (_isVertical) { if (internalLoader.isVertical) {
diff = flickableItem.contentHeight - flickableItem.height diff = flickableItem.contentHeight - flickableItem.height
} else { } else {
diff = flickableItem.contentWidth - flickableItem.width diff = flickableItem.contentWidth - flickableItem.width
@ -101,33 +98,33 @@ Item {
inverted: scrollbar.inverted inverted: scrollbar.inverted
positionAtMinimum: 0 positionAtMinimum: 0
positionAtMaximum: { positionAtMaximum: {
if (_isVertical) { if (internalLoader.isVertical) {
internalLoader.item.contents.height - internalLoader.item.handle.height internalLoader.item.contents.height - internalLoader.item.handle.height
} else { } else {
internalLoader.item.contents.width - internalLoader.item.handle.width internalLoader.item.contents.width - internalLoader.item.handle.width
} }
} }
value: _isVertical ? flickableItem.contentY : flickableItem.contentX value: internalLoader.isVertical ? flickableItem.contentY : flickableItem.contentX
onValueChanged: { onValueChanged: {
if (flickableItem.moving) { if (flickableItem.moving) {
return return
} }
if (_isVertical) { if (internalLoader.isVertical) {
flickableItem.contentY = value flickableItem.contentY = value
} else { } else {
flickableItem.contentX = value flickableItem.contentX = value
} }
} }
position: _isVertical ? internalLoader.item.handle.y : internalLoader.item.handle.x position: internalLoader.isVertical ? internalLoader.item.handle.y : internalLoader.item.handle.x
onPositionChanged: { onPositionChanged: {
if (internalLoader.item.mouseArea && internalLoader.item.mouseArea.pressed) { if (internalLoader.item.mouseArea && internalLoader.item.mouseArea.pressed) {
return return
} }
if (_isVertical) { if (internalLoader.isVertical) {
internalLoader.item.handle.y = position internalLoader.item.handle.y = position
} else { } else {
internalLoader.item.handle.x = position internalLoader.item.handle.x = position

View File

@ -43,12 +43,8 @@ Item {
property bool pressed: internalLoader.item.mouseArea?internalLoader.item.mouseArea.pressed:false property bool pressed: internalLoader.item.mouseArea?internalLoader.item.mouseArea.pressed:false
property real scrollButtonInterval: 50 property real scrollButtonInterval: 50
// Convinience API implicitWidth: internalLoader.isVertical ? (interactive ? 22 : 12) : 200
property bool _isVertical: orientation == Qt.Vertical implicitHeight: internalLoader.isVertical ? 200 : (interactive ? 22 : 12)
property bool _showButtons: stepSize != 0
implicitWidth: _isVertical ? (interactive ? 22 : 12) : 200
implicitHeight: _isVertical ? 200 : (interactive ? 22 : 12)
// TODO: needs to define if there will be specific graphics for // TODO: needs to define if there will be specific graphics for
// disabled scroll bars // disabled scroll bars
opacity: enabled ? 1.0 : 0.5 opacity: enabled ? 1.0 : 0.5
@ -65,15 +61,16 @@ Item {
Loader { Loader {
id: internalLoader id: internalLoader
anchors.fill: parent anchors.fill: parent
//property bool handleEnabled: _isVertical ? item.handle.height < item.contents.height : item.handle.width < item.contents.width //property bool handleEnabled: internalLoader.isVertical ? item.handle.height < item.contents.height : item.handle.width < item.contents.width
property bool handleEnabled: _isVertical ? flickableItem.contentHeight > flickableItem.height : flickableItem.contentWidth > flickableItem.width property bool handleEnabled: internalLoader.isVertical ? flickableItem.contentHeight > flickableItem.height : flickableItem.contentWidth > flickableItem.width
property bool isVertical: orientation == Qt.Vertical
function incrementValue(increment) function incrementValue(increment)
{ {
if (!flickableItem) if (!flickableItem)
return; return;
if (_isVertical) { if (internalLoader.isVertical) {
flickableItem.contentY = Math.max(0, Math.min(flickableItem.contentHeight, flickableItem.contentY = Math.max(0, Math.min(flickableItem.contentHeight,
flickableItem.contentY + increment)) flickableItem.contentY + increment))
} else { } else {
@ -88,7 +85,7 @@ Item {
minimumValue: 0 minimumValue: 0
maximumValue: { maximumValue: {
var diff; var diff;
if (_isVertical) { if (internalLoader.isVertical) {
diff = flickableItem.contentHeight - flickableItem.height diff = flickableItem.contentHeight - flickableItem.height
} else { } else {
diff = flickableItem.contentWidth - flickableItem.width diff = flickableItem.contentWidth - flickableItem.width
@ -101,33 +98,33 @@ Item {
inverted: scrollbar.inverted inverted: scrollbar.inverted
positionAtMinimum: 0 positionAtMinimum: 0
positionAtMaximum: { positionAtMaximum: {
if (_isVertical) { if (internalLoader.isVertical) {
internalLoader.item.contents.height - internalLoader.item.handle.height internalLoader.item.contents.height - internalLoader.item.handle.height
} else { } else {
internalLoader.item.contents.width - internalLoader.item.handle.width internalLoader.item.contents.width - internalLoader.item.handle.width
} }
} }
value: _isVertical ? flickableItem.contentY : flickableItem.contentX value: internalLoader.isVertical ? flickableItem.contentY : flickableItem.contentX
onValueChanged: { onValueChanged: {
if (flickableItem.moving) { if (flickableItem.moving) {
return return
} }
if (_isVertical) { if (internalLoader.isVertical) {
flickableItem.contentY = value flickableItem.contentY = value
} else { } else {
flickableItem.contentX = value flickableItem.contentX = value
} }
} }
position: _isVertical ? internalLoader.item.handle.y : internalLoader.item.handle.x position: internalLoader.isVertical ? internalLoader.item.handle.y : internalLoader.item.handle.x
onPositionChanged: { onPositionChanged: {
if (internalLoader.item.mouseArea && internalLoader.item.mouseArea.pressed) { if (internalLoader.item.mouseArea && internalLoader.item.mouseArea.pressed) {
return return
} }
if (_isVertical) { if (internalLoader.isVertical) {
internalLoader.item.handle.y = position internalLoader.item.handle.y = position
} else { } else {
internalLoader.item.handle.x = position internalLoader.item.handle.x = position

View File

@ -26,10 +26,10 @@ PlasmaCore.FrameSvgItem {
id: background id: background
anchors.fill: parent anchors.fill: parent
imagePath:"widgets/scrollbar" imagePath:"widgets/scrollbar"
prefix: _isVertical ? "background-vertical" : "background-horizontal" prefix: internalLoader.isVertical ? "background-vertical" : "background-horizontal"
Keys.onUpPressed: { Keys.onUpPressed: {
if (!enabled || !_isVertical) if (!enabled || !internalLoader.isVertical)
return; return;
if (inverted) if (inverted)
@ -39,7 +39,7 @@ PlasmaCore.FrameSvgItem {
} }
Keys.onDownPressed: { Keys.onDownPressed: {
if (!enabled || !_isVertical) if (!enabled || !internalLoader.isVertical)
return; return;
if (inverted) if (inverted)
@ -49,7 +49,7 @@ PlasmaCore.FrameSvgItem {
} }
Keys.onLeftPressed: { Keys.onLeftPressed: {
if (!enabled || _isVertical) if (!enabled || internalLoader.isVertical)
return; return;
if (inverted) if (inverted)
@ -59,7 +59,7 @@ PlasmaCore.FrameSvgItem {
} }
Keys.onRightPressed: { Keys.onRightPressed: {
if (!enabled || _isVertical) if (!enabled || internalLoader.isVertical)
return; return;
if (inverted) if (inverted)
@ -75,10 +75,10 @@ PlasmaCore.FrameSvgItem {
id: contents id: contents
anchors { anchors {
fill: parent fill: parent
leftMargin: _isVertical || stepSize <= 0 ? 0 : leftButton.width leftMargin: internalLoader.isVertical || stepSize <= 0 ? 0 : leftButton.width
rightMargin: _isVertical || stepSize <= 0 ? 0 : rightButton.width rightMargin: internalLoader.isVertical || stepSize <= 0 ? 0 : rightButton.width
topMargin: _isVertical && stepSize > 0 ? leftButton.height : 0 topMargin: internalLoader.isVertical && stepSize > 0 ? leftButton.height : 0
bottomMargin: _isVertical && stepSize > 0 ? rightButton.height : 0 bottomMargin: internalLoader.isVertical && stepSize > 0 ? rightButton.height : 0
} }
PlasmaCore.FrameSvgItem { PlasmaCore.FrameSvgItem {
@ -96,10 +96,10 @@ PlasmaCore.FrameSvgItem {
} }
} }
property int length: _isVertical? flickableItem.visibleArea.heightRatio * parent.height : flickableItem.visibleArea.widthRatio * parent.width property int length: internalLoader.isVertical? flickableItem.visibleArea.heightRatio * parent.height : flickableItem.visibleArea.widthRatio * parent.width
width: _isVertical ? parent.width : length width: internalLoader.isVertical ? parent.width : length
height: _isVertical ? length : parent.height height: internalLoader.isVertical ? length : parent.height
} }
} }
@ -113,23 +113,23 @@ PlasmaCore.FrameSvgItem {
visible: stepSize > 0 visible: stepSize > 0
anchors { anchors {
left: _isVertical ? undefined : parent.left left: internalLoader.isVertical ? undefined : parent.left
verticalCenter: _isVertical ? undefined : parent.verticalCenter verticalCenter: internalLoader.isVertical ? undefined : parent.verticalCenter
top: _isVertical ? parent.top : undefined top: internalLoader.isVertical ? parent.top : undefined
horizontalCenter: _isVertical ? parent.horizontalCenter : undefined horizontalCenter: internalLoader.isVertical ? parent.horizontalCenter : undefined
} }
width: 18
height: 18 height: 18
width: _showButtons ? 18 : 0
svg: scrollbarSvg svg: scrollbarSvg
elementId: { elementId: {
if (leftMouseArea.pressed) { if (leftMouseArea.pressed) {
return _isVertical ? "sunken-arrow-up" : "sunken-arrow-left" return internalLoader.isVertical ? "sunken-arrow-up" : "sunken-arrow-left"
} }
if (scrollbar.activeFocus || leftMouseArea.containsMouse) { if (scrollbar.activeFocus || leftMouseArea.containsMouse) {
return _isVertical ? "mouseover-arrow-up" : "mouseover-arrow-left" return internalLoader.isVertical ? "mouseover-arrow-up" : "mouseover-arrow-left"
} else { } else {
return _isVertical ? "mouseover-arrow-up" : "arrow-left" return internalLoader.isVertical ? "mouseover-arrow-up" : "arrow-left"
} }
} }
@ -160,23 +160,23 @@ PlasmaCore.FrameSvgItem {
visible: stepSize > 0 visible: stepSize > 0
anchors { anchors {
right: _isVertical ? undefined : parent.right right: internalLoader.isVertical ? undefined : parent.right
verticalCenter: _isVertical ? undefined : parent.verticalCenter verticalCenter: internalLoader.isVertical ? undefined : parent.verticalCenter
bottom: _isVertical ? parent.bottom : undefined bottom: internalLoader.isVertical ? parent.bottom : undefined
horizontalCenter: _isVertical ? parent.horizontalCenter : undefined horizontalCenter: internalLoader.isVertical ? parent.horizontalCenter : undefined
} }
width: 18
height: 18 height: 18
width: _showButtons ? 18 : 0
svg: scrollbarSvg svg: scrollbarSvg
elementId: { elementId: {
if (leftMouseArea.pressed) { if (leftMouseArea.pressed) {
return _isVertical ? "sunken-arrow-down" : "sunken-arrow-right" return internalLoader.isVertical ? "sunken-arrow-down" : "sunken-arrow-right"
} }
if (scrollbar.activeFocus || leftMouseArea.containsMouse) { if (scrollbar.activeFocus || leftMouseArea.containsMouse) {
return _isVertical ? "mouseover-arrow-down" : "mouseover-arrow-right" return internalLoader.isVertical ? "mouseover-arrow-down" : "mouseover-arrow-right"
} else { } else {
return _isVertical ? "mouseover-arrow-down" : "arrow-right" return internalLoader.isVertical ? "mouseover-arrow-down" : "arrow-right"
} }
} }
@ -210,7 +210,7 @@ PlasmaCore.FrameSvgItem {
hoverEnabled: true hoverEnabled: true
drag { drag {
target: handle target: handle
axis: _isVertical ? Drag.YAxis : Drag.XAxis axis: internalLoader.isVertical ? Drag.YAxis : Drag.XAxis
minimumX: range.positionAtMinimum minimumX: range.positionAtMinimum
maximumX: range.positionAtMaximum maximumX: range.positionAtMaximum
minimumY: range.positionAtMinimum minimumY: range.positionAtMinimum
@ -218,7 +218,7 @@ PlasmaCore.FrameSvgItem {
} }
onPressed: { onPressed: {
if (_isVertical) { if (internalLoader.isVertical) {
// Clamp the value // Clamp the value
var newY = Math.max(mouse.y, drag.minimumY); var newY = Math.max(mouse.y, drag.minimumY);
newY = Math.min(newY, drag.maximumY); newY = Math.min(newY, drag.maximumY);

View File

@ -26,7 +26,7 @@ PlasmaCore.FrameSvgItem {
id: background id: background
anchors.fill: parent anchors.fill: parent
imagePath:"widgets/scrollbar" imagePath:"widgets/scrollbar"
prefix: _isVertical ? "background-vertical" : "background-horizontal" prefix: internalLoader.isVertical ? "background-vertical" : "background-horizontal"
opacity: 0 opacity: 0
Behavior on opacity { Behavior on opacity {
@ -48,10 +48,10 @@ PlasmaCore.FrameSvgItem {
imagePath:"widgets/scrollbar" imagePath:"widgets/scrollbar"
prefix: "slider" prefix: "slider"
property int length: _isVertical? flickableItem.visibleArea.heightRatio * parent.height : flickableItem.visibleArea.widthRatio * parent.width property int length: internalLoader.isVertical? flickableItem.visibleArea.heightRatio * parent.height : flickableItem.visibleArea.widthRatio * parent.width
width: _isVertical ? parent.width : length width: internalLoader.isVertical ? parent.width : length
height: _isVertical ? length : parent.height height: internalLoader.isVertical ? length : parent.height
} }
} }

View File

@ -78,7 +78,7 @@ CommonDialog {
content: Item { content: Item {
id: contentItem id: contentItem
width: theme.defaultFont.mSize.width * 80 width: theme.defaultFont.mSize.width * 40
height: theme.defaultFont.mSize.height * 12 height: theme.defaultFont.mSize.height * 12
Item { Item {