mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
ui fixes/additions
This commit is contained in:
parent
be49554be1
commit
bd9bea7081
4 changed files with 28 additions and 22 deletions
|
|
@ -227,6 +227,9 @@ QVariant MultiWorldList::data(const QModelIndex& index, int role) const
|
||||||
case NameColumn:
|
case NameColumn:
|
||||||
return instanceWorld.world.name();
|
return instanceWorld.world.name();
|
||||||
|
|
||||||
|
case InstanceColumn:
|
||||||
|
return instanceWorld.instance->name();
|
||||||
|
|
||||||
case GameModeColumn:
|
case GameModeColumn:
|
||||||
return instanceWorld.world.gameType().toTranslatedString();
|
return instanceWorld.world.gameType().toTranslatedString();
|
||||||
|
|
||||||
|
|
@ -303,6 +306,8 @@ QVariant MultiWorldList::headerData(int section, [[maybe_unused]] Qt::Orientatio
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case NameColumn:
|
case NameColumn:
|
||||||
return tr("Name");
|
return tr("Name");
|
||||||
|
case InstanceColumn:
|
||||||
|
return tr("Instance");
|
||||||
case GameModeColumn:
|
case GameModeColumn:
|
||||||
return tr("Game Mode");
|
return tr("Game Mode");
|
||||||
case LastPlayedColumn:
|
case LastPlayedColumn:
|
||||||
|
|
@ -321,6 +326,8 @@ QVariant MultiWorldList::headerData(int section, [[maybe_unused]] Qt::Orientatio
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case NameColumn:
|
case NameColumn:
|
||||||
return tr("The name of the world.");
|
return tr("The name of the world.");
|
||||||
|
case InstanceColumn:
|
||||||
|
return tr("The instance the world belongs to.");
|
||||||
case GameModeColumn:
|
case GameModeColumn:
|
||||||
return tr("Game mode of the world.");
|
return tr("Game mode of the world.");
|
||||||
case LastPlayedColumn:
|
case LastPlayedColumn:
|
||||||
|
|
@ -454,7 +461,7 @@ int64_t MultiWorldList::calculateWorldSize(const QFileInfo& file)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiWorldList::loadWorldsAsync() //this causes problems when deleting instances iy - only load this screen when switch to all worlds page?
|
void MultiWorldList::loadWorldsAsync()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_worlds.size(); ++i) {
|
for (int i = 0; i < m_worlds.size(); ++i) {
|
||||||
auto file = m_worlds.at(i).world.container();
|
auto file = m_worlds.at(i).world.container();
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,9 @@ struct InstanceWorld {
|
||||||
class MultiWorldList : public QAbstractListModel {
|
class MultiWorldList : public QAbstractListModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum Columns { NameColumn, GameModeColumn, LastPlayedColumn, SizeColumn, InfoColumn };
|
enum Columns { NameColumn, InstanceColumn, GameModeColumn, LastPlayedColumn, SizeColumn, InfoColumn };
|
||||||
|
|
||||||
enum Roles { ObjectRole = Qt::UserRole + 1, FolderRole, SeedRole, NameRole, GameModeRole, LastPlayedRole, SizeRole, IconFileRole };
|
enum Roles { ObjectRole = Qt::UserRole + 1, FolderRole, SeedRole, NameRole, InstanceRole, GameModeRole, LastPlayedRole, SizeRole, IconFileRole };
|
||||||
|
|
||||||
MultiWorldList(const QList<QString>& dirs, const QList<BaseInstance*>& instances);
|
MultiWorldList(const QList<QString>& dirs, const QList<BaseInstance*>& instances);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,7 @@ MultiWorldListPage::MultiWorldListPage(MultiWorldList* worlds, QWidget* parent)
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui->toolBar->insertSpacer(ui->actionRefresh);
|
ui->toolBar->insertSpacer(ui->actionRefresh);
|
||||||
|
ui->actionJoin->setEnabled(true);
|
||||||
|
|
||||||
auto* proxy = new MultiWorldListProxyModel(this);
|
auto* proxy = new MultiWorldListProxyModel(this);
|
||||||
proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
|
proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
|
@ -117,10 +118,6 @@ void MultiWorldListPage::openedImpl()
|
||||||
{
|
{
|
||||||
m_worlds->startWatching();
|
m_worlds->startWatching();
|
||||||
|
|
||||||
// if (!m_inst || !m_inst->traits().contains("feature:is_quick_play_singleplayer")) { //get rid of this??? iy
|
|
||||||
// ui->toolBar->removeAction(ui->actionJoin);
|
|
||||||
// }
|
|
||||||
|
|
||||||
auto const setting_name = QString("WideBarVisibility_%1").arg(id());
|
auto const setting_name = QString("WideBarVisibility_%1").arg(id());
|
||||||
m_wide_bar_setting = APPLICATION->settings()->getOrRegisterSetting(setting_name);
|
m_wide_bar_setting = APPLICATION->settings()->getOrRegisterSetting(setting_name);
|
||||||
|
|
||||||
|
|
@ -209,7 +206,15 @@ void MultiWorldListPage::on_actionRemove_triggered()
|
||||||
|
|
||||||
void MultiWorldListPage::on_actionView_Folder_triggered()
|
void MultiWorldListPage::on_actionView_Folder_triggered()
|
||||||
{
|
{
|
||||||
DesktopServices::openPath(m_worlds->dirs()[0].absolutePath(), true); //remove view folder option for all worlds (make it world specific) iy
|
QModelIndex index = getSelectedWorld();
|
||||||
|
if (!index.isValid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto worldVariant = m_worlds->data(index, MultiWorldList::ObjectRole);
|
||||||
|
auto world = (World*)worldVariant.value<void*>();
|
||||||
|
|
||||||
|
DesktopServices::openPath(world->canonicalFilePath(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiWorldListPage::on_actionData_Packs_triggered()
|
void MultiWorldListPage::on_actionData_Packs_triggered()
|
||||||
|
|
@ -237,9 +242,9 @@ void MultiWorldListPage::on_actionData_Packs_triggered()
|
||||||
GenericPageProvider provider(dialog->windowTitle());
|
GenericPageProvider provider(dialog->windowTitle());
|
||||||
|
|
||||||
bool isIndexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
bool isIndexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||||
m_datapackModel.reset(new DataPackFolderModel(folder, m_worlds->allWorlds()[0].instance, isIndexed, true)); //don't use instance 0 iy
|
m_datapackModel.reset(new DataPackFolderModel(folder, static_cast<InstanceWorld*>(m_worlds->data(index, MultiWorldList::ObjectRole).value<void*>())->instance, isIndexed, true)); //these cause crashes sometimes iy with null error SIGSEGV (probably due to watchers) after every first time launched -> using index 0 for instances doesnt fix it
|
||||||
|
|
||||||
provider.addPageCreator([this] { return new DataPackPage(m_worlds->allWorlds()[0].instance, m_datapackModel.get(), this); }); //no instance 0 iy
|
provider.addPageCreator([this, index] { return new DataPackPage(static_cast<InstanceWorld*>(m_worlds->data(index, MultiWorldList::ObjectRole).value<void*>())->instance, m_datapackModel.get(), this); }); //iy
|
||||||
|
|
||||||
auto layout = new QVBoxLayout(dialog);
|
auto layout = new QVBoxLayout(dialog);
|
||||||
|
|
||||||
|
|
@ -375,16 +380,10 @@ void MultiWorldListPage::worldChanged([[maybe_unused]] const QModelIndex& curren
|
||||||
ui->actionCopy->setEnabled(enable);
|
ui->actionCopy->setEnabled(enable);
|
||||||
ui->actionRename->setEnabled(enable);
|
ui->actionRename->setEnabled(enable);
|
||||||
ui->actionData_Packs->setEnabled(enable);
|
ui->actionData_Packs->setEnabled(enable);
|
||||||
|
ui->actionView_Folder->setEnabled(enable);
|
||||||
|
ui->actionJoin->setEnabled(enable);
|
||||||
bool hasIcon = !index.data(MultiWorldList::IconFileRole).isNull();
|
bool hasIcon = !index.data(MultiWorldList::IconFileRole).isNull();
|
||||||
ui->actionReset_Icon->setEnabled(enable && hasIcon);
|
ui->actionReset_Icon->setEnabled(enable && hasIcon);
|
||||||
|
|
||||||
// auto supportsJoin = m_inst && m_inst->traits().contains("feature:is_quick_play_singleplayer"); //change this to be on instance by instance basis iy
|
|
||||||
// ui->actionJoin->setEnabled(enable && supportsJoin);
|
|
||||||
ui->actionJoin->setEnabled(true);
|
|
||||||
|
|
||||||
// if (!supportsJoin) {
|
|
||||||
// ui->toolBar->removeAction(ui->actionJoin);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiWorldListPage::on_actionAdd_triggered()
|
void MultiWorldListPage::on_actionAdd_triggered()
|
||||||
|
|
@ -400,9 +399,9 @@ void MultiWorldListPage::on_actionAdd_triggered()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiWorldListPage::isWorldSafe(QModelIndex)
|
bool MultiWorldListPage::isWorldSafe(QModelIndex index)
|
||||||
{
|
{
|
||||||
return !m_worlds->allWorlds()[0].instance->isRunning(); //don't use instance 0 iy
|
return !static_cast<InstanceWorld*>(m_worlds->data(index, MultiWorldList::ObjectRole).value<void*>())->instance->isRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiWorldListPage::worldSafetyNagQuestion(const QString& actionType)
|
bool MultiWorldListPage::worldSafetyNagQuestion(const QString& actionType)
|
||||||
|
|
@ -471,7 +470,7 @@ void MultiWorldListPage::on_actionJoin_triggered()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto worldVariant = m_worlds->data(index, MultiWorldList::ObjectRole);
|
auto worldVariant = m_worlds->data(index, MultiWorldList::ObjectRole);
|
||||||
auto world = (InstanceWorld*)worldVariant.value<void*>();
|
auto *world = static_cast<InstanceWorld*>(worldVariant.value<void*>());
|
||||||
APPLICATION->launch(world->instance, LaunchMode::Normal, std::make_shared<MinecraftTarget>(MinecraftTarget::parse(world->world.folderName(), true)));
|
APPLICATION->launch(world->instance, LaunchMode::Normal, std::make_shared<MinecraftTarget>(MinecraftTarget::parse(world->world.folderName(), true)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,10 +91,10 @@
|
||||||
<addaction name="actionMCEdit"/>
|
<addaction name="actionMCEdit"/>
|
||||||
<addaction name="actionData_Packs"/>
|
<addaction name="actionData_Packs"/>
|
||||||
<addaction name="actionReset_Icon"/>
|
<addaction name="actionReset_Icon"/>
|
||||||
|
<addaction name="actionView_Folder"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionCopy_Seed"/>
|
<addaction name="actionCopy_Seed"/>
|
||||||
<addaction name="actionRefresh"/>
|
<addaction name="actionRefresh"/>
|
||||||
<addaction name="actionView_Folder"/>
|
|
||||||
</widget>
|
</widget>
|
||||||
<action name="actionAdd">
|
<action name="actionAdd">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue