diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/instancemodel.cpp | 13 | ||||
-rw-r--r-- | gui/instancemodel.h | 1 | ||||
-rw-r--r-- | gui/mainwindow.cpp | 33 | ||||
-rw-r--r-- | gui/mainwindow.h | 7 |
4 files changed, 44 insertions, 10 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(); |