From b0a600b7201335b88acbd5d8a6f3cdbc87b24a27 Mon Sep 17 00:00:00 2001 From: Ice Yeti <101294194+IceYetiWins@users.noreply.github.com> Date: Sat, 6 Jun 2026 11:12:32 -0400 Subject: [PATCH] joining world switches to main screen + fix issues with instance toolbar visibility --- launcher/ui/MainWindow.cpp | 22 +++++++++++++++++++--- launcher/ui/MainWindow.h | 4 ++++ launcher/ui/MultiWorldListPage.cpp | 1 + launcher/ui/MultiWorldListPage.h | 3 +++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index c9ec6bd23..e7af59a6b 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -192,8 +192,6 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi ui->instanceToolBar->addContextMenuAction(ui->instanceToolBar->toggleViewAction()); ui->instanceToolBar->addContextMenuAction(ui->actionToggleStatusBar); ui->instanceToolBar->addContextMenuAction(ui->actionLockToolbars); - - m_oldInstanceToolbarSetting = ui->instanceToolBar->isVisible(); } // set the menu for the folders help, accounts, and export tool buttons @@ -356,6 +354,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi ui->instanceToolBar->setVisibilityState(QByteArray::fromBase64(instanceToolbarSetting->get().toString().toUtf8())); //fix instance toolbar checkbox independent of all worlds screen showing iy connect(ui->actionAllWorlds, &QAction::toggled, this, &MainWindow::onAllWorldsToggled); + connect(allWorldsPage, &MultiWorldListPage::worldJoined, this, &MainWindow::worldJoined); } // The cat background @@ -867,6 +866,17 @@ QString intListToString(const QList& list) } void MainWindow::onAllWorldsToggled(bool toggled) +{ + toggleAllWorldsScreen(toggled); +} + +void MainWindow::worldJoined() +{ + ui->actionAllWorlds->setChecked(false); + toggleAllWorldsScreen(false); +} + +void MainWindow::toggleAllWorldsScreen(bool toggled) { if (toggled) { QList allInstances = APPLICATION->instances()->getAllInstances(); @@ -883,9 +893,11 @@ void MainWindow::onAllWorldsToggled(bool toggled) allWorldsPage = newAllWorldsPage; view->setVisible(false); - m_oldInstanceToolbarSetting = ui->instanceToolBar->isVisible(); //won't work if starts on all worlds screen iy + m_oldInstanceToolbarSetting = ui->instanceToolBar->isVisible(); ui->instanceToolBar->setVisible(false); allWorldsPage->setVisible(true); + + connect(allWorldsPage, &MultiWorldListPage::worldJoined, this, &MainWindow::worldJoined); } else { allWorldsPage->setVisible(false); view->setVisible(true); @@ -1631,6 +1643,10 @@ void MainWindow::on_actionViewSelectedInstFolder_triggered() void MainWindow::closeEvent(QCloseEvent* event) { + if (view->isVisible()) { + m_oldInstanceToolbarSetting = ui->instanceToolBar->isVisible(); + } + toggleAllWorldsScreen(false); // Save the window state and geometry. APPLICATION->settings()->set("MainWindowState", QString::fromUtf8(saveState().toBase64())); APPLICATION->settings()->set("MainWindowGeometry", QString::fromUtf8(saveGeometry().toBase64())); diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h index 3e80da15b..ee4a53a69 100644 --- a/launcher/ui/MainWindow.h +++ b/launcher/ui/MainWindow.h @@ -175,6 +175,8 @@ class MainWindow : public QMainWindow { void taskEnd(); + void worldJoined(); + /** * called when an icon is changed in the icon model. */ @@ -236,6 +238,8 @@ class MainWindow : public QMainWindow { void runModalTask(Task* task); void instanceFromInstanceTask(InstanceTask* task); + void toggleAllWorldsScreen(bool toggled); + private: Ui::MainWindow* ui; // these are managed by Qt's memory management model! diff --git a/launcher/ui/MultiWorldListPage.cpp b/launcher/ui/MultiWorldListPage.cpp index 7064df357..9dd38a5a1 100644 --- a/launcher/ui/MultiWorldListPage.cpp +++ b/launcher/ui/MultiWorldListPage.cpp @@ -504,6 +504,7 @@ void MultiWorldListPage::join(QModelIndex index) auto worldVariant = m_worlds->data(index, MultiWorldList::ObjectRole); auto *world = static_cast(worldVariant.value()); APPLICATION->launch(world->instance, LaunchMode::Normal, std::make_shared(MinecraftTarget::parse(world->world.folderName(), true))); + emit worldJoined(); } #include "MultiWorldListPage.moc" diff --git a/launcher/ui/MultiWorldListPage.h b/launcher/ui/MultiWorldListPage.h index 1440a9657..3114172e8 100644 --- a/launcher/ui/MultiWorldListPage.h +++ b/launcher/ui/MultiWorldListPage.h @@ -65,6 +65,9 @@ class MultiWorldListPage : public QMainWindow, public BasePage { virtual void openedImpl() override; virtual void closedImpl() override; + signals: + void worldJoined(); + protected: bool eventFilter(QObject* obj, QEvent* ev) override; bool worldListFilter(QKeyEvent* ev);