mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
initial toggle button ui
This commit is contained in:
parent
3a6ae78bc6
commit
e88b293f4a
4 changed files with 50 additions and 14 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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<int>& list)
|
|||
return slist.join(',');
|
||||
}
|
||||
|
||||
void MainWindow::onAllWorldsToggled(bool toggled)
|
||||
{
|
||||
if (toggled) {
|
||||
QList<BaseInstance*> allInstances = APPLICATION->instances()->getAllInstances();
|
||||
QList<QString> dirs;
|
||||
for (BaseInstance* inst : allInstances) {
|
||||
dirs.append(dynamic_cast<MinecraftInstance*>(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<QString, QString>& e
|
|||
if (creationTask) {
|
||||
instanceFromInstanceTask(creationTask);
|
||||
}
|
||||
|
||||
QList<BaseInstance*> allInstances = APPLICATION->instances()->getAllInstances();
|
||||
QList<QString> dirs;
|
||||
for (BaseInstance* inst : allInstances) {
|
||||
dirs.append(dynamic_cast<MinecraftInstance*>(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()
|
||||
|
|
|
|||
|
|
@ -90,6 +90,8 @@ class MainWindow : public QMainWindow {
|
|||
QMenu* createPopupMenu() override;
|
||||
|
||||
private slots:
|
||||
void onAllWorldsToggled(bool);
|
||||
|
||||
void onCatToggled(bool);
|
||||
|
||||
void onCatChanged(int);
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@
|
|||
<addaction name="actionHelpButton"/>
|
||||
<addaction name="actionCheckUpdate"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionAllWorlds"/>
|
||||
<addaction name="actionCAT"/>
|
||||
<addaction name="actionAccountsButton"/>
|
||||
</widget>
|
||||
|
|
@ -175,6 +176,7 @@
|
|||
</property>
|
||||
<addaction name="actionChangeTheme"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionAllWorlds"/>
|
||||
<addaction name="actionCAT"/>
|
||||
<addaction name="actionToggleStatusBar"/>
|
||||
<addaction name="actionLockToolbars"/>
|
||||
|
|
@ -779,6 +781,20 @@
|
|||
<string>Open the Java folder in a file browser. Only available if the built-in Java downloader is used.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAllWorlds">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="allworlds"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&All Worlds</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Toggle All Worlds Screen</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue