/************************************************************************ 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 : rsessvoice.cpp Module : UI Dialog Author : vic.ren Created on : 2012-11-05 Description : The session dialog Modify History: 1. Date: Author: Modification: 2012-11-05 Vic Ren Create *************************************************/ #include "JusCallPch.h" const QSize SIZEAUDIO = QSize(410 + SHADOW_WIDTH, 160 + SHADOW_HEIGHT); RSessVoice::RSessVoice(RSession *pSession, QWidget *parent) : RMetroDlg(parent) , m_pSession(pSession) , m_nSessTime(0) , m_pStatistics(ZNULL) { setWindowFlags(Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint); setFocusPolicy(Qt::StrongFocus); setAttribute(Qt::WA_DeleteOnClose); initDlg(); updateContact(); } void RSessVoice::resizeEvent(QResizeEvent * event) { RMetroDlg::resizeEvent(event); m_pBtnInfo->move(width() - 61, BORDER_TOP); m_pLabelName->move(BORDER_LEFT + 7, BORDER_TOP); m_pLabelTime->move(width() - BORDER_RIGHT - m_pLabelTime->width() - 10, height() - BORDER_BOTTOM - m_pLabelTime->height() - 10); m_pControlPad->move(BORDER_LEFT + 15, BORDER_TOP + 50); } void RSessVoice::closeEvent(QCloseEvent * event) { RClient::Instance()->widgetClosed(this); if (m_pSession->sessId() != ZINVALIDID) Mtc_CallTerm(m_pSession->sessId(), EN_MTC_CALL_TERM_STATUS_NORMAL, ZNULL); emit signalVoiceEnded(); if (m_pStatistics) m_pStatistics->close(); RMetroDlg::closeEvent(event); } void RSessVoice::mousePressEvent(QMouseEvent * event) { if (!event) return; RMetroDlg::mousePressEvent(event); m_pControlPad->hideVolumeControl(); } void RSessVoice::focusOutEvent(QFocusEvent * event) { QWidget::focusOutEvent(event); m_pControlPad->hideVolumeControl(); } void RSessVoice::initDlg() { connect(this, SIGNAL(signalClickedBtnClose()), SLOT(close())); connect(this, SIGNAL(signalClickedBtnMin()), SLOT(showMinimized())); resize(SIZEAUDIO); addBoder(); addTitle("", (EN_UI_DLG_BTN_CLOSE | EN_UI_DLG_BTN_MIN)); setDragEnabled(true); m_pBtnInfo = new RRightTopBtn(this, ":/images/ic_btn_information.png"); m_pBtnInfo->resize(20, 20); connect(m_pBtnInfo, SIGNAL(clicked()), SLOT(slotClickedBtnInfo())); m_pControlPad = new RControlPad(m_pSession, false, this); m_pControlPad->setWindowFlags(Qt::FramelessWindowHint); connect(m_pControlPad, SIGNAL(signalClickedBtnAnswer()), SLOT(slotClickedBtnAnswer())); connect(m_pControlPad, SIGNAL(signalClickedBtnDecline()), SLOT(slotClickedBtnDecline())); connect(m_pControlPad, SIGNAL(signalClickedBtnEnd()), SLOT(slotClickedBtnEnd())); m_pLabelName = new QLabel(this); m_pLabelName->setFixedHeight(38); m_pLabelName->setFont(RStyle::fontSize(28)); m_pLabelName->setAlignment(Qt::AlignBottom); m_pLabelCurPhone = new QLabel(this); m_pLabelCurPhone->setFixedHeight(38); m_pLabelCurPhone->setFont(RStyle::fontSize(24)); m_pLabelCurPhone->setAlignment(Qt::AlignBottom); m_pLabelTime = new QLabel(this); m_pLabelTime->setFont(RStyle::fontSize(14)); m_pLabelTime->setFixedSize(110, 20); m_pLabelTime->setAlignment(Qt::AlignRight); } void RSessVoice::moveToPositon() { RClient::Instance()->moveToPositon(this); } void RSessVoice::updateContact() { m_pLabelCurPhone->setText(""); m_pLabelName->setText(""); if (!m_pSession) return; QString qsName = m_pSession->name(); if (qsName.isEmpty()) qsName = m_pSession->currentPhone(); setWindowTitle(QString(tr("Voice-")) + qsName); m_pLabelName->setText(qsName); m_pLabelName->adjustSize(); if (m_pSession->name().isEmpty()) return; int nX = m_pLabelName->width() + 20; m_pLabelCurPhone->setFixedWidth(340 - m_pLabelName->width()); m_pLabelCurPhone->move(nX, 0); QFontMetrics fmPhone(m_pLabelCurPhone->font()); QString qsPhone = fmPhone.elidedText(m_pSession->currentPhone(), Qt::ElideRight, m_pLabelCurPhone->width()); m_pLabelCurPhone->setText(qsPhone); } void RSessVoice::showSessFailed() { m_pLabelTime->setText(tr("Call failed")); QTimer::singleShot(2000, this, SLOT(close())); } void RSessVoice::showSessOut() { m_pLabelTime->setText(tr("Calling...")); m_pControlPad->showSessOut(); } void RSessVoice::showSessIncoming() { m_pControlPad->showSessIncoming(); m_pLabelTime->setText(tr("")); moveToPositon(); } void RSessVoice::showSessAlerted() { m_pLabelTime->setText(tr("Ringing...")); } void RSessVoice::showSessConnecting() { m_pLabelTime->setText(tr("Connecting...")); } void RSessVoice::showSessTalking() { m_pLabelTime->setText(tr("00:00")); disconnect(&m_TimerSess, SIGNAL(timeout()), 0, 0); connect(&m_TimerSess, SIGNAL(timeout()), this, SLOT(slotSessTimer())); m_TimerSess.start(1000); m_pControlPad->showSessTalking(); } void RSessVoice::showSessTermed() { m_TimerSess.stop(); m_pLabelTime->setText(tr("Ending...")); m_nSessTime = 0; QTimer::singleShot(2000, this, SLOT(close())); m_pControlPad->showSessTermed(); } void RSessVoice::slotClickedBtnInfo() { if (m_pStatistics) { m_pStatistics->close(); m_pStatistics->deleteLater(); m_pStatistics = ZNULL; return; } m_pStatistics = new RStatistics(m_pSession->sessId()); connect(m_pStatistics, SIGNAL(signalClosed()), SLOT(slotStatisticsClosed())); m_pStatistics->show(); m_pStatistics->move(x() + 40, y() + 40); } void RSessVoice::slotClickedBtnAnswer() { Mtc_CallAnswer(m_pSession->sessId(), 0, ZTRUE, ZFALSE); } void RSessVoice::slotClickedBtnDecline() { Mtc_CallTerm(m_pSession->sessId(), EN_MTC_CALL_TERM_STATUS_DECLINE, ZNULL); showSessTermed(); } void RSessVoice::slotClickedBtnEnd() { Mtc_CallTerm(m_pSession->sessId(), EN_MTC_CALL_TERM_STATUS_NORMAL, ZNULL); showSessTermed(); } void RSessVoice::slotClickedBtnSpkMute() { //Mtc_CallSetSpkMute(m_pSession->sessId(), m_pBtnSpk->isChecked()); } void RSessVoice::slotClickedBtnMicMute() { //Mtc_CallSetMicMute(m_pSession->sessId(), m_pBtnMic->isChecked()); } void RSessVoice::slotStatisticsClosed() { m_pStatistics = ZNULL; } void RSessVoice::slotSessTimer() { m_nSessTime ++; char strTimer[100] = {0}; sprintf(strTimer, "%02d:%02d", m_nSessTime/60, m_nSessTime%60); m_pLabelTime->setText(QString(strTimer)); }