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
|
/**
* Copyright (C) 2014, Pelagicore
*
* Author: Jonatan PÄlsson <jonatan.palsson@pelagicore.com>
*
* This file is part of the GENIVI project Browser Proof-Of-Concept
* For further information, see http://genivi.org/
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef BROWSERPAGE_H
#define BROWSERPAGE_H
#include <QWebPage>
#include <QObject>
#include "userinput.h"
class BrowserPage : public QWebPage {
Q_OBJECT
public:
BrowserPage(QObject *parent, userinput *input)
: QWebPage (parent), m_userInput (input){
connect(this, SIGNAL(onAlertDialog(QString)),
m_userInput, SIGNAL(onAlertDialog(QString)));
connect(this, SIGNAL(onConfirmDialog(QString)),
m_userInput, SIGNAL(onConfirmDialog(QString)));
connect(this, SIGNAL(onPromptDialog(QString, QString)),
m_userInput, SIGNAL(onPromptDialog(QString, QString)));
connect(this, SIGNAL(onDialogCanceled(void)),
m_userInput, SIGNAL(onDialogCanceled(void)));
}
~BrowserPage(){ }
signals:
void onAlertDialog(QString);
void onConfirmDialog(QString);
void onPromptDialog(QString, QString);
protected:
void javaScriptAlert(QWebFrame *frame, const QString &message);
bool javaScriptConfirm(QWebFrame *frame, const QString &message);
bool javaScriptPrompt (QWebFrame *, const QString &, const QString &, QString *);
protected slots:
void confirm(bool b) {m_confirm = b;}
void prompt (QString s, bool b) {m_promptBool = b; m_promptStr = s;}
private:
userinput *m_userInput;
bool m_confirm;
bool m_promptBool;
QString m_promptStr;
};
#endif /* BROWSERPAGE_H */
|