summaryrefslogtreecommitdiffstats
path: root/gui/browserdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/browserdialog.cpp')
-rw-r--r--gui/browserdialog.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/gui/browserdialog.cpp b/gui/browserdialog.cpp
new file mode 100644
index 00000000..40c50c3f
--- /dev/null
+++ b/gui/browserdialog.cpp
@@ -0,0 +1,76 @@
+#include "browserdialog.h"
+#include "ui_browserdialog.h"
+
+#include <QtWebKit/QWebHistory>
+
+BrowserDialog::BrowserDialog(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::BrowserDialog),
+ m_pageTitleInWindowTitle(true),
+ m_windowTitleFormat("%1")
+{
+ ui->setupUi(this);
+ ui->webView->setPage(new QWebPage());
+ refreshWindowTitle();
+ resize(800, 600);
+}
+
+BrowserDialog::~BrowserDialog()
+{
+ delete ui;
+}
+
+// Navigation Buttons
+void BrowserDialog::on_btnBack_clicked()
+{
+ ui->webView->back();
+}
+
+void BrowserDialog::on_btnForward_clicked()
+{
+ ui->webView->forward();
+}
+
+void BrowserDialog::on_webView_urlChanged(const QUrl &url)
+{
+ Q_UNUSED(url);
+ //qDebug("urlChanged");
+ ui->btnBack->setEnabled(ui->webView->history()->canGoBack());
+ ui->btnForward->setEnabled(ui->webView->history()->canGoForward());
+}
+
+// Window Title Magic
+void BrowserDialog::refreshWindowTitle()
+{
+ //qDebug("refreshTitle");
+ if (m_pageTitleInWindowTitle)
+ setWindowTitle(m_windowTitleFormat.arg(ui->webView->title()));
+ else
+ setWindowTitle(m_windowTitleFormat);
+}
+
+void BrowserDialog::setPageTitleInWindowTitle(bool enable)
+{
+ m_pageTitleInWindowTitle = enable;
+ refreshWindowTitle();
+}
+
+void BrowserDialog::setWindowTitleFormat(QString format)
+{
+ m_windowTitleFormat = format;
+ refreshWindowTitle();
+}
+
+void BrowserDialog::on_webView_titleChanged(const QString &title)
+{
+ //qDebug("titleChanged");
+ if (m_pageTitleInWindowTitle)
+ setWindowTitle(m_windowTitleFormat.arg(title));
+}
+
+// Public access Methods
+void BrowserDialog::load(const QUrl &url)
+{
+ //qDebug("load");
+ ui->webView->setUrl(url);
+}