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-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#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:
171
172 struct { // Windows menu:
179 struct { // Arrangement mode submenu:
189
190 struct { // Settings menu:
194
201
202 public: // Methods:
203
205 QAction * showBookshelfAction,
206 QAction * showBookmarksAction,
207 QAction * showMagAction,
208 QObject * parent = nullptr);
209
210 void retranslateUi();
211
212 };
213
214public:
215
217 QWidget * parent = nullptr,
218 Qt::WindowFlags flags = Qt::WindowFlags());
219
220 ~BibleTime() override;
221
222 static BibleTime * instance() noexcept { return m_instance; }
223
224 /** Saves the configuration dialog settings, doesn't open dialog. */
225 void saveConfigSettings();
226
227 /** \returns a pointer to the Navigation toolbar. */
228 QToolBar * navToolBar() const noexcept { return m_navToolBar; }
229
230 /** \returns a pointer to the Works toolbar. */
232 { return m_worksToolBar; }
233
234 /** \returns a pointer to the Tools toolbar. */
235 QToolBar * toolsToolBar() const noexcept { return m_toolsToolBar; }
236
237 /** \returns a pointer to the info display. */
239 { return m_infoDisplay; }
240
241 /** Clears the actions of the MDI related toolbars. */
242 void clearMdiToolBars();
243
244 /** \returns the main window CKeyChooser. */
245 CKeyChooser * keyChooser() const;
246
247 /**
248 Displays a dialog which asks the user an unlock key for the given module
249 and tries to unlock the module. If an invalid unlock key is given, a
250 warning message is issued and the user is again asked for the key.
251 \param[in] module The module to unlock.
252 \param[in] parent The parent widget for the unlock dialogs.
253 \returns whether the module was successfully unlocked.
254 */
255 static bool moduleUnlock(CSwordModuleInfo * module,
256 QWidget * parent = nullptr);
257
258 /** \returns a pointer to the module associated with the current window. */
260
261 /** \returns a pointer to the display associated with the current window. */
263
264 /** Opens the BtFindWidget below the MDI area. */
265 void openFindWidget();
266
267 /** Sets the focus on the display widget. */
268 void setDisplayFocus();
269
271 QString const & searchText = {});
272
273public Q_SLOTS:
274
275 /** Opens the optionsdialog of BibleTime. */
276 void slotSettingsOptions();
277
278 /** Opens the bookshelf wizard. */
279 void slotBookshelfWizard();
280
281 /** Opens the handbook. */
283
284 /** Opens the bible study howto. */
286
287 /** Opens the Tip Dialog. */
288 void slotOpenTipDialog();
289
290 /**
291 Processes the command-line options given to BibleTime.
292 \param[in] ignoreSession Specifies whether --ignore-session was used.
293 \param[in] bibleKey If --open-default-bible was used, the bible key
294 specified, or null otherwise.
295 */
296 void processCommandline(bool ignoreSession, QString const & bibleKey);
297
298 void autoScrollStop();
299
300Q_SIGNALS:
301
302 void toggledTextWindowHeader(bool newState);
303 void toggledTextWindowNavigator(bool newState);
304 void toggledTextWindowToolButtons(bool newState);
307
308private: // methods:
309
310 bool event(QEvent * event) override;
311
312 /** Creates the main window menu and toolbar. */
314
315 /** Creates MDI and and BtFindWidget. */
316 void createCentralWidget();
317
318 /** Initializes the view of this widget. */
319 void initView();
320
321 /** Initializes the menubar of BibleTime. */
322 void initMenubar();
323
324 /** Initializes the SIGNAL / SLOT connections. */
325 void initConnections();
326
327 /** Initializes the action objects of the GUI. */
328 void initActions();
329
330 /** Initializes the toolbars. */
331 void initToolbars();
332
333 /** Retranslates the UI. */
334 void retranslateUi();
335
336 /**
337 Refreshes all presenter supporting at least in of the features given as
338 parameter.
339 */
340 void refreshDisplayWindows() const;
341
342 template <bool goingUp>
343 void autoScroll();
344
345 /**
346 Set the visibility of all tool bars according to the configuration taking
347 the toolbarsInEachWindow setting into account.
348 */
349 void showOrHideToolBars();
350
351 void slotShowDebugWindow(bool);
352
353private Q_SLOTS:
354
355 /**
356 Creates a new presenter in the MDI area according to the type of the
357 module.
358 */
359 CDisplayWindow * createReadDisplayWindow(QList<CSwordModuleInfo *> modules,
360 QString const & key);
362 QString const & key = {});
363 void slotModuleUnlock(CSwordModuleInfo * module);
364 void moduleAbout(CSwordModuleInfo * module);
365
366 /** Automatically scrolls the display. */
367 void slotAutoScroll();
368
369 /** Called when the window menu is about to show. */
371
372 /** Called when the open windows menu is about to show. */
374
375 void slotUpdateWindowArrangementActions(QAction * trigerredAction);
376
377 void slotCascade();
378 void slotTile();
379 void slotTileVertical();
380 void slotTileHorizontal();
381
382 /** Shows or hides the main toolbar. */
387
389
390 /**
391 Shows or hides the text window text area headers and sets configuration
392 that newly opened windows don't user headers.
393 */
395
396 /** Used to set the active menu. */
397 void slotSetActiveSubWindow(QWidget * window);
398
399 void slotActiveWindowChanged(QMdiSubWindow * window);
400
401 /** Saves the current settings into the currently activated profile. */
402 void saveProfile();
403
404 /** Deletes the chosen session from the menu and from disk. */
405 void deleteProfile(QAction * action);
406
407 /** Loads the profile with the menu id ID. */
408 void loadProfile(QAction * action);
409
410 /** Loads the profile with the given key. */
411 void loadProfile(QString const & profileKey);
412
413 /** Reloads the current profile. */
414 void reloadProfile();
415
416 /** Toggles between normal and fullscreen mode. */
417 void toggleFullscreen();
418
419 void autoScrollPause();
420 bool autoScrollAnyKey();
421
422 /** Called when search button is pressed. */
423 void slotSearchModules();
424
425 /** Called for search default bible. */
427
428 /** Saves current settings into a new profile. */
429 void saveToNewProfile();
430
431 /** Refreshes the save profile and load profile menus. */
432 void refreshProfileMenus();
433
434 /** Open the About Dialog. */
435 void slotOpenAboutDialog();
436
437private: // fields:
438
440
441 // Docking widgets and their respective content widgets:
447
452
467
469
472
475 QPointer<Search::CSearchDialog> m_searchDialog;
476
478 QPointer<QWidget> m_debugWindow;
479
480};
481
482extern template void BibleTime::autoScroll<true>();
483extern 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:455
QPointer< QWidget > m_debugWindow
Definition bibletime.h:478
void slotModuleUnlock(CSwordModuleInfo *module)
BtModuleChooserBar * m_worksToolBar
Definition bibletime.h:450
QMenu * m_searchMenu
Definition bibletime.h:457
void clearMdiToolBars()
QActionGroup * m_windowArrangementActionGroup
Definition bibletime.h:461
BtBookshelfDockWidget * m_bookshelfDock
Definition bibletime.h:442
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:473
void moduleAbout(CSwordModuleInfo *module)
QDockWidget * m_magDock
Definition bibletime.h:445
CKeyChooser * keyChooser() const
QToolBar * m_mainToolBar
Definition bibletime.h:448
QAction * m_debugWidgetAction
Definition bibletime.h:477
QMenu * m_fileMenu
Definition bibletime.h:453
void slotActiveWindowChanged(QMdiSubWindow *window)
ActionCollection * m_actions
Definition bibletime.h:468
void deleteProfile(QAction *action)
void openFindWidget()
void slotTileHorizontal()
CMDIArea * m_mdi
Definition bibletime.h:470
InfoDisplay::CInfoDisplay * m_infoDisplay
Definition bibletime.h:446
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:439
QDockWidget * m_bookmarksDock
Definition bibletime.h:443
QToolBar * toolsToolBar() const noexcept
Definition bibletime.h:235
CBookmarkIndex * m_bookmarksPage
Definition bibletime.h:444
void showOrHideToolBars()
void colorThemeChanged()
void setDisplayFocus()
void slotAutoScroll()
void toggledTextWindowNavigator(bool newState)
QMenu * m_settingsMenu
Definition bibletime.h:465
void slotOpenWindowsMenuAboutToShow()
void openOnlineHelp_Handbook()
void initConnections()
static BibleTime * instance() noexcept
Definition bibletime.h:222
void createMenuAndToolBar()
QMenu * m_windowDeleteProfileMenu
Definition bibletime.h:464
BtModuleChooserBar * worksToolBar() const noexcept
Definition bibletime.h:231
void refreshProfileMenus()
void slotToggleToolsToolbar()
QToolBar * m_toolsToolBar
Definition bibletime.h:451
void slotToggleToolBarsInEachWindow()
void toggledTextWindowModuleChooser(bool newState)
QToolBar * navToolBar() const noexcept
Definition bibletime.h:228
QToolBar * m_navToolBar
Definition bibletime.h:449
BtFindWidget * m_findWidget
Definition bibletime.h:471
InfoDisplay::CInfoDisplay * infoDisplay() const noexcept
Definition bibletime.h:238
QMenu * m_viewMenu
Definition bibletime.h:454
void saveToNewProfile()
QPointer< Search::CSearchDialog > m_searchDialog
Definition bibletime.h:475
void slotTileVertical()
CSwordModuleInfo const * getCurrentModule()
QMenu * m_scrollMenu
Definition bibletime.h:456
BtModelViewReadDisplay * getCurrentDisplay()
void openOnlineHelp_Howto()
~BibleTime() override
void processCommandline(bool ignoreSession, QString const &bibleKey)
void slotWindowMenuAboutToShow()
QMenu * m_windowsMenu
Definition bibletime.h:458
QMenu * m_helpMenu
Definition bibletime.h:466
void autoScrollStop()
void saveConfigSettings()
QMenu * m_windowLoadProfileMenu
Definition bibletime.h:462
QActionGroup * m_windowLoadProfileActionGroup
Definition bibletime.h:463
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:474
QMenu * m_openWindowsMenu
Definition bibletime.h:459
void slotSetActiveSubWindow(QWidget *window)
void toggleFullscreen()
bool autoScrollAnyKey()
QMenu * m_windowArrangementMenu
Definition bibletime.h:460
The base class for all display windows of BibleTime.