BibleTime
btaboutdialog.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 "btaboutdialog.h"
14
15#include <QApplication>
16#include <QColor>
17#include <QDebug>
18#include <QDesktopServices>
19#include <QDialogButtonBox>
20#include <QDir>
21#include <QFile>
22#include <QFont>
23#include <QFontMetrics>
24#include <QHBoxLayout>
25#include <QIODevice>
26#include <QLabel>
27#include <QPalette>
28#include <QPlainTextEdit>
29#include <QTabWidget>
30#include <QTextBrowser>
31#include <QTextStream>
32#include <QtGlobal>
33#include <QUrl>
34#include <QVBoxLayout>
35#include <QWidget>
36#include <utility>
37#include "../util/btconnect.h"
38#include "../util/bticons.h"
39#include "../util/directory.h"
40#include "messagedialog.h"
41
42// Sword includes:
43#include <swversion.h>
44
45
46#define MAKE_STYLE(t) "<style type=\"text/css\">"\
47 "body{"\
48 "background-color:" + (t)->palette().color(QPalette::Window).name() + ";"\
49 "color:" + (t)->palette().color(QPalette::WindowText).name() +\
50 "}"\
51 "h3{font-weight:bold;text-align:center}"\
52 "a{text-decoration:underline}"\
53 "a:link{color:" + (t)->palette().color(QPalette::Link).name() + "}"\
54 "a:visited{color:" + (t)->palette().color(QPalette::LinkVisited).name() + "}"\
55 "</style>"
56#define MAKE_HTML(t,x) "<html><head>" MAKE_STYLE(t) "</head><body>" + (x) + "</body></html>"
57#define MAKE_LINK(c,u,t) "<a href=\"" u "\">"; (c) += (t); (c) += "</a>"
58#define MAKE_LINK_STATIC(u,t) "<a href=\"" u "\">" t "</a>"
59#define MAKE_CONTR(c,n,r) "<li>" n " (";\
60 (c) += (r);\
61 (c) += ")</li>"
62#define MAKE_CONTR2(c,n,r,r2) "<li>" n " (";\
63 (c) += (r);\
64 (c) += ", ";\
65 (c) += (r2);\
66 (c) += ")</li>"
67
68class BtAboutDialog::LicenseTab final : public QWidget {
69
70public: // Methods:
71
73 : QWidget(parent)
74 , m_label(new QLabel(this))
75 , m_licenseBrowser(new QPlainTextEdit(this))
76 {
77 auto * const mainLayout = new QVBoxLayout(this);
78
79 m_label->setWordWrap(true);
80 mainLayout->addWidget(m_label);
81
82 m_licenseBrowser->setReadOnly(true);
83 { // Set monospace font:
84 QFont licenseFont(QStringLiteral("BibleTime nonexistant font"));
85 licenseFont.setStyleHint(QFont::Monospace);
86 m_licenseBrowser->setFont(std::move(licenseFont));
87 }
88 mainLayout->addWidget(m_licenseBrowser);
89 }
90
91 void setLabelText(QString const & text) { m_label->setText(text); }
92
93 void setLicense(QString const & license)
94 { m_licenseBrowser->setPlainText(license); }
95
96private: // Fields
97
98 QLabel * const m_label;
99 QPlainTextEdit * const m_licenseBrowser;
100
101}; // LicenseTab
102
103BtAboutDialog::BtAboutDialog(QWidget *parent, Qt::WindowFlags wflags)
104 : QDialog(parent, wflags)
105{
106 setAttribute(Qt::WA_DeleteOnClose);
107 resize(640, 380);
108
109 QVBoxLayout *mainLayout = new QVBoxLayout;
110
111 QWidget *top = new QWidget(this);
112 QHBoxLayout *topLayout = new QHBoxLayout;
113 m_iconLabel = new QLabel(this);
114 m_iconLabel->setPixmap(BtIcons::instance().icon_bibletime.pixmap(48));
115 topLayout->addWidget(m_iconLabel);
116 m_versionLabel = new QLabel(this);
117 QFont font = m_versionLabel->font();
118 font.setPointSize(font.pointSize()+6);
119 font.setBold(true);
120 m_versionLabel->setFont(font);
121 topLayout->addWidget(m_versionLabel);
122 top->setLayout(topLayout);
123 mainLayout->addWidget(top, 0, Qt::AlignCenter);
124
125 m_tabWidget = new QTabWidget(this);
126 mainLayout->addWidget(m_tabWidget);
127
128 auto const addTab = [this]{
129 auto * const tab = new QTextBrowser(this);
130 tab->setOpenLinks(false);
131 m_tabWidget->addTab(tab, "");
132 BT_CONNECT(tab, &QTextBrowser::anchorClicked,
133 [](QUrl const & url) {
134 if (url.scheme() == "qt") {
135 qApp->aboutQt();
136 } else {
137 QDesktopServices::openUrl(url);
138 }
139 });
140 return tab;
141 };
142
143 m_bibletimeTab = addTab();
144 m_contributorsTab = addTab();
145 m_swordTab = addTab();
146 m_qtTab = addTab();
147
148 {
149 auto const & licensePath = util::directory::getLicensePath();
150 QFile licenseFile(licensePath);
151 if (licenseFile.open(QFile::ReadOnly)) {
152 m_licenseTab = new LicenseTab(this);
153 m_licenseTab->setLicense(QTextStream(&licenseFile).readAll());
154 m_tabWidget->addTab(m_licenseTab, "");
155 licenseFile.close();
156 } else {
157 qWarning() << "Failed to read license from" << licensePath;
158 }
159 }
160
161 m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this);
162 mainLayout->addWidget(m_buttonBox);
163 setLayout(mainLayout);
164
165 BT_CONNECT(m_buttonBox, &QDialogButtonBox::rejected,
166 this, &BtAboutDialog::reject);
167
169}
170
171void BtAboutDialog::resizeEvent(QResizeEvent* event) {
172 Q_UNUSED(event)
173 QString version = "BibleTime " BT_VERSION;
174 QFontMetrics fm(m_versionLabel->font());
175 int w = width() - m_iconLabel->width() - 80;
176 QString shortVersion = fm.elidedText(version, Qt::ElideMiddle, w);
177 m_versionLabel->setText(shortVersion);
178}
179
181 setWindowTitle(tr("About BibleTime"));
182
188
190}
191
193 m_tabWidget->setTabText(0, tr("&BibleTime"));
194
195 QString content("<p>");
196 content += tr("BibleTime is an easy to use but powerful Bible study tool.");
197 content += "</p><p>";
198 content += tr("(c)1999-2025, The BibleTime Team");
199 content += "</p><p>" MAKE_LINK_STATIC(BT_HOMEPAGE, BT_HOMEPAGE) "</p>";
200 m_bibletimeTab->setHtml(MAKE_HTML(m_bibletimeTab, content));
201}
202
204 m_tabWidget->setTabText(1, tr("&Contributors"));
205
206 const QString developer(tr("developer"));
207 const QString designer(tr("designer"));
208 const QString artist(tr("artist"));
209
210 /****************************************************************************************
211 *** NB!!! Credits are sorted alphabetically by last name! ***
212 ****************************************************************************************/
213
214 QString content("<p><b>");
215 content += tr("The following people contributed to BibleTime:");
216 content += "</b></p><ul>"
217 MAKE_CONTR(content, "Thomas Abthorpe", tr("documentation and translation manager"))
218 MAKE_CONTR2(content, "Joachim Ansorg", tr("project founder"), developer)
219 MAKE_CONTR(content, "David Blue", designer)
220 MAKE_CONTR(content, "Tim Brodie", developer)
221 MAKE_CONTR(content, "Timothy R. Butler", designer)
222 MAKE_CONTR(content, "Jim Campbell", developer)
223 MAKE_CONTR(content, "Lee Carpenter", developer)
224 MAKE_CONTR(content, "Jeremy Erickson", tr("packager"))
225 MAKE_CONTR(content, "Troy A. Griffitts", tr("creator of The Sword Project"))
226 MAKE_CONTR(content, "Martin Gruner", developer)
227 MAKE_CONTR(content, "Thomas Hagedorn", tr("domain sponsor"))
228 MAKE_CONTR(content, "Bob Harman", tr("howto"))
229 MAKE_CONTR(content, "Gary Holmlund", developer)
230 MAKE_CONTR(content, "Nikolay Igotti", developer)
231 MAKE_CONTR(content, "Laurent Valentin Jospin", artist)
232 MAKE_CONTR(content, "Eeli Kaikkonnen", developer)
233 MAKE_CONTR(content, "Chris Kujawa", developer)
234 MAKE_CONTR(content, "Mark Lybarger", developer)
235 MAKE_CONTR(content, "Konstantin Maslyuk", developer)
236 MAKE_CONTR(content, "Luke Mauldin", developer)
237 MAKE_CONTR(content, "James Ots", designer)
238 MAKE_CONTR(content, "Andrus Raag", artist)
239 MAKE_CONTR2(content, "Jaak Ristioja", tr("project manager"), developer)
240 MAKE_CONTR(content, "Fred Saalbach", tr("documentation"))
241 MAKE_CONTR(content, "Erik Schanze", tr("documentation"))
242 MAKE_CONTR(content, "Gary Sims", developer)
243 MAKE_CONTR2(content, "Wolfgang Stradner", tr("tester"), tr("usability expert"))
244 MAKE_CONTR(content, "Kang Sun", developer)
245 MAKE_CONTR(content, "Thorsten Uhlmann", developer)
246 MAKE_CONTR(content, "John Turpish", developer)
247 MAKE_CONTR(content, "David White", developer)
248 MAKE_CONTR(content, "Mark Zealey", developer)
249 MAKE_CONTR(content, "Patrick Sebastian Zimmermann", developer)
250 "</ul><p><b>";
251
252
253 /****************************************************************************************
254 *** NB!!! Credits are sorted alphabetically by last name! ***
255 ****************************************************************************************/
256 content += tr("The following people translated BibleTime into their language:");
257 content += "</b></p><ul>"
258 "<li>Roy Alvear Aguirre</li>"
259 "<li>Horatiu Alexe</li>"
260 "<li>Andrew Alfy</li>"
261 "<li>Jan B&#x11B;lohoubek</li>"
262 "<li>Luis Barron</li>"
263 "<li>M&aacute;rio Castanheira</li>"
264 "<li>Chun-shek Chan</li>"
265 "<li>Ján Ďanovský</li>"
266 "<li>Nouhoun Y. Diarra</li>"
267 "<li>Rafael Fagundes</li>"
268 "<li>Eeli Kaikkonen</li>"
269 "<li>Ilpo Kantonen</li>"
270 "<li>Pavel Laukko</li>"
271 "<li>Johan van der Lingen</li>"
272 "<li>Piotr Markiewicz</li>"
273 "<li>Konstantin Maslyuk</li>"
274 "<li>G&eacute;za Nov&aacute;k</li>"
275 "<li>Gabriel P&eacute;rez</li>"
276 "<li>Igor Plisco</li>"
277 "<li>Zdenko Podobn&yacute;</li>"
278 "<li>Jaak Ristioja</li>"
279 "<li>Igor Rykhlin</li>"
280 "<li>Vlad Savitsky</li>"
281 "<li>Jean Van Schaftingen</li>"
282 "<li>Flavio Theodor de Lima Silva</li>"
283 "<li>Henrik Sonesson</li>"
284 "<li>Giovanni Tedaldi</li>"
285 "<li>Roland Teschner</li>"
286 "<li>Damian Wrzalski</li>"
287 "<li>Dmitry Yurevich</li>"
288 "<li>Esteban Zeller</li>"
289 "<li>Aaron Zhou</li>"
290 "</ul><p>";
291 content += tr("Some names may be missing, please file an issue at %1 if "
292 "you notice errors or omissions.").arg(MAKE_LINK_STATIC(
293 "https://github.com/bibletime/bibletime/issues",
294 "https://github.com/bibletime/bibletime/issues"));
295 content += "</p>";
296
298}
299
300
302 m_tabWidget->setTabText(2, tr("&SWORD"));
303
304 QString version(sword::SWVersion::currentVersion.getText());
305 QString content("<h3>");
306 content += tr("SWORD library version %1").arg(version);
307 content += "</h3><p>";
308 content += tr("BibleTime makes use of the SWORD Project. The SWORD Project is the "
309 "CrossWire Bible Society's free Bible software project. Its purpose is to "
310 "create cross-platform open-source tools &mdash; covered by the GNU "
311 "General Public License &mdash; that allow programmers and Bible "
312 "societies to write new Bible software more quickly and easily.");
313 content += "</p><p>";
314 content += tr("The SWORD Project: ");
315 content += MAKE_LINK_STATIC("http://www.crosswire.org/sword/",
316 "www.crosswire.org/sword") "</p>";
317
318 m_swordTab->setHtml(MAKE_HTML(m_swordTab, content));
319}
320
322 m_tabWidget->setTabText(3, tr("&Qt"));
323
324 QString content("<h3>");
325 content += tr("Qt toolkit version %1").arg(qVersion());
326 content += "</h3><p>";
327 content += tr("This program uses Qt version %1.").arg(qVersion());
328 content += "</p><p>";
329 content += tr("Qt is a cross-platform application and UI framework, created with C++ "
330 "language. It has been released under the LGPL license.");
331
332 content += " " MAKE_LINK(content, "qt://about", tr("More info...")) "</p>";
333
334 m_qtTab->setHtml(MAKE_HTML(m_qtTab, content));
335}
336
338 if (!m_licenseTab)
339 return;
340
341 m_tabWidget->setTabText(m_tabWidget->indexOf(m_licenseTab), tr("&License"));
342
344 QStringLiteral("<p>%1</p><p>%2</p>")
345 .arg(tr("BibleTime is released under the GPL license. You "
346 "can download and use the program for personal, "
347 "private, public or commercial purposes without "
348 "restrictions, but can give away or distribute the "
349 "program only if you also distribute the "
350 "corresponding source code."),
351 tr("The complete legally binding license is below.")));
352}
#define MAKE_LINK(c, u, t)
#define MAKE_CONTR(c, n, r)
#define MAKE_CONTR2(c, n, r, r2)
#define MAKE_HTML(t, x)
#define MAKE_LINK_STATIC(u, t)
#define BT_CONNECT(...)
Definition btconnect.h:20
void setLicense(QString const &license)
QPlainTextEdit *const m_licenseBrowser
LicenseTab(QWidget *parent)
void setLabelText(QString const &text)
QLabel * m_versionLabel
BtAboutDialog(QWidget *parent=nullptr, Qt::WindowFlags wflags=Qt::Dialog)
QTextBrowser * m_bibletimeTab
QTextBrowser * m_qtTab
QTextBrowser * m_swordTab
QTabWidget * m_tabWidget
QDialogButtonBox * m_buttonBox
QLabel * m_iconLabel
void retranslateSwordTab()
void retranslateLicenceTab()
void retranslateContributorsTab()
void resizeEvent(QResizeEvent *event) override
QTextBrowser * m_contributorsTab
LicenseTab * m_licenseTab
static BtIcons & instance()
Definition bticons.h:44
void prepareDialogBox(QDialogButtonBox *box)
QString const & getLicensePath()