Repository: eliranwong/UniqueBible (language: python)

Issue:
Ver 25.75; Add Copy with reference in context menu



Discussion / hints:

Fix patch:
diff --git a/UniqueBibleAppVersion.txt b/UniqueBibleAppVersion.txt
index 148844e384..7dca851a8e 100644
--- a/UniqueBibleAppVersion.txt
+++ b/UniqueBibleAppVersion.txt
@@ -1,1 +1,1 @@
-25.74
+25.75
diff --git a/gui/WebEngineView.py b/gui/WebEngineView.py
index 6eec9e44b0..072a8ca918 100644
--- a/gui/WebEngineView.py
+++ b/gui/WebEngineView.py
@@ -223,6 +223,11 @@ def addMenuActions(self):
         copyText.triggered.connect(self.copySelectedText)
         subMenu.addAction(copyText)
 
+        copyText = QAction(self)
+        copyText.setText(config.thisTranslation["textWithReference"])
+        copyText.triggered.connect(self.copySelectedTextWithReference)
+        subMenu.addAction(copyText)
+
         copyReferences = QAction(self)
         copyReferences.setText(config.thisTranslation["bibleReferences"])
         copyReferences.triggered.connect(self.copyAllReferences)
@@ -680,6 +685,28 @@ def copySelectedText(self):
         else:
             self.page().triggerAction(self.page().Copy)
 
+    def copySelectedTextWithReference(self):
+        if not self.selectedText():
+            self.messageNoSelection()
+        else:
+            selectedText = self.selectedText().strip()
+            verse = config.mainV
+            lastVerse = None
+            try:
+                firstVerse = re.findall(r'\d+', selectedText)[0]
+                lastVerse = re.findall(r'\d+', selectedText)[-1]
+                if firstVerse:
+                    verse = firstVerse
+                    if int(firstVerse) == int(lastVerse):
+                        lastVerse = None
+            except:
+                pass
+            reference = self.parent.parent.bcvToVerseReference(config.mainB, config.mainC, verse)
+            if lastVerse:
+                reference += "-" + lastVerse
+            text = "{0} ({1})\n{2}".format(reference, config.mainText, selectedText)
+            QApplication.clipboard().setText(text)
+
     def copyHtmlCode(self):
         #self.page().runJavaScript("document.documentElement.outerHTML", 0, self.copyHtmlToClipboard)
         self.page().toHtml(self.copyHtmlToClipboard)
diff --git a/lang/language_de.py b/lang/language_de.py
index fb9e299661..0db034b536 100644
--- a/lang/language_de.py
+++ b/lang/language_de.py
@@ -746,4 +746,5 @@
     "selectAll": "Alles auswählen",
     "selectNone": "Keine auswählen",
     "displayCmdOutput": "Ausgabe des Befehls CMD anzeigen",
+    "textWithReference": "Text mit Referenz",
 }
\ No newline at end of file
diff --git a/lang/language_el.py b/lang/language_el.py
index b2012a73f8..4bda2978dd 100644
--- a/lang/language_el.py
+++ b/lang/language_el.py
@@ -746,4 +746,5 @@
     "selectAll": "Επιλογή όλων:",
     "selectNone": "Επιλέξτε Χωρίς.",
     "displayCmdOutput": "Εμφάνιση εξόδου της εντολής CMD",
+    "textWithReference": "Κείμενο με αναφορά:",
 }
\ No newline at end of file
diff --git a/lang/language_en_GB.py b/lang/language_en_GB.py
index 8db74a711c..349bc95221 100644
--- a/lang/language_en_GB.py
+++ b/lang/language_en_GB.py
@@ -746,4 +746,5 @@
     "selectAll": "Select All",
     "selectNone": "Select None",
     "displayCmdOutput": "Display output of CMD command",
+    "textWithReference": "Text with reference",
 }
\ No newline at end of file
diff --git a/lang/language_en_US.py b/lang/language_en_US.py
index 6c70bebed1..3536f41020 100644
--- a/lang/language_en_US.py
+++ b/lang/language_en_US.py
@@ -746,4 +746,5 @@
     "selectAll": "Select All",
     "selectNone": "Select None",
     "displayCmdOutput": "Display output of CMD command",
+    "textWithReference": "Text with reference",
 }
\ No newline at end of file
diff --git a/lang/language_es.py b/lang/language_es.py
index f4f27fca04..86087f0e8c 100644
--- a/lang/language_es.py
+++ b/lang/language_es.py
@@ -746,4 +746,5 @@
     "selectAll": "Seleccionar todo",
     "selectNone": "Seleccione Ninguno",
     "displayCmdOutput": "Mostrar salida del mandato CMD",
+    "textWithReference": "Texto con referencia",
 }
\ No newline at end of file
diff --git a/lang/language_fr.py b/lang/language_fr.py
index d3d7e001c4..0ea1ae055b 100644
--- a/lang/language_fr.py
+++ b/lang/language_fr.py
@@ -746,4 +746,5 @@
     "selectAll": "Sélectionner tout",
     "selectNone": "Sélectionner Aucun",
     "displayCmdOutput": "Affichage de la sortie de la commande CMD",
+    "textWithReference": "Texte avec référence",
 }
\ No newline at end of file
diff --git a/lang/language_hi.py b/lang/language_hi.py
index e9b714f1fc..a0181cdc59 100644
--- a/lang/language_hi.py
+++ b/lang/language_hi.py
@@ -746,4 +746,5 @@
     "selectAll": "सभी को चुनें",
     "selectNone": "कुछ नहीं चुनें",
     "displayCmdOutput": "सीएमडी कमांड के आउटपुट को प्रदर्शित करें",
+    "textWithReference": "संदर्भ के साथ पाठ",
 }
\ No newline at end of file
diff --git a/lang/language_it.py b/lang/language_it.py
index b26a9f34cd..321e6be924 100644
--- a/lang/language_it.py
+++ b/lang/language_it.py
@@ -746,4 +746,5 @@
     "selectAll": "Seleziona tutto",
     "selectNone": "Selezionare Nessuno",
     "displayCmdOutput": "Visualizza output del comando CMD",
+    "textWithReference": "Testo con riferimento",
 }
\ No newline at end of file
diff --git a/lang/language_ja.py b/lang/language_ja.py
index 6eb1aee760..701e42144d 100644
--- a/lang/language_ja.py
+++ b/lang/language_ja.py
@@ -746,4 +746,5 @@
     "selectAll": "すべて選択",
     "selectNone": "なしを選択",
     "displayCmdOutput": "CMD コマンドの出力の表示",
+    "textWithReference": "参照のあるテキスト",
 }
\ No newline at end of file
diff --git a/lang/language_ko.py b/lang/language_ko.py
index 51fc872e86..047fd99077 100644
--- a/lang/language_ko.py
+++ b/lang/language_ko.py
@@ -746,4 +746,5 @@
     "selectAll": "모두 선택",
     "selectNone": "없음 선택",
     "displayCmdOutput": "CMD 명령의 출력 표시",
+    "textWithReference": "참조 텍스트",
 }
\ No newline at end of file
diff --git a/lang/language_ml.py b/lang/language_ml.py
index 0c2e437f15..f8d28b6b43 100644
--- a/lang/language_ml.py
+++ b/lang/language_ml.py
@@ -746,4 +746,5 @@
     "selectAll": "എല്ലാം തെരഞ്ഞെടുക്കുക",
     "selectNone": "ഒന്നുമല്ല തെരഞ്ഞെടുക്കുക",
     "displayCmdOutput": "CMD ആജ്ഞ പ്രദര്ശിപ്പിക്കുക",
+    "textWithReference": "റഫറൻസ് കൂടിയ പദാവലി",
 }
\ No newline at end of file
diff --git a/lang/language_ro.py b/lang/language_ro.py
index 906064080b..12b016678c 100644
--- a/lang/language_ro.py
+++ b/lang/language_ro.py
@@ -746,4 +746,5 @@
     "selectAll": "Selectare tot",
     "selectNone": "Selectare Fără",
     "displayCmdOutput": "Afişare ieşire comandă CMD",
+    "textWithReference": "Text cu referinţă",
 }
\ No newline at end of file
diff --git a/lang/language_ru.py b/lang/language_ru.py
index 1250eb81cd..01e924d32d 100644
--- a/lang/language_ru.py
+++ b/lang/language_ru.py
@@ -746,4 +746,5 @@
     "selectAll": "Выбрать все",
     "selectNone": "Выберите Нет",
     "displayCmdOutput": "Показать вывод команды CMD",
+    "textWithReference": "Текст со ссылкой",
 }
\ No newline at end of file
diff --git a/lang/language_zh_HANS.py b/lang/language_zh_HANS.py
index dc6ee77ead..41d3d27785 100644
--- a/lang/language_zh_HANS.py
+++ b/lang/language_zh_HANS.py
@@ -746,4 +746,5 @@
     "selectAll": "全部选中",
     "selectNone": "选择无",
     "displayCmdOutput": "显示 CMD 命令的输出",
+    "textWithReference": "带有引用的文本",
 }
\ No newline at end of file
diff --git a/lang/language_zh_HANT.py b/lang/language_zh_HANT.py
index 9f83131d37..374d4bdd1b 100644
--- a/lang/language_zh_HANT.py
+++ b/lang/language_zh_HANT.py
@@ -746,4 +746,5 @@
     "selectAll": "全選",
     "selectNone": "選取無",
     "displayCmdOutput": "顯示 CMD 指令的輸出",
+    "textWithReference": "參照文字",
 }
\ No newline at end of file
diff --git a/patches.txt b/patches.txt
index 5292c29f1a..65fd1bbd2a 100644
--- a/patches.txt
+++ b/patches.txt
@@ -885,6 +885,25 @@
 (25.74, "file", "util/TextCommandParser.py")
 (25.74, "file", "util/ThirdParty.py")
 (25.74, "file", "util/UpdateUtil.py")
-(25.74, "file", "latest_changes.txt")
-(25.74, "file", "patches.txt")
-(25.74, "file", "UniqueBibleAppVersion.txt")
+(25.75, "file", "gui/WebEngineView.py")
+(25.75, "file", "lang/language_de.py")
+(25.75, "file", "lang/language_el.py")
+(25.75, "file", "lang/language_en_GB.py")
+(25.75, "file", "lang/language_en_US.py")
+(25.75, "file", "lang/language_es.py")
+(25.75, "file", "lang/language_fr.py")
+(25.75, "file", "lang/language_hi.py")
+(25.75, "file", "lang/language_it.py")
+(25.75, "file", "lang/language_ja.py")
+(25.75, "file", "lang/language_ko.py")
+(25.75, "file", "lang/language_ml.py")
+(25.75, "file", "lang/language_ro.py")
+(25.75, "file", "lang/language_ru.py")
+(25.75, "file", "lang/language_zh_HANS.py")
+(25.75, "file", "lang/language_zh_HANT.py")
+(25.75, "file", "util/LanguageUtil.py")
+(25.75, "file", "util/TextCommandParser.py")
+(25.75, "file", "util/Translator.py")
+(25.75, "file", "UniqueBibleAppVersion.txt")
+(25.75, "file", "latest_changes.txt")
+(25.75, "file", "patches.txt")
diff --git a/util/LanguageUtil.py b/util/LanguageUtil.py
index 511f27f592..2ab1128c60 100644
--- a/util/LanguageUtil.py
+++ b/util/LanguageUtil.py
@@ -230,7 +230,7 @@ def translateWord(text, code):
             print("Error executing: " + str(e))
     else:
         # printCodesSupportedLanguages()
-        addLanguageStringToAllFiles("displayCmdOutput", "Display output of CMD command")
+        addLanguageStringToAllFiles("textWithReference", "Text with reference")
         # createNewLanguageFile("ro")
         # validateLanguageFileSizes()
 
diff --git a/util/TextCommandParser.py b/util/TextCommandParser.py
index f2b35042ba..810024a990 100644
--- a/util/TextCommandParser.py
+++ b/util/TextCommandParser.py
@@ -1258,7 +1258,7 @@ def readBible(self, command, source):
                         playlist = self.getBiblePlaylist(command, text, folder)
                 elif count == 1:
                     text, reference = self.splitCommand(command)
-                    playlist = self.getBiblePlaylist(command, text, folder)
+                    playlist = self.getBiblePlaylist(reference, text, folder)
                 elif count == 2:
                     text, commandList = self.splitCommand(command)
                     reference, folder = self.splitCommand(commandList)
diff --git a/util/Translator.py b/util/Translator.py
index 4834329dd9..ad59db3bd6 100644
--- a/util/Translator.py
+++ b/util/Translator.py
@@ -25,7 +25,7 @@ def authenticate(self):
                     authenticator=authenticator
                 )
                 language_translator.set_service_url(config.myIBMWatsonUrl)
-                #print(language_translator)
+                # print(language_translator)
                 self.language_translator = language_translator
             else:
                 self.language_translator = None


Test patch:
diff --git a/latest_changes.txt b/latest_changes.txt
index 97026d8bd8..5d452e0f6b 100644
--- a/latest_changes.txt
+++ b/latest_changes.txt
@@ -1,9 +1,12 @@
+Major change in version 25.75:
+* Add Copy with reference in context menu
+
 Major changes in version 25.74:
 * Add ability to read multiple chapters
-    * READBIBLE:::Matt 1-28
-    * READBIBLE:::KJV:::Matt 1, Mark 1, Luke 1, John 1
-    * READBIBLE:::KJV:::Matt 1-5
-    * READBIBLE:::KJV:::1 Cor 13, Rev 1:::soft-music
+- READBIBLE:::Matt 1-28
+- READBIBLE:::KJV:::Matt 1, Mark 1, Luke 1, John 1
+- READBIBLE:::KJV:::Matt 1-5
+- READBIBLE:::KJV:::1 Cor 13, Rev 1:::soft-music
 * Add more info to InfoDialog
 
 Major changes in version 25.73: