BibleTime
cbookreadwindow.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 "cbookreadwindow.h"
14
15#include <QAction>
16#include <QDockWidget>
17#include <Qt>
18#include <QToolBar>
19#include "../../backend/config/btconfigcore.h"
20#include "../../backend/drivers/btmodulelist.h"
21#include "../../backend/drivers/cswordmoduleinfo.h"
22#include "../../util/btassert.h"
23#include "../../util/btconnect.h"
24#include "../../util/cresmgr.h"
25#include "../bibletime.h"
26#include "../display/btmodelviewreaddisplay.h"
27#include "../keychooser/bthistory.h"
28#include "../keychooser/cbooktreechooser.h"
29#include "../keychooser/ckeychooser.h"
30#include "btactioncollection.h"
32#include "btmodulechooserbar.h"
34
35
38{
39 auto * const qaction = new QAction(tr("Toggle tree view"), this);
40 qaction->setCheckable(true);
41 addAction(QStringLiteral("toggleTree"), qaction);
42}
43
44CBookReadWindow::CBookReadWindow(QList<CSwordModuleInfo *> const & modules,
45 QString const & key,
46 CMDIArea * parent)
47 : CDisplayWindow(modules, key, false, new ActionCollection(), parent)
48{
49 auto * const h = history();
50
52 m_treeChooserDock->setFeatures(QDockWidget::NoDockWidgetFeatures);
53 m_treeChooserDock->setAllowedAreas(
54 Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
55 // "Remove" title bar:
56 m_treeChooserDock->setTitleBarWidget(new QWidget(m_treeChooserDock));
59 swordKey(),
62 h, &BTHistory::add);
66 m_treeChooserDock->hide();
67 addDockWidget(Qt::LeftDockWidgetArea, m_treeChooserDock);
68
69 init();
70}
71
74
76 if (conf.value<bool>(QStringLiteral("treeShown"), true)
77 != m_treeAction->isChecked())
78 m_treeAction->activate(QAction::Trigger);
79}
80
83 conf.setValue(QStringLiteral("treeShown"), m_treeAction->isChecked());
84}
85
88
89 m_treeAction = &ac->action(QStringLiteral("toggleTree"));
91 BT_CONNECT(m_treeAction, &QAction::triggered,
92 m_treeChooserDock, &QDockWidget::setVisible);
93 addAction(m_treeAction);
94
95 ac->readShortcuts(QStringLiteral("Book shortcuts"));
96}
97
98/** No descriptions */
109
113
114 mainToolBar()->addAction(m_actions.backInHistory);
116 mainToolBar()->addWidget(keyChooser());
117
118 // Tools toolbar
119 buttonsToolBar()->addAction(m_treeAction); // Tree
120 m_treeAction->setChecked(false);
123 buttonsToolBar()->addWidget(button); // Display settings
124 // Search:
125 buttonsToolBar()->addAction(
126 &actionCollection()->action(
128}
129
131 auto const constMods = constModules();
132
133 // Navigation toolbar
134 btMainWindow()->navToolBar()->addAction(m_actions.backInHistory); //1st button
135 btMainWindow()->navToolBar()->addAction(m_actions.forwardInHistory); //2nd button
136 CKeyChooser * const keyChooser =
138 swordKey(),
139 btMainWindow()->navToolBar());
140 auto * const h = history();
142 h, &BTHistory::add);
145 btMainWindow()->navToolBar()->addWidget(keyChooser);
150
151 // Works toolbar
153
154 // Tools toolbar
155 btMainWindow()->toolsToolBar()->addAction(m_treeAction); // Tree
158 btMainWindow()->toolsToolBar()->addWidget(button); // Display settings
159 // Search:
160 btMainWindow()->toolsToolBar()->addAction(
161 &actionCollection()->action(
163}
164
165/** Reimplementation to take care of the tree chooser. */
#define BT_ASSERT(...)
Definition btassert.h:17
#define BT_CONNECT(...)
Definition btconnect.h:20
void historyMoved(QString newKey)
void add(CSwordKey *newKey)
Definition bthistory.cpp:29
QToolBar * toolsToolBar() const noexcept
Definition bibletime.h:235
BtModuleChooserBar * worksToolBar() const noexcept
Definition bibletime.h:231
QToolBar * navToolBar() const noexcept
Definition bibletime.h:228
void readShortcuts(QString const &group)
Read shortcuts from config.
void addAction(QString const &name, QAction *const action)
QAction & action(QString const &name) const
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.
void associateWithWindow(CDisplayWindow *window)
ActionCollection(QObject *parent=nullptr)
CBookReadWindow(QList< CSwordModuleInfo * > const &modules, QString const &key, CMDIArea *parent)
void initConnections() override
CBookTreeChooser * m_treeChooser
void applyProfileSettings(BtConfigCore const &windowConf) override
Loads the settings of this window from configuration.
void modulesChanged() override
void storeProfileSettings(BtConfigCore &windowConf) const override
Stores the settings of this window to configuration.
QDockWidget * m_treeChooserDock
void initToolbars() override
QAction * m_treeAction
void initActions() override
void setupMainWindowToolBars() override
void updateKey(CSwordKey *) final override
void setModules(BtConstModuleList const &modules, bool refresh=true) final override
The base class for all display windows of BibleTime.
virtual void modulesChanged()
QToolBar * buttonsToolBar() const noexcept
void sigKeyChanged(CSwordKey *key)
struct CDisplayWindow::ActionsStruct m_actions
void setDisplaySettingsButton(BtDisplaySettingsButton *button)
QToolBar * mainToolBar() const noexcept
virtual void initConnections()
virtual void storeProfileSettings(BtConfigCore &windowConf) const
Stores the settings of this window to configuration.
CKeyChooser * keyChooser() const noexcept
virtual void lookupSwordKey(CSwordKey *)
BtConstModuleList constModules() const
CSwordKey * swordKey() const noexcept
BibleTime * btMainWindow()
virtual void applyProfileSettings(BtConfigCore const &windowConf)
Loads the settings of this window from configuration.
ActionCollection * actionCollection() const noexcept
BtModuleList const & modules() const noexcept
BTHistory * history() const noexcept
void handleHistoryMoved(QString const &newKey)
void keyChanged(CSwordKey *newKey)
virtual void updateKey(CSwordKey *key)=0
static CKeyChooser * createInstance(const BtConstModuleList &modules, CSwordKey *key, QWidget *parent)
BtToolBarPopupAction * forwardInHistory
BtToolBarPopupAction * backInHistory