From 66dd35254724ec5d4471a8be71f92e06cf0fa8e8 Mon Sep 17 00:00:00 2001 From: Javier Date: Sun, 12 Sep 2021 01:36:41 +0200 Subject: add ability to export a stroke list in plain text --- mainwindow.cc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'mainwindow.cc') diff --git a/mainwindow.cc b/mainwindow.cc index bba19cc..8a32f2c 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -117,7 +117,7 @@ void MainWindow::openNotebook(const QString &pen, const QString ¬ebook) void MainWindow::exportCurrentPageAsPng(const QString &file) { qDebug() << "Exporting current page" << ui->notebookView->curPage() << "to" << file; - QImage image = ui->notebookView->exportPage(ui->notebookView->curPage()); + QImage image = ui->notebookView->exportPageAsImage(ui->notebookView->curPage()); if (!image.save(file, "PNG")) { QMessageBox::warning(this, tr("Export page"), tr("Could not export current page to '%s'").arg(file)); @@ -139,6 +139,18 @@ void MainWindow::exportCurrentPageAsSvg(const QString &file) painter.end(); } +void MainWindow::exportCurrentPageAsStrokeListTxt(const QString &file) +{ + QFile f(file); + if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) { + QMessageBox::warning(this, tr("Export page"), + tr("Could not export current page to '%s'").arg(file)); + return; + } + ui->notebookView->exportPageAsStrokeList(&f, ui->notebookView->curPage()); + f.close(); +} + void MainWindow::exportCurrentPaperReplayAsAac(const QString &file) { QString src = _media->currentSource().fileName(); @@ -311,6 +323,7 @@ void MainWindow::handleExport() QStringList filters; filters << tr("Current page as PNG image (*.png)") << tr("Current page as SVG image (*.svg)") + << tr("Current page as stroke list text file (*.txt)") << tr("Current audio as AAC (*.aac)"); QString filter; QString fileName = QFileDialog::getSaveFileName(this, tr("Export page"), QString(), @@ -331,6 +344,12 @@ void MainWindow::handleExport() exportCurrentPageAsSvg(fileName); break; case 2: + if (!fileName.endsWith(".txt", Qt::CaseInsensitive)) { + fileName.append(".txt"); + } + exportCurrentPageAsStrokeListTxt(fileName); + break; + case 3: if (!fileName.endsWith(".aac", Qt::CaseInsensitive)) { fileName.append(".aac"); } -- cgit v1.2.3