diff options
-rw-r--r-- | CMakeLists.txt | 5 | ||||
-rw-r--r-- | gui/LegacyModEditDialog.cpp | 10 | ||||
-rw-r--r-- | gui/ModListView.cpp | 3 | ||||
-rw-r--r-- | gui/browserdialog.cpp | 76 | ||||
-rw-r--r-- | gui/browserdialog.h | 41 | ||||
-rw-r--r-- | gui/browserdialog.ui | 92 | ||||
-rw-r--r-- | gui/mainwindow.cpp | 8 | ||||
-rw-r--r-- | logic/BaseInstance.h | 2 | ||||
-rw-r--r-- | logic/LegacyInstance.cpp | 4 | ||||
-rw-r--r-- | logic/LegacyInstance.h | 2 | ||||
-rw-r--r-- | logic/ModList.cpp | 30 | ||||
-rw-r--r-- | logic/ModList.h | 2 | ||||
-rw-r--r-- | logic/OneSixInstance.cpp | 4 | ||||
-rw-r--r-- | logic/OneSixInstance.h | 2 |
14 files changed, 37 insertions, 244 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 29d3a286..f6520333 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -163,7 +163,6 @@ gui/settingsdialog.h gui/newinstancedialog.h gui/logindialog.h gui/taskdialog.h -gui/browserdialog.h gui/aboutdialog.h gui/consolewindow.h gui/instancemodel.h @@ -233,7 +232,6 @@ gui/settingsdialog.cpp gui/newinstancedialog.cpp gui/logindialog.cpp gui/taskdialog.cpp -gui/browserdialog.cpp gui/aboutdialog.cpp gui/consolewindow.cpp gui/instancemodel.cpp @@ -293,7 +291,6 @@ gui/settingsdialog.ui gui/newinstancedialog.ui gui/logindialog.ui gui/taskdialog.ui -gui/browserdialog.ui gui/aboutdialog.ui gui/consolewindow.ui gui/versionselectdialog.ui @@ -338,7 +335,7 @@ ADD_EXECUTABLE(MultiMC MACOSX_BUNDLE WIN32 ${MULTIMC_SOURCES} ${MULTIMC_HEADERS} ${MULTIMC_UI} ${MULTIMC_QRC} ${MULTIMC_RCS}) # Link -QT5_USE_MODULES(MultiMC Widgets Network WebKitWidgets Xml) +QT5_USE_MODULES(MultiMC Widgets Network Xml) TARGET_LINK_LIBRARIES(MultiMC quazip patchlib libUtil libSettings libGroupView ${MultiMC_LINK_ADDITIONAL_LIBS}) ADD_DEPENDENCIES(MultiMC MultiMCLauncher libUtil libSettings libGroupView) diff --git a/gui/LegacyModEditDialog.cpp b/gui/LegacyModEditDialog.cpp index 61e3872e..9e0b7a46 100644 --- a/gui/LegacyModEditDialog.cpp +++ b/gui/LegacyModEditDialog.cpp @@ -18,6 +18,7 @@ #include <logic/ModList.h> #include <pathutils.h> #include <QFileDialog> +#include <QDebug> LegacyModEditDialog::LegacyModEditDialog( LegacyInstance* inst, QWidget* parent ) : m_inst(inst), @@ -32,11 +33,10 @@ LegacyModEditDialog::LegacyModEditDialog( LegacyInstance* inst, QWidget* parent m_mods = m_inst->loaderModList(); m_coremods = m_inst->coreModList(); m_jarmods = m_inst->jarModList(); - /* - m_mods->startWatching(); - m_coremods->startWatching(); - m_jarmods->startWatching(); - */ + + qDebug() << m_mods.data(); + qDebug() << m_coremods.data(); + qDebug() << m_jarmods.data(); ui->jarModsTreeView->setModel(m_jarmods.data()); ui->coreModsTreeView->setModel(m_coremods.data()); diff --git a/gui/ModListView.cpp b/gui/ModListView.cpp index a9898851..61ab3651 100644 --- a/gui/ModListView.cpp +++ b/gui/ModListView.cpp @@ -1,6 +1,9 @@ #include "ModListView.h" #include <QHeaderView> #include <QMouseEvent> +#include <QPainter> +#include <QDrag> +#include <QRect> ModListView::ModListView ( QWidget* parent ) :QTreeView ( parent ) diff --git a/gui/browserdialog.cpp b/gui/browserdialog.cpp deleted file mode 100644 index 40c50c3f..00000000 --- a/gui/browserdialog.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#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 deleted file mode 100644 index 9d3587ef..00000000 --- a/gui/browserdialog.h +++ /dev/null @@ -1,41 +0,0 @@ -#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 deleted file mode 100644 index f32b9822..00000000 --- a/gui/browserdialog.ui +++ /dev/null @@ -1,92 +0,0 @@ -<?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 ba7e135c..97e60658 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -40,7 +40,6 @@ #include "gui/newinstancedialog.h" #include "gui/logindialog.h" #include "gui/taskdialog.h" -#include "gui/browserdialog.h" #include "gui/aboutdialog.h" #include "gui/versionselectdialog.h" #include "gui/lwjglselectdialog.h" @@ -366,13 +365,13 @@ void MainWindow::on_actionViewSelectedInstFolder_triggered() void MainWindow::on_actionEditInstMods_triggered() { - //TODO: Needs to do current ModEditDialog too BaseInstance* inst = selectedInstance(); if (inst) { auto dialog = inst->createModEditDialog(this); if(dialog) dialog->exec(); + dialog->deleteLater(); } } @@ -527,10 +526,7 @@ void MainWindow::on_actionMakeDesktopShortcut_triggered() // BrowserDialog void MainWindow::openWebPage ( QUrl url ) { - BrowserDialog *browser = new BrowserDialog ( this ); - - browser->load ( url ); - browser->exec(); + QDesktopServices::openUrl(url); } void MainWindow::on_actionChangeInstMCVersion_triggered() diff --git a/logic/BaseInstance.h b/logic/BaseInstance.h index 8b5de6f5..af721b04 100644 --- a/logic/BaseInstance.h +++ b/logic/BaseInstance.h @@ -129,7 +129,7 @@ public: virtual void cleanupAfterRun() = 0; /// create a mod edit dialog for the instance - virtual QSharedPointer<QDialog> createModEditDialog ( QWidget* parent ) = 0; + virtual QDialog * createModEditDialog ( QWidget* parent ) = 0; signals: /*! * \brief Signal emitted when properties relevant to the instance view change diff --git a/logic/LegacyInstance.cpp b/logic/LegacyInstance.cpp index c2a4b66a..cf2c622c 100644 --- a/logic/LegacyInstance.cpp +++ b/logic/LegacyInstance.cpp @@ -127,9 +127,9 @@ QSharedPointer< ModList > LegacyInstance::loaderModList() return d->loader_mod_list; } -QSharedPointer< QDialog > LegacyInstance::createModEditDialog ( QWidget* parent ) +QDialog * LegacyInstance::createModEditDialog ( QWidget* parent ) { - return QSharedPointer<QDialog> (new LegacyModEditDialog(this, parent)); + return new LegacyModEditDialog(this, parent); } diff --git a/logic/LegacyInstance.h b/logic/LegacyInstance.h index ef7006ab..4c8d8f69 100644 --- a/logic/LegacyInstance.h +++ b/logic/LegacyInstance.h @@ -88,7 +88,7 @@ public: virtual MinecraftProcess* prepareForLaunch( QString user, QString session ); virtual void cleanupAfterRun(); - virtual QSharedPointer< QDialog > createModEditDialog ( QWidget* parent ); + virtual QDialog * createModEditDialog ( QWidget* parent ); protected slots: virtual void jarModsChanged(); diff --git a/logic/ModList.cpp b/logic/ModList.cpp index 2a98eec7..c968f326 100644 --- a/logic/ModList.cpp +++ b/logic/ModList.cpp @@ -37,7 +37,7 @@ bool ModList::update() return false; QList<Mod> newMods; - + m_dir.refresh(); auto folderContents = m_dir.entryInfoList(); bool orderWasInvalid = false; @@ -206,7 +206,7 @@ bool ModList::deleteMod ( size_t index ) if(m.destroy()) { beginRemoveRows(QModelIndex(), index, index); - mods.erase(mods.begin() + index); + mods.removeAt(index); endRemoveRows(); saveListFile(); emit changed(); @@ -296,7 +296,7 @@ QStringList ModList::mimeTypes() const { QStringList types; types << "text/uri-list"; - types << "application/x-mcmod"; + types << "text/plain"; return types; } @@ -314,21 +314,25 @@ Qt::DropActions ModList::supportedDragActions() const QMimeData* ModList::mimeData ( const QModelIndexList& indexes ) const { + QMimeData * data = new QMimeData(); + if(indexes.size() == 0) - return nullptr; + return data; auto idx = indexes[0]; int row = idx.row(); if(row <0 || row >= mods.size()) - return nullptr; - - QMimeData * data = new QMimeData(); + return data; QStringList params; params << m_list_id << QString::number(row); - data->setData("application/x-mcmod", params.join('|').toLatin1()); + data->setText(params.join('|')); return data; } +bool ModList::removeRows ( int row, int count, const QModelIndex& parent ) +{ + return QAbstractItemModel::removeRows ( row, count, parent ); +} bool ModList::dropMimeData ( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent ) { @@ -337,7 +341,6 @@ bool ModList::dropMimeData ( const QMimeData* data, Qt::DropAction action, int r // check if the action is supported if (!data || !(action & supportedDropActions())) return false; - qDebug() << "row: " << row << " column: " << column; if(parent.isValid()) { row = parent.row(); @@ -350,10 +353,10 @@ bool ModList::dropMimeData ( const QMimeData* data, Qt::DropAction action, int r row = rowCount(); if (column == -1) column = 0; - qDebug() << "row: " << row << " column: " << column; + qDebug() << "Drop row: " << row << " column: " << column; // files dropped from outside? - if(data->hasFormat("text/uri-list") && data->hasUrls()) + if(data->hasUrls()) { auto urls = data->urls(); for(auto url: urls) @@ -367,14 +370,15 @@ bool ModList::dropMimeData ( const QMimeData* data, Qt::DropAction action, int r } return true; } - else if(data->hasFormat("application/x-mcmod")) + else if(data->hasText()) { - QString sourcestr = QString::fromLatin1(data->data("application/x-mcmod")); + QString sourcestr = data->text(); auto list = sourcestr.split('|'); if(list.size() != 2) return false; QString remoteId = list[0]; int remoteIndex = list[1].toInt(); + qDebug() << "move: " << sourcestr; // no moving of things between two lists if(remoteId != m_list_id) return false; diff --git a/logic/ModList.h b/logic/ModList.h index 0e172efd..04ddaa8e 100644 --- a/logic/ModList.h +++ b/logic/ModList.h @@ -66,6 +66,8 @@ public: virtual bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent); /// what drag actions do we support? virtual Qt::DropActions supportedDragActions() const; + + virtual bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()); /// what drop actions do we support? virtual Qt::DropActions supportedDropActions() const; diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp index b7f39e4a..b216c930 100644 --- a/logic/OneSixInstance.cpp +++ b/logic/OneSixInstance.cpp @@ -151,9 +151,9 @@ void OneSixInstance::cleanupAfterRun() dir.removeRecursively(); } -QSharedPointer< QDialog > OneSixInstance::createModEditDialog ( QWidget* parent ) +QDialog * OneSixInstance::createModEditDialog ( QWidget* parent ) { - return QSharedPointer< QDialog >(); + return nullptr; } diff --git a/logic/OneSixInstance.h b/logic/OneSixInstance.h index edd96eaa..18f03a92 100644 --- a/logic/OneSixInstance.h +++ b/logic/OneSixInstance.h @@ -23,7 +23,7 @@ public: virtual bool shouldUpdate() const; virtual void setShouldUpdate(bool val); - virtual QSharedPointer< QDialog > createModEditDialog ( QWidget* parent ); + virtual QDialog * createModEditDialog ( QWidget* parent ); /// reload the full version json file. return true on success! bool reloadFullVersion(); |