diff options
author | Orochimarufan <orochimarufan.x3@gmail.com> | 2013-02-13 00:35:35 +0100 |
---|---|---|
committer | Orochimarufan <orochimarufan.x3@gmail.com> | 2013-02-13 00:35:35 +0100 |
commit | 79c5ae121b4f4de24fe3edc57bf3f0e3a8fccfe4 (patch) | |
tree | 813a1211ed634db4dc7e7df9a8874e1cf32c14b1 /gui/browserdialog.cpp | |
parent | b66be337fdb4d9fe023f1c4912573f99cca5437c (diff) | |
download | MultiMC-79c5ae121b4f4de24fe3edc57bf3f0e3a8fccfe4.tar MultiMC-79c5ae121b4f4de24fe3edc57bf3f0e3a8fccfe4.tar.gz MultiMC-79c5ae121b4f4de24fe3edc57bf3f0e3a8fccfe4.tar.lz MultiMC-79c5ae121b4f4de24fe3edc57bf3f0e3a8fccfe4.tar.xz MultiMC-79c5ae121b4f4de24fe3edc57bf3f0e3a8fccfe4.zip |
add first iteration of the integrated browser
Diffstat (limited to 'gui/browserdialog.cpp')
-rw-r--r-- | gui/browserdialog.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/gui/browserdialog.cpp b/gui/browserdialog.cpp new file mode 100644 index 00000000..58f185ce --- /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); +} |