Debian Codegraph @

tests/manual/imagehandler/main.qml

raw
1 /****************************************************************************
2 **
3 ** Copyright (C) 2018 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the manual tests of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21 ** included in the packaging of this file. Please review the following
22 ** information to ensure the GNU General Public License requirements will
23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24 **
25 ** $QT_END_LICENSE$
26 **
27 ****************************************************************************/
28
29 import QtQuick 2.8
30 import QtQuick.Window 2.0
31
32 Window {
33 id: root
34 width: 480
35 height: 480
36 visible: true
37 Image {
38 id: svgImage
39 source: "large.svg"
40 height: parent.height - column.height
41 width: parent.width
42 sourceSize.height: height
43 sourceSize.width: width
44 MouseArea {
45 anchors.fill: parent
46 onClicked: svgImage.source = "embeddedimage.svg"
47 }
48 }
49 ListModel {
50 id: imageFillModeModel
51 ListElement { text: "Stretch"; fillMode: Image.Stretch }
52 ListElement { text: "Preserve Aspect Fit"; fillMode: Image.PreserveAspectFit }
53 ListElement { text: "Preserve Aspect Crop"; fillMode: Image.PreserveAspectCrop }
54 ListElement { text: "Tile"; fillMode: Image.Tile }
55 ListElement { text: "Tile Vertically"; fillMode: Image.TileVertically }
56 ListElement { text: "Tile Horizontally"; fillMode: Image.TileHorizontally }
57 ListElement { text: "Pad"; fillMode: Image.Pad }
58 }
59 Column {
60 id: column
61 height: 75
62 anchors.bottom: parent.bottom
63 Text {
64 text: "Click the options below to change the fill mode.<br>Click the image to change the used image."
65 font.pointSize: 16
66 }
67
68 Row {
69 id: checkBoxesRow
70 width: parent.width
71 Repeater {
72 model: imageFillModeModel
73 Rectangle {
74 color: "lightGreen"
75 height: 50
76 width: 100
77 Text {
78 text: model.text
79 wrapMode: Text.Wrap
80 font.pointSize: 16
81 anchors.fill: parent
82 MouseArea {
83 anchors.fill: parent
84 onClicked: {
85 svgImage.fillMode = model.fillMode
86 if (svgImage.fillMode === Image.Tile || svgImage.fillMode === Image.TileHorizontally ||
87 svgImage.fillMode === Image.TileVertically)
88 svgImage.sourceSize.height = svgImage.sourceSize.width = 300
89 else {
90 svgImage.sourceSize.height = svgImage.height
91 svgImage.sourceSize.width = svgImage.width
92 }
93 }
94 }
95 }
96 }
97 }
98 }
99 }
100 }