BibleTime
bibletime.h
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-2026 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#pragma once
14
15#include <QMainWindow>
16
17#include <QList>
18#include <QPointer>
19#ifdef BUILD_TEXT_TO_SPEECH
20#include <QTextToSpeech>
21#endif
22#include <QTimer>
23#include "../backend/drivers/btmodulelist.h"
24#include "../backend/drivers/cswordmoduleinfo.h"
26
27
28namespace InfoDisplay { class CInfoDisplay; }
29namespace Search { class CSearchDialog; }
30class BibleTimeApp;
31class BtActionClass;
34class BtFindWidget;
38class CBookmarkIndex;
39class CDisplayWindow;
40class CKeyChooser;
41class CMDIArea;
42class QAction;
43class QMdiSubWindow;
44class QMenu;
45class QActionGroup;
46class QToolBar;
47class QSplitter;
48
49/**
50 * @page backend The structure of the backend
51 * <p>
52 * The backend implementation for Sword is called CSwordBackend, the classes we use
53 * to work with keys are called CSwordVerseKey and CSwordLDKey, both are derived from
54 * the class CSwordKey.
55 * The CSwordKey derived classes used for Sword do also inherit the classes
56 * VerseKey (CSwordVerseKey)
57 * and SWKey (CSwordLDKey).
58 * </p>
59 * <p>
60 * The classes used to handle all module based stuff are derived from CSwordModuleInfo.
61 * The module classes are: CSwordModuleInfo (for Sword modules),
62 * CSwordBibleModuleInfo (for bibles), CSwordCommentaryModuleInfo (for commentaries) and
63 * CSwordLexiconModuleInfo (for lexicons).
64 * Have a look at the class documentation of the mentioned classes to learn how the
65 * structure of them looks like and which class inherits which other class.
66 * </p>
67 * <p>
68 * The first objects which should be created in the application is the backend
69 * (for Sword the class is called CSwordBackend).
70 * Then create all the different module classes for the correct Sword modules.
71 * Have a look at
72 * BibleTime::initBackend() to see how it's done in BibleTime.@br
73 * Later you can work with them for example by using the CSwordKey and
74 * CSwordModuleInfo derived class.
75 * </p>
76 */
77
78/**
79 * @page frontend The structure of the frontend
80 *
81 * <p>
82 * The frontend contains the classes which interact with the user. For example the
83 * display windows, the searchdialog or the other parts.
84 * </p><p>
85 * The display windows which provide functionality are CBibleReadWindow for
86 * Bibles, CBookReadWindow for books, CCommentaryReadWindow for commentaries and CLexiconReadWindow for
87 * lexicon and dictionaries. CHTMLWriteWindow and CPlainWriteWindows are used for editing the Personal Commentary.
88 * </p><p>
89 *
90 * The class CDisplayWindow is the class that various views with in the windows are derived.
91 * </p><p>
92 *
93 * Another important part of the frontend are the keychoosers.
94 * They provide an interface to choose a key of a module.
95 * The interface for different module types is different.
96 * The base class is CKeyChooser which is the factory for the derived classes.
97 * Use the function CKeyChooser::createInstance to get the correct
98 * keychooser implementation for the desired module.<br/>
99 * </p><p>
100 * Some major toolbar widgets are CKeyChooser and BtDisplaySettingsButton.
101 * </p>
102 */
103
104/** @mainpage BibleTime - Source Code Documentation
105 * BibleTime main page.
106 * <p>This is the source code documentation of BibleTime, a Bible study tool.
107 * <p>
108 * The main class of BibleTime is called @ref BibleTime, which is the main window
109 * and initializes all important parts at startup.
110 * </p><p>
111 * BibleTime is divided in two major parts, the backend and the frontend.
112 * The text display windows belong to the @ref frontend.
113 * The backend is mainly a wrapper around Sword's classes to use Qt functionality
114 * to allow easy access to it's functionality and to have it in a (more or less :)
115 * object oriented structure.</p>
116 * <p>
117 * - Introduction to the frontend: @ref frontend<br/>
118 * - Introduction to the backend: @ref backend<br/>
119 * - Introduction to the model/view display: @ref modelviewmain<br/>
120 * </p>
121 */
122
123/** BibleTime's main class.
124 * The main class of BibleTime. Here are the main widgets created.
125 *
126 * This is the main class of BibleTime! This class creates the GUI, the QAction objects
127 * and connects to some slots. Please insert the creation of actions in initActions,
128 * the creation of widgets into initView and the connect(...) calls into initConnections.
129 * Reading from a config file on creation time should go into readSettings(), saving into
130 * saveSettings().
131 * This is the general way of all BibleTime classes.
132 */
133class BibleTime final : public QMainWindow {
134
135 Q_OBJECT
136
137 friend class CDisplayWindow;
138
139public: // Types:
140
142
143 public: // Fields:
144
145 struct { // File menu:
149
150 struct { // View menu:
156 struct { // Toolbars submenu:
163 struct { // Scroll submenu:
169
170 struct { // Search menu:
175
176 struct { // Windows menu:
183 struct { // Arrangement mode submenu:
193
194 struct { // Settings menu:
198
205
206 public: // Methods:
207
209 QAction * showBookshelfAction,
210 QAction * showBookmarksAction,
211 QAction * showMagAction,
212 QObject * parent = nullptr);
213
214 void retranslateUi();
215
216 };
217
218public:
219
221 QWidget * parent = nullptr,
222 Qt::WindowFlags flags = Qt::WindowFlags());
223
224 ~BibleTime() override;
225
226 static BibleTime * instance() noexcept { return m_instance; }
227
228 /** Saves the configuration dialog settings, doesn't open dialog. */
229 void saveConfigSettings();
230
231 /** \returns a pointer to the Navigation toolbar. */
232 QToolBar * navToolBar() const noexcept { return m_navToolBar; }
233
234 /** \returns a pointer to the Works toolbar. */
236 { return m_worksToolBar; }
237
238 /** \returns a pointer to the Tools toolbar. */
239 QToolBar * toolsToolBar() const noexcept { return m_toolsToolBar; }
240
241 /** \returns a pointer to the info display. */
243 { return m_infoDisplay; }
244
245 /** Clears the actions of the MDI related toolbars. */
246 void clearMdiToolBars();
247
248 /** \returns the main window CKeyChooser. */
249 CKeyChooser * keyChooser() const;
250
251 /**
252 Displays a dialog which asks the user an unlock key for the given module
253 and tries to unlock the module. If an invalid unlock key is given, a
254 warning message is issued and the user is again asked for the key.
255 \param[in] module The module to unlock.
256 \param[in] parent The parent widget for the unlock dialogs.
257 \returns whether the module was successfully unlocked.
258 */
259 static bool moduleUnlock(CSwordModuleInfo * module,
260 QWidget * parent = nullptr);
261
262 /** \returns a pointer to the module associated with the current window. */
264
265 /** \returns a pointer to the display associated with the current window. */
267
268 /** Opens the BtFindWidget below the MDI area. */
269 void openFindWidget();
270
271 /** Sets the focus on the display widget. */
272 void setDisplayFocus();
273
275 QString const & searchText = {});
276
277 #ifdef BUILD_TEXT_TO_SPEECH
278 /**
279 Speaks the given text.
280 \param[in] text The text to speak.
281 */
282 void speakText(QString const & text);
283
284 /**
285 Creates a QTextToSpeech instance, taking text-to-speech
286 settings into account.
287 \returns The QTextToSpeech instance.
288 */
289 static std::unique_ptr<QTextToSpeech> createTextToSpeechInstance();
290 #endif
291
292public Q_SLOTS:
293
294 /** Opens the optionsdialog of BibleTime. */
295 void slotSettingsOptions();
296
297 /** Opens the bookshelf wizard. */
298 void slotBookshelfWizard();
299
300 /** Opens the handbook. */
302
303 /** Opens the bible study howto. */
305
306 /** Opens the Tip Dialog. */
307 void slotOpenTipDialog();
308
309 /**
310 Processes the command-line options given to BibleTime.
311 \param[in] ignoreSession Specifies whether --ignore-session was used.
312 \param[in] bibleKey If --open-default-bible was used, the bible key
313 specified, or null otherwise.
314 */
315 void processCommandline(bool ignoreSession, QString const & bibleKey);
316
317 void autoScrollStop();
318
319Q_SIGNALS:
320
321 void toggledTextWindowHeader(bool newState);
322 void toggledTextWindowNavigator(bool newState);
323 void toggledTextWindowToolButtons(bool newState);
326
327private: // methods:
328
329 bool event(QEvent * event) override;
330
331 /** Creates the main window menu and toolbar. */
333
334 /** Creates MDI and and BtFindWidget. */
335 void createCentralWidget();
336
337 /** Initializes the view of this widget. */
338 void initView();
339
340 /** Initializes the menubar of BibleTime. */
341 void initMenubar();
342
343 /** Initializes the SIGNAL / SLOT connections. */
344 void initConnections();
345
346 /** Initializes the action objects of the GUI. */
347 void initActions();
348
349 /** Initializes the toolbars. */
350 void initToolbars();
351
352 /** Retranslates the UI. */
353 void retranslateUi();
354
355 /**
356 Refreshes all presenter supporting at least in of the features given as
357 parameter.
358 */
359 void refreshDisplayWindows() const;
360
361 template <bool goingUp>
362 void autoScroll();
363
364 /**
365 Set the visibility of all tool bars according to the configuration taking
366 the toolbarsInEachWindow setting into account.
367 */
368 void showOrHideToolBars();
369
370 void slotShowDebugWindow(bool);
371
372private Q_SLOTS:
373
374 /**
375 Creates a new presenter in the MDI area according to the type of the
376 module.
377 */
378 CDisplayWindow * createReadDisplayWindow(QList<CSwordModuleInfo *> modules,
379 QString const & key);
381 QString const & key = {});
382 void slotModuleUnlock(CSwordModuleInfo * module);
383 void moduleAbout(CSwordModuleInfo * module);
384
385 /** Automatically scrolls the display. */
386 void slotAutoScroll();
387
388 /** Called when the window menu is about to show. */
390
391 /** Called when the open windows menu is about to show. */
393
394 void slotUpdateWindowArrangementActions(QAction * trigerredAction);
395
396 void slotCascade();
397 void slotTile();
398 void slotTileVertical();
399 void slotTileHorizontal();
400
401 /** Shows or hides the main toolbar. */
406
408
409 /**
410 Shows or hides the text window text area headers and sets configuration
411 that newly opened windows don't user headers.
412 */
414
415 /** Used to set the active menu. */
416 void slotSetActiveSubWindow(QWidget * window);
417
418 void slotActiveWindowChanged(QMdiSubWindow * window);
419
420 /** Saves the current settings into the currently activated profile. */
421 void saveProfile();
422
423 /** Deletes the chosen session from the menu and from disk. */
424 void deleteProfile(QAction * action);
425
426 /** Loads the profile with the menu id ID. */
427 void loadProfile(QAction * action);
428
429 /** Loads the profile with the given key. */
430 void loadProfile(QString const & profileKey);
431
432 /** Reloads the current profile. */
433 void reloadProfile();
434
435 /** Toggles between normal and fullscreen mode. */
436 void toggleFullscreen();
437
438 void autoScrollPause();
439 bool autoScrollAnyKey();
440
442
443 /** Called when search button is pressed. */
444 void slotSearchModules();
445
446 /** Called for search default bible. */
448
449 /** Saves current settings into a new profile. */
450 void saveToNewProfile();
451
452 /** Refreshes the save profile and load profile menus. */
453 void refreshProfileMenus();
454
455 /** Open the About Dialog. */
456 void slotOpenAboutDialog();
457
458private: // fields:
459
461
462 // Docking widgets and their respective content widgets:
468
473
488
490
493
496 QPointer<Search::CSearchDialog> m_searchDialog;
497
499 QPointer<QWidget> m_debugWindow;
500
501 #ifdef BUILD_TEXT_TO_SPEECH
502 std::unique_ptr<QTextToSpeech> m_textToSpeech;
503 #endif
504
505};
506
507extern template void BibleTime::autoScroll<true>();
508extern template void BibleTime::autoScroll<false>();
QList< CSwordModuleInfo const * > BtConstModuleList
struct BibleTime::ActionCollection::@5 settings
struct BibleTime::ActionCollection::@3 search
struct BibleTime::ActionCollection::@1 file
BtOpenWorkAction * openWork
Definition bibletime.h:146
struct BibleTime::ActionCollection::@4 windows
struct BibleTime::ActionCollection::@2 view
struct BibleTime::ActionCollection::@2::@7 scroll
struct BibleTime::ActionCollection::@2::@6 toolbars
struct BibleTime::ActionCollection::@4::@8 arrangementMode
QAction * showToolbarsInTextWindows
Definition bibletime.h:161
void loadProfile(QAction *action)
QMenu * m_toolBarsMenu
Definition bibletime.h:476
QPointer< QWidget > m_debugWindow
Definition bibletime.h:499
void slotModuleUnlock(CSwordModuleInfo *module)
BtModuleChooserBar * m_worksToolBar
Definition bibletime.h:471
QMenu * m_searchMenu
Definition bibletime.h:478
void clearMdiToolBars()
QActionGroup * m_windowArrangementActionGroup
Definition bibletime.h:482
BtBookshelfDockWidget * m_bookshelfDock
Definition bibletime.h:463
void slotBookshelfWizard()
void slotOpenTipDialog()
void slotSearchModules()
static bool moduleUnlock(CSwordModuleInfo *module, QWidget *parent=nullptr)
void retranslateUi()
void slotShowDebugWindow(bool)
int m_autoScrollSpeed
Definition bibletime.h:494
void moduleAbout(CSwordModuleInfo *module)
QDockWidget * m_magDock
Definition bibletime.h:466
CKeyChooser * keyChooser() const
QToolBar * m_mainToolBar
Definition bibletime.h:469
QAction * m_debugWidgetAction
Definition bibletime.h:498
QMenu * m_fileMenu
Definition bibletime.h:474
void slotActiveWindowChanged(QMdiSubWindow *window)
ActionCollection * m_actions
Definition bibletime.h:489
void slotSearchActiveWindow()
void deleteProfile(QAction *action)
void openFindWidget()
void slotTileHorizontal()
CMDIArea * m_mdi
Definition bibletime.h:491
InfoDisplay::CInfoDisplay * m_infoDisplay
Definition bibletime.h:467
void slotUpdateWindowArrangementActions(QAction *trigerredAction)
void toggledTextWindowToolButtons(bool newState)
void createCentralWidget()
bool event(QEvent *event) override
void slotToggleWorksToolbar()
void slotOpenAboutDialog()
void toggledTextWindowHeader(bool newState)
void initToolbars()
void openSearchDialog(BtConstModuleList modules, QString const &searchText={})
void slotSearchDefaultBible()
void slotSettingsOptions()
void slotToggleMainToolbar()
void autoScrollPause()
void slotToggleTextWindowHeader()
static BibleTime * m_instance
Definition bibletime.h:460
QDockWidget * m_bookmarksDock
Definition bibletime.h:464
QToolBar * toolsToolBar() const noexcept
Definition bibletime.h:239
CBookmarkIndex * m_bookmarksPage
Definition bibletime.h:465
void showOrHideToolBars()
void colorThemeChanged()
void setDisplayFocus()
void slotAutoScroll()
void toggledTextWindowNavigator(bool newState)
QMenu * m_settingsMenu
Definition bibletime.h:486
void slotOpenWindowsMenuAboutToShow()
void openOnlineHelp_Handbook()
void initConnections()
static BibleTime * instance() noexcept
Definition bibletime.h:226
void createMenuAndToolBar()
QMenu * m_windowDeleteProfileMenu
Definition bibletime.h:485
BtModuleChooserBar * worksToolBar() const noexcept
Definition bibletime.h:235
void refreshProfileMenus()
void slotToggleToolsToolbar()
QToolBar * m_toolsToolBar
Definition bibletime.h:472
void slotToggleToolBarsInEachWindow()
void toggledTextWindowModuleChooser(bool newState)
QToolBar * navToolBar() const noexcept
Definition bibletime.h:232
QToolBar * m_navToolBar
Definition bibletime.h:470
BtFindWidget * m_findWidget
Definition bibletime.h:492
InfoDisplay::CInfoDisplay * infoDisplay() const noexcept
Definition bibletime.h:242
QMenu * m_viewMenu
Definition bibletime.h:475
void saveToNewProfile()
QPointer< Search::CSearchDialog > m_searchDialog
Definition bibletime.h:496
void slotTileVertical()
CSwordModuleInfo const * getCurrentModule()
QMenu * m_scrollMenu
Definition bibletime.h:477
BtModelViewReadDisplay * getCurrentDisplay()
void openOnlineHelp_Howto()
~BibleTime() override
void processCommandline(bool ignoreSession, QString const &bibleKey)
void slotWindowMenuAboutToShow()
QMenu * m_windowsMenu
Definition bibletime.h:479
QMenu * m_helpMenu
Definition bibletime.h:487
void autoScrollStop()
void saveConfigSettings()
QMenu * m_windowLoadProfileMenu
Definition bibletime.h:483
QActionGroup * m_windowLoadProfileActionGroup
Definition bibletime.h:484
CDisplayWindow * createReadDisplayWindow(QList< CSwordModuleInfo * > modules, QString const &key)
Creates a new presenter in the MDI area according to the type of the module.
void refreshDisplayWindows() const
void slotToggleNavigatorToolbar()
QTimer m_autoScrollTimer
Definition bibletime.h:495
QMenu * m_openWindowsMenu
Definition bibletime.h:480
void slotSetActiveSubWindow(QWidget *window)
void toggleFullscreen()
bool autoScrollAnyKey()
QMenu * m_windowArrangementMenu
Definition bibletime.h:481
The base class for all display windows of BibleTime.