Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 3.82 KB | None | 0 0
  1. /*#############################################################################
  2.  * Copyright 2016 LGE
  3.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of LGE.
  4.  * No part of this file may be copied, modified, sold, and distributed in any
  5.  * form or by any means without prior explicit permission in writing from
  6.  * FPT Software.
  7.  *****************************
  8.  *
  9.  * File name            : HomeScreen_Button_Key.qml
  10.  *
  11.  * Decription           : This file is a button in keybroad on authentication screen.
  12.  *
  13.  * Author               : ThangNQ15
  14.  *
  15.  * Created date         : 21/11/2016
  16.  *
  17.  * History
  18.  *
  19.  *  Date(DDMMYYY)   PIC       Description
  20.  *
  21.  *  21112016      ThangNQ15     first created
  22.  *
  23. ############################################################################*/
  24.  
  25. import QtQuick 2.4
  26. import "../Constants/."
  27.  
  28. Item {
  29.     id: root
  30.     objectName: "KeyButton"
  31.     layer.enabled: true
  32.  
  33.     width: img.width
  34.     height: img.height
  35.  
  36.     /* property */
  37.     property string colorLabelDefault: AppModel.themeCar === "Inv" ? idString.black_color : idString.white_color
  38.     property string colorLabelHighlight: AppModel.themeCar === "M0" ? idString.white_color : idString.black_color
  39.     property var imgSource: idImgPath.etc_caution_btn_agree               //image path of component
  40.     property alias buttonLabel: textID.text                         //lable of component
  41.     property alias fontSize: textID.font.pixelSize                  //font size of lable
  42.     property bool isPressing: false                                 //variant for check button status
  43.     property bool isPressed: false
  44.     property bool isDisable: false
  45.     property bool isForegroundApp: AppModel.isForegroundApp
  46.     property bool isWaitingCallApp: AppModel.isPressingQml
  47.     property bool isPopupDisplaying: AppModel.isPopupDisplaying
  48.     //signals
  49.     signal clickedButton()      //signal when clicked button
  50.     signal pressedButton()
  51.     signal releaseButton()
  52.  
  53.     onIsPopupDisplayingChanged: {
  54.         if(isPopupDisplaying){
  55.             isPressed = false;
  56.             isPressing = false;
  57.         }
  58.     }
  59.  
  60.     onIsWaitingCallAppChanged: {
  61.         if(isWaitingCallApp){
  62.             mouseAreaID.enabled = false;
  63.             if(isPressed)
  64.                 isPressing = true;
  65.         } else {
  66.             mouseAreaID.enabled = !isDisable;
  67.             isPressed = false;
  68.             isPressing = false;
  69.         }
  70.     }
  71.  
  72.     onIsForegroundAppChanged: {
  73.         if(!isForegroundApp){
  74.             if(isPressing){
  75.                 isPressing = false;
  76.                 isPressed = false;
  77.             }
  78.         }
  79.     }
  80.  
  81.     onIsDisableChanged: {
  82.         mouseAreaID.enabled = !isDisable;
  83.         if(isDisable) {
  84.             isPressing = false;
  85.             isPressed = false;
  86.         }
  87.     }
  88.  
  89.     MouseArea {
  90.         id: mouseAreaID
  91.         anchors.fill: parent
  92.         enabled: !isDisable
  93.         onPressed: {
  94.             isPressing = true;
  95.             isPressed = true;
  96.             pressedButton()
  97.         }
  98.         onContainsMouseChanged: {
  99.             if(!mouseAreaID.containsMouse && isPressed){
  100.                 isPressing = isWaitingCallApp;
  101.                 isPressed = false;
  102.                 releaseButton()
  103.             }
  104.         }
  105.         onReleased: {
  106.             if(isPressing){
  107.                 clickedButton();
  108.             }
  109.             releaseButton()
  110.         }
  111.     }
  112.  
  113.     Image {
  114.         id : img
  115.         source: root.visible ? (isDisable ?  imgSource[2] : (isPressing? imgSource[1] : imgSource[0])) : ""
  116.     }
  117.  
  118.     Text{
  119.         id : textID
  120.         anchors {
  121.             centerIn: parent
  122.         }
  123.         width: img.width - 10
  124.         horizontalAlignment: Text.AlignHCenter
  125.         elide: Text.ElideRight
  126.         color: isDisable ? "gray" : ((!isPressing) ? colorLabelDefault : colorLabelHighlight)
  127.     }
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement