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