diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-10 16:26:46 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-11 10:32:38 +0200 |
commit | 03fd92efdb0407b34beee13a0d2f4888b4397916 (patch) | |
tree | d24f57edc3489b531984c8f07e8ba2f4680a5e67 /framework/qml/View.qml | |
parent | 24cd706a39ac50c77dd9b88f50b8197bb2013173 (diff) | |
download | kube-03fd92efdb0407b34beee13a0d2f4888b4397916.tar.gz kube-03fd92efdb0407b34beee13a0d2f4888b4397916.zip |
A new composer based on Kube.View
Kube.View is a sort of split-view that always only shows a fixed number
of splits (and doesn't support manual resizing).
Diffstat (limited to 'framework/qml/View.qml')
-rw-r--r-- | framework/qml/View.qml | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/framework/qml/View.qml b/framework/qml/View.qml new file mode 100644 index 00000000..6a0b51b4 --- /dev/null +++ b/framework/qml/View.qml | |||
@@ -0,0 +1,83 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2017 Michael Bohlender, <michael.bohlender@kdemail.net> | ||
3 | * Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License along | ||
16 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | ||
19 | |||
20 | |||
21 | import QtQuick 2.7 | ||
22 | import QtQuick.Controls 1.3 | ||
23 | import QtQuick.Controls 2.0 as Controls2 | ||
24 | import QtQuick.Layouts 1.1 | ||
25 | import org.kube.framework 1.0 as Kube | ||
26 | |||
27 | Item { | ||
28 | id: container | ||
29 | |||
30 | property int visibleViews: 2 | ||
31 | property int currentIndex: 0 | ||
32 | property int count: contentItems.length | ||
33 | default property alias contentItems: content.data | ||
34 | |||
35 | onCurrentIndexChanged: showRelevantSplits() | ||
36 | Component.onCompleted: showRelevantSplits() | ||
37 | |||
38 | function incrementCurrentIndex() { | ||
39 | if (currentIndex < count) { | ||
40 | currentIndex = currentIndex + 1 | ||
41 | } | ||
42 | } | ||
43 | |||
44 | function decrementCurrentIndex() { | ||
45 | if (currentIndex > 0) { | ||
46 | currentIndex = currentIndex - 1 | ||
47 | } | ||
48 | } | ||
49 | |||
50 | function showRelevantSplits() { | ||
51 | var i; | ||
52 | for (i = 0; i < count; i++) { | ||
53 | if (i < currentIndex) { | ||
54 | contentItems[i].visible = false; | ||
55 | } else if (i > (currentIndex + visibleViews - 1)) { | ||
56 | contentItems[i].visible = false; | ||
57 | } else { | ||
58 | contentItems[i].visible = true; | ||
59 | } | ||
60 | } | ||
61 | |||
62 | } | ||
63 | |||
64 | Kube.IconButton { | ||
65 | anchors { | ||
66 | top: container.top | ||
67 | left: container.left | ||
68 | } | ||
69 | z: 1 | ||
70 | background: Rectangle { | ||
71 | anchors.fill: parent | ||
72 | color: Kube.Colors.textColor | ||
73 | } | ||
74 | iconName: Kube.Icons.goBack_inverted | ||
75 | visible: currentIndex > 0 | ||
76 | onClicked: decrementCurrentIndex() | ||
77 | } | ||
78 | |||
79 | RowLayout { | ||
80 | id: content | ||
81 | anchors.fill: parent | ||
82 | } | ||
83 | } | ||