BibleTime
bttipdialog.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 "bttipdialog.h"
14
15#include <QCheckBox>
16#include <QColor>
17#include <QDesktopServices>
18#include <QDialogButtonBox>
19#include <QFlags>
20#include <QFont>
21#include <QHBoxLayout>
22#include <QPalette>
23#include <QPushButton>
24#include <QSizePolicy>
25#include <QTextBrowser>
26#include <QVBoxLayout>
27#include <QWidget>
28#include "../../backend/config/btconfig.h"
29#include "../../util/btconnect.h"
30#include "../../util/bticons.h"
31#include "../../util/cresmgr.h"
32#include "../messagedialog.h"
33
34
35class QUrl;
36
37namespace {
38
39inline QString vertical_align(const QString &text) {
40 return QStringLiteral(
41 "<table height=\"100%\"><tr>"
42 "<td style=\"vertical-align:middle\" height=\"100%\">%1</td>"
43 "</tr></table>").arg(text);
44}
45
46inline QString make_style(QWidget *widget) {
47 auto const & p = widget->palette();
48 return QStringLiteral(
49 "<style type=\"text/css\">"
50 "body{"
51 "background-color:%1;"
52 "color:%2"
53 "}"
54 "h3{font-weight:bold;text-align:center}"
55 "a{text-decoration:underline}"
56 "a:link{color:%3}"
57 "a:visited{color:%4}"
58 "</style>")
59 .arg(p.color(QPalette::Base).name(),
60 p.color(QPalette::Text).name(),
61 p.color(QPalette::Link).name(),
62 p.color(QPalette::LinkVisited).name());
63}
64
65inline QString make_html(QWidget *widget, const QString &text) {
66 return QStringLiteral("<html><head>%1</head><body>%2</body></html>")
67 .arg(make_style(widget), vertical_align(text));
68}
69
70auto const LastTipNumberKey = QStringLiteral("GUI/lastTipNumber");
71
72} // anonymous namespace
73
74
75BtTipDialog::BtTipDialog(QWidget *parent, Qt::WindowFlags wflags)
76 : QDialog(parent, wflags)
77{
78 setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
79 setWindowTitle(tr("Tip Of The Day"));
80 setWindowIcon(CResMgr::mainMenu::help::tipOfTheDay::icon());
81 resize(450, 240);
82
83 QVBoxLayout *mainLayout = new QVBoxLayout;
84
85 m_tipView = new QTextBrowser(this);
86 m_tipView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
87 m_tipView->setOpenExternalLinks(true);
88 m_tipView->setStyleSheet(
89 QStringLiteral("QTextEdit{background-color:rgb(255,255,255)}"));
90 QFont font = m_tipView->font();
91 font.setPointSize(font.pointSize()+2);
92 m_tipView->setFont(font);
93 mainLayout->addWidget(m_tipView);
94
95 QHBoxLayout* hLayout = new QHBoxLayout;
96
97 m_showTipsCheckBox = new QCheckBox;
98 m_showTipsCheckBox->setText(tr("Show tips at startup"));
99 m_showTipsCheckBox->setChecked(
100 btConfig().value<bool>(QStringLiteral("GUI/showTipAtStartup"),
101 true));
102 hLayout->addWidget(m_showTipsCheckBox);
103
104 m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Close,
105 Qt::Horizontal,
106 this);
108
109 QPushButton *nextButton;
110 nextButton = m_buttonBox->addButton(tr("Next Tip"),
111 QDialogButtonBox::ActionRole);
112 hLayout->addWidget(m_buttonBox);
113
114 mainLayout->addLayout(hLayout);
115 setLayout(mainLayout);
116
117 BT_CONNECT(m_showTipsCheckBox, &QCheckBox::toggled,
118 [](bool v) { btConfig().setValue("GUI/showTipAtStartup", v); });
119 BT_CONNECT(m_buttonBox, &QDialogButtonBox::rejected,
120 this, &BtTipDialog::reject);
121 BT_CONNECT(nextButton, &QPushButton::clicked,
122 [this]{
123 m_tipNumber = (m_tipNumber + 1) % m_tips.size();
124 btConfig().setValue(LastTipNumberKey, m_tipNumber);
125 displayTip();
126 });
127 BT_CONNECT(m_tipView, &QTextBrowser::anchorClicked,
128 [](QUrl const & url) { QDesktopServices::openUrl(url); });
129
130 m_tipNumber = btConfig().value<int>(LastTipNumberKey, 0);
132}
133
135 m_tips.clear();
136
137 m_tips << tr("The currently active window can be auto scrolled up or down."
138 " Start scrolling by pressing Shift+Down. You can increase the"
139 " scrolling speed by pressing Shift+Down multiple times. To"
140 " pause scrolling press Space. To start scrolling again at the"
141 " previous speed press Space again. To slow down scrolling or scroll"
142 " the other direction press Shift+Up one or more times. Pressing"
143 " any other key or changing the active window will stop the scrolling.");
144
145 m_tips << tr("To add multiple Bible works in parallel in your active Bible or commentary window"
146 " select this icon and choose another Bible or commentary work.")
147 + "<br><center>" + iconToHtml(CResMgr::modules::bible::icon_add()) + "</center>";
148
149 m_tips << tr("To add multiple commentary works in parallel in your active commentary window"
150 " select this icon and choose another commentary work.")
151 + "<br><center>" + iconToHtml(CResMgr::modules::commentary::icon_add()) + "</center>";
152
153 m_tips << tr("To learn more about the BibleTime project please go to our web site.")
154 + "<br><center><a href=\"" BT_HOMEPAGE "\">" BT_HOMEPAGE "</a></center>";
155
156 m_tips << tr("To synchronize a commentary window with the active Bible window, activate the"
157 " commentary window and select this icon.") + "<br><center>"
158 + iconToHtml(CResMgr::displaywindows::commentaryWindow::syncWindow::icon())
159 + "</center><br>" + tr("Select the icon again to stop the synchronization.");
160
161 m_tips << tr("To create a bookmark drag any verse reference from a Bible or commentary work"
162 " into the Bookmarks window. An arrow will indicate the position that the bookmark will"
163 " go when you release the cursor. Other works will have a reference in the upper left"
164 " corner that can be used to create a bookmark.");
165
166 m_tips << tr("To change a bookmark title or description, right click on the bookmark"
167 " and select the Edit Bookmark menu. After finishing the edit the description can be"
168 " seen by hovering over the bookmark.");
169
170 m_tips << tr("To find more information about a work, go the the Bookshelf window, right"
171 " click on the work, and select the About menu.");
172
173 m_tips << tr("The Bookshelf, Bookmark, and Mag windows can be moved to new locations by"
174 " dragging them from the title at the top of each window. They can be placed to the left,"
175 " right, above, or below the works windows. They can be placed on top of each other and"
176 " tabs will appear so each window can be selected. They can be resized by dragging the"
177 " border between the window and another window.");
178
179 m_tips << tr("You can search for Strong's numbers in a work. Start with a work that has Strong's"
180 " numbers and hover over a word. Right click the word and use the Strong's Search"
181 " menu. A search dialog will appear that allows you to see the use of the same"
182 " Strong's number in other locations of the work.");
183
184 m_tips << tr("You can save personal notes for specific verse references. You must install"
185 " the Personal commentary. Open the Bookshelf Manager, choose Crosswire as the"
186 " source, English as the language, and look under Commentary. Once installed, open it"
187 " like any other window, or in parallel with a bible. Click a verse to edit it.");
188
189 m_tips << tr("You can view Strong's number information in the MAG window by hovering over"
190 " a word in a Bible work that has Strong's numbers. You should have the StrongsGreek"
191 " and StrongsHebrew lexicons from Crosswire installed.");
192
193 m_tips << tr("You can save your open windows in a session. Such a session can easily be restored"
194 " later on. You can save as many sessions as you like. The session feature can be"
195 " accessed under the Window menu entry.");
196
197 displayTip();
198}
199
201{ m_tipView->setHtml(make_html(this, m_tips[m_tipNumber])); }
BtConfig & btConfig()
This is a shortchand for BtConfig::getInstance().
Definition btconfig.h:305
#define BT_CONNECT(...)
Definition btconnect.h:20
QString iconToHtml(QIcon const &icon, int const extent)
Definition bticons.cpp:193
T value(QString const &key, T const &defaultValue=T()) const
Returns the settings value for the given global key.
void setValue(QString const &key, T const &value)
Sets a value for a key.
QTextBrowser * m_tipView
Definition bttipdialog.h:47
void retranslateUi()
QDialogButtonBox * m_buttonBox
Definition bttipdialog.h:46
void displayTip()
QStringList m_tips
Definition bttipdialog.h:50
BtTipDialog(QWidget *parent=nullptr, Qt::WindowFlags wflags=Qt::Dialog)
QCheckBox * m_showTipsCheckBox
Definition bttipdialog.h:48
QString vertical_align(const QString &text)
QString make_html(QWidget *widget, const QString &text)
QString make_style(QWidget *widget)
void prepareDialogBox(QDialogButtonBox *box)