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-2021 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"
33 #include "bttoolbarpopupaction.h"
34 
35 
37  CMDIArea * parent)
38  : CDisplayWindow(modules, false, parent)
39 {
40  auto * const h = history();
41 
42  m_treeChooserDock = new QDockWidget(this);
43  m_treeChooserDock->setFeatures(QDockWidget::NoDockWidgetFeatures);
44  m_treeChooserDock->setAllowedAreas(
45  Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
46  // "Remove" title bar:
47  m_treeChooserDock->setTitleBarWidget(new QWidget(m_treeChooserDock));
51  h, &BTHistory::add);
54  m_treeChooserDock->setWidget(m_treeChooser);
55  m_treeChooserDock->hide();
56  addDockWidget(Qt::LeftDockWidgetArea, m_treeChooserDock);
57 
58  init();
59 }
60 
63 
65  if (conf.value<bool>(QStringLiteral("treeShown"), true)
66  != m_treeAction->isChecked())
67  m_treeAction->activate(QAction::Trigger);
68 }
69 
72  conf.setValue(QStringLiteral("treeShown"), m_treeAction->isChecked());
73 }
74 
79 
80  m_treeAction = &ac->action(QStringLiteral("toggleTree"));
82  BT_CONNECT(m_treeAction, &QAction::triggered,
83  m_treeChooserDock, &QDockWidget::setVisible);
84  addAction(m_treeAction);
85 
86  ac->readShortcuts(QStringLiteral("Book shortcuts"));
87 }
88 
90  QAction* qaction;
91 
92  qaction = new QAction( /* QIcon(CResMgr::displaywindows::bookWindow::toggleTree::icon), */
93  tr("Toggle tree view"), a);
94  qaction->setCheckable(true);
95  // qaction->setShortcut(CResMgr::displaywindows::bookWindow::toggleTree::accel);
96  a->addAction(QStringLiteral("toggleTree"), qaction);
97 }
98 
99 /** No descriptions */
102 
109 }
110 
114 
115  mainToolBar()->addAction(m_actions.backInHistory);
116  mainToolBar()->addAction(m_actions.forwardInHistory);
117  mainToolBar()->addWidget(keyChooser());
118 
119  // Tools toolbar
120  buttonsToolBar()->addAction(m_treeAction); // Tree
121  m_treeAction->setChecked(false);
123  setDisplaySettingsButton(button);
124  buttonsToolBar()->addWidget(button); // Display settings
125  // Search:
126  buttonsToolBar()->addAction(
127  &actionCollection()->action(
129 }
130 
132  auto const constMods = constModules();
133 
134  // Navigation toolbar
135  btMainWindow()->navToolBar()->addAction(m_actions.backInHistory); //1st button
136  btMainWindow()->navToolBar()->addAction(m_actions.forwardInHistory); //2nd button
137  CKeyChooser * const keyChooser =
138  CKeyChooser::createInstance(constMods,
139  key(),
140  btMainWindow()->navToolBar());
141  auto * const h = history();
143  h, &BTHistory::add);
146  btMainWindow()->navToolBar()->addWidget(keyChooser);
151 
152  // Works toolbar
154 
155  // Tools toolbar
156  btMainWindow()->toolsToolBar()->addAction(m_treeAction); // Tree
158  setDisplaySettingsButton(button);
159  btMainWindow()->toolsToolBar()->addWidget(button); // Display settings
160  // Search:
161  btMainWindow()->toolsToolBar()->addAction(
162  &actionCollection()->action(
164 }
165 
166 /** Reimplementation to take care of the tree chooser. */
170 }
#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:156
QToolBar * navToolBar() const noexcept
Definition: bibletime.h:149
BtModuleChooserBar * worksToolBar() const noexcept
Definition: bibletime.h:152
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.
Definition: btconfigcore.h:50
void setValue(QString const &key, T const &value)
Sets a value for a key.
Definition: btconfigcore.h:73
void associateWithWindow(CDisplayWindow *window)
CBookReadWindow(QList< CSwordModuleInfo * > const &modules, 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
static void insertKeyboardActions(BtActionCollection *const a)
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()
void sigKeyChanged(CSwordKey *key)
struct CDisplayWindow::ActionsStruct m_actions
void setDisplaySettingsButton(BtDisplaySettingsButton *button)
CKeyChooser * keyChooser() const
virtual void initConnections()
QToolBar * mainToolBar() const noexcept
virtual void storeProfileSettings(BtConfigCore &windowConf) const
Stores the settings of this window to configuration.
BtActionCollection * actionCollection() const
virtual void initActions()
virtual void lookupSwordKey(CSwordKey *)
BTHistory * history() const noexcept
BtConstModuleList constModules() const
BibleTime * btMainWindow()
virtual void applyProfileSettings(BtConfigCore const &windowConf)
Loads the settings of this window from configuration.
CSwordKey * key() const
QToolBar * buttonsToolBar() const noexcept
void handleHistoryMoved(QString const &newKey)
Definition: ckeychooser.cpp:56
void keyChanged(CSwordKey *newKey)
virtual void updateKey(CSwordKey *key)=0
static CKeyChooser * createInstance(const BtConstModuleList &modules, CSwordKey *key, QWidget *parent)
Definition: ckeychooser.cpp:26
BtToolBarPopupAction * forwardInHistory
BtToolBarPopupAction * backInHistory