summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/drivers/cswordlexiconmoduleinfo.cpp42
-rw-r--r--src/backend/drivers/cswordlexiconmoduleinfo.h30
-rw-r--r--src/backend/filters/osistohtml.cpp14
-rw-r--r--src/backend/managers/clanguagemgr.cpp3
-rw-r--r--src/backend/rendering/btinforendering.cpp4
-rw-r--r--src/backend/rendering/chtmlexportrendering.cpp6
-rw-r--r--src/bibletime.h5
-rw-r--r--src/bibletime_init.cpp8
-rw-r--r--src/frontend/btaboutdialog.cpp6
-rw-r--r--src/frontend/btmoduleindexdialog.cpp11
-rw-r--r--src/frontend/btwebenginepage.cpp1
-rw-r--r--src/frontend/display/bthtmlreaddisplay.cpp2
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.cpp7
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.cpp17
-rw-r--r--src/frontend/displaywindow/cplainwritewindow.cpp5
-rw-r--r--src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp5
-rw-r--r--src/frontend/searchdialog/csearchdialog.cpp11
-rw-r--r--src/frontend/settingsdialogs/btstandardworkstab.cpp6
-rw-r--r--src/util/directory.cpp9
19 files changed, 168 insertions, 24 deletions
diff --git a/src/backend/drivers/cswordlexiconmoduleinfo.cpp b/src/backend/drivers/cswordlexiconmoduleinfo.cpp
index d523fa0..5b1e704 100644
--- a/src/backend/drivers/cswordlexiconmoduleinfo.cpp
+++ b/src/backend/drivers/cswordlexiconmoduleinfo.cpp
@@ -11,6 +11,7 @@
#include <QFile>
#include <QDataStream>
+#include <QRegExp>
#include <QTextCodec>
#include <QDebug>
@@ -113,3 +114,44 @@ const QStringList &CSwordLexiconModuleInfo::entries() const {
return m_entries;
}
+
+void CSwordLexiconModuleInfo::testForStrongsKeys() {
+ auto & m = module();
+ m.setPosition(sword::TOP);
+ m.increment();
+ QString key = QString::fromUtf8(m.getKeyText());
+ QRegExp rx1("[GH][0-9]+");
+ if (rx1.exactMatch(key)) {
+ m_hasStrongsKeys = true;
+ m_hasLeadingStrongsLetter = true;
+ m_strongsDigitsLength = key.length() - 1;
+ } else {
+ QRegExp rx2("[0-9]+");
+ if (rx2.exactMatch(key)) {
+ m_hasStrongsKeys = true;
+ m_strongsDigitsLength = key.length();
+ }
+ }
+ return;
+}
+
+bool CSwordLexiconModuleInfo:: hasStrongsKeys() const {
+ return m_hasStrongsKeys;
+}
+
+QString CSwordLexiconModuleInfo::normalizeStrongsKey(const QString &key) const {
+
+ QRegExp rx("([GH]*)([0-9]+)");
+ if (! rx.exactMatch(key))
+ return key;
+ QString StrongsChar = rx.cap(1);
+ QString digits = rx.cap(2);
+
+ while (digits.length() < m_strongsDigitsLength)
+ digits = "0" +digits;
+ QString newKey = digits;
+ if (m_hasLeadingStrongsLetter)
+ newKey = StrongsChar + digits;
+ return newKey;
+}
+
diff --git a/src/backend/drivers/cswordlexiconmoduleinfo.h b/src/backend/drivers/cswordlexiconmoduleinfo.h
index bd69dcc..cffc2ba 100644
--- a/src/backend/drivers/cswordlexiconmoduleinfo.h
+++ b/src/backend/drivers/cswordlexiconmoduleinfo.h
@@ -26,7 +26,23 @@ class CSwordLexiconModuleInfo: public CSwordModuleInfo {
public: /* Methods: */
inline CSwordLexiconModuleInfo(sword::SWModule & module,
CSwordBackend & backend)
- : CSwordModuleInfo(module, backend, Lexicon) {}
+ : CSwordModuleInfo(module, backend, Lexicon),
+ m_hasStrongsKeys(false),
+ m_hasLeadingStrongsLetter(false),
+ m_strongsDigitsLength(0) {
+ testForStrongsKeys();
+ }
+
+ /**
+ Return true if this lexicon has Strong's keys
+ */
+ bool hasStrongsKeys() const;
+
+ /**
+ Takes a Strong's key string and formats it consistent
+ with the key strings of this module.
+ */
+ QString normalizeStrongsKey(const QString& key) const;
/**
This method returns the entries of the modules represented by this
@@ -46,6 +62,18 @@ class CSwordLexiconModuleInfo: public CSwordModuleInfo {
}
private: /* Fields: */
+
+ /**
+ See if module keys are consistent with Strong's references
+ and determine if keys start with "G" or "H" and the number
+ of digits in the keys.
+ */
+ void testForStrongsKeys();
+
+ bool m_hasStrongsKeys;
+ bool m_hasLeadingStrongsLetter;
+ int m_strongsDigitsLength;
+
/**
This is the list which caches the entres of the module.
*/
diff --git a/src/backend/filters/osistohtml.cpp b/src/backend/filters/osistohtml.cpp
index bca5670..cd06275 100644
--- a/src/backend/filters/osistohtml.cpp
+++ b/src/backend/filters/osistohtml.cpp
@@ -78,6 +78,11 @@ bool Filters::OsisToHtml::handleToken(sword::SWBuf &buf, const char *token, swor
buf.append("<div class=\"chapter\" ></div>"); //don't open a div here, that would lead to a broken XML structure
} else if (type == "x-p") {
buf.append("<br/>");
+ } else if (type == "paragraph") {
+ if (tag.getAttribute("sID"))
+ buf.append("<p>");
+ else if (tag.getAttribute("eID"))
+ buf.append("</p>");
} else {
buf.append("<div>");
}
@@ -285,7 +290,6 @@ bool Filters::OsisToHtml::handleToken(sword::SWBuf &buf, const char *token, swor
myUserData->suspendTextPassThru = false;
}
}
- // The <p> paragraph tag is handled by OSISHTMLHref
else if (!strcmp(tag.getName(), "reference")) { // <reference> tag
if (!tag.isEndTag() && !tag.isEmpty()) {
@@ -417,9 +421,11 @@ bool Filters::OsisToHtml::handleToken(sword::SWBuf &buf, const char *token, swor
}
}
else if (!strcmp(tag.getName(), "p")) {
- if (tag.isEmpty()) {
- buf.append("<p/>");
- }
+ if (tag.isEndTag())
+ buf.append("</p>");
+ else
+ buf.append("<p>");
+
}
// <q> quote
diff --git a/src/backend/managers/clanguagemgr.cpp b/src/backend/managers/clanguagemgr.cpp
index 5914336..bb080e5 100644
--- a/src/backend/managers/clanguagemgr.cpp
+++ b/src/backend/managers/clanguagemgr.cpp
@@ -1,3 +1,4 @@
+
/*********
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
@@ -415,7 +416,7 @@ void CLanguageMgr::init() {
//: Language name pt
m_langList.append( new Language("pt", "Portuguese", QObject::tr("Portuguese")) );
//: Language name pt_BR
- m_langList.append( new Language("pt_BR", "Brasilian Portuguese", QObject::tr("Brasilian Portuguese")) );//added by ourself
+ m_langList.append( new Language("pt_BR", "Brazilian Portuguese", QObject::tr("Brazilian Portuguese")) );//added by ourself
// m_langList.append( new Language("qu", "Quechua", QObject::tr("Quechua")) );
//: Language name qut
m_langList.append( new Language("qut", "Quich\u00e9, West Central", QObject::tr("Quich\u00e9, West Central")) );
diff --git a/src/backend/rendering/btinforendering.cpp b/src/backend/rendering/btinforendering.cpp
index c2e0efc..523022f 100644
--- a/src/backend/rendering/btinforendering.cpp
+++ b/src/backend/rendering/btinforendering.cpp
@@ -18,6 +18,7 @@
#include "../managers/cdisplaytemplatemgr.h"
#include "../managers/referencemanager.h"
#include "chtmlexportrendering.h"
+#include "../drivers/cswordlexiconmoduleinfo.h"
using namespace Rendering;
@@ -380,7 +381,8 @@ QString decodeStrongs(QString const & data) {
QString text;
if (module) {
QSharedPointer<CSwordKey> key(CSwordKey::createInstance(module));
- key->setKey((*it).mid(1)); // skip H or G (language sign), will have to change later if we have better modules
+ auto lexModule = qobject_cast<CSwordLexiconModuleInfo*>(module);
+ key->setKey(lexModule->normalizeStrongsKey(*it));
text = key->renderedText();
}
//if the module could not be found just display an empty lemma info
diff --git a/src/backend/rendering/chtmlexportrendering.cpp b/src/backend/rendering/chtmlexportrendering.cpp
index f9802db..e504b83 100644
--- a/src/backend/rendering/chtmlexportrendering.cpp
+++ b/src/backend/rendering/chtmlexportrendering.cpp
@@ -116,7 +116,7 @@ QString CHTMLExportRendering::renderEntry(KeyTreeItem const & i, CSwordKey * k)
.append("\"");
}
- if (key->isValid()) {
+ if (key->isValid() && i.key() == key->key()) {
key_renderedText = key->renderedText();
// if key was expanded
@@ -139,7 +139,7 @@ QString CHTMLExportRendering::renderEntry(KeyTreeItem const & i, CSwordKey * k)
key_renderedText = "<span class=\"inactive\">&#8212;</span>";
}
- if (m_filterOptions.headings) {
+ if (m_filterOptions.headings && key->isValid() && i.key() == key->key()) {
// only process EntryAttributes, do not render, this might destroy the EntryAttributes again
swModule.renderText(nullptr, -1, 0);
@@ -190,7 +190,7 @@ QString CHTMLExportRendering::renderEntry(KeyTreeItem const & i, CSwordKey * k)
entry.append(langAttr).append(isRTL ? " dir=\"rtl\">" : " dir=\"ltr\">");
//keys should normally be left-to-right, but this doesn't apply in all cases
- if(key->isValid())
+ if(key->isValid() && i.key() == key->key())
entry.append("<span class=\"entryname\" dir=\"ltr\">").append(entryLink(i, *mod_Itr)).append("</span>");
if (m_addText)
diff --git a/src/bibletime.h b/src/bibletime.h
index 038d58a..a15bd57 100644
--- a/src/bibletime.h
+++ b/src/bibletime.h
@@ -180,6 +180,11 @@ class BibleTime : public QMainWindow {
void clearMdiToolBars();
/**
+ * Returns the main window CKeyChooser
+ */
+ CKeyChooser* keyChooser() const;
+
+ /**
Displays a dialog which asks the user an unlock key for the given module and tries
to unlock the module. If an invalid unlock key is given, a warning message is
issued and the user is again asked for the key.
diff --git a/src/bibletime_init.cpp b/src/bibletime_init.cpp
index ceb14ff..b959d0d 100644
--- a/src/bibletime_init.cpp
+++ b/src/bibletime_init.cpp
@@ -32,6 +32,7 @@
#include "frontend/display/btfindwidget.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/btmodulechooserbar.h"
+#include "frontend/keychooser/ckeychooser.h"
#include "frontend/bookmarks/cbookmarkindex.h"
#include "frontend/settingsdialogs/cdisplaysettings.h"
#include "util/btassert.h"
@@ -313,6 +314,13 @@ void BibleTime::clearMdiToolBars() {
m_formatToolBar->clear();
}
+CKeyChooser* BibleTime::keyChooser() const {
+ BT_ASSERT(m_navToolBar);
+
+ CKeyChooser* keyChooser = m_navToolBar->findChild<CKeyChooser*>();
+ return keyChooser;
+}
+
void BibleTime::createMenuAndToolBar()
{
// Create menubar
diff --git a/src/frontend/btaboutdialog.cpp b/src/frontend/btaboutdialog.cpp
index 65d9b34..aa6ebbe 100644
--- a/src/frontend/btaboutdialog.cpp
+++ b/src/frontend/btaboutdialog.cpp
@@ -256,7 +256,7 @@ void BtAboutDialog::retranslateQtTab() {
content += "</p><p>";
content += tr("Qt is a cross-platform application and UI framework, created with C++ "
"language. It has been released under the LGPL license.");
- content += " " MAKE_LINK(content, "about:qt", tr("More info...")) "</p>";
+ content += " " MAKE_LINK(content, "http://qt", tr("More info...")) "</p>";
m_qtTab->setHtml(MAKE_HTML(m_qtTab, content));
}
@@ -284,10 +284,8 @@ void BtAboutDialog::retranslateLicenceTab() {
}
void BtAboutDialog::linkClicked(const QUrl &url) {
- if (url.scheme() == "about") {
- if (url.path() == "qt") {
+ if (url.host() == "qt") {
qApp->aboutQt();
- }
} else {
QDesktopServices::openUrl(url);
}
diff --git a/src/frontend/btmoduleindexdialog.cpp b/src/frontend/btmoduleindexdialog.cpp
index 8b70541..370ce42 100644
--- a/src/frontend/btmoduleindexdialog.cpp
+++ b/src/frontend/btmoduleindexdialog.cpp
@@ -64,10 +64,19 @@ bool BtModuleIndexDialog::indexAllModulesPrivate(const QList<CSwordModuleInfo*>
try {
m->buildIndex();
} catch (...) {
+ QString msg;
+ try {
+ throw;
+ } catch (std::exception const & e) {
+ msg = e.what();
+ } catch (...) {
+ msg = tr("<UNKNOWN EXCEPTION>");
+ }
+
message::showWarning(this,
tr("Indexing aborted"),
tr("An internal error occurred while building "
- "the index."));
+ "the index.") + "<br/><br/>" + msg);
success = false;
}
diff --git a/src/frontend/btwebenginepage.cpp b/src/frontend/btwebenginepage.cpp
index e2fd666..c818789 100644
--- a/src/frontend/btwebenginepage.cpp
+++ b/src/frontend/btwebenginepage.cpp
@@ -69,6 +69,7 @@ void BtWebEnginePage::javaScriptConsoleMessage(
BtWebEnginePage::BtWebEnginePage(QObject *parent)
:QWebPage(parent) {
settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
+ setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
}
void BtWebEnginePage::addJavaScriptObject(const QString &name, QObject *object) {
diff --git a/src/frontend/display/bthtmlreaddisplay.cpp b/src/frontend/display/bthtmlreaddisplay.cpp
index eace51f..fe1ae8c 100644
--- a/src/frontend/display/bthtmlreaddisplay.cpp
+++ b/src/frontend/display/bthtmlreaddisplay.cpp
@@ -244,7 +244,7 @@ void BtHtmlReadDisplay::setText( const QString& newText ) {
#endif
// Send text to the html viewer
- m_view->setHtml(jsText);
+ m_view->setHtml(jsText, QUrl("file://"));
this->currentSource = jsText;
}
diff --git a/src/frontend/displaywindow/cbiblereadwindow.cpp b/src/frontend/displaywindow/cbiblereadwindow.cpp
index 7789953..b9f8f20 100644
--- a/src/frontend/displaywindow/cbiblereadwindow.cpp
+++ b/src/frontend/displaywindow/cbiblereadwindow.cpp
@@ -408,12 +408,19 @@ void CBibleReadWindow::lookupSwordKey( CSwordKey* newKey ) {
}
void CBibleReadWindow::syncWindows() {
+ QMdiSubWindow * activeWindow = mdi()->activeSubWindow();
Q_FOREACH(QMdiSubWindow * const subWindow, mdi()->subWindowList()) {
CDisplayWindow* w = dynamic_cast<CDisplayWindow*>(subWindow->widget());
if (w && w->syncAllowed()) {
w->lookupKey( key()->key() );
}
}
+
+ // Fix problem with QWebEngineView::setHtml
+ // It set the focus of any updated window causing
+ // it to be the active window.
+ if (mdi()->activeSubWindow() != activeWindow)
+ mdi()->setActiveSubWindow(activeWindow);
}
void CBibleReadWindow::setupMainWindowToolBars() {
diff --git a/src/frontend/displaywindow/cdisplaywindow.cpp b/src/frontend/displaywindow/cdisplaywindow.cpp
index 1285205..ba8ec18 100644
--- a/src/frontend/displaywindow/cdisplaywindow.cpp
+++ b/src/frontend/displaywindow/cdisplaywindow.cpp
@@ -57,7 +57,12 @@ CDisplayWindow::CDisplayWindow(const QList<CSwordModuleInfo *> & modules, CMDIAr
m_popupMenu(nullptr),
m_displayWidget(nullptr),
m_history(nullptr) {
- setAttribute(Qt::WA_DeleteOnClose); //we want to destroy this window when it is closed
+
+ // Cannot delete on close. QMdiSubWindow and this window work
+ // as pairs. They must be deleted in a specific order.
+ // QMdiSubWindow handles this procedure.
+ //setAttribute(Qt::WA_DeleteOnClose);
+
m_actionCollection = new BtActionCollection(this);
setModules(modules);
@@ -288,7 +293,7 @@ void CDisplayWindow::reload(CSwordBackend::SetupChangedReason) {
lookup();
- m_actionCollection->readShortcuts("DisplayWindow shortcuts");
+ m_actionCollection->readShortcuts("Displaywindow shortcuts");
m_actionCollection->readShortcuts("Readwindow shortcuts");
emit sigModuleListSet(m_modules);
}
@@ -583,6 +588,12 @@ void CDisplayWindow::printAnchorWithText() {
}
void CDisplayWindow::setFocusKeyChooser() {
- keyChooser()->setFocus();
+ if (btConfig().sessionValue<bool>("GUI/showToolbarsInEachWindow", true)) {
+ keyChooser()->setFocus();
+ } else {
+ CKeyChooser* mainWinKeyChooser = btMainWindow()->keyChooser();
+ if (mainWinKeyChooser)
+ mainWinKeyChooser->setFocus();
+ }
}
diff --git a/src/frontend/displaywindow/cplainwritewindow.cpp b/src/frontend/displaywindow/cplainwritewindow.cpp
index b51339e..8d960db 100644
--- a/src/frontend/displaywindow/cplainwritewindow.cpp
+++ b/src/frontend/displaywindow/cplainwritewindow.cpp
@@ -263,8 +263,10 @@ void CPlainWriteWindow::insertKeyboardActions( BtActionCollection* const a) {
}
void CPlainWriteWindow::saveCurrentText() {
- if (key())
+ if (key()) {
+ m_writeDisplay->setModified(false);
saveCurrentText(key()->key());
+ }
}
@@ -303,6 +305,7 @@ void CPlainWriteWindow::beforeKeyChange() {
switch (message::showQuestion( this, tr("Save Text?"), tr("Save changed text?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) ) {
case QMessageBox::Yes: { //save the changes
+ m_writeDisplay->setModified(false); // Do before saveCurrentText to prevent recursion
saveCurrentText( thisWindowsKey );
break;
}
diff --git a/src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp b/src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp
index 98cd47f..8b5d02e 100644
--- a/src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp
+++ b/src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp
@@ -83,7 +83,10 @@ BtBibleKeyWidget::BtBibleKeyWidget(const CSwordBibleModuleInfo *mod,
setTabOrder(m_textbox, nullptr);
- m_dropDownButtons = new QWidget(nullptr);
+
+ // Using "this" instead of "nullptr" works around a Qt 5.9 bug, QTBUG-61213
+ m_dropDownButtons = new QWidget(this);
+
m_dropDownButtons->setWindowFlags(Qt::Popup);
m_dropDownButtons->setAttribute(Qt::WA_WindowPropagation);
m_dropDownButtons->setCursor(Qt::ArrowCursor);
diff --git a/src/frontend/searchdialog/csearchdialog.cpp b/src/frontend/searchdialog/csearchdialog.cpp
index ccefe9f..1057b43 100644
--- a/src/frontend/searchdialog/csearchdialog.cpp
+++ b/src/frontend/searchdialog/csearchdialog.cpp
@@ -168,10 +168,19 @@ void CSearchDialog::startSearch() {
try {
m_searcher.startSearch();
} catch (...) {
+ QString msg;
+ try {
+ throw;
+ } catch (std::exception const & e) {
+ msg = e.what();
+ } catch (...) {
+ msg = tr("<UNKNOWN EXCEPTION>");
+ }
+
message::showWarning(this,
tr("Search aborted"),
tr("An internal error occurred while executing "
- "your search."));
+ "your search.") + "<br/><br/>" + msg);
// Re-enable the dialog:
setEnabled(true);
setCursor(Qt::ArrowCursor);
diff --git a/src/frontend/settingsdialogs/btstandardworkstab.cpp b/src/frontend/settingsdialogs/btstandardworkstab.cpp
index 1190aa6..62c6278 100644
--- a/src/frontend/settingsdialogs/btstandardworkstab.cpp
+++ b/src/frontend/settingsdialogs/btstandardworkstab.cpp
@@ -15,6 +15,7 @@
#include <QLabel>
#include <QVBoxLayout>
#include "backend/config/btconfig.h"
+#include "backend/drivers/cswordlexiconmoduleinfo.h"
#include "backend/managers/cswordbackend.h"
#include "frontend/settingsdialogs/cswordsettings.h"
#include "util/tool.h"
@@ -72,11 +73,12 @@ BtStandardWorksTab::BtStandardWorksTab(CSwordSettingsPage *parent)
break;
case CSwordModuleInfo::Lexicon: {
bool inserted = false;
- if (m->has(CSwordModuleInfo::HebrewDef)) {
+ auto lexModule = qobject_cast<CSwordLexiconModuleInfo const *>(m);
+ if (m->has(CSwordModuleInfo::HebrewDef) && lexModule->hasStrongsKeys()) {
m_standardHebrewStrongsLexiconCombo->addItem(modDescript);
inserted = true;
}
- if (m->has(CSwordModuleInfo::GreekDef)) {
+ if (m->has(CSwordModuleInfo::GreekDef) && lexModule->hasStrongsKeys()) {
m_standardGreekStrongsLexiconCombo->addItem(modDescript);
inserted = true;
}
diff --git a/src/util/directory.cpp b/src/util/directory.cpp
index 53086ec..64eb624 100644
--- a/src/util/directory.cpp
+++ b/src/util/directory.cpp
@@ -18,6 +18,9 @@
#include <QFileInfoList>
#include <QLocale>
#include "btassert.h"
+#ifdef Q_OS_WIN32
+#include <windows.h>
+#endif
namespace util {
@@ -229,6 +232,12 @@ bool initDirectoryCache() {
return false;
}
}
+#elif defined Q_OS_WIN32
+#define BUFSIZE 4096
+ wchar_t homeDir[BUFSIZE];
+ GetEnvironmentVariable(TEXT("APPDATA"), homeDir, BUFSIZE);
+ QString qHomeDir = QString::fromWCharArray(homeDir);
+ cachedUserHomeDir.reset(new QDir(qHomeDir));
#else
cachedUserHomeDir.reset(new QDir(qgetenv("HOME")));
#endif