From 036c612d415f81bb871dbb8425ab8d5df8a85f0c Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Wed, 31 Aug 2022 14:27:03 -0400 Subject: [PATCH] Add and implement menu item "File | Copy main text window to WSJT-X.txt". --- widgets/mainwindow.cpp | 25 +++++++++++++++++++++++++ widgets/mainwindow.h | 1 + widgets/mainwindow.ui | 8 +++++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/widgets/mainwindow.cpp b/widgets/mainwindow.cpp index b08ac2af4..fa1874dbe 100644 --- a/widgets/mainwindow.cpp +++ b/widgets/mainwindow.cpp @@ -10000,3 +10000,28 @@ void MainWindow::on_jt65Button_clicked() } on_actionJT65_triggered(); } + +void MainWindow::on_actionCopy_to_WSJTX_txt_triggered() +{ + qDebug() << ui->decodedTextBrowser->toPlainText(); + + static QFile f {QDir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)}.absoluteFilePath ("WSJT-X.txt")}; + if(!f.open(QIODevice::Text | QIODevice::WriteOnly)) { + MessageBox::warning_message (this, tr ("WSJT-X.txt file error"), + tr ("Cannot open \"%1\" for writing").arg (f.fileName ()), + tr ("Error: %1").arg (f.errorString ())); + } else { + QString t=ui->decodedTextBrowser->toPlainText(); + + QTextStream out(&f); + out << t << +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) + endl +#else + Qt::endl +#endif + ; + f.close(); + } +} + diff --git a/widgets/mainwindow.h b/widgets/mainwindow.h index aa1796c4a..d3a6e0060 100644 --- a/widgets/mainwindow.h +++ b/widgets/mainwindow.h @@ -173,6 +173,7 @@ private slots: void on_actionOpen_next_in_directory_triggered(); void on_actionDecode_remaining_files_in_directory_triggered(); void on_actionDelete_all_wav_files_in_SaveDir_triggered(); + void on_actionCopy_to_WSJTX_txt_triggered(); void on_actionOpen_log_directory_triggered (); void on_actionNone_triggered(); void on_actionSave_all_triggered(); diff --git a/widgets/mainwindow.ui b/widgets/mainwindow.ui index f377631f2..c275a70e8 100644 --- a/widgets/mainwindow.ui +++ b/widgets/mainwindow.ui @@ -3026,6 +3026,8 @@ QLabel[oob="true"] { + + @@ -3036,7 +3038,6 @@ QLabel[oob="true"] { - @@ -3669,6 +3670,11 @@ QLabel[oob="true"] { Active Stations + + + Copy main text window to WSJT-X.txt + +