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 <QSplitter>
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 
38 
40  if (conf.value<bool>(QStringLiteral("treeShown"), true)
41  != m_treeAction->isChecked())
42  m_treeAction->activate(QAction::Trigger);
43 }
44 
47  conf.setValue(QStringLiteral("treeShown"), m_treeAction->isChecked());
48 }
49 
54 
55  m_treeAction = &ac->action(QStringLiteral("toggleTree"));
57  BT_CONNECT(m_treeAction, &QAction::triggered,
59  addAction(m_treeAction);
60 
61  ac->readShortcuts(QStringLiteral("Book shortcuts"));
62 }
63 
65  QAction* qaction;
66 
67  qaction = new QAction( /* QIcon(CResMgr::displaywindows::bookWindow::toggleTree::icon), */
68  tr("Toggle tree view"), a);
69  qaction->setCheckable(true);
70  // qaction->setShortcut(CResMgr::displaywindows::bookWindow::toggleTree::accel);
71  a->addAction(QStringLiteral("toggleTree"), qaction);
72 }
73 
74 /** No descriptions */
77 
84 }
85 
86 /** Init the view */
88  QSplitter* splitter = new QSplitter(this);
89 
90  auto const constMods = constModules();
91  auto * const h = history();
92  m_treeChooser = new CBookTreeChooser(constMods, key(), splitter);
94  h, &BTHistory::add);
97 
98  auto * const dw = new BtModelViewReadDisplay(this, splitter);
99  dw->setModules(moduleNames());
100  setDisplayWidget(dw);
101  m_treeChooser->hide();
102  splitter->setStretchFactor(1,3);
103 
104  // Add the Navigation toolbar
105  auto * const navigationToolBar = mainToolBar();
106  addToolBar(navigationToolBar);
108  CKeyChooser::createInstance(constMods,
109  key(),
110  navigationToolBar));
111 
113 
114  // Add the Tools toolbar
115  addToolBar(buttonsToolBar());
116 
117  setCentralWidget( splitter );
118 }
119 
123 
124  mainToolBar()->addAction(m_actions.backInHistory);
125  mainToolBar()->addAction(m_actions.forwardInHistory);
126  mainToolBar()->addWidget(keyChooser());
127 
128  // Tools toolbar
129  buttonsToolBar()->addAction(m_treeAction); // Tree
130  m_treeAction->setChecked(false);
132  setDisplaySettingsButton(button);
133  buttonsToolBar()->addWidget(button); // Display settings
134  // Search:
135  buttonsToolBar()->addAction(
136  &actionCollection()->action(
138 }
139 
141  auto const constMods = constModules();
142 
143  // Navigation toolbar
144  btMainWindow()->navToolBar()->addAction(m_actions.backInHistory); //1st button
145  btMainWindow()->navToolBar()->addAction(m_actions.forwardInHistory); //2nd button
146  CKeyChooser * const keyChooser =
147  CKeyChooser::createInstance(constMods,
148  key(),
149  btMainWindow()->navToolBar());
150  auto * const h = history();
152  h, &BTHistory::add);
155  btMainWindow()->navToolBar()->addWidget(keyChooser);
160 
161  // Works toolbar
163 
164  // Tools toolbar
165  btMainWindow()->toolsToolBar()->addAction(m_treeAction); // Tree
167  setDisplaySettingsButton(button);
168  btMainWindow()->toolsToolBar()->addWidget(button); // Display settings
169  // Search:
170  btMainWindow()->toolsToolBar()->addAction(
171  &actionCollection()->action(
173 }
174 
175 /** Is called when the action was executed to toggle the tree view. */
177  if (m_treeAction->isChecked()) {
179  }
180  else {
181  m_treeChooser->hide();
182  }
183 }
184 
185 /** Reimplementation to take care of the tree chooser. */
189 }
#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)
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.
void initView() override
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
void addModuleChooserBar()
virtual void modulesChanged()
void sigKeyChanged(CSwordKey *key)
void setDisplayWidget(BtModelViewReadDisplay *newDisplay)
struct CDisplayWindow::ActionsStruct m_actions
void setDisplaySettingsButton(BtDisplaySettingsButton *button)
CKeyChooser * keyChooser() const
virtual void initConnections()
virtual void storeProfileSettings(BtConfigCore &windowConf) const
Stores the settings of this window to configuration.
BtActionCollection * actionCollection() const
virtual void initActions()
virtual void lookupSwordKey(CSwordKey *)
void setKeyChooser(CKeyChooser *ck)
BTHistory * history() const noexcept
BtConstModuleList constModules() const
BibleTime * btMainWindow()
virtual void applyProfileSettings(BtConfigCore const &windowConf)
Loads the settings of this window from configuration.
QToolBar * mainToolBar()
QStringList const & moduleNames() const noexcept
CSwordKey * key() const
QToolBar * buttonsToolBar()
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