From 671035c9b1bae40b0144bab9f97ff1d163127c92 Mon Sep 17 00:00:00 2001 From: Jan Boon Date: Tue, 26 Nov 2019 08:40:33 +0800 Subject: [PATCH] Add source of old Qt based BNP make gui from sfb --- code/nel/tools/misc/bnp_make_qt/main.cpp | 11 + code/nel/tools/misc/bnp_make_qt/main.h | 8 + .../nel/tools/misc/bnp_make_qt/mainwindow.cpp | 253 ++++++++++++++ code/nel/tools/misc/bnp_make_qt/mainwindow.h | 61 ++++ code/nel/tools/misc/bnp_make_qt/mainwindow.ui | 322 ++++++++++++++++++ 5 files changed, 655 insertions(+) create mode 100644 code/nel/tools/misc/bnp_make_qt/main.cpp create mode 100644 code/nel/tools/misc/bnp_make_qt/main.h create mode 100644 code/nel/tools/misc/bnp_make_qt/mainwindow.cpp create mode 100644 code/nel/tools/misc/bnp_make_qt/mainwindow.h create mode 100644 code/nel/tools/misc/bnp_make_qt/mainwindow.ui diff --git a/code/nel/tools/misc/bnp_make_qt/main.cpp b/code/nel/tools/misc/bnp_make_qt/main.cpp new file mode 100644 index 000000000..4efc51df3 --- /dev/null +++ b/code/nel/tools/misc/bnp_make_qt/main.cpp @@ -0,0 +1,11 @@ +#include "main.h" + +int main(int argc, char * argv[]) +{ + QApplication application(argc, argv); + MainWindow window; + + window.show(); + + return application.exec(); +} diff --git a/code/nel/tools/misc/bnp_make_qt/main.h b/code/nel/tools/misc/bnp_make_qt/main.h new file mode 100644 index 000000000..a8a4b8652 --- /dev/null +++ b/code/nel/tools/misc/bnp_make_qt/main.h @@ -0,0 +1,8 @@ +#ifndef MAIN_H +#define MAIN_H + +#include + +#include "mainwindow.h" + +#endif // MAIN_H diff --git a/code/nel/tools/misc/bnp_make_qt/mainwindow.cpp b/code/nel/tools/misc/bnp_make_qt/mainwindow.cpp new file mode 100644 index 000000000..888330a80 --- /dev/null +++ b/code/nel/tools/misc/bnp_make_qt/mainwindow.cpp @@ -0,0 +1,253 @@ +#include "mainwindow.h" + +MainWindow::MainWindow(QWidget * parent) : + QMainWindow(parent), + uiMainWindow_(new Ui::MainWindow), + processList_(new QProcess(this)), + processSearch_(new QProcess(this)), + processPack_(new QProcess(this)), + processUnpack_(new QProcess(this)) +{ + uiMainWindow_->setupUi(this); + + settings_ = new QSettings("bnp_make_frontend.cfg", QSettings::IniFormat); + bnpMakeBinary_ = settings_->value("BnpMakeBinary").toString(); + dataPath_ = settings_->value("DataPath").toString(); + + uiMainWindow_->lineEditSearchPath->setText(dataPath_); + uiMainWindow_->lineEditBnpMake->setText(bnpMakeBinary_); + uiMainWindow_->lineEditDataPath->setText(dataPath_); + + connect(uiMainWindow_->pushButtonListBrowse, SIGNAL(clicked()), this, SLOT(onButtonListBrowseClicked())); + connect(uiMainWindow_->pushButtonList, SIGNAL(clicked()), this, SLOT(onButtonListClicked())); + connect(processList_, SIGNAL(finished(int)), this, SLOT(onProcessListComplete())); + + connect(uiMainWindow_->pushButtonSearchBrowse, SIGNAL(clicked()), this, SLOT(onButtonSearchBrowseClicked())); + connect(uiMainWindow_->pushButtonSearch, SIGNAL(clicked()), this, SLOT(onButtonSearchClicked())); + connect(processSearch_, SIGNAL(finished(int)), this, SLOT(onProcessSearchComplete())); + + connect(uiMainWindow_->pushButtonPackBrowse, SIGNAL(clicked()), this, SLOT(onButtonPackBrowseClicked())); + connect(uiMainWindow_->pushButtonPack, SIGNAL(clicked()), this, SLOT(onButtonPackClicked())); + connect(processPack_, SIGNAL(finished(int)), this, SLOT(onProcessPackComplete())); + + connect(uiMainWindow_->pushButtonUnpackBrowse, SIGNAL(clicked()), this, SLOT(onButtonUnpackBrowseClicked())); + connect(uiMainWindow_->pushButtonUnpack, SIGNAL(clicked()), this, SLOT(onButtonUnpackClicked())); + connect(processUnpack_, SIGNAL(finished(int)), this, SLOT(onProcessUnpackComplete())); + + connect(uiMainWindow_->pushButtonBnpMakeBrowse, SIGNAL(clicked()), this, SLOT(onButtonBnpMakeBrowseClicked())); + connect(uiMainWindow_->pushButtonDataPathBrowse, SIGNAL(clicked()), this, SLOT(onButtonDataPathBrowseClicked())); +} + +MainWindow::~MainWindow() +{ + delete uiMainWindow_; +} + +void MainWindow::onButtonListBrowseClicked() +{ + QString fileName; + + fileName = QFileDialog::getOpenFileName(this, "Choose a BNP file", dataPath_, "BNP file (*.bnp)"); + uiMainWindow_->lineEditList->setText(fileName); +} + +void MainWindow::onButtonListClicked() +{ + QStringList arguments; + + uiMainWindow_->textEditList->clear(); + + if (bnpMakeBinary_ != "") + if (uiMainWindow_->lineEditList->text() != "") + { + arguments << "/l" << uiMainWindow_->lineEditList->text(); + processList_->start(bnpMakeBinary_, arguments); + } + else + uiMainWindow_->textEditList->append("Choose a BNP file."); + else + uiMainWindow_->textEditList->append("Check bnp_make path."); +} + +void MainWindow::onProcessListComplete() +{ + QString output; + + output = processList_->readAllStandardOutput(); + uiMainWindow_->textEditList->append(output); + uiMainWindow_->textEditList->append("List complete."); +} + +void MainWindow::onButtonSearchBrowseClicked() +{ + QString directory; + + directory = QFileDialog::getExistingDirectory(this, tr("Choose a directory"), dataPath_, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + uiMainWindow_->lineEditSearchPath->setText(directory); +} + +void MainWindow::onButtonSearchClicked() +{ + QDir dir; + QStringList nameFilters; + + uiMainWindow_->textEditSearch->clear(); + + if (bnpMakeBinary_ != "") + if (uiMainWindow_->lineEditSearchPath->text() != "") + { + dir.cd(uiMainWindow_->lineEditSearchPath->text()); + + nameFilters << "*.bnp"; + dir.setNameFilters(nameFilters); + dir.setFilter(QDir::Files); + + fileInfoList_ = dir.entryInfoList(); + fileInfoListIndex_ = 0; + + onProcessSearchComplete(); + } + else + uiMainWindow_->textEditSearch->append("Choose a directory."); + else + uiMainWindow_->textEditSearch->append("Check bnp_make path."); +} + +void MainWindow::onProcessSearchComplete() +{ + QFileInfo fileInfo; + QStringList arguments; + QString output; + QStringList outputList; + QString line; + + if (fileInfoListIndex_ > 0) + { + output = processSearch_->readAllStandardOutput(); + + if (uiMainWindow_->lineEditSearchString->text() == "") + uiMainWindow_->textEditSearch->append(output); + else + { + outputList = output.split("\n"); + + foreach (line, outputList) + if (line.contains(uiMainWindow_->lineEditSearchString->text())) + uiMainWindow_->textEditSearch->append(line.trimmed()); + } + } + + if (fileInfoListIndex_ < fileInfoList_.count()) + { + fileInfo = fileInfoList_.at(fileInfoListIndex_++); + uiMainWindow_->textEditSearch->append("===> " + uiMainWindow_->lineEditSearchPath->text() + "/" + fileInfo.fileName() + ":"); + arguments << "/l" << uiMainWindow_->lineEditSearchPath->text() + "/" + fileInfo.fileName(); + processSearch_->start(bnpMakeBinary_, arguments); + } + else + { + uiMainWindow_->textEditSearch->append("Search complete."); + } +} + +void MainWindow::onButtonPackBrowseClicked() +{ + QString directory; + + directory = QFileDialog::getExistingDirectory(this, tr("Choose the source directory"), dataPath_, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + uiMainWindow_->lineEditPack->setText(directory); +} + +void MainWindow::onButtonPackClicked() +{ + QStringList arguments; + + uiMainWindow_->textEditPack->clear(); + + if (bnpMakeBinary_ != "") + if (uiMainWindow_->lineEditPack->text() != "") + { + uiMainWindow_->textEditPack->append("Pack in progress..."); + + arguments << "/p" << uiMainWindow_->lineEditPack->text(); + processPack_->start(bnpMakeBinary_, arguments); + } + else + uiMainWindow_->textEditPack->append("Choose the source directory."); + else + uiMainWindow_->textEditPack->append("Check bnp_make path."); +} + +void MainWindow::onProcessPackComplete() +{ + QString output; + + output = processPack_->readAllStandardOutput(); + uiMainWindow_->textEditPack->append(output); + uiMainWindow_->textEditPack->append("Pack complete."); +} + +void MainWindow::onButtonUnpackBrowseClicked() +{ + QString fileName; + + fileName = QFileDialog::getOpenFileName(this, "Choose a BNP file", dataPath_, "BNP file (*.bnp)"); + uiMainWindow_->lineEditUnpack->setText(fileName); +} + +void MainWindow::onButtonUnpackClicked() +{ + QStringList arguments; + + uiMainWindow_->textEditUnpack->clear(); + + if (bnpMakeBinary_ != "") + if (uiMainWindow_->lineEditUnpack->text() != "") + { + uiMainWindow_->textEditUnpack->append("Unpack in progress..."); + + arguments << "/u" << uiMainWindow_->lineEditUnpack->text(); + processUnpack_->start(bnpMakeBinary_, arguments); + } + else + uiMainWindow_->textEditUnpack->append("Choose a BNP file."); + else + uiMainWindow_->textEditUnpack->append("Check bnp_make path."); +} + +void MainWindow::onProcessUnpackComplete() +{ + uiMainWindow_->textEditUnpack->append("Unpack complete."); +} + +void MainWindow::onButtonBnpMakeBrowseClicked() +{ + QString fileName; + + fileName = QFileDialog::getOpenFileName(this, "Locate the bnp_make binary", dataPath_); + uiMainWindow_->lineEditBnpMake->setText(fileName); + + bnpMakeBinary_ = fileName; + settings_->setValue("BnpMakeBinary", fileName); + + uiMainWindow_->textEditSettings->clear(); + if (fileName != "") + uiMainWindow_->textEditSettings->append("bnp_make path changed."); + else + uiMainWindow_->textEditSettings->append("Locate the bnp_make binary."); +} + +void MainWindow::onButtonDataPathBrowseClicked() +{ + QString directory; + + directory = QFileDialog::getExistingDirectory(this, tr("Choose a directory"), dataPath_, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + uiMainWindow_->lineEditDataPath->setText(directory); + + dataPath_ = directory; + settings_->setValue("DataPath", directory); + uiMainWindow_->lineEditSearchPath->setText(directory); + + uiMainWindow_->textEditSettings->clear(); + uiMainWindow_->textEditSettings->append("Data path changed."); +} diff --git a/code/nel/tools/misc/bnp_make_qt/mainwindow.h b/code/nel/tools/misc/bnp_make_qt/mainwindow.h new file mode 100644 index 000000000..776b5fe01 --- /dev/null +++ b/code/nel/tools/misc/bnp_make_qt/mainwindow.h @@ -0,0 +1,61 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include +#include + +#include "ui_mainwindow.h" + +namespace Ui +{ + class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + + public: + explicit MainWindow(QWidget * parent = 0); + ~MainWindow(); + + public slots: + void onButtonListBrowseClicked(); + void onButtonListClicked(); + void onProcessListComplete(); + + void onButtonSearchBrowseClicked(); + void onButtonSearchClicked(); + void onProcessSearchComplete(); + + void onButtonPackBrowseClicked(); + void onButtonPackClicked(); + void onProcessPackComplete(); + + void onButtonUnpackBrowseClicked(); + void onButtonUnpackClicked(); + void onProcessUnpackComplete(); + + void onButtonBnpMakeBrowseClicked(); + void onButtonDataPathBrowseClicked(); + + private: + Ui::MainWindow * uiMainWindow_; + QSettings * settings_; + QString bnpMakeBinary_; + QString dataPath_; + + QProcess * processList_; + + QProcess * processSearch_; + int fileInfoListIndex_; + QFileInfoList fileInfoList_; + + QProcess * processPack_; + + QProcess * processUnpack_; +}; + +#endif // MAINWINDOW_H diff --git a/code/nel/tools/misc/bnp_make_qt/mainwindow.ui b/code/nel/tools/misc/bnp_make_qt/mainwindow.ui new file mode 100644 index 000000000..37097744e --- /dev/null +++ b/code/nel/tools/misc/bnp_make_qt/mainwindow.ui @@ -0,0 +1,322 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + bnp-make-frontend + + + + :/images/bnp-make-frontend.ico:/images/bnp-make-frontend.ico + + + QTabWidget::Rounded + + + + + + + 0 + + + + List + + + + + + + + + + BNP file: + + + + + + + true + + + + + + + Browse + + + + + + + + + List + + + + + + + true + + + + + + + + + + Search + + + + + + + + + + Search path: + + + + + + + true + + + + + + + Browse + + + + + + + + + + + Search string: + + + + + + + + + + + + Search + + + + + + + true + + + + + + + + + + Pack + + + + + + + + + + Source path: + + + + + + + true + + + + + + + Browse + + + + + + + + + Pack + + + + + + + true + + + + + + + + + + Unpack + + + + + + + + + + BNP file: + + + + + + + true + + + + + + + Browse + + + + + + + + + Unpack + + + + + + + true + + + + + + + + + + Settings + + + + + + + + + + bnp_make path: + + + + + + + true + + + + + + + Browse + + + + + + + + + + + Data path: + + + + + + + true + + + + + + + Browse + + + + + + + + + true + + + + + + + + + + + + + + + + + +