summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gui/instancemodel.cpp13
-rw-r--r--gui/instancemodel.h1
-rw-r--r--gui/mainwindow.cpp33
-rw-r--r--gui/mainwindow.h7
-rw-r--r--libmultimc/include/instance.h29
-rw-r--r--libmultimc/include/instancelist.h3
-rw-r--r--libmultimc/src/instancelist.cpp13
7 files changed, 85 insertions, 14 deletions
diff --git a/gui/instancemodel.cpp b/gui/instancemodel.cpp
index 0051602b..3c96c8f0 100644
--- a/gui/instancemodel.cpp
+++ b/gui/instancemodel.cpp
@@ -5,7 +5,6 @@
InstanceModel::InstanceModel ( const InstanceList& instances, QObject *parent )
: QAbstractListModel ( parent ), m_instances ( &instances )
{
- cachedIcon = QIcon(":/icons/multimc/scalable/apps/multimc.svg");
currentInstancesNumber = m_instances->count();
connect(m_instances,SIGNAL(instanceAdded(int)),this,SLOT(onInstanceAdded(int)));
connect(m_instances,SIGNAL(instanceChanged(int)),this,SLOT(onInstanceChanged(int)));
@@ -19,10 +18,10 @@ void InstanceModel::onInstanceAdded ( int index )
endInsertRows();
}
-// TODO: this doesn't trigger yet
void InstanceModel::onInstanceChanged ( int index )
{
-
+ QModelIndex mx = InstanceModel::index(index);
+ dataChanged(mx,mx);
}
void InstanceModel::onInvalidated()
@@ -71,8 +70,12 @@ QVariant InstanceModel::data ( const QModelIndex& index, int role ) const
}
case Qt::DecorationRole:
{
- // FIXME: replace with an icon cache
- return cachedIcon;
+ // FIXME: replace with an icon cache/renderer
+ QString path = ":/icons/instances/";
+ path += pdata->iconKey();
+ QIcon icon(path);
+ return icon;
+ //else return QIcon(":/icons/multimc/scalable/apps/multimc.svg");
}
// for now.
case KCategorizedSortFilterProxyModel::CategorySortRole:
diff --git a/gui/instancemodel.h b/gui/instancemodel.h
index de43b7b8..208ee68e 100644
--- a/gui/instancemodel.h
+++ b/gui/instancemodel.h
@@ -29,7 +29,6 @@ public slots:
private:
const InstanceList* m_instances;
- QIcon cachedIcon;
int currentInstancesNumber;
};
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index a96d80a7..78f58713 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -116,6 +116,11 @@ MainWindow::MainWindow ( QWidget *parent ) :
// Load the instances.
instList.loadList();
+ // just a test
+ /*
+ instList.at(0)->setGroup("TEST GROUP");
+ instList.at(0)->setName("TEST ITEM");
+ */
}
MainWindow::~MainWindow()
@@ -140,6 +145,18 @@ void MainWindow::on_actionAddInstance_triggered()
newInstDlg->exec();
}
+void MainWindow::on_actionChangeInstGroup_triggered()
+{
+ Instance* inst = selectedInstance();
+ if(inst)
+ {
+ QString name ( inst->group() );
+ name = QInputDialog::getText ( this, tr ( "Group name" ), tr ( "Enter a new group name." ), QLineEdit::Normal, name );
+ inst->setGroup(name);
+ }
+}
+
+
void MainWindow::on_actionViewInstanceFolder_triggered()
{
openInDefaultProgram ( globalSettings->get ( "InstanceDir" ).toString() );
@@ -210,8 +227,7 @@ void MainWindow::on_instanceView_customContextMenuRequested ( const QPoint &pos
instContextMenu->exec ( view->mapToGlobal ( pos ) );
}
-
-void MainWindow::on_actionLaunchInstance_triggered()
+Instance* MainWindow::selectedInstance()
{
QAbstractItemView * iv = view;
auto smodel = iv->selectionModel();
@@ -224,7 +240,18 @@ void MainWindow::on_actionLaunchInstance_triggered()
if(mindex.isValid())
{
- Instance * inst = (Instance *) mindex.data(InstanceModel::InstancePointerRole).value<void *>();
+ return (Instance *) mindex.data(InstanceModel::InstancePointerRole).value<void *>();
+ }
+ else
+ return nullptr;
+}
+
+
+void MainWindow::on_actionLaunchInstance_triggered()
+{
+ Instance* inst = selectedInstance();
+ if(inst)
+ {
doLogin(inst->id());
}
}
diff --git a/gui/mainwindow.h b/gui/mainwindow.h
index c2dedf74..5d990639 100644
--- a/gui/mainwindow.h
+++ b/gui/mainwindow.h
@@ -44,14 +44,19 @@ public:
// Browser Dialog
void openWebPage(QUrl url);
+
+private:
+ Instance *selectedInstance();
private slots:
void on_actionAbout_triggered();
void on_actionAddInstance_triggered();
- void on_actionViewInstanceFolder_triggered();
+ void on_actionChangeInstGroup_triggered();
+ void on_actionViewInstanceFolder_triggered();
+
void on_actionRefresh_triggered();
void on_actionViewCentralModsFolder_triggered();
diff --git a/libmultimc/include/instance.h b/libmultimc/include/instance.h
index 9334dff8..258a0dab 100644
--- a/libmultimc/include/instance.h
+++ b/libmultimc/include/instance.h
@@ -176,16 +176,28 @@ public:
//// General Info ////
virtual QString name() { return settings().get("name").toString(); }
- virtual void setName(QString val) { settings().set("name", val); }
+ virtual void setName(QString val)
+ {
+ settings().set("name", val);
+ emit propertiesChanged(this);
+ }
virtual QString iconKey() const { return settings().get("iconKey").toString(); }
- virtual void setIconKey(QString val) { settings().set("iconKey", val); }
+ virtual void setIconKey(QString val)
+ {
+ settings().set("iconKey", val);
+ emit propertiesChanged(this);
+ }
virtual QString notes() const { return settings().get("notes").toString(); }
virtual void setNotes(QString val) { settings().set("notes", val); }
virtual QString group() const { return m_group; }
- virtual void setGroup(QString val) { m_group = val; }
+ virtual void setGroup(QString val)
+ {
+ m_group = val;
+ emit propertiesChanged(this);
+ }
virtual bool shouldRebuild() const { return settings().get("NeedsRebuild").toBool(); }
virtual void setShouldRebuild(bool val) { settings().set("NeedsRebuild", val); }
@@ -208,7 +220,10 @@ public:
virtual qint64 lastLaunch() { return settings().get("lastLaunchTime").value<qint64>(); }
virtual void setLastLaunch(qint64 val = QDateTime::currentMSecsSinceEpoch())
- { settings().set("lastLaunchTime", val); }
+ {
+ settings().set("lastLaunchTime", val);
+ emit propertiesChanged(this);
+ }
////// Directories //////
@@ -283,6 +298,12 @@ public:
*/
virtual SettingsObject &settings() const;
+signals:
+ /*!
+ * \brief Signal emitted when properties relevant to the instance view change
+ */
+ void propertiesChanged(Instance * inst);
+
private:
QString m_rootDir;
QString m_group;
diff --git a/libmultimc/include/instancelist.h b/libmultimc/include/instancelist.h
index 3eef8bdc..a0d8788a 100644
--- a/libmultimc/include/instancelist.h
+++ b/libmultimc/include/instancelist.h
@@ -78,6 +78,9 @@ signals:
void instanceChanged(int index);
void invalidated();
+private slots:
+ void propertiesChanged(Instance * inst);
+
protected:
QString m_instDir;
QList< InstancePtr > m_instances;
diff --git a/libmultimc/src/instancelist.cpp b/libmultimc/src/instancelist.cpp
index a835fcfe..f9c525d0 100644
--- a/libmultimc/src/instancelist.cpp
+++ b/libmultimc/src/instancelist.cpp
@@ -185,6 +185,7 @@ InstanceList::InstListError InstanceList::loadList()
qDebug(QString("Loaded instance %1").arg(inst->name()).toUtf8());
inst->setParent(this);
m_instances.append(inst);
+ connect(instPtr, SIGNAL(propertiesChanged(Instance*)),this, SLOT(propertiesChanged(Instance*)));
}
}
}
@@ -221,4 +222,16 @@ InstancePtr InstanceList::getInstanceById(QString instId)
return InstancePtr();
else
return iter.peekPrevious();
+}
+
+void InstanceList::propertiesChanged(Instance * inst)
+{
+ for(int i = 0; i < m_instances.count(); i++)
+ {
+ if(inst == m_instances[i].data())
+ {
+ emit instanceChanged(i);
+ break;
+ }
+ }
} \ No newline at end of file