Changeset View
Changeset View
Standalone View
Standalone View
applets/notes/package/contents/ui/configAppearance.qml
Show All 12 Lines | |||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | 15 | * GNU General Public License for more details. | ||
16 | * | 16 | * | ||
17 | * You should have received a copy of the GNU General Public License | 17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/> | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/> | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | import QtQuick 2.0 | 21 | import QtQuick 2.5 | ||
22 | import QtQuick.Controls 1.3 as QtControls | 22 | import QtQuick.Controls 2.5 as QQC2 | ||
23 | import QtQuick.Layouts 1.1 as QtLayouts | | |||
24 | 23 | | |||
24 | import org.kde.kcm 1.1 as KCM | ||||
25 | import org.kde.plasma.core 2.0 as PlasmaCore | 25 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
26 | import org.kde.plasma.components 2.0 as PlasmaComponents | | |||
27 | 26 | | |||
28 | QtLayouts.ColumnLayout { | 27 | KCM.GridView { | ||
29 | id: appearancePage | 28 | id: gridView | ||
30 | 29 | | |||
31 | property string cfg_color | 30 | property string cfg_color | ||
32 | 31 | | |||
33 | PlasmaCore.Svg { | 32 | contentWidth: implicitWidth | ||
34 | id: noteSvg | 33 | contentHeight: implicitHeight | ||
35 | imagePath: "widgets/notes" | | |||
36 | } | | |||
37 | | ||||
38 | SystemPalette { | | |||
39 | id: syspal | | |||
40 | } | | |||
41 | | ||||
42 | QtControls.ScrollView { | | |||
43 | id: notesView | | |||
44 | QtLayouts.Layout.fillWidth: true | | |||
45 | QtLayouts.Layout.fillHeight: true | | |||
46 | frameVisible: true | | |||
47 | verticalScrollBarPolicy: Qt.ScrollBarAlwaysOn // otherwise we get stuck in a re-layout loop | | |||
48 | horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff | | |||
49 | | ||||
50 | GridView { | | |||
51 | id: notesGrid | | |||
52 | width: notesView.width | | |||
53 | height: notesView.height | | |||
54 | cacheBuffer: 2000 // sometimes GridView gets confused and layouts items *somewhere* | | |||
55 | cellWidth: Math.floor(notesView.viewport.width / 3) | | |||
56 | cellHeight: cellWidth | | |||
57 | model: ["white", "black", "red", "orange", "yellow", "green", "blue", "pink", "translucent", "translucent-light"] | | |||
58 | currentIndex: model.indexOf(cfg_color) | | |||
59 | onCurrentIndexChanged: cfg_color = model[currentIndex] | | |||
60 | | ||||
61 | highlight: Rectangle { | | |||
62 | color: syspal.highlight | | |||
63 | } | | |||
64 | highlightMoveDuration: 0 | | |||
65 | | ||||
66 | delegate: MouseArea { | | |||
67 | width: notesGrid.cellWidth | | |||
68 | height: notesGrid.cellHeight | | |||
69 | hoverEnabled: true | | |||
70 | onClicked: notesGrid.currentIndex = index | | |||
71 | 34 | | |||
72 | Rectangle { | 35 | view.model: ["white", "black", "red", "orange", "yellow", "green", "blue", "pink", "translucent", "translucent-light"] | ||
36 | view.currentIndex: view.model.indexOf(cfg_color) | ||||
37 | view.onCurrentIndexChanged: cfg_color = view.model[view.currentIndex] | ||||
38 | | ||||
39 | view.delegate: KCM.GridDelegate { | ||||
40 | id: delegate | ||||
41 | thumbnailAvailable: true | ||||
42 | thumbnail: PlasmaCore.SvgItem { | ||||
73 | anchors.fill: parent | 43 | anchors.fill: parent | ||
74 | color: syspal.highlight | 44 | anchors.margins: units.gridUnit / 2 | ||
75 | opacity: 0.5 | | |||
76 | visible: parent.containsMouse | | |||
77 | } | | |||
78 | 45 | | |||
79 | PlasmaCore.SvgItem { | 46 | svg: PlasmaCore.Svg { imagePath: "widgets/notes" } | ||
80 | anchors { | | |||
81 | fill: parent | | |||
82 | margins: units.gridUnit / 2 | | |||
83 | } | | |||
84 | svg: noteSvg | | |||
85 | elementId: modelData + "-notes" | 47 | elementId: modelData + "-notes" | ||
86 | 48 | | |||
87 | PlasmaComponents.Label { | 49 | QQC2.Label { | ||
88 | anchors { | 50 | anchors.fill: parent | ||
89 | fill: parent | | |||
90 | //this isn't a frameSVG, the default SVG margins take up around 7% of the frame size, so we use that | | |||
91 | margins: parent.width * 0.07 | | |||
92 | } | | |||
93 | horizontalAlignment: Text.AlignHCenter | 51 | horizontalAlignment: Text.AlignHCenter | ||
94 | verticalAlignment: Text.AlignVCenter | 52 | verticalAlignment: Text.AlignVCenter | ||
95 | wrapMode: Text.WordWrap | 53 | | ||
54 | text: (modelData == "translucent-light") ? i18n("A translucent sticky note") : i18n("A %1 sticky note", modelData) | ||||
96 | elide: Text.ElideRight | 55 | elide: Text.ElideRight | ||
97 | text: { | 56 | wrapMode: Text.WordWrap | ||
98 | switch (modelData) { | 57 | | ||
99 | case "white": return i18n("A white sticky note") | | |||
100 | case "black": return i18n("A black sticky note") | | |||
101 | case "red": return i18n("A red sticky note") | | |||
102 | case "orange": return i18n("An orange sticky note") | | |||
103 | case "yellow": return i18n("A yellow sticky note") | | |||
104 | case "green": return i18n("A green sticky note") | | |||
105 | case "blue": return i18n("A blue sticky note") | | |||
106 | case "pink": return i18n("A pink sticky note") | | |||
107 | case "translucent": return i18n("A translucent sticky note") | | |||
108 | case "translucent-light": return i18n("A translucent sticky note with light text") | | |||
109 | } | | |||
110 | } | | |||
111 | //this is deliberately _NOT_ the theme color as we are over a known bright background | 58 | //this is deliberately _NOT_ the theme color as we are over a known bright background | ||
112 | //an unknown colour over a known colour is a bad move as you end up with white on yellow | 59 | //an unknown colour over a known colour is a bad move as you end up with white on yellow | ||
113 | color: { | 60 | color: { | ||
114 | if (modelData === "black" || modelData === "translucent-light") { | 61 | if (modelData == "black" || modelData == "translucent-light") { | ||
davidedmundson: this looks like it's a bad merge | |||||
Fixed in 61ab2de7bf19a496e11085245b2fa65a48bd6408, sorry about that. ngraham: Fixed in 61ab2de7bf19a496e11085245b2fa65a48bd6408, sorry about that. | |||||
115 | return "#dfdfdf" | 62 | return "#dfdfdf" | ||
116 | } else { | 63 | } else { | ||
117 | return "#202020" | 64 | return "#202020" | ||
118 | } | 65 | } | ||
119 | } | 66 | } | ||
120 | } | 67 | } | ||
121 | } | 68 | } | ||
122 | } | 69 | onClicked: { | ||
70 | cfg_color = modelData | ||||
71 | gridView.forceActiveFocus(); | ||||
123 | } | 72 | } | ||
124 | } | 73 | } | ||
125 | } | 74 | } |
this looks like it's a bad merge