From e88b293f4a65b6147bc3ee36a4934648de878980 Mon Sep 17 00:00:00 2001 From: Ice Yeti <101294194+IceYetiWins@users.noreply.github.com> Date: Sun, 31 May 2026 21:38:58 -0400 Subject: [PATCH] initial toggle button ui --- launcher/minecraft/MultiWorldList.cpp | 2 +- launcher/ui/MainWindow.cpp | 44 +++++++++++++++++++-------- launcher/ui/MainWindow.h | 2 ++ launcher/ui/MainWindow.ui | 16 ++++++++++ 4 files changed, 50 insertions(+), 14 deletions(-) diff --git a/launcher/minecraft/MultiWorldList.cpp b/launcher/minecraft/MultiWorldList.cpp index c43f84054..923f1751b 100644 --- a/launcher/minecraft/MultiWorldList.cpp +++ b/launcher/minecraft/MultiWorldList.cpp @@ -454,7 +454,7 @@ int64_t MultiWorldList::calculateWorldSize(const QFileInfo& file) return -1; } -void MultiWorldList::loadWorldsAsync() +void MultiWorldList::loadWorldsAsync() //this causes problems when deleting instances iy - only load this screen when switch to all worlds page? { for (int i = 0; i < m_worlds.size(); ++i) { auto file = m_worlds.at(i).world.container(); diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 8fd3ee8aa..d18db22e1 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -349,6 +349,11 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi allWorldsPage = new MultiWorldListPage(allWorlds); ui->horizontalLayout->addWidget(allWorldsPage); + + allWorldsPage->setVisible(false); + 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); } // The cat background @@ -859,6 +864,32 @@ QString intListToString(const QList& list) return slist.join(','); } +void MainWindow::onAllWorldsToggled(bool toggled) +{ + if (toggled) { + QList allInstances = APPLICATION->instances()->getAllInstances(); + QList dirs; + for (BaseInstance* inst : allInstances) { + dirs.append(dynamic_cast(inst)->worldDir()); + } + + allWorlds = new MultiWorldList(dirs, allInstances); + allWorlds->update(); + auto newAllWorldsPage = new MultiWorldListPage(allWorlds); + ui->horizontalLayout->replaceWidget(allWorldsPage, newAllWorldsPage); + delete allWorldsPage; + allWorldsPage = newAllWorldsPage; + + view->setVisible(false); + ui->instanceToolBar->setVisible(false); + allWorldsPage->setVisible(true); + } else { + allWorldsPage->setVisible(false); + view->setVisible(true); + ui->instanceToolBar->setVisibilityState(QByteArray::fromBase64(instanceToolbarSetting->get().toString().toUtf8())); + } +} + void MainWindow::onCatToggled(bool state) { setCatBackground(state); @@ -943,19 +974,6 @@ void MainWindow::addInstance(const QString& url, const QMap& e if (creationTask) { instanceFromInstanceTask(creationTask); } - - QList allInstances = APPLICATION->instances()->getAllInstances(); - QList dirs; - for (BaseInstance* inst : allInstances) { - dirs.append(dynamic_cast(inst)->worldDir()); - } - - allWorlds = new MultiWorldList(dirs, allInstances); - allWorlds->update(); - auto newAllWorldsPage = new MultiWorldListPage(allWorlds); - ui->horizontalLayout->replaceWidget(allWorldsPage, newAllWorldsPage); - delete allWorldsPage; - allWorldsPage = newAllWorldsPage; } void MainWindow::on_actionAddInstance_triggered() diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h index adc13cfe1..636e00617 100644 --- a/launcher/ui/MainWindow.h +++ b/launcher/ui/MainWindow.h @@ -90,6 +90,8 @@ class MainWindow : public QMainWindow { QMenu* createPopupMenu() override; private slots: + void onAllWorldsToggled(bool); + void onCatToggled(bool); void onCatChanged(int); diff --git a/launcher/ui/MainWindow.ui b/launcher/ui/MainWindow.ui index e9b9aa442..2e7d210dd 100644 --- a/launcher/ui/MainWindow.ui +++ b/launcher/ui/MainWindow.ui @@ -56,6 +56,7 @@ + @@ -175,6 +176,7 @@ + @@ -779,6 +781,20 @@ Open the Java folder in a file browser. Only available if the built-in Java downloader is used. + + + true + + + + + + &All Worlds + + + Toggle All Worlds Screen + +