mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
select instance after joining world from all worlds screen
This commit is contained in:
parent
2e656c247b
commit
1c1717a8ea
6 changed files with 33 additions and 5 deletions
|
|
@ -335,6 +335,8 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||
[](const QString& groupName) -> bool { return APPLICATION->instances()->isGroupCollapsed(groupName); });
|
||||
connect(view, &InstanceView::groupStateChanged, APPLICATION->instances(), &InstanceList::on_GroupStateChanged);
|
||||
ui->horizontalLayout->addWidget(view);
|
||||
|
||||
connect(this, &MainWindow::selectInstance, view, &InstanceView::selectInstance);
|
||||
}
|
||||
// Create the all worlds widget
|
||||
{
|
||||
|
|
@ -866,10 +868,11 @@ void MainWindow::onAllWorldsToggled(bool toggled)
|
|||
toggleAllWorldsScreen(toggled);
|
||||
}
|
||||
|
||||
void MainWindow::worldJoined()
|
||||
void MainWindow::worldJoined(BaseInstance* instance)
|
||||
{
|
||||
ui->actionAllWorlds->setChecked(false);
|
||||
toggleAllWorldsScreen(false);
|
||||
emit selectInstance(instance);
|
||||
}
|
||||
|
||||
void MainWindow::toggleAllWorldsScreen(bool toggled)
|
||||
|
|
@ -877,7 +880,7 @@ void MainWindow::toggleAllWorldsScreen(bool toggled)
|
|||
if (toggled) {
|
||||
QList<BaseInstance*> allInstances = APPLICATION->instances()->getAllInstances();
|
||||
|
||||
allWorlds = new MultiWorldList(allInstances);
|
||||
allWorlds = new MultiWorldList(allInstances); //make this be unique pointer or whatever instead of awkward replace and delete iy
|
||||
allWorlds->update();
|
||||
auto newAllWorldsPage = new MultiWorldListPage(allWorlds);
|
||||
ui->horizontalLayout->replaceWidget(allWorldsPage, newAllWorldsPage);
|
||||
|
|
@ -888,6 +891,7 @@ void MainWindow::toggleAllWorldsScreen(bool toggled)
|
|||
m_oldInstanceToolbarSetting = ui->instanceToolBar->isVisible();
|
||||
ui->instanceToolBar->setVisible(false);
|
||||
allWorldsPage->setVisible(true);
|
||||
statusBar()->setVisible(false);
|
||||
|
||||
allWorlds->startWatching();
|
||||
|
||||
|
|
@ -896,6 +900,7 @@ void MainWindow::toggleAllWorldsScreen(bool toggled)
|
|||
allWorldsPage->setVisible(false);
|
||||
view->setVisible(true);
|
||||
ui->instanceToolBar->setVisible(m_oldInstanceToolbarSetting);
|
||||
statusBar()->setVisible(APPLICATION->settings()->get("StatusBarVisible").toBool());
|
||||
|
||||
allWorlds->stopWatching();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,6 +86,8 @@ class MainWindow : public QMainWindow {
|
|||
signals:
|
||||
void isClosing();
|
||||
|
||||
void selectInstance(BaseInstance* instance);
|
||||
|
||||
protected:
|
||||
QMenu* createPopupMenu() override;
|
||||
|
||||
|
|
@ -175,7 +177,7 @@ class MainWindow : public QMainWindow {
|
|||
|
||||
void taskEnd();
|
||||
|
||||
void worldJoined();
|
||||
void worldJoined(BaseInstance* instance);
|
||||
|
||||
/**
|
||||
* called when an icon is changed in the icon model.
|
||||
|
|
|
|||
|
|
@ -587,7 +587,7 @@ void MultiWorldListPage::join(QModelIndex index)
|
|||
auto worldVariant = m_worlds->data(index, MultiWorldList::ObjectRole);
|
||||
auto *world = static_cast<InstanceWorld*>(worldVariant.value<void*>());
|
||||
APPLICATION->launch(world->instance, LaunchMode::Normal, std::make_shared<MinecraftTarget>(MinecraftTarget::parse(world->world.folderName(), true)));
|
||||
emit worldJoined();
|
||||
emit worldJoined(world->instance);
|
||||
}
|
||||
|
||||
#include "MultiWorldListPage.moc"
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class MultiWorldListPage : public QMainWindow, public BasePage {
|
|||
virtual void closedImpl() override;
|
||||
|
||||
signals:
|
||||
void worldJoined();
|
||||
void worldJoined(BaseInstance* instance);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject* obj, QEvent* ev) override;
|
||||
|
|
|
|||
|
|
@ -207,6 +207,24 @@ void InstanceView::updateGeometries()
|
|||
viewport()->update();
|
||||
}
|
||||
|
||||
void InstanceView::selectInstance(BaseInstance* instance)
|
||||
{
|
||||
QModelIndex index;
|
||||
|
||||
for (int row = 0; row < model()->rowCount(); row++) {
|
||||
for (int j = 0; j < model()->columnCount(); j++) {
|
||||
auto testIndex = model()->index(row, j);
|
||||
if (testIndex.data(InstanceList::InstanceIDRole).toString() == instance->id()) {
|
||||
index = testIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (index.isValid()) {
|
||||
selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect);
|
||||
}
|
||||
}
|
||||
|
||||
bool InstanceView::isIndexHidden(const QModelIndex& index) const
|
||||
{
|
||||
VisualGroup* cat = category(index);
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@
|
|||
#include <QListView>
|
||||
#include <QScrollBar>
|
||||
#include <functional>
|
||||
|
||||
#include "BaseInstance.h"
|
||||
#include "VisualGroup.h"
|
||||
#include "ui/themes/CatPainter.h"
|
||||
|
||||
|
|
@ -82,6 +84,7 @@ class InstanceView : public QAbstractItemView {
|
|||
|
||||
public slots:
|
||||
virtual void updateGeometries() override;
|
||||
void selectInstance(BaseInstance* instance);
|
||||
|
||||
protected slots:
|
||||
virtual void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QList<int>& roles) override;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue