Start on import wizard and move JSON wrappers into NostalgiaStudio library
This commit is contained in:
parent
03d7b5fd26
commit
e79e3756c5
@ -21,7 +21,6 @@ target_link_libraries(
|
||||
NostalgiaCommon
|
||||
NostalgiaCore
|
||||
NostalgiaStudio
|
||||
NostalgiaStudioJson
|
||||
)
|
||||
|
||||
install(
|
||||
@ -32,4 +31,3 @@ install(
|
||||
)
|
||||
|
||||
add_subdirectory(lib)
|
||||
add_subdirectory(json)
|
||||
|
@ -1,40 +0,0 @@
|
||||
cmake_minimum_required(VERSION 2.8.11)
|
||||
|
||||
project(NostalgiaStudioJson)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
add_library(
|
||||
NostalgiaStudioJson
|
||||
json_read.cpp
|
||||
json_write.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaStudioJson
|
||||
Qt5::Core
|
||||
Qt5::Widgets
|
||||
)
|
||||
|
||||
install(
|
||||
FILES
|
||||
json.hpp
|
||||
json_read.hpp
|
||||
json_write.hpp
|
||||
DESTINATION
|
||||
include/nostalgia/studio/json
|
||||
)
|
||||
|
||||
|
||||
add_executable(
|
||||
NostalgiaStudioJsonTest
|
||||
test.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaStudioJsonTest
|
||||
NostalgiaStudioJson
|
||||
)
|
||||
|
||||
add_test("Test\\ NostalgiaStudioJson" NostalgiaStudioJsonTest)
|
@ -7,7 +7,9 @@ set(CMAKE_AUTOMOC ON)
|
||||
|
||||
add_library(
|
||||
NostalgiaStudio
|
||||
newwizard.cpp
|
||||
json_read.cpp
|
||||
json_write.cpp
|
||||
wizard.cpp
|
||||
oxfstreeview.cpp
|
||||
project.cpp
|
||||
)
|
||||
@ -29,9 +31,24 @@ target_link_libraries(
|
||||
|
||||
install(
|
||||
FILES
|
||||
json.hpp
|
||||
json_read.hpp
|
||||
json_write.hpp
|
||||
newwizard.hpp
|
||||
oxfstreeview.hpp
|
||||
project.hpp
|
||||
DESTINATION
|
||||
include/nostalgia/studio/lib
|
||||
)
|
||||
|
||||
add_executable(
|
||||
NostalgiaStudioJsonTest
|
||||
json_test.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaStudioJsonTest
|
||||
NostalgiaStudio
|
||||
)
|
||||
|
||||
add_test("Test\\ NostalgiaStudioJson" NostalgiaStudioJsonTest)
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <QListWidget>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include "newwizard.hpp"
|
||||
#include "wizard.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
namespace studio {
|
||||
@ -241,8 +241,8 @@ void WizardFormPage::showValidationError(QString msg) {
|
||||
}
|
||||
|
||||
|
||||
Wizard::Wizard(QWidget *parent): QWizard(parent) {
|
||||
setWindowTitle(tr("New..."));
|
||||
Wizard::Wizard(QString windowTitle, QWidget *parent): QWizard(parent) {
|
||||
setWindowTitle(windowTitle);
|
||||
setModal(true);
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ class Wizard: public QWizard {
|
||||
std::function<void()> m_acceptFunc;
|
||||
|
||||
public:
|
||||
Wizard(QWidget *parent = 0);
|
||||
Wizard(QString windowTitle, QWidget *parent = 0);
|
||||
|
||||
void setAccept(std::function<void()> acceptFunc);
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <ox/clargs/clargs.hpp>
|
||||
#include "json/json.hpp"
|
||||
#include "lib/json.hpp"
|
||||
#include "mainwindow.hpp"
|
||||
|
||||
using namespace nostalgia::studio;
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include <QTabBar>
|
||||
#include <QVector>
|
||||
|
||||
#include "lib/newwizard.hpp"
|
||||
#include "lib/wizard.hpp"
|
||||
#include "lib/oxfstreeview.hpp"
|
||||
#include "lib/project.hpp"
|
||||
#include "mainwindow.hpp"
|
||||
@ -68,6 +68,16 @@ void MainWindow::setupMenu() {
|
||||
SLOT(showNewWizard())
|
||||
);
|
||||
|
||||
// Import...
|
||||
m_importAction = addAction(
|
||||
fileMenu,
|
||||
tr("&Import..."),
|
||||
tr(""),
|
||||
this,
|
||||
SLOT(showImportWizard())
|
||||
);
|
||||
m_importAction->setEnabled(false);
|
||||
|
||||
// Open Project
|
||||
addAction(
|
||||
fileMenu,
|
||||
@ -107,7 +117,17 @@ void MainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockWidget)
|
||||
m_dockWidgets.push_back(dockWidget);
|
||||
}
|
||||
|
||||
void MainWindow::addAction(QMenu *menu, QString text, QString toolTip,
|
||||
QAction *MainWindow::addAction(QMenu *menu, QString text, QString toolTip, const QObject *tgt, const char *cb) {
|
||||
auto action = menu->addAction(text);
|
||||
action->setStatusTip(toolTip);
|
||||
auto conn = connect(action, SIGNAL(triggered()), tgt, cb);
|
||||
m_cleanupTasks.push_back([this, conn]() {
|
||||
QObject::disconnect(conn);
|
||||
});
|
||||
return action;
|
||||
}
|
||||
|
||||
QAction *MainWindow::addAction(QMenu *menu, QString text, QString toolTip,
|
||||
QKeySequence::StandardKey key, const QObject *tgt, const char *cb) {
|
||||
auto action = menu->addAction(text);
|
||||
action->setShortcuts(key);
|
||||
@ -116,9 +136,10 @@ void MainWindow::addAction(QMenu *menu, QString text, QString toolTip,
|
||||
m_cleanupTasks.push_back([this, conn]() {
|
||||
QObject::disconnect(conn);
|
||||
});
|
||||
return action;
|
||||
}
|
||||
|
||||
void MainWindow::addAction(QMenu *menu, QString text, QString toolTip,
|
||||
QAction *MainWindow::addAction(QMenu *menu, QString text, QString toolTip,
|
||||
QKeySequence::StandardKey key, void (*cb)()) {
|
||||
auto action = menu->addAction(text);
|
||||
action->setShortcuts(key);
|
||||
@ -127,6 +148,7 @@ void MainWindow::addAction(QMenu *menu, QString text, QString toolTip,
|
||||
m_cleanupTasks.push_back([this, conn]() {
|
||||
QObject::disconnect(conn);
|
||||
});
|
||||
return action;
|
||||
}
|
||||
|
||||
void MainWindow::openProject() {
|
||||
@ -136,13 +158,14 @@ void MainWindow::openProject() {
|
||||
if (err == 0) {
|
||||
m_project = project;
|
||||
m_projectExplorer->setModel(new OxFSModel(m_project->romFS()));
|
||||
m_importAction->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::showNewWizard() {
|
||||
const QString PROJECT_NAME = "projectName";
|
||||
const QString PROJECT_PATH = "projectPath";
|
||||
Wizard wizard;
|
||||
Wizard wizard(tr("New..."));
|
||||
auto ws = new WizardSelect();
|
||||
wizard.addPage(ws);
|
||||
ws->addOption(tr("Project"),
|
||||
@ -182,5 +205,49 @@ void MainWindow::showNewWizard() {
|
||||
wizard.exec();
|
||||
}
|
||||
|
||||
void MainWindow::showImportWizard() {
|
||||
const QString TILESHEET_NAME = "projectName";
|
||||
const QString IMPORT_PATH = "projectPath";
|
||||
Wizard wizard(tr("Import..."));
|
||||
auto ws = new WizardSelect();
|
||||
wizard.addPage(ws);
|
||||
|
||||
ws->addOption(tr("Tile Sheet"),
|
||||
[&wizard, TILESHEET_NAME, IMPORT_PATH]() {
|
||||
QVector<QWizardPage*> pgs;
|
||||
auto pg = new WizardFormPage();
|
||||
pg->addLineEdit(tr("Tile Sheet &Name:"), TILESHEET_NAME + "*", "", [IMPORT_PATH, pg, &wizard](QString projectName) {
|
||||
auto projectPath = wizard.field(IMPORT_PATH).toString();
|
||||
auto path = projectPath + "/" + projectName;
|
||||
if (!QDir(path).exists()) {
|
||||
return 0;
|
||||
} else {
|
||||
pg->showValidationError(tr("This project directory already exists."));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
);
|
||||
pg->addDirBrowse(tr("Project &Path:"), IMPORT_PATH + "*");
|
||||
pgs.push_back(pg);
|
||||
pgs.push_back(new WizardConclusionPage(tr("Importing tile sheet: ") + "%1/%2", {IMPORT_PATH}));
|
||||
return pgs;
|
||||
}
|
||||
);
|
||||
|
||||
wizard.setAccept([&wizard, ws, TILESHEET_NAME, IMPORT_PATH]() {
|
||||
auto projectName = wizard.field(TILESHEET_NAME).toString();
|
||||
auto projectPath = wizard.field(IMPORT_PATH).toString();
|
||||
if (QDir(projectPath).exists()) {
|
||||
auto path = projectPath + "/" + projectName;
|
||||
if (QDir(path).exists()) {
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
wizard.show();
|
||||
wizard.exec();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ class MainWindow: public QMainWindow {
|
||||
static const QString AppTitle;
|
||||
|
||||
private:
|
||||
QAction *m_importAction = nullptr;
|
||||
QSharedPointer<Project> m_project;
|
||||
QPointer<QMenu> m_viewMenu;
|
||||
QVector<std::function<void()>> m_cleanupTasks;
|
||||
@ -79,10 +80,12 @@ class MainWindow: public QMainWindow {
|
||||
|
||||
void addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget);
|
||||
|
||||
void addAction(QMenu *menu, QString text, QString toolTip,
|
||||
QAction *addAction(QMenu *menu, QString text, QString toolTip, const QObject *tgt, const char *cb);
|
||||
|
||||
QAction *addAction(QMenu *menu, QString text, QString toolTip,
|
||||
QKeySequence::StandardKey key, const QObject *tgt, const char *cb);
|
||||
|
||||
void addAction(QMenu *menu, QString text, QString toolTip,
|
||||
QAction *addAction(QMenu *menu, QString text, QString toolTip,
|
||||
QKeySequence::StandardKey key, void (*cb)());
|
||||
|
||||
int readSettings(QString path);
|
||||
@ -93,6 +96,8 @@ class MainWindow: public QMainWindow {
|
||||
void openProject();
|
||||
|
||||
void showNewWizard();
|
||||
|
||||
void showImportWizard();
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user