1
#include "SFLPhonePlasmoid.h"
3
#include <QFontMetrics>
8
#include "../../src/lib/CallModel.h"
10
SFLPhonePlasmoid::SFLPhonePlasmoid(QObject* parent, const QVariantList& args)
11
: Plasma::PopupApplet(parent, args), extenderItem(0), callInit(false), requierAttention(false)
13
//m_svg.setImagePath("widgets/background");
14
setBackgroundHints(DefaultBackground);
16
CallModelConvenience::init();
18
setMinimumSize(24,24);
21
void SFLPhonePlasmoid::dataUpdated(const QString& source, const Plasma::DataEngine::Data& data)
23
mainWidget->dataUpdated(source, data);
25
//Prevent conferences from being initialized before calls
26
if ((source == "calls") && (!callInit)) {
27
sflphoneEngine->connectSource("conferences", this,0/*Update only if something happen*/);
32
SFLPhonePlasmoid::~SFLPhonePlasmoid()
37
void SFLPhonePlasmoid::init()
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*/);
45
mainWidget = new MainWidget();
46
connect(mainWidget,SIGNAL(requierAttention()),this,SLOT(notify()));
48
//panelFrame = new Plasma::SvgWidget(&panel_icon);
49
panelFrame = new Plasma::PushButton(this);
51
QGraphicsLinearLayout* mainLayout = new QGraphicsLinearLayout(Qt::Vertical);
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");
56
mainLayout->addItem(panelFrame);
58
setLayout(mainLayout);
60
//connect(panelFrame, SIGNAL(clicked(Qt::MouseButton)), this, SLOT(showCallPopup(Qt::MouseButton)));
61
connect(panelFrame->nativeWidget(), SIGNAL(clicked()), this, SLOT(showCallPopup()));
63
extender()->setEmptyExtenderMessage(i18n("no running jobs..."));
66
void SFLPhonePlasmoid::constraintsEvent(Plasma::Constraints constraints)
68
if (constraints& Plasma::FormFactorConstraint) {
69
//FormFactor previous = formFaction;
70
switch (formFactor()) {
72
case Plasma::MediaCenter:
73
formFaction = Desktop;
74
m_orientation = Qt::Vertical;
76
case Plasma::Horizontal:
78
m_orientation = Qt::Horizontal;
80
case Plasma::Vertical:
82
m_orientation = Qt::Vertical;
86
//if (previous != m_mode)
93
//void SFLPhonePlasmoid::modeChanged(int index)
97
// if (currentMode == HISTORY)
98
// switchPage(historyScrollArea,callScrollArea,contactScrollArea,true);
100
// switchPage(contactScrollArea,callScrollArea,historyScrollArea,true);
103
// if (currentMode == CALL)
104
// switchPage(callScrollArea,historyScrollArea,contactScrollArea,false);
106
// switchPage(contactScrollArea,historyScrollArea,callScrollArea,true);
109
// if (currentMode == CALL)
110
// switchPage(callScrollArea,contactScrollArea,historyScrollArea,false);
112
// switchPage(historyScrollArea,contactScrollArea,callScrollArea,false);
115
//currentMode = index;
118
//void SFLPhonePlasmoid::switchPage(Plasma::ScrollWidget* oldFrame, Plasma::ScrollWidget* newFrame, Plasma::ScrollWidget* toHide, bool direction)
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);
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);
137
// oldFrame->setVisible(true);
138
// newFrame->setVisible(true);
139
// toHide->setVisible(false);
141
// slideAnim->start(QAbstractAnimation::DeleteWhenStopped);
142
// slideAnimOut->start(QAbstractAnimation::DeleteWhenStopped);
145
void SFLPhonePlasmoid::showCallPopup(/*Qt::MouseButton button*/)
149
extenderItem = new Plasma::ExtenderItem(extender());
150
extenderItem->setTitle("SFL Phone");
151
extenderItem->setWidget(mainWidget);
152
//extenderItem->showCloseButton();
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;
164
void SFLPhonePlasmoid::notify()
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;
171
K_EXPORT_PLASMA_APPLET(sflphone, SFLPhonePlasmoid)