~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to kde/src/widgets/callviewoverlaytoolbar.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (1.1.11)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20140128182336-3xenud1kbnwmf3mz
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 *   Copyright (C) 2012-2013 by Savoir-Faire Linux                         *
3
 
 *   Author : Emmanuel Lepage Valle <emmanuel.lepage@savoirfairelinux.com >*
4
 
 *                                                                         *
5
 
 *   This program is free software; you can redistribute it and/or modify  *
6
 
 *   it under the terms of the GNU General Public License as published by  *
7
 
 *   the Free Software Foundation; either version 3 of the License, or     *
8
 
 *   (at your option) any later version.                                   *
9
 
 *                                                                         *
10
 
 *   This program is distributed in the hope that it will be useful,       *
11
 
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12
 
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13
 
 *   GNU General Public License for more details.                          *
14
 
 *                                                                         *
15
 
 *   You should have received a copy of the GNU General Public License     *
16
 
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
17
 
 **************************************************************************/
18
 
#include "callviewoverlaytoolbar.h"
19
 
 
20
 
//Qt
21
 
#include <QtGui/QPaintEvent>
22
 
#include <QtGui/QPainter>
23
 
#include <QtGui/QBrush>
24
 
#include <QtGui/QPen>
25
 
#include <QtSvg/QSvgRenderer>
26
 
#include <QtGui/QHBoxLayout>
27
 
#include <QDebug> //TODO remove
28
 
 
29
 
//KDE
30
 
#include <KStandardDirs>
31
 
#include <KIcon>
32
 
 
33
 
//SFLPhone
34
 
#include "sflphone.h"
35
 
#include "extendedaction.h"
36
 
 
37
 
const bool visibility[8][13] = {              /*ROW = BUTTONS   COLS=STATE*/
38
 
            /* INCOMING  RINGING CURRENT DIALING  HOLD FAILURE BUSY  TRANSFERRED TRANSF_HOLD  OVER  ERROR CONFERENCE CONFERENCE_HOLD:*/
39
 
 /*PICKUP   */ { true   , true ,  false,  false, false, false, false,   false,     false,    false, false,  false,      false    },
40
 
 /*HOLD     */ { false  , false,  true ,  false, false, false, false,   true ,     false,    false, false,  true ,      false    },
41
 
 /*UNHOLD   */ { false  , false,  false,  false, true , false, false,   false,     false,    false, false,  false,      false    },
42
 
 /*HANGUP   */ { false  , true ,  true ,  false, true , true , true ,   true ,     true ,    false, true ,  true ,      true     },
43
 
 /*MUTE     */ { false  , true ,  true ,  false, false, false, false,   false,     false,    false, false,  false,      false    },
44
 
 /*TRANSFER */ { false  , false,  true ,  false, true , false, false,   false,     false,    false, false,  false,      false    },
45
 
 /*RECORD   */ { false  , true ,  true ,  false, true , false, false,   true ,     true ,    false, false,  true ,      true     },
46
 
 /*REFUSE   */ { true   , false,  false,  false, false, false, false,   false,     false,    false, false,  false,      false    }
47
 
};
48
 
 
49
 
///Constructor
50
 
CallViewOverlayToolbar::CallViewOverlayToolbar(QWidget* parent) : QWidget(parent),m_pRightRender(0),m_pLeftRender(0)
51
 
{
52
 
   m_pRightRender = new QSvgRenderer( KStandardDirs::locate("data","sflphone-client-kde/overlay_right_corner.svg") );
53
 
   m_pLeftRender  = new QSvgRenderer( KStandardDirs::locate("data","sflphone-client-kde/overlay_left_corner.svg" ) );
54
 
 
55
 
   QHBoxLayout* layout = new QHBoxLayout(this);
56
 
 
57
 
   m_pHold     = createButton( SFLPhone::app()->getHoldAction()     );
58
 
   m_pUnhold   = createButton( SFLPhone::app()->getUnholdAction()   );
59
 
   m_pMute     = createButton( SFLPhone::app()->getMuteAction()     );
60
 
   m_pPickup   = createButton( SFLPhone::app()->getPickupAction()   );
61
 
   m_pHangup   = createButton( SFLPhone::app()->getHangupAction()   );
62
 
   m_pTransfer = createButton( SFLPhone::app()->getTransferAction() );
63
 
   m_pRecord   = createButton( SFLPhone::app()->getRecordAction()   );
64
 
   m_pRefuse   = createButton( SFLPhone::app()->getRefuseAction()   );
65
 
 
66
 
   m_hButtons[ ActionButton::HOLD     ] = m_pHold    ;
67
 
   m_hButtons[ ActionButton::UNHOLD   ] = m_pUnhold  ;
68
 
   m_hButtons[ ActionButton::PICKUP   ] = m_pPickup  ;
69
 
   m_hButtons[ ActionButton::HANGUP   ] = m_pHangup  ;
70
 
   m_hButtons[ ActionButton::MUTE     ] = m_pMute    ;
71
 
   m_hButtons[ ActionButton::TRANSFER ] = m_pTransfer;
72
 
   m_hButtons[ ActionButton::RECORD   ] = m_pRecord  ;
73
 
   m_hButtons[ ActionButton::REFUSE   ] = m_pRefuse  ;
74
 
 
75
 
   layout->addWidget( m_pHangup   );
76
 
   layout->addWidget( m_pTransfer );
77
 
   layout->addWidget( m_pMute     );
78
 
   layout->addWidget( m_pRecord   );
79
 
   layout->addWidget( m_pUnhold   );
80
 
   layout->addWidget( m_pHold     );
81
 
   layout->addWidget( m_pPickup   );
82
 
   layout->addWidget( m_pRefuse   );
83
 
 
84
 
   setMinimumSize(100,56);
85
 
} //CallViewOverlayToolbar
86
 
 
87
 
///Resize event
88
 
void CallViewOverlayToolbar::resizeEvent(QResizeEvent* event)
89
 
{
90
 
   QWidget::resizeEvent(event);
91
 
}
92
 
 
93
 
///Repaint event
94
 
void CallViewOverlayToolbar::paintEvent(QPaintEvent* event)
95
 
{
96
 
   Q_UNUSED(event);
97
 
   QPainter customPainter(this);
98
 
   customPainter.setRenderHint(QPainter::Antialiasing);
99
 
   QBrush b = customPainter.brush();
100
 
   QPen   p = customPainter.pen();
101
 
 
102
 
   b.setColor("black");
103
 
   customPainter.setOpacity(0.5);
104
 
 
105
 
   customPainter.setBrush (Qt::black);
106
 
   customPainter.setPen   (Qt::transparent);
107
 
   customPainter.drawRect (QRect(3,10,width()-6,height()-16)               );
108
 
   customPainter.drawPie  (QRect(width()-8-3,height()-10,8,8),270*16,90*16 );
109
 
   customPainter.drawPie  (QRect(3,height()-10,8,8),180*16,90*16           );
110
 
   customPainter.drawRect (QRect(5+2,height()-6,width()-8-6,3)             );
111
 
 
112
 
   m_pLeftRender->render (&customPainter,QRect( 3,0,10,10)                 );
113
 
   m_pRightRender->render(&customPainter,QRect( width()-13,0,10,10)        );
114
 
} //paintEvent
115
 
 
116
 
///Create a toolbar button
117
 
ObserverToolButton* CallViewOverlayToolbar::createButton(ExtendedAction* action)
118
 
{
119
 
   ObserverToolButton* b = new ObserverToolButton(this);
120
 
   b->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
121
 
   b->setIconSize(QSize(28,28));
122
 
   b->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
123
 
   b->setText(action->text());
124
 
   b->setShortcut(0);
125
 
   b->setStyleSheet("margin-bottom:0px;margin-top:7px;font-weight:bold;background-color:transparent;color:#DDDDDD;padding-top:5px;");
126
 
   b->setIcon(action->altIcon());
127
 
   connect(action,SIGNAL(textChanged(QString)),b,SLOT(setNewText(QString)));
128
 
   connect(b,SIGNAL(clicked()),action,SLOT(trigger()));
129
 
   return b;
130
 
} //createButton
131
 
 
132
 
///Hide or show the toolbar and select visible actions
133
 
void CallViewOverlayToolbar::updateState(call_state state)
134
 
{
135
 
   m_hButtons[ ActionButton::HOLD     ]->setVisible(visibility[ ActionButton::HOLD     ][state]);
136
 
   m_hButtons[ ActionButton::UNHOLD   ]->setVisible(visibility[ ActionButton::UNHOLD   ][state]);
137
 
   m_hButtons[ ActionButton::PICKUP   ]->setVisible(visibility[ ActionButton::PICKUP   ][state]);
138
 
   m_hButtons[ ActionButton::HANGUP   ]->setVisible(visibility[ ActionButton::HANGUP   ][state]);
139
 
   m_hButtons[ ActionButton::MUTE     ]->setVisible(visibility[ ActionButton::MUTE     ][state]);
140
 
   m_hButtons[ ActionButton::TRANSFER ]->setVisible(visibility[ ActionButton::TRANSFER ][state]);
141
 
   m_hButtons[ ActionButton::RECORD   ]->setVisible(visibility[ ActionButton::RECORD   ][state]);
142
 
   m_hButtons[ ActionButton::REFUSE   ]->setVisible(visibility[ ActionButton::REFUSE   ][state]);
143
 
} //updateState
144
 
 
145
 
void CallViewOverlayToolbar::hideEvent(QHideEvent *)
146
 
{
147
 
    emit visibilityChanged(false);
148
 
}
149
 
 
150
 
void CallViewOverlayToolbar::showEvent(QShowEvent *)
151
 
{
152
 
    emit visibilityChanged(true);
153
 
}