Changeset 273:4d083abe9c33 in qutecom-coip


Ignore:
Timestamp:
Jun 24, 2010 12:20:11 AM (3 years ago)
Author:
laurent
Branch:
default
Message:

CallWidget? flow

Location:
gui/src/call
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gui/src/call/callwidget.cpp

    r195 r273  
    55:QMainWindow(parent),_tCallSession(tCallSession),ui(new Ui::CallWidget) 
    66{ 
     7        _timerIdProgressAnimation = 0;  
     8        _timerIdSession = 0; 
     9        _durationSession = 0; 
     10         
     11        _lastStatus = EnumPhoneCallState::PhoneCallStateIncoming; 
     12         
    713    ui->setupUi(this); 
    814 
    9         _callButton = new CallButton; 
    10         statusBar()->addPermanentWidget(_callButton); 
    1115        _labelMsg = new QLabel; 
    1216        statusBar()->addWidget(_labelMsg); 
     
    1418         
    1519        _remoteVideoFrame = QPixmap(":/qute.png"); 
    16          
    17         connect(_callButton,SIGNAL(clickedSignal()),this,SLOT(callButtonClickedSlot())); 
    1820         
    1921        connect(_tCallSession, 
     
    3133:QMainWindow(parent),ui(new Ui::CallWidget) 
    3234{ 
     35        _timerIdProgressAnimation = 0; 
     36        _timerIdSession = 0; 
     37        _durationSession = 0; 
     38         
     39        _lastStatus = EnumPhoneCallState::PhoneCallStateUnknown; 
     40         
    3341    ui->setupUi(this); 
    3442         
    35         _callButton = new CallButton; 
    36         statusBar()->addPermanentWidget(_callButton); 
    3743        _labelMsg = new QLabel; 
    3844        statusBar()->addWidget(_labelMsg); 
     
    4046         
    4147        _remoteVideoFrame = QPixmap(":/qute.png"); 
    42          
    43         connect(_callButton,SIGNAL(clickedSignal()),this,SLOT(callButtonClickedSlot())); 
    44          
    45         _callButton->hide(); 
    4648         
    4749        _tCallSession = Coip::self()->getTCallSessionManager().createTCallSession(); 
     
    8385{ 
    8486        QPainter painter(this); 
     87        painter.setRenderHint(QPainter::Antialiasing, true); 
    8588 
    8689        if(!_remoteVideoFrame.isNull()) 
    87                 painter.drawPixmap(ui->label->pos(),_remoteVideoFrame.scaled(ui->label->size(),Qt::KeepAspectRatio,Qt::SmoothTransformation)); 
     90        { 
     91                QPixmap pix = _remoteVideoFrame.scaled(ui->label->size(),Qt::KeepAspectRatio,Qt::SmoothTransformation); 
     92                QRect re(0,0,pix.width(),pix.height()); 
     93                re.moveCenter(ui->label->rect().center()); 
     94                painter.drawPixmap(re,pix); 
     95        } 
     96                 
    8897        if(!_localVideoFrame.isNull()) 
    8998                painter.drawPixmap(ui->label->pos(),_localVideoFrame.scaled(ui->label->size()/6,Qt::KeepAspectRatio,Qt::SmoothTransformation)); 
    90 } 
     99         
     100        if(_lastStatus != EnumPhoneCallState::PhoneCallStateTalking) 
     101        { 
     102                painter.fillRect(centralWidget()->rect(),QColor(30,30,30,200)); 
     103         
     104                if(!_timerIdProgressAnimation && (_lastStatus == EnumPhoneCallState::PhoneCallStateIncoming || _lastStatus == EnumPhoneCallState::PhoneCallStateHold)) 
     105                { 
     106                        painter.setPen(QPen(QColor(255,255,255,200), 3)); 
     107                        QRect re(0,0,50,50); 
     108                        re.moveCenter(centralWidget()->rect().center()); 
     109                        painter.drawEllipse(re); 
     110                 
     111                        re.translate(re.width()/4, 0); 
     112                        painter.setBrush(QColor(255,255,255,200)); 
     113                        painter.drawPie(re, 150 * 16, 60 * 16); 
     114                } 
     115        }        
     116         
     117        if(_timerIdProgressAnimation) 
     118        { 
     119                for (int i=0; i<9; i++) 
     120        { 
     121                        QColor color = Qt::white; 
     122                        color.setAlphaF(1.0f - (i/9.0f)); 
     123                        painter.setPen(Qt::NoPen); 
     124                        painter.setBrush(color); 
     125                        painter.save(); 
     126                        painter.translate(centralWidget()->rect().center()); 
     127                        painter.rotate(_angleProgressAnimation - i*40.0f); 
     128                        painter.drawRect(QRectF(5.5, 0.9, 21.5, 5)); 
     129                        painter.restore(); 
     130        } 
     131        } 
     132} 
     133 
     134void CallWidget::mouseReleaseEvent(QMouseEvent *) 
     135{ 
     136        if(_tCallSession->isStarted()) 
     137        { 
     138                if(_lastStatus == EnumPhoneCallState::PhoneCallStateTalking) 
     139                { 
     140                        startProgressAnimation(); 
     141                        _tCallSession->pause(); 
     142                } 
     143                else if(_lastStatus == EnumPhoneCallState::PhoneCallStateHold) 
     144                { 
     145                        startProgressAnimation(); 
     146                        _tCallSession->resume(); 
     147                } 
     148                         
     149        } 
     150        else if(_lastStatus == EnumPhoneCallState::PhoneCallStateIncoming) 
     151        { 
     152                startProgressAnimation(); 
     153                _tCallSession->start(); 
     154        }                
     155} 
     156 
     157void CallWidget::timerEvent(QTimerEvent* event) 
     158{ 
     159        if(event->timerId() == _timerIdProgressAnimation) 
     160        { 
     161                _angleProgressAnimation = (_angleProgressAnimation+30)%360; 
     162                update(); 
     163        } 
     164        else if(event->timerId() == _timerIdSession) 
     165        { 
     166                _durationSession++; 
     167                QTime time; 
     168                setWindowTitle(time.addSecs(_durationSession).toString()); 
     169        } 
     170} 
     171 
     172void CallWidget::startSessionTimer() 
     173{ 
     174        _timerIdSession = startTimer(1000); 
     175} 
     176 
     177void CallWidget::stopSessionTimer() 
     178{ 
     179        killTimer(_timerIdSession); 
     180} 
     181 
     182void CallWidget::startProgressAnimation() 
     183{ 
     184        if(!_timerIdProgressAnimation) 
     185                _timerIdProgressAnimation = startTimer(100); 
     186} 
     187 
     188void CallWidget::stopProgressAnimation() 
     189{ 
     190        if(_timerIdProgressAnimation) 
     191        { 
     192                killTimer(_timerIdProgressAnimation); 
     193                _timerIdProgressAnimation = 0; 
     194        } 
     195} 
     196 
    91197 
    92198void CallWidget::hangUpButtonClicked() { 
    93199 
    94200        _tCallSession->stop(); 
    95         //_ui->hangUpButton->setEnabled(false); 
    96201} 
    97202 
     
    108213 
    109214void CallWidget::phoneCallStateChangedSlot(EnumPhoneCallState::PhoneCallState state) { 
     215         
     216        _lastStatus = state; 
     217         
    110218        switch(state) { 
    111219                        //case EnumPhoneCallState::PhoneCallStateUnknown: 
    112220                case EnumPhoneCallState::PhoneCallStateClosed: 
     221                        stopProgressAnimation(); 
     222                        stopSessionTimer(); 
     223                        _labelMsg->setText("Closed...");                         
     224                        break; 
     225                         
    113226                case EnumPhoneCallState::PhoneCallStateError: 
    114                         _labelMsg->setText("Closed..."); 
    115                         _callButton->showProgressIndicator(false); 
    116                         _callButton->hide(); 
     227                        stopProgressAnimation(); 
     228                        stopSessionTimer(); 
     229                        _labelMsg->setText("Error...");                  
    117230                        break; 
    118231                         
    119232                case EnumPhoneCallState::PhoneCallStateTalking: 
     233                        stopProgressAnimation(); 
     234                        startSessionTimer(); 
    120235                        _labelMsg->setText("Talking..."); 
    121                         _callButton->show(); 
    122                         _callButton->showProgressIndicator(false); 
    123                         _callButton->setPixBackground(QPixmap(":/call/holdButtonFullScreen.png")); 
    124236                        break; 
    125237                         
    126238                case EnumPhoneCallState::PhoneCallStateDialing: 
     239                        startProgressAnimation(); 
    127240                        _labelMsg->setText("Dialing..."); 
    128                         _callButton->showProgressIndicator(true); 
    129241                        break; 
    130242                         
    131243                case EnumPhoneCallState::PhoneCallStateRinging: 
    132244                        _labelMsg->setText("Ringing..."); 
    133                         _callButton->showProgressIndicator(true); 
    134245                        break; 
    135246                         
    136247                case EnumPhoneCallState::PhoneCallStateHold: 
     248                        stopProgressAnimation(); 
    137249                        _labelMsg->setText("Hold..."); 
    138                         _callButton->showProgressIndicator(false); 
    139250                        break; 
    140251                         
    141252                case EnumPhoneCallState::PhoneCallStateResumed: 
    142253                        _labelMsg->setText("Resumed..."); 
    143                         _callButton->showProgressIndicator(false); 
    144254                        break; 
    145255                         
    146256                case EnumPhoneCallState::PhoneCallStateMissed: 
     257                        stopProgressAnimation(); 
    147258                        _labelMsg->setText("Missed..."); 
    148                         _callButton->showProgressIndicator(false); 
    149                         _callButton->hide(); 
    150259                        break; 
    151260                         
    152261                case EnumPhoneCallState::PhoneCallStateRedirected: 
     262                        stopProgressAnimation(); 
     263                        stopSessionTimer(); 
    153264                        _labelMsg->setText("Redirected..."); 
    154                         _callButton->showProgressIndicator(false); 
    155                         _callButton->hide(); 
    156265                        break; 
    157266                         
     
    161270                        break; 
    162271        } 
     272        update(); 
    163273} 
    164274 
  • gui/src/call/callwidget.h

    r177 r273  
    44#include <QtGui> 
    55#include <coip/coip.h> 
    6 #include <call/callbutton.h> 
    76 
    87namespace Ui { 
     
    2524        void closeEvent(QCloseEvent*); 
    2625        void paintEvent(QPaintEvent*); 
     26        void mouseReleaseEvent(QMouseEvent *); 
     27        void timerEvent(QTimerEvent*); 
    2728 
    2829private: 
     
    3132         
    3233        QLabel * _labelMsg; 
    33         CallButton * _callButton; 
     34 
     35        int _timerIdSession; 
     36        int _durationSession; 
     37        void startSessionTimer(); 
     38        void stopSessionTimer(); 
     39         
     40        int _timerIdProgressAnimation; 
     41        int _angleProgressAnimation; 
     42        void startProgressAnimation(); 
     43        void stopProgressAnimation(); 
     44         
    3445    Ui::CallWidget *ui; 
    3546        TCallSession * _tCallSession; 
    36  
     47        EnumPhoneCallState::PhoneCallState _lastStatus; 
     48         
    3749private Q_SLOTS: 
    3850        void hangUpButtonClicked(); 
Note: See TracChangeset for help on using the changeset viewer.