diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/mainwindow.cpp | 60 | ||||
-rw-r--r-- | src/ui/metadatadialog.cpp | 31 | ||||
-rw-r--r-- | src/ui/painter.cpp | 14 |
3 files changed, 101 insertions, 4 deletions
diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 7e4ca77..5a60391 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -1,14 +1,66 @@ #include "ui/mainwindow.h" #include "ui_mainwindow.h" -MainWindow::MainWindow(QWidget *parent) : +#include "ui/metadatadialog.h" + +#include <iostream> + +MainWindow::MainWindow(samb::Structogram *structogram, QWidget *parent) : QMainWindow(parent), - ui(new Ui::MainWindow) + _ui(new Ui::MainWindow), + _structogram(structogram) { - ui->setupUi(this); + _ui->setupUi(this); + initData(); } MainWindow::~MainWindow() { - delete ui; + delete _ui; +} + +/**** private slots ****/ + +void MainWindow::on_newButton_clicked() +{ + if (_structogram != nullptr) + { + // TODO: implement save dialog + std::cout << "TODO: implement save dialog" << std::endl; + + delete _structogram; + _structogram = nullptr; + } + + MetadataDialog *dialog = new MetadataDialog(this); + if (dialog->exec() == QDialog::Accepted) + { + _structogram = new samb::Structogram(dialog->title(), dialog->author()); + } + + delete dialog; +} + +void MainWindow::on_metadataButton_clicked() +{ + if (_structogram == nullptr) { return; } + + MetadataDialog *dialog = new MetadataDialog(this); + dialog->setMetadata(_structogram->title(), _structogram->author()); + + if (dialog->exec() == QDialog::Accepted) + { + _structogram->title(dialog->title()); + _structogram->author(dialog->author()); + } +} + +/**** private methods ****/ + +void MainWindow::initData() +{ + if (_structogram == nullptr) + { + _structogram = new samb::Structogram("", ""); + } } diff --git a/src/ui/metadatadialog.cpp b/src/ui/metadatadialog.cpp new file mode 100644 index 0000000..348f225 --- /dev/null +++ b/src/ui/metadatadialog.cpp @@ -0,0 +1,31 @@ +#include "ui/metadatadialog.h" +#include "ui_metadatadialog.h" + +MetadataDialog::MetadataDialog(QWidget *parent) : + QDialog(parent), + _ui(new Ui::MetadataDialog) +{ + _ui->setupUi(this); +} + +MetadataDialog::~MetadataDialog() +{ + delete _ui; +} + +void MetadataDialog::setMetadata(const QString& title, const QString& author) +{ + _ui->titleEdit->setText(title); + _ui->authorEdit->setText(author); +} + + +QString MetadataDialog::title() const +{ + return _ui->titleEdit->text(); +} + +QString MetadataDialog::author() const +{ + return _ui->authorEdit->text(); +} diff --git a/src/ui/painter.cpp b/src/ui/painter.cpp new file mode 100644 index 0000000..b04e389 --- /dev/null +++ b/src/ui/painter.cpp @@ -0,0 +1,14 @@ +#include "ui/painter.h" +#include "ui_painter.h" + +Painter::Painter(QWidget *parent) : + QWidget(parent), + _ui(new Ui::Painter) +{ + _ui->setupUi(this); +} + +Painter::~Painter() +{ + delete _ui; +} |