summaryrefslogtreecommitdiff
path: root/src/frontend/settingsdialogs
diff options
context:
space:
mode:
authorTeus Benschop <teusjannette@gmail.com>2017-10-06 12:24:31 +0200
committerTeus Benschop <teusjannette@gmail.com>2017-10-06 12:24:31 +0200
commit90d2181239761f8950b95768d3b037843e9e8b50 (patch)
tree6cc667ab420cc04029de2de7e361d2305e214595 /src/frontend/settingsdialogs
parent1ea03c0fce8066c1e22188447b4a6ca4dcef1201 (diff)
New upstream version 2.11.0
Diffstat (limited to 'src/frontend/settingsdialogs')
-rw-r--r--src/frontend/settingsdialogs/btconfigdialog.cpp87
-rw-r--r--src/frontend/settingsdialogs/btconfigdialog.h94
-rw-r--r--src/frontend/settingsdialogs/btfontchooserwidget.cpp51
-rw-r--r--src/frontend/settingsdialogs/btfontchooserwidget.h11
-rw-r--r--src/frontend/settingsdialogs/btfontsettings.cpp31
-rw-r--r--src/frontend/settingsdialogs/btfontsettings.h8
-rw-r--r--src/frontend/settingsdialogs/btlanguagesettings.cpp139
-rw-r--r--src/frontend/settingsdialogs/btlanguagesettings.h50
-rw-r--r--src/frontend/settingsdialogs/btshortcutsdialog.cpp9
-rw-r--r--src/frontend/settingsdialogs/btshortcutsdialog.h4
-rw-r--r--src/frontend/settingsdialogs/btshortcutseditor.cpp277
-rw-r--r--src/frontend/settingsdialogs/btshortcutseditor.h20
-rw-r--r--src/frontend/settingsdialogs/btstandardworkstab.cpp25
-rw-r--r--src/frontend/settingsdialogs/btstandardworkstab.h2
-rw-r--r--src/frontend/settingsdialogs/bttextfilterstab.cpp7
-rw-r--r--src/frontend/settingsdialogs/bttextfilterstab.h2
-rw-r--r--src/frontend/settingsdialogs/cacceleratorsettings.cpp59
-rw-r--r--src/frontend/settingsdialogs/cacceleratorsettings.h15
-rw-r--r--src/frontend/settingsdialogs/cconfigurationdialog.cpp24
-rw-r--r--src/frontend/settingsdialogs/cconfigurationdialog.h6
-rw-r--r--src/frontend/settingsdialogs/cdisplaysettings.cpp160
-rw-r--r--src/frontend/settingsdialogs/cdisplaysettings.h22
-rw-r--r--src/frontend/settingsdialogs/clistwidget.cpp2
-rw-r--r--src/frontend/settingsdialogs/clistwidget.h6
-rw-r--r--src/frontend/settingsdialogs/cswordsettings.cpp5
-rw-r--r--src/frontend/settingsdialogs/cswordsettings.h7
26 files changed, 600 insertions, 523 deletions
diff --git a/src/frontend/settingsdialogs/btconfigdialog.cpp b/src/frontend/settingsdialogs/btconfigdialog.cpp
new file mode 100644
index 0000000..7e971e9
--- /dev/null
+++ b/src/frontend/settingsdialogs/btconfigdialog.cpp
@@ -0,0 +1,87 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2016 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "btconfigdialog.h"
+
+#include <QDialogButtonBox>
+#include <QFrame>
+#include <QHBoxLayout>
+#include <QListWidget>
+#include <QStackedWidget>
+#include <QVBoxLayout>
+#include "util/btassert.h"
+#include "util/btconnect.h"
+
+
+BtConfigDialog::BtConfigDialog(QWidget * const parent,
+ Qt::WindowFlags const flags)
+ : QDialog(parent, flags)
+ , m_contentsList(new QListWidget(this))
+ , m_pageWidget(new QStackedWidget(this))
+{
+ QHBoxLayout * const mainLayout = new QHBoxLayout(this);
+
+ m_contentsList->setViewMode(QListView::IconMode);
+ m_contentsList->setMovement(QListView::Static);
+ BT_CONNECT(m_contentsList, &QListWidget::currentRowChanged,
+ m_pageWidget, &QStackedWidget::setCurrentIndex);
+ mainLayout->addWidget(m_contentsList);
+
+ m_pageLayout = new QVBoxLayout;
+ mainLayout->addLayout(m_pageLayout);
+
+ m_pageWidget->setSizePolicy(QSizePolicy::MinimumExpanding,
+ QSizePolicy::MinimumExpanding);
+ m_pageLayout->addWidget(m_pageWidget);
+}
+
+void BtConfigDialog::addPage(Page * const pageWidget) {
+ m_pageWidget->addWidget(pageWidget);
+
+ QListWidgetItem * const item = new QListWidgetItem(m_contentsList);
+ item->setTextAlignment(Qt::AlignHCenter);
+ item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ pageWidget->setListWidgetItem(item);
+
+ int const thisItemWidth = m_contentsList->visualItemRect(item).width();
+ if (m_maxItemWidth < thisItemWidth) {
+ // Reset the list width:
+ m_maxItemWidth = thisItemWidth;
+ m_contentsList->setFixedWidth(
+ m_maxItemWidth + (m_contentsList->frameWidth() * 2));
+ }
+
+ // All items should have the same width:
+ for (int i = 0; i < m_contentsList->count(); ++i)
+ m_contentsList->item(i)->setSizeHint(
+ QSize(m_maxItemWidth,
+ m_contentsList->visualItemRect(
+ m_contentsList->item(i)).height()));
+
+ setCurrentPage(m_contentsList->row(item));
+}
+
+void BtConfigDialog::setButtonBox(QDialogButtonBox * const box) {
+ BT_ASSERT(box);
+ BT_ASSERT(m_pageLayout->count() == 1); // Only m_pageWidget in layout
+
+ // First add a horizontal ruler:
+ QFrame * const buttonBoxRuler = new QFrame(this);
+ buttonBoxRuler->setGeometry(QRect(1, 1, 1, 3));
+ buttonBoxRuler->setFrameShape(QFrame::HLine);
+ buttonBoxRuler->setFrameShadow(QFrame::Sunken);
+ buttonBoxRuler->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ m_pageLayout->addWidget(buttonBoxRuler);
+
+ // Add button box:
+ m_pageLayout->addWidget(box);
+}
+
+void BtConfigDialog::setCurrentPage(int const newIndex)
+{ m_contentsList->setCurrentRow(newIndex); }
diff --git a/src/frontend/settingsdialogs/btconfigdialog.h b/src/frontend/settingsdialogs/btconfigdialog.h
new file mode 100644
index 0000000..ae096f3
--- /dev/null
+++ b/src/frontend/settingsdialogs/btconfigdialog.h
@@ -0,0 +1,94 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2016 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTCONFIGDIALOG_H
+#define BTCONFIGDIALOG_H
+
+#include <QDialog>
+
+#include <QIcon>
+#include <QListWidgetItem>
+
+
+class QDialogButtonBox;
+class QStackedWidget;
+class QVBoxLayout;
+
+/**
+* Base class for configuration dialogs. A dialog which has a page chooser (icons
+* + text) at the left, widget pages and a buttonbox.
+*
+* Usage: add BtConfigPage pages with addPage(), add a button box with addButtonBox().
+* Connect the button box signals. Use setAttribute(Qt::WA_DeleteOnClose) if you want
+* an auto-destroying window.
+*/
+class BtConfigDialog : public QDialog {
+
+public: /* Types: */
+
+ /** Base class for configuration dialog pages. */
+ class Page : public QWidget {
+
+ friend class BtConfigDialog;
+
+ public: /* Methods: */
+
+ inline Page(QIcon const & icon, QWidget * const parent)
+ : QWidget(parent)
+ , m_icon(icon)
+ {}
+
+ inline void setHeaderText(QString const & headerText) {
+ m_headerText = headerText;
+ if (m_listWidgetItem)
+ m_listWidgetItem->setText(headerText);
+ }
+
+ private: /* Methods: */
+
+ void setListWidgetItem(QListWidgetItem * const item) noexcept {
+ m_listWidgetItem = item;
+ item->setIcon(m_icon);
+ item->setText(m_headerText);
+ }
+
+ private: /* Fields: */
+
+ QIcon const m_icon;
+ QString m_headerText;
+ QListWidgetItem * m_listWidgetItem = nullptr;
+
+ };
+
+public: /* Methods: */
+
+ BtConfigDialog(QWidget * const parent = nullptr,
+ Qt::WindowFlags const flags = 0);
+
+ /** Adds a BtConfigPage to the paged widget stack. The new page will be the current page.*/
+ void addPage(Page * const pageWidget);
+
+ /** Adds a button box to the lower edge of the dialog. */
+ void setButtonBox(QDialogButtonBox * const buttonBox);
+
+ /** Changes the current page using the given index number. */
+ void setCurrentPage(int const newIndex);
+
+private: /* Fields: */
+
+ QListWidget * const m_contentsList;
+ QStackedWidget * const m_pageWidget;
+ QVBoxLayout * m_pageLayout;
+ int m_maxItemWidth = 0;
+
+};
+
+#endif
diff --git a/src/frontend/settingsdialogs/btfontchooserwidget.cpp b/src/frontend/settingsdialogs/btfontchooserwidget.cpp
index 7fcf6b5..9e3051c 100644
--- a/src/frontend/settingsdialogs/btfontchooserwidget.cpp
+++ b/src/frontend/settingsdialogs/btfontchooserwidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,24 +15,24 @@
#include <QLabel>
#include <QListWidget>
#include <QListWidgetItem>
-#include <QWebSettings>
-#include <QWebView>
+#include "frontend/btwebengineview.h"
#include "frontend/settingsdialogs/clistwidget.h"
+#include "util/btconnect.h"
namespace {
-class BtFontPreviewWebView: public QWebView {
+class BtFontPreviewWebView: public BtWebEngineView {
public: /* Methods: */
- inline BtFontPreviewWebView(QWidget *parent = 0)
- : QWebView(parent)
+ inline BtFontPreviewWebView(QWidget *parent = nullptr)
+ : BtWebEngineView(parent)
{
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
}
- virtual inline QSize sizeHint() const {
+ inline QSize sizeHint() const override {
return QSize(100, 100);
}
@@ -100,30 +100,24 @@ void BtFontChooserWidget::retranslateUi() {
}
void BtFontChooserWidget::connectListWidgets() {
- bool ok = connect(
- m_fontListWidget,
- SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
- this,
- SLOT(fontChanged(QListWidgetItem *, QListWidgetItem *)));
- Q_ASSERT(ok);
-
- ok = connect(
+ BT_CONNECT(m_fontListWidget,
+ SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
+ this,
+ SLOT(fontChanged(QListWidgetItem *, QListWidgetItem *)));
+ BT_CONNECT(
m_styleListWidget,
SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
this,
SLOT(styleChanged(QListWidgetItem *, QListWidgetItem *)));
- Q_ASSERT(ok);
-
- ok = connect(
+ BT_CONNECT(
m_sizeListWidget,
SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
this,
SLOT(sizeChanged(QListWidgetItem *, QListWidgetItem *)));
- Q_ASSERT(ok);
}
void BtFontChooserWidget::fontChanged(QListWidgetItem* current, QListWidgetItem* /*previous*/) {
- if (current == 0)
+ if (current == nullptr)
return;
const QString fontFamily = current->text();
@@ -136,9 +130,9 @@ void BtFontChooserWidget::fontChanged(QListWidgetItem* current, QListWidgetItem*
void BtFontChooserWidget::loadFonts() {
m_fontListWidget->clear();
QFontDatabase database;
- Q_FOREACH (const QString &font, database.families()) {
+ Q_FOREACH(QString const & font, database.families())
m_fontListWidget->addItem(font);
- }
+
// This triggers loading the styles for the first font
m_fontListWidget->setCurrentRow(0);
}
@@ -159,9 +153,8 @@ void BtFontChooserWidget::loadSizes(const QString& font, const QString& style) {
// Put new values into listWidget
m_sizeListWidget->clear();
QFontDatabase database;
- Q_FOREACH (int size, database.pointSizes(font, style)) {
+ Q_FOREACH(int const size, database.pointSizes(font, style))
m_sizeListWidget->addItem(QString::number(size));
- }
restoreListWidgetValue(m_sizeListWidget, saveText);
}
@@ -220,9 +213,9 @@ QString BtFontChooserWidget::saveListWidgetValue(QListWidget* listWidget) {
}
void BtFontChooserWidget::setFont(const QFont& font) {
- disconnect(m_fontListWidget, 0, 0, 0);
- disconnect(m_styleListWidget, 0, 0, 0);
- disconnect(m_sizeListWidget, 0, 0, 0);
+ disconnect(m_fontListWidget, nullptr, nullptr, nullptr);
+ disconnect(m_styleListWidget, nullptr, nullptr, nullptr);
+ disconnect(m_sizeListWidget, nullptr, nullptr, nullptr);
// set the font
m_font = font;
@@ -256,7 +249,7 @@ void BtFontChooserWidget::setSampleText(const QString& htmlText) {
}
void BtFontChooserWidget::sizeChanged(QListWidgetItem* current, QListWidgetItem* /*previous*/) {
- if (current == 0)
+ if (current == nullptr)
return;
m_font.setPointSize(m_sizeListWidget->currentItem()->text().toInt());
@@ -270,7 +263,7 @@ QSize BtFontChooserWidget::sizeHint() const {
}
void BtFontChooserWidget::styleChanged(QListWidgetItem* current, QListWidgetItem* /*previous*/) {
- if (current == 0)
+ if (current == nullptr)
return;
QString styleString = current->text();
diff --git a/src/frontend/settingsdialogs/btfontchooserwidget.h b/src/frontend/settingsdialogs/btfontchooserwidget.h
index eba5607..078fd89 100644
--- a/src/frontend/settingsdialogs/btfontchooserwidget.h
+++ b/src/frontend/settingsdialogs/btfontchooserwidget.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,7 +22,7 @@ class CListWidget;
class QListWidget;
class QListWidgetItem;
class QString;
-class QWebView;
+class BtWebEngineView;
class BtFontChooserWidget : public QFrame {
@@ -30,13 +30,12 @@ class BtFontChooserWidget : public QFrame {
public: /* Methods: */
- BtFontChooserWidget(QWidget *parent = 0);
+ BtFontChooserWidget(QWidget *parent = nullptr);
void setFont(const QFont &font);
void setSampleText(const QString &text);
- // Inherited from QWidget:
- virtual QSize sizeHint() const;
+ QSize sizeHint() const override;
signals:
@@ -72,7 +71,7 @@ class BtFontChooserWidget : public QFrame {
QLabel *m_fontSizeLabel;
CListWidget *m_sizeListWidget;
- QWebView *m_fontPreview;
+ BtWebEngineView *m_fontPreview;
QString m_htmlText;
QFont m_font;
diff --git a/src/frontend/settingsdialogs/btfontsettings.cpp b/src/frontend/settingsdialogs/btfontsettings.cpp
index 57a8aba..77aad3f 100644
--- a/src/frontend/settingsdialogs/btfontsettings.cpp
+++ b/src/frontend/settingsdialogs/btfontsettings.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,24 +20,20 @@
#include "bibletimeapp.h"
#include "frontend/settingsdialogs/btfontchooserwidget.h"
#include "frontend/settingsdialogs/cconfigurationdialog.h"
+#include "util/btconnect.h"
#include "util/cresmgr.h"
-#include "util/geticon.h"
#include "util/tool.h"
-// Sword includes:
-#include <localemgr.h>
-#include <swlocale.h>
-
BtFontSettingsPage::BtFontSettingsPage(CConfigurationDialog *parent)
- : BtConfigDialog::Page(util::getIcon(CResMgr::settings::fonts::icon), parent)
+ : BtConfigDialog::Page(CResMgr::settings::fonts::icon(), parent)
{
m_languageLabel = new QLabel(this);
m_languageComboBox = new QComboBox(this);
m_languageLabel->setBuddy(m_languageComboBox);
m_languageCheckBox = new QCheckBox(this);
- connect(m_languageCheckBox, SIGNAL(toggled(bool)),
- this, SLOT(useOwnFontClicked(bool)) );
+ BT_CONNECT(m_languageCheckBox, SIGNAL(toggled(bool)),
+ this, SLOT(useOwnFontClicked(bool)) );
QHBoxLayout *hLayout = new QHBoxLayout;
@@ -47,7 +43,7 @@ BtFontSettingsPage::BtFontSettingsPage(CConfigurationDialog *parent)
hLayout->addWidget(m_languageCheckBox);
CLanguageMgr::LangMap langMap = CLanguageMgr::instance()->availableLanguages();
- typedef CLanguageMgr::Language L;
+ using L = CLanguageMgr::Language;
for (CLanguageMgr::LangMapIterator it = langMap.constBegin();
it != langMap.constEnd();
it++)
@@ -64,7 +60,7 @@ BtFontSettingsPage::BtFontSettingsPage(CConfigurationDialog *parent)
for (FontMap::ConstIterator it = m_fontMap.constBegin(); it != m_fontMap.constEnd(); ++it) {
const QString &k = it.key();
if (m_fontMap[k].first) { // show font icon
- m_languageComboBox->addItem(util::getIcon("fonts.svg"), k);
+ m_languageComboBox->addItem(CResMgr::settings::fonts::icon(), k);
} else { // don't show icon for font
m_languageComboBox->addItem(k);
}
@@ -79,10 +75,10 @@ BtFontSettingsPage::BtFontSettingsPage(CConfigurationDialog *parent)
*/
// m_fontChooser->setSampleText("SOMETHING");
- connect(m_fontChooser, SIGNAL(fontSelected(const QFont&)),
- this, SLOT(newDisplayWindowFontSelected(const QFont&)));
- connect(m_languageComboBox, SIGNAL(activated(const QString&)),
- this, SLOT(newDisplayWindowFontAreaSelected(const QString&)));
+ BT_CONNECT(m_fontChooser, SIGNAL(fontSelected(QFont const &)),
+ this, SLOT(newDisplayWindowFontSelected(QFont const &)));
+ BT_CONNECT(m_languageComboBox, SIGNAL(activated(QString const &)),
+ this, SLOT(newDisplayWindowFontAreaSelected(QString const &)));
const BtConfig::FontSettingsPair &v = m_fontMap.value(m_languageComboBox->currentText());
m_fontChooser->setFont(v.second);
@@ -143,7 +139,9 @@ void BtFontSettingsPage::useOwnFontClicked(bool isOn) {
m_fontChooser->setEnabled(isOn);
m_fontMap[m_languageComboBox->currentText()].first = isOn;
m_languageComboBox->setItemIcon(m_languageComboBox->currentIndex(),
- isOn ? util::getIcon("fonts.svg") : QIcon());
+ isOn
+ ? CResMgr::settings::fonts::icon()
+ : QIcon());
}
void BtFontSettingsPage::retranslateUi() {
@@ -151,5 +149,4 @@ void BtFontSettingsPage::retranslateUi() {
m_languageLabel->setText(tr("&Language:"));
m_languageComboBox->setToolTip(tr("The font selection below will apply to all texts in this language"));
m_languageCheckBox->setText(tr("Use custom font"));
- m_fontsGroupBox->setTitle(tr("Optionally specify a custom font for each language:"));
}
diff --git a/src/frontend/settingsdialogs/btfontsettings.h b/src/frontend/settingsdialogs/btfontsettings.h
index 70d0d20..356a9a9 100644
--- a/src/frontend/settingsdialogs/btfontsettings.h
+++ b/src/frontend/settingsdialogs/btfontsettings.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,7 +12,7 @@
#ifndef BTFONTSETTINGS_H
#define BTFONTSETTINGS_H
-#include "frontend/bookshelfmanager/btconfigdialog.h"
+#include "btconfigdialog.h"
#include <QMap>
#include <QWidget>
@@ -32,11 +32,11 @@ class BtFontSettingsPage: public BtConfigDialog::Page {
private: /* Types: */
- typedef QMap<QString, BtConfig::FontSettingsPair> FontMap;
+ using FontMap = QMap<QString, BtConfig::FontSettingsPair>;
public: /* Methods: */
- BtFontSettingsPage(CConfigurationDialog *parent = 0);
+ BtFontSettingsPage(CConfigurationDialog *parent = nullptr);
void save() const;
diff --git a/src/frontend/settingsdialogs/btlanguagesettings.cpp b/src/frontend/settingsdialogs/btlanguagesettings.cpp
deleted file mode 100644
index 37e53c8..0000000
--- a/src/frontend/settingsdialogs/btlanguagesettings.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2014 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "frontend/settingsdialogs/btlanguagesettings.h"
-
-#include <QComboBox>
-#include <QFormLayout>
-#include <QLabel>
-#include <QVBoxLayout>
-#include <QWidget>
-#include "backend/config/btconfig.h"
-#include "bibletimeapp.h"
-#include "frontend/settingsdialogs/cconfigurationdialog.h"
-#include "util/cresmgr.h"
-#include "util/geticon.h"
-#include "util/tool.h"
-
-// Sword includes:
-#include <localemgr.h>
-#include <swlocale.h>
-
-
-typedef std::list<sword::SWBuf>::const_iterator SBLCI;
-
-
-BtLanguageSettingsPage::BtLanguageSettingsPage(CConfigurationDialog *parent)
- : BtConfigDialog::Page(util::getIcon(CResMgr::settings::languages::icon), parent)
-{
- m_swordLocaleCombo = new QComboBox(this);
- m_languageNamesLabel = new QLabel(this);
- m_languageNamesLabel->setBuddy(m_swordLocaleCombo);
-
- QFormLayout * formLayout = new QFormLayout(this);
- formLayout->addRow(m_languageNamesLabel, m_swordLocaleCombo);
-
- retranslateUi();
-
- initSwordLocaleCombo();
-}
-
-void BtLanguageSettingsPage::save() {
- btConfig().setValue("language", m_swordLocaleCombo->itemData(m_swordLocaleCombo->currentIndex()));
-}
-
-void BtLanguageSettingsPage::resetLanguage() {
- QVector<QString> atv = bookNameAbbreviationsTryVector();
-
- QString best = "en_US";
- Q_ASSERT(atv.contains(best));
- int i = atv.indexOf(best);
- if (i > 0) {
- atv.resize(i);
- const std::list<sword::SWBuf> locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
- for (SBLCI it = locales.begin(); it != locales.end(); ++it) {
- const char * abbr = sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getName();
- i = atv.indexOf(abbr);
- if (i >= 0) {
- best = abbr;
- if (i == 0)
- break;
- atv.resize(i);
- }
- }
- }
- btConfig().setValue("language", best);
-}
-
-QVector<QString> BtLanguageSettingsPage::bookNameAbbreviationsTryVector() {
- QVector<QString> atv;
- atv.reserve(4);
- {
- QString settingsLanguage = btConfig().value<QString>("language");
- if (!settingsLanguage.isEmpty())
- atv.append(settingsLanguage);
- }
- {
- const QString localeLanguageAndCountry = QLocale::system().name();
- if (!localeLanguageAndCountry.isEmpty()) {
- atv.append(localeLanguageAndCountry);
- int i = localeLanguageAndCountry.indexOf('_');
- if (i > 0)
- atv.append(localeLanguageAndCountry.left(i));
- }
- }
- Q_ASSERT(CLanguageMgr::instance()->languageForAbbrev("en_US"));
- atv.append("en_US");
- return atv;
-}
-
-void BtLanguageSettingsPage::initSwordLocaleCombo() {
- typedef QMap<QString, QString>::const_iterator SSMCI;
-
- QMap<QString, QString> languageNames;
- Q_ASSERT(CLanguageMgr::instance()->languageForAbbrev("en_US"));
- languageNames.insert(CLanguageMgr::instance()->languageForAbbrev("en_US")->translatedName(), "en_US");
-
- const std::list<sword::SWBuf> locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
- for (SBLCI it = locales.begin(); it != locales.end(); ++it) {
- const char * const abbreviation = sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getName();
- const CLanguageMgr::Language * const l = CLanguageMgr::instance()->languageForAbbrev(abbreviation);
-
- if (l->isValid()) {
- languageNames.insert(l->translatedName(), abbreviation);
- } else {
- languageNames.insert(
- sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getDescription(),
- abbreviation);
- }
- }
-
- int index = 0;
- QVector<QString> atv = bookNameAbbreviationsTryVector();
- for (SSMCI it = languageNames.constBegin(); it != languageNames.constEnd(); ++it) {
- if (!atv.isEmpty()) {
- int i = atv.indexOf(it.value());
- if (i >= 0) {
- atv.resize(i);
- index = m_swordLocaleCombo->count();
- }
- }
- m_swordLocaleCombo->addItem(it.key(), it.value());
- }
- m_swordLocaleCombo->setCurrentIndex(index);
-}
-
-void BtLanguageSettingsPage::retranslateUi() {
- setHeaderText(tr("Languages"));
-
- m_languageNamesLabel->setText(tr("Language for names of Bible books:"));
- const QString toolTip(tr("The languages which can be used for the biblical book names. Translations are provided by the Sword library."));
- m_languageNamesLabel->setToolTip(toolTip);
- m_swordLocaleCombo->setToolTip(toolTip);
-}
diff --git a/src/frontend/settingsdialogs/btlanguagesettings.h b/src/frontend/settingsdialogs/btlanguagesettings.h
deleted file mode 100644
index 89caaf2..0000000
--- a/src/frontend/settingsdialogs/btlanguagesettings.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********
-*
-* In the name of the Father, and of the Son, and of the Holy Spirit.
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2014 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef BTLANGUAGESETTINGS_H
-#define BTLANGUAGESETTINGS_H
-
-#include "frontend/bookshelfmanager/btconfigdialog.h"
-
-#include <QMap>
-#include <QWidget>
-
-
-class CConfigurationDialog;
-class QComboBox;
-class QLabel;
-
-class BtLanguageSettingsPage: public BtConfigDialog::Page {
-
- Q_OBJECT
-
- public: /* Methods: */
-
- BtLanguageSettingsPage(CConfigurationDialog *parent = 0);
-
- void save();
-
- static void resetLanguage();
-
- private: /* Methods: */
-
- static QVector<QString> bookNameAbbreviationsTryVector();
- void initSwordLocaleCombo();
- void retranslateUi();
-
- private: /* Fields: */
-
- QLabel *m_languageNamesLabel;
- QComboBox* m_swordLocaleCombo;
-
-};
-
-#endif
diff --git a/src/frontend/settingsdialogs/btshortcutsdialog.cpp b/src/frontend/settingsdialogs/btshortcutsdialog.cpp
index 10601f6..5299560 100644
--- a/src/frontend/settingsdialogs/btshortcutsdialog.cpp
+++ b/src/frontend/settingsdialogs/btshortcutsdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,13 +16,14 @@
#include <QLabel>
#include <QRadioButton>
#include <QVBoxLayout>
+#include "util/btconnect.h"
// *************** BtShortcutsDialog ***************************************************************************
// A dialog to allow the user to input a shortcut for a primary and alternate key
BtShortcutsDialog::BtShortcutsDialog(QWidget* parent)
- : QDialog(parent), m_primaryLabel(0), m_alternateLabel(0), m_primaryButton(0), m_alternateButton(0) {
+ : QDialog(parent), m_primaryLabel(nullptr), m_alternateLabel(nullptr), m_primaryButton(nullptr), m_alternateButton(nullptr) {
setWindowTitle(tr("Configure shortcuts"));
setMinimumWidth(350);
@@ -59,8 +60,8 @@ BtShortcutsDialog::BtShortcutsDialog(QWidget* parent)
message::prepareDialogBox(buttons);
vLayout->addWidget(buttons);
- connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
- connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
+ BT_CONNECT(buttons, SIGNAL(accepted()), this, SLOT(accept()));
+ BT_CONNECT(buttons, SIGNAL(rejected()), this, SLOT(reject()));
}
// get new primary key from dialog
diff --git a/src/frontend/settingsdialogs/btshortcutsdialog.h b/src/frontend/settingsdialogs/btshortcutsdialog.h
index 722cef9..e5294ac 100644
--- a/src/frontend/settingsdialogs/btshortcutsdialog.h
+++ b/src/frontend/settingsdialogs/btshortcutsdialog.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -48,7 +48,7 @@ class BtShortcutsDialog : public QDialog {
protected:
// get key from users input, put into primary or alternate label for display to user
- void keyReleaseEvent(QKeyEvent* event);
+ void keyReleaseEvent(QKeyEvent* event) override;
private:
QLabel* m_primaryLabel;
diff --git a/src/frontend/settingsdialogs/btshortcutseditor.cpp b/src/frontend/settingsdialogs/btshortcutseditor.cpp
index 2e943eb..3811f7d 100644
--- a/src/frontend/settingsdialogs/btshortcutseditor.cpp
+++ b/src/frontend/settingsdialogs/btshortcutseditor.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,6 +22,7 @@
#include <QVBoxLayout>
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/settingsdialogs/btshortcutsdialog.h"
+#include "util/btconnect.h"
// *************** BtShortcutsEditorItem *******************************************************************
@@ -48,7 +49,7 @@ class BtShortcutsEditorItem : public QTableWidgetItem {
};
BtShortcutsEditorItem::BtShortcutsEditorItem(QAction* action)
- : m_action(action), m_newFirstHotkey(0), m_newSecondHotkey(0) {
+ : m_action(action), m_newFirstHotkey(nullptr), m_newSecondHotkey(nullptr) {
QList<QKeySequence> list = m_action->shortcuts();
if (list.count() > 0)
m_newFirstHotkey = new QKeySequence(list.at(0));
@@ -74,13 +75,13 @@ void BtShortcutsEditorItem::setDefaultKeys(QKeySequence keys) {
}
void BtShortcutsEditorItem::setFirstHotkey(QKeySequence keys) {
- if (m_newFirstHotkey == 0)
+ if (m_newFirstHotkey == nullptr)
m_newFirstHotkey = new QKeySequence();
*m_newFirstHotkey = keys;
}
void BtShortcutsEditorItem::setSecondHotkey(const QString& keys) {
- if (m_newSecondHotkey == 0)
+ if (m_newSecondHotkey == nullptr)
m_newSecondHotkey = new QKeySequence();
*m_newSecondHotkey = QKeySequence(keys);
}
@@ -88,22 +89,22 @@ void BtShortcutsEditorItem::setSecondHotkey(const QString& keys) {
// Deletes hotkey information
void BtShortcutsEditorItem::deleteHotkeys() {
delete m_newFirstHotkey;
- m_newFirstHotkey = 0;
+ m_newFirstHotkey = nullptr;
delete m_newSecondHotkey;
- m_newSecondHotkey = 0;
+ m_newSecondHotkey = nullptr;
}
// Moves the hotkey information into the QAction variable
void BtShortcutsEditorItem::commitChanges() {
QString actionName = text();
QList<QKeySequence> list;
- if ( (m_newFirstHotkey != 0) && (*m_newFirstHotkey != QKeySequence()) ) {
+ if ( (m_newFirstHotkey != nullptr) && (*m_newFirstHotkey != QKeySequence()) ) {
list << *m_newFirstHotkey;
}
- if ( (m_newSecondHotkey != 0) && (*m_newSecondHotkey != QKeySequence()) )
+ if ( (m_newSecondHotkey != nullptr) && (*m_newSecondHotkey != QKeySequence()) )
list << *m_newSecondHotkey;
- if (m_action != 0)
+ if (m_action != nullptr)
m_action->setShortcuts(list);
}
@@ -111,29 +112,139 @@ void BtShortcutsEditorItem::commitChanges() {
// ******************* BtShortcutsEditor *******************************************************
BtShortcutsEditor::BtShortcutsEditor(BtActionCollection* collection, QWidget* parent)
- : QWidget(parent), m_dlg(new BtShortcutsDialog(this)), m_table(0), m_shortcutChooser(0), m_noneButton(0), m_defaultButton(0),
- m_customButton(0), m_defaultLabelValue(0), m_currentRow(-1) {
- init();
- addCollection(collection);
- bool ok = connect(m_dlg, SIGNAL(keyChangeRequest(const QString&)), this, SLOT(makeKeyChangeRequest(const QString&)) );
- Q_ASSERT(ok);
-}
-
-BtShortcutsEditor::BtShortcutsEditor(QWidget* parent)
- : QWidget(parent), m_table(0) {
- init();
-}
+ : QWidget(parent), m_dlg(new BtShortcutsDialog(this)), m_table(nullptr), m_shortcutChooser(nullptr), m_noneButton(nullptr), m_defaultButton(nullptr),
+ m_customButton(nullptr), m_defaultLabelValue(nullptr), m_currentRow(-1) {
-// initialize this widget
-void BtShortcutsEditor::init() {
- QVBoxLayout* vBox = new QVBoxLayout(this);
+ QVBoxLayout * const vBox = new QVBoxLayout(this);
setLayout(vBox);
- m_table = createShortcutsTable();
+ // Create the action and shortcuts table:
+ m_table = new QTableWidget{this};
+ m_table->setColumnCount(3);
+ m_table->setAlternatingRowColors(true);
+ m_table->setSelectionBehavior(QAbstractItemView::SelectRows);
+ m_table->setHorizontalHeaderLabels({tr("Action\nname"),
+ tr("First\nshortcut"),
+ tr("Second\nshortcut")});
+ m_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
+ m_table->horizontalHeader()->resizeSection(0, 180);
+ m_table->horizontalHeader()->resizeSection(1, 100);
+ m_table->horizontalHeader()->setStretchLastSection(true);
+ m_table->verticalHeader()->setVisible(false);
+ m_table->setShowGrid(false);
+ BT_CONNECT(m_table, &QTableWidget::cellClicked,
+ this, &BtShortcutsEditor::changeRow);
vBox->addWidget(m_table);
- m_shortcutChooser = createShortcutChooser();
+ // Create the area below the table where the shortcuts are edited:
+ m_shortcutChooser =
+ new QGroupBox(tr("Shortcut for selected action name"), this);
+ m_shortcutChooser->setFlat(false);
+ {
+ QVBoxLayout * const vLayout = new QVBoxLayout(m_shortcutChooser);
+ {
+ QHBoxLayout * const hLayout = new QHBoxLayout();
+ vLayout->addLayout(hLayout);
+
+ m_noneButton = new QRadioButton(tr("None"), m_shortcutChooser);
+ hLayout->addWidget(m_noneButton);
+ BT_CONNECT(m_noneButton, &QRadioButton::clicked,
+ this, &BtShortcutsEditor::noneButtonClicked);
+
+ m_defaultButton =
+ new QRadioButton(tr("Default"), m_shortcutChooser);
+ hLayout->addWidget(m_defaultButton);
+ BT_CONNECT(
+ m_defaultButton, &QRadioButton::clicked,
+ this, &BtShortcutsEditor::defaultButtonClicked);
+
+ m_customButton = new QRadioButton(tr("Custom"), m_shortcutChooser);
+ hLayout->addWidget(m_customButton);
+ BT_CONNECT(m_customButton, &QRadioButton::clicked,
+ this, &BtShortcutsEditor::customButtonClicked);
+
+ m_customPushButton = new QPushButton(m_shortcutChooser);
+ m_customPushButton->setMinimumWidth(140);
+ hLayout->addWidget(m_customPushButton);
+
+ hLayout->addItem(new QSpacerItem(1,
+ 1,
+ QSizePolicy::Expanding,
+ QSizePolicy::Minimum));
+ }
+
+ QHBoxLayout * const hLayout = new QHBoxLayout();
+ vLayout->addLayout(hLayout);
+
+ hLayout->addWidget(new QLabel(tr("Default key:"), m_shortcutChooser));
+
+ m_defaultLabelValue = new QLabel(m_shortcutChooser);
+ hLayout->addWidget(m_defaultLabelValue);
+
+ hLayout->addItem(new QSpacerItem(1,
+ 1,
+ QSizePolicy::Expanding,
+ QSizePolicy::Minimum));
+ }
vBox->addWidget(m_shortcutChooser);
+
+ collection->foreachQAction([this](QAction & action,
+ QKeySequence const & defaultKeys)
+ {
+ int const count = m_table->rowCount();
+ m_table->insertRow(count);
+
+ {
+ BtShortcutsEditorItem * const item =
+ new BtShortcutsEditorItem{&action};
+ try {
+ /// \todo Remove this & hack and use Qt properties instead:
+ item->setText(action.text().replace(QRegExp("&(.)"), "\\1"));
+ item->setIcon(action.icon());
+ item->setDefaultKeys(defaultKeys);
+ item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ m_table->setItem(count, 0, item);
+ } catch (...) {
+ delete item;
+ throw;
+ }
+ }
+
+ QList<QKeySequence> keys = action.shortcuts();
+
+ {
+ QTableWidgetItem * const item = new QTableWidgetItem;
+ try {
+ item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ item->setToolTip(tr("Select to change key"));
+ if (keys.count() > 0)
+ item->setText(keys[0].toString());
+ m_table->setItem(count, 1, item);
+ } catch (...) {
+ delete item;
+ throw;
+ }
+ }
+
+ {
+ QTableWidgetItem * const item = new QTableWidgetItem;
+ try {
+ item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ item->setToolTip(tr("Select to change key"));
+ if (keys.count() > 1)
+ item->setText(keys[1].toString());
+ m_table->setItem(count, 2, item);
+ } catch (...) {
+ delete item;
+ throw;
+ }
+ }
+ });
+ m_table->sortItems(0);
+ m_table->selectRow(0);
+ changeRow(0, 0);
+ BT_CONNECT(m_dlg, &BtShortcutsDialog::keyChangeRequest,
+ this, &BtShortcutsEditor::makeKeyChangeRequest);
}
// get the shortcut editor item from the zeroth column of the table
@@ -148,77 +259,11 @@ void BtShortcutsEditor::commitChanges() {
int rows = m_table->rowCount();
for (int row = 0; row < rows; row++) {
BtShortcutsEditorItem* btItem = getShortcutsEditor(row);
- if (btItem != 0)
+ if (btItem != nullptr)
btItem->commitChanges();
}
}
-// puts actions and shortcut keys into QTableWidget
-void BtShortcutsEditor::addCollection(BtActionCollection* collection, const QString& title) {
- Q_UNUSED(title); /// \todo Is this correct?
-
- foreach (QAction *action, collection->actions()) {
- /// \todo Is the following check really necessary?
- if (action) {
- int count = m_table->rowCount();
- m_table->insertRow(count);
-
- QString name = action->text().remove('&');
- QList<QKeySequence> keys = action->shortcuts();
- QIcon icon = action->icon();
- QKeySequence defaultKeys = collection->getDefaultShortcut(action);
-
- BtShortcutsEditorItem* item = new BtShortcutsEditorItem(action);
- item->setText(name);
- item->setIcon(icon);
- item->setDefaultKeys(defaultKeys);
- item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
- m_table->setItem(count, 0, item);
-
- QTableWidgetItem* item1 = new QTableWidgetItem();
- item1->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
- item1->setToolTip(tr("Select to change key"));
- if (keys.count() > 0)
- item1->setText(keys[0].toString());
- m_table->setItem(count, 1, item1);
-
- QTableWidgetItem* item2 = new QTableWidgetItem();
- item2->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
- item2->setToolTip(tr("Select to change key"));
- if (keys.count() > 1)
- item2->setText(keys[1].toString());
- m_table->setItem(count, 2, item2);
- }
- }
- m_table->sortItems(0);
- m_table->selectRow(0);
- changeRow(0, 0);
-}
-
-// create the action and shortcuts table
-QTableWidget* BtShortcutsEditor::createShortcutsTable() {
- QTableWidget* table = new QTableWidget(this);
- table->setColumnCount(3);
- table->setAlternatingRowColors(true);
- table->setSelectionBehavior(QAbstractItemView::SelectRows);
- QStringList headerList;
- headerList << tr("Action\nname") << tr("First\nshortcut") << tr("Second\nshortcut");
- table->setHorizontalHeaderLabels(headerList);
-#if QT_VERSION < 0x050000
- table->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
-#else
- table->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
-#endif
- table->horizontalHeader()->resizeSection(0, 180);
- table->horizontalHeader()->resizeSection(1, 100);
- table->horizontalHeader()->setStretchLastSection(true);
- table->verticalHeader()->setVisible(false);
- table->setShowGrid(false);
- bool ok = connect(table, SIGNAL(cellClicked(int, int)), this, SLOT(changeRow(int, int)));
- Q_ASSERT(ok);
- return table;
-}
-
// called when a different action name row is selected
void BtShortcutsEditor::changeRow(int row, int column) {
Q_UNUSED(column); /// \todo Is this correct?
@@ -248,52 +293,6 @@ void BtShortcutsEditor::changeRow(int row, int column) {
m_customButton->setChecked(true);
}
-// create the area below the table where the shortcuts are edited
-QWidget* BtShortcutsEditor::createShortcutChooser() {
- QGroupBox* box = new QGroupBox(tr("Shortcut for selected action name"), this);
- box->setFlat(false);
- QVBoxLayout* vLayout = new QVBoxLayout(box);
- QHBoxLayout* hLayout = new QHBoxLayout();
- vLayout->addLayout(hLayout);
-
- m_noneButton = new QRadioButton(tr("None"), box);
- hLayout->addWidget(m_noneButton);
- bool ok = connect(m_noneButton, SIGNAL(clicked(bool)), this, SLOT(noneButtonClicked(bool)));
- Q_ASSERT(ok);
-
- m_defaultButton = new QRadioButton(tr("Default"), box);
- hLayout->addWidget(m_defaultButton);
- ok = connect(m_defaultButton, SIGNAL(clicked(bool)), this, SLOT(defaultButtonClicked(bool)));
- Q_ASSERT(ok);
-
- m_customButton = new QRadioButton(tr("Custom"), box);
- hLayout->addWidget(m_customButton);
- ok = connect(m_customButton, SIGNAL(clicked(bool)), this, SLOT(customButtonClicked(bool)));
- Q_ASSERT(ok);
-
- m_customPushButton = new QPushButton(box);
- m_customPushButton->setMinimumWidth(140);
- hLayout->addWidget(m_customPushButton);
-
- QSpacerItem* spacer = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
- hLayout->addItem(spacer);
-
- QHBoxLayout* hLayout2 = new QHBoxLayout();
- vLayout->addLayout(hLayout2);
-
- QLabel* defaultLabel = new QLabel(tr("Default key:"), box);
- hLayout2->addWidget(defaultLabel);
-
- m_defaultLabelValue = new QLabel(box);
- hLayout2->addWidget(m_defaultLabelValue);
-
- QSpacerItem* spacer2 = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
- hLayout2->addItem(spacer2);
-
- return box;
-}
-
-
// called when the none radio button is clicked
void BtShortcutsEditor::noneButtonClicked(bool checked) {
Q_UNUSED(checked); /// \todo Is this correct?
diff --git a/src/frontend/settingsdialogs/btshortcutseditor.h b/src/frontend/settingsdialogs/btshortcutseditor.h
index d58ac08..66cee81 100644
--- a/src/frontend/settingsdialogs/btshortcutseditor.h
+++ b/src/frontend/settingsdialogs/btshortcutseditor.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,6 +19,7 @@
class BtActionCollection;
class BtShortcutsEditorItem;
class BtShortcutsDialog;
+class QGroupBox;
class QLabel;
class QPushButton;
class QRadioButton;
@@ -28,15 +29,11 @@ class QTableWidget;
class BtShortcutsEditor : public QWidget {
Q_OBJECT
public:
- BtShortcutsEditor(BtActionCollection* collection, QWidget* parent);
- BtShortcutsEditor(QWidget* parent);
+ BtShortcutsEditor(BtActionCollection * collection, QWidget * parent);
// saves shortcut keys into the QAction
void commitChanges();
- // puts actions and shortcut keys into QTableWidget
- void addCollection(BtActionCollection *collection, const QString &title = QString::null);
-
// clears any shortcut keys in the table matching the specified keys
void clearConflictWithKeys(const QString& keys);
@@ -70,21 +67,12 @@ class BtShortcutsEditor : public QWidget {
private:
- // create the action and shortcuts table
- QTableWidget* createShortcutsTable();
-
- // create the area below the table where the shortcuts are edited
- QWidget* createShortcutChooser();
-
// get the shortcut editor item from the zeroth column of the table
BtShortcutsEditorItem* getShortcutsEditor(int row);
- // initialize this widget
- void init();
-
BtShortcutsDialog* m_dlg;
QTableWidget* m_table;
- QWidget* m_shortcutChooser;
+ QGroupBox * m_shortcutChooser;
QRadioButton* m_noneButton;
QRadioButton* m_defaultButton;
QRadioButton* m_customButton;
diff --git a/src/frontend/settingsdialogs/btstandardworkstab.cpp b/src/frontend/settingsdialogs/btstandardworkstab.cpp
index 9cef549..1190aa6 100644
--- a/src/frontend/settingsdialogs/btstandardworkstab.cpp
+++ b/src/frontend/settingsdialogs/btstandardworkstab.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -23,8 +23,6 @@
BtStandardWorksTab::BtStandardWorksTab(CSwordSettingsPage *parent)
: QWidget(parent)
{
- typedef QList<CSwordModuleInfo*>::const_iterator MLCI;
-
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->setMargin(5);
mainLayout->setSpacing(2);
@@ -59,12 +57,13 @@ BtStandardWorksTab::BtStandardWorksTab(CSwordSettingsPage *parent)
//fill the comboboxes with the right modules
- const QList<CSwordModuleInfo*> &modules(CSwordBackend::instance()->moduleList());
QString modDescript;
- for (MLCI it(modules.begin()); it != modules.end(); it++) {
- modDescript = (*it)->config(CSwordModuleInfo::Description);
+ Q_FOREACH(CSwordModuleInfo const * const m,
+ CSwordBackend::instance()->moduleList())
+ {
+ modDescript = m->config(CSwordModuleInfo::Description);
- switch ((*it)->type()) {
+ switch (m->type()) {
case CSwordModuleInfo::Bible:
m_standardBibleCombo->addItem(modDescript);
break;
@@ -73,23 +72,23 @@ BtStandardWorksTab::BtStandardWorksTab(CSwordSettingsPage *parent)
break;
case CSwordModuleInfo::Lexicon: {
bool inserted = false;
- if ((*it)->has(CSwordModuleInfo::HebrewDef)) {
+ if (m->has(CSwordModuleInfo::HebrewDef)) {
m_standardHebrewStrongsLexiconCombo->addItem(modDescript);
inserted = true;
}
- if ((*it)->has(CSwordModuleInfo::GreekDef)) {
+ if (m->has(CSwordModuleInfo::GreekDef)) {
m_standardGreekStrongsLexiconCombo->addItem(modDescript);
inserted = true;
}
- if ((*it)->has(CSwordModuleInfo::HebrewParse)) {
+ if (m->has(CSwordModuleInfo::HebrewParse)) {
m_standardHebrewMorphLexiconCombo->addItem(modDescript);
inserted = true;
}
- if ((*it)->has(CSwordModuleInfo::GreekParse)) {
+ if (m->has(CSwordModuleInfo::GreekParse)) {
m_standardGreekMorphLexiconCombo->addItem(modDescript);
inserted = true;
}
- if ((*it)->category() == CSwordModuleInfo::DailyDevotional) {
+ if (m->category() == CSwordModuleInfo::DailyDevotional) {
m_standardDailyDevotionalCombo->addItem(modDescript);
inserted = true;
}
@@ -109,7 +108,7 @@ BtStandardWorksTab::BtStandardWorksTab(CSwordSettingsPage *parent)
QStringList moduleList;
// fill combobox and modulelist
- const CSwordModuleInfo* m;
+ const CSwordModuleInfo* m;
#define STANDARD_WORKS_COMBO_ADD(name) \
comboList.append(m_ ## name ## Combo); \
diff --git a/src/frontend/settingsdialogs/btstandardworkstab.h b/src/frontend/settingsdialogs/btstandardworkstab.h
index 0b91b4c..d03fe9e 100644
--- a/src/frontend/settingsdialogs/btstandardworkstab.h
+++ b/src/frontend/settingsdialogs/btstandardworkstab.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/bttextfilterstab.cpp b/src/frontend/settingsdialogs/bttextfilterstab.cpp
index e8da038..ee1c410 100644
--- a/src/frontend/settingsdialogs/bttextfilterstab.cpp
+++ b/src/frontend/settingsdialogs/bttextfilterstab.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -72,8 +72,9 @@ void BtTextFiltersTab::save() {
void BtTextFiltersTab::retranslateUi() {
util::tool::initExplanationLabel(m_explanationLabel, "",
tr("Filters control the appearance of text. Here you can specify "
- "default settings for all filters. You can override these "
- "settings in each display window."));
+ "default settings for all filters. These settings apply to newly "
+ "opened display windows only. You can override these settings in "
+ "each display window."));
m_lineBreaksCheck->setText(tr("Insert line break after each verse"));
m_verseNumbersCheck->setText(tr("Show verse numbers"));
diff --git a/src/frontend/settingsdialogs/bttextfilterstab.h b/src/frontend/settingsdialogs/bttextfilterstab.h
index 3f6e904..fbfedde 100644
--- a/src/frontend/settingsdialogs/bttextfilterstab.h
+++ b/src/frontend/settingsdialogs/bttextfilterstab.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/cacceleratorsettings.cpp b/src/frontend/settingsdialogs/cacceleratorsettings.cpp
index d85bf51..c95a715 100644
--- a/src/frontend/settingsdialogs/cacceleratorsettings.cpp
+++ b/src/frontend/settingsdialogs/cacceleratorsettings.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -26,12 +26,12 @@
#include "frontend/displaywindow/creadwindow.h"
#include "frontend/messagedialog.h"
#include "frontend/settingsdialogs/cconfigurationdialog.h"
+#include "util/btconnect.h"
#include "util/cresmgr.h"
-#include "util/geticon.h"
CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
- : BtConfigDialog::Page(util::getIcon(CResMgr::settings::keys::icon), parent)
+ : BtConfigDialog::Page(CResMgr::settings::keys::icon(), parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
@@ -44,9 +44,8 @@ CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
m_typeChooser = new QComboBox(this);
layoutForWindowTypeChooser->addWidget(m_typeChooser);
- bool ok = connect(m_typeChooser, SIGNAL(activated(const QString&)),
- SLOT(slotKeyChooserTypeChanged(const QString&)) );
- Q_ASSERT(ok);
+ BT_CONNECT(m_typeChooser, SIGNAL(activated(QString const &)),
+ SLOT(slotKeyChooserTypeChanged(QString const &)) );
// m_*.title strings are empty here, they are filled and added to the stacked widget in the retranslateUi() function
m_keyChooserStack = new QStackedWidget(this);
@@ -60,9 +59,11 @@ CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
m_application.actionCollection->readShortcuts("Application shortcuts");
m_application.keyChooser = new BtShortcutsEditor(m_application.actionCollection, m_keyChooserStack);
m_keyChooserStack->addWidget(m_application.keyChooser);
- ok = connect(m_application.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
- this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
- Q_ASSERT(ok);
+ BT_CONNECT(m_application.keyChooser,
+ SIGNAL(keyChangeRequest(BtShortcutsEditor *, QString const &)),
+ this,
+ SLOT(completeKeyChangeRequest(BtShortcutsEditor *,
+ QString const &)));
// ----- All display windows ------ //
m_general.actionCollection = new BtActionCollection(this);
@@ -70,9 +71,11 @@ CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
m_general.actionCollection->readShortcuts("Displaywindow shortcuts");
m_general.keyChooser = new BtShortcutsEditor(m_general.actionCollection, m_keyChooserStack);
m_keyChooserStack->addWidget(m_general.keyChooser);
- ok = connect(m_general.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
- this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
- Q_ASSERT(ok);
+ BT_CONNECT(m_general.keyChooser,
+ SIGNAL(keyChangeRequest(BtShortcutsEditor *, QString const &)),
+ this,
+ SLOT(completeKeyChangeRequest(BtShortcutsEditor *,
+ QString const &)));
// ----- Bible windows ------ //
m_bible.actionCollection = new BtActionCollection(this);
@@ -80,9 +83,11 @@ CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
m_bible.actionCollection->readShortcuts("Bible shortcuts");
m_bible.keyChooser = new BtShortcutsEditor(m_bible.actionCollection, m_keyChooserStack);
m_keyChooserStack->addWidget(m_bible.keyChooser);
- ok = connect(m_bible.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
- this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
- Q_ASSERT(ok);
+ BT_CONNECT(m_bible.keyChooser,
+ SIGNAL(keyChangeRequest(BtShortcutsEditor *, QString const &)),
+ this,
+ SLOT(completeKeyChangeRequest(BtShortcutsEditor *,
+ QString const &)));
// ----- Commentary windows ------ //
m_commentary.actionCollection = new BtActionCollection(this);
@@ -90,9 +95,11 @@ CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
m_commentary.actionCollection->readShortcuts("Commentary shortcuts");
m_commentary.keyChooser = new BtShortcutsEditor(m_commentary.actionCollection, m_keyChooserStack);
m_keyChooserStack->addWidget(m_commentary.keyChooser);
- ok = connect(m_commentary.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
- this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
- Q_ASSERT(ok);
+ BT_CONNECT(m_commentary.keyChooser,
+ SIGNAL(keyChangeRequest(BtShortcutsEditor *, QString const &)),
+ this,
+ SLOT(completeKeyChangeRequest(BtShortcutsEditor *,
+ QString const &)));
// ----- Lexicon windows ------ //
m_lexicon.actionCollection = new BtActionCollection(this);
@@ -100,9 +107,11 @@ CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
m_lexicon.actionCollection->readShortcuts("Lexicon shortcuts");
m_lexicon.keyChooser = new BtShortcutsEditor(m_lexicon.actionCollection, m_keyChooserStack);
m_keyChooserStack->addWidget(m_lexicon.keyChooser);
- ok = connect(m_lexicon.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
- this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
- Q_ASSERT(ok);
+ BT_CONNECT(m_lexicon.keyChooser,
+ SIGNAL(keyChangeRequest(BtShortcutsEditor *, QString const &)),
+ this,
+ SLOT(completeKeyChangeRequest(BtShortcutsEditor *,
+ QString const &)));
// ----- Book windows ------ //
m_book.actionCollection = new BtActionCollection(this);
@@ -110,9 +119,11 @@ CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
m_book.actionCollection->readShortcuts("Book shortcuts");
m_book.keyChooser = new BtShortcutsEditor(m_book.actionCollection, m_keyChooserStack);
m_keyChooserStack->addWidget(m_book.keyChooser);
- ok = connect(m_book.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
- this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
- Q_ASSERT(ok);
+ BT_CONNECT(m_book.keyChooser,
+ SIGNAL(keyChangeRequest(BtShortcutsEditor *, QString const &)),
+ this,
+ SLOT(completeKeyChangeRequest(BtShortcutsEditor *,
+ QString const &)));
mainLayout->addWidget(m_keyChooserStack);
slotKeyChooserTypeChanged(m_application.title);
diff --git a/src/frontend/settingsdialogs/cacceleratorsettings.h b/src/frontend/settingsdialogs/cacceleratorsettings.h
index 49408d5..4e79ca6 100644
--- a/src/frontend/settingsdialogs/cacceleratorsettings.h
+++ b/src/frontend/settingsdialogs/cacceleratorsettings.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,7 +12,7 @@
#ifndef CACCELERATORSETTINGS_H
#define CACCELERATORSETTINGS_H
-#include "frontend/bookshelfmanager/btconfigdialog.h"
+#include "btconfigdialog.h"
#include <QPointer>
#include <QWidget>
@@ -36,7 +36,7 @@ class CAcceleratorSettingsPage: public BtConfigDialog::Page {
public: /* Methods: */
- CAcceleratorSettingsPage(CConfigurationDialog *parent = 0);
+ CAcceleratorSettingsPage(CConfigurationDialog *parent = nullptr);
void save();
@@ -58,13 +58,8 @@ class CAcceleratorSettingsPage: public BtConfigDialog::Page {
QString title;
WindowType() {
- keyChooser = 0;
- actionCollection = 0;
- };
- WindowType(const QString& newTitle) {
- title = newTitle;
- keyChooser = 0;
- actionCollection = 0;
+ keyChooser = nullptr;
+ actionCollection = nullptr;
}
};
diff --git a/src/frontend/settingsdialogs/cconfigurationdialog.cpp b/src/frontend/settingsdialogs/cconfigurationdialog.cpp
index 951880b..93801f0 100644
--- a/src/frontend/settingsdialogs/cconfigurationdialog.cpp
+++ b/src/frontend/settingsdialogs/cconfigurationdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,9 +18,9 @@
#include "frontend/settingsdialogs/cacceleratorsettings.h"
#include "frontend/settingsdialogs/cdisplaysettings.h"
#include "frontend/settingsdialogs/btfontsettings.h"
-#include "frontend/settingsdialogs/btlanguagesettings.h"
#include "frontend/settingsdialogs/cswordsettings.h"
#include "frontend/messagedialog.h"
+#include "util/btconnect.h"
#include "util/cresmgr.h"
#include "util/directory.h"
@@ -32,12 +32,11 @@ const QString GeometryKey = "GUI/SettingsDialog/geometry";
CConfigurationDialog::CConfigurationDialog(QWidget * parent, BtActionCollection* actionCollection )
: BtConfigDialog(parent),
m_actionCollection(actionCollection),
- m_displayPage(0),
- m_swordPage(0),
- m_acceleratorsPage(0),
- m_fontsPage(0),
- m_languagesPage(0),
- m_bbox(0) {
+ m_displayPage(nullptr),
+ m_swordPage(nullptr),
+ m_acceleratorsPage(nullptr),
+ m_fontsPage(nullptr),
+ m_bbox(nullptr) {
setWindowTitle(tr("Configure BibleTime"));
setAttribute(Qt::WA_DeleteOnClose);
@@ -49,10 +48,6 @@ CConfigurationDialog::CConfigurationDialog(QWidget * parent, BtActionCollection*
m_swordPage = new CSwordSettingsPage(this);
addPage(m_swordPage);
- // Add "Languages" page
- m_languagesPage = new BtLanguageSettingsPage(this);
- addPage(m_languagesPage);
-
// Add "Fonts" page
m_fontsPage = new BtFontSettingsPage(this);
addPage(m_fontsPage);
@@ -68,8 +63,8 @@ CConfigurationDialog::CConfigurationDialog(QWidget * parent, BtActionCollection*
m_bbox->addButton(QDialogButtonBox::Cancel);
message::prepareDialogBox(m_bbox);
setButtonBox(m_bbox);
- bool ok = connect(m_bbox, SIGNAL(clicked(QAbstractButton *)), SLOT(slotButtonClicked(QAbstractButton *)));
- Q_ASSERT(ok);
+ BT_CONNECT(m_bbox, SIGNAL(clicked(QAbstractButton *)),
+ SLOT(slotButtonClicked(QAbstractButton *)));
loadDialogSettings();
@@ -83,7 +78,6 @@ CConfigurationDialog::~CConfigurationDialog() {
/** Save the dialog settings **/
void CConfigurationDialog::save() {
m_acceleratorsPage->save();
- m_languagesPage->save();
m_fontsPage->save();
m_swordPage->save();
m_displayPage->save();
diff --git a/src/frontend/settingsdialogs/cconfigurationdialog.h b/src/frontend/settingsdialogs/cconfigurationdialog.h
index fbd4944..ec00cf4 100644
--- a/src/frontend/settingsdialogs/cconfigurationdialog.h
+++ b/src/frontend/settingsdialogs/cconfigurationdialog.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,14 +12,13 @@
#ifndef CCONFIGURATIONDIALOG_H
#define CCONFIGURATIONDIALOG_H
-#include "frontend/bookshelfmanager/btconfigdialog.h"
+#include "btconfigdialog.h"
class BtActionCollection;
class CAcceleratorSettingsPage;
class CDisplaySettingsPage;
class BtFontSettingsPage;
-class BtLanguageSettingsPage;
class CSwordSettingsPage;
class QAbstractButton;
class QDialogButtonBox;
@@ -41,7 +40,6 @@ class CConfigurationDialog : public BtConfigDialog {
CSwordSettingsPage* m_swordPage;
CAcceleratorSettingsPage* m_acceleratorsPage;
BtFontSettingsPage* m_fontsPage;
- BtLanguageSettingsPage* m_languagesPage;
QDialogButtonBox* m_bbox;
// Load the settings from the resource file
diff --git a/src/frontend/settingsdialogs/cdisplaysettings.cpp b/src/frontend/settingsdialogs/cdisplaysettings.cpp
index 5b690f6..92bf5a0 100644
--- a/src/frontend/settingsdialogs/cdisplaysettings.cpp
+++ b/src/frontend/settingsdialogs/cdisplaysettings.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,24 +13,31 @@
#include <QComboBox>
#include <QLabel>
#include <QVBoxLayout>
-#include <QWebView>
+#include <QFormLayout>
#include "backend/config/btconfig.h"
#include "backend/managers/cdisplaytemplatemgr.h"
#include "backend/rendering/cdisplayrendering.h"
#include "bibletimeapp.h"
+#include "frontend/btwebengineview.h"
#include "frontend/settingsdialogs/cconfigurationdialog.h"
+#include "util/btassert.h"
+#include "util/btconnect.h"
#include "util/cresmgr.h"
-#include "util/geticon.h"
#include "util/tool.h"
+// Sword includes:
+#include <localemgr.h>
+#include <swlocale.h>
+
+using SBLCI = std::list<sword::SWBuf>::const_iterator;
// ***********************
-// Container for QWebView to control its size
+// Container for BtWebEngineView to control its size
class CWebViewerWidget : public QWidget {
public:
- CWebViewerWidget(QWidget* parent = 0);
+ CWebViewerWidget(QWidget* parent = nullptr);
~CWebViewerWidget();
- virtual QSize sizeHint () const;
+ QSize sizeHint() const override;
};
CWebViewerWidget::CWebViewerWidget(QWidget* parent)
@@ -47,36 +54,37 @@ QSize CWebViewerWidget::sizeHint () const {
/** Initializes the startup section of the OD. */
CDisplaySettingsPage::CDisplaySettingsPage(CConfigurationDialog *parent)
- : BtConfigDialog::Page(util::getIcon(CResMgr::settings::startup::icon), parent)
+ : BtConfigDialog::Page(CResMgr::settings::startup::icon(), parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
- { //startup logo
- m_showLogoCheck = new QCheckBox(this);
- m_showLogoCheck->setChecked(btConfig().value<bool>("GUI/showSplashScreen", true));
- mainLayout->addWidget(m_showLogoCheck);
- }
- mainLayout->addSpacing(20);
+ QFormLayout *formLayout = new QFormLayout();
+
+ //startup logo
+ m_showLogoLabel = new QLabel(this);
+ m_showLogoCheck = new QCheckBox(this);
+ m_showLogoCheck->setChecked(btConfig().value<bool>("GUI/showSplashScreen", true));
+ formLayout->addRow(m_showLogoLabel, m_showLogoCheck);
- m_explanationLabel = new QLabel(this);
- mainLayout->addWidget(m_explanationLabel);
+ m_swordLocaleCombo = new QComboBox(this);
+ m_languageNamesLabel = new QLabel(this);
+ m_languageNamesLabel->setBuddy(m_swordLocaleCombo);
+ formLayout->addRow(m_languageNamesLabel, m_swordLocaleCombo);
- QHBoxLayout* hboxlayout = new QHBoxLayout();
+ initSwordLocaleCombo();
m_styleChooserCombo = new QComboBox( this ); //create first to enable buddy for label
- connect( m_styleChooserCombo, SIGNAL( activated( int ) ),
- this, SLOT( updateStylePreview() ) );
+ BT_CONNECT(m_styleChooserCombo, SIGNAL(activated(int)),
+ this, SLOT(updateStylePreview()));
m_availableLabel = new QLabel(this);
m_availableLabel->setBuddy(m_styleChooserCombo);
- hboxlayout->addWidget(m_availableLabel);
- hboxlayout->addWidget( m_styleChooserCombo );
- hboxlayout->addStretch();
- mainLayout->addLayout( hboxlayout );
+ formLayout->addRow(m_availableLabel, m_styleChooserCombo );
+ mainLayout->addLayout(formLayout);
QWidget* webViewWidget = new CWebViewerWidget(this);
QLayout* webViewLayout = new QVBoxLayout(webViewWidget);
- m_stylePreviewViewer = new QWebView(webViewWidget);
+ m_stylePreviewViewer = new BtWebEngineView(webViewWidget);
m_previewLabel = new QLabel(webViewWidget);
m_previewLabel->setBuddy(m_stylePreviewViewer);
webViewLayout->addWidget(m_previewLabel);
@@ -94,25 +102,116 @@ CDisplaySettingsPage::CDisplaySettingsPage(CConfigurationDialog *parent)
}
}
+ m_transifexLabel = new QLabel(this);
+ mainLayout->addWidget(m_transifexLabel);
+
retranslateUi(); // also calls updateStylePreview();
}
void CDisplaySettingsPage::retranslateUi() {
setHeaderText(tr("Display"));
- util::tool::initExplanationLabel(
- m_explanationLabel,
- tr("Display templates"),
- tr("Display templates define how text is displayed.")
- );
+ m_languageNamesLabel->setText(tr("Language for names of Bible books:"));
+ const QString toolTip(tr("The languages which can be used for the biblical book names. Translations are provided by the Sword library."));
+ m_languageNamesLabel->setToolTip(toolTip);
+ m_swordLocaleCombo->setToolTip(toolTip);
- m_showLogoCheck->setText(tr("Show startup logo"));
- m_showLogoCheck->setToolTip(tr("Show the BibleTime logo on startup"));
+ m_showLogoLabel->setText(tr("Show startup logo:"));
+ m_showLogoLabel->setToolTip(tr("Show the BibleTime logo on startup."));
m_availableLabel->setText(tr("Available display styles:"));
m_previewLabel->setText(tr("Style preview"));
updateStylePreview();
+
+ m_transifexLabel->setWordWrap(true);
+ m_transifexLabel->setOpenExternalLinks(true);
+ m_transifexLabel->setText(tr(
+ "Did you know? You can help translating the GUI of BibleTime to your language at %1."
+ ).arg(QString("<a href=\"https://www.transifex.com/bibletime/bibletime/\">")
+ .append(tr("Transifex"))
+ .append("</a>")));
+}
+
+void CDisplaySettingsPage::resetLanguage() {
+ QVector<QString> atv = bookNameAbbreviationsTryVector();
+
+ QString best = "en_US";
+ BT_ASSERT(atv.contains(best));
+ int i = atv.indexOf(best);
+ if (i > 0) {
+ atv.resize(i);
+ const std::list<sword::SWBuf> locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
+ for (SBLCI it = locales.begin(); it != locales.end(); ++it) {
+ const char * abbr = sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getName();
+ i = atv.indexOf(abbr);
+ if (i >= 0) {
+ best = abbr;
+ if (i == 0)
+ break;
+ atv.resize(i);
+ }
+ }
+ }
+ btConfig().setValue("GUI/booknameLanguage", best);
+}
+
+QVector<QString> CDisplaySettingsPage::bookNameAbbreviationsTryVector() {
+ QVector<QString> atv;
+ atv.reserve(4);
+ {
+ QString settingsLanguage = btConfig().value<QString>("GUI/booknameLanguage");
+ if (!settingsLanguage.isEmpty())
+ atv.append(settingsLanguage);
+ }
+ {
+ const QString localeLanguageAndCountry = QLocale::system().name();
+ if (!localeLanguageAndCountry.isEmpty()) {
+ atv.append(localeLanguageAndCountry);
+ int i = localeLanguageAndCountry.indexOf('_');
+ if (i > 0)
+ atv.append(localeLanguageAndCountry.left(i));
+ }
+ }
+ BT_ASSERT(CLanguageMgr::instance()->languageForAbbrev("en_US"));
+ atv.append("en_US");
+ return atv;
+}
+
+void CDisplaySettingsPage::initSwordLocaleCombo() {
+ using SSMCI = QMap<QString, QString>::const_iterator;
+
+ QMap<QString, QString> languageNames;
+ BT_ASSERT(CLanguageMgr::instance()->languageForAbbrev("en_US"));
+ languageNames.insert(CLanguageMgr::instance()->languageForAbbrev("en_US")->translatedName(), "en_US");
+
+ const std::list<sword::SWBuf> locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
+ for (SBLCI it = locales.begin(); it != locales.end(); ++it) {
+ const char * const abbreviation = sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getName();
+ const CLanguageMgr::Language * const l = CLanguageMgr::instance()->languageForAbbrev(abbreviation);
+
+ if (l->isValid()) {
+ languageNames.insert(l->translatedName(), abbreviation);
+ } else {
+ languageNames.insert(
+ sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getDescription(),
+ abbreviation);
+ }
+ }
+
+ int index = 0;
+ QVector<QString> atv = bookNameAbbreviationsTryVector();
+ for (SSMCI it = languageNames.constBegin(); it != languageNames.constEnd(); ++it) {
+ if (!atv.isEmpty()) {
+ int i = atv.indexOf(it.value());
+ if (i >= 0) {
+ atv.resize(i);
+ index = m_swordLocaleCombo->count();
+ }
+ }
+ m_swordLocaleCombo->addItem(it.key(), it.value());
+ }
+ m_swordLocaleCombo->setCurrentIndex(index);
}
@@ -172,4 +271,5 @@ void CDisplaySettingsPage::updateStylePreview() {
void CDisplaySettingsPage::save() {
btConfig().setValue("GUI/showSplashScreen", m_showLogoCheck->isChecked() );
btConfig().setValue("GUI/activeTemplateName", m_styleChooserCombo->currentText());
+ btConfig().setValue("GUI/booknameLanguage", m_swordLocaleCombo->itemData(m_swordLocaleCombo->currentIndex()));
}
diff --git a/src/frontend/settingsdialogs/cdisplaysettings.h b/src/frontend/settingsdialogs/cdisplaysettings.h
index 834c846..1f6ad6a 100644
--- a/src/frontend/settingsdialogs/cdisplaysettings.h
+++ b/src/frontend/settingsdialogs/cdisplaysettings.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,7 +12,7 @@
#ifndef CDISPLAYSETTINGS_H
#define CDISPLAYSETTINGS_H
-#include "frontend/bookshelfmanager/btconfigdialog.h"
+#include "btconfigdialog.h"
#include <QWidget>
@@ -21,7 +21,7 @@ class CConfigurationDialog;
class QCheckBox;
class QComboBox;
class QLabel;
-class QWebView;
+class BtWebEngineView;
class CDisplaySettingsPage: public BtConfigDialog::Page {
@@ -29,10 +29,12 @@ class CDisplaySettingsPage: public BtConfigDialog::Page {
public: /* Methods: */
- CDisplaySettingsPage(CConfigurationDialog *parent = 0);
+ CDisplaySettingsPage(CConfigurationDialog *parent = nullptr);
void save();
+ static void resetLanguage();
+
protected: /* Methods: */
void retranslateUi();
@@ -41,13 +43,21 @@ class CDisplaySettingsPage: public BtConfigDialog::Page {
/** Update the style preview widget. */
void updateStylePreview();
+ private: /* Methods: */
+
+ static QVector<QString> bookNameAbbreviationsTryVector();
+ void initSwordLocaleCombo();
+
private: /* Fields: */
+ QLabel* m_showLogoLabel;
QCheckBox* m_showLogoCheck;
- QLabel *m_explanationLabel;
+ QLabel *m_languageNamesLabel;
+ QComboBox* m_swordLocaleCombo;
+ QLabel *m_transifexLabel;
QComboBox* m_styleChooserCombo;
QLabel *m_availableLabel;
- QWebView* m_stylePreviewViewer;
+ BtWebEngineView* m_stylePreviewViewer;
QLabel *m_previewLabel;
};
diff --git a/src/frontend/settingsdialogs/clistwidget.cpp b/src/frontend/settingsdialogs/clistwidget.cpp
index 9504009..79a254e 100644
--- a/src/frontend/settingsdialogs/clistwidget.cpp
+++ b/src/frontend/settingsdialogs/clistwidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/clistwidget.h b/src/frontend/settingsdialogs/clistwidget.h
index 393754c..2693463 100644
--- a/src/frontend/settingsdialogs/clistwidget.h
+++ b/src/frontend/settingsdialogs/clistwidget.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,9 +18,9 @@
class CListWidget : public QListWidget {
Q_OBJECT
public:
- CListWidget(QWidget* parent = 0);
+ CListWidget(QWidget* parent = nullptr);
- virtual QSize sizeHint () const;
+ QSize sizeHint() const override;
void setCharWidth(int width);
};
diff --git a/src/frontend/settingsdialogs/cswordsettings.cpp b/src/frontend/settingsdialogs/cswordsettings.cpp
index f8f0ebf..5913d78 100644
--- a/src/frontend/settingsdialogs/cswordsettings.cpp
+++ b/src/frontend/settingsdialogs/cswordsettings.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,11 +15,10 @@
#include "frontend/settingsdialogs/bttextfilterstab.h"
#include "frontend/settingsdialogs/cconfigurationdialog.h"
#include "util/cresmgr.h"
-#include "util/geticon.h"
CSwordSettingsPage::CSwordSettingsPage(CConfigurationDialog * parent)
- : BtConfigDialog::Page(util::getIcon(CResMgr::settings::sword::icon), parent)
+ : BtConfigDialog::Page(CResMgr::settings::sword::icon(), parent)
{
static const QString nullString;
diff --git a/src/frontend/settingsdialogs/cswordsettings.h b/src/frontend/settingsdialogs/cswordsettings.h
index 18a4268..16f4b9a 100644
--- a/src/frontend/settingsdialogs/cswordsettings.h
+++ b/src/frontend/settingsdialogs/cswordsettings.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2014 by the BibleTime developers.
+* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,7 +12,8 @@
#ifndef CSWORDSETTINGS_H
#define CSWORDSETTINGS_H
-#include "frontend/bookshelfmanager/btconfigdialog.h"
+#include "btconfigdialog.h"
+
#include <QWidget>
@@ -26,7 +27,7 @@ class CSwordSettingsPage: public BtConfigDialog::Page {
public: /* Methods: */
- CSwordSettingsPage(CConfigurationDialog * parent = 0);
+ CSwordSettingsPage(CConfigurationDialog * parent = nullptr);
void save();