Warning, /graphics/peruse/src/creator/qml/PageMetaInfo.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * Copyright (C) 2018 Wolthera van Hövell tot Westerflier<griffinvalley@gmail.com>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Lesser General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2.1 of the License, or (at your option) version 3, or any
0008  * later version accepted by the membership of KDE e.V. (or its
0009  * successor approved by the membership of KDE e.V.), which shall
0010  * act as a proxy defined in Section 6 of version 3 of the license.
0011  *
0012  * This library is distributed in the hope that it will be useful,
0013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015  * Lesser General Public License for more details.
0016  *
0017  * You should have received a copy of the GNU Lesser General Public
0018  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0019  *
0020  */
0021 
0022 import QtQuick 2.12
0023 import QtQuick.Layouts 1.4
0024 import QtQuick.Controls 2.12 as QtControls
0025 import QtQuick.Dialogs 1.3
0026 
0027 import org.kde.kirigami 2.13 as Kirigami
0028 /**
0029  * Page that holds an image to edit the frames on.
0030  */
0031 import QtQuick 2.0
0032 
0033 Kirigami.ScrollablePage {
0034     id: root;
0035     title: i18nc("title text for the page meta information editor sheet", "Edit Page Information");
0036     property QtObject page;
0037     property string colorname: "#ffffff";
0038     signal save();
0039 
0040     actions {
0041         main: saveAndCloseAction;
0042     }
0043     Kirigami.Action {
0044         id: saveAndCloseAction;
0045         text: i18nc("Saves the remaining unsaved edited fields and closes the metainfo editor", "Close Editor");
0046         iconName: "dialog-ok";
0047         shortcut: "Esc";
0048         onTriggered: {
0049             root.page.setTitle(defaultTitle.text, "")
0050             root.save();
0051             pageStack.pop();
0052         }
0053     }
0054 
0055     Kirigami.FormLayout {
0056         Layout.fillWidth: true
0057         QtControls.TextField {
0058             id: defaultTitle;
0059             Kirigami.FormData.label: i18nc("label text for the edit field for the page title", "Title");
0060             placeholderText: i18nc("placeholder text for the page title text-input", "Write to add default title");
0061             text: root.page.title("");
0062             onEditingFinished: root.page.setTitle(text, "");
0063         }
0064         QtControls.TextField {
0065             id: pageId;
0066             Kirigami.FormData.label: i18nc("label text for the edit field for the page id", "ID");
0067             placeholderText: i18nc("placeholder text for page ID text-input", "Write to add an ID");
0068             text: root.page.id
0069             onEditingFinished: root.page.id = text
0070         }
0071         QtControls.ComboBox {
0072             id: transition;
0073             Kirigami.FormData.label: i18nc("label text for the edit field for the page transition type", "Transition");
0074             model: root.page.availableTransitions();
0075             currentIndex: root.page.transition!==""?
0076                               root.page.availableTransitions().indexOf(root.page.transition):
0077                               root.page.availableTransitions().indexOf("none");
0078             onActivated: root.page.transition = currentText;
0079         }
0080         Row {
0081             Kirigami.FormData.label: i18nc("label text for the edit field for the page background color", "Background Color");
0082             height: Kirigami.Units.iconSizes.medium;
0083             Rectangle {
0084                 id: pageBackgroundColor;
0085                 height: Kirigami.Units.iconSizes.medium;
0086                 width: Kirigami.Units.iconSizes.huge;
0087                 radius: 3;
0088                 border.color: Kirigami.Theme.disabledTextColor;
0089                 border.width: 1;
0090                 color: root.page.bgcolor !== ""? root.page.bgcolor: root.colorname;
0091                 MouseArea {
0092                     anchors.fill: parent;
0093                     onClicked: {
0094                         backgroundColorDialog.open();
0095 
0096                     }
0097                     hoverEnabled: true;
0098                     onEntered: parent.border.color = Kirigami.Theme.buttonHoverColor;
0099                     onExited: parent.border.color = Kirigami.Theme.disabledTextColor;
0100                 }
0101                 ColorDialog {
0102                     id: backgroundColorDialog
0103                     title: i18nc("@title color choosing dialog","Choose the background color for page");
0104                     color: root.page.bgcolor !== ""? root.page.bgcolor: root.colorname;
0105                     onAccepted: root.page.bgcolor = color;
0106                 }
0107             }
0108         }
0109 
0110         Kirigami.Separator {
0111             Kirigami.FormData.label: i18nc("label text for the edit field for the page frames", "Frames");
0112             Kirigami.FormData.isSection: true
0113         }
0114 
0115         Repeater {
0116             model: page.framePointStrings
0117             delegate: RowLayout {
0118                 Kirigami.FormData.label: i18nc("Comic book panel frame name.", "Frame %1", index+1);
0119                 Layout.fillWidth: true;
0120                 ColumnLayout {
0121                     QtControls.Switch {
0122                         text: i18nc("A switch which lets the user change the background colour of the page when this frame is focused", "Change page background color");
0123                     }
0124                     RowLayout {
0125                         QtControls.Label {
0126                             height: Kirigami.Units.iconSizes.medium;
0127                             text: i18nc("Label from frame background color.", "Background Color:");
0128                         }
0129                         Rectangle {
0130                             height: Kirigami.Units.iconSizes.medium;
0131                             width: Kirigami.Units.iconSizes.huge;
0132                             radius: 3;
0133                             border.color: Kirigami.Theme.disabledTextColor;
0134                             border.width: 1;
0135                             color: page.frame(index).bgcolor !== ""? page.frame(index).bgcolor: pageBackgroundColor.color;
0136                             MouseArea {
0137                                 anchors.fill: parent;
0138                                 onClicked: {
0139                                     frameBackgroundColorDialog.open();
0140                                 }
0141                                 hoverEnabled: true;
0142                                 onEntered: parent.border.color = Kirigami.Theme.buttonHoverColor;
0143                                 onExited: parent.border.color = Kirigami.Theme.disabledTextColor;
0144                             }
0145                             ColorDialog {
0146                                 id: frameBackgroundColorDialog
0147                                 title: i18nc("@title color choosing dialog","Choose background color for this frame");
0148                                 color: page.frame(index).bgcolor !== ""? page.frame(index).bgcolor: pageBackgroundColor.color;
0149                                 onAccepted: page.frame(index).bgcolor = color;
0150                             }
0151                         }
0152                     }
0153                 }
0154                 Item { height: Kirigami.Units.iconSizes.medium; Layout.fillWidth: true; }
0155                 QtControls.ToolButton {
0156                     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
0157                     QtControls.ToolTip.text: i18nc("swap the position of this frame with the previous one", "Move Up");
0158                     icon.name: "go-up"
0159                     display: QtControls.AbstractButton.IconOnly
0160                     onClicked: { page.swapFrames(index, index - 1); }
0161                     enabled: index > 0;
0162                     visible: enabled;
0163                 }
0164                 QtControls.ToolButton {
0165                     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
0166                     QtControls.ToolTip.text: i18nc("swap the position of this frame with the next one", "Move Down");
0167                     icon.name: "go-down"
0168                     display: QtControls.AbstractButton.IconOnly
0169                     onClicked: { page.swapFrames(index, index + 1); }
0170                     enabled: index < page.framePointStrings.length - 1;
0171                     visible: enabled;
0172                 }
0173                 QtControls.ToolButton {
0174                     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
0175                     QtControls.ToolTip.text: i18nc("remove the frame from the page", "Delete Frame");
0176                     icon.name: "list-remove"
0177                     display: QtControls.AbstractButton.IconOnly
0178                     onClicked: page.removeFrame(index);
0179                 }
0180             }
0181         }
0182         Kirigami.Separator {
0183             Kirigami.FormData.label: i18nc("label text for the edit field for the page textareas", "Text Areas");
0184             Kirigami.FormData.isSection: true;
0185         }
0186         Row {
0187             spacing: Kirigami.Units.smallSpacing;
0188             Kirigami.FormData.label: i18nc("Label from textlayer background color.", "Background Color:");
0189             Rectangle {
0190                 height: Kirigami.Units.iconSizes.medium;
0191                 width: Kirigami.Units.iconSizes.huge;
0192                 id: textLayerBgColor;
0193                 radius: 3;
0194                 border.color: Kirigami.Theme.disabledTextColor;
0195                 border.width: 1;
0196                 color: page.textLayer("").bgcolor !== ""? page.textLayer("").bgcolor: pageBackgroundColor.color;
0197                 MouseArea {
0198                     anchors.fill: parent;
0199                     onClicked: {
0200                         textLayerBackgroundColorDialog.open();
0201 
0202                     }
0203                     hoverEnabled: true;
0204                     onEntered: parent.border.color = Kirigami.Theme.buttonHoverColor;
0205                     onExited: parent.border.color = Kirigami.Theme.disabledTextColor;
0206                 }
0207                 ColorDialog {
0208                     id: textLayerBackgroundColorDialog
0209                     title: i18nc("@title color choosing dialog","Choose the background color for all text areas on this page");
0210                     color: page.textLayer("").bgcolor !== ""? page.textLayer("").bgcolor: pageBackgroundColor.color;
0211                     onAccepted: page.textLayer("").bgcolor = color;
0212                 }
0213             }
0214         }
0215         Repeater {
0216             model: page.textLayer("").textareaPointStrings;
0217             delegate: Kirigami.SwipeListItem {
0218                 Layout.fillWidth: true
0219                 height: childrenRect.height
0220                 supportsMouseEvents: true;
0221                 actions: [
0222                     Kirigami.Action {
0223                         text: i18nc("swap the position of this text area with the previous one", "Move Up");
0224                         iconName: "go-up"
0225                         onTriggered: { page.textLayer("").swapTextareas(index, index - 1); }
0226                         enabled: index > 0;
0227                         visible: enabled;
0228                     },
0229                     Kirigami.Action {
0230                         text: i18nc("swap the position of this text area with the next one", "Move Down");
0231                         iconName: "go-down"
0232                         onTriggered: { page.textLayer("").swapTextareas(index, index + 1); }
0233                         enabled: index < page.textLayer("").textareaPointStrings.length - 1;
0234                         visible: enabled;
0235                     },
0236                     Kirigami.Action {
0237                         text: i18nc("remove the text area from the page", "Delete Text Area");
0238                         iconName: "list-remove"
0239                         onTriggered: page.textLayer("").removeTextarea(index);
0240                     }
0241                 ]
0242                 contentItem: Item {
0243                     Layout.fillWidth: true;
0244                     Layout.fillHeight: true;
0245                     QtControls.Label {
0246                         id: textareaLabel;
0247                         text: i18nc("Comic book panel textarea name.", "Text Area %1", index+1);
0248                     }
0249                     QtControls.TextArea {
0250                         anchors {
0251                             top: textareaLabel.bottom;
0252                             topMargin: Kirigami.Units.smallSpacing;
0253                         }
0254                         width:parent.width-Kirigami.Units.iconSizes.huge;
0255                         wrapMode: TextEdit.Wrap
0256                         text: page.textLayer("").textarea(index).paragraphs.join("\n\n");
0257                         onEditingFinished: page.textLayer("").textarea(index).paragraphs = text.split("\n\n");
0258                     }
0259                 }
0260             }
0261         }
0262         Kirigami.Separator {
0263             Kirigami.FormData.label: i18nc("label text for the edit field for the page jumps", "Jumps");
0264             Kirigami.FormData.isSection: true;
0265         }
0266         Repeater {
0267             id: jumpsRepeater;
0268             model: page.jumps
0269             delegate: Kirigami.SwipeListItem {
0270                 Layout.fillWidth: true
0271                 height: childrenRect.height
0272                 supportsMouseEvents: true;
0273                 actions: [
0274                     Kirigami.Action {
0275                         text: i18nc("swap the position of this jump with the previous one", "Move Up");
0276                         iconName: "go-up"
0277                         onTriggered: { page.swapJumps(index, index - 1); }
0278                         enabled: index > 0;
0279                         visible: enabled;
0280                     },
0281                     Kirigami.Action {
0282                         text: i18nc("swap the position of this jump with the next one", "Move Down");
0283                         iconName: "go-down"
0284                         onTriggered: { page.swapJumps(index, index + 1); }
0285                         enabled: index < jumpsRepeater.count - 1;
0286                         visible: enabled;
0287                     },
0288                     Kirigami.Action {
0289                         text: i18nc("remove the jump from the page", "Delete Jump");
0290                         iconName: "list-remove"
0291                         onTriggered: page.removeJump(index);
0292                     }
0293                 ]
0294                 contentItem: Item {
0295                     Layout.fillWidth: true;
0296                     Layout.fillHeight: true;
0297                     QtControls.Label {
0298                         id: jumpLabel;
0299                         text: i18nc("Comic book panel jump name.", "Jump %1", index+1);
0300                     }
0301                     QtControls.Label {
0302                         id: pageIndexLabel;
0303                         anchors {
0304                             top: jumpLabel.bottom;
0305                             topMargin: Kirigami.Units.smallSpacing;
0306                         }
0307                         height: jumpIndexSpin.height;
0308                         text: i18nc("Label from jump page index.", "Page Index:");
0309                     }
0310 
0311                     QtControls.SpinBox {
0312                         anchors {
0313                             top: jumpLabel.bottom;
0314                             topMargin: Kirigami.Units.smallSpacing;
0315                             left: pageIndexLabel.right;
0316                             leftMargin: Kirigami.Units.smallSpacing;
0317                         }
0318                         from: 0;
0319                         to: 99;
0320                         id: jumpIndexSpin;
0321                         value: modelData.pageIndex;
0322                         onValueChanged: {
0323                             if (modelData.pageIndex !== value) {
0324                                 modelData.pageIndex = value;
0325                             }
0326                         }
0327                     }
0328                 }
0329             }
0330         }
0331     }
0332 }