GH-1227 add world copy and rename
This commit is contained in:
@ -22,6 +22,7 @@
|
||||
#include <QClipboard>
|
||||
#include <QMessageBox>
|
||||
#include <QTreeView>
|
||||
#include <QInputDialog>
|
||||
|
||||
|
||||
#include "MultiMC.h"
|
||||
@ -35,6 +36,7 @@ WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worl
|
||||
ui->setupUi(this);
|
||||
ui->tabWidget->tabBar()->hide();
|
||||
QSortFilterProxyModel * proxy = new QSortFilterProxyModel(this);
|
||||
proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
proxy->setSourceModel(m_worlds.get());
|
||||
ui->worldTreeView->setSortingEnabled(true);
|
||||
ui->worldTreeView->setModel(proxy);
|
||||
@ -207,6 +209,8 @@ void WorldListPage::worldChanged(const QModelIndex ¤t, const QModelIndex &
|
||||
ui->copySeedBtn->setEnabled(enable);
|
||||
ui->mcEditBtn->setEnabled(enable);
|
||||
ui->rmWorldBtn->setEnabled(enable);
|
||||
ui->copyBtn->setEnabled(enable);
|
||||
ui->renameBtn->setEnabled(enable);
|
||||
}
|
||||
|
||||
void WorldListPage::on_addBtn_clicked()
|
||||
@ -224,4 +228,41 @@ void WorldListPage::on_addBtn_clicked()
|
||||
}
|
||||
m_worlds->startWatching();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WorldListPage::on_copyBtn_clicked()
|
||||
{
|
||||
QModelIndex index = getSelectedWorld();
|
||||
if (!index.isValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto worldVariant = m_worlds->data(index, WorldList::ObjectRole);
|
||||
auto world = (World *) worldVariant.value<void *>();
|
||||
bool ok = false;
|
||||
QString name = QInputDialog::getText(this, tr("World name"), tr("Enter a new name for the copy."), QLineEdit::Normal, world->name(), &ok);
|
||||
|
||||
if (ok && name.length() > 0)
|
||||
{
|
||||
world->install(m_worlds->dir().absolutePath(), name);
|
||||
}
|
||||
}
|
||||
|
||||
void WorldListPage::on_renameBtn_clicked()
|
||||
{
|
||||
QModelIndex index = getSelectedWorld();
|
||||
if (!index.isValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto worldVariant = m_worlds->data(index, WorldList::ObjectRole);
|
||||
auto world = (World *) worldVariant.value<void *>();
|
||||
|
||||
bool ok = false;
|
||||
QString name = QInputDialog::getText(this, tr("World name"), tr("Enter a new world name."), QLineEdit::Normal, world->name(), &ok);
|
||||
|
||||
if (ok && name.length() > 0)
|
||||
{
|
||||
world->rename(name);
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +82,8 @@ private slots:
|
||||
void on_mcEditBtn_clicked();
|
||||
void on_rmWorldBtn_clicked();
|
||||
void on_addBtn_clicked();
|
||||
void on_copyBtn_clicked();
|
||||
void on_renameBtn_clicked();
|
||||
void on_viewFolderBtn_clicked();
|
||||
void worldChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
};
|
||||
|
@ -70,6 +70,20 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="copyBtn">
|
||||
<property name="text">
|
||||
<string>Copy</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="renameBtn">
|
||||
<property name="text">
|
||||
<string>Rename</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="rmWorldBtn">
|
||||
<property name="text">
|
||||
@ -134,6 +148,8 @@
|
||||
<tabstop>tabWidget</tabstop>
|
||||
<tabstop>worldTreeView</tabstop>
|
||||
<tabstop>addBtn</tabstop>
|
||||
<tabstop>copyBtn</tabstop>
|
||||
<tabstop>renameBtn</tabstop>
|
||||
<tabstop>rmWorldBtn</tabstop>
|
||||
<tabstop>mcEditBtn</tabstop>
|
||||
<tabstop>copySeedBtn</tabstop>
|
||||
|
Reference in New Issue
Block a user