Browse Source

Use TypicaWebView in AboutTypica

Neal Wilson 11 years ago
parent
commit
8a382bc337
2 changed files with 5 additions and 33 deletions
  1. 2
    30
      src/abouttypica.w
  2. 3
    3
      src/webview.w

+ 2
- 30
src/abouttypica.w View File

@@ -11,11 +11,11 @@ browser or email client.
11 11
 
12 12
 @(abouttypica.h@>=
13 13
 #include <QMainWindow>
14
-#include <QWebView>
15 14
 #include <QFile>
16 15
 #include <QtDebug>
17 16
 #include <QMessageBox>
18 17
 #include <QDesktopServices>
18
+#include "webview.h"
19 19
 
20 20
 #ifndef AboutTypicaHeader
21 21
 #define AboutTypicaHeader
@@ -25,8 +25,6 @@ class AboutTypica : public QMainWindow
25 25
 	Q_OBJECT
26 26
 	public:
27 27
 		AboutTypica();
28
-	public slots:
29
-		void linkClicked(const QUrl &url);
30 28
 };
31 29
 
32 30
 #endif
@@ -48,35 +46,9 @@ AboutTypica::AboutTypica() : QMainWindow(NULL)
48 46
 	QFile aboutFile(":/resources/html/about.html");
49 47
 	aboutFile.open(QIODevice::ReadOnly);
50 48
 	QByteArray content = aboutFile.readAll();
51
-	QWebView *banner = new QWebView;
49
+	TypicaWebView *banner = new TypicaWebView;
52 50
  	banner->setHtml(content, QUrl("qrc:/resources/html/about.html"));
53 51
 	aboutFile.close();
54 52
 	setCentralWidget(banner);
55
-	QWebPage *page = banner->page();
56
-	page->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
57
-	connect(page, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClicked(QUrl)));
58 53
 }
59 54
 
60
-@ In order to display the About Qt window, we detect a special URL from a link
61
-clicked in the about box.
62
-
63
-@<AboutTypica implementation@>=
64
-void AboutTypica::linkClicked(const QUrl &url)
65
-{
66
-	if(url.scheme() == "typica")
67
-	{
68
-		QString address(url.toEncoded());
69
-		if(address == "typica://aboutqt")
70
-		{
71
-			QMessageBox::aboutQt(this);
72
-		}
73
-		else
74
-		{
75
-			qDebug() << "Unexpected link. Got: " << address;
76
-		}
77
-	}
78
-	else
79
-	{
80
-		QDesktopServices::openUrl(url);
81
-	}
82
-}

+ 3
- 3
src/webview.w View File

@@ -29,7 +29,7 @@ class TypicaWebView : public QWebView
29 29
 		TypicaWebView();
30 30
 		Q_INVOKABLE void load(const QString &url);
31 31
 		Q_INVOKABLE void print();
32
-		Q_INVOKABLE void setHtml(const QString &html);
32
+		Q_INVOKABLE void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
33 33
 		Q_INVOKABLE void setContent(QIODevice *device);
34 34
 		Q_INVOKABLE QString saveXml();
35 35
 	signals:
@@ -120,9 +120,9 @@ void TypicaWebView::print()
120 120
 	}
121 121
 }
122 122
 
123
-void TypicaWebView::setHtml(const QString &html)
123
+void TypicaWebView::setHtml(const QString &html, const QUrl &baseUrl)
124 124
 {
125
-	QWebView::setHtml(html);
125
+	QWebView::setHtml(html, baseUrl);
126 126
 }
127 127
 
128 128
 void TypicaWebView::setContent(QIODevice *device)

Loading…
Cancel
Save