diff --git a/launcher/ui/MultiWorldListPage.cpp b/launcher/ui/MultiWorldListPage.cpp index 417a37eda..7064df357 100644 --- a/launcher/ui/MultiWorldListPage.cpp +++ b/launcher/ui/MultiWorldListPage.cpp @@ -111,6 +111,7 @@ MultiWorldListPage::MultiWorldListPage(MultiWorldList* worlds, QWidget* parent) head->setSectionResizeMode(4, QHeaderView::ResizeToContents); connect(ui->worldTreeView->selectionModel(), &QItemSelectionModel::currentChanged, this, &MultiWorldListPage::worldChanged); + connect(ui->worldTreeView, &QAbstractItemView::doubleClicked, this, &MultiWorldListPage::worldDoubleClicked); worldChanged(QModelIndex(), QModelIndex()); } @@ -382,6 +383,7 @@ void MultiWorldListPage::worldChanged([[maybe_unused]] const QModelIndex& curren ui->actionData_Packs->setEnabled(enable); ui->actionView_Folder->setEnabled(enable); ui->actionJoin->setEnabled(enable); + ui->actionInstance_Settings->setEnabled(enable); bool hasIcon = !index.data(MultiWorldList::IconFileRole).isNull(); ui->actionReset_Icon->setEnabled(enable && hasIcon); } @@ -458,14 +460,44 @@ void MultiWorldListPage::on_actionRename_triggered() } } +void MultiWorldListPage::on_actionInstance_Settings_triggered() +{ + QModelIndex index = getSelectedWorld(); + if (!index.isValid()) { + return; + } + auto worldVariant = m_worlds->data(index, MultiWorldList::ObjectRole); + auto *world = static_cast(worldVariant.value()); + + if (world->instance->canEdit()) { + APPLICATION->showInstanceWindow(world->instance); + } else { + CustomMessageBox::selectable(this, tr("Instance not editable"), + tr("This instance is not editable. It may be broken, invalid, or too old. Check logs for details."), + QMessageBox::Critical) + ->show(); + } +} + void MultiWorldListPage::on_actionRefresh_triggered() { m_worlds->update(); } +void MultiWorldListPage::worldDoubleClicked(const QModelIndex& index) +{ + auto proxy = (QSortFilterProxyModel*)ui->worldTreeView->model(); + join(proxy->mapToSource(index)); +} + void MultiWorldListPage::on_actionJoin_triggered() { QModelIndex index = getSelectedWorld(); + join(index); +} + +void MultiWorldListPage::join(QModelIndex index) +{ if (!index.isValid()) { return; } diff --git a/launcher/ui/MultiWorldListPage.h b/launcher/ui/MultiWorldListPage.h index 5531017a7..1440a9657 100644 --- a/launcher/ui/MultiWorldListPage.h +++ b/launcher/ui/MultiWorldListPage.h @@ -75,6 +75,7 @@ class MultiWorldListPage : public QMainWindow, public BasePage { bool isWorldSafe(QModelIndex index); bool worldSafetyNagQuestion(const QString& actionType); void mceditError(); + void join(QModelIndex index); private: Ui::MultiWorldListPage* ui; @@ -92,6 +93,7 @@ class MultiWorldListPage : public QMainWindow, public BasePage { void on_actionAdd_triggered(); void on_actionCopy_triggered(); void on_actionRename_triggered(); + void on_actionInstance_Settings_triggered(); void on_actionRefresh_triggered(); void on_actionView_Folder_triggered(); void on_actionData_Packs_triggered(); @@ -99,6 +101,7 @@ class MultiWorldListPage : public QMainWindow, public BasePage { void worldChanged(const QModelIndex& current, const QModelIndex& previous); void mceditState(LoggedProcess::State state); void on_actionJoin_triggered(); + void worldDoubleClicked(const QModelIndex& index); void ShowContextMenu(const QPoint& pos); }; diff --git a/launcher/ui/MultiWorldListPage.ui b/launcher/ui/MultiWorldListPage.ui index 4b4acfd70..aa89840aa 100644 --- a/launcher/ui/MultiWorldListPage.ui +++ b/launcher/ui/MultiWorldListPage.ui @@ -88,6 +88,7 @@ + @@ -157,6 +158,14 @@ Manage data packs inside the world. + + + View Instance + + + View the instance this world belongs to. + +