Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*#############################################################################
- * Copyright 2016 LGE
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of LGE.
- * No part of this file may be copied, modified, sold, and distributed in any
- * form or by any means without prior explicit permission in writing from
- * FPT Software.
- *****************************
- *
- * File name : HomeScreen_Button_Key.qml
- *
- * Decription : This file is a button in keybroad on authentication screen.
- *
- * Author : ThangNQ15
- *
- * Created date : 21/11/2016
- *
- * History
- *
- * Date(DDMMYYY) PIC Description
- *
- * 21112016 ThangNQ15 first created
- *
- ############################################################################*/
- import QtQuick 2.4
- import "../Constants/."
- Item {
- id: root
- objectName: "KeyButton"
- layer.enabled: true
- width: img.width
- height: img.height
- /* property */
- property string colorLabelDefault: AppModel.themeCar === "Inv" ? idString.black_color : idString.white_color
- property string colorLabelHighlight: AppModel.themeCar === "M0" ? idString.white_color : idString.black_color
- property var imgSource: idImgPath.etc_caution_btn_agree //image path of component
- property alias buttonLabel: textID.text //lable of component
- property alias fontSize: textID.font.pixelSize //font size of lable
- property bool isPressing: false //variant for check button status
- property bool isPressed: false
- property bool isDisable: false
- property bool isForegroundApp: AppModel.isForegroundApp
- property bool isWaitingCallApp: AppModel.isPressingQml
- property bool isPopupDisplaying: AppModel.isPopupDisplaying
- //signals
- signal clickedButton() //signal when clicked button
- signal pressedButton()
- signal releaseButton()
- onIsPopupDisplayingChanged: {
- if(isPopupDisplaying){
- isPressed = false;
- isPressing = false;
- }
- }
- onIsWaitingCallAppChanged: {
- if(isWaitingCallApp){
- mouseAreaID.enabled = false;
- if(isPressed)
- isPressing = true;
- } else {
- mouseAreaID.enabled = !isDisable;
- isPressed = false;
- isPressing = false;
- }
- }
- onIsForegroundAppChanged: {
- if(!isForegroundApp){
- if(isPressing){
- isPressing = false;
- isPressed = false;
- }
- }
- }
- onIsDisableChanged: {
- mouseAreaID.enabled = !isDisable;
- if(isDisable) {
- isPressing = false;
- isPressed = false;
- }
- }
- MouseArea {
- id: mouseAreaID
- anchors.fill: parent
- enabled: !isDisable
- onPressed: {
- isPressing = true;
- isPressed = true;
- pressedButton()
- }
- onContainsMouseChanged: {
- if(!mouseAreaID.containsMouse && isPressed){
- isPressing = isWaitingCallApp;
- isPressed = false;
- releaseButton()
- }
- }
- onReleased: {
- if(isPressing){
- clickedButton();
- }
- releaseButton()
- }
- }
- Image {
- id : img
- source: root.visible ? (isDisable ? imgSource[2] : (isPressing? imgSource[1] : imgSource[0])) : ""
- }
- Text{
- id : textID
- anchors {
- centerIn: parent
- }
- width: img.width - 10
- horizontalAlignment: Text.AlignHCenter
- elide: Text.ElideRight
- color: isDisable ? "gray" : ((!isPressing) ? colorLabelDefault : colorLabelHighlight)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement