~noskcaj/ubuntu/saucy/sflphone/merge-1.2.3-2

« back to all changes in this revision

Viewing changes to kde/plasma/plasmoid/SFLPhonePlasmoid.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2012-05-19 21:46:37 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20120519214637-la8rbrford5kj6m3
Tags: 1.1.0-1
* New upstream release 
  - Fixes "FTBFS with libccrtp-dev/2.0.2 from experimental" (Closes: #663282)
* NEW Maintainer: Debian VoIP Team - Thanks Francois for your work.
  - (Closes: #665789: O: sflphone -- SIP and IAX2 compatible VoIP phone)
* Added Build-Depends: libdbus-c++-bin
* Add gcc47-fixes.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include "SFLPhonePlasmoid.h"
2
 
#include <QPainter>
3
 
#include <QFontMetrics>
4
 
#include <QSizeF>
5
 
#include <KIcon>
6
 
#include <KPushButton>
7
 
 
8
 
#include "../../src/lib/CallModel.h"
9
 
 
10
 
SFLPhonePlasmoid::SFLPhonePlasmoid(QObject* parent, const QVariantList& args)
11
 
    : Plasma::PopupApplet(parent, args), extenderItem(0), callInit(false), requierAttention(false)
12
 
{
13
 
   //m_svg.setImagePath("widgets/background");
14
 
   setBackgroundHints(DefaultBackground);
15
 
 
16
 
   CallModelConvenience::init();
17
 
 
18
 
   setMinimumSize(24,24);
19
 
}
20
 
 
21
 
void SFLPhonePlasmoid::dataUpdated(const QString& source, const Plasma::DataEngine::Data& data)
22
 
{
23
 
   mainWidget->dataUpdated(source, data);
24
 
 
25
 
   //Prevent conferences from being initialized before calls
26
 
   if ((source == "calls") && (!callInit)) {
27
 
      sflphoneEngine->connectSource("conferences", this,0/*Update only if something happen*/);
28
 
      callInit = true;
29
 
   }
30
 
}
31
 
 
32
 
SFLPhonePlasmoid::~SFLPhonePlasmoid()
33
 
{
34
 
 
35
 
}
36
 
 
37
 
void SFLPhonePlasmoid::init()
38
 
{
39
 
   //contactEngine = dataEngine("akonadi");
40
 
   sflphoneEngine = dataEngine("sflphone");
41
 
   sflphoneEngine->connectSource("calls", this,0/*Update only if something happen*/);
42
 
   sflphoneEngine->connectSource("info", this,0/*Update only if something happen*/);
43
 
   sflphoneEngine->connectSource("history", this,0/*Update only if something happen*/);
44
 
 
45
 
   mainWidget = new MainWidget();
46
 
   connect(mainWidget,SIGNAL(requierAttention()),this,SLOT(notify()));
47
 
 
48
 
   //panelFrame = new Plasma::SvgWidget(&panel_icon);
49
 
   panelFrame = new Plasma::PushButton(this);
50
 
 
51
 
   QGraphicsLinearLayout* mainLayout = new QGraphicsLinearLayout(Qt::Vertical);
52
 
 
53
 
   //panel_icon.setImagePath("/usr/share/kde4/apps/sflphone-plasmoid/icons/sflphone.svg");
54
 
   panelFrame->setImage("/usr/share/kde4/apps/sflphone-plasmoid/icons/sflphone.svg");
55
 
 
56
 
   mainLayout->addItem(panelFrame);
57
 
 
58
 
   setLayout(mainLayout);
59
 
 
60
 
   //connect(panelFrame, SIGNAL(clicked(Qt::MouseButton)), this, SLOT(showCallPopup(Qt::MouseButton)));
61
 
   connect(panelFrame->nativeWidget(), SIGNAL(clicked()), this, SLOT(showCallPopup()));
62
 
 
63
 
   extender()->setEmptyExtenderMessage(i18n("no running jobs..."));
64
 
}
65
 
 
66
 
void SFLPhonePlasmoid::constraintsEvent(Plasma::Constraints constraints)
67
 
{
68
 
   if (constraints& Plasma::FormFactorConstraint) {
69
 
      //FormFactor previous = formFaction;
70
 
      switch (formFactor()) {
71
 
         case Plasma::Planar:
72
 
         case Plasma::MediaCenter:
73
 
            formFaction = Desktop;
74
 
            m_orientation = Qt::Vertical;
75
 
            break;
76
 
         case Plasma::Horizontal:
77
 
            formFaction = Panel;
78
 
            m_orientation = Qt::Horizontal;
79
 
            break;
80
 
         case Plasma::Vertical:
81
 
            formFaction = Panel;
82
 
            m_orientation = Qt::Vertical;
83
 
            break;
84
 
      }
85
 
 
86
 
          //if (previous != m_mode)
87
 
             //connectToEngine();
88
 
   }
89
 
}
90
 
 
91
 
 
92
 
 
93
 
//void SFLPhonePlasmoid::modeChanged(int index)
94
 
//{
95
 
   //switch (index) {
96
 
   //   case CALL:
97
 
   //      if (currentMode == HISTORY)
98
 
   //        switchPage(historyScrollArea,callScrollArea,contactScrollArea,true);
99
 
   //      else
100
 
   //         switchPage(contactScrollArea,callScrollArea,historyScrollArea,true);
101
 
   //      break;
102
 
   //   case HISTORY:
103
 
   //      if (currentMode == CALL)
104
 
   //         switchPage(callScrollArea,historyScrollArea,contactScrollArea,false);
105
 
   //      else
106
 
   //         switchPage(contactScrollArea,historyScrollArea,callScrollArea,true);
107
 
   //      break;
108
 
   //   case CONTACT:
109
 
   //      if (currentMode == CALL)
110
 
   //         switchPage(callScrollArea,contactScrollArea,historyScrollArea,false);
111
 
   //      else
112
 
   //         switchPage(historyScrollArea,contactScrollArea,callScrollArea,false);
113
 
   //      break;
114
 
   //}
115
 
   //currentMode = index;
116
 
//}
117
 
 
118
 
//void SFLPhonePlasmoid::switchPage(Plasma::ScrollWidget* oldFrame, Plasma::ScrollWidget* newFrame, Plasma::ScrollWidget* toHide, bool direction)
119
 
//{
120
 
//   QPointF targetPos = oldFrame->pos();
121
 
//   newFrame->setPos(QPoint(targetPos.x() - newFrame->size().width() ,targetPos.y()));
122
 
//   Plasma::Animation *slideAnim = Plasma::Animator::create(Plasma::Animator::SlideAnimation);
123
 
//   slideAnim->setProperty("movementDirection", /*(direction)?*/Plasma::Animation::MoveRight/*:Plasma::Animation::MoveLeft*/);
124
 
//   slideAnim->setProperty("reference", Plasma::Animation::Center);
125
 
//   slideAnim->setProperty("distance", newFrame->size().width());
126
 
//   slideAnim->setProperty("duration",1000);
127
 
//   slideAnim->setTargetWidget(newFrame);
128
 
//
129
 
//   oldFrame->setPos(targetPos);
130
 
//   Plasma::Animation *slideAnimOut = Plasma::Animator::create(Plasma::Animator::SlideAnimation);
131
 
//   slideAnimOut->setProperty("movementDirection", /*(direction)?*/Plasma::Animation::MoveRight/*:Plasma::Animation::MoveLeft*/);
132
 
//   slideAnimOut->setProperty("reference", Plasma::Animation::Center);
133
 
//   slideAnimOut->setProperty("distance", newFrame->size().width());
134
 
//   slideAnimOut->setProperty("duration",1000);
135
 
//   slideAnimOut->setTargetWidget(oldFrame);
136
 
 
137
 
//   oldFrame->setVisible(true);
138
 
//   newFrame->setVisible(true);
139
 
//   toHide->setVisible(false);
140
 
 
141
 
//   slideAnim->start(QAbstractAnimation::DeleteWhenStopped);
142
 
//   slideAnimOut->start(QAbstractAnimation::DeleteWhenStopped);
143
 
//}
144
 
 
145
 
void SFLPhonePlasmoid::showCallPopup(/*Qt::MouseButton button*/)
146
 
{
147
 
   //Q_UNUSED(button)
148
 
   if (!extenderItem) {
149
 
      extenderItem = new Plasma::ExtenderItem(extender());
150
 
      extenderItem->setTitle("SFL Phone");
151
 
      extenderItem->setWidget(mainWidget);
152
 
      //extenderItem->showCloseButton();
153
 
   }
154
 
 
155
 
   togglePopup();
156
 
 
157
 
   if (requierAttention) {
158
 
      //panel_icon.setImagePath("/usr/share/kde4/apps/sflphone-plasmoid/icons/sflphone.svg");
159
 
      panelFrame->setImage("/usr/share/kde4/apps/sflphone-plasmoid/icons/sflphone.svg");
160
 
      requierAttention = false;
161
 
   }
162
 
}
163
 
 
164
 
void SFLPhonePlasmoid::notify()
165
 
{
166
 
   //panel_icon.setImagePath("/usr/share/kde4/apps/sflphone-plasmoid/icons/sflphone_notif.svg");
167
 
   panelFrame->setImage("/usr/share/kde4/apps/sflphone-plasmoid/icons/sflphone_notif.svg");
168
 
   requierAttention = true;
169
 
}
170
 
 
171
 
K_EXPORT_PLASMA_APPLET(sflphone, SFLPhonePlasmoid)
172