diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/LegacyModEditDialog.cpp | 35 | ||||
-rw-r--r-- | gui/LegacyModEditDialog.h | 39 | ||||
-rw-r--r-- | gui/LegacyModEditDialog.ui | 21 | ||||
-rw-r--r-- | gui/ModEditDialogCommon.cpp | 37 | ||||
-rw-r--r-- | gui/ModEditDialogCommon.h | 5 | ||||
-rw-r--r-- | gui/OneSixModEditDialog.cpp | 11 | ||||
-rw-r--r-- | gui/OneSixModEditDialog.h | 1 | ||||
-rw-r--r-- | gui/OneSixModEditDialog.ui | 7 |
8 files changed, 132 insertions, 24 deletions
diff --git a/gui/LegacyModEditDialog.cpp b/gui/LegacyModEditDialog.cpp index 45f041f3..87647e0f 100644 --- a/gui/LegacyModEditDialog.cpp +++ b/gui/LegacyModEditDialog.cpp @@ -24,6 +24,7 @@ #include <pathutils.h> #include <QFileDialog> +//#include <QMessageBox> #include <QDebug> #include <QEvent> #include <QKeyEvent> @@ -342,4 +343,36 @@ void LegacyModEditDialog::on_viewTexPackBtn_clicked() void LegacyModEditDialog::on_buttonBox_rejected() { close(); -}
\ No newline at end of file +} + +//FIXME: too much copypasta makes peterix a sad hacker. BUT IT'S SO DELICIOUS! + +void LegacyModEditDialog::on_coreWebsite_clicked() +{ + int first, last; + auto list = ui->coreModsTreeView->selectionModel()->selectedRows(); + + if (!lastfirst(list, first, last)) + return; + showWebsiteForMod(this, m_coremods->operator[](first)); +} + +void LegacyModEditDialog::on_jarWebsite_clicked() +{ + int first, last; + auto list = ui->jarModsTreeView->selectionModel()->selectedRows(); + + if (!lastfirst(list, first, last)) + return; + showWebsiteForMod(this, m_jarmods->operator[](first)); +} + +void LegacyModEditDialog::on_loaderWebsite_clicked() +{ + int first, last; + auto list = ui->loaderModTreeView->selectionModel()->selectedRows(); + + if (!lastfirst(list, first, last)) + return; + showWebsiteForMod(this, m_mods->operator[](first)); +} diff --git a/gui/LegacyModEditDialog.h b/gui/LegacyModEditDialog.h index 5f6973d3..f12d9a7b 100644 --- a/gui/LegacyModEditDialog.h +++ b/gui/LegacyModEditDialog.h @@ -3,7 +3,7 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software @@ -19,51 +19,60 @@ #include "logic/LegacyInstance.h" #include <logic/net/DownloadJob.h> -namespace Ui { +namespace Ui +{ class LegacyModEditDialog; } class LegacyModEditDialog : public QDialog { Q_OBJECT - + public: - explicit LegacyModEditDialog(LegacyInstance* inst, QWidget *parent = 0); + explicit LegacyModEditDialog(LegacyInstance *inst, QWidget *parent = 0); ~LegacyModEditDialog(); - -private slots: - + +private +slots: + void on_addJarBtn_clicked(); void on_rmJarBtn_clicked(); void on_addForgeBtn_clicked(); void on_moveJarUpBtn_clicked(); void on_moveJarDownBtn_clicked(); - + void on_addCoreBtn_clicked(); void on_rmCoreBtn_clicked(); void on_viewCoreBtn_clicked(); - + void on_addModBtn_clicked(); void on_rmModBtn_clicked(); void on_viewModBtn_clicked(); - + void on_addTexPackBtn_clicked(); void on_rmTexPackBtn_clicked(); void on_viewTexPackBtn_clicked(); + + void on_jarWebsite_clicked(); + void on_loaderWebsite_clicked(); + void on_coreWebsite_clicked(); + // Questionable: SettingsDialog doesn't need this for some reason? void on_buttonBox_rejected(); + protected: bool eventFilter(QObject *obj, QEvent *ev); - bool jarListFilter( QKeyEvent* ev ); - bool coreListFilter( QKeyEvent* ev ); - bool loaderListFilter( QKeyEvent* ev ); - bool texturePackListFilter( QKeyEvent* ev ); + bool jarListFilter(QKeyEvent *ev); + bool coreListFilter(QKeyEvent *ev); + bool loaderListFilter(QKeyEvent *ev); + bool texturePackListFilter(QKeyEvent *ev); + private: Ui::LegacyModEditDialog *ui; std::shared_ptr<ModList> m_mods; std::shared_ptr<ModList> m_coremods; std::shared_ptr<ModList> m_jarmods; std::shared_ptr<ModList> m_texturepacks; - LegacyInstance * m_inst; + LegacyInstance *m_inst; DownloadJobPtr forgeJob; }; diff --git a/gui/LegacyModEditDialog.ui b/gui/LegacyModEditDialog.ui index 73b767dc..6a4b6d1e 100644 --- a/gui/LegacyModEditDialog.ui +++ b/gui/LegacyModEditDialog.ui @@ -58,6 +58,13 @@ </widget> </item> <item> + <widget class="QPushButton" name="jarWebsite"> + <property name="text"> + <string>Website</string> + </property> + </widget> + </item> + <item> <spacer name="jarModsButtonSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -117,6 +124,13 @@ </widget> </item> <item> + <widget class="QPushButton" name="coreWebsite"> + <property name="text"> + <string>Website</string> + </property> + </widget> + </item> + <item> <spacer name="coreModsButtonSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -172,6 +186,13 @@ </widget> </item> <item> + <widget class="QPushButton" name="loaderWebsite"> + <property name="text"> + <string>Website</string> + </property> + </widget> + </item> + <item> <spacer name="mlModsButtonSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> diff --git a/gui/ModEditDialogCommon.cpp b/gui/ModEditDialogCommon.cpp index 5da0a039..692ac0c4 100644 --- a/gui/ModEditDialogCommon.cpp +++ b/gui/ModEditDialogCommon.cpp @@ -1,17 +1,40 @@ #include "ModEditDialogCommon.h" - -bool lastfirst (QModelIndexList & list, int & first, int & last) +#include <QDesktopServices> +#include <QMessageBox> +#include <QString> +#include <QUrl> +bool lastfirst(QModelIndexList &list, int &first, int &last) { - if(!list.size()) + if (!list.size()) return false; first = last = list[0].row(); - for(auto item: list) + for (auto item : list) { int row = item.row(); - if(row < first) + if (row < first) first = row; - if(row > last) + if (row > last) last = row; } return true; -}
\ No newline at end of file +} + +void showWebsiteForMod(QWidget *parentDlg, Mod &m) +{ + QString url = m.homeurl(); + if (url.size()) + { + // catch the cases where the protocol is missing + if(!url.startsWith("http")) + { + url = "http://" + url; + } + QDesktopServices::openUrl(url); + } + else + { + QMessageBox::warning( + parentDlg, parentDlg->tr("How sad!"), + parentDlg->tr("The mod author didn't provide a website link for this mod.")); + } +} diff --git a/gui/ModEditDialogCommon.h b/gui/ModEditDialogCommon.h index a27a8a82..bc8e223f 100644 --- a/gui/ModEditDialogCommon.h +++ b/gui/ModEditDialogCommon.h @@ -1,4 +1,7 @@ #pragma once #include <QAbstractItemModel> +#include <logic/Mod.h> -bool lastfirst (QModelIndexList & list, int & first, int & last);
\ No newline at end of file +bool lastfirst (QModelIndexList & list, int & first, int & last); + +void showWebsiteForMod(QWidget * parentDlg, Mod& m);
\ No newline at end of file diff --git a/gui/OneSixModEditDialog.cpp b/gui/OneSixModEditDialog.cpp index 24f01c53..788a61d0 100644 --- a/gui/OneSixModEditDialog.cpp +++ b/gui/OneSixModEditDialog.cpp @@ -30,6 +30,7 @@ #include <QDebug> #include <QEvent> #include <QKeyEvent> +#include <QDesktopServices> OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent) : m_inst(inst), QDialog(parent), ui(new Ui::OneSixModEditDialog) @@ -296,3 +297,13 @@ void OneSixModEditDialog::on_viewResPackBtn_clicked() { openDirInDefaultProgram(m_inst->resourcePacksDir(), true); } + +void OneSixModEditDialog::on_loaderWebsite_clicked() +{ + int first, last; + auto list = ui->loaderModTreeView->selectionModel()->selectedRows(); + + if (!lastfirst(list, first, last)) + return; + showWebsiteForMod(this, m_mods->operator[](first)); +} diff --git a/gui/OneSixModEditDialog.h b/gui/OneSixModEditDialog.h index 5c65fea3..ce4da4fe 100644 --- a/gui/OneSixModEditDialog.h +++ b/gui/OneSixModEditDialog.h @@ -44,6 +44,7 @@ private slots: void on_forgeBtn_clicked(); void on_customizeBtn_clicked(); void on_revertBtn_clicked(); + void on_loaderWebsite_clicked(); void updateVersionControls(); void disableVersionControls(); protected: diff --git a/gui/OneSixModEditDialog.ui b/gui/OneSixModEditDialog.ui index 527899ca..b97d4304 100644 --- a/gui/OneSixModEditDialog.ui +++ b/gui/OneSixModEditDialog.ui @@ -185,6 +185,13 @@ </widget> </item> <item> + <widget class="QPushButton" name="loaderWebsite"> + <property name="text"> + <string>Website</string> + </property> + </widget> + </item> + <item> <spacer name="verticalSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> |