diff options
Diffstat (limited to 'mainwindow.cc')
-rw-r--r-- | mainwindow.cc | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/mainwindow.cc b/mainwindow.cc index dae4ae6..e7a73fa 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -142,7 +142,7 @@ void MainWindow::exportCurrentPageAsSvg(const QString &file) painter.end(); } -void MainWindow::exportCurrentPageAsStrokeListTxt(const QString &file) +void MainWindow::exportCurrentPageAsTXYP(const QString &file, bool relativeTime) { QFile f(file); if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) { @@ -150,7 +150,7 @@ void MainWindow::exportCurrentPageAsStrokeListTxt(const QString &file) tr("Could not export current page to '%s'").arg(file)); return; } - ui->notebookView->exportPageAsStrokeList(&f, ui->notebookView->curPage()); + ui->notebookView->exportPageAsTXYP(&f, ui->notebookView->curPage(), relativeTime); f.close(); } @@ -310,13 +310,21 @@ void MainWindow::handlePenSyncFailed(const QString &penName) void MainWindow::handleExport() { + QSettings settings; + if (_curNotebookName == PAPER_REPLAY) { + settings.beginGroup("export"); + settings.beginGroup("audio"); + + QString dir = settings.value("dir").toString(); + QStringList filters; filters << tr("Current audio as AAC (*.aac)"); QString filter; - QString fileName = QFileDialog::getSaveFileName(this, tr("Export page"), QString(), + QString fileName = QFileDialog::getSaveFileName(this, tr("Export page"), dir, filters.join(";;"), &filter); if (fileName.isEmpty()) return; + int filterIndex = filters.indexOf(filter); switch (filterIndex) { case 0: @@ -325,18 +333,31 @@ void MainWindow::handleExport() } exportCurrentPaperReplayAsAac(fileName); break; + default: + Q_UNREACHABLE(); } + + QFileInfo file(fileName); + settings.setValue("dir", file.absolutePath()); } else if (!_curNotebookName.isEmpty()) { + settings.beginGroup("export"); + settings.beginGroup("page"); + + QString dir = settings.value("dir").toString(); + 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 page as TXYP (*.txyp)") << tr("Current audio as AAC (*.aac)"); - QString filter; - QString fileName = QFileDialog::getSaveFileName(this, tr("Export page"), QString(), + int filterIndex = settings.value("filetype").toInt(); + QString filter = filters.value(filterIndex); + + QString fileName = QFileDialog::getSaveFileName(this, tr("Export page"), dir, filters.join(";;"), &filter); if (fileName.isEmpty()) return; - int filterIndex = filters.indexOf(filter); + + filterIndex = filters.indexOf(filter); switch (filterIndex) { case 0: if (!fileName.endsWith(".png", Qt::CaseInsensitive)) { @@ -351,10 +372,10 @@ void MainWindow::handleExport() exportCurrentPageAsSvg(fileName); break; case 2: - if (!fileName.endsWith(".txt", Qt::CaseInsensitive)) { - fileName.append(".txt"); + if (!fileName.endsWith(".txyp", Qt::CaseInsensitive)) { + fileName.append(".txyp"); } - exportCurrentPageAsStrokeListTxt(fileName); + exportCurrentPageAsTXYP(fileName, settings.value("txyp_relative_t", true).toBool()); break; case 3: if (!fileName.endsWith(".aac", Qt::CaseInsensitive)) { @@ -362,7 +383,13 @@ void MainWindow::handleExport() } exportCurrentPaperReplayAsAac(fileName); break; + default: + Q_UNREACHABLE(); } + + QFileInfo file(fileName); + settings.setValue("dir", file.absolutePath()); + settings.setValue("filetype", filterIndex); } else { QMessageBox::warning(this, tr("Export page"), tr("Open a notebook or audio in order to export")); |