mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-12 05:07:46 +02:00
Use custom signals to record previous name
Signed-off-by: Yihe Li <winmikedows@hotmail.com>
This commit is contained in:
@ -289,14 +289,15 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||
|
||||
view->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
// FIXME: leaks ListViewDelegate
|
||||
view->setItemDelegate(new ListViewDelegate(this));
|
||||
auto delegate = new ListViewDelegate(this);
|
||||
view->setItemDelegate(delegate);
|
||||
view->setFrameShape(QFrame::NoFrame);
|
||||
// do not show ugly blue border on the mac
|
||||
view->setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||
connect(view->itemDelegate(), &QAbstractItemDelegate::closeEditor, this, [this] {
|
||||
if (auto newRoot = askToUpdateInstanceDirName(m_selectedInstance, this); !newRoot.isEmpty()) {
|
||||
connect(delegate, &ListViewDelegate::textChanged, this, [this](QString before, QString after) {
|
||||
if (auto newRoot = askToUpdateInstanceDirName(m_selectedInstance, before, after, this); !newRoot.isEmpty()) {
|
||||
refreshInstances();
|
||||
setSelectedInstanceByRoot(newRoot);
|
||||
setSelectedInstanceById(QFileInfo(newRoot).fileName());
|
||||
}
|
||||
});
|
||||
|
||||
@ -1138,18 +1139,6 @@ void MainWindow::setSelectedInstanceById(const QString& id)
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setSelectedInstanceByRoot(const QString& instanceRoot)
|
||||
{
|
||||
if (instanceRoot.isNull())
|
||||
return;
|
||||
const QModelIndex index = APPLICATION->instances()->getInstanceIndexByRoot(instanceRoot);
|
||||
if (index.isValid()) {
|
||||
QModelIndex selectionIndex = proxymodel->mapFromSource(index);
|
||||
view->selectionModel()->setCurrentIndex(selectionIndex, QItemSelectionModel::ClearAndSelect);
|
||||
updateStatusCenter();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionChangeInstGroup_triggered()
|
||||
{
|
||||
if (!m_selectedInstance)
|
||||
|
Reference in New Issue
Block a user