Warning, /graphics/peruse/src/creator/qml/CreateNewBook.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * Copyright (C) 2016 Dan Leinir Turthra Jensen <admin@leinir.dk> 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.Controls 2.12 as QtControls 0024 import QtQuick.Dialogs 1.3 0025 0026 import org.kde.kirigami 2.7 as Kirigami 0027 0028 import org.kde.peruse 0.1 as Peruse 0029 /** 0030 * @brief page with a form for creating a new comic. 0031 * 0032 * It asks for the default title, folder and cover image, 0033 * and when done it open the new book in Book. 0034 */ 0035 Kirigami.Page { 0036 id: root; 0037 property string categoryName: "createNewBook"; 0038 title: i18nc("title of the new book creation page", "Create New Book"); 0039 0040 actions { 0041 main: Kirigami.Action { 0042 text: i18nc("Accept button which will create a new book", "Create Book"); 0043 iconName: "dialog-ok"; 0044 property int splitPos: osIsWindows ? 8 : 7; 0045 onTriggered: { 0046 var filename = newBookModel.createBook(getFolderDlg.folder.toString().substring(splitPos), titleEdit.text, getCoverDlg.fileUrl.toString().substring(splitPos)); 0047 if(filename.length > 0) 0048 { 0049 mainWindow.openBook(filename); 0050 } 0051 } 0052 } 0053 } 0054 Peruse.ArchiveBookModel { 0055 id: newBookModel; 0056 qmlEngine: globalQmlEngine; 0057 } 0058 0059 Column { 0060 id: contentColumn; 0061 width: root.width - (root.leftPadding + root.rightPadding); 0062 height: childrenRect.height; 0063 spacing: Kirigami.Units.smallSpacing; 0064 Kirigami.Heading { 0065 width: parent.width; 0066 height: paintedHeight + Kirigami.Units.smallSpacing * 2; 0067 text: i18nc("label text for the edit field for the book title", "Title"); 0068 } 0069 QtControls.TextField { 0070 id: titleEdit; 0071 width: parent.width; 0072 text: i18nc("Default name for new books", "Untitled"); 0073 } 0074 0075 Kirigami.Heading { 0076 width: parent.width; 0077 height: paintedHeight + Kirigami.Units.smallSpacing * 2; 0078 text: i18nc("label text for the edit field for the file system location for the book", "Folder"); 0079 } 0080 QtControls.Label { 0081 width: parent.width - getFolderButton.width; 0082 text: getFolderDlg.folder; 0083 QtControls.ToolButton { 0084 id: getFolderButton; 0085 anchors.left: parent.right; 0086 height: parent.height; 0087 width: height; 0088 contentItem: Kirigami.Icon { 0089 source: "folder-open-symbolic" 0090 } 0091 onClicked: getFolderDlg.open(); 0092 } 0093 FileDialog { 0094 id: getFolderDlg; 0095 title: i18nc("@title:window folder dialog used to select the location of a new book", "Please Choose the Location for the Book"); 0096 folder: mainWindow.homeDir(); 0097 selectFolder: true; 0098 } 0099 } 0100 0101 Kirigami.Heading { 0102 width: parent.width - getCoverButton.width; 0103 height: paintedHeight + Kirigami.Units.smallSpacing * 2; 0104 text: i18nc("label text for the edit field for the cover image for the book", "Cover Image"); 0105 QtControls.ToolButton { 0106 id: getCoverButton; 0107 anchors.left: parent.right; 0108 height: getFolderButton.height; 0109 width: height; 0110 contentItem: Kirigami.Icon { 0111 source: "folder-open-symbolic" 0112 } 0113 onClicked: getCoverDlg.open(); 0114 } 0115 FileDialog { 0116 id: getCoverDlg; 0117 title: i18nc("@title:window file dialog used to select the cover image for a new book", "Please Choose Your Cover Image"); 0118 folder: mainWindow.homeDir(); 0119 nameFilters: [ 0120 i18nc("File filter option for displaying only jpeg files", "JPEG images %1", "(*.jpg, *.jpeg)"), 0121 i18nc("File filter option for displaying all files", "All files %1", "(*)") 0122 ]; 0123 } 0124 } 0125 Item { 0126 width: parent.width; 0127 height: Kirigami.Units.iconSizes.enormous + Kirigami.Units.smallSpacing; 0128 Image { 0129 anchors.centerIn: parent; 0130 height: Kirigami.Units.iconSizes.enormous; 0131 width: Kirigami.Units.iconSizes.enormous; 0132 asynchronous: true; 0133 fillMode: Image.PreserveAspectFit; 0134 source: getCoverDlg.fileUrl; 0135 } 0136 } 0137 } 0138 }