mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
view instance button and double click to join world on all worlds screen
This commit is contained in:
parent
551f704c0f
commit
547d870930
3 changed files with 44 additions and 0 deletions
|
|
@ -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<InstanceWorld*>(worldVariant.value<void*>());
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@
|
|||
<addaction name="actionRename"/>
|
||||
<addaction name="actionCopy"/>
|
||||
<addaction name="actionRemove"/>
|
||||
<addaction name="actionInstance_Settings"/>
|
||||
<addaction name="actionMCEdit"/>
|
||||
<addaction name="actionData_Packs"/>
|
||||
<addaction name="actionReset_Icon"/>
|
||||
|
|
@ -157,6 +158,14 @@
|
|||
<string>Manage data packs inside the world.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionInstance_Settings">
|
||||
<property name="text">
|
||||
<string>View Instance</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>View the instance this world belongs to.</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue