some UI changes for usability
[makneto-zunavac1.git] / src / ui-mobile / declarative / SessionControlPanel.qml
blob4d3a16fed3bb7bb0649dfd0de077e1b41b14905d
1 /*
2  *   Copyright (C) 2011 Lukáš Karas <lukas.karas@centrum.cz>
3  *
4  *   This program is free software; you can redistribute it and/or modify
5  *   it under the terms of the GNU General Public License as published by
6  *   the Free Software Foundation; either version 2 of the License, or
7  *   (at your option) any later version.
8  *
9  *   This program is distributed in the hope that it will be useful,
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *   GNU General Public License for more details.
13  *
14  *   You should have received a copy of the GNU General Public License
15  *   along with this program; if not, write to the
16  *   Free Software Foundation, Inc.,
17  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18  */
19 import Qt 4.7
21 TopPanel{
22     id: sessionToolbar
23     //BorderImage { source: "img/toolbar.sci"; anchors.fill: parent }
24     //color: "transparent"
25     //y: 10
26     //width: height * 3
28     //height: main.toolbarHeight
30     //anchors.horizontalCenter: parent.horizontalCenter
31     anchors{top: parent.top; left: parent.left; right: parent.right}
32     state: "chat"
33     //anchors.right: crossIcon.right
35     signal requestCall(string sessionId, bool video);
36     signal requestHangup(string sessionId);
38     function log(msg){
39         console.log("II [SessionControlPanel.qml]: "+msg);
40     }
41     function error(msg){
42         console.log("EE [SessionControlPanel.qml]: "+msg);
43     }
44     function warn(msg){
45         console.log("WW [SessionControlPanel.qml]: "+msg);
46     }
48     function updateMicIcon(b){
49         //micIcon.source = b ? "img/mic-on.svg": "img/mic-off.png";
50     }
52     Rectangle{
53         width: height * 5
54         anchors{top: parent.top; bottom: parent.bottom}
55         anchors.horizontalCenter: parent.horizontalCenter
56         color: "transparent"
58         Image {
59             id: boardIcon
60             source: "img/table.svg"
61             height: parent.height * 0.8
62             width: height
63             anchors{ margins: parent.height*0.1; left: parent.left; top: parent.top }
65             MouseArea{
66                 anchors.fill: parent
67                 onClicked: {
68                     sessionToolbar.parent.setBoard(!sessionToolbar.parent.board);
69                 }
70             }
71         }
73         Image {
74             id: callIcon
75             source: "img/call-start.png"
76             height: parent.height * 0.8
77             width: height
78             anchors{ margins: parent.height*0.1; left: boardIcon.right; top: parent.top;
79                 leftMargin:parent.height *.5; }
81             MouseArea{
82                 anchors.fill: parent
83                 onClicked: {
84                     if (sessionToolbar.state == "call"){
85                         log("request hangup "+sessionToolbar.parent.sessionId);
86                         requestHangup(sessionToolbar.parent.sessionId);
87                     }else{
88                         log("request audio call "+sessionToolbar.parent.sessionId);
89                         requestCall(sessionToolbar.parent.sessionId, false);
90                     }
91                 }
92             }
93         }
95         Image {
96             id: camIcon
97             source: "img/cam.svg"
98             height: parent.height * 0.8
99             width: 0
100             //visible: false
101             anchors{ margins: 0; left: callIcon.right; top: parent.top; leftMargin:parent.height *.5}
102             MouseArea{
103                 anchors.fill: parent
104                 onClicked: {
105                     log("request video call "+sessionToolbar.parent.sessionId);
106                     requestCall(sessionToolbar.parent.sessionId, true);
107                 }
108             }
109         }
112     }
113     Image {
114         id: crossIcon
115         source: "img/cross.png"
116         height: parent.height * 0.8
117         width: height
118         anchors{ margins: parent.height*0.1; right: parent.right; top: parent.top}
120         MouseArea{
121             anchors.fill: parent
122             onClicked: {
123                 sessionToolbar.parent.closeSession();
124             }
125         }
126     }
128     states: [
129         State {
130             name: "chat"
131             //PropertyChanges { target: sessionToolbar; width:  height*4}
132             PropertyChanges { target: callIcon; source: "img/call-start.png" }
133             PropertyChanges { target: camIcon; anchors.margins: parent.height*0.1; visible: true; width: height; }
134         },
135         State {
136             name: "call"
137             PropertyChanges { target: callIcon; source: "img/call-end.png";}
138             //PropertyChanges { target: sessionToolbar; width:  height*2.5 }
139             PropertyChanges { target: camIcon; anchors.margins:0; width: 0; } // visible: false;
140         }
141     ]
143     transitions: [
144         Transition {
145             from: "chat"; to: "call"
146             NumberAnimation { properties: "width,height,x,y,anchors.margins"; easing.type: Easing.InOutQuad; duration: 500 }
147         },
148         Transition {
149             from: "call"; to: "chat"
150             NumberAnimation { properties: "width,height,x,y,anchors.margins"; easing.type: Easing.InOutQuad; duration: 500 }
151         }
152     ]