summaryrefstree
path: root/usr/bin/qml/Carlink/Bluetoothlist.qml
blob: b59bd6a096d3406e7ff30b31a2a4791b0c0cb99d (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import QtQuick 2.0
import "../com/neusoft/auto/widgets"
import "../windowsList.js" as WindowsList
import "../layoutList.js" as Layout

Item {
    id : bluelist
    width: 500
    height: 600

    Image {
        id: background
        x : 0 ; y : 0
        height: 30
		Text {
			property real rate: 0.860
			id : text_title
			height : 30
			width :  250
			color: "white"
			font.family: "方正兰亭黑简体"
			font.pixelSize:31*text_title.rate
            text : qsTr("BT device lists")+systemCtrl.emptyString
		}
    }
    Item {
        id: page
        x :0 ; y : 30
        width: 360
        height: 640



        ListView {
            id: view
            anchors.fill: parent
            anchors.rightMargin: 12
            model : carlinkCtrl.getMacList();
            delegate: model_delegate
            spacing: 30
            interactive: false
        }
		
        Component {
            id: model_delegate

            Image {
                width: 700
                height: 40
				Text {
					property real rate: 0.860
					id : label
					height : 40
					width :  250
					color: "white"
					font.family: "方正兰亭黑简体"
					font.pixelSize:31*label.rate
					horizontalAlignment: label.AlignHCenter
					text : model.modelData.macName
				}
				HMIButton {
					id : bindbtn
					x :520
					btnImg: bindbtn.pressed ?"qrc:MATERIAL/MATERIAL_M8X_SETTINGS_BUTTON_PUSHED"+systemCtrl.style
																  : "qrc:MATERIAL/MATERIAL_M8X_SETTINGS_BUTTON"+systemCtrl.style									
					HMILabel
					{
						id:lab
						anchors.fill: parent
                        			text: model.modelData.isBind? qsTr("Unbind")+systemCtrl.emptyString  : qsTr("Bind")+systemCtrl.emptyString
						color:"white"
						font.pixelSize: 24
					}								
                    onClicked: {
                        console.log ("selected mac :" ,label.text);
                        console.log ("selected index : " ,index );
                        carlinkCtrl.set_hmi_selected_mac(label.text);
                        carlinkCtrl.setCurrentIndex(index);
                        if (modelData.isBind){
                            console.log("unbind------------------->>")							
                            carlinkCtrl.setIsBindMac(false);
							ScreenManager.changeForm(Layout.FM_OPEN,WindowsList.CARLINK_CHECKPASSWORD)
                        }
                        else {
                            console.log("bind------------------->>")
                            carlinkCtrl.setIsBindMac(true);	
                            //Naca70191 [The upper limit of the same account to bind Bluetooth device is eight]by sunjiaqi
							console.log("carlinkCtrl.getBindMacCount():"+carlinkCtrl.getBindMacCount())
                            if(carlinkCtrl.getBindMacCount() == 8){
                                if (0 ===systemCtrl.getLanguage() ){
                                     carlinkCtrl.showPromptInfo ("Too many bound BT device,Please unbind one to add new." , true);
                                }
                                else{
                                     carlinkCtrl.showPromptInfo ("可绑定的蓝牙设备已达上限,请先解绑一个设备." , true);
                                }
                            }
                            else{
                               ScreenManager.changeForm(Layout.FM_OPEN,WindowsList.CARLINK_CHECKPASSWORD)
                            }
                        }							
                       
                    }
                }
            }
        }
    }
	Connections {
		target: carlinkCtrl
		onSig_isMaclistChanged : {
			console.log("maclist changed---------->>>")
			view.model = carlinkCtrl.getMacList();
			console.log("maclist changed---------->>>over")
		}
	}
}