diff options
author | RazrFalcon <razrfalcon@gmail.com> | 2019-01-03 14:10:12 +0200 |
---|---|---|
committer | RazrFalcon <razrfalcon@gmail.com> | 2019-01-03 14:10:12 +0200 |
commit | cf365efd4ab280226f6b2f388f1620ea88f72d1d (patch) | |
tree | 758bf4e1acaaecab37a7f90120129d179c486bb6 /tools/viewsvg/mainwindow.cpp | |
parent | 3afab96590fe632c7912b3748c37d25e47c2db3d (diff) |
Replace examples/qt-demo with tools/viewsvg.
Diffstat (limited to 'tools/viewsvg/mainwindow.cpp')
-rw-r--r-- | tools/viewsvg/mainwindow.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tools/viewsvg/mainwindow.cpp b/tools/viewsvg/mainwindow.cpp new file mode 100644 index 0000000..10215b8 --- /dev/null +++ b/tools/viewsvg/mainwindow.cpp @@ -0,0 +1,59 @@ +#include <QMessageBox> +#include <QTimer> +#include <QFile> + +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + SvgView::init(); + + ui->cmbBoxSize->setCurrentIndex(1); + ui->cmbBoxBackground->setCurrentIndex(1); + + ui->svgView->setFitToView(true); + ui->svgView->setBackgound(SvgView::Backgound::White); + + connect(ui->svgView, &SvgView::loadError, this, [this](const QString &msg){ + QMessageBox::critical(this, "Error", msg); + }); + + QTimer::singleShot(5, this, &MainWindow::onStart); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::onStart() +{ + ui->svgView->setFocus(); + + const auto args = QCoreApplication::arguments(); + if (args.size() != 2) { + return; + } + + ui->svgView->loadFile(args.at(1)); +} + +void MainWindow::on_cmbBoxSize_activated(int index) +{ + ui->svgView->setFitToView(index == 1); +} + +void MainWindow::on_cmbBoxBackground_activated(int index) +{ + ui->svgView->setBackgound(SvgView::Backgound(index)); +} + +void MainWindow::on_chBoxDrawBorder_toggled(bool checked) +{ + ui->svgView->setDrawImageBorder(checked); +} |