Remove button additions

Signed-off-by: Yihe Li <winmikedows@hotmail.com>
This commit is contained in:
Yihe Li
2025-05-19 01:33:15 +08:00
parent 4839595a11
commit 46c9eb1d5f
8 changed files with 2 additions and 278 deletions
@@ -40,10 +40,8 @@
#include "ui/dialogs/CustomMessageBox.h"
#include "ui_ServersPage.h"
#include <DesktopServices.h>
#include <FileSystem.h>
#include <io/stream_reader.h>
#include <minecraft/ShortcutUtils.h>
#include <minecraft/MinecraftInstance.h>
#include <tag_compound.h>
#include <tag_list.h>
@@ -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<QAction*> 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>(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();