Add create shortcut button for worlds
Signed-off-by: Yihe Li <winmikedows@hotmail.com>
This commit is contained in:
@@ -345,6 +345,28 @@ void WorldListPage::worldChanged([[maybe_unused]] const QModelIndex& current, [[
|
||||
|
||||
if (!supportsJoin) {
|
||||
ui->toolBar->removeAction(ui->actionJoin);
|
||||
ui->toolBar->removeAction(ui->actionCreateWorldShortcut);
|
||||
} else {
|
||||
QList<QAction*> 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);
|
||||
}
|
||||
ui->actionCreateWorldShortcut->setEnabled(enable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,6 +442,42 @@ 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();
|
||||
|
||||
@@ -95,6 +95,10 @@ 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();
|
||||
|
||||
@@ -85,10 +85,11 @@
|
||||
<addaction name="actionRename"/>
|
||||
<addaction name="actionCopy"/>
|
||||
<addaction name="actionRemove"/>
|
||||
<addaction name="actionCreateWorldShortcut"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionMCEdit"/>
|
||||
<addaction name="actionDatapacks"/>
|
||||
<addaction name="actionReset_Icon"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionCopy_Seed"/>
|
||||
<addaction name="actionRefresh"/>
|
||||
<addaction name="actionView_Folder"/>
|
||||
@@ -118,6 +119,14 @@
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCreateWorldShortcut">
|
||||
<property name="text">
|
||||
<string>Create Shortcut</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Creates a shortcut on a selected folder to join the selected world.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMCEdit">
|
||||
<property name="text">
|
||||
<string>MCEdit</string>
|
||||
@@ -154,6 +163,39 @@
|
||||
<string>Manage datapacks inside the world.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCreateWorldShortcutDesktop">
|
||||
<property name="text">
|
||||
<string>Desktop</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Creates a shortcut to this world on your desktop</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::TextHeuristicRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCreateWorldShortcutApplications">
|
||||
<property name="text">
|
||||
<string>Applications</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Create a shortcut of this world on your start menu</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::TextHeuristicRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCreateWorldShortcutOther">
|
||||
<property name="text">
|
||||
<string>Other...</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Creates a shortcut in a folder selected by you</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::TextHeuristicRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
||||
Reference in New Issue
Block a user