1 |
#include <QApplication> |
#include <QApplication> |
2 |
#include <QDesktopWidget> |
#include <QDesktopWidget> |
|
#include <iostream> |
|
3 |
#include <stdexcept> |
#include <stdexcept> |
4 |
|
|
5 |
#include "MyWebView.h" |
#include "MyWebView.h" |
6 |
|
|
7 |
|
|
8 |
MyWebView::MyWebView(QWidget* parent) : QWebView(parent) { |
MyWebView::MyWebView(QWidget* parent) : QWebView(parent) { |
9 |
// this->setWindowState( Qt::WindowFullScreen ); |
connect(this, SIGNAL( loadFinished(bool) ), this, SLOT( onChange(bool) ) ); |
10 |
qApp->setOverrideCursor( QCursor( Qt::BlankCursor) ); |
|
11 |
|
QWebSettings* settings = QWebSettings::globalSettings(); |
12 |
connect(this, SIGNAL( loadStarted() ), this, SLOT( test() ) ); |
settings->setAttribute( QWebSettings::JavascriptEnabled, true); |
13 |
|
settings->setAttribute( QWebSettings::PluginsEnabled, true); |
14 |
|
|
15 |
|
|
16 |
|
|
17 |
QTimer* timer = new QTimer(this); |
QTimer* timer = new QTimer(this); |
18 |
connect(timer, SIGNAL(timeout()), this, SLOT(onTimer())); |
connect(timer, SIGNAL(timeout()), this, SLOT(onTimer())); |
19 |
timer->start(1000); |
timer->start(1000); |
20 |
|
|
21 |
} |
} |
22 |
|
|
23 |
void MyWebView::show() { |
void MyWebView::start() { |
|
QWebView::show(); |
|
24 |
try { |
try { |
25 |
this->load( QUrl( generateUrl() ) ); |
this->load( QUrl( generateUrl() ) ); |
26 |
} catch (std::exception& e) { |
} catch (std::exception& e) { |
37 |
|
|
38 |
QString MyWebView::generateUrl() { |
QString MyWebView::generateUrl() { |
39 |
QDesktopWidget* desktop = QApplication::desktop(); |
QDesktopWidget* desktop = QApplication::desktop(); |
40 |
QRect rect = desktop->screenGeometry(); |
QRect rect = desktop->screenGeometry(); |
|
|
|
|
QString width; |
|
|
width.setNum( rect.width() ); |
|
41 |
|
|
42 |
QString height; |
|
43 |
height.setNum( rect.height() ); |
QString width, height; |
44 |
|
width.setNum( rect.width() ); |
45 |
|
height.setNum( rect.height() ); |
46 |
|
|
47 |
|
|
48 |
QSettings settings("Caddi", "infoscreen"); |
QSettings settings("Caddi", "infoscreen"); |
49 |
std::cout << settings.fileName().toAscii().data() << std::endl; |
qDebug() << "Settings: " << settings.fileName(); |
50 |
|
|
51 |
QString url = settings.value("url").toString(); |
QString url = settings.value("url").toString(); |
52 |
QString screenid = settings.value("screenid").toString(); |
QString screenid = settings.value("screenid").toString(); |
53 |
|
|
60 |
url.append("&height=").append(height); |
url.append("&height=").append(height); |
61 |
|
|
62 |
|
|
63 |
std::cout << url.toAscii().data() << std::endl; |
qDebug() << "URL:" << url; |
64 |
|
|
65 |
|
|
66 |
return url; |
return url; |
67 |
} |
} |
68 |
|
|
69 |
//public slots: |
//public slots: |
70 |
void MyWebView::test() { |
void MyWebView::onChange(bool success) { |
71 |
std::cout << "test" << std::endl; |
//qDebug() << "html" << this->page()->mainFrame()->toHtml(); |
72 |
} |
} |
73 |
|
|
74 |
|
|
75 |
void MyWebView::onTimer() { |
void MyWebView::onTimer() { |
|
static int count = 0; |
|
|
count++; |
|
|
|
|
|
if (count == 10) { |
|
|
system("xset dpms force off"); |
|
|
} |
|
|
|
|
|
std::cout << "timer" << std::endl; |
|
76 |
} |
} |