Commit 01b0a336 authored by Eike Hein's avatar Eike Hein

Try out the new Kirigami.ColorScope

CCMAIL:notmart@gmail.com
parent 1824c94b
......@@ -252,298 +252,308 @@ Kirigami.ApplicationWindow {
property Item viewTreeList: null
MouseArea {
Kirigami.ColorScope {
anchors.fill: parent
onClicked: {
if (viewTreeList) {
viewTreeList.forceActiveFocus();
context: Kirigami.ColorScope.Complementary
MouseArea {
anchors.fill: parent
onClicked: {
if (viewTreeList) {
viewTreeList.forceActiveFocus();
}
}
}
}
QQC2.StackView {
id: sidebarStackView
QQC2.StackView {
id: sidebarStackView
anchors.fill: parent
anchors.fill: parent
background: Rectangle { color: KUIC.ExtraColors.spotColor }
background: Rectangle { color: Kirigami.Theme.backgroundColor }
initialItem: viewTreeComponent
initialItem: viewTreeComponent
onBusyChanged: {
if (!busy && depth == 2) {
currentItem.currentIndex = 0;
currentItem.forceActiveFocus();
onBusyChanged: {
if (!busy && depth == 2) {
currentItem.currentIndex = 0;
currentItem.forceActiveFocus();
}
}
}
pushEnter: Transition {
YAnimator {
from: sidebarStackView.height
to: 0
duration: Kirigami.Units.longDuration * 2
easing.type: Easing.OutCubic
pushEnter: Transition {
YAnimator {
from: sidebarStackView.height
to: 0
duration: Kirigami.Units.longDuration * 2
easing.type: Easing.OutCubic
}
}
}
pushExit: Transition {
OpacityAnimator {
from: 1.0
to: 0.0
duration: Kirigami.Units.longDuration * 2
pushExit: Transition {
OpacityAnimator {
from: 1.0
to: 0.0
duration: Kirigami.Units.longDuration * 2
}
}
}
popEnter: Transition {
OpacityAnimator {
from: 0.0
to: 1.0
duration: Kirigami.Units.longDuration * 2
popEnter: Transition {
OpacityAnimator {
from: 0.0
to: 1.0
duration: Kirigami.Units.longDuration * 2
}
}
}
popExit: Transition {
YAnimator {
from: 0
to: sidebarStackView.height
duration: Kirigami.Units.longDuration * 2
easing.type: Easing.OutCubic
popExit: Transition {
YAnimator {
from: 0
to: sidebarStackView.height
duration: Kirigami.Units.longDuration * 2
easing.type: Easing.OutCubic
}
}
}
Component.onCompleted: konvUi.sidebarStackView = sidebarStackView
}
Component.onCompleted: konvUi.sidebarStackView = sidebarStackView
}
Component {
id: viewTreeComponent
Component {
id: viewTreeComponent
KUIC.ListView {
id: viewTreeList
KUIC.ListView {
id: viewTreeList
QQC2.ScrollBar.vertical: QQC2.ScrollBar {}
QQC2.ScrollBar.vertical: QQC2.ScrollBar {}
clip: true
clip: true
model: viewModel
model: viewModel
function showView(index, view) {
viewTreeList.forceActiveFocus();
viewModel.showView(view);
function showView(index, view) {
viewTreeList.forceActiveFocus();
viewModel.showView(view);
if (!konvUi.pageStack.wideMode) {
konvUi.pageStack.currentIndex = 1;
if (!konvUi.pageStack.wideMode) {
konvUi.pageStack.currentIndex = 1;
}
}
}
delegate: Column {
property int topLevelIndex: index
delegate: Column {
property int topLevelIndex: index
ListItem {
width: viewTreeList.width
ListItem {
width: viewTreeList.width
textColor: KUIC.ExtraColors.spotTextColor
backgroundColor: KUIC.ExtraColors.spotColor
textColor: Kirigami.Theme.textColor
backgroundColor: Kirigami.Theme.backgroundColor
text: model.display
textMargin: Kirigami.Units.gridUnit
text: model.display
textMargin: Kirigami.Units.gridUnit
onClicked: viewTreeList.showView(topLevelIndex, value)
}
onClicked: viewTreeList.showView(topLevelIndex, value)
}
DelegateModel {
id: subLevelEntries
DelegateModel {
id: subLevelEntries
model: viewModel
rootIndex: modelIndex(index)
model: viewModel
rootIndex: modelIndex(index)
delegate: ListItem {
width: viewTreeList.width
delegate: ListItem {
width: viewTreeList.width
textColor: KUIC.ExtraColors.spotTextColor
backgroundColor: KUIC.ExtraColors.spotColor
textColor: Kirigami.Theme.textColor
backgroundColor: Kirigami.Theme.backgroundColor
text: model.display
textMargin: Kirigami.Units.gridUnit * 2
text: model.display
textMargin: Kirigami.Units.gridUnit * 2
onClicked: viewTreeList.showView(topLevelIndex, value)
onClicked: viewTreeList.showView(topLevelIndex, value)
}
}
Column { Repeater { model: subLevelEntries } }
}
Column { Repeater { model: subLevelEntries } }
}
Keys.onUpPressed: {
event.accept = true;
viewModel.showPreviousView();
}
Keys.onUpPressed: {
event.accept = true;
viewModel.showPreviousView();
}
Keys.onDownPressed: {
event.accept = true;
viewModel.showNextView();
}
Keys.onDownPressed: {
event.accept = true;
viewModel.showNextView();
Component.onCompleted: sidebar.viewTreeList = viewTreeList
}
Component.onCompleted: sidebar.viewTreeList = viewTreeList
}
}
Component {
id: settingsTreeComponent
Component {
id: settingsTreeComponent
QQC2.ScrollView {
id: viewTree
QQC2.ScrollView {
id: viewTree
property alias currentIndex: settingsTreeList.currentIndex
property alias currentIndex: settingsTreeList.currentIndex
KUIC.ListView {
id: settingsTreeList
KUIC.ListView {
id: settingsTreeList
focus: true
focus: true
clip: true
clip: true
currentIndex: -1
currentIndex: -1
onCurrentIndexChanged: positionViewAtIndex(currentIndex, ListView.Contain)
onCurrentIndexChanged: positionViewAtIndex(currentIndex, ListView.Contain)
model: ListModel {
ListElement { name: "Dummy 1" }
ListElement { name: "Dummy 2" }
ListElement { name: "Dummy 3" }
}
model: ListModel {
ListElement { name: "Dummy 1" }
ListElement { name: "Dummy 2" }
ListElement { name: "Dummy 3" }
}
delegate: ListItem {
width: settingsTreeList.width
delegate: ListItem {
width: settingsTreeList.width
textColor: Kirigami.Theme.textColor
backgroundColor: Kirigami.Theme.backgroundColor
textColor: KUIC.ExtraColors.spotTextColor
backgroundColor: KUIC.ExtraColors.spotColor
text: name
textMargin: Kirigami.Units.gridUnit
text: name
textMargin: Kirigami.Units.gridUnit
onIsActiveChanged: {
if (isActive && konvUi.contentStackView.depth == 1) {
konvUi.contentStackView.push("SettingsPage.qml", {"title": name});
//konvUi.settingsModeButtons.enabled = true;
}
}
onIsActiveChanged: {
if (isActive && konvUi.contentStackView.depth == 1) {
konvUi.contentStackView.push("SettingsPage.qml", {"title": name});
//konvUi.settingsModeButtons.enabled = true;
onClicked: {
settingsTreeList.forceActiveFocus();
settingsTreeList.currentIndex = index;
}
}
onClicked: {
settingsTreeList.forceActiveFocus();
settingsTreeList.currentIndex = index;
}
}
Keys.onUpPressed: {
event.accept = true;
Keys.onUpPressed: {
event.accept = true;
if (currentIndex == -1) {
currentIndex = 0;
return;
}
if (currentIndex == -1) {
currentIndex = 0;
return;
decrementCurrentIndex();
}
decrementCurrentIndex();
}
Keys.onDownPressed: {
event.accept = true;
Keys.onDownPressed: {
event.accept = true;
if (currentIndex == -1) {
currentIndex = 0;
return;
}
if (currentIndex == -1) {
currentIndex = 0;
return;
incrementCurrentIndex();
}
incrementCurrentIndex();
}
}
}
}
PageHandle {
id: sidebarRightPaginationHandle
PageHandle {
id: sidebarRightPaginationHandle
anchors.right: parent.right
anchors.right: parent.right
visible: !konvUi.pageStack.wideMode
visible: !konvUi.pageStack.wideMode
iconName: "go-previous"
iconSelected: true
iconName: "go-previous"
iconSelected: true
color: KUIC.ExtraColors.alternateSpotColor
color: Qt.lighter(Kirigami.Theme.backgroundColor, 1.02)
onTriggered: pageStack.currentIndex = 1
onTriggered: pageStack.currentIndex = 1
}
}
footer: Rectangle {
id: sidebarFooter
footer: Kirigami.ColorScope {
width: parent.width
height: footerHeight
color: KUIC.ExtraColors.alternateSpotColor
Rectangle {
id: settingsModeToggleButton
id: sidebarFooter
width: sidebarFooter.height
height: width
anchors.fill: parent
property bool checked: false
color: Qt.lighter(Kirigami.Theme.backgroundColor, 1.02)
color: checked ? Kirigami.Theme.highlightColor: KUIC.ExtraColors.alternateSpotColor
Rectangle {
id: settingsModeToggleButton
onCheckedChanged: {
konvUi.settingsMode = checked;
width: sidebarFooter.height
height: width
if (checked) {
sidebarStackView.push(settingsTreeComponent);
konvUi.contentFooterStackView.push("SettingsModeButtons.qml", {"enabled": false});
} else {
sidebarStackView.pop();
property bool checked: false
if (konvUi.contentStackView.depth == 2) {
konvUi.contentStackView.pop();
konvUi.contentFooterStackView.pop();
}
color: checked ? Kirigami.Theme.highlightColor : Qt.lighter(Kirigami.Theme.backgroundColor, 1.02)
konvUi.showMenuBar(false);
onCheckedChanged: {
konvUi.settingsMode = checked;
inputField.forceActiveFocus();
if (checked) {
sidebarStackView.push(settingsTreeComponent);
konvUi.contentFooterStackView.push("SettingsModeButtons.qml", {"enabled": false});
} else {
sidebarStackView.pop();
if (konvUi.contentStackView.depth == 2) {
konvUi.contentStackView.pop();
konvUi.contentFooterStackView.pop();
}
konvUi.showMenuBar(false);
inputField.forceActiveFocus();
}
}
}
Kirigami.Icon {
anchors.centerIn: parent
Kirigami.Icon {
anchors.centerIn: parent
width: parent.width - (Kirigami.Units.smallSpacing * 4)
height: width
width: parent.width - (Kirigami.Units.smallSpacing * 4)
height: width
selected: true
selected: true
source: "application-menu"
}
source: "application-menu"
}
MouseArea {
anchors.fill: parent
MouseArea {
anchors.fill: parent
onClicked: parent.checked = !parent.checked
onClicked: parent.checked = !parent.checked
}
}
}
QQC1.ComboBox {
anchors.fill: sidebarFooter
anchors.leftMargin: settingsModeToggleButton.width
QQC1.ComboBox {
anchors.fill: sidebarFooter
anchors.leftMargin: settingsModeToggleButton.width
visible: viewModel.currentServer
visible: viewModel.currentServer
editable: true
editable: true
model: viewModel.currentServer ? [viewModel.currentServer.nickname] : []
model: viewModel.currentServer ? [viewModel.currentServer.nickname] : []
onAccepted: {
return; // WIPQTQUICK TODO Server::setNickname does something weird
if (viewModel.currentServer) {
viewModel.currentServer.setNickname(currentText);
onAccepted: {
return; // WIPQTQUICK TODO Server::setNickname does something weird
if (viewModel.currentServer) {
viewModel.currentServer.setNickname(currentText);
}
}
}
}
......
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