2022-11-19 20:34:26 +05:30
|
|
|
#include "ImportResourcePackDialog.h"
|
|
|
|
#include "ui_ImportResourcePackDialog.h"
|
|
|
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QPushButton>
|
|
|
|
|
|
|
|
#include "Application.h"
|
|
|
|
#include "InstanceList.h"
|
|
|
|
|
2022-11-19 21:29:30 +05:30
|
|
|
#include <InstanceList.h>
|
2022-11-19 20:34:26 +05:30
|
|
|
#include "ui/instanceview/InstanceDelegate.h"
|
|
|
|
|
|
|
|
ImportResourcePackDialog::ImportResourcePackDialog(QWidget* parent) : QDialog(parent), ui(new Ui::ImportResourcePackDialog)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
setWindowModality(Qt::WindowModal);
|
|
|
|
|
|
|
|
auto contentsWidget = ui->instanceView;
|
|
|
|
contentsWidget->setViewMode(QListView::ListMode);
|
|
|
|
contentsWidget->setFlow(QListView::LeftToRight);
|
|
|
|
contentsWidget->setIconSize(QSize(48, 48));
|
|
|
|
contentsWidget->setMovement(QListView::Static);
|
|
|
|
contentsWidget->setResizeMode(QListView::Adjust);
|
|
|
|
contentsWidget->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
|
|
contentsWidget->setSpacing(5);
|
|
|
|
contentsWidget->setWordWrap(false);
|
|
|
|
contentsWidget->setWrapping(true);
|
|
|
|
contentsWidget->setUniformItemSizes(true);
|
|
|
|
contentsWidget->setTextElideMode(Qt::ElideRight);
|
|
|
|
contentsWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
|
|
|
contentsWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
|
|
|
contentsWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
contentsWidget->setItemDelegate(new ListViewDelegate());
|
|
|
|
|
|
|
|
contentsWidget->setModel(APPLICATION->instances().get());
|
|
|
|
|
|
|
|
connect(contentsWidget, SIGNAL(doubleClicked(QModelIndex)), SLOT(activated(QModelIndex)));
|
|
|
|
connect(contentsWidget->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
|
|
|
|
SLOT(selectionChanged(QItemSelection, QItemSelection)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImportResourcePackDialog::activated(QModelIndex index)
|
|
|
|
{
|
2022-11-19 21:29:30 +05:30
|
|
|
selectedInstanceKey = index.data(InstanceList::InstanceIDRole).toString();
|
2022-11-19 20:34:26 +05:30
|
|
|
accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImportResourcePackDialog::selectionChanged(QItemSelection selected, QItemSelection deselected)
|
|
|
|
{
|
|
|
|
if (selected.empty())
|
|
|
|
return;
|
|
|
|
|
2022-11-19 21:29:30 +05:30
|
|
|
QString key = selected.first().indexes().first().data(InstanceList::InstanceIDRole).toString();
|
2022-11-19 20:34:26 +05:30
|
|
|
if (!key.isEmpty()) {
|
|
|
|
selectedInstanceKey = key;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImportResourcePackDialog::~ImportResourcePackDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|