From d95d6405149751ce3ec1e5d7ee86764c0faf871a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Kov=C3=A1cs?= Date: Thu, 15 Feb 2024 09:37:10 +0100 Subject: [PATCH] Add latintextN command to Qt port --- qt/mainwindow.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++----- qt/mainwindow.h | 5 +++++ 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp index 4852a69c..dce16a75 100644 --- a/qt/mainwindow.cpp +++ b/qt/mainwindow.cpp @@ -22,13 +22,13 @@ extern string text[2]; extern vector textset; QString getClipboardInfos() { - QString intro = "Contents of the clipboards in a-y notation"; + QString intro = "Contents of the clipboards in Greek (and in a-y notation)"; for (int i = 0; i < 2; ++i) { intro += "
Clipboard " + QString::number(i + 1); if (text[i].empty()) intro += " is empty."; else - intro += " contains " + text[i] + "."; + intro += " contains " + latinToGreek(text[i]) + " (" + text[i] + ")."; } return intro; } @@ -116,16 +116,48 @@ void MainWindow::greekText1() this->greekText(0); } - void MainWindow::greekText2() { this->greekText(1); } +void MainWindow::latinText(int index) +{ + QInputDialog inputDialog(this); + inputDialog.setWindowTitle(tr("Put a Latin (a-y) transcription in clipboard")); + inputDialog.setLabelText(tr("Latin text:")); + if (textset[index]) { + inputDialog.setTextValue(text[index].c_str()); + } + if (inputDialog.exec() != QDialog::Accepted) + return; + const QString value = inputDialog.textValue().trimmed(); + if (value.isEmpty()) + return; + string rest = value.toStdString(); + + text[index] = rest; + textset[index] = true; // activate clipboard + info("Stored."); // Success! + + infoLabel->setText(getClipboardInfos()); +} + +void MainWindow::latinText1() +{ + this->latinText(0); +} + +void MainWindow::latinText2() +{ + this->latinText(1); +} + + void MainWindow::about() { QMessageBox::about(this, tr("About Menu"), - tr("bibref is a tool that helps discovering internal references in the Bible." + tr("bibref is a tool that helps discovering internal references in the Bible." "
It aims at finding citations of the Septuagint" " in the Greek New Testament" " in a mechanical way.")); @@ -151,10 +183,18 @@ void MainWindow::createActions() greekText1Act->setStatusTip(tr("Define a Greek text and put its Latin transcription in clipboard 1")); connect(greekText1Act, &QAction::triggered, this, &MainWindow::greekText1); - greekText2Act = new QAction(tr("&Text 2"), this); + greekText2Act = new QAction(tr("Text 2"), this); greekText2Act->setStatusTip(tr("Define a Greek text and put its Latin transcription in clipboard 2")); connect(greekText2Act, &QAction::triggered, this, &MainWindow::greekText2); + latinText1Act = new QAction(tr("&Latin text 1"), this); + latinText1Act->setStatusTip(tr("Put a Latin (a-y) transcription in clipboard 1")); + connect(latinText1Act, &QAction::triggered, this, &MainWindow::latinText1); + + latinText2Act = new QAction(tr("Latin text 2"), this); + latinText2Act->setStatusTip(tr("Put a Latin (a-y) transcription in clipboard 2")); + connect(latinText2Act, &QAction::triggered, this, &MainWindow::latinText2); + aboutAct = new QAction(tr("&About"), this); aboutAct->setStatusTip(tr("Show the application's About box")); connect(aboutAct, &QAction::triggered, this, &MainWindow::about); @@ -164,6 +204,7 @@ void MainWindow::createActions() connect(aboutQtAct, &QAction::triggered, qApp, &QApplication::aboutQt); connect(aboutQtAct, &QAction::triggered, this, &MainWindow::aboutQt); } + void MainWindow::createMenus() { fileMenu = menuBar()->addMenu(tr("&File")); @@ -174,6 +215,8 @@ void MainWindow::createMenus() editMenu = menuBar()->addMenu(tr("&Edit")); editMenu->addAction(greekText1Act); editMenu->addAction(greekText2Act); + editMenu->addAction(latinText1Act); + editMenu->addAction(latinText2Act); helpMenu = menuBar()->addMenu(tr("&Help")); helpMenu->addAction(aboutAct); diff --git a/qt/mainwindow.h b/qt/mainwindow.h index ebdbc73d..ebc10d27 100644 --- a/qt/mainwindow.h +++ b/qt/mainwindow.h @@ -23,6 +23,8 @@ private slots: void addBibles(); void greekText1(); void greekText2(); + void latinText1(); + void latinText2(); void about(); void aboutQt(); @@ -30,6 +32,7 @@ private slots: void createActions(); void createMenus(); void greekText(int n); + void latinText(int n); QMenu *fileMenu; QMenu *editMenu; @@ -38,6 +41,8 @@ private slots: QAction *exitAct; QAction *greekText1Act; QAction *greekText2Act; + QAction *latinText1Act; + QAction *latinText2Act; QAction *aboutAct; QAction *aboutQtAct; QLabel *infoLabel;