diff options
author | Javier <dev.git@javispedro.com> | 2021-09-12 01:36:41 +0200 |
---|---|---|
committer | Javier <dev.git@javispedro.com> | 2021-09-12 01:36:41 +0200 |
commit | 66dd35254724ec5d4471a8be71f92e06cf0fa8e8 (patch) | |
tree | 1918dcca44dd75108d442bf173b58419ab41a518 /mainwindow.cc | |
parent | 8333259e49fc2961cab0939e3d937167d38a9f9d (diff) | |
download | scribiu-66dd35254724ec5d4471a8be71f92e06cf0fa8e8.tar.gz scribiu-66dd35254724ec5d4471a8be71f92e06cf0fa8e8.zip |
add ability to export a stroke list in plain text
Diffstat (limited to 'mainwindow.cc')
-rw-r--r-- | mainwindow.cc | 21 |
1 files changed, 20 insertions, 1 deletions
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"); } |