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

0001 /*
0002  * Copyright (C) 2015 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 
0025 import org.kde.kirigami 2.7 as Kirigami
0026 
0027 Item {
0028     id: root;
0029     height: childrenRect.height;
0030 
0031     property string title;
0032     property string text;
0033     property bool removePossible: true;
0034     signal saveRequested();
0035     signal removeRequested();
0036 
0037     onTextChanged: {
0038         if(text !== editor.text) {
0039             editor.text = text;
0040         }
0041     }
0042 
0043     QtControls.Label {
0044         id: titleLabel;
0045         width: parent.width;
0046         height: paintedHeight + Kirigami.Units.smallSpacing * 2;
0047         text: root.title;
0048         QtControls.Button {
0049             id: removeButton;
0050             anchors {
0051                 top: parent.top;
0052                 right: parent.right;
0053             }
0054             height: parent.height;
0055             width: height;
0056             contentItem: Kirigami.Icon {
0057                 source: "list-remove";
0058             }
0059             visible: root.removePossible;
0060             onClicked: root.removeRequested();
0061         }
0062         QtControls.Button {
0063             anchors {
0064                 top: parent.top;
0065                 right: removeButton.visible ? removeButton.left : parent.right;
0066                 rightMargin: removeButton.visible ? Kirigami.Units.smallSpacing : 0;
0067             }
0068             height: parent.height;
0069             width: height;
0070             contentItem: Kirigami.Icon {
0071                 source: "document-save";
0072             }
0073             opacity: editor.text !== root.text;
0074             Behavior on opacity { NumberAnimation { duration: mainWindow.animationDuration; } }
0075             enabled: opacity > 0;
0076             onClicked: {
0077                 root.text = editor.text;
0078                 root.saveRequested();
0079             }
0080         }
0081     }
0082     QtControls.TextField {
0083         id: editor;
0084         width: parent.width;
0085         anchors.top: titleLabel.bottom;
0086     }
0087 }