diff options
Diffstat (limited to 'tests/manual')
155 files changed, 6618 insertions, 1091 deletions
diff --git a/tests/manual/cursorChange/main.qml b/tests/manual/cursorChange/main.qml new file mode 100644 index 0000000000..563545b60d --- /dev/null +++ b/tests/manual/cursorChange/main.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 + +Window { + id: tw + visible: true + width: 800 + height: 500 + color: "green" + Text { + id: txt + font.pointSize: 16 + anchors.top: parent.top + text: "Move to the blue item.\nCheck the mouse cursor is a PointingHand.\nClick on the blue item." + } + + Rectangle { + anchors.centerIn: parent + width: 100 + height: 50 + color: "blue" + MouseArea { + id: testHand + anchors.fill: parent + onClicked: { + tw1.show() + } + cursorShape: Qt.PointingHandCursor + } + } + + Window { + Text { + font.pointSize: 16 + anchors.top: parent.top + text: "Move the cursor to near one of the edges.\nClick the mouse button." + } + id: tw1 + visible: false + width: 800 + height: 500 + color: "yellow" + MouseArea { + anchors.fill: parent + onClicked: { + tw1.close() + txt.text = "Mouse cursor should now be back to an Arrow cursor" + } + } + } +} diff --git a/tests/manual/highdpi/imageprovider.cpp b/tests/manual/highdpi/imageprovider.cpp index 069fa5998f..9f2f6aa872 100644 --- a/tests/manual/highdpi/imageprovider.cpp +++ b/tests/manual/highdpi/imageprovider.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/tests/manual/imagehandler/embeddedimage.svg b/tests/manual/imagehandler/embeddedimage.svg new file mode 100644 index 0000000000..f952640822 --- /dev/null +++ b/tests/manual/imagehandler/embeddedimage.svg @@ -0,0 +1,10 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" + version="1.2" baseProfile="tiny"> + + <desc>This document has a reference to an external image</desc> + + <image x="200" y="200" width="100" height="100" xlink:href="heart.png"> + <title>External image</title> + </image> +</svg> diff --git a/tests/manual/imagehandler/heart.png b/tests/manual/imagehandler/heart.png Binary files differnew file mode 100644 index 0000000000..deaec18274 --- /dev/null +++ b/tests/manual/imagehandler/heart.png diff --git a/tests/manual/imagehandler/large.svg b/tests/manual/imagehandler/large.svg new file mode 100644 index 0000000000..99b3b67616 --- /dev/null +++ b/tests/manual/imagehandler/large.svg @@ -0,0 +1,462 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> +<svg + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + version="1.0" + width="128" + height="128" + viewBox="0 0 105.427 137.439" + id="Livello_1" + xml:space="preserve" + style="overflow:visible"><defs + id="defs2727"><linearGradient + x1="26.294399" + y1="11.6704" + x2="71.901901" + y2="133.0273" + id="linearGradient3352" + xlink:href="#XMLID_34_" + gradientUnits="userSpaceOnUse" /><linearGradient + x1="36.838902" + y1="7.7075" + x2="82.446297" + y2="129.0645" + id="linearGradient3354" + xlink:href="#XMLID_34_" + gradientUnits="userSpaceOnUse" /><linearGradient + x1="33.882301" + y1="23.583" + x2="39.972198" + y2="23.583" + id="XMLID_34_" + gradientUnits="userSpaceOnUse"> + <stop + id="stop2672" + style="stop-color:#ff5d5d;stop-opacity:1" + offset="0" /> + <stop + id="stop2674" + style="stop-color:#e20800;stop-opacity:1" + offset="1" /> + </linearGradient><linearGradient + x1="33.882301" + y1="23.583" + x2="39.972198" + y2="23.583" + id="linearGradient3368" + xlink:href="#XMLID_34_" + gradientUnits="userSpaceOnUse" /><linearGradient + x1="54.356899" + y1="1.124" + x2="99.964401" + y2="122.481" + id="linearGradient3370" + xlink:href="#XMLID_34_" + gradientUnits="userSpaceOnUse" /><linearGradient + x1="15.8457" + y1="15.5972" + x2="61.453098" + y2="136.9541" + id="linearGradient3376" + xlink:href="#XMLID_34_" + gradientUnits="userSpaceOnUse" /><linearGradient + x1="43.438" + y1="5.2275" + x2="89.045403" + y2="126.5845" + id="linearGradient3382" + xlink:href="#XMLID_34_" + gradientUnits="userSpaceOnUse" /><linearGradient + x1="8.1176996" + y1="14.9019" + x2="70.759598" + y2="117.2331" + id="linearGradient3792" + xlink:href="#XMLID_30_" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.9991,-4.18e-2,4.18e-2,0.9991,-2.4309,1.195)" /><linearGradient + x1="10.5708" + y1="10.1548" + x2="73.2117" + y2="112.4844" + id="linearGradient3794" + xlink:href="#XMLID_30_" + gradientUnits="userSpaceOnUse" /><linearGradient + x1="6.2178001" + y1="72.223602" + x2="79.360802" + y2="72.223602" + id="XMLID_26_" + gradientUnits="userSpaceOnUse" + gradientTransform="translate(0,2.1512354)"> + <stop + id="stop2578" + style="stop-color:#ffffff;stop-opacity:1" + offset="0" /> + <stop + id="stop2580" + style="stop-color:#eeeeec;stop-opacity:1" + offset="1" /> + </linearGradient><filter + id="filter5869"><feGaussianBlur + id="feGaussianBlur5871" + stdDeviation="1.2254964" + inkscape:collect="always" /></filter><filter + id="filter5873"><feGaussianBlur + id="feGaussianBlur5875" + stdDeviation="1.3615922" + inkscape:collect="always" /></filter><filter + id="filter2854"><feGaussianBlur + id="feGaussianBlur2856" + stdDeviation="0.8944793" + inkscape:collect="always" /></filter></defs> +<filter + id="AI_Sfocatura_1"> + <feGaussianBlur + id="feGaussianBlur2545" + stdDeviation="1" /> +</filter> +<g + transform="translate(-3.2052027,3.2058836)" + id="g2547"> + <g + transform="matrix(0.9982563,0,0,0.9982563,-1.5492234e-2,0.2232388)" + id="g2549"> + <g + id="g2551"> + <linearGradient + x1="6.2178001" + y1="68.029297" + x2="79.360802" + y2="68.029297" + id="XMLID_24_" + gradientUnits="userSpaceOnUse"> + <stop + id="stop2554" + style="stop-color:#ffffff;stop-opacity:1" + offset="0" /> + <stop + id="stop2556" + style="stop-color:#eeeeec;stop-opacity:1" + offset="1" /> + </linearGradient> + <path + d="M 9.542,121.224 C 7.713,121.224 6.217,119.728 6.217,117.9 L 6.217,18.16 C 6.217,16.331 7.713,14.835 9.542,14.835 L 76.036,14.835 C 77.864,14.835 79.36,16.331 79.36,18.16 L 79.36,117.9 C 79.36,119.728 77.864,121.224 76.036,121.224 L 9.542,121.224 z" + id="path2558" + style="fill:url(#XMLID_24_)" /> + </g> + <g + id="g2560"> + <linearGradient + x1="10.5718" + y1="15.3989" + x2="73.212097" + y2="117.7277" + id="XMLID_25_" + gradientUnits="userSpaceOnUse"> + <stop + id="stop2563" + style="stop-color:#77b753;stop-opacity:1" + offset="0" /> + <stop + id="stop2565" + style="stop-color:#00892c;stop-opacity:1" + offset="1" /> + </linearGradient> + <path + d="M 11.204,18.159 C 10.29,18.159 9.542,18.907 9.542,19.821 L 9.542,116.237 C 9.542,117.151 10.29,117.899 11.204,117.899 L 74.375,117.899 C 75.289,117.899 76.037,117.151 76.037,116.237 L 76.037,19.821 C 76.037,18.907 75.289,18.159 74.375,18.159 L 11.204,18.159 z" + id="path2567" + style="fill:url(#XMLID_25_)" /> + </g> + </g> + <g + transform="matrix(0.9982563,0,0,0.9982563,1.05825,0.2232388)" + id="g2569"> + <path + d="M 11.639,126.468 C 9.811,126.468 8.314,124.972 8.314,123.143 L 8.314,23.403 C 8.314,21.574 9.811,20.078 11.639,20.078 L 78.134,20.078 C 79.962,20.078 81.458,21.574 81.458,23.403 L 81.458,123.143 C 81.458,124.972 79.962,126.468 78.134,126.468 L 23.696022,126.468 L 11.639,126.468 z" + transform="matrix(1.041449,0,0,1,-4.451967,3.1512354)" + id="path2575" + style="opacity:0.6;filter:url(#filter2854)" /><path + d="M 9.542,127.56924 C 7.714,127.56924 6.218,126.07324 6.218,124.24624 L 6.218,24.505236 C 6.218,22.677236 7.714,21.181236 9.542,21.181236 L 76.037,21.181236 C 77.865,21.181236 79.361,22.677236 79.361,24.505236 L 79.361,124.24624 C 79.361,126.07324 77.865,127.56924 76.037,127.56924 L 9.542,127.56924 z" + id="path2582" + style="fill:url(#XMLID_26_)" /> + <g + transform="translate(0,2.1512354)" + id="g2584"> + <g + transform="matrix(1.0276326,0,0,1,-2.2508995,0)" + id="g2586" + style="opacity:0.5;filter:url(#AI_Sfocatura_1)"> + <path + d="M 11.639,123.321 C 9.811,123.321 8.314,121.824 8.314,119.997 L 81.458,119.997 C 81.458,121.824 79.962,123.321 78.134,123.321 L 11.639,123.321 z" + id="path2588" /> + </g> + <linearGradient + x1="6.2178001" + y1="69.078102" + x2="79.360802" + y2="69.078102" + id="XMLID_27_" + gradientUnits="userSpaceOnUse"> + <stop + id="stop2591" + style="stop-color:#ffffff;stop-opacity:1" + offset="0" /> + <stop + id="stop2593" + style="stop-color:#eeeeec;stop-opacity:1" + offset="1" /> + </linearGradient> + <path + d="M 9.542,122.272 C 7.714,122.272 6.218,120.776 6.218,118.947 L 6.218,19.207 C 6.218,17.378 7.714,15.882 9.542,15.882 L 76.037,15.882 C 77.865,15.882 79.361,17.378 79.361,19.207 L 79.361,118.947 C 79.361,120.776 77.865,122.272 76.037,122.272 L 9.542,122.272 z" + id="path2595" + style="fill:url(#XMLID_27_)" /> + </g> + <g + transform="translate(0,3.2268531)" + id="g2597"> + <g + transform="matrix(1.0368435,0,0,1,-3.0011994,-1.0756177)" + id="g2599" + style="opacity:0.5;filter:url(#AI_Sfocatura_1)"> + <path + d="M 11.639,120.175 C 9.811,120.175 8.314,118.679 8.314,116.85 L 81.458,116.85 C 81.458,118.679 79.962,120.175 78.134,120.175 L 11.639,120.175 z" + id="path2601" /> + </g> + <linearGradient + x1="6.2178001" + y1="65.931602" + x2="79.360802" + y2="65.931602" + id="XMLID_28_" + gradientUnits="userSpaceOnUse" + gradientTransform="translate(0,-1.0756177)"> + <stop + id="stop2604" + style="stop-color:#ffffff;stop-opacity:1" + offset="0" /> + <stop + id="stop2606" + style="stop-color:#eeeeec;stop-opacity:1" + offset="1" /> + </linearGradient> + <path + d="M 9.542,118.05038 C 7.714,118.05038 6.218,116.55438 6.218,114.72638 L 6.218,14.986382 C 6.218,13.157382 7.714,11.661382 9.542,11.661382 L 76.037,11.661382 C 77.865,11.661382 79.361,13.157382 79.361,14.986382 L 79.361,114.72638 C 79.361,116.55438 77.865,118.05038 76.037,118.05038 L 9.542,118.05038 z" + id="path2608" + style="fill:url(#XMLID_28_)" /> + </g> + <g + transform="translate(0,1.8317954)" + id="g2610"> + <g + transform="matrix(1.0184218,0,0,1.0158314,-1.4821779,-1.8527316)" + id="g2612" + style="opacity:0.5;filter:url(#AI_Sfocatura_1)"> + <path + d="M 10.639,117.029 C 8.811,117.029 7.314,115.532 7.314,113.704 L 7.314,13.964 C 7.314,12.135 8.811,10.639 10.639,10.639 L 77.134,10.639 C 78.962,10.639 80.458,12.135 80.458,13.964 L 80.458,113.704 C 80.458,115.532 78.962,117.029 77.134,117.029 L 10.639,117.029 z" + id="path2614" /> + </g> + <linearGradient + x1="6.2178001" + y1="62.785599" + x2="79.360802" + y2="62.785599" + id="XMLID_29_" + gradientUnits="userSpaceOnUse"> + <stop + id="stop2617" + style="stop-color:#ffffff;stop-opacity:1" + offset="0" /> + <stop + id="stop2619" + style="stop-color:#eeeeec;stop-opacity:1" + offset="1" /> + </linearGradient> + <path + d="M 9.542,115.98 C 7.714,115.98 6.218,114.483 6.218,112.656 L 6.218,12.916 C 6.218,11.087 7.714,9.591 9.542,9.591 L 76.037,9.591 C 77.865,9.591 79.361,11.087 79.361,12.916 L 79.361,112.657 C 79.361,114.484 77.865,115.981 76.037,115.981 L 9.542,115.981 L 9.542,115.98 z" + id="path2621" + style="fill:url(#XMLID_29_)" /> + <linearGradient + x1="10.5708" + y1="10.1548" + x2="73.2117" + y2="112.4844" + id="XMLID_30_" + gradientUnits="userSpaceOnUse"> + <stop + id="stop2624" + style="stop-color:#73bdf2;stop-opacity:1" + offset="0" /> + <stop + id="stop2626" + style="stop-color:#3592ee;stop-opacity:1" + offset="1" /> + </linearGradient> + <path + d="M 11.204,12.916 C 10.289,12.916 9.541,13.664 9.541,14.578 L 9.541,110.994 C 9.541,111.909 10.289,112.657 11.204,112.657 L 74.373,112.657 C 75.288,112.657 76.036,111.909 76.036,110.994 L 76.036,14.578 C 76.036,13.664 75.288,12.916 74.373,12.916 L 11.204,12.916 L 11.204,12.916 z" + id="path2628" + style="fill:url(#linearGradient3794)" /> + </g> + </g> + <g + transform="matrix(0.9961334,-6.5068755e-2,6.5068755e-2,0.9961334,-5.7493275,-6.3015051)" + id="g2630"> + <g + transform="matrix(1.0311837,0,0,1.0154411,-2.8218065,-1.9088007)" + id="g2632" + style="opacity:0.6;filter:url(#filter5869)"> + <path + d="M 10.744,123.615 C 8.917,123.691 7.36,122.259 7.283,120.432 L 3.118,20.779 C 3.042,18.952 4.474,17.395 6.301,17.319 L 72.737,14.542 C 74.563,14.465 76.121,15.898 76.198,17.725 L 80.363,117.377 C 80.439,119.204 79.007,120.761 77.181,120.839 L 10.744,123.615 z" + id="path2634" /> + </g> + <g + id="g2636"> + + <linearGradient + x1="3.7607" + y1="67.532204" + x2="76.909698" + y2="67.532204" + id="XMLID_31_" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.9991,-4.18e-2,4.18e-2,0.9991,-2.4309,1.195)"> + <stop + id="stop2639" + style="stop-color:#ffffff;stop-opacity:1" + offset="0" /> + <stop + id="stop2641" + style="stop-color:#eeeeec;stop-opacity:1" + offset="1" /> + </linearGradient> + <path + d="M 9.695,121.518 C 7.868,121.595 6.311,120.163 6.234,118.335 L 2.069,18.682 C 1.993,16.855 3.425,15.298 5.252,15.222 L 71.688,12.444 C 73.514,12.368 75.072,13.8 75.149,15.627 L 79.314,115.28 C 79.391,117.106 77.959,118.663 76.131,118.741 L 9.695,121.518 z" + id="path2643" + style="fill:url(#XMLID_31_)" /> + </g> + <path + d="M 7.051,18.474 C 6.138,18.513 5.422,19.291 5.46,20.204 L 9.486,116.535 C 9.525,117.448 10.303,118.164 11.217,118.126 L 74.331,115.489 C 75.244,115.451 75.96,114.672 75.922,113.759 L 71.897,17.427 C 71.859,16.513 71.08,15.797 70.167,15.836 L 7.051,18.474 z" + id="path2652" + style="fill:url(#linearGradient3792);fill-opacity:1" /> + <path + d="M 9.5625,22.375 C 10.84375,52.927083 12.125,83.479167 13.40625,114.03125 C 32.885417,113.21875 52.364583,112.40625 71.84375,111.59375 C 70.5625,81.041667 69.28125,50.489583 68,19.9375 C 48.520833,20.75 29.041667,21.5625 9.5625,22.375 z" + id="path4189" + style="opacity:0.6;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:1.00000001, 1.00000001;stroke-dashoffset:0;stroke-opacity:1" /></g> + <g + transform="matrix(0.9982563,0,0,0.9982563,10.72193,-5.1454722)" + id="g2654"> + <g + transform="translate(-4.2156998e-8,1.0756177)" + id="g2656" + style="opacity:0.6;filter:url(#filter5873)"> + <path + d="M 10.854785,112.52047 C 9.0174891,112.09656 7.8676311,110.2731 8.2990859,108.46891 L 31.839177,9.9940152 C 32.271664,8.1888112 34.127539,7.0580233 35.964835,7.481942 L 102.78149,22.901224 C 104.61776,23.325142 105.76865,25.149615 105.33616,26.954819 L 81.79607,125.42768 C 81.364615,127.23289 79.507708,128.36368 77.671444,127.93976 L 10.854785,112.52047 z" + id="path2658" /> + </g> + <g + id="g2660"> + + <linearGradient + x1="16.688499" + y1="-8.9546003" + x2="94.108398" + y2="105.6356" + id="XMLID_33_" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.9735,0.2287,-0.2287,0.9735,14.4454,7.996)"> + <stop + id="stop2663" + style="stop-color:#ffffff;stop-opacity:1" + offset="0" /> + <stop + id="stop2665" + style="stop-color:#eeeeec;stop-opacity:1" + offset="1" /> + </linearGradient> + <path + d="M 12.707,111.688 C 10.927,111.271 9.813,109.472 10.231,107.692 L 33.037,10.593 C 33.455,8.813 35.254,7.698 37.034,8.116 L 101.767,23.32 C 103.546,23.738 104.661,25.537 104.243,27.317 L 81.436,124.415 C 81.019,126.195 79.219,127.31 77.44,126.892 L 12.707,111.688 z" + id="path2667" + style="fill:url(#XMLID_33_)" /> + </g> + <path + d="M 33.925,25.17 L 35.435,25.3 C 35.369,25.76 35.413,26.134 35.567,26.422 C 35.721,26.71 35.941,26.887 36.226,26.954 C 36.538,27.027 36.832,26.947 37.114,26.715 C 37.396,26.483 37.594,26.116 37.712,25.615 C 37.821,25.149 37.805,24.759 37.661,24.445 C 37.517,24.132 37.298,23.939 37.004,23.87 C 36.811,23.825 36.571,23.817 36.281,23.846 L 36.797,22.386 C 37.187,22.487 37.522,22.455 37.801,22.292 C 38.076,22.127 38.26,21.847 38.353,21.451 C 38.431,21.12 38.41,20.843 38.291,20.618 C 38.172,20.392 37.984,20.25 37.729,20.19 C 37.473,20.13 37.226,20.187 36.987,20.358 C 36.749,20.531 36.562,20.825 36.427,21.24 L 35.104,20.624 C 35.455,19.78 35.886,19.208 36.401,18.909 C 36.915,18.61 37.492,18.536 38.131,18.686 C 38.85,18.855 39.36,19.244 39.663,19.853 C 39.967,20.462 40.045,21.076 39.9,21.695 C 39.802,22.113 39.618,22.468 39.35,22.758 C 39.081,23.049 38.726,23.276 38.287,23.439 C 38.699,23.661 38.996,24.004 39.18,24.471 C 39.362,24.937 39.383,25.471 39.242,26.073 C 39.036,26.949 38.604,27.613 37.948,28.064 C 37.29,28.515 36.601,28.655 35.88,28.486 C 35.189,28.323 34.661,27.944 34.297,27.347 C 33.931,26.751 33.808,26.025 33.925,25.17 z" + id="path2676" + style="fill:url(#linearGradient3368);fill-opacity:1" /> + <linearGradient + x1="26.294399" + y1="11.6704" + x2="71.901901" + y2="133.0273" + id="XMLID_35_" + gradientUnits="userSpaceOnUse"> + <stop + id="stop2679" + style="stop-color:#ff8080;stop-opacity:1" + offset="0" /> + <stop + id="stop2681" + style="stop-color:#e20800;stop-opacity:1" + offset="1" /> + </linearGradient> + <path + d="M 32.977,38.964 C 33.619,37.58 34.903,36.55 35.811,35.945 C 36.752,35.319 37.49,34.55 37.729,33.53 C 38.094,31.979 36.471,30.257 34.621,31.997 C 33.74,29.616 31.507,30.433 31.143,31.984 C 30.903,33.003 31.223,34.019 31.786,35 C 32.329,35.946 33.021,37.439 32.977,38.964 z" + id="path2683" + style="fill:url(#linearGradient3352);fill-opacity:1" /> + <path + d="M 80.223,109.559 L 78.711,109.43 C 78.779,108.969 78.734,108.595 78.58,108.308 C 78.426,108.02 78.205,107.842 77.922,107.776 C 77.61,107.703 77.315,107.782 77.033,108.014 C 76.751,108.246 76.553,108.614 76.433,109.114 C 76.324,109.581 76.341,109.97 76.484,110.284 C 76.629,110.598 76.849,110.79 77.142,110.859 C 77.335,110.904 77.576,110.913 77.865,110.883 L 77.349,112.343 C 76.958,112.242 76.624,112.274 76.345,112.439 C 76.07,112.603 75.886,112.883 75.792,113.279 C 75.714,113.609 75.735,113.887 75.854,114.112 C 75.973,114.339 76.161,114.481 76.416,114.541 C 76.672,114.602 76.918,114.545 77.156,114.372 C 77.394,114.2 77.582,113.906 77.717,113.49 L 79.039,114.106 C 78.689,114.95 78.258,115.521 77.742,115.82 C 77.228,116.119 76.652,116.193 76.013,116.043 C 75.294,115.874 74.783,115.486 74.48,114.876 C 74.175,114.268 74.097,113.653 74.244,113.034 C 74.342,112.616 74.525,112.262 74.795,111.971 C 75.063,111.681 75.418,111.453 75.857,111.289 C 75.445,111.069 75.146,110.725 74.964,110.259 C 74.78,109.793 74.761,109.259 74.902,108.657 C 75.109,107.78 75.541,107.117 76.197,106.666 C 76.855,106.216 77.543,106.075 78.265,106.244 C 78.956,106.406 79.484,106.786 79.849,107.382 C 80.217,107.978 80.34,108.704 80.223,109.559 z" + id="path2694" + style="fill:#e20800;fill-opacity:1" /><path + d="M 81.063,95.83 C 80.422,97.214 79.138,98.244 78.23,98.85 C 77.29,99.477 76.55,100.246 76.311,101.264 C 75.947,102.815 77.57,104.536 79.419,102.797 C 80.301,105.178 82.533,104.361 82.898,102.811 C 83.138,101.791 82.819,100.776 82.255,99.795 C 81.711,98.849 81.021,97.355 81.063,95.83 z" + id="path2701" + style="fill:url(#linearGradient3382);fill-opacity:1" /> + <linearGradient + x1="54.356899" + y1="1.124" + x2="99.964401" + y2="122.481" + id="XMLID_39_" + gradientUnits="userSpaceOnUse"> + <stop + id="stop2704" + style="stop-color:#ff8080;stop-opacity:1" + offset="0" /> + <stop + id="stop2706" + style="stop-color:#e20800;stop-opacity:1" + offset="1" /> + </linearGradient> + <path + d="M 63.174,42.222 C 64.361,39.656 66.742,37.748 68.427,36.625 C 70.171,35.463 71.54,34.04 71.985,32.15 C 72.66,29.274 69.651,26.081 66.22,29.307 C 64.585,24.892 60.448,26.406 59.772,29.281 C 59.329,31.172 59.921,33.055 60.965,34.873 C 61.97,36.628 63.253,39.396 63.174,42.222 z" + id="path2708" + style="fill:url(#linearGradient3370);fill-opacity:1" /> + <linearGradient + x1="36.838902" + y1="7.7075" + x2="82.446297" + y2="129.0645" + id="XMLID_40_" + xlink:href="#XMLID_39_" + gradientUnits="userSpaceOnUse"> + <stop + id="stop2711" + style="stop-color:#ff8080;stop-opacity:1" + offset="0" /> + <stop + id="stop2713" + style="stop-color:#e20800;stop-opacity:1" + offset="1" /> + </linearGradient> + <path + d="M 55.486,74.959 C 56.672,72.393 59.054,70.485 60.737,69.362 C 62.481,68.2 63.851,66.777 64.296,64.886 C 64.97,62.01 61.962,58.818 58.532,62.043 C 56.897,57.628 52.759,59.142 52.082,62.018 C 51.638,63.908 52.23,65.792 53.275,67.609 C 54.281,69.364 55.565,72.132 55.486,74.959 z" + id="path2715" + style="fill:url(#linearGradient3354);fill-opacity:1" /> + <path + d="M 51.37,92.488 C 50.182,95.054 47.801,96.961 46.117,98.084 C 44.373,99.246 43.004,100.67 42.559,102.561 C 41.884,105.436 44.893,108.627 48.323,105.404 C 49.958,109.82 54.096,108.304 54.772,105.428 C 55.217,103.538 54.623,101.655 53.579,99.836 C 52.573,98.082 51.291,95.314 51.37,92.488 z" + id="path2724" + style="fill:url(#linearGradient3376);fill-opacity:1" /> + </g> +</g> +</svg> diff --git a/tests/manual/imagehandler/main.qml b/tests/manual/imagehandler/main.qml new file mode 100644 index 0000000000..ec474e62ce --- /dev/null +++ b/tests/manual/imagehandler/main.qml @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.8 +import QtQuick.Window 2.0 + +Window { + id: root + width: 480 + height: 480 + visible: true + Image { + id: svgImage + source: "large.svg" + height: parent.height - column.height + width: parent.width + sourceSize.height: height + sourceSize.width: width + MouseArea { + anchors.fill: parent + onClicked: svgImage.source = "embeddedimage.svg" + } + } + ListModel { + id: imageFillModeModel + ListElement { text: "Stretch"; fillMode: Image.Stretch } + ListElement { text: "Preserve Aspect Fit"; fillMode: Image.PreserveAspectFit } + ListElement { text: "Preserve Aspect Crop"; fillMode: Image.PreserveAspectCrop } + ListElement { text: "Tile"; fillMode: Image.Tile } + ListElement { text: "Tile Vertically"; fillMode: Image.TileVertically } + ListElement { text: "Tile Horizontally"; fillMode: Image.TileHorizontally } + ListElement { text: "Pad"; fillMode: Image.Pad } + } + Column { + id: column + height: 75 + anchors.bottom: parent.bottom + Text { + text: "Click the options below to change the fill mode.<br>Click the image to change the used image." + font.pointSize: 16 + } + + Row { + id: checkBoxesRow + width: parent.width + Repeater { + model: imageFillModeModel + Rectangle { + color: "lightGreen" + height: 50 + width: 100 + Text { + text: model.text + wrapMode: Text.Wrap + font.pointSize: 16 + anchors.fill: parent + MouseArea { + anchors.fill: parent + onClicked: { + svgImage.fillMode = model.fillMode + if (svgImage.fillMode === Image.Tile || svgImage.fillMode === Image.TileHorizontally || + svgImage.fillMode === Image.TileVertically) + svgImage.sourceSize.height = svgImage.sourceSize.width = 300 + else { + svgImage.sourceSize.height = svgImage.height + svgImage.sourceSize.width = svgImage.width + } + } + } + } + } + } + } + } +} diff --git a/tests/manual/qmlplugindump/tests/dumper/Imports/imports.h b/tests/manual/mousearea/main.cpp index 3854a042d2..ea41cb521a 100644 --- a/tests/manual/qmlplugindump/tests/dumper/Imports/imports.h +++ b/tests/manual/mousearea/main.cpp @@ -1,9 +1,9 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2018 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** -** This file is part of the test suite of the Qt Toolkit. +** This file is part of the manual tests of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage @@ -25,20 +25,31 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - -#ifndef IMPORTS_H -#define IMPORTS_H - +#include <QGuiApplication> +#include <QQmlApplicationEngine> #include <QQuickItem> +#include <QQuickWindow> -class Imports : public QQuickItem +int main(int argc, char *argv[]) { - Q_OBJECT - -public: - Imports(QQuickItem *parent = 0); - ~Imports(); -}; + QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QGuiApplication app(argc, argv); -#endif // IMPORTS_H + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + if (!app.arguments().isEmpty()) { + QQuickWindow *win = static_cast<QQuickWindow *>(engine.rootObjects().first()); + auto lastArg = app.arguments().last(); + if (lastArg.endsWith(QLatin1String(".qml"))) { + auto root = win->findChild<QQuickItem *>("LauncherList"); + int showExampleIdx = -1; + for (int i = root->metaObject()->methodCount(); showExampleIdx < 0 && i >= 0; --i) + if (root->metaObject()->method(i).name() == QByteArray("showExample")) + showExampleIdx = i; + QMetaMethod showExampleFn = root->metaObject()->method(showExampleIdx); + showExampleFn.invoke(root, Q_ARG(QVariant, QVariant(QLatin1String("../../") + lastArg))); + } + } + return app.exec(); +} diff --git a/tests/manual/qmlplugindump/tests/dumper/Imports/imports_plugin.cpp b/tests/manual/mousearea/main.qml index ec6e56ca33..9a3243b670 100644 --- a/tests/manual/qmlplugindump/tests/dumper/Imports/imports_plugin.cpp +++ b/tests/manual/mousearea/main.qml @@ -1,9 +1,9 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2018 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** -** This file is part of the test suite of the Qt Toolkit. +** This file is part of the manual tests of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage @@ -26,15 +26,20 @@ ** ****************************************************************************/ -#include "imports_plugin.h" -#include "imports.h" +import QtQuick 2.12 +import QtQuick.Window 2.2 +import "qrc:/quick/shared/" as Examples -#include <qqml.h> - -void ImportsPlugin::registerTypes(const char *uri) -{ - // @uri tests.dumper.imports - qmlRegisterType<Imports>(uri, 1, 0, "Imports"); +Window { + width: 800 + height: 600 + visible: true + Examples.LauncherList { + id: ll + objectName: "LauncherList" + anchors.fill: parent + Component.onCompleted: { + addExample("plain mouse area", "Plain mouse area for testing flags passed from mouse event", Qt.resolvedUrl("plainMouseArea.qml")) + } + } } - - diff --git a/tests/manual/mousearea/mousearea.pro b/tests/manual/mousearea/mousearea.pro new file mode 100644 index 0000000000..3705d41df0 --- /dev/null +++ b/tests/manual/mousearea/mousearea.pro @@ -0,0 +1,7 @@ +TEMPLATE = app + +QT += qml quick + +SOURCES += main.cpp + +RESOURCES += qml.qrc ../../../examples/quick/shared/quick_shared.qrc diff --git a/tests/manual/mousearea/plainMouseArea.qml b/tests/manual/mousearea/plainMouseArea.qml new file mode 100644 index 0000000000..4f37b0635f --- /dev/null +++ b/tests/manual/mousearea/plainMouseArea.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.11 + +Rectangle { + id: root + width: 480 + height: 480 + color: "white" + Text { + id: pressedLabel + x: 0 + y: 0 + width: 480 + height: 50 + font.pointSize: 18 + } + + MouseArea { + anchors.fill: parent + onPressed: { + pressedLabel.text = "Pressed - " + (mouse.flags === Qt.MouseEventCreatedDoubleClick ? + "Press from double click" : "No flags") + } + } +} diff --git a/tests/manual/mousearea/qml.qrc b/tests/manual/mousearea/qml.qrc new file mode 100644 index 0000000000..870b50ae92 --- /dev/null +++ b/tests/manual/mousearea/qml.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + <file>plainMouseArea.qml</file> + </qresource> +</RCC> diff --git a/tests/manual/nodetypes/Animators.qml b/tests/manual/nodetypes/Animators.qml index 7d8baf1cb8..c582106c5d 100644 --- a/tests/manual/nodetypes/Animators.qml +++ b/tests/manual/nodetypes/Animators.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/tests/manual/nodetypes/Effects.qml b/tests/manual/nodetypes/Effects.qml index 85e7ab7a15..90a30c40d3 100644 --- a/tests/manual/nodetypes/Effects.qml +++ b/tests/manual/nodetypes/Effects.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/tests/manual/nodetypes/Images.qml b/tests/manual/nodetypes/Images.qml index 7c1ba5345b..95e8442690 100644 --- a/tests/manual/nodetypes/Images.qml +++ b/tests/manual/nodetypes/Images.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/tests/manual/nodetypes/Layers.qml b/tests/manual/nodetypes/Layers.qml index 52c8fa8144..755d00d41a 100644 --- a/tests/manual/nodetypes/Layers.qml +++ b/tests/manual/nodetypes/Layers.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/tests/manual/nodetypes/LotsOfImages.qml b/tests/manual/nodetypes/LotsOfImages.qml index 38356a3390..72c36aba01 100644 --- a/tests/manual/nodetypes/LotsOfImages.qml +++ b/tests/manual/nodetypes/LotsOfImages.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/tests/manual/nodetypes/LotsOfRects.qml b/tests/manual/nodetypes/LotsOfRects.qml index 46a05a2453..e54174f10c 100644 --- a/tests/manual/nodetypes/LotsOfRects.qml +++ b/tests/manual/nodetypes/LotsOfRects.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/tests/manual/nodetypes/Painter.qml b/tests/manual/nodetypes/Painter.qml index a5973379f4..c5db3496f8 100644 --- a/tests/manual/nodetypes/Painter.qml +++ b/tests/manual/nodetypes/Painter.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/tests/manual/nodetypes/Rects.qml b/tests/manual/nodetypes/Rects.qml index 0d3a8cd459..7f12d118dd 100644 --- a/tests/manual/nodetypes/Rects.qml +++ b/tests/manual/nodetypes/Rects.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/tests/manual/nodetypes/Text.qml b/tests/manual/nodetypes/Text.qml index fb0c92cb10..58befe8c49 100644 --- a/tests/manual/nodetypes/Text.qml +++ b/tests/manual/nodetypes/Text.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/tests/manual/nodetypes/main.qml b/tests/manual/nodetypes/main.qml index a9fe09972c..9f1a5c5e9c 100644 --- a/tests/manual/nodetypes/main.qml +++ b/tests/manual/nodetypes/main.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/tests/manual/nodetypes/nodetypes.cpp b/tests/manual/nodetypes/nodetypes.cpp index c5382bab4a..287574f25c 100644 --- a/tests/manual/nodetypes/nodetypes.cpp +++ b/tests/manual/nodetypes/nodetypes.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the demonstration applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/tests/manual/qmlplugindump/tests/dumper/Imports/imports.cpp b/tests/manual/pointer/content/CheckBox.qml index d2296ce6ba..3702457ee9 100644 --- a/tests/manual/qmlplugindump/tests/dumper/Imports/imports.cpp +++ b/tests/manual/pointer/content/CheckBox.qml @@ -1,9 +1,9 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2018 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** -** This file is part of the test suite of the Qt Toolkit. +** This file is part of the manual tests of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage @@ -26,19 +26,19 @@ ** ****************************************************************************/ -#include "imports.h" +import QtQuick 2.12 -Imports::Imports(QQuickItem *parent): - QQuickItem(parent) -{ - // By default, QQuickItem does not draw anything. If you subclass - // QQuickItem to create a visual item, you will need to uncomment the - // following line and re-implement updatePaintNode() - - // setFlag(ItemHasContents, true); -} - -Imports::~Imports() -{ +Row { + id: root + property bool checked : false + property string label : "CheckBox" + Rectangle { + width: 10; height: 10 + color: root.checked ? "#202020" : "transparent" + border.color: "black" + TapHandler { + onTapped: root.checked = !root.checked + } + } + Text { text: root.label } } - diff --git a/tests/manual/pointer/content/FakeFlickable.qml b/tests/manual/pointer/content/FakeFlickable.qml new file mode 100644 index 0000000000..ffb5c4e914 --- /dev/null +++ b/tests/manual/pointer/content/FakeFlickable.qml @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 + +Item { + id: root + default property alias data: __contentItem.data + property alias velocity: anim.velocity + property alias contentX: __contentItem.x // sign is reversed compared to Flickable.contentX + property alias contentY: __contentItem.y // sign is reversed compared to Flickable.contentY + property alias contentWidth: __contentItem.width + property alias contentHeight: __contentItem.height + signal flickStarted + signal flickEnded + + Item { + id: __contentItem + objectName: "__contentItem" + width: childrenRect.width + height: childrenRect.height + + property real xlimit: root.width - __contentItem.width + property real ylimit: root.height - __contentItem.height + + function returnToBounds() { + if (x > 0) { + returnXAnim.to = 0 + returnXAnim.start() + } else if (x < xlimit) { + returnXAnim.to = xlimit + returnXAnim.start() + } + if (y > 0) { + returnYAnim.to = 0 + returnYAnim.start() + } else if (y < ylimit) { + returnYAnim.to = ylimit + returnYAnim.start() + } + } + + DragHandler { + id: dragHandler + onActiveChanged: if (!active) anim.restart(centroid.velocity) + } + MomentumAnimation { + id: anim + target: __contentItem + onStarted: root.flickStarted() + onStopped: { + __contentItem.returnToBounds() + root.flickEnded() + } + } + NumberAnimation { + id: returnXAnim + target: __contentItem + property: "x" + duration: 200 + easing.type: Easing.OutQuad + } + NumberAnimation { + id: returnYAnim + target: __contentItem + property: "y" + duration: 200 + easing.type: Easing.OutQuad + } + } +} diff --git a/tests/manual/pointer/content/FlashAnimation.qml b/tests/manual/pointer/content/FlashAnimation.qml new file mode 100644 index 0000000000..57817e9aee --- /dev/null +++ b/tests/manual/pointer/content/FlashAnimation.qml @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 + +SequentialAnimation { + id: tapFlash + running: false + PropertyAction { value: false } + PauseAnimation { duration: 100 } + PropertyAction { value: true } + PauseAnimation { duration: 100 } + PropertyAction { value: false } + PauseAnimation { duration: 100 } + PropertyAction { value: true } + PauseAnimation { duration: 100 } + PropertyAction { value: false } + PauseAnimation { duration: 100 } + PropertyAction { value: true } +} diff --git a/tests/manual/pointer/content/MomentumAnimation.qml b/tests/manual/pointer/content/MomentumAnimation.qml new file mode 100644 index 0000000000..ae42f906a1 --- /dev/null +++ b/tests/manual/pointer/content/MomentumAnimation.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 + +ParallelAnimation { + id: root + property Item target: null + property int duration: 500 + property vector2d velocity: Qt.vector2d(0,0) + + function restart(vel) { + stop() + velocity = vel + start() + } + + NumberAnimation { + id: xAnim + target: root.target + property: "x" + to: target.x + velocity.x / duration * 100000 + duration: root.duration + easing.type: Easing.OutQuad + } + NumberAnimation { + id: yAnim + target: root.target + property: "y" + to: target.y + velocity.y / duration * 100000 + duration: root.duration + easing.type: Easing.OutQuad + } +} diff --git a/tests/manual/pointer/content/MouseAreaButton.qml b/tests/manual/pointer/content/MouseAreaButton.qml new file mode 100644 index 0000000000..f75b8f9c56 --- /dev/null +++ b/tests/manual/pointer/content/MouseAreaButton.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Window 2.12 + +Item { + id: container + + property alias text: buttonLabel.text + property alias label: buttonLabel + signal clicked + property alias containsMouse: mouseArea.containsMouse + property alias pressed: mouseArea.pressed + implicitHeight: Math.max(Screen.pixelDensity * 7, buttonLabel.implicitHeight * 1.2) + implicitWidth: Math.max(Screen.pixelDensity * 11, buttonLabel.implicitWidth * 1.3) + height: implicitHeight + width: implicitWidth + + SystemPalette { id: palette } + + Rectangle { + id: frame + anchors.fill: parent + color: palette.button + gradient: Gradient { + GradientStop { position: 0.0; color: mouseArea.pressed ? Qt.darker(palette.button, 1.3) : palette.button } + GradientStop { position: 1.0; color: Qt.darker(palette.button, 1.3) } + } + antialiasing: true + radius: height / 6 + border.color: Qt.darker(palette.button, 1.5) + border.width: 1 + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked() + hoverEnabled: true + } + + Text { + id: buttonLabel + text: container.text + color: palette.buttonText + anchors.centerIn: parent + } +} diff --git a/tests/manual/pointer/content/MouseAreaSlider.qml b/tests/manual/pointer/content/MouseAreaSlider.qml new file mode 100644 index 0000000000..e784e959b1 --- /dev/null +++ b/tests/manual/pointer/content/MouseAreaSlider.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 + +Item { + id: root + property int value: 50 + property int maximumValue: 99 + property alias label: label.text + + Rectangle { + id: slot + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.margins: 10 + anchors.topMargin: 30 + anchors.bottomMargin: 30 + anchors.horizontalCenter: parent.horizontalCenter + width: 10 + color: "black" + radius: width / 2 + smooth: true + } + + Rectangle { + // RectangularGlow is better, but that's a different module + id: glow + anchors.fill: knob + anchors.margins: -5 + anchors.leftMargin: -2 + anchors.horizontalCenterOffset: 1 + radius: 5 + color: "#4400FFFF" + opacity: ma.pressed ? 1 : 0 + } + Image { + id: knob + source: "../resources/mixer-knob.png" + antialiasing: true + x: slot.x - width / 2 + slot.width / 2 + height: root.width / 2 + width: implicitWidth / implicitHeight * height + property bool programmatic: false + property real multiplier: root.maximumValue / (ma.drag.maximumY - ma.drag.minimumY) + onYChanged: if (!programmatic) root.value = root.maximumValue - (knob.y - ma.drag.minimumY) * multiplier + transformOrigin: Item.Center + function setValue(value) { knob.y = ma.drag.maximumY - value / knob.multiplier } + MouseArea { + id: ma + anchors.fill: parent + drag.target: parent + drag.minimumX: knob.x + drag.maximumX: knob.x + drag.minimumY: slot.y + drag.maximumY: slot.height + slot.y - knob.height + } + } + + Text { + font.pointSize: 16 + color: "red" + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + text: root.value + } + + Text { + id: label + font.pointSize: 12 + color: "red" + anchors.top: parent.top + anchors.topMargin: 5 + anchors.horizontalCenter: parent.horizontalCenter + } + + onHeightChanged: { + knob.programmatic = true + knob.setValue(root.value) + knob.programmatic = false + } +} diff --git a/tests/manual/pointer/content/MouseFeedbackSprite.qml b/tests/manual/pointer/content/MouseFeedbackSprite.qml new file mode 100644 index 0000000000..d3068ff503 --- /dev/null +++ b/tests/manual/pointer/content/MouseFeedbackSprite.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 + +PointHandler { + id: handler + objectName: "mouse point" + acceptedDevices: PointerDevice.Mouse + acceptedButtons: Qt.AllButtons + target: Image { + objectName: "mouse sprite" + source: "../resources/mouse.png" + visible: handler.active + x: handler.point.position.x - width / 2 + y: handler.point.position.y - height / 2 + parent: handler.parent + Image { + source: "../resources/mouse_left.png" + visible: handler.point.pressedButtons & Qt.LeftButton + } + Image { + source: "../resources/mouse_middle.png" + visible: handler.point.pressedButtons & Qt.MiddleButton + } + Image { + source: "../resources/mouse_right.png" + visible: handler.point.pressedButtons & Qt.RightButton + } + } +} diff --git a/tests/manual/pointer/content/MptaButton.qml b/tests/manual/pointer/content/MptaButton.qml new file mode 100644 index 0000000000..ed8702b9b3 --- /dev/null +++ b/tests/manual/pointer/content/MptaButton.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Window 2.12 + +Item { + id: container + + property alias text: buttonLabel.text + property alias label: buttonLabel + signal clicked + property alias pressed: point.pressed + implicitHeight: Math.max(Screen.pixelDensity * 7, buttonLabel.implicitHeight * 1.2) + implicitWidth: Math.max(Screen.pixelDensity * 11, buttonLabel.implicitWidth * 1.3) + height: implicitHeight + width: implicitWidth + + SystemPalette { id: palette } + + Rectangle { + id: frame + anchors.fill: parent + color: palette.button + gradient: Gradient { + GradientStop { position: 0.0; color: container.pressed ? Qt.darker(palette.button, 1.3) : palette.button } + GradientStop { position: 1.0; color: Qt.darker(palette.button, 1.3) } + } + antialiasing: true + radius: height / 6 + border.color: Qt.darker(palette.button, 1.5) + border.width: 1 + } + + MultiPointTouchArea { + id: mpta + anchors.fill: parent + touchPoints: [ TouchPoint { + id: point + onPressedChanged: if (!pressed) container.clicked() + } ] + } + + Text { + id: buttonLabel + text: container.text + color: palette.buttonText + anchors.centerIn: parent + } +} diff --git a/tests/manual/pointer/content/MultiButton.qml b/tests/manual/pointer/content/MultiButton.qml new file mode 100644 index 0000000000..485784a875 --- /dev/null +++ b/tests/manual/pointer/content/MultiButton.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 + +Rectangle { + id: root + property alias label: label.text + property alias pressed: tap.pressed + property bool checked: false + property alias gesturePolicy: tap.gesturePolicy + property alias margin: tap.margin + signal tapped + + width: label.implicitWidth * 1.5; height: label.implicitHeight * 2.0 + border.color: "#9f9d9a"; border.width: 1; radius: height / 4; antialiasing: true + + gradient: Gradient { + GradientStop { position: 0.0; color: tap.pressed ? "#b8b5b2" : "#efebe7" } + GradientStop { position: 1.0; color: "#b8b5b2" } + } + + TapHandler { + id: tap + objectName: label.text + onTapped: { + tapFlash.start() + root.tapped() + } + } + + Text { + id: label + font.pointSize: 14 + text: "Button" + anchors.centerIn: parent + } + + Rectangle { + anchors.fill: parent + color: "transparent" + border.width: 2; radius: root.radius; antialiasing: true + opacity: tapFlash.running ? 1 : 0 + FlashAnimation on visible { + id: tapFlash + } + } +} diff --git a/tests/manual/pointer/content/ScrollBar.qml b/tests/manual/pointer/content/ScrollBar.qml new file mode 100644 index 0000000000..9928433d1f --- /dev/null +++ b/tests/manual/pointer/content/ScrollBar.qml @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 + +Rectangle { + id: root + property real contentHeight: 100 + property FakeFlickable flick: null + property real position + + onPositionChanged: if (flick && (drag.active || tap.active)) { + if (knob.state === "horizontal") + flick.contentX = position * knob.scrollDistance + else if (knob.state === "vertical") + flick.contentY = position * knob.scrollDistance + } + + SystemPalette { id: palette } + + color: palette.button + border.color: Qt.darker(palette.button, 1.5) + gradient: Gradient { + GradientStop { position: 0; color: Qt.darker(palette.button, 1.3) } + GradientStop { position: 1; color: palette.button } + } + antialiasing: true + radius: Math.min(width, height) / 6 + width: 20 + height: 20 + + TapHandler { + id: tap + onTapped: { + if (knob.state === "horizontal") + knob.x = position.x - knob.width / 2 + else if (knob.state === "vertical") + knob.y = position.y - knob.height / 2 + } + } + + Rectangle { + id: knob + border.color: "black" + border.width: 1 + gradient: Gradient { + GradientStop { position: 0; color: palette.button } + GradientStop { position: 1; color: Qt.darker(palette.button, 1.3) } + } + radius: 2 + antialiasing: true + state: root.height > root.width ? "vertical" : root.height < root.width ? "horizontal" : "" + property real scrollDistance: 0 + property real scrolledX: 0 + property real scrolledY: 0 + property real max: 0 + + Binding on x { + value: knob.scrolledX + when: !drag.active + } + + Binding on y { + value: knob.scrolledY + when: !drag.active + } + + states: [ + // We will control the horizontal. We will control the vertical. + State { + name: "horizontal" + PropertyChanges { + target: knob + max: root.width - knob.width + scrolledX: Math.min(max, Math.max(0, max * flick.contentX / (flick.width - flick.contentWidth))) + scrolledY: 1 + scrollDistance: flick.width - flick.contentWidth + width: flick.width * (flick.width / flick.contentWidth) - (height - anchors.margins) * 2 + height: root.height - 2 + } + PropertyChanges { + target: drag + xAxis.minimum: 0 + xAxis.maximum: knob.max + yAxis.minimum: 1 + yAxis.maximum: 1 + } + PropertyChanges { + target: root + position: knob.x / drag.xAxis.maximum + } + }, + State { + name: "vertical" + PropertyChanges { + target: knob + max: root.height - knob.height + scrolledX: 1 + scrolledY: Math.min(max, Math.max(0, max * flick.contentY / (flick.height - flick.contentHeight))) + scrollDistance: flick.height - flick.contentHeight + width: root.width - 2 + height: root.width - 2 + } + PropertyChanges { + target: drag + xAxis.minimum: 1 + xAxis.maximum: 1 + yAxis.minimum: 0 + yAxis.maximum: knob.max + } + PropertyChanges { + target: root + position: knob.y / drag.yAxis.maximum + } + } + ] + + DragHandler { + id: drag + } + } +} diff --git a/tests/manual/pointer/content/Slider.qml b/tests/manual/pointer/content/Slider.qml new file mode 100644 index 0000000000..c381d97c7c --- /dev/null +++ b/tests/manual/pointer/content/Slider.qml @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 + +Item { + id: root + property int value: 50 + property int maximumValue: 99 + property alias label: label.text + property alias tapEnabled: tap.enabled + property alias pressed: tap.pressed + signal tapped + + DragHandler { + id: dragHandler + objectName: label.text + " DragHandler" + target: knob + xAxis.enabled: false + yAxis.minimum: slot.y + yAxis.maximum: slot.height + slot.y - knob.height + } + + Rectangle { + id: slot + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.margins: 10 + anchors.topMargin: 30 + anchors.bottomMargin: 30 + anchors.horizontalCenter: parent.horizontalCenter + width: 10 + color: "black" + radius: width / 2 + smooth: true + } + + Rectangle { + // RectangularGlow is better, but that's a different module + id: glow + anchors.fill: knob + anchors.margins: -5 + anchors.leftMargin: -2 + anchors.horizontalCenterOffset: 1 + radius: 5 + color: "#4400FFFF" + opacity: tap.pressed || tapFlash.running ? 1 : 0 + FlashAnimation on visible { + id: tapFlash + } + } + Image { + id: knob + source: "../resources/mixer-knob.png" + antialiasing: true + x: slot.x - width / 2 + slot.width / 2 + height: root.width / 2 + width: implicitWidth / implicitHeight * height + property bool programmatic: false + property real multiplier: root.maximumValue / (dragHandler.yAxis.maximum - dragHandler.yAxis.minimum) + onYChanged: if (!programmatic) root.value = root.maximumValue - (knob.y - dragHandler.yAxis.minimum) * multiplier + transformOrigin: Item.Center + function setValue(value) { knob.y = dragHandler.yAxis.maximum - value / knob.multiplier } + TapHandler { + id: tap + objectName: label.text + " TapHandler" + gesturePolicy: TapHandler.DragThreshold + onTapped: { + tapFlash.start() + root.tapped + } + } + } + + Text { + font.pointSize: 16 + color: "red" + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + text: root.value + } + + Text { + id: label + font.pointSize: 12 + color: "red" + anchors.top: parent.top + anchors.topMargin: 5 + anchors.horizontalCenter: parent.horizontalCenter + } + + onHeightChanged: { + knob.programmatic = true + knob.setValue(root.value) + knob.programmatic = false + } +} diff --git a/tests/manual/pointer/content/TapHandlerButton.qml b/tests/manual/pointer/content/TapHandlerButton.qml new file mode 100644 index 0000000000..2dc1d78a6f --- /dev/null +++ b/tests/manual/pointer/content/TapHandlerButton.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Window 2.12 + +Item { + id: container + + property alias text: buttonLabel.text + property alias label: buttonLabel + signal clicked + property alias pressed: th.pressed + implicitHeight: Math.max(Screen.pixelDensity * 7, buttonLabel.implicitHeight * 1.2) + implicitWidth: Math.max(Screen.pixelDensity * 11, buttonLabel.implicitWidth * 1.3) + height: implicitHeight + width: implicitWidth + + SystemPalette { id: palette } + + Rectangle { + id: frame + anchors.fill: parent + color: palette.button + gradient: Gradient { + GradientStop { position: 0.0; color: container.pressed ? Qt.darker(palette.button, 1.3) : palette.button } + GradientStop { position: 1.0; color: Qt.darker(palette.button, 1.3) } + } + antialiasing: true + radius: height / 6 + border.color: Qt.darker(palette.button, 1.5) + border.width: 1 + } + + TapHandler { + id: th + onTapped: container.clicked() + } + + Text { + id: buttonLabel + text: container.text + color: palette.buttonText + anchors.centerIn: parent + } +} diff --git a/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy_plugin.cpp b/tests/manual/pointer/content/TextBox.qml index 7bd869fc34..b59c21379f 100644 --- a/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy_plugin.cpp +++ b/tests/manual/pointer/content/TextBox.qml @@ -1,9 +1,9 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2018 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** -** This file is part of the test suite of the Qt Toolkit. +** This file is part of the manual tests of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage @@ -26,15 +26,26 @@ ** ****************************************************************************/ -#include "dummy_plugin.h" -#include "dummy.h" +import QtQuick 2.12 -#include <qqml.h> - -void DummyPlugin::registerTypes(const char *uri) -{ - // @uri tests.dumper.dummy - qmlRegisterType<Dummy>(uri, 1, 0, "Dummy"); -} +Rectangle { + id: r1 + radius: 10 + border.color: "black" + border.width: 4 + property string label + implicitHeight: txt.implicitHeight + 12 + implicitWidth: txt.implicitWidth+ 12 + color: "#c0c0c0" + function queryColor(pressed) { + return pressed ? "#ff4040" : "#c0c0c0" + } + Text { + id: txt + y: 6 + anchors.horizontalCenter: parent.horizontalCenter + text: parent.label + } +} diff --git a/tests/manual/pointer/content/TouchpointFeedbackSprite.qml b/tests/manual/pointer/content/TouchpointFeedbackSprite.qml new file mode 100644 index 0000000000..bee3b8b795 --- /dev/null +++ b/tests/manual/pointer/content/TouchpointFeedbackSprite.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 + +PointHandler { + id: handler + objectName: "point " + handler.point.id.toString(16) + acceptedDevices: PointerDevice.TouchScreen | PointerDevice.TouchPad + target: AnimatedSprite { + objectName: "sprite " + handler.point.id.toString(16) + source: "../resources/fingersprite.png" + visible: handler.active + running: visible // QTBUG-64544: running defaults to true, but we don't see it animating if we don't toggle it like this + x: handler.point.position.x - 20 + y: handler.point.position.y - 13 + width: frameWidth + height: frameHeight + frameWidth: 43 + frameHeight: 64 + frameCount: 3 + frameRate: 5 + parent: handler.parent + } +} diff --git a/tests/manual/pointer/fakeFlickable.qml b/tests/manual/pointer/fakeFlickable.qml new file mode 100644 index 0000000000..284e0d1f34 --- /dev/null +++ b/tests/manual/pointer/fakeFlickable.qml @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import "content" + +Rectangle { + color: "#444" + width: 480 + height: 480 + + FakeFlickable { + id: ff + anchors.fill: parent + anchors.rightMargin: rightSB.width + Row { + Item { + width: 100 + height: 400 + Slider { + id: slider + label: "font size" + anchors.fill: parent + maximumValue: 36 + value: 14 + } + } + Text { + id: text + color: "beige" + font.family: "mono" + font.pointSize: slider.value + onTextChanged: console.log("text geom " + width + "x" + height + + ", parent " + parent + " geom " + parent.width + "x" + parent.height) + } + } + + + onFlickStarted: console.log("flick started with velocity " + velocity) + onFlickEnded: console.log("flick ended with velocity " + velocity) + + Component.onCompleted: { + var request = new XMLHttpRequest() + request.open('GET', 'content/FakeFlickable.qml') + request.onreadystatechange = function(event) { + if (request.readyState === XMLHttpRequest.DONE) + text.text = request.responseText + } + request.send() + } + } + + ScrollBar { + id: rightSB + objectName: "rightSB" + flick: ff + height: parent.height - width + anchors.right: parent.right + } + + ScrollBar { + id: bottomSB + objectName: "bottomSB" + flick: ff + width: parent.width - height + anchors.bottom: parent.bottom + } + + Rectangle { + id: cornerCover + color: "lightgray" + width: rightSB.width + height: bottomSB.height + anchors { + right: parent.right + bottom: parent.bottom + } + } +} diff --git a/tests/manual/pointer/flickableWithHandlers.qml b/tests/manual/pointer/flickableWithHandlers.qml new file mode 100644 index 0000000000..08cedb9a16 --- /dev/null +++ b/tests/manual/pointer/flickableWithHandlers.qml @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import "qrc:/quick/shared/" as Examples +import "content" + +Rectangle { + id: root + width: 400 + height: 400 + objectName: "root" + color: "#222222" + + Flickable { + anchors.fill: parent + anchors.margins: 10 + anchors.topMargin: 40 + contentHeight: 600 + contentWidth: 600 + pressDelay: pressDelayCB.checked ? 1000 : 0 + + Column { + spacing: 6 + Rectangle { + radius: 5 + width: parent.width - 12 + height: pressDelayCB.implicitHeight + 12 + x: 6 + color: "lightgray" + Examples.CheckBox { + x: 6; y: 6 + id: pressDelayCB + text: "press delay" + } + } + + + Row { + spacing: 6 + Slider { + label: "DragHandler" + value: 49; width: 100; height: 400 + } + MouseAreaSlider { + label: "MouseArea" + value: 49; width: 100; height: 400 + } + Column { + spacing: 6 + MouseAreaButton { + text: "MouseArea" + } + MptaButton { + text: "MultiPointTouchArea" + } + MptaButton { + text: "MultiPointTouchArea" + } + TapHandlerButton { + text: "TapHandler" + } + TapHandlerButton { + text: "TapHandler" + } + } + } + } + } +} diff --git a/tests/manual/pointer/flingAnimation.qml b/tests/manual/pointer/flingAnimation.qml new file mode 100644 index 0000000000..2bc6de7065 --- /dev/null +++ b/tests/manual/pointer/flingAnimation.qml @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import "content" + +Rectangle { + id: root + width: 640 + height: 480 + color: "black" + + Repeater { + model: 2 + + Image { + id: ball + objectName: "ball" + index + source: "resources/redball.png" + property real homeX: 200 + index * 200 + property real homeY: 200 + width: 80; height: 80; x: homeX; y: 200 + + Text { + anchors.centerIn: parent + color: "white" + text: momentum.velocity.x.toFixed(2) + "," + momentum.velocity.y.toFixed(2) + } + + SequentialAnimation { + id: anim + + function restart(vel) { + stop() + momentum.velocity = vel + start() + } + + MomentumAnimation { id: momentum; target: ball } + + PauseAnimation { duration: 500 } + + ParallelAnimation { + id: ballReturn + NumberAnimation { + target: ball + property: "x" + to: homeX + duration: 1000 + easing.period: 50 + easing.type: Easing.OutElastic + } + NumberAnimation { + target: ball + property: "y" + to: homeY + duration: 1000 + easing.type: Easing.OutElastic + } + } + } + + DragHandler { + id: dragHandler + objectName: "dragHandler" + index + onActiveChanged: { + if (!active) + anim.restart(centroid.velocity) + } + } + Rectangle { + visible: dragHandler.active + anchors.fill: parent + anchors.margins: -5 + radius: width / 2 + opacity: 0.25 + } + + Rectangle { + visible: width > 0 + width: dragHandler.centroid.velocity.length() * 100 + height: 2 + x: ball.width / 2 + y: ball.height / 2 + z: -1 + rotation: Math.atan2(dragHandler.centroid.velocity.y, dragHandler.centroid.velocity.x) * 180 / Math.PI + transformOrigin: Item.BottomLeft + antialiasing: true + + Image { + source: "resources/arrowhead.png" + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + width: 16 + height: 12 + antialiasing: true + } + } + } + } +} diff --git a/tests/manual/pointer/inputinspector.cpp b/tests/manual/pointer/inputinspector.cpp new file mode 100644 index 0000000000..82d814b848 --- /dev/null +++ b/tests/manual/pointer/inputinspector.cpp @@ -0,0 +1,197 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "inputinspector.h" +#include <QtQuick/QQuickWindow> +#include <QtQuick/QQuickItem> +#include <QtQuick/private/qquickpointerhandler_p.h> +#include <QtCore/QSet> + +static const int timerInterval = 100; + +InputInspector::InputInspector(QObject *parent) : QObject(parent) +{ +} + +InputInspector::~InputInspector() +{ + m_window = nullptr; + killTimer(m_timerId); +} + +QString InputInspector::mouseGrabber() const +{ + QString name; + if (m_window) { + if (QQuickItem *grabber = m_window->mouseGrabberItem()) { + name = objectIdentifier(grabber); + } else { + name = QLatin1String("no grabber"); + } + } else { + name = "ERROR: need a source window"; + } + return name; +} + +QString InputInspector::passiveGrabbers() const +{ + return vectorStringJoin(passiveGrabbers_helper()); +} + +QString InputInspector::exclusiveGrabbers() const +{ + return vectorStringJoin(exclusiveGrabbers_helper()); +} + +QString InputInspector::vectorStringJoin(const QVector<QObject*> &arr) const +{ + QString res; + for (QObject* obj: arr) { + if (!res.isEmpty()) + res += QLatin1String(" , "); + res += objectIdentifier(obj); + } + res.prepend(QLatin1String("[")); + res += QLatin1String("]"); + return res; +} + +QQuickWindow *InputInspector::source() const +{ + return m_window; +} + +void InputInspector::setSource(QQuickWindow *window) +{ + m_window = window; + if (m_window && !m_timerId) + m_timerId = startTimer(timerInterval); + emit sourceChanged(); +} + +void InputInspector::update() +{ + const QString mouseGrabberName = mouseGrabber(); + if (lastState.mouseGrabber != mouseGrabberName) { + emit mouseGrabberChanged(); + lastState.mouseGrabber = mouseGrabberName; + } + + const QString tempPassiveGrabbers = passiveGrabbers(); + if (lastState.passiveGrabbers != tempPassiveGrabbers) { + emit passiveGrabbersChanged(); + lastState.passiveGrabbers = tempPassiveGrabbers; + } + + const QString tempExclusiveGrabbers = exclusiveGrabbers(); + if (lastState.exclusiveGrabbers != tempExclusiveGrabbers) { + emit exclusiveGrabbersChanged(); + lastState.exclusiveGrabbers = tempExclusiveGrabbers; + } +} + +void InputInspector::timerEvent(QTimerEvent *event) +{ + if (event->timerId() == m_timerId) + update(); +} + +QQuickPointerDevice *InputInspector::pointerDevice() const +{ + QQuickPointerDevice *device = QQuickPointerDevice::touchDevices().value(0); + if (!device) + device = QQuickPointerDevice::genericMouseDevice(); + return device; +} + +QVector<QObject*> InputInspector::passiveGrabbers_helper(int pointId /*= 0*/) const +{ + QVector<QObject*> result; + QSet<QObject*> visited; + QQuickPointerDevice *device = pointerDevice(); + if (device && source()) { + QQuickWindowPrivate *winPriv = QQuickWindowPrivate::get(source()); + QQuickPointerEvent *pointerEvent = winPriv->pointerEventInstance(device); + if (pointerEvent) { + for (int i = 0; i < pointerEvent->pointCount(); ++i) { + QQuickEventPoint *eventPoint = pointerEvent->point(i); + QVector<QPointer <QQuickPointerHandler> > passives = eventPoint->passiveGrabbers(); + if (!pointId || eventPoint->pointId() == pointId) { + for (auto it = passives.constBegin(); it != passives.constEnd(); ++it) { + QObject *handler = it->data(); + if (!visited.contains(handler)) { + result << it->data(); + visited << handler; + } + } + } + } + } + } + return result; +} + +QVector<QObject*> InputInspector::exclusiveGrabbers_helper(int pointId /*= 0*/) const +{ + QVector<QObject*> result; + QSet<QObject*> visited; + QQuickPointerDevice *device = pointerDevice(); + if (device && source()) { + QQuickWindowPrivate *winPriv = QQuickWindowPrivate::get(source()); + QQuickPointerEvent *pointerEvent = winPriv->pointerEventInstance(device); + if (pointerEvent) { + for (int i = 0; i < pointerEvent->pointCount(); ++i) { + QQuickEventPoint *eventPoint = pointerEvent->point(i); + if (!pointId || eventPoint->pointId() == pointId) { + if (QObject *exclusiveGrabber = eventPoint->exclusiveGrabber()) { + if (!visited.contains(exclusiveGrabber)) { + result << exclusiveGrabber; + visited << exclusiveGrabber; + } + } + } + } + } + } + return result; +} + +QString InputInspector::objectIdentifier(QObject *o) +{ + QString name; + name = o->objectName(); + if (name.isEmpty()) + name = o->property("text").toString(); + if (name.isEmpty()) + name = o->metaObject()->className(); + if (name.isEmpty()) + name = QLatin1String("unknown"); + + return name; +} diff --git a/tests/manual/pointer/inputinspector.h b/tests/manual/pointer/inputinspector.h new file mode 100644 index 0000000000..66a053d0c3 --- /dev/null +++ b/tests/manual/pointer/inputinspector.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef INPUTINSPECTOR_H +#define INPUTINSPECTOR_H + +#include <QObject> +class QQuickWindow; +class QQuickPointerHandler; +class QQuickPointerDevice; + +class InputInspector : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString mouseGrabber READ mouseGrabber NOTIFY mouseGrabberChanged) + Q_PROPERTY(QString passiveGrabbers READ passiveGrabbers NOTIFY passiveGrabbersChanged) + Q_PROPERTY(QString exclusiveGrabbers READ exclusiveGrabbers NOTIFY exclusiveGrabbersChanged) + Q_PROPERTY(QQuickWindow * source READ source WRITE setSource NOTIFY sourceChanged) +public: + explicit InputInspector(QObject *parent = nullptr); + ~InputInspector(); + QString mouseGrabber() const; + QString passiveGrabbers() const; + QString exclusiveGrabbers() const; + QQuickWindow *source() const; + void setSource(QQuickWindow *window); + + void timerEvent(QTimerEvent *event); + Q_INVOKABLE void update(); + +signals: + void mouseGrabberChanged(); + void passiveGrabbersChanged(); + void exclusiveGrabbersChanged(); + void sourceChanged(); +private: + QVector<QObject*> passiveGrabbers_helper(int pointId = 0) const; + QVector<QObject*> exclusiveGrabbers_helper(int pointId = 0) const; + static QString objectIdentifier(QObject *o); + QQuickPointerDevice *pointerDevice() const; + QString vectorStringJoin(const QVector<QObject*> &arr) const; + +private: + mutable struct LastState { + QString mouseGrabber; + QString passiveGrabbers; + QString exclusiveGrabbers; + } lastState; + + QQuickWindow *m_window = nullptr; + int m_timerId = 0; +}; + +#endif // INPUTINSPECTOR_H diff --git a/tests/manual/pointer/joystick.qml b/tests/manual/pointer/joystick.qml new file mode 100644 index 0000000000..c8880f9100 --- /dev/null +++ b/tests/manual/pointer/joystick.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 + +Item { + width: image.implicitWidth; height: image.implicitHeight + Image { + id: image + anchors.centerIn: parent + source: "resources/joystick-outer-case-pov.jpg" + property real margin: 50 + + Image { + id: knob + source: "resources/redball.png" + DragHandler { + id: dragHandler + xAxis { + minimum: image.margin + maximum: image.width - image.margin - knob.width + } + yAxis { + minimum: image.margin + maximum: image.height - image.margin - knob.height + } + } + + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } + states: [ + State { + when: dragHandler.active + AnchorChanges { + target: knob + anchors.horizontalCenter: undefined + anchors.verticalCenter: undefined + } + } + ] + transitions: [ + Transition { + AnchorAnimation { easing.type: Easing.OutElastic } + } + ] + } + } +} diff --git a/tests/manual/pointer/main.cpp b/tests/manual/pointer/main.cpp new file mode 100644 index 0000000000..43ad182a76 --- /dev/null +++ b/tests/manual/pointer/main.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <QGuiApplication> +#include <QQmlApplicationEngine> +#include <QQuickItem> +#include <QQuickWindow> +#include "inputinspector.h" + +int main(int argc, char *argv[]) +{ + QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QGuiApplication app(argc, argv); + qmlRegisterType<InputInspector>("org.qtproject.Test", 1, 0, "InputInspector"); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + if (engine.rootObjects().isEmpty()) + return -1; + if (!app.arguments().isEmpty()) { + QQuickWindow * win = static_cast<QQuickWindow *>(engine.rootObjects().first()); + auto lastArg = app.arguments().last(); + if (lastArg.endsWith(QLatin1String(".qml"))) { + auto root = win->findChild<QQuickItem *>("LauncherList"); + int showExampleIdx = -1; + for (int i = root->metaObject()->methodCount(); showExampleIdx < 0 && i >= 0; --i) + if (root->metaObject()->method(i).name() == QByteArray("showExample")) + showExampleIdx = i; + QMetaMethod showExampleFn = root->metaObject()->method(showExampleIdx); + showExampleFn.invoke(root, Q_ARG(QVariant, QVariant(QLatin1String("../../") + lastArg))); + } + } + + return app.exec(); +} diff --git a/tests/manual/pointer/main.qml b/tests/manual/pointer/main.qml new file mode 100644 index 0000000000..d382d8b23d --- /dev/null +++ b/tests/manual/pointer/main.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Window 2.12 +import QtQuick.Layouts 1.2 +import org.qtproject.Test 1.0 +import "qrc:/quick/shared/" as Examples +import "content" + +Window { + id: window + width: 800 + height: 600 + visible: true + Examples.LauncherList { + id: ll + objectName: "LauncherList" + anchors.fill: parent + Component.onCompleted: { + addExample("single point handler", "QQuickPointerSingleHandler: test properties copied from events", Qt.resolvedUrl("singlePointHandlerProperties.qml")) + addExample("hover", "ensure that a hierarchy of items can share the hover state", Qt.resolvedUrl("sidebar.qml")) + addExample("joystick", "DragHandler: move one item inside another with any pointing device", Qt.resolvedUrl("joystick.qml")) + addExample("mixer", "mixing console", Qt.resolvedUrl("mixer.qml")) + addExample("pinch", "PinchHandler: scale, rotate and drag", Qt.resolvedUrl("pinchHandler.qml")) + addExample("map", "scale and pan", Qt.resolvedUrl("map.qml")) + addExample("custom map", "scale and pan", Qt.resolvedUrl("map2.qml")) + addExample("fling animation", "DragHandler: after dragging, use an animation to simulate momentum", Qt.resolvedUrl("flingAnimation.qml")) + addExample("fake Flickable", "implementation of a simplified Flickable using only Items, DragHandler and MomentumAnimation", Qt.resolvedUrl("fakeFlickable.qml")) + addExample("photo surface", "re-implementation of the existing photo surface demo using Handlers", Qt.resolvedUrl("photosurface.qml")) + addExample("tap", "TapHandler: device-agnostic tap/click detection for buttons", Qt.resolvedUrl("tapHandler.qml")) + addExample("multibuttons", "TapHandler: gesturePolicy (99 red balloons)", Qt.resolvedUrl("multibuttons.qml")) + addExample("flickable with Handlers", "Flickable with buttons, sliders etc. implemented in various ways", Qt.resolvedUrl("flickableWithHandlers.qml")) + addExample("tap and drag", "Flickable with all possible combinations of TapHandler and DragHandler children", Qt.resolvedUrl("pointerDrag.qml")) + } + } + Item { + id: glassPane + objectName: "glassPane" + z: 10000 + anchors.fill: parent + + // TODO use Instantiator to create these... but we need to be able to set their parents to glassPane somehow (QTBUG-64546) + TouchpointFeedbackSprite { } + TouchpointFeedbackSprite { } + TouchpointFeedbackSprite { } + TouchpointFeedbackSprite { } + TouchpointFeedbackSprite { } + TouchpointFeedbackSprite { } + + MouseFeedbackSprite { } + + InputInspector { + id: inspector + source: window + } + + Rectangle { + anchors.bottom: parent.bottom + anchors.right: parent.right + anchors.margins: 4 + radius: 5 + width: Math.max(grid.implicitWidth, 400) + implicitHeight: grid.implicitHeight + color: "#40404080" + GridLayout { + id: grid + width: parent.width + columns: 3 + Text { text: "mouseGrabber" } Text { text: inspector.mouseGrabber } Item { Layout.fillWidth: true } + Text { text: "passiveGrabbers" } Text { text: inspector.passiveGrabbers } Item { Layout.fillWidth: true } + Text { text: "exclusiveGrabbers" } Text { text: inspector.exclusiveGrabbers } Item { Layout.fillWidth: true } + } + } + } +} diff --git a/tests/manual/pointer/map.qml b/tests/manual/pointer/map.qml new file mode 100644 index 0000000000..c400874d58 --- /dev/null +++ b/tests/manual/pointer/map.qml @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 + +Item { + width: 640 + height: 480 + + Rectangle { + id: map + color: "aqua" + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + width: image.width + height: image.height + transform: Rotation { id: tilt; origin.x: width / 2; origin.y: height / 2; axis { x: 1; y: 0; z: 0 } } + + Image { + id: image + anchors.centerIn: parent + fillMode: Image.PreserveAspectFit + source: "resources/map.svgz" + Component.onCompleted: { width = implicitWidth; height = implicitHeight } + } + + Text { + anchors.centerIn: parent + text: image.sourceSize.width + " x " + image.sourceSize.height + + " scale " + map.scale.toFixed(2) + " active scale " + pinch.activeScale.toFixed(2) + } + } + + DragHandler { + objectName: "single-point drag" + target: map + } + + DragHandler { + id: tiltHandler + objectName: "two-point tilt" + minimumPointCount: 2 + maximumPointCount: 2 + xAxis.enabled: false + target: null + onTranslationChanged: tilt.angle = translation.y / -2 + } + + PinchHandler { + id: pinch + objectName: "two-point pinch" + target: map + minimumScale: 0.1 + maximumScale: 10 + xAxis.enabled: false + yAxis.enabled: false + onActiveChanged: if (!active) reRenderIfNecessary() + grabPermissions: PinchHandler.TakeOverForbidden // don't allow takeover if pinch has started + } + + function reRenderIfNecessary() { + var newSourceWidth = image.sourceSize.width * pinch.scale + var ratio = newSourceWidth / image.sourceSize.width + if (ratio > 1.1 || ratio < 0.9) + image.sourceSize.width = newSourceWidth + } +} diff --git a/tests/manual/pointer/map2.qml b/tests/manual/pointer/map2.qml new file mode 100644 index 0000000000..0f45013e92 --- /dev/null +++ b/tests/manual/pointer/map2.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 + +Item { + width: 640 + height: 480 + + Rectangle { + id: map + color: "aqua" + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + width: image.implicitWidth + height: image.implicitHeight + property point center : Qt.point(x + map.width/2, y + map.height/2) + + function setCenter(xx, yy) { + map.x = xx - map.width/2 + map.y = yy - map.height/2 + } + + + Image { + id: image + anchors.centerIn: parent + fillMode: Image.PreserveAspectFit + source: "resources/map.svgz" + } + } + + PinchHandler { + id: pinch + target: map + minimumScale: 0.1 + maximumScale: 10 + } + + DragHandler { + property point startDrag + target: null + onActiveChanged: { + if (active) + startDrag = map.center + } + + onTranslationChanged: { + if (!target) + map.setCenter(startDrag.x + translation.x, startDrag.y + translation.y) + } + } +} diff --git a/tests/manual/pointer/mixer.qml b/tests/manual/pointer/mixer.qml new file mode 100644 index 0000000000..6044b59633 --- /dev/null +++ b/tests/manual/pointer/mixer.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import "content" + +Rectangle { + id: root + width: 1280 + height: 960 + objectName: "root" + color: "#222222" + + ListView { + id: list + objectName: "listView" + anchors.fill: parent + anchors.margins: 10 + orientation: Qt.Horizontal + + model: 20 + + delegate: Item { + objectName: "delegateItem" + index + width: 154 + height: list.height + + Slider { + anchors.fill: parent + label: "Channel " + (index + 1) + } + } + } +} diff --git a/tests/manual/pointer/multibuttons.qml b/tests/manual/pointer/multibuttons.qml new file mode 100644 index 0000000000..d143134a3a --- /dev/null +++ b/tests/manual/pointer/multibuttons.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Particles 2.0 +import QtQuick.Layouts 1.0 +import "content" + +Item { + width: 800 + height: 800 + ColumnLayout { + anchors.right: parent.right + spacing: 20 + Text { text: "protagonist"; font.pointSize: 12 } + MultiButton { + id: balloonsButton + label: "Launch Balloons" + Layout.fillWidth: true + gesturePolicy: TapHandler.WithinBounds + margin: 10 + } + Text { text: "the goons"; font.pointSize: 12 } + MultiButton { + id: missilesButton + label: "Launch Missile" + Layout.fillWidth: true + gesturePolicy: TapHandler.ReleaseWithinBounds + margin: 10 + onTapped: missileEmitter.burst(1) + } + MultiButton { + id: fightersButton + label: "Launch Fighters" + Layout.fillWidth: true + gesturePolicy: TapHandler.DragThreshold + margin: 10 + } + } + ParticleSystem { + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.leftMargin: 150 + ImageParticle { source: "resources/balloon.png" } + Emitter { anchors.bottom: parent.bottom; enabled: balloonsButton.pressed; lifeSpan: 5000; size: 64 + maximumEmitted: 99 + emitRate: 50; velocity: PointDirection { x: 10; y: -150; yVariation: 30; xVariation: 50 } } } + ParticleSystem { + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + ImageParticle { source: "resources/fighter.png" } + Emitter { anchors.bottom: parent.bottom; enabled: fightersButton.pressed; lifeSpan: 15000; size: 204 + emitRate: 3; velocity: PointDirection { x: -1000; y: -250; yVariation: 150; xVariation: 50 } } } + ParticleSystem { + anchors.bottom: parent.bottom + anchors.right: parent.right + anchors.rightMargin: 100 + ImageParticle { source: "resources/missile.png"; autoRotation: true; rotation: 90 } + Emitter { id: missileEmitter; anchors.bottom: parent.bottom; lifeSpan: 5000; size: 128; + emitRate: 0; velocity: PointDirection { x: -200; y: -350; yVariation: 200; xVariation: 100 } } } +} diff --git a/tests/manual/pointer/photosurface.qml b/tests/manual/pointer/photosurface.qml new file mode 100644 index 0000000000..57ad12788e --- /dev/null +++ b/tests/manual/pointer/photosurface.qml @@ -0,0 +1,162 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Dialogs 1.0 +import Qt.labs.folderlistmodel 1.0 +import "content" + +Rectangle { + id: root + visible: true + width: 1024; height: 600 + color: "black" + property int highestZ: 0 + property real defaultSize: 200 + property real surfaceViewportRatio: 1.5 + + FileDialog { + id: fileDialog + title: "Choose a folder with some images" + selectFolder: true + onAccepted: folderModel.folder = fileUrl + "/" + } + Shortcut { + id: openShortcut + sequence: StandardKey.Open + onActivated: fileDialog.open() + } + + FakeFlickable { + id: flick + anchors.fill: parent + contentWidth: width * 2 + contentHeight: height * 2 + Repeater { + model: FolderListModel { + id: folderModel + folder: "resources/" + objectName: "folderModel" + showDirs: false + nameFilters: ["*.png", "*.jpg", "*.gif"] + } + Rectangle { + id: photoFrame + objectName: "frame-" + fileName + width: image.width * (1 + 0.10 * image.height / image.width) + height: image.height * 1.10 + scale: defaultSize / Math.max(image.sourceSize.width, image.sourceSize.height) + Behavior on scale { NumberAnimation { duration: 200 } } + Behavior on x { NumberAnimation { duration: 200 } } + Behavior on y { NumberAnimation { duration: 200 } } + border.color: pinchHandler.active || dragHandler.active ? "red" : "black" + border.width: 2 + smooth: true + antialiasing: true + Component.onCompleted: { + x = Math.random() * root.width - width / 2 + y = Math.random() * root.height - height / 2 + rotation = Math.random() * 13 - 6 + } + Image { + id: image + anchors.centerIn: parent + fillMode: Image.PreserveAspectFit + source: folderModel.folder + fileName + antialiasing: true + } + + MomentumAnimation { id: anim; target: photoFrame } + + DragHandler { + id: dragHandler + onActiveChanged: { + if (!active) + anim.restart(point.velocity) + } + } + + PinchHandler { + id: pinchHandler + minimumRotation: -360 + maximumRotation: 360 + minimumScale: 0.1 + maximumScale: 10 + property real zRestore: 0 + } + } + } + } + + Rectangle { + id: verticalScrollDecorator + anchors.right: parent.right + anchors.margins: 2 + color: "cyan" + border.color: "black" + border.width: 1 + width: 5 + radius: 2 + antialiasing: true + height: flick.height * (flick.height / flick.contentHeight) - (width - anchors.margins) * 2 + y: -flick.contentY * (flick.height / flick.contentHeight) + NumberAnimation on opacity { id: vfade; to: 0; duration: 500 } + onYChanged: { opacity = 1.0; fadeTimer.restart() } + } + + Rectangle { + id: horizontalScrollDecorator + anchors.bottom: parent.bottom + anchors.margins: 2 + color: "cyan" + border.color: "black" + border.width: 1 + height: 5 + radius: 2 + antialiasing: true + width: flick.width * (flick.width / flick.contentWidth) - (height - anchors.margins) * 2 + x: -flick.contentX * (flick.width / flick.contentWidth) + NumberAnimation on opacity { id: hfade; to: 0; duration: 500 } + onXChanged: { opacity = 1.0; fadeTimer.restart() } + } + + Timer { id: fadeTimer; interval: 1000; onTriggered: { hfade.start(); vfade.start() } } + + Text { + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.margins: 10 + color: "darkgrey" + wrapMode: Text.WordWrap + font.pointSize: 8 + text: "Press " + openShortcut.nativeText + " to choose a different image folder\n" + + "On a touchscreen: use two fingers to zoom and rotate, one finger to drag\n" + + "With a mouse: drag normally" + } +} diff --git a/tests/manual/pointer/pinchDragFlingMPTA.qml b/tests/manual/pointer/pinchDragFlingMPTA.qml new file mode 100644 index 0000000000..b68c6cb8c1 --- /dev/null +++ b/tests/manual/pointer/pinchDragFlingMPTA.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import "content" + +Rectangle { + width: 1024; height: 600 + color: "beige" + objectName: "beige root" + + function getTransformationDetails(item, pinchhandler) { + return "scale:" + pinchhandler.scale.toFixed(2) + + " rotation:" + pinchhandler.rotation.toFixed(2) + + " translation:" + "(" + pinchhandler.translation.x.toFixed(2) + "," + pinchhandler.translation.y.toFixed(2) + ")" + } + + Rectangle { + id: container + objectName: "container rect" + width: 600 + height: 500 + color: pinch3.active ? "red" : "black" + antialiasing: true + Loader { + source: "../touch/mpta-crosshairs.qml" + anchors.fill: parent + anchors.margins: 2 + } + Item { + anchors.fill: parent + // In order for PinchHandler to get a chance to take a passive grab, it has to get the touchpoints first. + // In order to get the touchpoints first, it has to be on top of the Z order: i.e. come last in paintOrderChildItems(). + // This is the opposite situation as with filtersChildMouseEvents: e.g. PinchArea would have wanted to be the parent, + // if it even knew that trick (which it doesn't). + PinchHandler { + id: pinch3 + objectName: "3-finger pinch" + target: container + minimumPointCount: 3 + minimumScale: 0.1 + maximumScale: 10 + onActiveChanged: if (!active) fling.restart(centroid.velocity) + } + DragHandler { + id: dragHandler + objectName: "DragHandler" + target: container + acceptedModifiers: Qt.MetaModifier + onActiveChanged: if (!active) fling.restart(point.velocity) + } + } + MomentumAnimation { id: fling; target: container } + } + Text { + anchors.bottom: parent.bottom + text: pinch3.active ? getTransformationDetails(container, pinch3) : + "Pinch with 3 fingers to scale, rotate and translate\nHold down Meta to drag with one finger or mouse" + } +} diff --git a/tests/manual/pointer/pinchHandler.qml b/tests/manual/pointer/pinchHandler.qml new file mode 100644 index 0000000000..8ef6623f7f --- /dev/null +++ b/tests/manual/pointer/pinchHandler.qml @@ -0,0 +1,175 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import "content" + +Rectangle { + width: 1024; height: 600 + color: "#eee" + + function getTransformationDetails(item, pinchhandler) { + return "\n\npinch.scale:" + pinchhandler.scale.toFixed(2) + + "\npinch.rotation:" + pinchhandler.rotation.toFixed(2) + + "\npinch.translation:" + "(" + pinchhandler.translation.x.toFixed(2) + "," + pinchhandler.translation.y.toFixed(2) + ")" + + "\nrect.scale: " + item.scale.toFixed(2) + + "\nrect.rotation: " + item.rotation.toFixed(2) + + "\nrect.position: " + "(" + item.x.toFixed(2) + "," + item.y.toFixed(2) + ")" + } + + function activePincher() { + if (grandparentPinch.active) + return grandparentPinch + else if (parentPinch.active) + return parentPinch + else if (pinch2.active) + return pinch2 + return pinch3 // always return a pinch handler, even when its inactive. The indicator will be invisble anyway. + } + + Rectangle { + width: parent.width - 100; height: parent.height - 100; x: 50; y: 50 + color: "beige" + border.width: grandparentPinch.active ? 2 : 0 + border.color: border.width > 0 ? "red" : "transparent" + antialiasing: true + + PinchHandler { + id: grandparentPinch + objectName: "grandparent pinch" + minimumScale: 0.5 + maximumScale: 3 + minimumPointCount: 3 + } + + Text { + text: "Pinch with 3 fingers to scale, rotate and translate" + + getTransformationDetails(parent, grandparentPinch) + } + + Rectangle { + width: parent.width - 100; height: parent.height - 100; x: 50; y: 50 + color: "#ffe0e0e0" + antialiasing: true + + PinchHandler { + id: parentPinch + objectName: "parent pinch" + minimumScale: 0.5 + maximumScale: 3 + } + + Text { + text: "Pinch with 2 fingers to scale, rotate and translate" + + getTransformationDetails(parent, parentPinch) + } + + Rectangle { + id: rect2 + width: 400 + height: 300 + color: "lightsteelblue" + antialiasing: true + x: 100 + y: 200 + rotation: 30 + transformOrigin: Item.TopRight + border.width: (lsbDragHandler.active || pinch2.active) ? 2 : 0 + border.color: border.width > 0 ? "red" : "transparent" + + Text { + anchors.centerIn: parent + text: "Pinch with 2 fingers to scale, rotate and translate\nDrag with 1 finger" + + getTransformationDetails(rect2, pinch2) + "\nz " + rect2.z + } + DragHandler { + id: lsbDragHandler + objectName: "lightsteelblue drag" + } + PinchHandler { + id: pinch2 + objectName: "lightsteelblue pinch" + minimumRotation: -45 + maximumRotation: 45 + minimumScale: 0.5 + maximumScale: 3 + minimumX: 0 + maximumX: 600 + // acceptedModifiers: Qt.ControlModifier + } + TapHandler { gesturePolicy: TapHandler.DragThreshold; onTapped: rect2.z = rect3.z + 1 } + } + + Rectangle { + id: rect3 + x: 500 + width: 400 + height: 300 + color: "wheat" + antialiasing: true + border.width: (wheatDragHandler.active || pinch3.active) ? 2 : 0 + border.color: border.width > 0 ? "red" : "transparent" + + Text { + anchors.centerIn: parent + text: "Pinch with 3 fingers to scale, rotate and translate\nDrag with 1 finger" + + getTransformationDetails(rect3, pinch3) + "\nz " + rect3.z + } + DragHandler { + id: wheatDragHandler + objectName: "wheat drag" + } + PinchHandler { + id: pinch3 + objectName: "wheat 3-finger pinch" + minimumPointCount: 3 + minimumScale: 0.1 + maximumScale: 10 + onActiveChanged: { + if (!active) + anim.restart(centroid.velocity) + } + } + TapHandler { gesturePolicy: TapHandler.DragThreshold; onTapped: rect3.z = rect2.z + 1 } + MomentumAnimation { id: anim; target: rect3 } + } + } + } + Rectangle { + id: centroidIndicator + property QtObject pincher: activePincher() + x: pincher.centroid.scenePosition.x - radius + y: pincher.centroid.scenePosition.y - radius + z: 1 + visible: pincher.active + radius: width / 2 + width: 10 + height: width + color: "red" + } +} diff --git a/tests/manual/pointer/pointHandlerOnFlickable.qml b/tests/manual/pointer/pointHandlerOnFlickable.qml new file mode 100644 index 0000000000..bd39d545ca --- /dev/null +++ b/tests/manual/pointer/pointHandlerOnFlickable.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import "content" + +Flickable { + id: root + objectName: "root" + width: 800 + height: 480 + contentWidth: 1000 + contentHeight: 600 + + Rectangle { + objectName: "button" + anchors.centerIn: parent + border.color: "tomato" + border.width: 10 + color: innerTap.pressed ? "wheat" : "transparent" + width: 100 + height: 100 + TapHandler { + id: innerTap + objectName: "buttonTap" + } + } + + TapHandler { + id: contentItemTap + objectName: "contentItemTap" + onLongPressed: longPressFeedback.createObject(root.contentItem, + {"x": point.position.x, "y": point.position.y, + "text": contentItemTap.timeHeld.toFixed(3) + " sec"}) + + } + TouchpointFeedbackSprite { } + TouchpointFeedbackSprite { } + TouchpointFeedbackSprite { } + TouchpointFeedbackSprite { } + TouchpointFeedbackSprite { } + + Component { + id: longPressFeedback + Text { } + } + + Component.onCompleted: contentItem.objectName = "Flickable's contentItem" +} diff --git a/tests/manual/pointer/pointer.pro b/tests/manual/pointer/pointer.pro new file mode 100644 index 0000000000..43fddbd459 --- /dev/null +++ b/tests/manual/pointer/pointer.pro @@ -0,0 +1,8 @@ +TEMPLATE = app + +QT += qml quick quick-private svg + +SOURCES += main.cpp inputinspector.cpp +HEADERS += inputinspector.h + +RESOURCES += qml.qrc ../../../examples/quick/shared/quick_shared.qrc diff --git a/tests/manual/pointer/pointerDrag.qml b/tests/manual/pointer/pointerDrag.qml new file mode 100644 index 0000000000..79044eb0b4 --- /dev/null +++ b/tests/manual/pointer/pointerDrag.qml @@ -0,0 +1,218 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import "content" + +Rectangle { + id: root + width: 600; height: 480; color: "#f0f0f0" + + property int globalGesturePolicy : TapHandler.DragThreshold + + Flickable { + id: flick + anchors.fill: parent + contentHeight: 600 + contentWidth: 1000 + objectName: "Flick" + + Repeater { + model: flick.contentHeight/200 + Rectangle { + width: flick.contentWidth + height: 101 + x: 0 + y: index * 200 + border.color: "#808080" + border.width: 1 + color: "transparent" + } + } + + Repeater { + model: flick.contentWidth/200 + Rectangle { + width: 101 + height: flick.contentHeight + x: index * 200 + y: 0 + border.color: "#808080" + border.width: 1 + color: "transparent" + } + } + + TextBox { + x: 0; y: 0 + width: 100; height: 100 + label: "DragHandler" + objectName: "dragSquircle1" + DragHandler { + + } + } + + TextBox { + x: 100; y: 0 + width: 100; height: 100 + label: "TapHandler" + color: queryColor(tap1.pressed) + + TapHandler { + id: tap1 + gesturePolicy: root.globalGesturePolicy + } + } + + TextBox { + x: 200; y: 0 + width: 100; height: 100 + label: "TapHandler\nDragHandler" + color: queryColor(tap2.pressed) + TapHandler { + id: tap2 + gesturePolicy: root.globalGesturePolicy + } + DragHandler { } + } + + TextBox { + x: 300; y: 0 + width: 100; height: 100 + label: "DragHandler\nTapHandler" + color: queryColor(tap3.pressed) + DragHandler { } + TapHandler { + id: tap3 + gesturePolicy: root.globalGesturePolicy + } + } + + TextBox { + x: 400; y: 0 + width: 100; height: 100 + label: "DragHandler" + DragHandler { } + + TextBox { + label: "TapHandler" + x: (parent.width - width)/2 + y: 60 + color: queryColor(tap4.pressed) + TapHandler { + id: tap4 + gesturePolicy: root.globalGesturePolicy + } + } + } + + TextBox { + objectName: "dragSquircle5" + x: 500; y: 0 + width: 100; height: 100 + label: "TapHandler" + color: queryColor(tap5.pressed) + CheckBox { + id: ckGreedyDrag + x: 10 + anchors.bottom: dragRect5.top + label: " Greedy ↓" + checked: true + } + TapHandler { + id: tap5 + gesturePolicy: root.globalGesturePolicy + } + + TextBox { + id: dragRect5 + objectName: "dragRect5" + label: "DragHandler" + x: (parent.width - width)/2 + y: 60 + DragHandler { + grabPermissions: ckGreedyDrag ? DragHandler.CanTakeOverFromAnything : + DragHandler.CanTakeOverFromItems | DragHandler.CanTakeOverFromHandlersOfDifferentType | DragHandler.ApprovesTakeOverByAnything + } + } + } + + + TextBox { + x: 0; y: 100 + width: 100; height: 100 + label: "No MouseArea" + + TextBox { + objectName: "dragRect01" + label: "DragHandler" + x: (parent.width - width)/2 + y: 60 + DragHandler { } + } + } + + TextBox { + id: r2 + label: "MouseArea" + x: 100; y: 100 + width: 100; height: 100 + + MouseArea { + id: ma + enabled: ckEnabled.checked + drag.target: ckDrag.checked ? r2 : undefined + drag.threshold: ckExtendDragThreshold.checked ? 50 : undefined + anchors.fill: parent + } + Column { + anchors.bottom: parent.bottom + anchors.bottomMargin: 10 + x: 10 + CheckBox { + id: ckEnabled + label: " Enabled" + checked: true + } + + CheckBox { + id: ckDrag + label: " Drag" + checked: true + } + + CheckBox { + id: ckExtendDragThreshold + label: " Extend threshold" + checked: false + } + } + } + } +} diff --git a/tests/manual/pointer/qml.qrc b/tests/manual/pointer/qml.qrc new file mode 100644 index 0000000000..95bece180a --- /dev/null +++ b/tests/manual/pointer/qml.qrc @@ -0,0 +1,47 @@ +<RCC> + <qresource prefix="/"> + <file>flingAnimation.qml</file> + <file>main.qml</file> + <file>fakeFlickable.qml</file> + <file>flickableWithHandlers.qml</file> + <file>joystick.qml</file> + <file>map.qml</file> + <file>mixer.qml</file> + <file>multibuttons.qml</file> + <file>photosurface.qml</file> + <file>pinchHandler.qml</file> + <file>pointerDrag.qml</file> + <file>singlePointHandlerProperties.qml</file> + <file>sidebar.qml</file> + <file>tapHandler.qml</file> + <file>content/CheckBox.qml</file> + <file>content/FakeFlickable.qml</file> + <file>content/FlashAnimation.qml</file> + <file>content/MomentumAnimation.qml</file> + <file>content/MouseAreaButton.qml</file> + <file>content/MouseAreaSlider.qml</file> + <file>content/MouseFeedbackSprite.qml</file> + <file>content/MptaButton.qml</file> + <file>content/MultiButton.qml</file> + <file>content/ScrollBar.qml</file> + <file>content/Slider.qml</file> + <file>content/TapHandlerButton.qml</file> + <file>content/TextBox.qml</file> + <file>content/TouchpointFeedbackSprite.qml</file> + <file>resources/arrowhead.png</file> + <file>resources/balloon.png</file> + <file>resources/fighter.png</file> + <file>resources/fingersprite.png</file> + <file>resources/grabbing-location.svg</file> + <file>resources/joystick-outer-case-pov.jpg</file> + <file>resources/map.svgz</file> + <file>resources/missile.png</file> + <file>resources/mixer-knob.png</file> + <file>resources/mouse.png</file> + <file>resources/mouse_left.png</file> + <file>resources/mouse_middle.png</file> + <file>resources/mouse_right.png</file> + <file>resources/redball.png</file> + <file>map2.qml</file> + </qresource> +</RCC> diff --git a/tests/manual/pointer/resources/arrowhead.png b/tests/manual/pointer/resources/arrowhead.png Binary files differnew file mode 100644 index 0000000000..7719bc6d6a --- /dev/null +++ b/tests/manual/pointer/resources/arrowhead.png diff --git a/tests/manual/pointer/resources/balloon.png b/tests/manual/pointer/resources/balloon.png Binary files differnew file mode 100644 index 0000000000..6476facc49 --- /dev/null +++ b/tests/manual/pointer/resources/balloon.png diff --git a/tests/manual/pointer/resources/fighter.png b/tests/manual/pointer/resources/fighter.png Binary files differnew file mode 100644 index 0000000000..2acee43cba --- /dev/null +++ b/tests/manual/pointer/resources/fighter.png diff --git a/tests/manual/pointer/resources/fingersprite.png b/tests/manual/pointer/resources/fingersprite.png Binary files differnew file mode 100644 index 0000000000..423d115fdf --- /dev/null +++ b/tests/manual/pointer/resources/fingersprite.png diff --git a/tests/manual/pointer/resources/grabbing-location.svg b/tests/manual/pointer/resources/grabbing-location.svg new file mode 100644 index 0000000000..c26881e9ba --- /dev/null +++ b/tests/manual/pointer/resources/grabbing-location.svg @@ -0,0 +1 @@ +<svg width="3408" height="3124"><path d="M1517 1562c0-126-93-229-208-229s-208 102-208 229c0 126 93 229 208 229s208-102 208-229zm123-172c-58-206-221-365-424-412l-270 531H380l203-223 219-241 346-380c42 14 82 32 121 54 232 128 402 375 449 671h-77zm-551-933c448 123 782 546 802 1055h1517C3386 673 2787 0 2050 0H696L0 1367h120l826-938 146 25c-1 1-2 2-3 4zm551 1277c-58 206-221 365-424 412l-270-531H380l203 223 219 241 346 380c42-14 82-32 121-54 232-128 402-375 449-671h-77zm-548 936l-146 25-826-938H0l696 1367h1354c737 0 1337-673 1358-1512H1891c-19 509-354 933-802 1055 1 1 2 2 3 4z" fill="#ee832b"/></svg> diff --git a/tests/manual/pointer/resources/joystick-outer-case-pov.jpg b/tests/manual/pointer/resources/joystick-outer-case-pov.jpg Binary files differnew file mode 100644 index 0000000000..01cd78fdcf --- /dev/null +++ b/tests/manual/pointer/resources/joystick-outer-case-pov.jpg diff --git a/tests/manual/pointer/resources/map.svgz b/tests/manual/pointer/resources/map.svgz Binary files differnew file mode 100644 index 0000000000..64d509c106 --- /dev/null +++ b/tests/manual/pointer/resources/map.svgz diff --git a/tests/manual/pointer/resources/missile.png b/tests/manual/pointer/resources/missile.png Binary files differnew file mode 100644 index 0000000000..72c02d1fb9 --- /dev/null +++ b/tests/manual/pointer/resources/missile.png diff --git a/tests/manual/pointer/resources/mixer-knob.png b/tests/manual/pointer/resources/mixer-knob.png Binary files differnew file mode 100644 index 0000000000..b7d42ee3bd --- /dev/null +++ b/tests/manual/pointer/resources/mixer-knob.png diff --git a/tests/manual/pointer/resources/mouse.png b/tests/manual/pointer/resources/mouse.png Binary files differnew file mode 100644 index 0000000000..268946df0a --- /dev/null +++ b/tests/manual/pointer/resources/mouse.png diff --git a/tests/manual/pointer/resources/mouse_left.png b/tests/manual/pointer/resources/mouse_left.png Binary files differnew file mode 100644 index 0000000000..9292301b47 --- /dev/null +++ b/tests/manual/pointer/resources/mouse_left.png diff --git a/tests/manual/pointer/resources/mouse_middle.png b/tests/manual/pointer/resources/mouse_middle.png Binary files differnew file mode 100644 index 0000000000..064e8b9c16 --- /dev/null +++ b/tests/manual/pointer/resources/mouse_middle.png diff --git a/tests/manual/pointer/resources/mouse_right.png b/tests/manual/pointer/resources/mouse_right.png Binary files differnew file mode 100644 index 0000000000..cab1a36ba6 --- /dev/null +++ b/tests/manual/pointer/resources/mouse_right.png diff --git a/tests/manual/pointer/resources/redball.png b/tests/manual/pointer/resources/redball.png Binary files differnew file mode 100644 index 0000000000..68d2e1d638 --- /dev/null +++ b/tests/manual/pointer/resources/redball.png diff --git a/tests/manual/pointer/rubberbandOnTable.qml b/tests/manual/pointer/rubberbandOnTable.qml new file mode 100644 index 0000000000..177568d41e --- /dev/null +++ b/tests/manual/pointer/rubberbandOnTable.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 + +TableView { + id: root + objectName: "root" + width: 480 + height: 480 + columnSpacing: 2 + rowSpacing: 2 + // TODO use TableModel when it's ready, to test with multiple columns + model: 10 + + delegate: Rectangle { + id: tableDelegate + objectName: "itemview delegate" + color: delegateTap.pressed ? "wheat" : "beige" + implicitWidth: 200 + implicitHeight: 140 + + Rectangle { + objectName: "button" + anchors.centerIn: parent + border.color: "tomato" + border.width: 10 + color: buttonTap.pressed ? "goldenrod" : "beige" + width: 100 + height: 100 + TapHandler { + id: buttonTap + objectName: "buttonTap" + } + } + + TapHandler { + id: delegateTap + objectName: "delegateTap" + } + } + + DragHandler { + id: rubberBandDrag + objectName: "rubberBandDrag" + target: null + acceptedDevices: PointerDevice.Mouse + } + Rectangle { + visible: rubberBandDrag.active + x: Math.min(rubberBandDrag.centroid.position.x, rubberBandDrag.centroid.pressPosition.x) + y: Math.min(rubberBandDrag.centroid.position.y, rubberBandDrag.centroid.pressPosition.y) + width: Math.abs(rubberBandDrag.centroid.position.x - rubberBandDrag.centroid.pressPosition.x) + height: Math.abs(rubberBandDrag.centroid.position.y - rubberBandDrag.centroid.pressPosition.y) + color: "transparent" + border.color: "black" + z: 1000 + } + + Component.onCompleted: contentItem.objectName = "TableView's contentItem" +} diff --git a/tests/manual/pointer/sidebar.qml b/tests/manual/pointer/sidebar.qml new file mode 100644 index 0000000000..827dbd1980 --- /dev/null +++ b/tests/manual/pointer/sidebar.qml @@ -0,0 +1,185 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import "content" + +Rectangle { + id: root + width: 640 + height: 480 + color: "#444" + + Component { + id: buttonsAndStuff + Column { + anchors.fill: parent + anchors.margins: 8 + spacing: 8 + + Rectangle { + objectName: "buttonWithMA" + width: parent.width + height: 30 + color: buttonMA.pressed ? "lightsteelblue" : "#999" + border.color: buttonMA.containsMouse ? "cyan" : "transparent" + + MouseArea { + id: buttonMA + objectName: "buttonMA" + hoverEnabled: true + anchors.fill: parent + onClicked: console.log("clicked MA") + } + + Text { + anchors.centerIn: parent + text: "MouseArea" + } + } + + Rectangle { + objectName: "buttonWithHH" + width: parent.width + height: 30 + color: flash ? "#999" : "white" + border.color: buttonHH.hovered ? "cyan" : "transparent" + property bool flash: true + + HoverHandler { + id: buttonHH + objectName: "buttonHH" + acceptedDevices: PointerDevice.AllDevices + } + + TapHandler { + onTapped: tapFlash.start() + } + + Text { + anchors.centerIn: parent + text: "HoverHandler" + } + + FlashAnimation on flash { + id: tapFlash + } + } + } + } + + Rectangle { + id: paddle + width: 100 + height: 40 + color: paddleHH.hovered ? "indianred" : "#888" + y: parent.height - 100 + radius: 10 + + HoverHandler { + id: paddleHH + objectName: "paddleHH" + } + + SequentialAnimation on x { + NumberAnimation { + to: root.width - paddle.width + duration: 2000 + easing { type: Easing.InOutQuad } + } + PauseAnimation { duration: 100 } + NumberAnimation { + to: 0 + duration: 2000 + easing { type: Easing.InOutQuad } + } + PauseAnimation { duration: 100 } + loops: Animation.Infinite + } + } + + Rectangle { + objectName: "topSidebar" + radius: 5 + antialiasing: true + x: -radius + y: -radius + width: 120 + height: 200 + border.color: topSidebarHH.hovered ? "cyan" : "black" + color: "#777" + + Rectangle { + color: "cyan" + width: 10 + height: width + radius: width / 2 + visible: topSidebarHH.hovered + x: topSidebarHH.point.position.x - width / 2 + y: topSidebarHH.point.position.y - height / 2 + z: 100 + } + + HoverHandler { + id: topSidebarHH + objectName: "topSidebarHH" + } + + Loader { + objectName: "topSidebarLoader" + sourceComponent: buttonsAndStuff + anchors.fill: parent + } + } + + Rectangle { + objectName: "bottomSidebar" + radius: 5 + antialiasing: true + x: -radius + anchors.bottom: parent.bottom + anchors.bottomMargin: -radius + width: 120 + height: 200 + border.color: bottomSidebarMA.containsMouse ? "cyan" : "black" + color: "#777" + + MouseArea { + id: bottomSidebarMA + objectName: "bottomSidebarMA" + hoverEnabled: true + anchors.fill: parent + } + + Loader { + objectName: "bottomSidebarLoader" + sourceComponent: buttonsAndStuff + anchors.fill: parent + } + } +} diff --git a/tests/manual/pointer/singlePointHandlerProperties.qml b/tests/manual/pointer/singlePointHandlerProperties.qml new file mode 100644 index 0000000000..71bff2d829 --- /dev/null +++ b/tests/manual/pointer/singlePointHandlerProperties.qml @@ -0,0 +1,152 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 + +Rectangle { + id: root + width: 480 + height: 480 + color: "black" + + Item { + id: crosshairs + x: pointHandler.point.position.x - width / 2 + y: pointHandler.point.position.y - height / 2 + width: parent.width / 2; height: parent.height / 2 + visible: pointHandler.active + rotation: pointHandler.point.rotation + + Rectangle { + color: "goldenrod" + anchors.centerIn: parent + width: 2; height: parent.height + antialiasing: true + } + Rectangle { + color: "goldenrod" + anchors.centerIn: parent + width: parent.width; height: 2 + antialiasing: true + } + Rectangle { + color: "goldenrod" + width: Math.max(2, 50 * pointHandler.point.pressure) + height: width + radius: width / 2 + anchors.centerIn: parent + antialiasing: true + Rectangle { + y: -56 + anchors.horizontalCenter: parent.horizontalCenter + color: "lightsteelblue" + implicitWidth: label.implicitWidth + implicitHeight: label.implicitHeight + Text { + id: label + text: 'id: ' + pointHandler.point.id.toString(16) + " uid: " + pointHandler.point.uniqueId.numericId + + '\npos: (' + pointHandler.point.position.x.toFixed(2) + ', ' + pointHandler.point.position.y.toFixed(2) + ')' + + '\nmodifiers: ' + pointHandler.point.modifiers.toString(16) + } + } + } + Rectangle { + color: "transparent" + border.color: "white" + antialiasing: true + width: pointHandler.point.ellipseDiameters.width + height: pointHandler.point.ellipseDiameters.height + radius: Math.min(width / 2, height / 2) + anchors.centerIn: parent + } + } + Rectangle { + id: velocityVector + visible: width > 0 + width: pointHandler.point.velocity.length() * 100 + height: 2 + x: pointHandler.point.position.x + y: pointHandler.point.position.y + rotation: Math.atan2(pointHandler.point.velocity.y, pointHandler.point.velocity.x) * 180 / Math.PI + transformOrigin: Item.BottomLeft + antialiasing: true + + Image { + source: "resources/arrowhead.png" + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + width: 16 + height: 12 + antialiasing: true + } + } + + Component { + id: grabbingLocationIndicator + Image { + source: "resources/grabbing-location.svg" + sourceSize.width: 32 + sourceSize.height: 32 + } + } + + Component { + id: mouseButtonIndicator + Image { + property int buttons + source: "resources/mouse.png" + Image { + source: "resources/mouse_left.png" + visible: buttons & Qt.LeftButton + } + Image { + source: "resources/mouse_middle.png" + visible: buttons & Qt.MidButton + } + Image { + source: "resources/mouse_right.png" + visible: buttons & Qt.RightButton + } + } + } + + PointHandler { + id: pointHandler + target: null + acceptedButtons: Qt.AllButtons + onGrabChanged: if (active) { // 'point' is an implicit parameter referencing to a QQuickEventPoint instance + console.log("grabbed " + point.pointId + " @ " + point.sceneGrabPos) + grabbingLocationIndicator.createObject(root, {"x": point.sceneGrabPosition.x, "y": point.sceneGrabPosition.y - 16}) + } + onPointChanged: { + // Here, 'point' is referring to the property of the PointHandler + if (point.pressedButtons) + mouseButtonIndicator.createObject(root, {"x": point.pressPosition.x - 44, "y": point.pressPosition.y - 64, "buttons": point.pressedButtons}) + } + } +} diff --git a/tests/manual/pointer/tapHandler.qml b/tests/manual/pointer/tapHandler.qml new file mode 100644 index 0000000000..8c1fac9a2f --- /dev/null +++ b/tests/manual/pointer/tapHandler.qml @@ -0,0 +1,184 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the manual tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import "qrc:/quick/shared/" as Examples + +Item { + width: 480 + height: 320 + + Rectangle { + id: rect + anchors.fill: parent; anchors.margins: 40 + border.width: 3; border.color: "transparent" + color: handler.pressed ? "lightsteelblue" : "darkgrey" + + TapHandler { + id: handler + acceptedButtons: (leftAllowedCB.checked ? Qt.LeftButton : Qt.NoButton) | + (middleAllowedCB.checked ? Qt.MiddleButton : Qt.NoButton) | + (rightAllowedCB.checked ? Qt.RightButton : Qt.NoButton) + gesturePolicy: (policyDragThresholdCB.checked ? TapHandler.DragThreshold : + policyWithinBoundsCB.checked ? TapHandler.WithinBounds : + TapHandler.ReleaseWithinBounds) + + onCanceled: { + console.log("canceled @ " + point.position) + borderBlink.blinkColor = "red" + borderBlink.start() + } + onTapped: { // 'eventPoint' is a signal parameter of type QQuickEventPoint* + console.log("tapped button " + eventPoint.event.button + " @ " + eventPoint.scenePosition + + " on device '" + eventPoint.event.device.name + "' " + (tapCount > 1 ? (tapCount + " times") : "for the first time")) + if (tapCount > 1) { + tapCountLabel.text = tapCount + flashAnimation.start() + } else { + borderBlink.tapFeedback(eventPoint.event.button) + } + } + onLongPressed: longPressFeedback.createObject(rect, + {"x": point.position.x, "y": point.position.y, + "text": handler.timeHeld.toFixed(3) + " sec", + "color": buttonToBlinkColor(point.pressedButtons)}) + } + + Text { + id: tapCountLabel + anchors.centerIn: parent + font.pixelSize: 72 + font.weight: Font.Black + SequentialAnimation { + id: flashAnimation + PropertyAction { target: tapCountLabel; property: "visible"; value: true } + PropertyAction { target: tapCountLabel; property: "opacity"; value: 1.0 } + PropertyAction { target: tapCountLabel; property: "scale"; value: 1.0 } + ParallelAnimation { + NumberAnimation { + target: tapCountLabel + property: "opacity" + to: 0 + duration: 500 + } + NumberAnimation { + target: tapCountLabel + property: "scale" + to: 1.5 + duration: 500 + } + } + } + } + + Rectangle { + id: expandingCircle + radius: handler.timeHeld * 100 + visible: radius > 0 && handler.pressed + border.width: 3 + border.color: buttonToBlinkColor(handler.point.pressedButtons) + color: "transparent" + width: radius * 2 + height: radius * 2 + x: handler.point.pressPosition.x - radius + y: handler.point.pressPosition.y - radius + opacity: 0.25 + } + + Component { + id: longPressFeedback + Text { } + } + + SequentialAnimation { + id: borderBlink + property color blinkColor: "red" + function tapFeedback(button) { + blinkColor = buttonToBlinkColor(button); + start(); + } + loops: 3 + ScriptAction { script: rect.border.color = borderBlink.blinkColor } + PauseAnimation { duration: 100 } + ScriptAction { script: rect.border.color = "transparent" } + PauseAnimation { duration: 100 } + } + } + + function buttonToBlinkColor(button) { + switch (button) { + case Qt.MiddleButton: return "orange"; + case Qt.RightButton: return "magenta"; + default: return "green"; + } + } + + Row { + spacing: 6 + Text { text: "accepted mouse clicks:"; anchors.verticalCenter: leftAllowedCB.verticalCenter } + Examples.CheckBox { + id: leftAllowedCB + checked: true + text: "left click" + } + Examples.CheckBox { + id: middleAllowedCB + text: "middle click" + } + Examples.CheckBox { + id: rightAllowedCB + text: "right click" + } + Text { text: " gesture policy:"; anchors.verticalCenter: leftAllowedCB.verticalCenter } + Examples.CheckBox { + id: policyDragThresholdCB + text: "drag threshold" + onCheckedChanged: if (checked) { + policyWithinBoundsCB.checked = false; + policyReleaseWithinBoundsCB.checked = false; + } + } + Examples.CheckBox { + id: policyWithinBoundsCB + text: "within bounds" + onCheckedChanged: if (checked) { + policyDragThresholdCB.checked = false; + policyReleaseWithinBoundsCB.checked = false; + } + } + Examples.CheckBox { + id: policyReleaseWithinBoundsCB + checked: true + text: "release within bounds" + onCheckedChanged: if (checked) { + policyDragThresholdCB.checked = false; + policyWithinBoundsCB.checked = false; + } + } + } +} diff --git a/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy.cpp b/tests/manual/pointer/tapWithModifiers.qml index 0ca82f20e2..8ca1c1bd63 100644 --- a/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy.cpp +++ b/tests/manual/pointer/tapWithModifiers.qml @@ -1,9 +1,9 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** -** This file is part of the test suite of the Qt Toolkit. +** This file is part of the manual tests of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage @@ -26,19 +26,20 @@ ** ****************************************************************************/ -#include "dummy.h" +import QtQuick 2.12 -Dummy::Dummy(QQuickItem *parent): - QQuickItem(parent) -{ - // By default, QQuickItem does not draw anything. If you subclass - // QQuickItem to create a visual item, you will need to uncomment the - // following line and re-implement updatePaintNode() - - // setFlag(ItemHasContents, true); -} - -Dummy::~Dummy() -{ +Item { + width: 200 + height: 200 + TapHandler { + acceptedModifiers: Qt.ControlModifier + onTapped: console.log("control-tapped") + } + TapHandler { + acceptedModifiers: Qt.NoModifier + onTapped: console.log("tapped with no modifiers") + } + TapHandler { + onTapped: console.log("tapped with modifiers " + point.event.modifiers) + } } - diff --git a/tests/manual/qmlplugindump/README b/tests/manual/qmlplugindump/README deleted file mode 100644 index 537afbba6e..0000000000 --- a/tests/manual/qmlplugindump/README +++ /dev/null @@ -1,42 +0,0 @@ -Tests for qmlplugindump ------------------------ - -The test are executed by compiling a series of sample projects and -running qmlplugindump on them, checking the generated plugin.qmltypes -files. Each test, except `builtins`, need a sample project in order -to be executed. A test is defined by: - - - test name - - sample project name - - sample project version - - expected results - -That means that different tests can use the same sample project, but -it is not possible to define a test that use more than one sample. -Test definitions are stored in the folder `definitions` as json files; -the file name is the test name, tests are executed in lexicographical -order on their names, and the contents defines the other properties in -the following format: - - { - "project": <project-name>, - "version": <version>, - "expected": [<regexp-patterns>*], - } - -where _project-name_, _version_, and _regexp-patterns_ are strings. - -The first two parameters are used to invoke qmlplugindump: - - qmlplugindump -nonrelocatable <uri> <version> <path> - -where: - - <uri> = tests.dumper.<project-name> - <path> = <test-root> - -therefore, it is important that the sample projects resides in -a subdirectory of `tests/dumper` named as the project itself. - -The last parameter is a list of regular expression patterns that -must match the `plugin.qmltypes` produced by qmlplugindump. diff --git a/tests/manual/qmlplugindump/definitions/000_dummy.json b/tests/manual/qmlplugindump/definitions/000_dummy.json deleted file mode 100644 index 15f62bbc13..0000000000 --- a/tests/manual/qmlplugindump/definitions/000_dummy.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "project": "Dummy", - "version": "1.0", - "expected": ["name: \"Dummy\""] -} diff --git a/tests/manual/qmlplugindump/definitions/001_versions.json b/tests/manual/qmlplugindump/definitions/001_versions.json deleted file mode 100644 index 185057f90d..0000000000 --- a/tests/manual/qmlplugindump/definitions/001_versions.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "project": "Versions", - "version": "1.0", - "expected": [ - "name: \"Versions\"", - "tests\\.dumper\\.Versions/Versions 1\\.0" - ] -} diff --git a/tests/manual/qmlplugindump/definitions/002_revisions.json b/tests/manual/qmlplugindump/definitions/002_revisions.json deleted file mode 100644 index 7f3d86ffe8..0000000000 --- a/tests/manual/qmlplugindump/definitions/002_revisions.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "project": "Versions", - "version": "1.1", - "expected": [ - "name: \"Versions\"", - "tests\\.dumper\\.Versions/Versions 1\\.1", - "exportMetaObjectRevisions: \\[0, 1\\]" - ] -} diff --git a/tests/manual/qmlplugindump/qmlplugindump.pro b/tests/manual/qmlplugindump/qmlplugindump.pro deleted file mode 100644 index b072cdc0cf..0000000000 --- a/tests/manual/qmlplugindump/qmlplugindump.pro +++ /dev/null @@ -1,8 +0,0 @@ -CONFIG += testcase -TARGET = tst_qmlplugindump -QT += testlib gui-private -osx:CONFIG -= app_bundle -CONFIG += parallel_test - -SOURCES += tst_qmlplugindump.cpp -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy.h b/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy.h deleted file mode 100644 index 8cf645da24..0000000000 --- a/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef DUMMY_H -#define DUMMY_H - -#include <QQuickItem> - -class Dummy : public QQuickItem -{ - Q_OBJECT - -public: - Dummy(QQuickItem *parent = 0); - ~Dummy(); -}; - -#endif // DUMMY_H - diff --git a/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy.pro b/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy.pro deleted file mode 100644 index 81975ee01c..0000000000 --- a/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy.pro +++ /dev/null @@ -1,33 +0,0 @@ -TEMPLATE = lib -TARGET = Dummy -QT += qml quick -CONFIG += qt plugin - -TARGET = $$qtLibraryTarget($$TARGET) -uri = tests.dumper.Dummy - -# Input -SOURCES += \ - dummy_plugin.cpp \ - dummy.cpp - -HEADERS += \ - dummy_plugin.h \ - dummy.h - -DISTFILES = qmldir - -!equals(_PRO_FILE_PWD_, $$OUT_PWD) { - cpqmldir.files = qmldir - cpqmldir.path = $$OUT_PWD - COPIES += cpqmldir -} - -qmldir.files = qmldir -unix { - installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /) - qmldir.path = $$installPath - target.path = $$installPath - INSTALLS += target qmldir -} - diff --git a/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy_plugin.h b/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy_plugin.h deleted file mode 100644 index 86e80e6a08..0000000000 --- a/tests/manual/qmlplugindump/tests/dumper/Dummy/dummy_plugin.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef DUMMY_PLUGIN_H -#define DUMMY_PLUGIN_H - -#include <QQmlExtensionPlugin> - -class DummyPlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) - -public: - void registerTypes(const char *uri); -}; - -#endif // DUMMY_PLUGIN_H - diff --git a/tests/manual/qmlplugindump/tests/dumper/Dummy/qmldir b/tests/manual/qmlplugindump/tests/dumper/Dummy/qmldir deleted file mode 100644 index a1b2e789ba..0000000000 --- a/tests/manual/qmlplugindump/tests/dumper/Dummy/qmldir +++ /dev/null @@ -1,3 +0,0 @@ -module tests.dumper.Dummy -plugin Dummy - diff --git a/tests/manual/qmlplugindump/tests/dumper/Imports/CompositeImports.qml b/tests/manual/qmlplugindump/tests/dumper/Imports/CompositeImports.qml deleted file mode 100644 index b1055b6992..0000000000 --- a/tests/manual/qmlplugindump/tests/dumper/Imports/CompositeImports.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -QtObject { - property int test: 0 -} diff --git a/tests/manual/qmlplugindump/tests/dumper/Imports/imports.pro b/tests/manual/qmlplugindump/tests/dumper/Imports/imports.pro deleted file mode 100644 index 1033c7a28f..0000000000 --- a/tests/manual/qmlplugindump/tests/dumper/Imports/imports.pro +++ /dev/null @@ -1,33 +0,0 @@ -TEMPLATE = lib -TARGET = Imports -QT += qml quick -CONFIG += qt plugin - -TARGET = $$qtLibraryTarget($$TARGET) -uri = tests.dumper.Imports - -# Input -SOURCES += \ - imports_plugin.cpp \ - imports.cpp - -HEADERS += \ - imports_plugin.h \ - imports.h - -DISTFILES = qmldir - -!equals(_PRO_FILE_PWD_, $$OUT_PWD) { - cpqmldir.files = qmldir - cpqmldir.path = $$OUT_PWD - COPIES += cpqmldir -} - -qmldir.files = qmldir -unix { - installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /) - qmldir.path = $$installPath - target.path = $$installPath - INSTALLS += target qmldir -} - diff --git a/tests/manual/qmlplugindump/tests/dumper/Imports/imports_plugin.h b/tests/manual/qmlplugindump/tests/dumper/Imports/imports_plugin.h deleted file mode 100644 index fd09584d47..0000000000 --- a/tests/manual/qmlplugindump/tests/dumper/Imports/imports_plugin.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef IMPORTS_PLUGIN_H -#define IMPORTS_PLUGIN_H - -#include <QQmlExtensionPlugin> - -class ImportsPlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) - -public: - void registerTypes(const char *uri); -}; - -#endif // IMPORTS_PLUGIN_H - diff --git a/tests/manual/qmlplugindump/tests/dumper/Imports/qmldir b/tests/manual/qmlplugindump/tests/dumper/Imports/qmldir deleted file mode 100644 index efab493dc8..0000000000 --- a/tests/manual/qmlplugindump/tests/dumper/Imports/qmldir +++ /dev/null @@ -1,3 +0,0 @@ -module tests.dumper.Imports -plugin Imports -CompositeImports 1.0 CompositeImports.qml diff --git a/tests/manual/qmlplugindump/tests/dumper/Singleton/CompositeSingleton.qml b/tests/manual/qmlplugindump/tests/dumper/Singleton/CompositeSingleton.qml deleted file mode 100644 index b47d2e98f4..0000000000 --- a/tests/manual/qmlplugindump/tests/dumper/Singleton/CompositeSingleton.qml +++ /dev/null @@ -1,6 +0,0 @@ -pragma Singleton -import QtQuick 2.0 - -QtObject { - property int test: 0 -} diff --git a/tests/manual/qmlplugindump/tests/dumper/Singleton/qmldir b/tests/manual/qmlplugindump/tests/dumper/Singleton/qmldir deleted file mode 100644 index dec4063fda..0000000000 --- a/tests/manual/qmlplugindump/tests/dumper/Singleton/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -module tests.dumper.Singleton -singleton CompositeSingleton 1.0 CompositeSingleton.qml diff --git a/tests/manual/qmlplugindump/tests/dumper/Versions/plugin.qmltypes b/tests/manual/qmlplugindump/tests/dumper/Versions/plugin.qmltypes deleted file mode 100644 index 0e09c2cfc7..0000000000 --- a/tests/manual/qmlplugindump/tests/dumper/Versions/plugin.qmltypes +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick.tooling 1.2 - -// This file describes the plugin-supplied types contained in the library. -// It is used for QML tooling purposes only. -// -// This file was auto-generated by: -// 'qmlplugindump tests.dumper.versions 1.1 .' - -Module { - dependencies: ["QtQuick 2.0"] - Component { - name: "Versions" - defaultProperty: "data" - prototype: "QQuickItem" - exports: ["Versions 1.0", "Versions 1.1"] - exportMetaObjectRevisions: [0, 1] - Property { name: "foo"; type: "int" } - Property { name: "bar"; revision: 1; type: "int" } - Property { name: "baz"; revision: 2; type: "int" } - } -} diff --git a/tests/manual/qmlplugindump/tests/dumper/Versions/qmldir b/tests/manual/qmlplugindump/tests/dumper/Versions/qmldir deleted file mode 100644 index 382225f517..0000000000 --- a/tests/manual/qmlplugindump/tests/dumper/Versions/qmldir +++ /dev/null @@ -1,3 +0,0 @@ -module tests.dumper.Versions -plugin Versions - diff --git a/tests/manual/qmlplugindump/tests/dumper/Versions/versions.cpp b/tests/manual/qmlplugindump/tests/dumper/Versions/versions.cpp deleted file mode 100644 index e5f435ca7f..0000000000 --- a/tests/manual/qmlplugindump/tests/dumper/Versions/versions.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "versions.h" - -Versions::Versions(QQuickItem *parent): - QQuickItem(parent) -{ - // By default, QQuickItem does not draw anything. If you subclass - // QQuickItem to create a visual item, you will need to uncomment the - // following line and re-implement updatePaintNode() - - // setFlag(ItemHasContents, true); -} - -Versions::~Versions() -{ -} - diff --git a/tests/manual/qmlplugindump/tests/dumper/Versions/versions.h b/tests/manual/qmlplugindump/tests/dumper/Versions/versions.h deleted file mode 100644 index 56403d90a7..0000000000 --- a/tests/manual/qmlplugindump/tests/dumper/Versions/versions.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef VERSIONS_H -#define VERSIONS_H - -#include <QQuickItem> - -class Versions : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(int foo READ foo WRITE setFoo NOTIFY fooChanged) - Q_PROPERTY(int bar READ bar WRITE setBar NOTIFY barChanged REVISION 1) - Q_PROPERTY(int baz READ baz WRITE setBaz NOTIFY bazChanged REVISION 2) - -public: - Versions(QQuickItem *parent = 0); - ~Versions(); - int foo() const { return m_foo; } - void setFoo(int value) { m_foo = value; } - int bar() const { return m_bar; } - void setBar(int value) { m_bar = value; } - int baz() const { return m_baz; } - void setBaz(int value) { m_baz = value; } -signals: - void fooChanged(); - void barChanged(); - void bazChanged(); -private: - int m_foo; - int m_bar; - int m_baz; -}; - -#endif // VERSIONS_H - diff --git a/tests/manual/qmlplugindump/tests/dumper/Versions/versions.pro b/tests/manual/qmlplugindump/tests/dumper/Versions/versions.pro deleted file mode 100644 index d59470862d..0000000000 --- a/tests/manual/qmlplugindump/tests/dumper/Versions/versions.pro +++ /dev/null @@ -1,33 +0,0 @@ -TEMPLATE = lib -TARGET = Versions -QT += qml quick -CONFIG += qt plugin - -TARGET = $$qtLibraryTarget($$TARGET) -uri = tests.dumper.Versions - -# Input -SOURCES += \ - versions_plugin.cpp \ - versions.cpp - -HEADERS += \ - versions_plugin.h \ - versions.h - -DISTFILES = qmldir - -!equals(_PRO_FILE_PWD_, $$OUT_PWD) { - cpqmldir.files = qmldir - cpqmldir.path = $$OUT_PWD - COPIES += cpqmldir -} - -qmldir.files = qmldir -unix { - installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /) - qmldir.path = $$installPath - target.path = $$installPath - INSTALLS += target qmldir -} - diff --git a/tests/manual/qmlplugindump/tests/dumper/Versions/versions_plugin.cpp b/tests/manual/qmlplugindump/tests/dumper/Versions/versions_plugin.cpp deleted file mode 100644 index 59741f96a3..0000000000 --- a/tests/manual/qmlplugindump/tests/dumper/Versions/versions_plugin.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "versions_plugin.h" -#include "versions.h" - -#include <qqml.h> - -void VersionsPlugin::registerTypes(const char *uri) -{ - // @uri tests.dumper.versions - qmlRegisterType<Versions>(uri, 1, 0, "Versions"); - qmlRegisterType<Versions, 1>(uri, 1, 1, "Versions"); -} - - diff --git a/tests/manual/qmlplugindump/tests/dumper/Versions/versions_plugin.h b/tests/manual/qmlplugindump/tests/dumper/Versions/versions_plugin.h deleted file mode 100644 index 4ba68a8125..0000000000 --- a/tests/manual/qmlplugindump/tests/dumper/Versions/versions_plugin.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef VERSIONS_PLUGIN_H -#define VERSIONS_PLUGIN_H - -#include <QQmlExtensionPlugin> - -class VersionsPlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) - -public: - void registerTypes(const char *uri); -}; - -#endif // VERSIONS_PLUGIN_H - diff --git a/tests/manual/qmlplugindump/tst_qmlplugindump.cpp b/tests/manual/qmlplugindump/tst_qmlplugindump.cpp deleted file mode 100644 index 1bedd4427b..0000000000 --- a/tests/manual/qmlplugindump/tst_qmlplugindump.cpp +++ /dev/null @@ -1,372 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qtest.h> -#include <QLibraryInfo> -#include <QDir> -#include <QDirIterator> -#include <QProcess> -#include <QRegularExpression> -#include <QJsonDocument> -#include <QJsonParseError> -#include <QJsonObject> -#include <QJsonArray> -#include <QJsonValue> - -#include <QDebug> - -#include <cstdlib> -#include <algorithm> - - -// System dependent definitions - -#if defined(Q_OS_WIN) - -static const char* systemMakeProgram = "jom"; -static const char* systemQmlplugindumpProgram = "qmlplugindump.exe"; - -static const QString libname(const QString &name) -{ - return name + QLatin1String(".dll"); -} - -#elif defined(Q_OS_DARWIN) - -static const char* systemMakeProgram = "make"; -static const char* systemQmlplugindumpProgram = "qmlplugindump"; - -static const QString libname(const QString &name) -{ - return QLatin1String("lib") + name + QLatin1String(".dynlib"); -} - -#else - -static const char* systemMakeProgram = "make"; -static const char* systemQmlplugindumpProgram = "qmlplugindump"; - -static const QString libname(const QString &name) -{ - return QLatin1String("lib") + name + QLatin1String(".so"); -} - -#endif - - -// Utilities - - -// Functor for matching a list of regular expression on a buffer. -// -class RegexpsChecker -{ -public: - RegexpsChecker(const QStringList &expected) : m_expected(expected) {} - bool operator()(const QByteArray &buffer) const - { - QRegularExpression re; - QRegularExpressionMatch m; - for (const QString &e : m_expected) { - re.setPattern(e); - m = re.match(QString::fromLatin1(buffer)); - if (!m.hasMatch()) { - qWarning() << "Pattern not found: " << e; - return false; - } - } - return true; - } -private: - const QStringList m_expected; -}; - - -// Run an external process in given path and with given arguments, if presents. -// Optionally run a regexp check on the process standard output. -// -bool run(const QString &path, const QString &cmd, const QStringList &args=QStringList(), - const RegexpsChecker *checker=0) { - QProcess process; - process.setWorkingDirectory(path); - process.start(cmd, args); - process.waitForFinished(); - if (process.error() == QProcess::FailedToStart) { - qWarning() << cmd << args << "failed to start."; - return false; - } - if (process.error() == QProcess::Crashed) { - qWarning() << cmd << args << "crashed."; - return false; - } - if (process.exitStatus() != QProcess::NormalExit) { - qWarning() << cmd << args << "exited with code: " << process.exitCode(); - return false; - } - if (checker) - (*checker)(process.readAllStandardOutput()); - return true; -} - - -// Test Definition -// -// A test is defined by id, project, version and expected patterns that should -// match the output of qmlplugindump. -// -class Test -{ -public: - Test(const QString &testId) : id(testId) {} - Test(const QString &testId, const QString &prjName, const QString &prjVersion, - const QStringList &expectedResult) : - id(testId), project(prjName), version(prjVersion), expected(expectedResult) {} - QString id; - QString project; - QString version; - QStringList expected; - bool isNull() const - { - return project.isEmpty() || version.isEmpty(); - } - friend bool operator<(const Test &t1, const Test &t2) { return t1.id < t2.id; } -}; - - -// Create test from a json document. -// -// The json document must contains these fields: -// -// project: string -// version: string -// expected: [string*] -// -// qmlplugindumper will be invoked with these arguments: -// -// qmlplugindumper tests.dumper.<PROJECT> <VERSION> -// -// PROJECT is the name of the sample project. It is used as a project name -// and as the last components of the URI: tests.dumper.<PROJECT>; the project -// path must be ./test/dumper/<PROJECT>. -// -// EXPECTED is a list of regular expression patterns that must match the -// plugin.qmltypes produced by qmlplugindump. -// -Test createTest(const QString &id, const QJsonObject &def) -{ - QJsonValue project = def.value(QLatin1String("project")); - QJsonValue version = def.value(QLatin1String("version")); - QJsonValue expected = def.value(QLatin1String("expected")); - if (!project.isString() || !version.isString() || !expected.isArray()){ - qWarning() << "Wrong definition for test: " << id << "."; - return Test(id); - } - QStringList patterns; - const auto expectedArray = expected.toArray(); - for (const QJsonValue &x : expectedArray) { - if (!x.isString()) { - qWarning() << "Wrong definition for test: " << id << "."; - return Test(id); - } else { - patterns << x.toString(); - } - } - return Test(id, project.toString(), version.toString(), patterns); -} - -// Read a test definition from a file. -// -// The file must define a json document that `createTest' can understand. -// -Test readTestDefinition(const QFileInfo &file) -{ - const QString path = file.filePath(); - const QString id = file.baseName(); - QFile fd(path); - if (fd.open(QIODevice::ReadOnly)) { - QTextStream in(&fd); - QJsonParseError err; - QJsonDocument doc = QJsonDocument::fromJson(in.readAll().toLatin1(), &err); - fd.close(); - if (err.error != QJsonParseError::NoError) { - qWarning() << "Parse error in test \"" << id << "\":" << err.errorString(); - return Test(id); - } - QJsonObject obj = doc.object(); - return createTest(id, obj); - } - qWarning() << "Cannot open " << path << "."; - return Test(id); -} - -// Read all files in `path' as test definitions. -// -// Returns a list of tests sorted lexicographically. -// -QList<Test> readAllTestDefinitions(const QString &path) -{ - QList<Test> samples; - QDirIterator it(path, QDir::Files); - while (it.hasNext()) { - it.next(); - samples << readTestDefinition(it.fileInfo()); - } - std::sort(samples.begin(), samples.end()); - return samples; -} - - -// TEST SUITE - -class tst_qmlplugindump : public QObject -{ - Q_OBJECT -public: - tst_qmlplugindump(); - -private slots: - void initTestCase(); - void builtins(); - void plugin_data(); - void plugin(); - void cleanupTestCase(); - -private: - static const char *prefix; - QString dumper; - QList<Test> tests; - QString samplePath(const QString &name); - bool compileSample(const QString &name); - bool cleanUpSample(const QString &name); -}; - -const char *tst_qmlplugindump::prefix = "tests.dumper."; - -tst_qmlplugindump::tst_qmlplugindump() -{ -} - -QString tst_qmlplugindump::samplePath(const QString &name) -{ - return QCoreApplication::applicationDirPath() - + QLatin1Char('/') - + QString(QLatin1String(prefix)).replace(QRegularExpression(QLatin1String("\\.")), - QLatin1String("/")).append(name); -} - -bool tst_qmlplugindump::compileSample(const QString &name) -{ - const QString path = samplePath(name); - return run(path, QLatin1String("qmake")) - && run(path, QLatin1String(systemMakeProgram)); -} - -bool tst_qmlplugindump::cleanUpSample(const QString &name) -{ - const QString path = samplePath(name); - const QStringList args(QLatin1String("clean")); - if (!run(path, QLatin1String(systemMakeProgram), args)) - return false; - - const QString libfile = path + QLatin1Char('/') + libname(name); - - if (!QFile::remove(libfile)) { - qWarning() << "Cannot remove" << libfile << "."; - return false; - } - return true; -} - -void tst_qmlplugindump::initTestCase() -{ - dumper = QLibraryInfo::location(QLibraryInfo::BinariesPath); - tests = readAllTestDefinitions(QCoreApplication::applicationDirPath() - + QLatin1String("/definitions")); - - dumper += QLatin1Char('/') + QLatin1String(systemQmlplugindumpProgram); - - if (!QFileInfo(dumper).exists()) { - QString message = QString::fromLatin1("qmlplugindump executable not found (looked for %0)") - .arg(dumper); - QFAIL(qPrintable(message)); - } -} - -void tst_qmlplugindump::builtins() -{ - QStringList args; - args += QLatin1String("-builtins"); - RegexpsChecker check(QStringList(QLatin1String("Module {"))); - QString cwd = QCoreApplication::applicationDirPath(); - QVERIFY(run(cwd, dumper, args, &check)); -} - -void tst_qmlplugindump::plugin_data() -{ - QTest::addColumn<QString>("project"); - QTest::addColumn<QString>("version"); - QTest::addColumn<QStringList>("expected"); - - for (const Test &t : qAsConst(tests)) { - if (t.isNull()) - QSKIP("Errors in test definition."); - QTest::newRow(t.id.toLatin1().data()) << t.project << t.version << t.expected; - } -} - -void tst_qmlplugindump::plugin() -{ - QFETCH(QString, project); - QFETCH(QString, version); - QFETCH(QStringList, expected); - - QVERIFY(compileSample(project)); - - QStringList args; - QString url = QLatin1String("tests.dumper.") + project; - QString cwd = QCoreApplication::applicationDirPath(); - args << QLatin1String("-nonrelocatable") << url << version << cwd; - RegexpsChecker check(expected); - QVERIFY(run(cwd, dumper, args, &check)); -} - -void tst_qmlplugindump::cleanupTestCase() -{ - QSet<const QString> projects; - for (const Test &t : qAsConst(tests)) - projects.insert(t.project); - for (const QString &p : qAsConst(projects)) { - if (!cleanUpSample(p)) - qWarning() << "Error in cleaning up project" << p << "."; - } -} - - -QTEST_MAIN(tst_qmlplugindump) - -#include "tst_qmlplugindump.moc" diff --git a/tests/manual/qmltypememory/TestPlugin/plugin.cpp b/tests/manual/qmltypememory/TestPlugin/plugin.cpp index d6cbf05a55..2f0802eba8 100644 --- a/tests/manual/qmltypememory/TestPlugin/plugin.cpp +++ b/tests/manual/qmltypememory/TestPlugin/plugin.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2013 Research In Motion. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the tests of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/tests/manual/quickwidgetviewer/main.cpp b/tests/manual/quickwidgetviewer/main.cpp new file mode 100644 index 0000000000..0f305b0328 --- /dev/null +++ b/tests/manual/quickwidgetviewer/main.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> +#include <QCommandLineOption> +#include <QCommandLineParser> +#include <QDebug> +#include <QDir> +#include <QFileDialog> +#include <QOpenGLFunctions> +#include <QOpenGLContext> +#include <QQmlEngine> +#include <QQuickWidget> +#include <QUrl> + +#include <iostream> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + QCoreApplication::setApplicationName("QQuickWidget Viewer"); + QCoreApplication::setOrganizationName("QtProject"); + QCoreApplication::setApplicationVersion(QT_VERSION_STR); + QCommandLineParser parser; + parser.addHelpOption(); + parser.addVersionOption(); + parser.addPositionalArgument("url", "The URL to open."); + parser.process(app); + + QUrl url; + if (parser.positionalArguments().isEmpty()) { + QFileDialog fileDialog(nullptr, "Select QML File"); + fileDialog.setMimeTypeFilters(QStringList("text/x-qml")); + if (fileDialog.exec() != QDialog::Accepted) + return 0; + url = fileDialog.selectedUrls().constFirst(); + } else { + url = QUrl::fromUserInput(parser.positionalArguments().constFirst(), + QDir::currentPath(), QUrl::AssumeLocalFile); + if (!url.isValid()) { + std::cerr << qPrintable(url.errorString()) << '\n'; + return -1; + } + } + + QQuickWidget w(url); + w.setAttribute(Qt::WA_AcceptTouchEvents); + if (w.status() == QQuickWidget::Error) + return -1; + QObject::connect(w.engine(), &QQmlEngine::quit, &app, &QCoreApplication::quit); + w.show(); + + std::cout << "Qt " << QT_VERSION_STR << ' ' << qPrintable(app.platformName()); + if (QOpenGLContext *openglContext = w.quickWindow()->openglContext()) { + QOpenGLFunctions *glFunctions = openglContext->functions(); + std::cout << " OpenGL \"" << glFunctions->glGetString(GL_RENDERER) + << "\" \"" << glFunctions->glGetString(GL_VERSION) << '"'; + } + const qreal devicePixelRatio = w.devicePixelRatioF(); + if (!qFuzzyCompare(devicePixelRatio, qreal(1))) + std::cout << ", DPR=" << devicePixelRatio; + std::cout << '\n'; + + return app.exec(); + +} diff --git a/tests/manual/quickwidgetviewer/quickwidgetviewer.pro b/tests/manual/quickwidgetviewer/quickwidgetviewer.pro new file mode 100644 index 0000000000..a32d05e174 --- /dev/null +++ b/tests/manual/quickwidgetviewer/quickwidgetviewer.pro @@ -0,0 +1,4 @@ +TEMPLATE = app +QT += quickwidgets +CONFIG += c++11 console +SOURCES += main.cpp diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_borders_exceed_height.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_borders_exceed_height.qml index c4321d25bb..1e2885baed 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_borders_exceed_height.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_borders_exceed_height.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_borders_exceed_width.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_borders_exceed_width.qml index 328ff40008..437f10dd97 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_borders_exceed_width.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_borders_exceed_width.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_smoothed.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_smoothed.qml index 804567cf19..12c600c4af 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_smoothed.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_smoothed.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed.qml index b10554ad66..c3d4e5b018 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_border_overlap.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_border_overlap.qml index 73cc53ed2b..5d645902ec 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_border_overlap.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_border_overlap.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_negative_borders.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_negative_borders.qml index 8356f02614..153b77d642 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_negative_borders.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_negative_borders.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_borders.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_borders.qml index 9213589648..687a54ee80 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_borders.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_borders.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_bottom.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_bottom.qml index 615abdee20..70bd5c0f14 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_bottom.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_bottom.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_center.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_center.qml index 58ed4d44dc..98d2b867b8 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_center.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_center.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_left.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_left.qml index 7e0045bf24..64cd9d30cc 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_left.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_left.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_right.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_right.qml index 04c2d021f0..6d63475cfd 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_right.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_right.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_right_left.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_right_left.qml index 5210bab321..6d2193633a 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_right_left.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_right_left.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_top.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_top.qml index 2e89496c92..c3c8dfb7f4 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_top.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_top.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_top_bottom.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_top_bottom.qml index 4388601f13..a32827cfc3 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_top_bottom.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_top_bottom.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/text/text_advance_bidi_ltr.qml b/tests/manual/scenegraph_lancelot/data/text/text_advance_bidi_ltr.qml index 2f40aece89..e5d230e309 100644 --- a/tests/manual/scenegraph_lancelot/data/text/text_advance_bidi_ltr.qml +++ b/tests/manual/scenegraph_lancelot/data/text/text_advance_bidi_ltr.qml @@ -1,4 +1,4 @@ -import QtQuick 2.0 +import QtQuick 2.10 Item { width: 320 diff --git a/tests/manual/scenegraph_lancelot/data/text/text_advance_hebrew.qml b/tests/manual/scenegraph_lancelot/data/text/text_advance_hebrew.qml index 0a9dce4d82..000977f964 100644 --- a/tests/manual/scenegraph_lancelot/data/text/text_advance_hebrew.qml +++ b/tests/manual/scenegraph_lancelot/data/text/text_advance_hebrew.qml @@ -1,4 +1,4 @@ -import QtQuick 2.0 +import QtQuick 2.10 Item { width: 320 diff --git a/tests/manual/scenegraph_lancelot/data/text/text_advance_latin.qml b/tests/manual/scenegraph_lancelot/data/text/text_advance_latin.qml index ccab5d8c64..f5fc501bb8 100644 --- a/tests/manual/scenegraph_lancelot/data/text/text_advance_latin.qml +++ b/tests/manual/scenegraph_lancelot/data/text/text_advance_latin.qml @@ -1,4 +1,4 @@ -import QtQuick 2.0 +import QtQuick 2.10 Item { width: 320 diff --git a/tests/manual/scenegraph_lancelot/data/text/text_advance_multiline.qml b/tests/manual/scenegraph_lancelot/data/text/text_advance_multiline.qml index ae0f10718c..a58a7cb40c 100644 --- a/tests/manual/scenegraph_lancelot/data/text/text_advance_multiline.qml +++ b/tests/manual/scenegraph_lancelot/data/text/text_advance_multiline.qml @@ -1,4 +1,4 @@ -import QtQuick 2.0 +import QtQuick 2.10 Item { width: 320 diff --git a/tests/manual/scenegraph_lancelot/data/text/text_advance_multiparagraph.qml b/tests/manual/scenegraph_lancelot/data/text/text_advance_multiparagraph.qml index 76f0910680..0627656ea6 100644 --- a/tests/manual/scenegraph_lancelot/data/text/text_advance_multiparagraph.qml +++ b/tests/manual/scenegraph_lancelot/data/text/text_advance_multiparagraph.qml @@ -1,4 +1,4 @@ -import QtQuick 2.0 +import QtQuick 2.10 Item { width: 320 diff --git a/tests/manual/scenegraph_lancelot/data/text/text_advance_multiparagraph_multifontsizes.qml b/tests/manual/scenegraph_lancelot/data/text/text_advance_multiparagraph_multifontsizes.qml index de33d65cdc..fb1f252148 100644 --- a/tests/manual/scenegraph_lancelot/data/text/text_advance_multiparagraph_multifontsizes.qml +++ b/tests/manual/scenegraph_lancelot/data/text/text_advance_multiparagraph_multifontsizes.qml @@ -1,4 +1,4 @@ -import QtQuick 2.0 +import QtQuick 2.10 Item { width: 320 diff --git a/tests/manual/scenegraph_lancelot/data/text/text_bengali_noshaping.qml b/tests/manual/scenegraph_lancelot/data/text/text_bengali_noshaping.qml new file mode 100644 index 0000000000..343d5768e4 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/text_bengali_noshaping.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Text { + anchors.fill: parent + wrapMode: Text.WrapAtWordBoundaryOrAnywhere + font.family: "Arial" // Should use Lohit Bengali + font.pixelSize: 20 + font.preferShaping: false + text: "ধারা ১: সমস্ত মানুষ স্বাধীনভাবে সমান মর্যাদা এবং অধিকার নিয়ে জন্মগ্রহণ করে। তাঁদের বিবেক এবং বুদ্ধি আছে; সুতরাং সকলেরই একে অপরের প্রতি ভ্রাতৃত্বসুলভ মনোভাব নিয়ে আচরণ করা উচিৎ।" + } +} diff --git a/tests/manual/scenegraph_lancelot/data/text/text_emoji_hebrew.qml b/tests/manual/scenegraph_lancelot/data/text/text_emoji_hebrew.qml new file mode 100644 index 0000000000..b67d584a12 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/text_emoji_hebrew.qml @@ -0,0 +1,45 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Component { + id: component + Column { + property variant listModel: model + Repeater { + model: [Text.NativeRendering, Text.QtRendering] + Rectangle { + width: text.implicitWidth + height: text.implicitHeight + color: listModel.backGroundColor ? listModel.backGroundColor : "white" + + Text { + id: text + font.pixelSize: 32 + renderType: modelData + text: "א😃א😇א😍א😜א😸!" + + color: listModel.color ? listModel.color : "black" + opacity: listModel.opacity ? listModel.opacity : 1.0 + } + } + } + } + } + + Column { + anchors.centerIn: parent + Repeater { + model: ListModel { + ListElement { color: "black" } + ListElement { color: "blue" } + ListElement { color: "#990000ff" } + ListElement { opacity: 0.5 } + ListElement { backGroundColor: "green" } + } + delegate: component + } + } +} diff --git a/tests/manual/scenegraph_lancelot/data/text/text_emoji_zwj.qml b/tests/manual/scenegraph_lancelot/data/text/text_emoji_zwj.qml new file mode 100644 index 0000000000..4691ff7efd --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/text_emoji_zwj.qml @@ -0,0 +1,45 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Component { + id: component + Column { + property variant listModel: model + Repeater { + model: [Text.NativeRendering, Text.QtRendering] + Rectangle { + width: text.implicitWidth + height: text.implicitHeight + color: listModel.backGroundColor ? listModel.backGroundColor : "white" + + Text { + id: text + font.pixelSize: 32 + renderType: modelData + text: "👨👩👧👦" + + color: listModel.color ? listModel.color : "black" + opacity: listModel.opacity ? listModel.opacity : 1.0 + } + } + } + } + } + + Column { + anchors.centerIn: parent + Repeater { + model: ListModel { + ListElement { color: "black" } + ListElement { color: "blue" } + ListElement { color: "#990000ff" } + ListElement { opacity: 0.5 } + ListElement { backGroundColor: "green" } + } + delegate: component + } + } +} diff --git a/tests/manual/scenegraph_lancelot/data/text/text_latin_noshaping.qml b/tests/manual/scenegraph_lancelot/data/text/text_latin_noshaping.qml new file mode 100644 index 0000000000..6dc6c2f3d6 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/text_latin_noshaping.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Text { + anchors.fill: parent + wrapMode: Text.WrapAtWordBoundaryOrAnywhere + font.family: "Arial" + font.pixelSize: 20 + font.preferShaping: false + text: "Are griffins birds or mammals?" + } +} diff --git a/tests/manual/scenegraph_lancelot/data/text/text_nokerning_latin.qml b/tests/manual/scenegraph_lancelot/data/text/text_nokerning_latin.qml new file mode 100644 index 0000000000..fd1d082c99 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/text_nokerning_latin.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Text { + text: "OATS FLAVOUR WAY" + anchors.centerIn: parent + + font.family: "Times New Roman" + font.italic: true + font.pixelSize: 30 + font.kerning: false + } +} diff --git a/tests/manual/shapestest/main.cpp b/tests/manual/shapestest/main.cpp index b9b93fbf9f..479ff0a1eb 100644 --- a/tests/manual/shapestest/main.cpp +++ b/tests/manual/shapestest/main.cpp @@ -1,38 +1,26 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** diff --git a/tests/manual/shapestest/shapestest.qml b/tests/manual/shapestest/shapestest.qml index df53f088ae..de9e20b8f3 100644 --- a/tests/manual/shapestest/shapestest.qml +++ b/tests/manual/shapestest/shapestest.qml @@ -372,6 +372,62 @@ Rectangle { } } } + + Rectangle { + border.color: "purple" + color: "transparent" + width: 200 + height: 100 + Shape { + anchors.fill: parent + ShapePath { + strokeWidth: -1 + strokeColor: "red" + fillGradient: RadialGradient { + centerX: 100; centerY: 50 + focalX: centerX; focalY: centerY + centerRadius: 50 + spread: RadialGradient.ReflectSpread + GradientStop { position: 0; color: "blue" } + GradientStop { position: 0.2; color: "green" } + GradientStop { position: 0.4; color: "red" } + GradientStop { position: 0.6; color: "yellow" } + GradientStop { position: 1; color: "cyan" } + } + PathLine { x: 0; y: 100 } + PathLine { x: 200; y: 100 } + PathLine { x: 200; y: 0 } + PathLine { x: 0; y: 0 } + } + } + } + + Rectangle { + border.color: "purple" + color: "transparent" + width: 200 + height: 100 + Shape { + anchors.fill: parent + ShapePath { + strokeWidth: -1 + strokeColor: "red" + fillGradient: ConicalGradient { + centerX: 100; centerY: 50 + angle: 90 + GradientStop { position: 0; color: "blue" } + GradientStop { position: 0.2; color: "green" } + GradientStop { position: 0.4; color: "red" } + GradientStop { position: 0.6; color: "yellow" } + GradientStop { position: 1; color: "cyan" } + } + PathLine { x: 0; y: 100 } + PathLine { x: 200; y: 100 } + PathLine { x: 200; y: 0 } + PathLine { x: 0; y: 0 } + } + } + } } } diff --git a/tests/manual/tableview/abstracttablemodel/Button.qml b/tests/manual/tableview/abstracttablemodel/Button.qml new file mode 100644 index 0000000000..2d4dcde80d --- /dev/null +++ b/tests/manual/tableview/abstracttablemodel/Button.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 + +Rectangle { + width: 100 + height: 40 + border.width: 1 + color: "lightgreen" + + property string text + signal clicked + + Text { + anchors.centerIn: parent + text: parent.text + } + + MouseArea { + anchors.fill: parent + onClicked: parent.clicked() + } +} diff --git a/tests/manual/tableview/abstracttablemodel/abstracttablemodel.pro b/tests/manual/tableview/abstracttablemodel/abstracttablemodel.pro new file mode 100644 index 0000000000..fee8edc6c8 --- /dev/null +++ b/tests/manual/tableview/abstracttablemodel/abstracttablemodel.pro @@ -0,0 +1,10 @@ +TEMPLATE = app +TARGET = tableview_abstracttablemodel +QT += qml quick +SOURCES += main.cpp +RESOURCES += main.qml Button.qml + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/tests/manual/tableview/abstracttablemodel/main.cpp b/tests/manual/tableview/abstracttablemodel/main.cpp new file mode 100644 index 0000000000..4fba938ee9 --- /dev/null +++ b/tests/manual/tableview/abstracttablemodel/main.cpp @@ -0,0 +1,256 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> +#include <QAbstractTableModel> +#include <QSet> +#include <QDebug> + +typedef QPair<QString, bool> CellData; + +class TestTableModel : public QAbstractTableModel +{ + Q_OBJECT + Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged) + Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount NOTIFY columnCountChanged) + +public: + TestTableModel(QObject *parent = nullptr) : QAbstractTableModel(parent) { } + + int rowCount(const QModelIndex & = QModelIndex()) const override { return m_rows; } + void setRowCount(int count) { + beginResetModel(); + m_rows = count; + rebuildModel(); + emit rowCountChanged(); + endResetModel(); + } + + int columnCount(const QModelIndex & = QModelIndex()) const override { return m_cols; } + void setColumnCount(int count) { + beginResetModel(); + m_cols = count; + rebuildModel(); + emit columnCountChanged(); + endResetModel(); + } + + int indexValue(const QModelIndex &index) const + { + return index.row() + (index.column() * rowCount()); + } + + void rebuildModel() + { + m_modelData = QVector<QVector<CellData>>(m_cols); + for (int x = 0; x < m_cols; ++x) { + m_modelData[x] = QVector<CellData>(m_rows); + for (int y = 0; y < m_rows; ++y) + m_modelData[x][y] = qMakePair(QStringLiteral("white"), false); + } + } + + QVariant data(const QModelIndex &index, int role) const override + { + if (!index.isValid()) + return QVariant(); + + switch (role) { + case Qt::DisplayRole: + return m_modelData[index.column()][index.row()].first; + case Qt::CheckStateRole: + return m_modelData[index.column()][index.row()].second; + default: + return QVariant(); + } + + return QVariant(); + } + + bool setData(const QModelIndex &index, const QVariant &value, + int role = Qt::EditRole) override + { + if (role != Qt::CheckStateRole) + return false; + + bool checked = value.toBool(); + auto &cellData = m_modelData[index.column()][index.row()]; + if (checked == cellData.second) + return false; + + cellData.second = checked; + + emit dataChanged(index, index, {role}); + return true; + } + + QHash<int, QByteArray> roleNames() const override + { + return { + {Qt::DisplayRole, "display"}, + {Qt::CheckStateRole, "checked"} + }; + } + + Q_INVOKABLE void insertRows(int row, int count) + { + insertRows(row, count, QModelIndex()); + } + + Q_INVOKABLE void removeRows(int row, int count) + { + removeRows(row, count, QModelIndex()); + } + + Q_INVOKABLE void insertColumns(int column, int count) + { + insertColumns(column, count, QModelIndex()); + } + + Q_INVOKABLE void removeColumns(int column, int count) + { + removeColumns(column, count, QModelIndex()); + } + + bool insertRows(int row, int count, const QModelIndex &) override + { + if (row > m_rows) + return false; + + beginInsertRows(QModelIndex(), row, row + count - 1); + + m_rows += count; + + for (int y = 0; y < count; ++y) { + for (int x = 0; x < m_cols; ++x) + m_modelData[x].insert(row, qMakePair(QStringLiteral("lightgreen"), false)); + } + + endInsertRows(); + + return true; + } + + bool removeRows(int row, int count, const QModelIndex &) override + { + if (row + count > m_rows) + count = m_rows - row; + if (count < 1) + return false; + + beginRemoveRows(QModelIndex(), row, row + count - 1); + + m_rows -= count; + + for (int y = 0; y < count; ++y) { + for (int x = 0; x < m_cols; ++x) + m_modelData[x].remove(row); + } + + endRemoveRows(); + + return true; + } + + bool insertColumns(int column, int count, const QModelIndex &) override + { + if (column > m_cols) + return false; + + beginInsertColumns(QModelIndex(), column, column + count - 1); + + m_cols += count; + + for (int x = 0; x < count; ++x) { + const int c = column + x; + m_modelData.insert(c, QVector<CellData>(m_rows)); + for (int y = 0; y < m_rows; ++y) + m_modelData[c][y] = qMakePair(QStringLiteral("lightblue"), false); + } + + endInsertColumns(); + + return true; + } + + bool removeColumns(int column, int count, const QModelIndex &) override + { + if (column + count > m_cols) + count = m_cols - column; + if (count < 1) + return false; + + beginRemoveColumns(QModelIndex(), column, column + count - 1); + + m_cols -= count; + + for (int x = 0; x < count; ++x) + m_modelData.remove(column + x); + + endRemoveColumns(); + + return true; + } + +signals: + void rowCountChanged(); + void columnCountChanged(); + +private: + int m_rows = 0; + int m_cols = 0; + + QVector<QVector<CellData>> m_modelData; +}; + +int main(int argc, char *argv[]) +{ + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QGuiApplication app(argc, argv); + + qmlRegisterType<TestTableModel>("TestTableModel", 0, 1, "TestTableModel"); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + + return app.exec(); +} + +#include "main.moc" diff --git a/tests/manual/tableview/abstracttablemodel/main.qml b/tests/manual/tableview/abstracttablemodel/main.qml new file mode 100644 index 0000000000..52967a1a0d --- /dev/null +++ b/tests/manual/tableview/abstracttablemodel/main.qml @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Window 2.3 +import QtQml.Models 2.2 +import TestTableModel 0.1 + +Window { + id: window + width: 640 + height: 480 + visible: true + + property int selectedX: -1 + property int selectedY: -1 + + TestTableModel { + id: tableModel + rowCount: 200 + columnCount: 5000 + } + + Rectangle { + anchors.fill: parent + anchors.margins: 10 + color: "darkgray" + + Row { + id: menu + x: 2 + y: 2 + spacing: 1 + Button { + text: "Add row" + onClicked: tableModel.insertRows(selectedY, 1) + } + Button { + text: "Remove row" + onClicked: tableModel.removeRows(selectedY, 1) + } + Button { + text: "Add column" + onClicked: tableModel.insertColumns(selectedX, 1) + } + Button { + text: "Remove column" + onClicked: tableModel.removeColumns(selectedX, 1) + } + } + Text { + anchors.right: parent.right + anchors.top: parent.top + anchors.margins: 2 + text: "x:" + selectedX + ", y:" + selectedY + } + + TableView { + id: tableView + anchors.left: parent.left + anchors.right: parent.right + anchors.top: menu.bottom + anchors.bottom: parent.bottom + anchors.margins: 2 + clip: true + + model: tableModel + delegate: tableViewDelegate + columnSpacing: 1 + rowSpacing: 1 + } + + Component { + id: tableViewDelegate + Rectangle { + id: delegate + implicitWidth: 100 + implicitHeight: 50 + color: display + border.width: row === selectedY && column == selectedX ? 2 : 0 + border.color: "darkgreen" + + Text { + anchors.fill: parent + text: column + ", " + row + + MouseArea { + anchors.fill: parent + onClicked: { + selectedX = column + selectedY = row + } + } + } + } + } + + } + +} diff --git a/tests/manual/tableview/listmodel/listmodel.pro b/tests/manual/tableview/listmodel/listmodel.pro new file mode 100644 index 0000000000..dbae0db2b1 --- /dev/null +++ b/tests/manual/tableview/listmodel/listmodel.pro @@ -0,0 +1,10 @@ +TEMPLATE = app +TARGET = tableview_listmodel +QT += qml quick +SOURCES += main.cpp +RESOURCES += main.qml + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/tests/manual/tableview/listmodel/main.cpp b/tests/manual/tableview/listmodel/main.cpp new file mode 100644 index 0000000000..2a3b90d392 --- /dev/null +++ b/tests/manual/tableview/listmodel/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + + return app.exec(); +} diff --git a/tests/manual/tableview/listmodel/main.qml b/tests/manual/tableview/listmodel/main.qml new file mode 100644 index 0000000000..dd0de60555 --- /dev/null +++ b/tests/manual/tableview/listmodel/main.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Window 2.3 +import QtQml.Models 2.2 + +Window { + id: window + width: 640 + height: 480 + visible: true + + ListModel { + id: listModel + Component.onCompleted: { + for (var i = 0; i < 30; ++i) + listModel.append({"name" : i}) + } + } + + Rectangle { + anchors.fill: parent + anchors.margins: 10 + color: "darkgray" + + TableView { + id: tableView + anchors.fill: parent + anchors.margins: 1 + clip: true + columnSpacing: 1 + rowSpacing: 1 + model: listModel + delegate: Component { + Rectangle { + id: tableDelegate + implicitWidth: 100 + implicitHeight: 50 + + Text { + anchors.centerIn: parent + text: name + "\n[" + column + ", " + row + "]" + } + } + } + } + } +} diff --git a/tests/manual/tableview/storagemodel/main.cpp b/tests/manual/tableview/storagemodel/main.cpp new file mode 100644 index 0000000000..97ae619ce4 --- /dev/null +++ b/tests/manual/tableview/storagemodel/main.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> +#include "storagemodel.h" + +int main(int argc, char *argv[]) +{ + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QGuiApplication app(argc, argv); + + qmlRegisterType<StorageModel>("StorageModel", 0, 1, "StorageModel"); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + + return app.exec(); +} + diff --git a/tests/manual/tableview/storagemodel/main.qml b/tests/manual/tableview/storagemodel/main.qml new file mode 100644 index 0000000000..725d7da7b0 --- /dev/null +++ b/tests/manual/tableview/storagemodel/main.qml @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Window 2.12 +import Qt.labs.qmlmodels 1.0 +import StorageModel 0.1 + +Window { + id: window + width: 480 + height: 300 + visible: true + color: "darkgray" + title: "Storage Volumes" + + TableView { + id: table + anchors.fill: parent + anchors.margins: 10 + clip: true + model: StorageModel { } + columnSpacing: 1 + rowSpacing: 1 + delegate: DelegateChooser { + role: "type" + DelegateChoice { + roleValue: "Value" + delegate: Rectangle { + color: "tomato" + implicitWidth: Math.max(100, label.implicitWidth + 8) + implicitHeight: label.implicitHeight + 4 + + Rectangle { + x: parent.width - width + width: value * parent.width / valueMax + height: parent.height + color: "white" + } + + Text { + id: label + anchors.baseline: parent.bottom + anchors.baselineOffset: -4 + anchors.left: parent.left + anchors.leftMargin: 4 + text: valueDisplay + " of " + valueMaxDisplay + " " + heading + } + } + } + DelegateChoice { + roleValue: "Flag" + // We could use a checkbox here but that would be another component (e.g. from Controls) + delegate: Rectangle { + implicitWidth: checkBox.implicitWidth + 8 + implicitHeight: checkBox.implicitHeight + 4 + Text { + id: checkBox + anchors.baseline: parent.bottom + anchors.baselineOffset: -4 + anchors.left: parent.left + anchors.leftMargin: 4 + text: (checkState ? "☑ " : "☐ ") + heading + } + } + } + DelegateChoice { + // roleValue: "String" // default delegate + delegate: Rectangle { + implicitWidth: stringLabel.implicitWidth + 8 + implicitHeight: stringLabel.implicitHeight + 4 + Text { + id: stringLabel + anchors.baseline: parent.bottom + anchors.baselineOffset: -4 + anchors.left: parent.left + anchors.leftMargin: 4 + text: display + } + } + } + } + } +} diff --git a/tests/manual/tableview/storagemodel/storagemodel.cpp b/tests/manual/tableview/storagemodel/storagemodel.cpp new file mode 100644 index 0000000000..b43454b249 --- /dev/null +++ b/tests/manual/tableview/storagemodel/storagemodel.cpp @@ -0,0 +1,278 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2016 Ivan Komissarov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "storagemodel.h" + +#include <QDir> +#include <QLocale> +#include <qmath.h> +#include <algorithm> +#include <cmath> + +StorageModel::StorageModel(QObject *parent) : + QAbstractTableModel(parent) +{ + refresh(); +} + +QHash<int, QByteArray> StorageModel::roleNames() const { + static auto roles = QHash<int, QByteArray> { + { int(Role::Type), "type" }, + { int(Role::Heading), "heading" }, + { int(Role::Value), "value" }, + { int(Role::ValueMax), "valueMax" }, + { int(Role::ValueDisplay), "valueDisplay" }, + { int(Role::ValueMaxDisplay), "valueMaxDisplay" }, + { Qt::CheckStateRole, "checkState" }, + }; + static auto ret = roles.unite(QAbstractTableModel::roleNames());; + return ret; +} + +void StorageModel::refresh() +{ + beginResetModel(); + m_volumes = QStorageInfo::mountedVolumes(); + std::sort(m_volumes.begin(), m_volumes.end(), + [](const QStorageInfo &st1, const QStorageInfo &st2) { + static const QString rootSortString = QStringLiteral(" "); + return (st1.isRoot() ? rootSortString : st1.rootPath()) + < (st2.isRoot() ? rootSortString : st2.rootPath()); + }); + endResetModel(); +} + +int StorageModel::columnCount(const QModelIndex &/*parent*/) const +{ + return int(Column::Count); +} + +int StorageModel::rowCount(const QModelIndex &parent) const +{ + if (parent.isValid()) + return 0; + return m_volumes.count(); +} + +Qt::ItemFlags StorageModel::flags(const QModelIndex &index) const +{ + Qt::ItemFlags result = QAbstractTableModel::flags(index); + switch (Column(index.column())) { + case Column::IsReady: + case Column::IsReadOnly: + case Column::IsValid: + result |= Qt::ItemIsUserCheckable; + break; + default: + break; + } + return result; +} + +QVariant StorageModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + switch (role) { + case Qt::DisplayRole: + case int(Role::ValueDisplay): { + const QStorageInfo &volume = m_volumes.at(index.row()); + switch (Column(index.column())) { + case Column::RootPath: + return QDir::toNativeSeparators(volume.rootPath()); + case Column::Name: + return volume.name(); + case Column::Device: + return volume.device(); + case Column::FileSystemName: + return volume.fileSystemType(); + case Column::Free: + return QLocale().formattedDataSize(volume.bytesFree()); + case Column::IsReady: + return volume.isReady(); + case Column::IsReadOnly: + return volume.isReadOnly(); + case Column::IsValid: + return volume.isValid(); + default: + break; + } + } break; + case Qt::CheckStateRole: { + const QStorageInfo &volume = m_volumes.at(index.row()); + switch (Column(index.column())) { + case Column::IsReady: + return volume.isReady(); + case Column::IsReadOnly: + return volume.isReadOnly(); + case Column::IsValid: + return volume.isValid(); + default: + break; + } + } break; + case Qt::TextAlignmentRole: + switch (Column(index.column())) { + case Column::Free: + return Qt::AlignTrailing; + default: + break; + } + return Qt::AlignLeading; + case Qt::ToolTipRole: { + QLocale locale; + const QStorageInfo &volume = m_volumes.at(index.row()); + return tr("Root path : %1\n" + "Name: %2\n" + "Display Name: %3\n" + "Device: %4\n" + "FileSystem: %5\n" + "Total size: %6\n" + "Free size: %7\n" + "Available size: %8\n" + "Is Ready: %9\n" + "Is Read-only: %10\n" + "Is Valid: %11\n" + "Is Root: %12" + ). + arg(QDir::toNativeSeparators(volume.rootPath())). + arg(volume.name()). + arg(volume.displayName()). + arg(QString::fromUtf8(volume.device())). + arg(QString::fromUtf8(volume.fileSystemType())). + arg(locale.formattedDataSize(volume.bytesTotal())). + arg(locale.formattedDataSize(volume.bytesFree())). + arg(locale.formattedDataSize(volume.bytesAvailable())). + arg(volume.isReady() ? tr("true") : tr("false")). + arg(volume.isReadOnly() ? tr("true") : tr("false")). + arg(volume.isValid() ? tr("true") : tr("false")). + arg(volume.isRoot() ? tr("true") : tr("false")); + } + case int(Role::Type): + switch (Column(index.column())) { + case Column::RootPath: + case Column::Name: + case Column::Device: + case Column::FileSystemName: + return QVariant::fromValue(Type::String); + break; + case Column::Free: + return QVariant::fromValue(Type::Value); + case Column::IsReady: + case Column::IsReadOnly: + case Column::IsValid: + return QVariant::fromValue(Type::Flag); + default: + break; + } + break; + case int(Role::Heading): + return headerData(index.column()); + case int(Role::Value): + switch (Column(index.column())) { + case Column::Free: + return m_volumes.at(index.row()).bytesFree(); + default: + break; + } + break; + case int(Role::ValueMax): + switch (Column(index.column())) { + case Column::Free: + return m_volumes.at(index.row()).bytesTotal(); + default: + break; + } + break; + case int(Role::ValueMaxDisplay): + switch (Column(index.column())) { + case Column::Free: + return QLocale().formattedDataSize(m_volumes.at(index.row()).bytesTotal()); + default: + break; + } + break; + } // switch (role) + return QVariant(); +} + +QVariant StorageModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (orientation != Qt::Horizontal) + return QVariant(); + + if (role != Qt::DisplayRole) + return QVariant(); + + switch (Column(section)) { + case Column::RootPath: + return tr("Root Path"); + case Column::Name: + return tr("Volume Name"); + case Column::Device: + return tr("Device"); + case Column::FileSystemName: + return tr("File System"); + case Column::Free: + return tr("Free"); + case Column::IsReady: + return tr("Ready"); + case Column::IsReadOnly: + return tr("Read-only"); + case Column::IsValid: + return tr("Valid"); + default: + break; + } + + return QVariant(); +} diff --git a/tests/manual/tableview/storagemodel/storagemodel.h b/tests/manual/tableview/storagemodel/storagemodel.h new file mode 100644 index 0000000000..6cbab3d850 --- /dev/null +++ b/tests/manual/tableview/storagemodel/storagemodel.h @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2016 Ivan Komissarov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef STORAGEMODEL_H +#define STORAGEMODEL_H + +#include <QAbstractTableModel> +#include <QStorageInfo> + +class StorageModel : public QAbstractTableModel +{ + Q_OBJECT + Q_DISABLE_COPY(StorageModel) +public: + enum class Column : int { + RootPath = 0, + Name, + Device, + FileSystemName, + Free, + IsReady, + IsReadOnly, + IsValid, + Count + }; + Q_ENUM(Column) + + enum class Role : int { + Type = Qt::UserRole + 1, + Heading, + Value, + ValueMax, // If we had ValueMin, it would always be zero in this example + ValueDisplay, + ValueMaxDisplay, + Count + }; + Q_ENUM(Role) + + enum class Type : int { + String, // use Qt::DisplayRole + Value, // use Role::Value and Role::ValueMax + Flag, // use Qt::CheckStateRole + Count + }; + Q_ENUM(Type) + + explicit StorageModel(QObject *parent = nullptr); + + int columnCount(const QModelIndex &parent) const override; + int rowCount(const QModelIndex &parent) const override; + QHash<int, QByteArray> roleNames() const override; + + QVariant data(const QModelIndex &index, int role) const override; + Qt::ItemFlags flags(const QModelIndex &index) const override; + QVariant headerData(int section, Qt::Orientation orientation = Qt::Horizontal, int role = Qt::DisplayRole) const override; + +public slots: + void refresh(); + +private: + QList<QStorageInfo> m_volumes; +}; + +#endif // STORAGEMODEL_H diff --git a/tests/manual/tableview/storagemodel/storagemodel.pro b/tests/manual/tableview/storagemodel/storagemodel.pro new file mode 100644 index 0000000000..c6a018239e --- /dev/null +++ b/tests/manual/tableview/storagemodel/storagemodel.pro @@ -0,0 +1,11 @@ +TEMPLATE = app +TARGET = tableview_storage +QT += qml quick +SOURCES += main.cpp storagemodel.cpp +HEADERS += storagemodel.h +RESOURCES += main.qml + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/tests/manual/tableview/tablemodel/form/RowForm.qml b/tests/manual/tableview/tablemodel/form/RowForm.qml new file mode 100644 index 0000000000..428682008a --- /dev/null +++ b/tests/manual/tableview/tablemodel/form/RowForm.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.11 + +ScrollView { + clip: true + + function inputAsRow() { + return [ + { checkable: checkableCheckBox.checked, checked: checkedCheckBox.checked }, + { amount: amountSpinBox.value }, + { fruitType: fruitTypeTextField.text }, + { fruitName: fruitNameTextField.text }, + { fruitPrice: parseFloat(fruitPriceTextField.text) }, + ] + } + + default property alias content: gridLayout.children + + GridLayout { + id: gridLayout + columns: 2 + + RowLayout { + Layout.columnSpan: 2 + + Label { + text: "checkable" + } + CheckBox { + id: checkableCheckBox + checked: true + } + + Label { + text: "checked" + } + CheckBox { + id: checkedCheckBox + } + } + + Label { + text: "amount" + } + SpinBox { + id: amountSpinBox + value: 1 + } + + Label { + text: "fruitType" + } + TextField { + id: fruitTypeTextField + text: "Pear" + } + + Label { + text: "fruitName" + } + TextField { + id: fruitNameTextField + text: "Williams" + } + + Label { + text: "fruitPrice" + } + TextField { + id: fruitPriceTextField + text: "1.50" + } + } +} diff --git a/tests/manual/tableview/tablemodel/form/form.pro b/tests/manual/tableview/tablemodel/form/form.pro new file mode 100644 index 0000000000..ba6f7a91b1 --- /dev/null +++ b/tests/manual/tableview/tablemodel/form/form.pro @@ -0,0 +1,10 @@ +TEMPLATE = app +TARGET = form +QT += qml quick +SOURCES += main.cpp +RESOURCES += main.qml RowForm.qml + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/tests/manual/tableview/tablemodel/form/main.cpp b/tests/manual/tableview/tablemodel/form/main.cpp new file mode 100644 index 0000000000..2a3b90d392 --- /dev/null +++ b/tests/manual/tableview/tablemodel/form/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + + return app.exec(); +} diff --git a/tests/manual/tableview/tablemodel/form/main.qml b/tests/manual/tableview/tablemodel/form/main.qml new file mode 100644 index 0000000000..21ecd8edbb --- /dev/null +++ b/tests/manual/tableview/tablemodel/form/main.qml @@ -0,0 +1,284 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Controls 2.5 +import QtQuick.Layouts 1.12 +import QtQuick.Window 2.12 +import Qt.labs.qmlmodels 1.0 + +ApplicationWindow { + id: window + width: 800 + height: 800 + visible: true + + ColumnLayout { + anchors.fill: parent + + TableView { + id: tableView + boundsBehavior: Flickable.StopAtBounds + + ScrollBar.horizontal: ScrollBar {} + ScrollBar.vertical: ScrollBar {} + + Layout.minimumHeight: window.height / 2 + Layout.fillWidth: true + Layout.fillHeight: true + + model: TableModel { + // One row = one type of fruit that can be ordered + rows: [ + [ + // Each object (line) is one cell/column, + // and each property in that object is a role. + { checked: false, checkable: true }, + { amount: 1 }, + { fruitType: "Apple" }, + { fruitName: "Granny Smith" }, + { fruitPrice: 1.50 } + ], + [ + { checked: true, checkable: true }, + { amount: 4 }, + { fruitType: "Orange" }, + { fruitName: "Navel" }, + { fruitPrice: 2.50 } + ], + [ + { checked: false, checkable: true }, + { amount: 1 }, + { fruitType: "Banana" }, + { fruitName: "Cavendish" }, + { fruitPrice: 3.50 } + ] + ] + } + + delegate: DelegateChooser { + DelegateChoice { + column: 0 + delegate: CheckBox { + objectName: "tableViewCheckBoxDelegate" + checked: model.checked + onToggled: model.checked = checked + } + } + DelegateChoice { + column: 1 + delegate: SpinBox { + objectName: "tableViewSpinBoxDelegate" + value: model.amount + onValueModified: model.amount = value + } + } + DelegateChoice { + delegate: TextField { + objectName: "tableViewTextFieldDelegate" + text: model.display + selectByMouse: true + implicitWidth: 140 + onAccepted: model.display = text + } + } + } + } + + TabBar { + id: operationTabBar + + Layout.fillWidth: true + Layout.preferredHeight: 40 + + TabButton { + text: "Append" + } + TabButton { + text: "Clear" + } + TabButton { + text: "Insert" + } + TabButton { + text: "Move" + } + TabButton { + text: "Remove" + } + TabButton { + text: "Set" + } + } + + StackLayout { + currentIndex: operationTabBar.currentIndex + + ColumnLayout { + RowForm { + id: appendRowForm + + Layout.fillHeight: true + } + + Button { + text: "Append" + + Layout.alignment: Qt.AlignRight + + onClicked: tableView.model.appendRow(appendRowForm.inputAsRow()) + } + } + ColumnLayout { + Button { + text: "Clear" + enabled: tableView.rows > 0 + + onClicked: tableView.model.clear() + } + } + ColumnLayout { + RowForm { + id: insertRowForm + + Layout.fillHeight: true + + Label { + text: "Insert index" + } + SpinBox { + id: insertIndexSpinBox + from: 0 + to: tableView.rows + } + } + + Button { + text: "Insert" + + Layout.alignment: Qt.AlignRight + + onClicked: tableView.model.insertRow(insertIndexSpinBox.value, insertRowForm.inputAsRow()) + } + } + GridLayout { + columns: 2 + + Label { + text: "Move from index" + } + SpinBox { + id: moveFromIndexSpinBox + from: 0 + to: tableView.rows > 0 ? tableView.rows - 1 : 0 + } + + Label { + text: "Move to index" + } + SpinBox { + id: moveToIndexSpinBox + from: 0 + to: tableView.rows > 0 ? tableView.rows - 1 : 0 + } + + Label { + text: "Rows to move" + } + SpinBox { + id: rowsToMoveSpinBox + from: 1 + to: tableView.rows + } + + Button { + text: "Move" + enabled: tableView.rows > 0 + + Layout.alignment: Qt.AlignRight + Layout.columnSpan: 2 + + onClicked: tableView.model.moveRow(moveFromIndexSpinBox.value, moveToIndexSpinBox.value, rowsToMoveSpinBox.value) + } + } + GridLayout { + Label { + text: "Remove index" + } + SpinBox { + id: removeIndexSpinBox + from: 0 + to: tableView.rows > 0 ? tableView.rows - 1 : 0 + } + + Button { + text: "Remove" + enabled: tableView.rows > 0 + + Layout.alignment: Qt.AlignRight + Layout.columnSpan: 2 + + onClicked: tableView.model.removeRow(removeIndexSpinBox.value) + } + } + ColumnLayout { + RowForm { + id: setRowForm + + Layout.fillHeight: true + + Label { + text: "Set index" + } + SpinBox { + id: setIndexSpinBox + from: 0 + to: tableView.rows > 0 ? tableView.rows - 1 : 0 + } + } + + Button { + text: "Set" + + onClicked: tableView.model.setRow(setIndexSpinBox.value, setRowForm.inputAsRow()); + } + } + } + } +} diff --git a/tests/manual/tableview/tablemodel/tablemodel.pro b/tests/manual/tableview/tablemodel/tablemodel.pro new file mode 100644 index 0000000000..4e4eba7653 --- /dev/null +++ b/tests/manual/tableview/tablemodel/tablemodel.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS += form diff --git a/tests/manual/tableview/tableview.pro b/tests/manual/tableview/tableview.pro new file mode 100644 index 0000000000..5040f0e747 --- /dev/null +++ b/tests/manual/tableview/tableview.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +SUBDIRS += abstracttablemodel \ + listmodel \ + storagemodel diff --git a/tests/manual/text/SignalIndicator.qml b/tests/manual/text/SignalIndicator.qml index 3eaadde6d7..22758d66ba 100644 --- a/tests/manual/text/SignalIndicator.qml +++ b/tests/manual/text/SignalIndicator.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the manual tests of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/tests/manual/text/main.cpp b/tests/manual/text/main.cpp index a4e1060cf5..5c171fa244 100644 --- a/tests/manual/text/main.cpp +++ b/tests/manual/text/main.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the manual tests of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/tests/manual/text/main.qml b/tests/manual/text/main.qml index d7e214ee38..e1f5a620b6 100644 --- a/tests/manual/text/main.qml +++ b/tests/manual/text/main.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the manual tests of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/tests/manual/text/textInputPropertiesAndSignals.qml b/tests/manual/text/textInputPropertiesAndSignals.qml index a3fd602c16..618c27f794 100644 --- a/tests/manual/text/textInputPropertiesAndSignals.qml +++ b/tests/manual/text/textInputPropertiesAndSignals.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the manual tests of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/tests/manual/touch/flicktext.qml b/tests/manual/touch/flicktext.qml index e541d5e35e..9e84261687 100644 --- a/tests/manual/touch/flicktext.qml +++ b/tests/manual/touch/flicktext.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the manual tests of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -38,7 +48,7 @@ ** ****************************************************************************/ -import QtQuick 2.4 +import QtQuick 2.12 import "qrc:/quick/shared/" as Examples Rectangle { @@ -57,6 +67,7 @@ Rectangle { contentWidth: text.implicitWidth contentHeight: text.implicitHeight pixelAligned: pxAlignCB.checked + synchronousDrag: syncDragCB.checked Text { id: text text: "foo bar" @@ -356,10 +367,15 @@ Rectangle { } Column { + spacing: 2 Examples.CheckBox { id: pxAlignCB text: "pixel aligned" } + Examples.CheckBox { + id: syncDragCB + text: "synchronous drag" + } Text { text: "content X " + flick.contentX.toFixed(2) + " Y " + flick.contentY.toFixed(2) } diff --git a/tests/manual/touch/main.cpp b/tests/manual/touch/main.cpp index baa9603175..5c171fa244 100644 --- a/tests/manual/touch/main.cpp +++ b/tests/manual/touch/main.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the manual tests of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/tests/manual/touch/main.qml b/tests/manual/touch/main.qml index 524f979c85..c208f8375c 100644 --- a/tests/manual/touch/main.qml +++ b/tests/manual/touch/main.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the manual tests of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are diff --git a/tests/manual/touch/mpta-crosshairs.qml b/tests/manual/touch/mpta-crosshairs.qml index d1dbd0f188..9fab8515ee 100644 --- a/tests/manual/touch/mpta-crosshairs.qml +++ b/tests/manual/touch/mpta-crosshairs.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** ** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the manual tests of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are @@ -50,6 +60,7 @@ Rectangle { MultiPointTouchArea { id: mpta anchors.fill: parent + //onGestureStarted: gesture.grab() // in case this is embedded in something that might steal touchPoints: [ TouchPoint { property color color: "red" }, TouchPoint { property color color: "orange" }, diff --git a/tests/manual/v4/fact.2.js b/tests/manual/v4/fact.2.js index d8f750b5a1..1696e8b80d 100644 --- a/tests/manual/v4/fact.2.js +++ b/tests/manual/v4/fact.2.js @@ -3,6 +3,6 @@ function fact(n) { return n > 1 ? n * fact(n - 1) : 1 } -for (var i = 0; i < 1000000; i = i + 1) +for (var i = 0; i < 100000; i = i + 1) fact(12) diff --git a/tests/manual/v4/typedarrays.js b/tests/manual/v4/typedarrays.js index 8cf2b8c75a..f727df7185 100644 --- a/tests/manual/v4/typedarrays.js +++ b/tests/manual/v4/typedarrays.js @@ -670,12 +670,12 @@ function TestDataViewConstructor() { /* This is wrong according to ecma 6 and should throw: - var d4 = new DataView(ab, 1, 3.1415926); + var d4 = new DataView(ab, 1, Math.PI); assertSame(ab, d4.buffer); assertSame(1, d4.byteOffset); assertSame(3, d4.byteLength); */ - assertThrows(function() { new DataView(ab, 3.1415926); }, RangeError); + assertThrows(function() { new DataView(ab, Math.PI); }, RangeError); // error cases assertThrows(function() { new DataView(ab, -1); }, RangeError); |