From 79c5ae121b4f4de24fe3edc57bf3f0e3a8fccfe4 Mon Sep 17 00:00:00 2001 From: Orochimarufan Date: Wed, 13 Feb 2013 00:35:35 +0100 Subject: add first iteration of the integrated browser --- gui/browserdialog.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++ gui/browserdialog.h | 41 +++++++++++++++++++++++ gui/browserdialog.ui | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++ gui/mainwindow.cpp | 18 ++++++++-- gui/mainwindow.h | 3 ++ 5 files changed, 227 insertions(+), 3 deletions(-) create mode 100644 gui/browserdialog.cpp create mode 100644 gui/browserdialog.h create mode 100644 gui/browserdialog.ui (limited to 'gui') 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 + +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 + +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 @@ + + + BrowserDialog + + + + 0 + 0 + 535 + 400 + + + + Dialog + + + + + + + + + 100 + 16777215 + + + + Back + + + + + + + + + + + 100 + 16777215 + + + + Forward + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 0 + 0 + + + + + about:blank + + + + + + + + + QWebView + QWidget +
QtWebKitWidgets/QWebView
+
+
+ + +
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(); -- cgit v1.2.3 From 369b1c55c99aa8bdcd2d57ab4aad3633343f1417 Mon Sep 17 00:00:00 2001 From: Orochimarufan Date: Wed, 13 Feb 2013 04:03:15 +0100 Subject: implement desktop shortcut creation. windows code not tested. --- gui/browserdialog.cpp | 8 ++++---- gui/mainwindow.cpp | 14 ++++++++++++++ gui/mainwindow.h | 2 ++ 3 files changed, 20 insertions(+), 4 deletions(-) (limited to 'gui') diff --git a/gui/browserdialog.cpp b/gui/browserdialog.cpp index 58f185ce..40c50c3f 100644 --- a/gui/browserdialog.cpp +++ b/gui/browserdialog.cpp @@ -34,7 +34,7 @@ void BrowserDialog::on_btnForward_clicked() void BrowserDialog::on_webView_urlChanged(const QUrl &url) { Q_UNUSED(url); - qDebug("urlChanged"); + //qDebug("urlChanged"); ui->btnBack->setEnabled(ui->webView->history()->canGoBack()); ui->btnForward->setEnabled(ui->webView->history()->canGoForward()); } @@ -42,7 +42,7 @@ void BrowserDialog::on_webView_urlChanged(const QUrl &url) // Window Title Magic void BrowserDialog::refreshWindowTitle() { - qDebug("refreshTitle"); + //qDebug("refreshTitle"); if (m_pageTitleInWindowTitle) setWindowTitle(m_windowTitleFormat.arg(ui->webView->title())); else @@ -63,7 +63,7 @@ void BrowserDialog::setWindowTitleFormat(QString format) void BrowserDialog::on_webView_titleChanged(const QString &title) { - qDebug("titleChanged"); + //qDebug("titleChanged"); if (m_pageTitleInWindowTitle) setWindowTitle(m_windowTitleFormat.arg(title)); } @@ -71,6 +71,6 @@ void BrowserDialog::on_webView_titleChanged(const QString &title) // Public access Methods void BrowserDialog::load(const QUrl &url) { - qDebug("load"); + //qDebug("load"); ui->webView->setUrl(url); } diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 271a67fb..9bbc4c38 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -18,11 +18,14 @@ #include #include +#include #include #include #include "util/osutils.h" +#include "util/userutil.h" +#include "util/pathutils.h" #include "gui/settingsdialog.h" #include "gui/newinstancedialog.h" @@ -159,6 +162,17 @@ void MainWindow::onLoginComplete(LoginResponse response) arg(response.getUsername(), response.getSessionID())); } +// Create A Desktop Shortcut +void MainWindow::on_actionMakeDesktopShortcut_triggered() +{ + QString name("Test"); + name = QInputDialog::getText(this, tr("MultiMC Shortcut"), tr("Enter a Shortcut Name."), QLineEdit::Normal, name); + + Util::createShortCut(Util::getDesktopDir(), "test", QStringList() << "-d" << "lol", name, "application-x-octet-stream"); + + QMessageBox::warning(this, "Stupidness", "A Dummy Shortcut was created. the current instance model doesnt allow for anything more"); +} + // BrowserDialog void MainWindow::openWebPage(QUrl url) { diff --git a/gui/mainwindow.h b/gui/mainwindow.h index cf6a9dbc..f2dfbc70 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -64,6 +64,8 @@ private slots: void on_actionLaunchInstance_triggered(); + + void on_actionMakeDesktopShortcut_triggered(); void doLogin(const QString& errorMsg = ""); -- cgit v1.2.3 From c523a2c752bb7b071715f6c4eac18f36bcd2c162 Mon Sep 17 00:00:00 2001 From: Orochimarufan Date: Wed, 20 Feb 2013 00:07:52 +0100 Subject: implement commandline parsing --- gui/mainwindow.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'gui') diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 9bbc4c38..0ca9fde1 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -1,4 +1,8 @@ /* Copyright 2013 MultiMC Contributors + * + * Authors: Andrew Okin + * Peterix + * Orochimarufan * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,9 +23,10 @@ #include #include #include - +#include #include #include +#include #include "util/osutils.h" #include "util/userutil.h" @@ -168,9 +173,9 @@ void MainWindow::on_actionMakeDesktopShortcut_triggered() QString name("Test"); name = QInputDialog::getText(this, tr("MultiMC Shortcut"), tr("Enter a Shortcut Name."), QLineEdit::Normal, name); - Util::createShortCut(Util::getDesktopDir(), "test", QStringList() << "-d" << "lol", name, "application-x-octet-stream"); + Util::createShortCut(Util::getDesktopDir(), QApplication::instance()->applicationFilePath(), QStringList() << "-dl" << QDir::currentPath() << "test", name, "application-x-octet-stream"); - QMessageBox::warning(this, "Stupidness", "A Dummy Shortcut was created. the current instance model doesnt allow for anything more"); + QMessageBox::warning(this, "Not useful", "A Dummy Shortcut was created. it will not do anything productive"); } // BrowserDialog -- cgit v1.2.3 From 576e979df4a54df9bf5ffeae3559f488b3045268 Mon Sep 17 00:00:00 2001 From: Orochimarufan Date: Thu, 21 Feb 2013 19:35:52 +0100 Subject: Implement About Dialog Prepared XDG icon theme in :/icons/multimc. will only be usefull as soon as Qt decides to support custom fallback themes. use the resources directly for now. --- gui/aboutdialog.cpp | 23 +++++ gui/aboutdialog.h | 22 ++++ gui/aboutdialog.ui | 288 ++++++++++++++++++++++++++++++++++++++++++++++++++++ gui/mainwindow.cpp | 4 +- 4 files changed, 336 insertions(+), 1 deletion(-) create mode 100644 gui/aboutdialog.cpp create mode 100644 gui/aboutdialog.h create mode 100644 gui/aboutdialog.ui (limited to 'gui') diff --git a/gui/aboutdialog.cpp b/gui/aboutdialog.cpp new file mode 100644 index 00000000..876f3044 --- /dev/null +++ b/gui/aboutdialog.cpp @@ -0,0 +1,23 @@ +#include "aboutdialog.h" +#include "ui_aboutdialog.h" + +#include +#include + +AboutDialog::AboutDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::AboutDialog) +{ + ui->setupUi(this); + + ui->icon->setPixmap(QIcon(":/icons/multimc/scalable/apps/multimc.svg").pixmap(64)); + + connect(ui->closeButton, SIGNAL(clicked()), SLOT(close())); + + QApplication::instance()->connect(ui->aboutQt, SIGNAL(clicked()), SLOT(aboutQt())); +} + +AboutDialog::~AboutDialog() +{ + delete ui; +} diff --git a/gui/aboutdialog.h b/gui/aboutdialog.h new file mode 100644 index 00000000..d462de28 --- /dev/null +++ b/gui/aboutdialog.h @@ -0,0 +1,22 @@ +#ifndef ABOUTDIALOG_H +#define ABOUTDIALOG_H + +#include + +namespace Ui { +class AboutDialog; +} + +class AboutDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AboutDialog(QWidget *parent = 0); + ~AboutDialog(); + +private: + Ui::AboutDialog *ui; +}; + +#endif // ABOUTDIALOG_H diff --git a/gui/aboutdialog.ui b/gui/aboutdialog.ui new file mode 100644 index 00000000..6b8f906d --- /dev/null +++ b/gui/aboutdialog.ui @@ -0,0 +1,288 @@ + + + AboutDialog + + + + 0 + 0 + 450 + 400 + + + + + 450 + 400 + + + + Dialog + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 15 + + + + MultiMC + + + Qt::AlignCenter + + + + + + + 0 + + + + + 0 + 0 + 432 + 153 + + + + About + + + + + + MultiMC is a custom launcher that makes managing Minecraft easier by allowing you to have multiple installations of Minecraft at once. + + + Qt::AlignCenter + + + true + + + + + + + + 8 + true + + + + © 2013 MultiMC Contributors + + + Qt::AlignCenter + + + + + + + + 10 + + + + <html><head/><body><p><a href="http://github.com/Forkk/MultiMC5"><span style=" text-decoration: underline; color:#0000ff;">http://github.com/Forkk/MultiMC5</span></a></p></body></html> + + + Qt::AlignCenter + + + + + + + + + 0 + 0 + 432 + 153 + + + + Credits + + + + + + true + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Andrew Okin &lt;<a href="mailto:forkk@forkk.net"><span style=" text-decoration: underline; color:#0000ff;">forkk@forkk.net</span></a>&gt;</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Petr Mrázek &lt;<a href="mailto:peterix@gmail.com"><span style=" text-decoration: underline; color:#0000ff;">peterix@gmail.com</span></a>&gt;</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Orochimarufan &lt;<a href="mailto:orochimarufan.x3@gmail.com"><span style=" text-decoration: underline; color:#0000ff;">orochimarufan.x3@gmail.com</span></a>&gt;</p></body></html> + + + + + + + + License + + + + + + + 0 + 0 + + + + true + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Copyright 2012 MultiMC Contributors</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">you may not use this file except in compliance with the License.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">You may obtain a copy of the License at</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;"> http://www.apache.org/licenses/LICENSE-2.0</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Unless required by applicable law or agreed to in writing, software</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">distributed under the License is distributed on an &quot;AS IS&quot; BASIS,</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">See the License for the specific language governing permissions and</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">limitations under the License.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">MultiMC uses bspatch, </span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Copyright 2003-2005 Colin Percival</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">All rights reserved</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Redistribution and use in source and binary forms, with or without</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">modification, are permitted providing that the following conditions</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">are met: </span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">1. Redistributions of source code must retain the above copyright</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;"> notice, this list of conditions and the following disclaimer.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">2. Redistributions in binary form must reproduce the above copyright</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;"> notice, this list of conditions and the following disclaimer in the</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;"> documentation and/or other materials provided with the distribution.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">POSSIBILITY OF SUCH DAMAGE.</span></p></body></html> + + + + + + + + + + + + + About Qt + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Close + + + + + + + + + + diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 0ca9fde1..43c5cd82 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -37,6 +37,7 @@ #include "gui/logindialog.h" #include "gui/taskdialog.h" #include "gui/browserdialog.h" +#include "gui/aboutdialog.h" #include "data/appsettings.h" #include "data/version.h" @@ -109,7 +110,8 @@ void MainWindow::on_actionNews_triggered() void MainWindow::on_actionAbout_triggered() { - + AboutDialog dialog(this); + dialog.exec(); } void MainWindow::on_mainToolBar_visibilityChanged(bool) -- cgit v1.2.3 From 3a173648e789f30b2843241ee38e694d16e10358 Mon Sep 17 00:00:00 2001 From: Orochimarufan Date: Fri, 22 Feb 2013 18:18:23 +0100 Subject: Implement ConsoleWindow --- gui/consolewindow.cpp | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ gui/consolewindow.h | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ gui/consolewindow.ui | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 208 insertions(+) create mode 100644 gui/consolewindow.cpp create mode 100644 gui/consolewindow.h create mode 100644 gui/consolewindow.ui (limited to 'gui') diff --git a/gui/consolewindow.cpp b/gui/consolewindow.cpp new file mode 100644 index 00000000..1d84fe04 --- /dev/null +++ b/gui/consolewindow.cpp @@ -0,0 +1,73 @@ +#include "consolewindow.h" +#include "ui_consolewindow.h" + +#include + +ConsoleWindow::ConsoleWindow(QWidget *parent) : + QDialog(parent), + ui(new Ui::ConsoleWindow), + m_mayclose(true) +{ + ui->setupUi(this); +} + +ConsoleWindow::~ConsoleWindow() +{ + delete ui; +} + +void ConsoleWindow::writeColor(QString text, const char *color) +{ + // append a paragraph + if (color != nullptr) + ui->text->appendHtml(QString("%2").arg(color).arg(text)); + else + ui->text->appendPlainText(text); + // scroll down + QScrollBar *bar = ui->text->verticalScrollBar(); + bar->setValue(bar->maximum()); +} + +void ConsoleWindow::write(QString data, WriteMode mode) +{ + if (data.endsWith('\n')) + data = data.left(data.length()-1); + QStringList paragraphs = data.split('\n'); + QListIterator iter(paragraphs); + if (mode == MULTIMC) + while(iter.hasNext()) + writeColor(iter.next(), "blue"); + else if (mode == ERROR) + while(iter.hasNext()) + writeColor(iter.next(), "red"); + else + while(iter.hasNext()) + writeColor(iter.next()); +} + +void ConsoleWindow::clear() +{ + ui->text->clear(); +} + +void ConsoleWindow::on_closeButton_clicked() +{ + close(); +} + +void ConsoleWindow::setMayClose(bool mayclose) +{ + m_mayclose = mayclose; + if (mayclose) + ui->closeButton->setEnabled(true); + else + ui->closeButton->setEnabled(false); +} + +void ConsoleWindow::closeEvent(QCloseEvent * event) +{ + if(!m_mayclose) + event->ignore(); + else + QDialog::closeEvent(event); +} diff --git a/gui/consolewindow.h b/gui/consolewindow.h new file mode 100644 index 00000000..1d322afb --- /dev/null +++ b/gui/consolewindow.h @@ -0,0 +1,69 @@ +#ifndef CONSOLEWINDOW_H +#define CONSOLEWINDOW_H + +#include + +namespace Ui { +class ConsoleWindow; +} + +class ConsoleWindow : public QDialog +{ + Q_OBJECT + +public: + /** + * @brief The WriteMode enum + * defines how stuff is displayed + */ + enum WriteMode { + DEFAULT, + ERROR, + MULTIMC + }; + + explicit ConsoleWindow(QWidget *parent = 0); + ~ConsoleWindow(); + + /** + * @brief specify if the window is allowed to close + * @param mayclose + * used to keep it alive while MC runs + */ + void setMayClose(bool mayclose); + +public slots: + /** + * @brief write a string + * @param data the string + * @param mode the WriteMode + * lines have to be put through this as a whole! + */ + void write(QString data, WriteMode mode=MULTIMC); + + /** + * @brief write a colored paragraph + * @param data the string + * @param color the css color name + * this will only insert a single paragraph. + * \n are ignored. a real \n is always appended. + */ + void writeColor(QString data, const char *color=nullptr); + + /** + * @brief clear the text widget + */ + void clear(); + +private slots: + void on_closeButton_clicked(); + +protected: + void closeEvent(QCloseEvent *); + +private: + Ui::ConsoleWindow *ui; + bool m_mayclose; +}; + +#endif // CONSOLEWINDOW_H diff --git a/gui/consolewindow.ui b/gui/consolewindow.ui new file mode 100644 index 00000000..f8c87aa0 --- /dev/null +++ b/gui/consolewindow.ui @@ -0,0 +1,66 @@ + + + ConsoleWindow + + + + 0 + 0 + 600 + 400 + + + + MultiMC Console + + + + + + + 10 + + + + false + + + true + + + + + + false + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Close + + + + + + + + + + -- cgit v1.2.3