mirror of
https://github.com/redstrate/Novus.git
synced 2025-04-23 12:37:45 +00:00
sagasu: Prepare for a better parts view, move properties into it
This commit is contained in:
parent
56353be167
commit
4fa1460b66
6 changed files with 45 additions and 16 deletions
|
@ -15,8 +15,8 @@ public:
|
||||||
explicit FileTreeWindow(GameData *data, QWidget *parent = nullptr);
|
explicit FileTreeWindow(GameData *data, QWidget *parent = nullptr);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void openFileProperties(QString path);
|
|
||||||
void extractFile(QString path);
|
void extractFile(QString path);
|
||||||
|
void pathSelected(QString path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GameData *data = nullptr;
|
GameData *data = nullptr;
|
||||||
|
|
|
@ -19,5 +19,7 @@ public:
|
||||||
private:
|
private:
|
||||||
QMdiArea *mdiArea = nullptr;
|
QMdiArea *mdiArea = nullptr;
|
||||||
|
|
||||||
GameData *data;
|
GameData *data = nullptr;
|
||||||
|
QTabWidget *partHolder = nullptr;
|
||||||
|
void refreshParts(QString qString);
|
||||||
};
|
};
|
|
@ -90,6 +90,10 @@ QVariant FileTreeModel::data(const QModelIndex &index, int role) const
|
||||||
|
|
||||||
auto item = static_cast<TreeInformation *>(index.internalPointer());
|
auto item = static_cast<TreeInformation *>(index.internalPointer());
|
||||||
if (role == Qt::UserRole) {
|
if (role == Qt::UserRole) {
|
||||||
|
if (item->type != TreeType::File || item->name.isEmpty()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
// build the full path
|
// build the full path
|
||||||
QString path;
|
QString path;
|
||||||
TreeInformation *parent = item;
|
TreeInformation *parent = item;
|
||||||
|
|
|
@ -31,11 +31,6 @@ FileTreeWindow::FileTreeWindow(GameData *data, QWidget *parent)
|
||||||
|
|
||||||
auto menu = new QMenu();
|
auto menu = new QMenu();
|
||||||
|
|
||||||
auto propertiesAction = menu->addAction(QStringLiteral("Properties"));
|
|
||||||
connect(propertiesAction, &QAction::triggered, this, [=] {
|
|
||||||
Q_EMIT openFileProperties(path);
|
|
||||||
});
|
|
||||||
|
|
||||||
auto extractAction = menu->addAction(QStringLiteral("Extract.."));
|
auto extractAction = menu->addAction(QStringLiteral("Extract.."));
|
||||||
connect(extractAction, &QAction::triggered, this, [=] {
|
connect(extractAction, &QAction::triggered, this, [=] {
|
||||||
Q_EMIT extractFile(path);
|
Q_EMIT extractFile(path);
|
||||||
|
@ -44,6 +39,13 @@ FileTreeWindow::FileTreeWindow(GameData *data, QWidget *parent)
|
||||||
menu->exec(treeWidget->mapToGlobal(pos));
|
menu->exec(treeWidget->mapToGlobal(pos));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(treeWidget, &QTreeView::clicked, [this, treeWidget](const QModelIndex &item) {
|
||||||
|
if (item.isValid()) {
|
||||||
|
auto path = m_fileModel->data(item, Qt::UserRole).toString();
|
||||||
|
Q_EMIT pathSelected(path);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "moc_filetreewindow.cpp"
|
#include "moc_filetreewindow.cpp"
|
|
@ -18,8 +18,6 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
physis_initialize_logging();
|
physis_initialize_logging();
|
||||||
|
|
||||||
app.setStyle(QStringLiteral("Windows"));
|
|
||||||
|
|
||||||
const QString gameDir{getGameDirectory()};
|
const QString gameDir{getGameDirectory()};
|
||||||
const std::string gameDirStd{gameDir.toStdString()};
|
const std::string gameDirStd{gameDir.toStdString()};
|
||||||
MainWindow w(physis_gamedata_initialize(gameDirStd.c_str()));
|
MainWindow w(physis_gamedata_initialize(gameDirStd.c_str()));
|
||||||
|
|
|
@ -18,14 +18,13 @@ MainWindow::MainWindow(GameData *data)
|
||||||
{
|
{
|
||||||
setupMenubar();
|
setupMenubar();
|
||||||
|
|
||||||
mdiArea = new QMdiArea();
|
auto dummyWidget = new QWidget();
|
||||||
setCentralWidget(mdiArea);
|
setCentralWidget(dummyWidget);
|
||||||
|
|
||||||
|
auto layout = new QHBoxLayout();
|
||||||
|
dummyWidget->setLayout(layout);
|
||||||
|
|
||||||
auto tree = new FileTreeWindow(data);
|
auto tree = new FileTreeWindow(data);
|
||||||
connect(tree, &FileTreeWindow::openFileProperties, this, [=](QString path) {
|
|
||||||
auto window = mdiArea->addSubWindow(new FilePropertiesWindow(data, path));
|
|
||||||
window->show();
|
|
||||||
});
|
|
||||||
connect(tree, &FileTreeWindow::extractFile, this, [this, data](QString path) {
|
connect(tree, &FileTreeWindow::extractFile, this, [this, data](QString path) {
|
||||||
const QFileInfo info(path);
|
const QFileInfo info(path);
|
||||||
|
|
||||||
|
@ -41,6 +40,30 @@ MainWindow::MainWindow(GameData *data)
|
||||||
file.write(reinterpret_cast<const char *>(fileData.data), fileData.size);
|
file.write(reinterpret_cast<const char *>(fileData.data), fileData.size);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
connect(tree, &FileTreeWindow::pathSelected, this, [=](QString path) {
|
||||||
|
refreshParts(path);
|
||||||
|
});
|
||||||
|
tree->setMaximumWidth(200);
|
||||||
|
layout->addWidget(tree);
|
||||||
|
|
||||||
mdiArea->addSubWindow(tree);
|
partHolder = new QTabWidget();
|
||||||
|
partHolder->setMinimumWidth(800);
|
||||||
|
partHolder->setMinimumHeight(720);
|
||||||
|
layout->addWidget(partHolder);
|
||||||
|
|
||||||
|
refreshParts({});
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::refreshParts(QString path)
|
||||||
|
{
|
||||||
|
partHolder->clear();
|
||||||
|
|
||||||
|
std::string pathStd = path.toStdString();
|
||||||
|
if (path.isEmpty() || !physis_gamedata_exists(data, pathStd.c_str())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add properties tab
|
||||||
|
auto propertiesWidget = new FilePropertiesWindow(data, path);
|
||||||
|
partHolder->addTab(propertiesWidget, QStringLiteral("Properties"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue