-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframebook.cpp
107 lines (84 loc) · 2.47 KB
/
framebook.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "framebook.h"
#include <QPainter>
#include <QFontMetrics>
#include <QSizeF>
#include <QPushButton>
#include <QGraphicsLinearLayout>
#include <QObject>
#include <Plasma/Applet>
#include <plasma/widgets/pushbutton.h>
#include <QHttp>
#include <stdio.h>
#include <QWebView>
#include <kconfigdialog.h>
#include <QList>
#include <QPair>
#include <QString>
#include <qjson/parser.h>
#include <QDebug>
#include <QSizePolicy>
#include <QTimer>
#include <framebookconfig.h>
//#include <framebookSettings.h>
FrameBook::FrameBook(QObject *parent,const QVariantList &args)
: Plasma::Applet(parent, args)
{
//init();
//setApplet(applet);
}
FrameBook::~FrameBook()
{
}
void FrameBook::init()
{
api=new FbApi(this);
api->id="317511414947451";
connect(api,SIGNAL(picsLoaded()),this,SLOT(nextImage()));
connect(api,SIGNAL(picLoaded(QString*)),this,SLOT(setImage(QString*)));
connect(this,SIGNAL(geometryChanged()),this,SLOT(setImgSize()));
setImgSize();
layout=new QGraphicsLinearLayout(Qt::Vertical,this);
nextBtn = new Plasma::PushButton(this);
nextBtn->setMaximumHeight(25);
timer=new QTimer(this);
timeout=5000;
connect(timer,SIGNAL(timeout()),this,SLOT(nextImage()));
nextBtn->setText("Next Image");
image=new Plasma::Label(this);
connect(nextBtn,SIGNAL(clicked()),this,SLOT(nextImage()));
layout->addItem(image);
layout->addItem(nextBtn);
layout->setAlignment(image,Qt::AlignHCenter);
setLayout(layout);
nextImage();
api->authenticate();
}
void FrameBook::nextImage(){
timer->stop();
if(api->nextPicture())
timer->start(timeout);
}
void FrameBook::setImage(QString * path){
qDebug() << size();
image->setImage(*path);
}
void FrameBook::setImgSize(){
api->imgWidth=qRound(size().width());
api->imgHeight=qRound(size().height());
}
void FrameBook::createConfigurationInterface(KConfigDialog * parent){
//delete config;
settings = new FrameBookSettings();
config = new FrameBookConfig(parent);
config->setInstallURL(api->getLoginUrl().toString());
//config->setAttributes(*api->user,*api->pass);
connect(parent,SIGNAL(settingsChanged(QString)),this,SLOT(updateSettings(QString)));
parent->addPage(config,settings, "Facebook Account","Image");
}
void FrameBook::updateSettings(QString dialog){
api->saveCredentials(config->getUser(),config->getPass());
api->authenticate();
}
// This is the command that links your applet to the .desktop file
K_EXPORT_PLASMA_APPLET(framebook, FrameBook)
#include "framebook.moc"