Warning, /accessibility/kontrast/src/contents/ui/FavoritePage.qml is written in an unsupported language. File is not indexed.

0001 /**
0002  * SPDX-FileCopyrightText: (C) 2020 Carl Schwan <carl@carlschwan.eu>
0003  * 
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 import QtQuick 2.1
0008 import org.kde.kirigami 2.12 as Kirigami
0009 import QtQuick.Controls 2.14 as QQC2
0010 import QtQuick.Window 2.14
0011 import QtQuick.Layouts 1.14
0012 import org.kde.kontrast.private 1.0
0013 
0014 Kirigami.ScrollablePage {
0015     id: root
0016     title: i18n("Favorite colors")
0017     property bool isMobile: Window.width <= Kirigami.Units.gridUnit * 30
0018     ListView {
0019         id: listview
0020         model: ColorStore
0021         Clipboard {
0022             id: clipboard
0023         }
0024 
0025         spacing: Kirigami.Units.smallSpacing
0026 
0027         delegate: QQC2.ItemDelegate {
0028 
0029             width: ListView.view.width
0030 
0031             background: Rectangle {
0032                 anchors.fill: parent
0033                 color: model.backgroundColor
0034             }
0035 
0036             contentItem: ColumnLayout {
0037                 id: layout
0038                 Kirigami.Heading {
0039                     Layout.fillWidth: true
0040                     level: 3
0041                     text: "Lorem Impsum"
0042                     color: model.textColor
0043                 }
0044 
0045                 Text {
0046                     Layout.fillWidth: true
0047                     text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque et dolor velit. Morbi elementum libero non vehicula porta. Suspendisse potenti. Suspendisse eu sapien lectus."
0048                     wrapMode: Text.WordWrap
0049                     color: model.textColor
0050                 }
0051 
0052                 Text {
0053                     text: i18n("Text: %1", model.textColor)
0054                     color: model.textColor
0055                     MouseArea {
0056                         anchors.fill: parent
0057                         onClicked: copyText();
0058                     }
0059                     Kirigami.Icon {
0060                         anchors.left: parent.right
0061                         height: parent.height
0062                         width: parent.height
0063                         source: "edit-copy"
0064                         color: model.textColor
0065                         MouseArea {
0066                             anchors.fill: parent
0067                             onClicked: copyText(model.textColor);
0068                         }
0069                     }
0070                 }
0071 
0072                 Text {
0073                     text: i18n("Background: %1", model.backgroundColor)
0074                     color: model.textColor
0075 
0076                     MouseArea {
0077                         anchors.fill: parent
0078                         onClicked: copyBackground();
0079                     }
0080                     Kirigami.Icon {
0081                         anchors.left: parent.right
0082                         height: parent.height
0083                         width: parent.height
0084                         source: "edit-copy"
0085                         color: model.textColor
0086                         MouseArea {
0087                             anchors.fill: parent
0088                             onClicked: copyBackground(model.backgroundColor);
0089                         }
0090                     }
0091                 }
0092 
0093                 QQC2.Button {
0094                     text: i18n("Remove")
0095                     Layout.topMargin: Kirigami.Units.largeSpacing
0096                     onClicked: {
0097                         ColorStore.removeColor(model.index)
0098                     }
0099                 }
0100             }
0101         }
0102     }
0103     
0104     function copyBackground(colorText) {
0105         clipboard.content = colorText;
0106         inlineMessage.text = i18n("Background color copied to clipboard");
0107         inlineMessage.visible = true;
0108         timer.interval = Kirigami.Units.longDuration
0109         timer.running = true;
0110     }
0111     
0112     function copyText(colorText) {
0113         clipboard.content = colorText;
0114         inlineMessage.text = i18n("Text color copied to clipboard");
0115         inlineMessage.visible = true;
0116         timer.interval = Kirigami.Units.longDuration
0117         timer.running = true;
0118     }
0119     
0120     footer: Kirigami.InlineMessage {
0121         id: inlineMessage
0122         type: Kirigami.MessageType.Information
0123         text: i18n("Color copied to clipboard")
0124         
0125         Timer {
0126             id: timer
0127             interval: Kirigami.Units.longDuration
0128             onTriggered: inlineMessage.visible = false
0129         }
0130     }
0131 }