BibleTime
btstandardworkstab.cpp
Go to the documentation of this file.
1/*********
2*
3* In the name of the Father, and of the Son, and of the Holy Spirit.
4*
5* This file is part of BibleTime's source code, https://bibletime.info/
6*
7* Copyright 1999-2025 by the BibleTime developers.
8* The BibleTime source code is licensed under the GNU General Public License
9* version 2.0.
10*
11**********/
12
13#include "btstandardworkstab.h"
14
15#include <QComboBox>
16#include <QFormLayout>
17#include <QLabel>
18#include <QSizePolicy>
19#include <QStringList>
20#include <QVBoxLayout>
21#include "../../backend/config/btconfig.h"
22#include "../../backend/drivers/cswordlexiconmoduleinfo.h"
23#include "../../backend/drivers/cswordmoduleinfo.h"
24#include "../../backend/managers/cswordbackend.h"
25#include "../../util/tool.h"
26#include "cswordsettings.h"
27
28
30 : QWidget(parent)
31{
32 QVBoxLayout *mainLayout = new QVBoxLayout(this);
33 mainLayout->setContentsMargins(5, 5, 5, 5);
34 mainLayout->setSpacing(2);
35
36 m_explanationLabel = new QLabel(this);
37 m_explanationLabel->setSizePolicy(QSizePolicy::MinimumExpanding,
38 QSizePolicy::Preferred);
39 m_explanationLabel->setMaximumHeight(50);
40 m_explanationLabel->setMinimumWidth(300);
41 mainLayout->addWidget(m_explanationLabel);
42
43 QFormLayout *formLayout = new QFormLayout;
44 formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
45
46 static constexpr auto const toLexModule =
47 [](CSwordModuleInfo const * module)
48 { return static_cast<CSwordLexiconModuleInfo const *>(module); };
49#define STANDARD_WORKS_TAB_ADD_ROW(fname,...) \
50 if (true) { \
51 m_ ## fname ## Label = new QLabel(this); \
52 m_ ## fname ## Combo = new QComboBox(this); \
53 formLayout->addRow(m_ ## fname ## Label, m_ ## fname ## Combo); \
54 auto const * const defaultModule = \
55 btConfig().getDefaultSwordModuleByType(#fname); \
56 for (auto const * const m : CSwordBackend::instance().moduleList()) { \
57 if (m->type() == CSwordModuleInfo::__VA_ARGS__) { \
58 QString itemText; \
59 if (auto description = \
60 m->config(CSwordModuleInfo::Description); \
61 !description.isEmpty()) \
62 { \
63 itemText = \
64 tr("%1: %2", \
65 "module name: module description").arg( \
66 m->name(), \
67 std::move(description)); \
68 } else { \
69 itemText = m->name(); \
70 } \
71 auto itemData = \
72 QVariant::fromValue( \
73 const_cast<void *>(static_cast<void const *>(m))); \
74 m_ ## fname ## Combo->addItem(std::move(itemText), \
75 std::move(itemData)); \
76 if (m == defaultModule) \
77 m_ ## fname ## Combo->setCurrentIndex( \
78 m_ ## fname ## Combo->count() - 1); \
79 } \
80 } \
81 } else (void) 0
82
83 STANDARD_WORKS_TAB_ADD_ROW(standardBible, Bible);
84 STANDARD_WORKS_TAB_ADD_ROW(standardCommentary, Commentary);
86 standardLexicon,
87 Lexicon
90 && toLexModule(m)->hasStrongsKeys())
92 && toLexModule(m)->hasStrongsKeys())
96 standardDailyDevotional,
97 Lexicon
100 standardHebrewStrongsLexicon,
101 Lexicon
103 && toLexModule(m)->hasStrongsKeys());
105 standardGreekStrongsLexicon,
106 Lexicon
108 && toLexModule(m)->hasStrongsKeys());
110 standardHebrewMorphLexicon,
111 Lexicon && m->has(CSwordModuleInfo::FeatureHebrewParse));
113 standardGreekMorphLexicon,
114 Lexicon && m->has(CSwordModuleInfo::FeatureGreekParse));
115#undef STANDARD_WORKS_TAB_ADD_ROW
116
117 mainLayout->addLayout(formLayout);
118 mainLayout->addStretch();
119
121}
122
123#define STANDARD_WORKS_SET_DEFAULT(name) \
124 btConfig().setDefaultSwordModuleByType(\
125 #name, \
126 static_cast<CSwordModuleInfo const *>( \
127 m_ ## name ## Combo->currentData().value<void *>()))
129 STANDARD_WORKS_SET_DEFAULT(standardBible);
130 STANDARD_WORKS_SET_DEFAULT(standardCommentary);
131 STANDARD_WORKS_SET_DEFAULT(standardLexicon);
132 STANDARD_WORKS_SET_DEFAULT(standardDailyDevotional);
133 STANDARD_WORKS_SET_DEFAULT(standardHebrewStrongsLexicon);
134 STANDARD_WORKS_SET_DEFAULT(standardGreekStrongsLexicon);
135 STANDARD_WORKS_SET_DEFAULT(standardHebrewMorphLexicon);
136 STANDARD_WORKS_SET_DEFAULT(standardGreekMorphLexicon);
137}
138#undef STANDARD_WORKS_SET_DEFAULT
139
142 m_explanationLabel, QString(),
143 tr("Standard works are used when no particular work is specified, for "
144 "example when a hyperlink into a Bible or lexicon was clicked."));
145
146 m_standardBibleLabel->setText(tr("Bible:"));
147 m_standardBibleCombo->setToolTip(
148 tr("The standard Bible is used when a hyperlink into a Bible "
149 "is clicked"));
150
151 m_standardCommentaryLabel->setText(tr("Commentary:"));
152 m_standardCommentaryCombo->setToolTip(
153 tr("The standard commentary is used when a hyperlink into a "
154 "commentary is clicked"));
155
156 m_standardLexiconLabel->setText(tr("Lexicon:"));
157 m_standardLexiconCombo->setToolTip(
158 tr("The standard lexicon is used when a hyperlink into a "
159 "lexicon is clicked"));
160
161 m_standardDailyDevotionalLabel->setText(tr("Daily devotional:"));
162 m_standardDailyDevotionalCombo->setToolTip(
163 tr("The standard devotional will be used to display a short "
164 "start up devotional"));
165
166 m_standardHebrewStrongsLexiconLabel->setText(
167 tr("Hebrew Strong's lexicon:"));
168 m_standardHebrewStrongsLexiconCombo->setToolTip(
169 tr("The standard Hebrew lexicon is used when a hyperlink into "
170 "a Hebrew lexicon is clicked"));
171
172 m_standardGreekStrongsLexiconLabel->setText(tr("Greek Strong's lexicon:"));
173 m_standardGreekStrongsLexiconCombo->setToolTip(
174 tr("The standard Greek lexicon is used when a hyperlink into a "
175 "Greek lexicon is clicked"));
176
177 m_standardHebrewMorphLexiconLabel->setText(
178 tr("Hebrew morphological lexicon:"));
179 m_standardHebrewMorphLexiconCombo->setToolTip(
180 tr("The standard morphological lexicon for Hebrew texts is "
181 "used when a hyperlink of a morphological tag in a Hebrew "
182 "text is clicked"));
183
184 m_standardGreekMorphLexiconLabel->setText(
185 tr("Greek morphological lexicon:"));
186 m_standardGreekMorphLexiconCombo->setToolTip(
187 tr("The standard morphological lexicon for Greek texts is used "
188 "when a hyperlink of a morphological tag in a Greek text is "
189 "clicked"));
190}
#define STANDARD_WORKS_SET_DEFAULT(name)
#define STANDARD_WORKS_TAB_ADD_ROW(fname,...)
BtStandardWorksTab(CSwordSettingsPage *parent)
void initExplanationLabel(QLabel *const label, const QString &heading, const QString &text)
Initializes a QLabel to explain difficult things of dialogs.
Definition tool.cpp:78