Commit 5ec665ef authored by camilo higuita's avatar camilo higuita
Browse files

revert api breaking changes for 2.0.2 release

parent 2ff8ef1e
......@@ -29,203 +29,201 @@ import "private" as Private
* \since org.mauikit.controls 1.2
* \inqmlmodule org.mauikit.controls
* \brief View switcher component
*
*
* Lists the different views declared into a swipe view, that does not jump around
* when resizing the application window and that takes care of different gestures for switching the views.
*
*
* This component takes care of creating the app views port as buttons in the application main header
* for switching the views.
*
*
* By default this component is not interactive when using touch gesture, to not steal fcous from other horizontal
* flickable gestures.
*/
Maui.Page
SwipeView
{
id: control
default property alias content: _swipeView.contentData
property alias currentIndex : _swipeView.currentIndex
property alias currentItem : _swipeView.currentItem
property alias count : _swipeView.count
property alias interactive : _swipeView.interactive
// interactive: Kirigami.Settings.hasTransientTouchInput
interactive: false
focus: true
/*!
* Maximum number of views to be shown in the app* view port in the header.
* The rest of views buttons will be collapsed into a menu button.
*/
* Maximum number of views to be shown in the app view port in the header.
* The rest of views buttons will be collapsed into a menu button.
*/
property int maxViews : 4
/*!
* The toolbar where the app view buttons will be* added.
*/
headBar.middleContent: Private.ActionGroup
* The toolbar where the app view buttons will be added.
*/
property Maui.ToolBar toolbar : window().headBar
//TODO: grouped property docs
/*!
* Access to the view port component where the app view buttons is added.
*/
Component
{
id: _actionGroup
currentIndex : _swipeView.currentIndex
Binding on currentIndex {
value: _swipeView.currentIndex
restoreMode: Binding.RestoreValue
}
onCurrentIndexChanged:
{
_swipeView.currentIndex = currentIndex
// _actionGroup.currentIndex = control.currentIndex
}
Component.onCompleted:
id: _viewPortComponent
Private.ActionGroup
{
for(var i in _swipeView.contentChildren)
id: _actionGroup
currentIndex : control.currentIndex
Binding on currentIndex {
value: control.currentIndex
restoreMode: Binding.RestoreValue
}
onCurrentIndexChanged:
{
const obj = _swipeView.contentChildren[i]
if(obj.Maui.AppView.title || obj.Maui.AppView.iconName)
control.currentIndex = currentIndex
// _actionGroup.currentIndex = control.currentIndex
}
Component.onCompleted:
{
for(var i in control.contentChildren)
{
if(_actionGroup.items.length < control.maxViews)
const obj = control.contentChildren[i]
if(obj.Maui.AppView.title || obj.Maui.AppView.iconName)
{
_actionGroup.items.push(obj)
}else
{
_actionGroup.hiddenItems.push(obj)
if(_actionGroup.items.length < control.maxViews)
{
_actionGroup.items.push(obj)
}else
{
_actionGroup.hiddenItems.push(obj)
}
}
}
}
}
}
SwipeView
onCurrentItemChanged:
{
id:_swipeView // interactive: Kirigami.Settings.hasTransientTouchInput
anchors.fill: parent
interactive: false
//TODO: grouped property docs
/*!
* Access to the view port component where the app view buttons is added.
*/
onCurrentItemChanged:
{
currentItem.forceActiveFocus()
_listView.positionViewAtIndex(control.currentIndex , ListView.SnapPosition)
history.push(_swipeView.currentIndex)
}
Keys.onBackPressed:
{
control.goBack()
}
Shortcut
currentItem.forceActiveFocus()
_listView.positionViewAtIndex(control.currentIndex , ListView.SnapPosition)
history.push(control.currentIndex)
}
Keys.onBackPressed:
{
control.goBack()
}
Shortcut
{
sequence: StandardKey.Back
onActivated: control.goBack()
}
contentItem: ListView
{
id: _listView
model: control.contentModel
interactive: control.interactive
currentIndex: control.currentIndex
spacing: control.spacing
orientation: control.orientation
snapMode: ListView.SnapOneItem
boundsBehavior: Flickable.StopAtBounds
clip: control.clip
preferredHighlightBegin: 0
preferredHighlightEnd: width
highlightRangeMode: ListView.StrictlyEnforceRange
highlightMoveDuration: 0
highlightFollowsCurrentItem: true
highlightResizeDuration: 0
highlightMoveVelocity: -1
highlightResizeVelocity: -1
maximumFlickVelocity: 4 * (control.orientation === Qt.Horizontal ? width : height)
property int lastPos: 0
onCurrentIndexChanged:
{
sequence: StandardKey.Back
onActivated: control.goBack()
_listView.lastPos = _listView.contentX
}
contentItem: ListView
}
Keys.enabled: true
// Keys.forwardTo:_listView
Keys.onPressed:
{
if((event.key == Qt.Key_1) && (event.modifiers & Qt.ControlModifier))
{
id: _listView
model: _swipeView.contentModel
interactive: _swipeView.interactive
currentIndex: _swipeView.currentIndex
spacing: _swipeView.spacing
orientation: _swipeView.orientation
snapMode: ListView.SnapOneItem
boundsBehavior: Flickable.StopAtBounds
clip: _swipeView.clip
preferredHighlightBegin: 0
preferredHighlightEnd: width
highlightRangeMode: ListView.StrictlyEnforceRange
highlightMoveDuration: 0
highlightFollowsCurrentItem: true
highlightResizeDuration: 0
highlightMoveVelocity: -1
highlightResizeVelocity: -1
maximumFlickVelocity: 4 * (_swipeView.orientation === Qt.Horizontal ? width : height)
property int lastPos: 0
onCurrentIndexChanged:
if(control.count > -1 )
{
_listView.lastPos = _listView.contentX
control.currentIndex = 0
}
}
Keys.enabled: true
// Keys.forwardTo:_listView
Keys.onPressed:
if((event.key == Qt.Key_2) && (event.modifiers & Qt.ControlModifier))
{
if((event.key == Qt.Key_1) && (event.modifiers & Qt.ControlModifier))
if(control.count > 0 )
{
if(_swipeView.count > -1 )
{
_swipeView.currentIndex = 0
}
control.currentIndex = 1
}
if((event.key == Qt.Key_2) && (event.modifiers & Qt.ControlModifier))
}
if((event.key == Qt.Key_3) && (event.modifiers & Qt.ControlModifier))
{
if(control.count > 1 )
{
if(_swipeView.count > 0 )
{
_swipeView.currentIndex = 1
}
control.currentIndex = 2
}
if((event.key == Qt.Key_3) && (event.modifiers & Qt.ControlModifier))
{
if(_swipeView.count > 1 )
{
_swipeView.currentIndex = 2
}
}
if((event.key == Qt.Key_4) && (event.modifiers & Qt.ControlModifier))
}
if((event.key == Qt.Key_4) && (event.modifiers & Qt.ControlModifier))
{
if(control.count > 2 )
{
if(_swipeView.count > 2 )
{
_swipeView.currentIndex = 3
}
control.currentIndex = 3
}
}
}
Component.onCompleted:
{
if(control.toolbar)
{
var object = _viewPortComponent.createObject(control.toolbar.middleContent)
control.toolbar.middleContent.push(object)
}
}
property QtObject history : QtObject
{
property var historyIndexes : []
function pop()
{
historyIndexes.pop()
return historyIndexes.pop()
}
function push(index)
{
historyIndexes.push(index)
}
function indexes()
{
return historyIndexes
}
}
/**
*
*/
*
*/
function goBack()
{
_swipeView.setCurrentIndex(history.pop())
control.setCurrentIndex(history.pop())
}
}
......@@ -66,7 +66,7 @@ Item
*/
signal doubleClicked(int index)
property Component delegate : ToolButton
property Component delegate : Maui.BasicToolButton
{
Layout.alignment: Qt.AlignCenter
// Layout.preferredWidth: visible ? implicitWidth : 0
......@@ -112,9 +112,9 @@ Item
delegate: control.delegate
}
ToolButton
Maui.BasicToolButton
{
Layout.alignment: Qt.AlignCenter
Layout.alignment: Qt.AlignCenter
readonly property QtObject obj : control.currentIndex >= control.items.length && control.currentIndex < control.count? control.hiddenItems[control.currentIndex - control.items.length] : null
......
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