From 46c9eb1d5fb2df8ebe10f4a57d41e9172b3aca84 Mon Sep 17 00:00:00 2001 From: Yihe Li Date: Mon, 19 May 2025 01:33:15 +0800 Subject: [PATCH] Remove button additions Signed-off-by: Yihe Li --- launcher/minecraft/WorldList.cpp | 38 ---------- launcher/minecraft/WorldList.h | 5 -- launcher/ui/pages/instance/ServersPage.cpp | 75 -------------------- launcher/ui/pages/instance/ServersPage.h | 4 -- launcher/ui/pages/instance/ServersPage.ui | 48 +------------ launcher/ui/pages/instance/WorldListPage.cpp | 59 --------------- launcher/ui/pages/instance/WorldListPage.h | 4 -- launcher/ui/pages/instance/WorldListPage.ui | 47 +----------- 8 files changed, 2 insertions(+), 278 deletions(-) diff --git a/launcher/minecraft/WorldList.cpp b/launcher/minecraft/WorldList.cpp index 582531577..6a821ba60 100644 --- a/launcher/minecraft/WorldList.cpp +++ b/launcher/minecraft/WorldList.cpp @@ -46,9 +46,6 @@ #include #include -#include -#include "minecraft/ShortcutUtils.h" - WorldList::WorldList(const QString& dir, BaseInstance* instance) : QAbstractListModel(), m_instance(instance), m_dir(dir) { FS::ensureFolderPathExists(m_dir.absolutePath()); @@ -457,39 +454,4 @@ void WorldList::loadWorldsAsync() } } -void WorldList::createWorldShortcut(const QModelIndex& index, QWidget* parent) const -{ - if (!m_instance) - return; - - if (DesktopServices::isFlatpak()) - createWorldShortcutInOther(index, parent); - else - createWorldShortcutOnDesktop(index, parent); -} - -void WorldList::createWorldShortcutOnDesktop(const QModelIndex& index, QWidget* parent) const -{ - const auto& world = allWorlds().at(index.row()); - QString name = QString(tr("%1 - %2")).arg(m_instance->name(), world.name()); - QStringList extraArgs{ "--world", world.name() }; - ShortcutUtils::createInstanceShortcutOnDesktop({ m_instance, name, tr("world"), parent, extraArgs }); -} - -void WorldList::createWorldShortcutInApplications(const QModelIndex& index, QWidget* parent) const -{ - const auto& world = allWorlds().at(index.row()); - QString name = QString(tr("%1 - %2")).arg(m_instance->name(), world.name()); - QStringList extraArgs{ "--world", world.name() }; - ShortcutUtils::createInstanceShortcutInApplications({ m_instance, name, tr("world"), parent, extraArgs }); -} - -void WorldList::createWorldShortcutInOther(const QModelIndex& index, QWidget* parent) const -{ - const auto& world = allWorlds().at(index.row()); - QString name = QString(tr("%1 - %2")).arg(m_instance->name(), world.name()); - QStringList extraArgs{ "--world", world.name() }; - ShortcutUtils::createInstanceShortcutInOther({ m_instance, name, tr("world"), parent, extraArgs }); -} - #include "WorldList.moc" diff --git a/launcher/minecraft/WorldList.h b/launcher/minecraft/WorldList.h index 4f54e0737..93fecf1f5 100644 --- a/launcher/minecraft/WorldList.h +++ b/launcher/minecraft/WorldList.h @@ -84,11 +84,6 @@ class WorldList : public QAbstractListModel { const QList& allWorlds() const { return m_worlds; } - void createWorldShortcut(const QModelIndex& index, QWidget* parent = nullptr) const; - void createWorldShortcutOnDesktop(const QModelIndex& index, QWidget* parent = nullptr) const; - void createWorldShortcutInApplications(const QModelIndex& index, QWidget* parent = nullptr) const; - void createWorldShortcutInOther(const QModelIndex& index, QWidget* parent = nullptr) const; - private slots: void directoryChanged(QString path); void loadWorldsAsync(); diff --git a/launcher/ui/pages/instance/ServersPage.cpp b/launcher/ui/pages/instance/ServersPage.cpp index 36844d92a..245bbffe2 100644 --- a/launcher/ui/pages/instance/ServersPage.cpp +++ b/launcher/ui/pages/instance/ServersPage.cpp @@ -40,10 +40,8 @@ #include "ui/dialogs/CustomMessageBox.h" #include "ui_ServersPage.h" -#include #include #include -#include #include #include #include @@ -104,38 +102,6 @@ struct Server { } } - void createServerShortcut(BaseInstance* instance, QWidget* parent = nullptr) const - { - if (!instance) - return; - - if (DesktopServices::isFlatpak()) - createServerShortcutInOther(instance, parent); - else - createServerShortcutOnDesktop(instance, parent); - } - - void createServerShortcutOnDesktop(BaseInstance* instance, QWidget* parent = nullptr) const - { - QString name = QString(QObject::tr("%1 - Server %2")).arg(instance->name(), m_name); - QStringList extraArgs{ "--server", m_address }; - ShortcutUtils::createInstanceShortcutOnDesktop({ instance, name, QObject::tr("server"), parent, extraArgs }); - } - - void createServerShortcutInApplications(BaseInstance* instance, QWidget* parent = nullptr) const - { - QString name = QString(QObject::tr("%1 - Server %2")).arg(instance->name(), m_name); - QStringList extraArgs{ "--server", m_address }; - ShortcutUtils::createInstanceShortcutInApplications({ instance, name, QObject::tr("server"), parent, extraArgs }); - } - - void createServerShortcutInOther(BaseInstance* instance, QWidget* parent = nullptr) const - { - QString name = QString(QObject::tr("%1 - Server %2")).arg(instance->name(), m_name); - QStringList extraArgs{ "--server", m_address }; - ShortcutUtils::createInstanceShortcutInOther({ instance, name, QObject::tr("server"), parent, extraArgs }); - } - // Data - persistent and user changeable QString m_name; QString m_address; @@ -615,26 +581,6 @@ ServersPage::ServersPage(InstancePtr inst, QWidget* parent) : QMainWindow(parent connect(ui->resourceComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(resourceIndexChanged(int))); connect(m_model, &QAbstractItemModel::rowsRemoved, this, &ServersPage::rowsRemoved); - QList shortcutActions = { ui->actionCreateServerShortcutOther }; - if (!DesktopServices::isFlatpak()) { - QString desktopDir = FS::getDesktopDir(); - QString applicationDir = FS::getApplicationsDir(); - - if (!applicationDir.isEmpty()) - shortcutActions.push_front(ui->actionCreateServerShortcutApplications); - - if (!desktopDir.isEmpty()) - shortcutActions.push_front(ui->actionCreateServerShortcutDesktop); - } - - if (shortcutActions.length() > 1) { - auto shortcutInstanceMenu = new QMenu(this); - - for (auto action : shortcutActions) - shortcutInstanceMenu->addAction(action); - ui->actionCreateServerShortcut->setMenu(shortcutInstanceMenu); - } - m_locked = m_inst->isRunning(); if (m_locked) { m_model->lock(); @@ -738,7 +684,6 @@ void ServersPage::updateState() ui->actionMove_Up->setEnabled(serverEditEnabled); ui->actionRemove->setEnabled(serverEditEnabled); ui->actionJoin->setEnabled(serverEditEnabled); - ui->actionCreateServerShortcut->setEnabled(serverEditEnabled); if (server) { ui->addressLine->setText(server->m_address); @@ -822,26 +767,6 @@ void ServersPage::on_actionJoin_triggered() APPLICATION->launch(m_inst, true, false, std::make_shared(MinecraftTarget::parse(address, false))); } -void ServersPage::on_actionCreateServerShortcut_triggered() -{ - m_model->at(currentServer)->createServerShortcut(m_inst.get(), this); -} - -void ServersPage::on_actionCreateServerShortcutDesktop_triggered() -{ - m_model->at(currentServer)->createServerShortcutOnDesktop(m_inst.get(), this); -} - -void ServersPage::on_actionCreateServerShortcutApplications_triggered() -{ - m_model->at(currentServer)->createServerShortcutInApplications(m_inst.get(), this); -} - -void ServersPage::on_actionCreateServerShortcutOther_triggered() -{ - m_model->at(currentServer)->createServerShortcutInOther(m_inst.get(), this); -} - void ServersPage::on_actionRefresh_triggered() { m_model->queryServersStatus(); diff --git a/launcher/ui/pages/instance/ServersPage.h b/launcher/ui/pages/instance/ServersPage.h index 94baaa004..77710d6cc 100644 --- a/launcher/ui/pages/instance/ServersPage.h +++ b/launcher/ui/pages/instance/ServersPage.h @@ -85,10 +85,6 @@ class ServersPage : public QMainWindow, public BasePage { void on_actionMove_Up_triggered(); void on_actionMove_Down_triggered(); void on_actionJoin_triggered(); - void on_actionCreateServerShortcut_triggered(); - void on_actionCreateServerShortcutDesktop_triggered(); - void on_actionCreateServerShortcutApplications_triggered(); - void on_actionCreateServerShortcutOther_triggered(); void on_actionRefresh_triggered(); void runningStateChanged(bool running); diff --git a/launcher/ui/pages/instance/ServersPage.ui b/launcher/ui/pages/instance/ServersPage.ui index bb8bff5aa..d330835c8 100644 --- a/launcher/ui/pages/instance/ServersPage.ui +++ b/launcher/ui/pages/instance/ServersPage.ui @@ -135,9 +135,6 @@ Qt::ToolButtonTextOnly - - true - false @@ -148,12 +145,10 @@ false - - - + @@ -182,47 +177,6 @@ Join - - - Create Shortcut - - - Creates a shortcut on a selected folder to join the selected server. - - - - - Desktop - - - Creates a shortcut to this server on your desktop - - - QAction::TextHeuristicRole - - - - - Applications - - - Create a shortcut of this server on your start menu - - - QAction::TextHeuristicRole - - - - - Other... - - - Creates a shortcut in a folder selected by you - - - QAction::TextHeuristicRole - - Refresh diff --git a/launcher/ui/pages/instance/WorldListPage.cpp b/launcher/ui/pages/instance/WorldListPage.cpp index c770f9f23..9e1a0fb55 100644 --- a/launcher/ui/pages/instance/WorldListPage.cpp +++ b/launcher/ui/pages/instance/WorldListPage.cpp @@ -89,26 +89,6 @@ WorldListPage::WorldListPage(InstancePtr inst, std::shared_ptr worlds ui->toolBar->insertSpacer(ui->actionRefresh); - QList shortcutActions = { ui->actionCreateWorldShortcutOther }; - if (!DesktopServices::isFlatpak()) { - QString desktopDir = FS::getDesktopDir(); - QString applicationDir = FS::getApplicationsDir(); - - if (!applicationDir.isEmpty()) - shortcutActions.push_front(ui->actionCreateWorldShortcutApplications); - - if (!desktopDir.isEmpty()) - shortcutActions.push_front(ui->actionCreateWorldShortcutDesktop); - } - - if (shortcutActions.length() > 1) { - auto shortcutInstanceMenu = new QMenu(this); - - for (auto action : shortcutActions) - shortcutInstanceMenu->addAction(action); - ui->actionCreateWorldShortcut->setMenu(shortcutInstanceMenu); - } - WorldListProxyModel* proxy = new WorldListProxyModel(this); proxy->setSortCaseSensitivity(Qt::CaseInsensitive); proxy->setSourceModel(m_worlds.get()); @@ -365,9 +345,6 @@ void WorldListPage::worldChanged([[maybe_unused]] const QModelIndex& current, [[ if (!supportsJoin) { ui->toolBar->removeAction(ui->actionJoin); - ui->toolBar->removeAction(ui->actionCreateWorldShortcut); - } else { - ui->actionCreateWorldShortcut->setEnabled(enable); } } @@ -443,42 +420,6 @@ void WorldListPage::on_actionRename_triggered() } } -void WorldListPage::on_actionCreateWorldShortcut_triggered() -{ - QModelIndex index = getSelectedWorld(); - if (!index.isValid()) { - return; - } - m_worlds->createWorldShortcut(index, this); -} - -void WorldListPage::on_actionCreateWorldShortcutDesktop_triggered() -{ - QModelIndex index = getSelectedWorld(); - if (!index.isValid()) { - return; - } - m_worlds->createWorldShortcutOnDesktop(index, this); -} - -void WorldListPage::on_actionCreateWorldShortcutApplications_triggered() -{ - QModelIndex index = getSelectedWorld(); - if (!index.isValid()) { - return; - } - m_worlds->createWorldShortcutInApplications(index, this); -} - -void WorldListPage::on_actionCreateWorldShortcutOther_triggered() -{ - QModelIndex index = getSelectedWorld(); - if (!index.isValid()) { - return; - } - m_worlds->createWorldShortcutInOther(index, this); -} - void WorldListPage::on_actionRefresh_triggered() { m_worlds->update(); diff --git a/launcher/ui/pages/instance/WorldListPage.h b/launcher/ui/pages/instance/WorldListPage.h index f2c081bc5..84d9cd075 100644 --- a/launcher/ui/pages/instance/WorldListPage.h +++ b/launcher/ui/pages/instance/WorldListPage.h @@ -95,10 +95,6 @@ class WorldListPage : public QMainWindow, public BasePage { void on_actionAdd_triggered(); void on_actionCopy_triggered(); void on_actionRename_triggered(); - void on_actionCreateWorldShortcut_triggered(); - void on_actionCreateWorldShortcutDesktop_triggered(); - void on_actionCreateWorldShortcutApplications_triggered(); - void on_actionCreateWorldShortcutOther_triggered(); void on_actionRefresh_triggered(); void on_actionView_Folder_triggered(); void on_actionDatapacks_triggered(); diff --git a/launcher/ui/pages/instance/WorldListPage.ui b/launcher/ui/pages/instance/WorldListPage.ui index 6d951cbdd..04344b453 100644 --- a/launcher/ui/pages/instance/WorldListPage.ui +++ b/launcher/ui/pages/instance/WorldListPage.ui @@ -70,9 +70,6 @@ Qt::ToolButtonTextOnly - - true - false @@ -88,11 +85,10 @@ - - + @@ -122,14 +118,6 @@ Delete - - - Create Shortcut - - - Creates a shortcut on a selected folder to join the selected world. - - MCEdit @@ -166,39 +154,6 @@ Manage datapacks inside the world. - - - Desktop - - - Creates a shortcut to this world on your desktop - - - QAction::TextHeuristicRole - - - - - Applications - - - Create a shortcut of this world on your start menu - - - QAction::TextHeuristicRole - - - - - Other... - - - Creates a shortcut in a folder selected by you - - - QAction::TextHeuristicRole - -