1/* 2 * Copyright (C) 2018 Wolthera van Hövell tot Westerflier<griffinvalley@gmail.com> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) version 3, or any 8 * later version accepted by the membership of KDE e.V. (or its 9 * successor approved by the membership of KDE e.V.), which shall 10 * act as a proxy defined in Section 6 of version 3 of the license. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 19 * 20 */ 21 22import QtQuick 2.12 23import QtQuick.Layouts 1.4 24import QtQuick.Controls 2.12 as QtControls 25import QtQuick.Dialogs 1.3 26 27import org.kde.kirigami 2.13 as Kirigami 28/** 29 * Page that holds an image to edit the frames on. 30 */ 31import QtQuick 2.0 32 33Kirigami.ScrollablePage { 34 id: root; 35 title: i18nc("title text for the page meta information editor sheet", "Edit Page Information"); 36 property QtObject page; 37 property string colorname: "#ffffff"; 38 signal save(); 39 40 actions { 41 main: saveAndCloseAction; 42 } 43 Kirigami.Action { 44 id: saveAndCloseAction; 45 text: i18nc("Saves the remaining unsaved edited fields and closes the metainfo editor", "Close Editor"); 46 iconName: "dialog-ok"; 47 shortcut: "Esc"; 48 onTriggered: { 49 root.page.setTitle(defaultTitle.text, "") 50 root.save(); 51 pageStack.pop(); 52 } 53 } 54 55 Kirigami.FormLayout { 56 Layout.fillWidth: true 57 QtControls.TextField { 58 id: defaultTitle; 59 Kirigami.FormData.label: i18nc("label text for the edit field for the page title", "Title"); 60 placeholderText: i18nc("placeholder text for default page text-input", "Write to add default title"); 61 text: root.page.title(""); 62 onEditingFinished: root.page.setTitle(text, ""); 63 } 64 QtControls.ComboBox { 65 id: transition; 66 Kirigami.FormData.label: i18nc("label text for the edit field for the page transition type", "Transition"); 67 model: root.page.availableTransitions(); 68 currentIndex: root.page.transition!==""? 69 root.page.availableTransitions().indexOf(root.page.transition): 70 root.page.availableTransitions().indexOf("none"); 71 onActivated: root.page.transition = currentText; 72 } 73 Row { 74 Kirigami.FormData.label: i18nc("label text for the edit field for the page background color", "Background Color"); 75 height: Kirigami.Units.iconSizes.medium; 76 Rectangle { 77 id: pageBackgroundColor; 78 height: Kirigami.Units.iconSizes.medium; 79 width: Kirigami.Units.iconSizes.huge; 80 radius: 3; 81 border.color: Kirigami.Theme.disabledTextColor; 82 border.width: 1; 83 color: root.page.bgcolor !== ""? root.page.bgcolor: root.colorname; 84 MouseArea { 85 anchors.fill: parent; 86 onClicked: { 87 backgroundColorDialog.open(); 88 89 } 90 hoverEnabled: true; 91 onEntered: parent.border.color = Kirigami.Theme.buttonHoverColor; 92 onExited: parent.border.color = Kirigami.Theme.disabledTextColor; 93 } 94 ColorDialog { 95 id: backgroundColorDialog 96 title: i18nc("@title color choosing dialog","Choose the background color for page"); 97 color: root.page.bgcolor !== ""? root.page.bgcolor: root.colorname; 98 onAccepted: root.page.bgcolor = color; 99 } 100 } 101 } 102 103 Kirigami.Separator { 104 Kirigami.FormData.label: i18nc("label text for the edit field for the page frames", "Frames"); 105 Kirigami.FormData.isSection: true 106 } 107 108 Repeater { 109 model: page.framePointStrings 110 delegate: RowLayout { 111 Kirigami.FormData.label: i18nc("Comic book panel frame name.", "Frame %1", index+1); 112 Layout.fillWidth: true; 113 ColumnLayout { 114 QtControls.Switch { 115 text: i18nc("A switch which lets the user change the background colour of the page when this frame is focused", "Change page background color"); 116 117 } 118 RowLayout { 119 QtControls.Label { 120 height: Kirigami.Units.iconSizes.medium; 121 text: i18nc("Label from frame background color.", "Background Color:"); 122 } 123 Rectangle { 124 height: Kirigami.Units.iconSizes.medium; 125 width: Kirigami.Units.iconSizes.huge; 126 radius: 3; 127 border.color: Kirigami.Theme.disabledTextColor; 128 border.width: 1; 129 color: page.frame(index).bgcolor !== ""? page.frame(index).bgcolor: pageBackgroundColor.color; 130 MouseArea { 131 anchors.fill: parent; 132 onClicked: { 133 frameBackgroundColorDialog.open(); 134 } 135 hoverEnabled: true; 136 onEntered: parent.border.color = Kirigami.Theme.buttonHoverColor; 137 onExited: parent.border.color = Kirigami.Theme.disabledTextColor; 138 } 139 ColorDialog { 140 id: frameBackgroundColorDialog 141 title: i18nc("@title color choosing dialog","Choose background color for this frame"); 142 color: page.frame(index).bgcolor !== ""? page.frame(index).bgcolor: pageBackgroundColor.color; 143 onAccepted: page.frame(index).bgcolor = color; 144 } 145 } 146 } 147 } 148 Item { height: Kirigami.Units.iconSizes.medium; Layout.fillWidth: true; } 149 QtControls.ToolButton { 150 QtControls.ToolTip.delay: Kirigami.Units.toolTipDelay; QtControls.ToolTip.timeout: 5000; QtControls.ToolTip.visible: parent.visible && (Kirigami.Settings.tabletMode ? pressed : hovered) && QtControls.ToolTip.text.length > 0 151 QtControls.ToolTip.text: i18nc("swap the position of this frame with the previous one", "Move Up"); 152 icon.name: "go-up" 153 display: QtControls.AbstractButton.IconOnly 154 onClicked: { page.swapFrames(index, index - 1); } 155 enabled: index > 0; 156 visible: enabled; 157 } 158 QtControls.ToolButton { 159 QtControls.ToolTip.delay: Kirigami.Units.toolTipDelay; QtControls.ToolTip.timeout: 5000; QtControls.ToolTip.visible: parent.visible && (Kirigami.Settings.tabletMode ? pressed : hovered) && QtControls.ToolTip.text.length > 0 160 QtControls.ToolTip.text: i18nc("swap the position of this frame with the next one", "Move Down"); 161 icon.name: "go-down" 162 display: QtControls.AbstractButton.IconOnly 163 onClicked: { page.swapFrames(index, index + 1); } 164 enabled: index < page.framePointStrings.length - 1; 165 visible: enabled; 166 } 167 QtControls.ToolButton { 168 QtControls.ToolTip.delay: Kirigami.Units.toolTipDelay; QtControls.ToolTip.timeout: 5000; QtControls.ToolTip.visible: parent.visible && (Kirigami.Settings.tabletMode ? pressed : hovered) && QtControls.ToolTip.text.length > 0 169 QtControls.ToolTip.text: i18nc("remove the frame from the page", "Delete Frame"); 170 icon.name: "list-remove" 171 display: QtControls.AbstractButton.IconOnly 172 onClicked: page.removeFrame(index); 173 } 174 } 175 } 176 Kirigami.Separator { 177 Kirigami.FormData.label: i18nc("label text for the edit field for the page textareas", "Text Areas"); 178 Kirigami.FormData.isSection: true; 179 } 180 Row { 181 spacing: Kirigami.Units.smallSpacing; 182 Kirigami.FormData.label: i18nc("Label from textlayer background color.", "Background Color:"); 183 Rectangle { 184 height: Kirigami.Units.iconSizes.medium; 185 width: Kirigami.Units.iconSizes.huge; 186 id: textLayerBgColor; 187 radius: 3; 188 border.color: Kirigami.Theme.disabledTextColor; 189 border.width: 1; 190 color: page.textLayer("").bgcolor !== ""? page.textLayer("").bgcolor: pageBackgroundColor.color; 191 MouseArea { 192 anchors.fill: parent; 193 onClicked: { 194 textLayerBackgroundColorDialog.open(); 195 196 } 197 hoverEnabled: true; 198 onEntered: parent.border.color = Kirigami.Theme.buttonHoverColor; 199 onExited: parent.border.color = Kirigami.Theme.disabledTextColor; 200 } 201 ColorDialog { 202 id: textLayerBackgroundColorDialog 203 title: i18nc("@title color choosing dialog","Choose the background color for all text areas on this page"); 204 color: page.textLayer("").bgcolor !== ""? page.textLayer("").bgcolor: pageBackgroundColor.color; 205 onAccepted: page.textLayer("").bgcolor = color; 206 } 207 } 208 } 209 Repeater { 210 model: page.textLayer("").textareaPointStrings; 211 delegate: Kirigami.SwipeListItem { 212 Layout.fillWidth: true 213 height: childrenRect.height 214 supportsMouseEvents: true; 215 actions: [ 216 Kirigami.Action { 217 text: i18nc("swap the position of this text area with the previous one", "Move Up"); 218 iconName: "go-up" 219 onTriggered: { page.textLayer("").swapTextareas(index, index - 1); } 220 enabled: index > 0; 221 visible: enabled; 222 }, 223 Kirigami.Action { 224 text: i18nc("swap the position of this text area with the next one", "Move Down"); 225 iconName: "go-down" 226 onTriggered: { page.textLayer("").swapTextareas(index, index + 1); } 227 enabled: index < page.textLayer("").textareaPointStrings.length - 1; 228 visible: enabled; 229 }, 230 Kirigami.Action { 231 text: i18nc("remove the text area from the page", "Delete Text Area"); 232 iconName: "list-remove" 233 onTriggered: page.textLayer("").removeTextarea(index); 234 } 235 ] 236 Item { 237 Layout.fillWidth: true; 238 Layout.fillHeight: true; 239 QtControls.Label { 240 id: textareaLabel; 241 text: i18nc("Comic book panel textarea name.", "Text Area %1", index+1); 242 } 243 QtControls.TextArea { 244 anchors { 245 top: textareaLabel.bottom; 246 topMargin: Kirigami.Units.smallSpacing; 247 } 248 width:parent.width-Kirigami.Units.iconSizes.huge; 249 text: page.textLayer("").textarea(index).paragraphs.join("\n\n"); 250 onEditingFinished: page.textLayer("").textarea(index).paragraphs = text.split("\n\n"); 251 } 252 } 253 } 254 } 255 Kirigami.Separator { 256 Kirigami.FormData.label: i18nc("label text for the edit field for the page jumps", "Jumps"); 257 Kirigami.FormData.isSection: true; 258 } 259 Repeater { 260 id: jumpsRepeater; 261 model: page.jumps 262 delegate: Kirigami.SwipeListItem { 263 Layout.fillWidth: true 264 height: childrenRect.height 265 supportsMouseEvents: true; 266 actions: [ 267 Kirigami.Action { 268 text: i18nc("swap the position of this jump with the previous one", "Move Up"); 269 iconName: "go-up" 270 onTriggered: { page.swapJumps(index, index - 1); } 271 enabled: index > 0; 272 visible: enabled; 273 }, 274 Kirigami.Action { 275 text: i18nc("swap the position of this jump with the next one", "Move Down"); 276 iconName: "go-down" 277 onTriggered: { page.swapJumps(index, index + 1); } 278 enabled: index < jumpsRepeater.count - 1; 279 visible: enabled; 280 }, 281 Kirigami.Action { 282 text: i18nc("remove the jump from the page", "Delete Jump"); 283 iconName: "list-remove" 284 onTriggered: page.removeJump(index); 285 } 286 ] 287 Item { 288 Layout.fillWidth: true; 289 Layout.fillHeight: true; 290 QtControls.Label { 291 id: jumpLabel; 292 text: i18nc("Comic book panel jump name.", "Jump %1", index+1); 293 } 294 QtControls.Label { 295 id: pageIndexLabel; 296 anchors { 297 top: jumpLabel.bottom; 298 topMargin: Kirigami.Units.smallSpacing; 299 } 300 height: jumpIndexSpin.height; 301 text: i18nc("Label from jump page index.", "Page Index:"); 302 } 303 304 QtControls.SpinBox { 305 anchors { 306 top: jumpLabel.bottom; 307 topMargin: Kirigami.Units.smallSpacing; 308 left: pageIndexLabel.right; 309 leftMargin: Kirigami.Units.smallSpacing; 310 } 311 from: 0; 312 to: 99; 313 id: jumpIndexSpin; 314 value: modelData.pageIndex; 315 onValueChanged: { 316 if (modelData.pageIndex !== value) { 317 modelData.pageIndex = value; 318 } 319 } 320 } 321 } 322 } 323 } 324 } 325} 326