Warning, /graphics/peruse/src/creator/qml/AddPageArea.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.12 as Kirigami 0028 /** 0029 * @brief a special overlay sheet for adding frames/textareas/jumps 0030 */ 0031 Kirigami.OverlaySheet { 0032 id: root; 0033 signal accepted(int type); 0034 0035 property string imageSource; 0036 0037 property point topLeft; 0038 property point bottomRight; 0039 0040 onBottomRightChanged: { 0041 var widthFull = Math.max(bottomRight.x, topLeft.x) - Math.min(bottomRight.x, topLeft.x); 0042 var heightFull = Math.max(bottomRight.y, topLeft.y) - Math.min(bottomRight.y, topLeft.y); 0043 var baseSize = Math.min(mainWindow.height, mainWindow.width)*0.3; 0044 0045 clipRectangle.height = baseSize; 0046 clipRectangle.width = baseSize*(widthFull/heightFull); 0047 var multiplier = baseSize/heightFull; 0048 if (widthFull > heightFull) { 0049 multiplier = baseSize/widthFull; 0050 clipRectangle.width = baseSize; 0051 clipRectangle.height = baseSize*(heightFull/widthFull); 0052 } 0053 preview.width = preview.sourceSize.width*multiplier; 0054 preview.height = preview.sourceSize.height*multiplier; 0055 preview.x = 0-(topLeft.x*multiplier); 0056 preview.y = 0-(topLeft.y*multiplier); 0057 } 0058 0059 showCloseButton: true 0060 header: Kirigami.Heading { 0061 text: i18nc("title text for the add page area sheet", "Add Page Area"); 0062 Layout.fillWidth: true 0063 elide: Text.ElideRight 0064 } 0065 0066 ColumnLayout { 0067 Rectangle { 0068 id: clipRectangle; 0069 clip:true; 0070 width: Kirigami.Units.iconSizes.huge*3; 0071 height: Kirigami.Units.iconSizes.huge*3; 0072 Layout.alignment: Qt.AlignHCenter; 0073 Image { 0074 id: preview 0075 source: root.imageSource; 0076 } 0077 } 0078 0079 RowLayout { 0080 QtControls.Button { 0081 id: createFrameButton; 0082 Layout.alignment: Qt.AlignLeft; 0083 Layout.fillWidth: true; 0084 text: i18nc("Button which creates a new frame, and closes the dialog", "Create Frame"); 0085 Keys.onReturnPressed: createAndClose(); 0086 onClicked: createAndClose(); 0087 0088 function createAndClose() { 0089 root.accepted(BookPage.FieldTypes.Frame); 0090 root.close(); 0091 } 0092 } 0093 0094 QtControls.Button { 0095 id: createTextareaButton; 0096 Layout.alignment: Qt.AlignCenter; 0097 Layout.fillWidth: true; 0098 text: i18nc("Button which creates new textarea, and closes the dialog", "Create Textarea"); 0099 Keys.onReturnPressed: createAndClose(); 0100 onClicked: createAndClose(); 0101 0102 function createAndClose() { 0103 root.accepted(BookPage.FieldTypes.Textarea); 0104 root.close(); 0105 } 0106 } 0107 0108 QtControls.Button { 0109 id: createJumpButton; 0110 Layout.alignment: Qt.AlignRight; 0111 Layout.fillWidth: true; 0112 text: i18nc("Button which creates a new jump, and closes the dialog", "Create Jump"); 0113 Keys.onReturnPressed: createAndClose(); 0114 onClicked: createAndClose(); 0115 0116 function createAndClose() { 0117 root.accepted(BookPage.FieldTypes.Jump); 0118 root.close(); 0119 } 0120 } 0121 } 0122 } 0123 }