summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt7
-rw-r--r--gui/browserdialog.cpp76
-rw-r--r--gui/browserdialog.h41
-rw-r--r--gui/browserdialog.ui92
-rw-r--r--gui/mainwindow.cpp18
-rw-r--r--gui/mainwindow.h3
6 files changed, 233 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f67b8346..efa93f8d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -106,6 +106,7 @@ gui/settingsdialog.cpp
gui/newinstancedialog.cpp
gui/logindialog.cpp
gui/taskdialog.cpp
+gui/browserdialog.cpp
util/pathutils.cpp
util/osutils.cpp
@@ -124,6 +125,7 @@ gui/settingsdialog.h
gui/newinstancedialog.h
gui/logindialog.h
gui/taskdialog.h
+gui/browserdialog.h
data/appsettings.h
data/inifile.h
@@ -159,6 +161,7 @@ gui/settingsdialog.ui
gui/newinstancedialog.ui
gui/logindialog.ui
gui/taskdialog.ui
+gui/browserdialog.ui
)
IF(WIN32)
@@ -172,11 +175,13 @@ QT5_WRAP_UI(MULTIMC_UI ${MULTIMC5_UIS})
QT5_ADD_RESOURCES(MULTIMC_QRC multimc.qrc)
add_executable(MultiMC ${MULTIMC_SOURCES} ${MULTIMC_HEADERS} ${MULTIMC_UI} ${MULTIMC_QRC})
-qt5_use_modules(MultiMC Widgets Network)
+qt5_use_modules(MultiMC Widgets Network WebKitWidgets)
target_link_libraries(MultiMC quazip patchlib ${MultiMC_LINK_ADDITIONAL_LIBS})
add_dependencies(MultiMC MultiMCLauncher)
install(TARGETS MultiMC RUNTIME DESTINATION .)
+SET(Qt5_DIR $ENV{QTDIR})
+
IF(WIN32)
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
SET(D "d")
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);
+}
diff --git a/gui/browserdialog.h b/gui/browserdialog.h
new file mode 100644
index 00000000..9d3587ef
--- /dev/null
+++ b/gui/browserdialog.h
@@ -0,0 +1,41 @@
+#ifndef BROWSERDIALOG_H
+#define BROWSERDIALOG_H
+
+#include <QDialog>
+
+namespace Ui {
+class BrowserDialog;
+}
+
+class BrowserDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit BrowserDialog(QWidget *parent = 0);
+ ~BrowserDialog();
+
+ void load(const QUrl &url);
+
+ void setPageTitleInWindowTitle(bool enable);
+ bool pageTitleInWindowTitle(void) { return m_pageTitleInWindowTitle; }
+
+ void setWindowTitleFormat(QString format);
+ QString windowTitleFormat(void) { return m_windowTitleFormat; }
+
+private:
+ Ui::BrowserDialog *ui;
+
+ bool m_pageTitleInWindowTitle;
+ QString m_windowTitleFormat;
+
+ void refreshWindowTitle(void);
+
+private slots:
+ void on_btnBack_clicked(void);
+ void on_btnForward_clicked(void);
+ void on_webView_urlChanged(const QUrl &url);
+ void on_webView_titleChanged(const QString &title);
+};
+
+#endif // BROWSERDIALOG_H
diff --git a/gui/browserdialog.ui b/gui/browserdialog.ui
new file mode 100644
index 00000000..f32b9822
--- /dev/null
+++ b/gui/browserdialog.ui
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>BrowserDialog</class>
+ <widget class="QDialog" name="BrowserDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>535</width>
+ <height>400</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="toolbarLayout">
+ <item>
+ <widget class="QCommandLinkButton" name="btnBack">
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Back</string>
+ </property>
+ <property name="icon">
+ <iconset theme="go-previous"/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCommandLinkButton" name="btnForward">
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Forward</string>
+ </property>
+ <property name="icon">
+ <iconset theme="go-next"/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="toolbarSpacer_1">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QWebView" name="webView">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="url">
+ <url>
+ <string>about:blank</string>
+ </url>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>QWebView</class>
+ <extends>QWidget</extends>
+ <header>QtWebKitWidgets/QWebView</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index bc0840a0..271a67fb 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -28,6 +28,7 @@
#include "gui/newinstancedialog.h"
#include "gui/logindialog.h"
#include "gui/taskdialog.h"
+#include "gui/browserdialog.h"
#include "data/appsettings.h"
#include "data/version.h"
@@ -36,7 +37,7 @@
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
- ui(new Ui::MainWindow)
+ ui(new Ui::MainWindow)
{
ui->setupUi(this);
@@ -88,12 +89,14 @@ void MainWindow::on_actionSettings_triggered()
void MainWindow::on_actionReportBug_triggered()
{
- QDesktopServices::openUrl(QUrl("http://bugs.forkk.net/"));
+ //QDesktopServices::openUrl(QUrl("http://bugs.forkk.net/"));
+ openWebPage(QUrl("http://bugs.forkk.net/"));
}
void MainWindow::on_actionNews_triggered()
{
- QDesktopServices::openUrl(QUrl("http://news.forkk.net/"));
+ //QDesktopServices::openUrl(QUrl("http://news.forkk.net/"));
+ openWebPage(QUrl("http://news.forkk.net/"));
}
void MainWindow::on_actionAbout_triggered()
@@ -155,3 +158,12 @@ void MainWindow::onLoginComplete(LoginResponse response)
QString("Logged in as %1 with session ID %2.").
arg(response.getUsername(), response.getSessionID()));
}
+
+// BrowserDialog
+void MainWindow::openWebPage(QUrl url)
+{
+ BrowserDialog *browser = new BrowserDialog(this);
+
+ browser->load(url);
+ browser->exec();
+}
diff --git a/gui/mainwindow.h b/gui/mainwindow.h
index 28ca341a..cf6a9dbc 100644
--- a/gui/mainwindow.h
+++ b/gui/mainwindow.h
@@ -35,6 +35,9 @@ public:
~MainWindow();
void closeEvent(QCloseEvent *event);
+
+ // Browser Dialog
+ void openWebPage(QUrl url);
private slots:
void on_actionAbout_triggered();