summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/LegacyModEditDialog.cpp92
-rw-r--r--gui/LegacyModEditDialog.h9
-rw-r--r--gui/LegacyModEditDialog.ui40
-rw-r--r--gui/ModListView.cpp32
-rw-r--r--gui/ModListView.h10
-rw-r--r--gui/mainwindow.cpp24
-rw-r--r--gui/mainwindow.ui3
7 files changed, 161 insertions, 49 deletions
diff --git a/gui/LegacyModEditDialog.cpp b/gui/LegacyModEditDialog.cpp
index a6becd7d..61e3872e 100644
--- a/gui/LegacyModEditDialog.cpp
+++ b/gui/LegacyModEditDialog.cpp
@@ -15,6 +15,9 @@
#include "LegacyModEditDialog.h"
#include "ui_LegacyModEditDialog.h"
+#include <logic/ModList.h>
+#include <pathutils.h>
+#include <QFileDialog>
LegacyModEditDialog::LegacyModEditDialog( LegacyInstance* inst, QWidget* parent ) :
m_inst(inst),
@@ -22,7 +25,22 @@ LegacyModEditDialog::LegacyModEditDialog( LegacyInstance* inst, QWidget* parent
ui(new Ui::LegacyModEditDialog)
{
ui->setupUi(this);
+ ensurePathExists(m_inst->coreModsDir());
+ ensurePathExists(m_inst->mlModsDir());
+ ensurePathExists(m_inst->jarModsDir());
+ m_mods = m_inst->loaderModList();
+ m_coremods = m_inst->coreModList();
+ m_jarmods = m_inst->jarModList();
+ /*
+ m_mods->startWatching();
+ m_coremods->startWatching();
+ m_jarmods->startWatching();
+ */
+
+ ui->jarModsTreeView->setModel(m_jarmods.data());
+ ui->coreModsTreeView->setModel(m_coremods.data());
+ ui->mlModTreeView->setModel(m_mods.data());
}
LegacyModEditDialog::~LegacyModEditDialog()
@@ -30,6 +48,80 @@ LegacyModEditDialog::~LegacyModEditDialog()
delete ui;
}
+void LegacyModEditDialog::on_addCoreBtn_clicked()
+{
+ QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Core Mods");
+ for(auto filename:fileNames)
+ {
+ m_coremods->installMod(QFileInfo(filename));
+ }
+}
+void LegacyModEditDialog::on_addForgeBtn_clicked()
+{
+
+}
+void LegacyModEditDialog::on_addJarBtn_clicked()
+{
+
+}
+void LegacyModEditDialog::on_addModBtn_clicked()
+{
+
+}
+void LegacyModEditDialog::on_addTexPackBtn_clicked()
+{
+
+}
+void LegacyModEditDialog::on_moveJarDownBtn_clicked()
+{
+
+}
+void LegacyModEditDialog::on_moveJarUpBtn_clicked()
+{
+
+}
+void LegacyModEditDialog::on_rmCoreBtn_clicked()
+{
+ auto sm = ui->coreModsTreeView->selectionModel();
+ auto selection = sm->selectedRows();
+ if(!selection.size())
+ return;
+ m_coremods->deleteMod(selection[0].row());
+}
+void LegacyModEditDialog::on_rmJarBtn_clicked()
+{
+ auto sm = ui->jarModsTreeView->selectionModel();
+ auto selection = sm->selectedRows();
+ if(!selection.size())
+ return;
+ m_jarmods->deleteMod(selection[0].row());
+}
+void LegacyModEditDialog::on_rmModBtn_clicked()
+{
+ auto sm = ui->mlModTreeView->selectionModel();
+ auto selection = sm->selectedRows();
+ if(!selection.size())
+ return;
+ m_mods->deleteMod(selection[0].row());
+}
+void LegacyModEditDialog::on_rmTexPackBtn_clicked()
+{
+
+}
+void LegacyModEditDialog::on_viewCoreBtn_clicked()
+{
+ openDirInDefaultProgram(m_inst->coreModsDir(), true);
+}
+void LegacyModEditDialog::on_viewModBtn_clicked()
+{
+ openDirInDefaultProgram(m_inst->mlModsDir(), true);
+}
+void LegacyModEditDialog::on_viewTexPackBtn_clicked()
+{
+ //openDirInDefaultProgram(m_inst->mlModsDir(), true);
+}
+
+
void LegacyModEditDialog::on_buttonBox_rejected()
{
close();
diff --git a/gui/LegacyModEditDialog.h b/gui/LegacyModEditDialog.h
index 3af6c8d7..0654300f 100644
--- a/gui/LegacyModEditDialog.h
+++ b/gui/LegacyModEditDialog.h
@@ -31,9 +31,9 @@ public:
~LegacyModEditDialog();
private slots:
- /* Mapped for implementation
+
void on_addJarBtn_clicked();
- void on_rmJarBtn_clicked();
+ void on_rmJarBtn_clicked();
void on_addForgeBtn_clicked();
void on_moveJarUpBtn_clicked();
void on_moveJarDownBtn_clicked();
@@ -49,11 +49,14 @@ private slots:
void on_addTexPackBtn_clicked();
void on_rmTexPackBtn_clicked();
void on_viewTexPackBtn_clicked();
- */
// Questionable: SettingsDialog doesn't need this for some reason?
void on_buttonBox_rejected();
private:
Ui::LegacyModEditDialog *ui;
+ QSharedPointer<ModList> m_mods;
+ QSharedPointer<ModList> m_coremods;
+ QSharedPointer<ModList> m_jarmods;
+ QSharedPointer<ModList> m_texturepacks;
LegacyInstance * m_inst;
};
diff --git a/gui/LegacyModEditDialog.ui b/gui/LegacyModEditDialog.ui
index d55c3e1c..c219e7c2 100644
--- a/gui/LegacyModEditDialog.ui
+++ b/gui/LegacyModEditDialog.ui
@@ -16,9 +16,6 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
- <property name="acceptDrops">
- <bool>false</bool>
- </property>
<property name="currentIndex">
<number>0</number>
</property>
@@ -28,12 +25,12 @@
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
- <widget class="QListView" name="jarModsListView">
- <property name="acceptDrops">
- <bool>true</bool>
+ <widget class="ModListView" name="jarModsTreeView">
+ <property name="verticalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOn</enum>
</property>
- <property name="dragDropMode">
- <enum>QAbstractItemView::DropOnly</enum>
+ <property name="horizontalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
</property>
</widget>
</item>
@@ -55,6 +52,9 @@
</item>
<item>
<widget class="QPushButton" name="addForgeBtn">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="text">
<string>MCForge</string>
</property>
@@ -97,10 +97,7 @@
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
- <widget class="QListView" name="coreModsListView">
- <property name="acceptDrops">
- <bool>true</bool>
- </property>
+ <widget class="ModListView" name="coreModsTreeView">
<property name="dragDropMode">
<enum>QAbstractItemView::DropOnly</enum>
</property>
@@ -152,7 +149,7 @@
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
- <widget class="QListView" name="mlModListView">
+ <widget class="ModListView" name="mlModTreeView">
<property name="acceptDrops">
<bool>true</bool>
</property>
@@ -210,19 +207,13 @@
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
- <widget class="QListView" name="texPackListView">
+ <widget class="ModListView" name="texPackTreeView">
<property name="acceptDrops">
<bool>true</bool>
</property>
- <property name="dragEnabled">
- <bool>false</bool>
- </property>
<property name="dragDropMode">
<enum>QAbstractItemView::DropOnly</enum>
</property>
- <property name="defaultDropAction">
- <enum>Qt::IgnoreAction</enum>
- </property>
</widget>
</item>
<item>
@@ -270,12 +261,19 @@
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
- <set>QDialogButtonBox::Close</set>
+ <set>QDialogButtonBox::Close|QDialogButtonBox::Reset</set>
</property>
</widget>
</item>
</layout>
</widget>
+ <customwidgets>
+ <customwidget>
+ <class>ModListView</class>
+ <extends>QTreeView</extends>
+ <header>gui/ModListView.h</header>
+ </customwidget>
+ </customwidgets>
<resources/>
<connections/>
</ui>
diff --git a/gui/ModListView.cpp b/gui/ModListView.cpp
new file mode 100644
index 00000000..a9898851
--- /dev/null
+++ b/gui/ModListView.cpp
@@ -0,0 +1,32 @@
+#include "ModListView.h"
+#include <QHeaderView>
+#include <QMouseEvent>
+
+ModListView::ModListView ( QWidget* parent )
+ :QTreeView ( parent )
+{
+ setAllColumnsShowFocus ( true );
+ setExpandsOnDoubleClick ( false );
+ setRootIsDecorated ( false );
+ setSortingEnabled ( false );
+ setAlternatingRowColors ( true );
+ setSelectionMode ( QAbstractItemView::SingleSelection );
+ setHeaderHidden ( false );
+ setSelectionBehavior(QAbstractItemView::SelectRows);
+ setVerticalScrollBarPolicy ( Qt::ScrollBarAlwaysOn );
+ setHorizontalScrollBarPolicy ( Qt::ScrollBarAsNeeded );
+ setDropIndicatorShown(true);
+ setDragEnabled(true);
+ setDragDropMode(QAbstractItemView::DragDrop);
+ viewport()->setAcceptDrops(true);
+}
+
+void ModListView::setModel ( QAbstractItemModel* model )
+{
+ QTreeView::setModel ( model );
+ auto head = header();
+ head->setStretchLastSection(false);
+ head->setSectionResizeMode(0, QHeaderView::Stretch);
+ head->setSectionResizeMode(1, QHeaderView::ResizeToContents);
+ dropIndicatorPosition();
+}
diff --git a/gui/ModListView.h b/gui/ModListView.h
new file mode 100644
index 00000000..1cbf86b7
--- /dev/null
+++ b/gui/ModListView.h
@@ -0,0 +1,10 @@
+#pragma once
+#include <QTreeView>
+
+class ModListView: public QTreeView
+{
+ Q_OBJECT
+public:
+ explicit ModListView ( QWidget* parent = 0 );
+ virtual void setModel ( QAbstractItemModel* model );
+}; \ No newline at end of file
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index 5087b38f..ba7e135c 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -64,11 +64,6 @@
#include "instancedelegate.h"
#include "IconPickerDialog.h"
-// Opens the given file in the default application.
-// TODO: Move this somewhere.
-void openFileInDefaultProgram ( QString filename );
-void openDirInDefaultProgram ( QString dirpath, bool ensureExists = false );
-
MainWindow::MainWindow ( QWidget *parent ) :
QMainWindow ( parent ),
ui ( new Ui::MainWindow ),
@@ -376,7 +371,8 @@ void MainWindow::on_actionEditInstMods_triggered()
if (inst)
{
auto dialog = inst->createModEditDialog(this);
- dialog->exec();
+ if(dialog)
+ dialog->exec();
}
}
@@ -537,22 +533,6 @@ void MainWindow::openWebPage ( QUrl url )
browser->exec();
}
-void openDirInDefaultProgram ( QString path, bool ensureExists )
-{
- QDir parentPath;
- QDir dir( path );
- if(!dir.exists())
- {
- parentPath.mkpath(dir.absolutePath());
- }
- QDesktopServices::openUrl ( "file:///" + dir.absolutePath() );
-}
-
-void openFileInDefaultProgram ( QString filename )
-{
- QDesktopServices::openUrl ( "file:///" + QFileInfo ( filename ).absolutePath() );
-}
-
void MainWindow::on_actionChangeInstMCVersion_triggered()
{
if (view->selectionModel()->selectedIndexes().count() < 1)
diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui
index ae34bf51..893062a5 100644
--- a/gui/mainwindow.ui
+++ b/gui/mainwindow.ui
@@ -347,9 +347,6 @@
</property>
</action>
<action name="actionEditInstMods">
- <property name="enabled">
- <bool>false</bool>
- </property>
<property name="text">
<string>Edit Mods</string>
</property>