9f17d59e
陈明泉
no message
|
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
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
215
216
217
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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
|
/************************************************************************
Copyright (c) 2005-2012 by Juphoon System Software Co., Ltd.
All rights reserved.
This software is confidential and proprietary to Juphoon System Software Co.,
Ltd.. No part of this software may be reproduced, stored, transmitted,
disclosed or used in any form or by any means other than as expressly
provided by the written license agreement between JusTel and its
licensee.
THIS SOFTWARE IS PROVIDED BY JusTel "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 JusTel 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.
Juphoon System Software Co., Ltd.
************************************************************************/
/*************************************************
File name : rsesswidgets.cpp
Module : UI Widget
Author : vic.ren
Created on : 2012-08-10
Description :
button box for session dialog
Modify History:
1. Date: Author: Modification:
*************************************************/
#include "JusCallPch.h"
/*According to the Qt docs, if you want to use GDI or Direct3D on Windows with Qt, you need to:
1) Override QWidget::paintEngine to return NULL
2) Call QWidget::setAttribute(Qt::WA_PaintOnScreen, true) */
RVideoWidget::RVideoWidget(QWidget *parent) : RWidget(parent)
{
setMouseTracking(true);
setAttribute(Qt::WA_PaintOnScreen, true);
}
QPaintEngine *RVideoWidget::paintEngine()const
{
//return QWidget::paintEngine();
return ZNULL;
}
void RVideoWidget::mouseMoveEvent(QMouseEvent * event)
{
event->ignore();
}
void RVideoWidget::mouseDoubleClickEvent(QMouseEvent *event)
{
if(!event) return;
QWidget::mouseDoubleClickEvent(event);
emit signalDoubleClicked();
}
RControlPad::RControlPad(RSession *pSession, bool bIsVideo, QWidget *parent)
: RWidget(parent), m_pSession(pSession), m_pVolumeWidget(ZNULL),
m_bIsVideo(bIsVideo)
{
setWindowFlags(Qt::FramelessWindowHint /*| Qt::Tool*/
| Qt::WindowStaysOnTopHint);
// setAttribute(Qt::WA_TranslucentBackground);
setFocusPolicy(Qt::NoFocus);
initDlg();
}
RControlPad::~RControlPad()
{
if (m_pVolumeWidget)
{
m_pVolumeWidget->hide();
delete m_pVolumeWidget;
}
}
void RControlPad::mouseMoveEvent(QMouseEvent * event)
{
if (!event) return;
QWidget::mouseMoveEvent(event);
QPoint ptNewPoint = event->globalPos();
if (event->buttons() == Qt::LeftButton)
{
QPoint ptLeftUpPoint = ptNewPoint - m_ptLastPoint;
m_pSession->moveVideo(ptLeftUpPoint);
m_ptLastPoint = ptNewPoint;
}
}
void RControlPad::mousePressEvent(QMouseEvent * event)
{
if (!event) return;
QWidget::mousePressEvent(event);
hideVolumeControl();
m_ptLastPoint = event->globalPos();
}
void RControlPad::mouseReleaseEvent(QMouseEvent * event)
{
if (!event) return;
QWidget::mouseReleaseEvent(event);
m_ptLastPoint = QPoint(0, 0);
}
void RControlPad::enterEvent(QEvent * event)
{
if (!event) return;
QWidget::enterEvent(event);
emit signalMouseInControl(true);
}
void RControlPad::leaveEvent(QEvent * event)
{
if (!event) return;
QWidget::leaveEvent(event);
emit signalMouseInControl(false);
}
void RControlPad::showEvent(QShowEvent * event)
{
if (!event) return;
QWidget::showEvent(event);
}
void RControlPad::hideEvent(QHideEvent * event)
{
if (!event) return;
QWidget::hideEvent(event);
if (!m_pVolumeWidget->isHidden())
m_pVolumeWidget->hide();
}
void RControlPad::resizeEvent(QResizeEvent * event)
{
if (!event) return;
QWidget::resizeEvent(event);
m_pBtnAnswer->move(width()/2 - 110, 10);
m_pBtnDecline->move(width()/2 + 50, 10);
m_pBtnEnd->move(width()/2 - 30, 10);
m_pBtnMic->move(width()/2 - 165, 25);
m_pBtnSpk->move(width()/2 + 135, 25);
}
void RControlPad::initDlg()
{
resize(380, 80);
m_pBtnAnswer = new RImageBtn(this);
m_pBtnAnswer->resize(60, 60);
m_pBtnAnswer->setBackgroud(":/images/ic_btn_answer.png");
connect(m_pBtnAnswer, SIGNAL(clicked()),
SIGNAL(signalClickedBtnAnswer()));
m_pBtnAnswer->hide();
m_pBtnDecline = new RImageBtn(this);
m_pBtnDecline->resize(60, 60);
m_pBtnDecline->setBackgroud(":/images/ic_btn_decline.png");
connect(m_pBtnDecline, SIGNAL(clicked()),
SIGNAL(signalClickedBtnDecline()));
m_pBtnDecline->hide();
m_pBtnEnd = new RImageBtn(this);
m_pBtnEnd->resize(60, 60);
m_pBtnEnd->setBackgroud(":/images/ic_btn_decline.png");
connect(m_pBtnEnd, SIGNAL(clicked()), SIGNAL(signalClickedBtnEnd()));
m_pBtnEnd->hide();
m_pBtnSpk = new RImageCheckBox(this, ":/images/ic_btn_spk_mute.png",
":/images/ic_btn_spk.png", m_bIsVideo);
m_pBtnSpk->resize(30, 30);
connect(m_pBtnSpk, SIGNAL(clicked()), SLOT(slotClickedBtnSpkMute()));
connect(m_pBtnSpk, SIGNAL(signalHovered()), SLOT(slotShowVolumeControl()));
m_pBtnSpk->hide();
m_pBtnMic = new RImageCheckBox(this, ":/images/ic_btn_mic_mute.png",
":/images/ic_btn_mic.png", m_bIsVideo);
m_pBtnMic->resize(30, 30);
connect(m_pBtnMic, SIGNAL(clicked()), SLOT(slotClickedBtnMicMute()));
m_pBtnMic->hide();
m_pVolumeWidget = new RVolumeWidget(m_pSession);
m_pVolumeWidget->hide();
connect(m_pVolumeWidget, SIGNAL(signalMuteCanceled(bool)),
SLOT(slotMuteCanceled(bool)));
if (m_bIsVideo)
{
m_pBtnEnd->setColor(RStyle::mainColor(), Qt::white);
m_pBtnDecline->setColor(Qt::white, Qt::white);
m_pBtnAnswer->setColor(RStyle::mainColor(), Qt::white);
drawRect(rect(), QColor(1, 1, 1, 178));
}
else
{
m_pBtnEnd->setColor(RStyle::mainColor(), Qt::white);
m_pBtnDecline->setColor(RStyle::fontColor(), Qt::white);
m_pBtnAnswer->setColor(RStyle::mainColor(), Qt::white);
drawRect(rect(), QColor(245, 245, 245, 178));
}
}
void RControlPad::showSessOut()
{
m_pBtnEnd->show();
}
void RControlPad::showSessIncoming()
{
m_pBtnAnswer->show();
m_pBtnDecline->show();
}
void RControlPad::showSessTalking()
{
m_pBtnAnswer->hide();
m_pBtnDecline->hide();
m_pBtnEnd->show();
m_pBtnMic->show();
m_pBtnSpk->show();
m_pBtnSpk->setChecked(Mtc_CallGetSpkMute(m_pSession->sessId()));
m_pBtnMic->setChecked(Mtc_CallGetMicMute(m_pSession->sessId()));
}
void RControlPad::showSessTermed()
{
m_pBtnEnd->hide();
m_pBtnAnswer->hide();
m_pBtnDecline->hide();
m_pBtnSpk->hide();
m_pBtnMic->hide();
m_pVolumeWidget->hide();
}
void RControlPad::hideVolumeControl()
{
if (!m_pVolumeWidget->isHidden())
m_pVolumeWidget->hide();
}
void RControlPad::slotClickedBtnSpkMute()
{
Mtc_CallSetSpkMute(m_pSession->sessId(), m_pBtnSpk->isChecked());
m_pVolumeWidget->setVolumeMute(m_pBtnSpk->isChecked());
}
void RControlPad::slotClickedBtnMicMute()
{
Mtc_CallSetMicMute(m_pSession->sessId(), m_pBtnMic->isChecked());
}
void RControlPad::slotShowVolumeControl()
{
int nX = mapToGlobal(m_pBtnSpk->pos()).x() + 7;
int nY = mapToGlobal(m_pBtnSpk->pos()).y() - m_pVolumeWidget->height() - 3;
m_pVolumeWidget->move(nX, nY);
m_pVolumeWidget->show();
}
void RControlPad::slotMuteCanceled(bool bMute)
{
m_pBtnSpk->setChecked(bMute);
Mtc_CallSetSpkMute(m_pSession->sessId(), m_pBtnSpk->isChecked());
}
RTitlePad::RTitlePad(RSession *pSession, QWidget *parent) : RWidget(parent),
m_pSession(pSession)
{
setWindowFlags(Qt::FramelessWindowHint | Qt::Tool
| Qt::WindowStaysOnTopHint);
setAttribute(Qt::WA_TranslucentBackground);
setFocusPolicy(Qt::NoFocus);
initDlg();
}
void RTitlePad::mouseMoveEvent(QMouseEvent * event)
{
if (!event) return;
QWidget::mouseMoveEvent(event);
QPoint ptNewPoint = event->globalPos();
if (event->buttons() == Qt::LeftButton)
{
QPoint ptLeftUpPoint = ptNewPoint - m_ptLastPoint;
m_pSession->moveVideo(ptLeftUpPoint);
m_ptLastPoint = ptNewPoint;
}
}
void RTitlePad::mousePressEvent(QMouseEvent * event)
{
if (!event) return;
QWidget::mousePressEvent(event);
m_ptLastPoint = event->globalPos();
}
void RTitlePad::mouseReleaseEvent(QMouseEvent * event)
{
if (!event) return;
QWidget::mouseReleaseEvent(event);
m_ptLastPoint = QPoint(0, 0);
}
void RTitlePad::enterEvent(QEvent * event)
{
if (!event) return;
QWidget::enterEvent(event);
emit signalMouseInControl(true);
}
void RTitlePad::leaveEvent(QEvent * event)
{
if (!event) return;
QWidget::leaveEvent(event);
emit signalMouseInControl(false);
}
void RTitlePad::resizeEvent(QResizeEvent *event)
{
if (!event) return;
QWidget::resizeEvent(event);
m_pLabelTime->move((width() - 95)/2, 8);
m_pBtnClose->move(width() - 20, 0);
}
void RTitlePad::initDlg()
{
m_pLabelName = new QLabel(this);
m_pLabelName->setStyleSheet("QLabel {color: white}");
m_pLabelName->setFixedHeight(24);
m_pLabelName->setFont(RStyle::fontSize(18));
m_pLabelName->setAlignment(Qt::AlignBottom);
m_pLabelName->move(10, 9);
m_pLabelCurPhone = new QLabel(this);
m_pLabelCurPhone->setStyleSheet("QLabel {color: white}");
m_pLabelCurPhone->setFixedHeight(24);
m_pLabelCurPhone->setAlignment(Qt::AlignBottom);
m_pLabelTime = new QLabel(this);
m_pLabelTime->setStyleSheet("QLabel {color: white}");
m_pLabelTime->setFixedSize(95, 24);
m_pLabelTime->setAlignment(Qt::AlignBottom | Qt::AlignHCenter);
m_pBtnClose = new RRightTopBtn(this, ":/images/ic_btn_close.png");
m_pBtnClose->setBtnWhite(true);
m_pBtnClose->resize(20, 20);
connect(m_pBtnClose, SIGNAL(clicked()), SIGNAL(signalClickedBtnClose()));
m_pBtnMin = new RRightTopBtn(this, ":/images/ic_btn_min.png");
m_pBtnMin->setBtnWhite(true);
m_pBtnMin->resize(20, 20);
connect(m_pBtnMin, SIGNAL(clicked()), SIGNAL(signalClickedBtnMin()));
m_pBtnInfo = new RRightTopBtn(this, ":/images/ic_btn_information.png");
m_pBtnInfo->setBtnWhite(true);
m_pBtnInfo->resize(20, 20);
connect(m_pBtnInfo, SIGNAL(clicked()), SIGNAL(signalClickedBtnInfo()));
m_pBtnMin->move(width() - 40, 0);
m_pBtnInfo->move(width() - 60, 0);
drawRect(rect(), QColor(1, 1, 1, 178));
}
void RTitlePad::updateContact()
{
m_pLabelCurPhone->setText("");
m_pLabelName->setText("");
if (!m_pSession) return;
QString qsName = m_pSession->name();
if (qsName.isEmpty())
qsName = m_pSession->currentPhone();
m_pLabelName->setText(qsName);
m_pLabelName->adjustSize();
if (m_pSession->name().isEmpty())
return;
int nX = m_pLabelName->width() + 20;
m_pLabelCurPhone->setFixedWidth(192 - m_pLabelName->width());
m_pLabelCurPhone->move(nX, 8);
QFontMetrics fmPhone(m_pLabelCurPhone->font());
QString qsPhone = fmPhone.elidedText(m_pSession->currentPhone(),
Qt::ElideRight, m_pLabelCurPhone->width());
m_pLabelCurPhone->setText(qsPhone);
}
void RTitlePad::setTime(const QString & qsTime)
{
m_pLabelTime->setText(qsTime);
}
void RTitlePad::setFixedWidth(int nWidth)
{
QWidget::setFixedWidth(nWidth);
drawRect(rect(), QColor(1, 1, 1, 178));
if (nWidth == RClient::screenWidth())
{
m_pBtnMin->hide();
m_pBtnInfo->move(width() - 40, 0);
}
else
{
m_pBtnMin->show();
m_pBtnMin->move(width() - 40, 0);
m_pBtnInfo->move(width() - 60, 0);
}
if (m_pSession->name().isEmpty())
return;
int nX = m_pLabelName->width() + 20;
int nPhoneWidth = (nWidth - 95)/2 - m_pLabelName->width();
m_pLabelCurPhone->setFixedWidth(nPhoneWidth);
m_pLabelCurPhone->move(nX, 8);
QFontMetrics fmPhone(m_pLabelCurPhone->font());
QString qsPhone = fmPhone.elidedText(m_pSession->currentPhone(),
Qt::ElideRight, m_pLabelCurPhone->width());
m_pLabelCurPhone->setText(qsPhone);
}
RVolumeWidget::RVolumeWidget(RSession *pSession, QWidget *parent)
: QWidget(parent), m_pSession(pSession), m_nVol(20), m_bIsMute(false)
{
setWindowFlags(Qt::FramelessWindowHint | Qt::Tool
| Qt::WindowStaysOnTopHint);
setFocusPolicy(Qt::NoFocus);
initDlg();
}
void RVolumeWidget::showEvent(QShowEvent * event)
{
if (!event) return;
QWidget::showEvent(event);
if (!m_bIsMute)
m_pSilder->setValue(Mtc_CallGetSpkVol(m_pSession->sessId()));
}
void RVolumeWidget::hideEvent(QHideEvent *event)
{
if (!event) return;
QWidget::hideEvent(event);
}
void RVolumeWidget::initDlg()
{
resize(15, 55);
m_pSilder = new QSlider(this);
m_pSilder->setCursor(Qt::PointingHandCursor);
m_pSilder->setOrientation(Qt::Vertical);
m_pSilder->setFocusPolicy(Qt::NoFocus);
m_pSilder->setRange(0, 20);
m_pSilder->setPageStep(5);
m_pSilder->setStyleSheet(RStyle::sliderVerticalStyle());
m_pSilder->resize(15, 55);
connect(m_pSilder, SIGNAL(valueChanged(int)),
SLOT(slotSessVolumeChanged(int)));
}
void RVolumeWidget::setVolumeMute(bool bMute)
{
m_bIsMute = bMute;
if (bMute)
m_pSilder->setValue(0);
else
m_pSilder->setValue(m_nVol);
}
void RVolumeWidget::slotSessVolumeChanged(int vol)
{
if (vol == 0)
{
emit signalMuteCanceled(true);
return;
}
emit signalMuteCanceled(false);
Mtc_CallSetSpkVol(m_pSession->sessId(), vol);
m_nVol = vol;
}
|