2021-04-22 22:04:30 +02:00
|
|
|
/*
|
|
|
|
|
* This file is part of the Flowee project
|
|
|
|
|
* Copyright (C) 2021 Tom Zander <tom@flowee.org>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
2021-05-23 00:27:34 +02:00
|
|
|
import QtQuick 2.11
|
|
|
|
|
import QtQuick.Controls 2.11
|
|
|
|
|
import QtQuick.Layouts 1.11
|
2021-04-22 22:04:30 +02:00
|
|
|
|
|
|
|
|
import Flowee.org.pay 1.0
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: root
|
|
|
|
|
|
|
|
|
|
property bool collapsable: true
|
|
|
|
|
property bool isCollapsed: false
|
|
|
|
|
property string title: ""
|
|
|
|
|
property alias content: child.children
|
2021-04-23 19:59:49 +02:00
|
|
|
property alias columns: child.columns
|
2021-04-22 22:04:30 +02:00
|
|
|
clip: true
|
|
|
|
|
|
2021-05-01 12:49:07 +02:00
|
|
|
width: 100 // should be changed by user
|
2021-04-22 22:04:30 +02:00
|
|
|
height: implicitHeight
|
|
|
|
|
implicitWidth: {
|
2021-05-01 12:49:07 +02:00
|
|
|
var w = child.width // even if its hidden, it takes horizontal space
|
2021-04-22 22:04:30 +02:00
|
|
|
if (titleArea.visible) {
|
|
|
|
|
var headerWidth = titleArea.width
|
|
|
|
|
if (arrowPoint.visible)
|
|
|
|
|
headerWidth += arrowPoint.width + 10
|
|
|
|
|
}
|
|
|
|
|
return w;
|
|
|
|
|
}
|
2021-05-01 12:49:07 +02:00
|
|
|
implicitHeight: arrowPoint.height + (isCollapsed ? 0 : child.height + 10)
|
2021-04-22 22:04:30 +02:00
|
|
|
|
|
|
|
|
Rectangle { // the outline
|
|
|
|
|
width: parent.width
|
|
|
|
|
y: titleArea.visible ? title.height / 2 : arrowPoint.height / 2
|
|
|
|
|
height: root.isCollapsed ? 1 : parent.height - y;
|
|
|
|
|
color: "#00000000"
|
|
|
|
|
border.color: title.palette.button
|
|
|
|
|
border.width: 2
|
|
|
|
|
radius: 3
|
|
|
|
|
}
|
|
|
|
|
MouseArea {
|
|
|
|
|
width: parent.width
|
|
|
|
|
height: 20
|
|
|
|
|
enabled: root.collapsable
|
|
|
|
|
onClicked: root.isCollapsed = !root.isCollapsed
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: titleArea
|
|
|
|
|
visible: title.text !== ""
|
|
|
|
|
color: title.palette.window
|
|
|
|
|
width: title.width + 18
|
|
|
|
|
height: title.height
|
|
|
|
|
anchors.left: arrowPoint.right
|
|
|
|
|
Label {
|
|
|
|
|
id: title
|
2021-05-01 12:49:07 +02:00
|
|
|
x: 12
|
2021-04-22 22:04:30 +02:00
|
|
|
text: root.title
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: arrowPoint
|
|
|
|
|
visible: parent.collapsable
|
|
|
|
|
color: title.palette.window
|
2021-05-01 12:49:07 +02:00
|
|
|
width: point.width + 12
|
2021-04-22 22:04:30 +02:00
|
|
|
height: point.height + 2
|
|
|
|
|
x: 6
|
|
|
|
|
y: 2
|
|
|
|
|
ArrowPoint {
|
|
|
|
|
id: point
|
|
|
|
|
x: 10
|
|
|
|
|
color: Flowee.useDarkSkin ? "white" : "black"
|
|
|
|
|
rotation: root.isCollapsed ? 0 : 90
|
|
|
|
|
transformOrigin: Item.Center
|
|
|
|
|
|
|
|
|
|
Behavior on rotation { NumberAnimation {} }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-01 12:49:07 +02:00
|
|
|
GridLayout { // user set content
|
|
|
|
|
id: child
|
2021-04-22 22:04:30 +02:00
|
|
|
x: 6
|
|
|
|
|
y: titleArea.height
|
2021-05-01 12:49:07 +02:00
|
|
|
width: root.width - 12
|
2021-04-22 22:04:30 +02:00
|
|
|
height: implicitHeight
|
|
|
|
|
visible: !root.isCollapsed
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Behavior on height { NumberAnimation { } }
|
|
|
|
|
}
|