Animate Sidebar ContentView focus switch
This commit is contained in:
@@ -4,11 +4,13 @@ import QtQuick.Controls 1.4
|
|||||||
import Ikinuki.Client 1.0
|
import Ikinuki.Client 1.0
|
||||||
|
|
||||||
TabView {
|
TabView {
|
||||||
|
id: tabView
|
||||||
property var providers
|
property var providers
|
||||||
property bool viewSelected: false
|
property bool viewSelected: false
|
||||||
|
state: viewSelected ? "selected" : "deselected"
|
||||||
property int xSelect: 0
|
property int xSelect: 0
|
||||||
property int ySelect: 0
|
property int ySelect: 0
|
||||||
width: parent.width * 0.8
|
width: viewSelected ? parent.width * 0.95 : parent.width * 0.8
|
||||||
height: parent.height
|
height: parent.height
|
||||||
|
|
||||||
property var maxElements: providers.length
|
property var maxElements: providers.length
|
||||||
@@ -45,6 +47,32 @@ TabView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
states: [
|
||||||
|
State {
|
||||||
|
name: "deselected"
|
||||||
|
PropertyChanges {
|
||||||
|
target: tabView
|
||||||
|
width: parent.width * 0.8
|
||||||
|
}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "selected"
|
||||||
|
PropertyChanges {
|
||||||
|
target: tabView
|
||||||
|
width: parent.width * 0.95
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
transitions: [
|
||||||
|
Transition {
|
||||||
|
NumberAnimation {
|
||||||
|
properties: "width"
|
||||||
|
duration: 150
|
||||||
|
easing.type: Easing.Linear
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Keys.onPressed: (event)=> {
|
Keys.onPressed: (event)=> {
|
||||||
console.log(Qt.Key_Left);
|
console.log(Qt.Key_Left);
|
||||||
if (event.key == Qt.Key_Left) {
|
if (event.key == Qt.Key_Left) {
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ import Ikinuki.Client 1.0
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
id: rect
|
id: rect
|
||||||
property var providers
|
property var providers
|
||||||
|
property bool maximized: true
|
||||||
property int selectedElement: 0
|
property int selectedElement: 0
|
||||||
property var max_elements: providers.length
|
property var max_elements: providers.length
|
||||||
width: parent.width * 0.2
|
width: parent.width * 0.2
|
||||||
height: parent.height
|
height: parent.height
|
||||||
color: "#22282A"
|
color: "#22282A"
|
||||||
|
state: maximized ? "maximized" : "minimized"
|
||||||
//color: "#0a3d4a"
|
//color: "#0a3d4a"
|
||||||
Column {
|
Column {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -19,10 +21,36 @@ Rectangle {
|
|||||||
model: providers
|
model: providers
|
||||||
SidebarElement {
|
SidebarElement {
|
||||||
provider: modelData
|
provider: modelData
|
||||||
|
maximized: rect.maximized
|
||||||
selected: (index == selectedElement) ? true : false
|
selected: (index == selectedElement) ? true : false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
states: [
|
||||||
|
State {
|
||||||
|
name: "minimized"
|
||||||
|
PropertyChanges {
|
||||||
|
target: rect
|
||||||
|
width: parent.width * 0.05
|
||||||
|
}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "maximized"
|
||||||
|
PropertyChanges {
|
||||||
|
target: rect
|
||||||
|
width: parent.width * 0.2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
transitions: [
|
||||||
|
Transition {
|
||||||
|
NumberAnimation {
|
||||||
|
properties: "width"
|
||||||
|
duration: 150
|
||||||
|
easing.type: Easing.Linear
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
function mod(n, m) {
|
function mod(n, m) {
|
||||||
return ((n % m) + m) % m;
|
return ((n % m) + m) % m;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import QtGraphicalEffects 1.12
|
|||||||
Item {
|
Item {
|
||||||
property var provider
|
property var provider
|
||||||
property bool selected: false
|
property bool selected: false
|
||||||
|
property bool maximized
|
||||||
|
|
||||||
width: parent.width * 0.9
|
width: parent.width * 0.9
|
||||||
height: parent.height * 0.07
|
height: parent.height * 0.07
|
||||||
@@ -16,7 +17,7 @@ Item {
|
|||||||
color: "black"
|
color: "black"
|
||||||
opacity: 0.5
|
opacity: 0.5
|
||||||
source: selector
|
source: selector
|
||||||
visible: selected ? true : false
|
visible: selected && maximized
|
||||||
}
|
}
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: selector
|
id: selector
|
||||||
@@ -24,7 +25,7 @@ Item {
|
|||||||
height: parent.height
|
height: parent.height
|
||||||
width: parent.width * 0.95
|
width: parent.width * 0.95
|
||||||
//anchors.fill: parent
|
//anchors.fill: parent
|
||||||
visible: selected ? true : false
|
visible: selected && maximized
|
||||||
radius: 10
|
radius: 10
|
||||||
}
|
}
|
||||||
Row {
|
Row {
|
||||||
@@ -64,6 +65,7 @@ Item {
|
|||||||
color: selected ? "#3c3c3c" : "#99afb4"
|
color: selected ? "#3c3c3c" : "#99afb4"
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.verticalCenterOffset: 4
|
anchors.verticalCenterOffset: 4
|
||||||
|
visible: maximized
|
||||||
//verticalAlignment: Text.AlignVCenter
|
//verticalAlignment: Text.AlignVCenter
|
||||||
//height: parent.height
|
//height: parent.height
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,9 +17,10 @@ ApplicationWindow {
|
|||||||
Row {
|
Row {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
focus: true
|
focus: true
|
||||||
default property int selectedView: 0
|
property int selectedView: 0
|
||||||
Sidebar {
|
Sidebar {
|
||||||
id: sidebar
|
id: sidebar
|
||||||
|
maximized: parent.selectedView == 0
|
||||||
providers: database.Providers
|
providers: database.Providers
|
||||||
}
|
}
|
||||||
ContentView {
|
ContentView {
|
||||||
|
|||||||
Reference in New Issue
Block a user