From 872bb95acf6fabd639da57cd41a4844d7e6dd0f0 Mon Sep 17 00:00:00 2001 From: jaseg Date: Tue, 4 Aug 2020 01:04:52 +0200 Subject: Initial commit --- numberator.cpp | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 numberator.cpp (limited to 'numberator.cpp') diff --git a/numberator.cpp b/numberator.cpp new file mode 100644 index 0000000..2497403 --- /dev/null +++ b/numberator.cpp @@ -0,0 +1,86 @@ +#include "numberator.h" +#include "ui_numberator.h" +#include "ui_TagListDock.h" + +Numberator::Numberator(QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::Numberator) + , tagsDockUi(new Ui::TagListDock) + , settings("jaseg.de", "Numberator") + , loadImageDialog(this) + , proj() + , tagListModel(proj) + , tagPropTableModel(proj) +{ + ui->setupUi(this); + + QDockWidget *dock = new QDockWidget(this); + tagsDockUi->setupUi(dock); + addDockWidget(Qt::LeftDockWidgetArea, dock); + ui->menuView->addAction(dock->toggleViewAction()); + connect(ui->actionReload_Image, &QAction::triggered, + &proj, &SQLiteSaveFile::reloadImageFromDisk); + + tagsDockUi->tagList->setModel(&tagListModel); + tagsDockUi->propertyTable->setModel(&tagPropTableModel); + + loadImageDialog.setWindowModality(Qt::ApplicationModal); + loadImageDialog.setWindowTitle("Load Image..."); + loadImageDialog.setNameFilter("Images (*.png, *.xpm, *.jpg)"); + loadImageDialog.setFileMode(QFileDialog::ExistingFile); + loadImageDialog.restoreState(settings.value("MainWindow/LoadImageFileDialogState").toByteArray()); + connect(&loadImageDialog, &QFileDialog::accepted, [=]() { + settings.setValue("MainWindow/LoadImageFileDialogState", this->loadImageDialog.saveState()); + }); + connect(&loadImageDialog, &QFileDialog::fileSelected, &proj, &SQLiteSaveFile::loadImageFromDisk); + connect(ui->actionImport_Image, &QAction::triggered, [=](bool checked){ + Q_UNUSED(checked); + this->loadImageDialog.open(); + }); + + saveOpenDialog.setWindowModality(Qt::ApplicationModal); + saveOpenDialog.setNameFilter("Project Files (*.npr);;Any File (*)"); + saveOpenDialog.setFileMode(QFileDialog::AnyFile); + saveOpenDialog.restoreState(settings.value("MainWindow/SaveAsFileDialogState").toByteArray()); + connect(&saveOpenDialog, &QFileDialog::accepted, [=]() { + settings.setValue("MainWindow/SaveAsFileDialogState", this->saveOpenDialog.saveState()); + }); + connect(ui->actionSave_Project, &QAction::triggered, [=](bool checked){ + Q_UNUSED(checked); + this->saveOpenDialog.setWindowTitle("Save Project as..."); + disconnect(&this->saveOpenDialog, &QFileDialog::fileSelected, nullptr, nullptr); + connect(&this->saveOpenDialog, &QFileDialog::fileSelected, + &this->proj, &SQLiteSaveFile::saveAs); + this->saveOpenDialog.open(); + }); + connect(ui->actionOpen_Project, &QAction::triggered, [=](bool checked){ + Q_UNUSED(checked); + this->saveOpenDialog.setWindowTitle("Open Project..."); + disconnect(&this->saveOpenDialog, &QFileDialog::fileSelected, nullptr, nullptr); + connect(&this->saveOpenDialog, &QFileDialog::fileSelected, + this, &Numberator::openFile); + this->saveOpenDialog.open(); + }); + + connect(ui->actionNew_Project, &QAction::triggered, + &proj, &SQLiteSaveFile::clearNew); + connect(ui->actionQuit, &QAction::triggered, &QApplication::quit); + connect(ui->actionAbout, &QAction::triggered, &aboutDialog, &AboutDialog::open); + + connect(tagsDockUi->tagList->selectionModel(), &QItemSelectionModel::currentChanged, + [=](const QModelIndex ¤t, const QModelIndex &previous) { + Q_UNUSED(previous); + tagPropTableModel.showTag(tagListModel.getTag(current)); + }); +} + +Numberator::~Numberator() +{ + delete ui; +} + +void Numberator::openFile(const QString &path) +{ + +} + -- cgit