This repository has been archived by the owner on Jul 30, 2019. It is now read-only.
forked from cip/WikiOnBoard
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
articleviewerqml.h
130 lines (106 loc) · 3.83 KB
/
articleviewerqml.h
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/* WikiOnBoard
Copyright (C) 2011 Christian Puehringer
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.*/
#ifndef ARTICLEVIEWERQML_H
#define ARTICLEVIEWERQML_H
#include <QtGui/QGraphicsProxyWidget>
#include <qdebug>
#include "zimfilewrapper.h"
#include "articleviewer.h"
#include <QApplication>
class ArticleViewerQML : public QGraphicsProxyWidget
{
Q_OBJECT
Q_PROPERTY(bool showImages READ showImages WRITE setShowImages NOTIFY showImagesChanged)
Q_PROPERTY(int zoomLevel READ zoomLevel WRITE setZoomLevel NOTIFY zoomLevelChanged)
public:
ArticleViewerQML(QGraphicsItem* parent = 0)
: QGraphicsProxyWidget(parent)
{
widget = new ArticleViewer(0,0);
setFocusPolicy(Qt::NoFocus);
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR)
#else
//On harmattan article font size way to small,
// therefore increase zoomlevel
widget->zoomIn(8);
#endif
setWidget(widget);
QObject::connect(widget, SIGNAL(backwardAvailable(bool)), this, SIGNAL(backwardAvailable(bool)));
QObject::connect(widget, SIGNAL(forwardAvailable(bool)), this, SIGNAL(forwardAvailable(bool)));
QObject::connect(widget, SIGNAL(openExternalLink(QUrl)), this, SIGNAL(openExternalLink(QUrl)));
}
bool showImages() const
{
return widget->showImages();
}
void setShowImages(const bool showImages)
{
if (showImages != widget->showImages()) {
widget->setShowImages(showImages);
emit showImagesChanged(showImages);
}
}
int zoomLevel() const
{
return widget->zoomLevel();
}
void setZoomLevel(const int zoomLevel) {
if (zoomLevel != widget->zoomLevel()) {
widget->setZoomLevel(zoomLevel);
emit zoomLevelChanged(zoomLevel);
}
}
Q_SIGNALS:
void showImagesChanged(bool showImages);
void zoomLevelChanged(int zoomLevel);
void backwardAvailable ( bool available);
void forwardAvailable ( bool available);
void openExternalLink( QUrl url);
public slots:
void setZimFileWrapper(ZimFileWrapper* zimFileWrapper) {
widget->setZimFileWrapper(zimFileWrapper);
}
void openArticle(QString articleUrl) {
//TODO use url in qml?
QUrl url(articleUrl);
QUrl urlDecoded =url.toString();
QString urlEncoded = QString::fromUtf8(url.toEncoded().data(),url.toEncoded().length());
qDebug() << "ArticleViewerQML.openArticle: url (decoded): " <<urlDecoded<<"\nurl (encoded):"<<urlEncoded ;
widget->setSource(url);
}
void backward() {
qDebug() << "ArticleViewerQML.backward()";
widget->backward();
}
void forward() {
qDebug() << "ArticleViewerQML.forward()";
widget->forward();
}
bool isBackwardAvailable() {
qDebug() << "ArticleViewerQML.isBackwardAvailable()";
return widget->isBackwardAvailable();
}
bool isForwardAvailable() {
qDebug() << "ArticleViewerQML.isForwardAvailable()";
return widget->isForwardAvailable();
}
void pageDown() {
widget->pageDown();
}
void pageUp() {
widget->pageUp();
}
private:
ArticleViewer *widget;
};
#endif // ARTICLEVIEWERQML_H