main.qml 12.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** $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$
**
****************************************************************************/

49
import QtQuick 2.6
Daniel Smith's avatar
Daniel Smith committed
50
import QtQuick.Window 2.2
51
import QtQuick.Layouts 1.3
52 53
import QtGraphicalEffects 1.0

Daniel Smith's avatar
Daniel Smith committed
54 55

Window {
56 57 58 59

    width: 800
    height: 600
    id: mainView
Daniel Smith's avatar
Daniel Smith committed
60
    visible: true
61

62 63
    property int pixelSize: height / 8
    property string textureExtension: (Qt.application.version % 5) * 10 < 11 ? ".png" : ".ktx"
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79

    function fontSource()
    {
        var s = "DejaVuSans"
        var suffix = ""
        for (var i = 0; i < Qt.application.arguments.length; ++i) {
            if (Qt.application.arguments[i] === "--complex-latin")
                s = "HVD_Peace"
            else if (Qt.application.arguments[i] === "--chinese")
                s = "WCL-02"
            else if (Qt.application.arguments[i] === "--df")
                suffix = "_df"
        }

        console.debug(s + suffix)

80
        return "file:fonts/" + s + suffix + ".ttf"
Daniel Smith's avatar
Daniel Smith committed
81

82 83 84 85 86 87 88 89 90 91 92
    }

    FontLoader {
        id: myFont
        source: fontSource()
    }

    function textSample()
    {
        for (var i = 0; i < Qt.application.arguments.length; ++i) {
            if (Qt.application.arguments[i] === "--chinese")
93
                return "紙開逮落供整間止並人主最人負村鳥線原。止天由子件要思学掲児治移混。想一垣祐化信位資会文探協融無歯。写惑山権手写負報見海毎光見燃。考表載取常人金呼将紙割席通試。電続長部撮一暗協出豊記愛提速本仕。暮分友当均娘要記欠発企勢深在個勝。場執時民迎就挙載対乗補稿対暮提。受撮柴針両別譜謙国後村治。続谿強校視扱就授科告絞報覧埼忌前信。南供低属書期面表案政付図一生細夏枝期返。基道注迅三著車興済川達受報期半豊講。荘弱住上含題豊格国再紙増休里部先民議后。図建旅村所械属断守目不変負。字教員将投広学催護所将到国報疑起彦象。追景始望上入最善樹培摘数目際練。映福投研生戦日新先扱横載映読海。間貢経陸罪鹿実飾写著社都弥融州冬一体断家。来止選豊祉紙地上書極談悩立今。尉忘掲一写岐国俊付期講勢危撤昇図院水。回問供首模分性少直覧触目能円側学聞年政。話第務葉著知総承小担供米第。約危毎低骨完竹知役容車子応。救析期未来虐迎方闘視格置触肥。速夜入相医聞県作上先達京。除浩著花員向律社中企能辛品日芸空質北需。面関相国第域治援土護択差東田比副新。属捕校術権単提追麿止角用鹿動。優次俗旧族港広宣転法中大手強樹団検。効行紀分済決隆情連場取説西。野画男子品無会等活日償道熱載出修国本。問共季秋関延毎囲訪熱暮伝織聞。予載当整衝輸小穏契独基常融矛序学。谷量部撃投断人震止期必風場徒格試哲。回品他関気間縦年法集更短案。決阪逃載原要平央改近固金征供着。南子申残帯列通話禁歩宅由。家健野兼牝安康選鉱枚露真断思貴。務文乳域放宮作藤洋杯郵番談内用弥。宝副半創書不野井民奈連先目無後主。暮携鎖処岡入秩声込来万江岸。床樹種少信手遺需村市不活見能正適切前掲氷。上情帰意株産工表受熱画聞遇応務。編原実産住崎杏本岩中龍現米布由鳥戦買。務割望海挙明放慮産上観尾変情公競田聞。対院転禁苫経最手礎辺装座入示覧重意術念。際雪域疑混士組探校報崎管古。問夫辞希印毎後開短民真見開接名将。川諸命早断任来数問安会神向鹿嘉政緩。界理展聞化資一質金津客沢社学稿多氏真属。定売葉者周戦入統品日亡司供正朝情共明。"
Daniel Smith's avatar
Daniel Smith committed
94
        }
95
        return "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG."
Daniel Smith's avatar
Daniel Smith committed
96
    }
97 98

    Image {
99
        id: background
100
        anchors.fill: parent
101 102 103
        source: "images/background2" + textureExtension
        layer.enabled: true
        visible: false
104
    }
105 106
    GaussianBlur {
        id: backgroundBlur
107
        anchors.fill: parent
108 109 110 111 112
        //width: 200
        //height: width
        source: background
        radius: 64
        Behavior on radius {
113 114 115 116 117 118
            
			NumberAnimation {
                from:0
                duration: 30000
				loops: Animation.Infinite
            }
119 120
        }
    }
121 122 123 124 125 126
    HueSaturation {
        anchors.fill: parent
        source: backgroundBlur
        hue: -1.0
        saturation: 0.5
        lightness: -0.1
127 128 129 130 131 132 133 134 135
		SequentialAnimation on hue {
			running: true
			loops: Animation.Infinite
			NumberAnimation {
				from: -1.0
				to: 1
				duration: 30000
			}
		}
136 137
    }

138 139 140 141

    Text {
        id: text1
        text: textSample()
142
        font.pixelSize: 20
143 144 145 146
        wrapMode: Text.WrapAtWordBoundaryOrAnywhere
        anchors.fill: parent
        font.family: myFont.name
        renderType: Text.QtRendering
147
        opacity: 0.1
148

149
		SequentialAnimation on color {
150
            running: true
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
            loops: Animation.Infinite
			ColorAnimation {
				from: "black"
				to: "#42f450"
				duration: 30000
			}
		}
        
		SequentialAnimation on opacity {
            running: true
            loops: Animation.Infinite
			OpacityAnimator {
				from: 0.1
				to: 0.5
				duration: 30000
			}
		}
168 169
    }

170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
    Text {
        id: versionWatermark
        text: "QT VERSION: " + Qt.application.version
        font.pixelSize: 30
        color: "white"
        x: mainView.width - versionWatermark.width - 20
        y: 20
        font.family: myFont.name
        renderType: Text.QtRendering
        layer.enabled: true
        // This item should be used as the 'mask'
        layer.samplerName: "maskSource"
        layer.effect: ShaderEffect {
            property var colorSource: versionTextGradient;
            fragmentShader: "
                uniform lowp sampler2D colorSource;
                uniform lowp sampler2D maskSource;
                uniform lowp float qt_Opacity;
                varying highp vec2 qt_TexCoord0;
                void main() {
                    gl_FragColor =
                        texture2D(colorSource, qt_TexCoord0)
                        * texture2D(maskSource, qt_TexCoord0).a
                        * qt_Opacity;
                }
            "
        }
        Rectangle {
                id: versionTextGradient;
                width: 10
                height: 20
                gradient: Gradient {
                    GradientStop { position: 0; color: "white" }
                    GradientStop { position: 0.5; color: "steelblue" }
                    GradientStop { position: 1; color: "orange" }
                }
                visible: false; // should not be visible on screen.
                layer.enabled: true;
                layer.smooth: true
            }
    }


    // Main visiable elements
    Column {
215
        anchors.verticalCenter: parent.verticalCenter
216
        anchors.horizontalCenter: parent.horizontalCenter
217
        spacing: 90
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
        Row{
            QUItBattery {
                id: battery
                charging: true
                maxLiquidRotation: 0
                rotation: 0
                value: 0.0

                SequentialAnimation on value {
                    running: true
                    loops: Animation.Infinite
                    NumberAnimation { to: 1.0; duration: 5000; loops: Animation.Infinite; easing.type: Easing.OutQuad }
                }
            }
        }

        Row {
            anchors.horizontalCenter: parent.horizontalCenter
            spacing: 50

            Speedometer {
                        id: myGauge
                        size: 200
                    }

            Item {
                id: buttons
                height: 200
                width: 200
                Repeater {
                    id: digits
                    model: ["7", "8", "9", "4", "5", "6", "1", "2", "3", "", "0", ""]
                    Button {
                        x: (index % 3) * width
                        y: Math.floor(index / 3 + 1) * height
                        width: 50
                        height: 35
                        color: "#eeeeee"
                        text: modelData
                    }
                }
            }
        }
    }
Daniel Smith's avatar
Daniel Smith committed
262
}