Commit bd80421d authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

Add the ability to activate the clickable arrow buttons on scrollbars

parent 1e0a54f8
Pipeline #1000 passed with stage
in 9 seconds
......@@ -11,10 +11,13 @@ FocusScope {
property bool stayAtBottom : false;
property bool showBorder : true;
property bool indicatorOnly : stayAtBottom;
property bool arrowButtons : Style.arrowButtons;
property alias placeholder : lbl.text;
property alias background : rect.color;
property alias headerItem : loaderHeader.sourceComponent;
property alias footerItem : loaderFooter.sourceComponent;
property int pageSizeX : (flickableItem ? flickableItem.width / 5 : 100);
property int pageSizeY : (flickableItem ? flickableItem.height / 5 : 100);
property Flickable flickableItem : null;
property int rounding : Style.roundness;
......@@ -23,6 +26,11 @@ FocusScope {
readonly property bool canScrollX : (flickableItem && flickableItem.contentWidth > flickableItem.width);
readonly property bool canScrollY : (flickableItem && flickableItem.contentHeight > flickableItem.height);
readonly property bool canGoUp : (canScrollY && flickableItem && flickableItem.contentY > minContentY);
readonly property bool canGoLeft : (canScrollX && flickableItem && flickableItem.contentX > minContentX);
readonly property bool canGoRight : (canScrollX && flickableItem && flickableItem.contentX < maxContentX);
readonly property bool canGoDown : (canScrollY && flickableItem && flickableItem.contentY < maxContentY);
readonly property real minContentX : 0;
readonly property real minContentY : 0;
readonly property real maxContentX : (canScrollX ? flickableItem.contentWidth - flickableItem.width : 0);
......@@ -183,6 +191,30 @@ FocusScope {
color: Style.colorGroove;
anchors.fill: parent;
}
TextButton {
id: btnLeft;
width: height;
enabled: canGoLeft;
visible: (arrowButtons && canScrollX);
ExtraAnchors.leftDock: parent;
onClicked: {
if (flickableItem) {
flickableItem.contentX = Math.max ((flickableItem.contentX - pageSizeX), minContentX);
}
}
}
TextButton {
id: btnRight;
width: height;
enabled: canGoRight;
visible: (arrowButtons && canScrollX);
ExtraAnchors.rightDock: parent;
onClicked: {
if (flickableItem) {
flickableItem.contentX = Math.min ((flickableItem.contentX + pageSizeX), maxContentX);
}
}
}
SymbolLoader {
id: arrowLeft;
size: Style.spacingNormal;
......@@ -267,6 +299,30 @@ FocusScope {
color: Style.colorGroove;
anchors.fill: parent;
}
TextButton {
id: btnUp;
height: width;
enabled: canGoUp;
visible: (arrowButtons && canScrollY);
ExtraAnchors.topDock: parent;
onClicked: {
if (flickableItem) {
flickableItem.contentY = Math.max ((flickableItem.contentY - pageSizeY), minContentY);
}
}
}
TextButton {
id: btnDown;
height: width;
enabled: canGoDown;
visible: (arrowButtons && canScrollY);
ExtraAnchors.bottomDock: parent;
onClicked: {
if (flickableItem) {
flickableItem.contentY = Math.min ((flickableItem.contentY + pageSizeY), maxContentY);
}
}
}
SymbolLoader {
id: arrowUp;
size: Style.spacingNormal;
......
......@@ -15,6 +15,7 @@ QtObject {
property bool useSlimFonts : true;
property bool useDarkTheme : false;
property bool useNativeText : false;
property bool arrowButtons : false;
property int themeFadeTime : 850;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment