19#include <QMdiSubWindow>
23#include "../../backend/config/btconfig.h"
24#include "../../backend/keys/cswordkey.h"
25#include "../../backend/managers/cswordbackend.h"
26#include "../../util/cresmgr.h"
27#include "../bibletime.h"
28#include "../cexportmanager.h"
29#include "../cmdiarea.h"
30#include "../display/btmodelviewreaddisplay.h"
31#include "../display/modelview/btqmlinterface.h"
32#include "../display/modelview/btquickwidget.h"
33#include "../keychooser/ckeychooser.h"
34#include "../keychooser/bthistory.h"
35#include "../messagedialog.h"
45 for (; w; w = w->parentWidget())
46 if (QMdiSubWindow *
const sw = qobject_cast<QMdiSubWindow *>(w))
52 bar->setAllowedAreas(Qt::TopToolBarArea);
53 bar->setFloatable(
false);
54 bar->setWindowTitle(title);
55 bar->setVisible(visible);
64 auto * actn =
new QAction(QIcon(), tr(
"Copy"),
this);
65 actn->setShortcut(QKeySequence::Copy);
66 addAction(QStringLiteral(
"copySelectedText"), actn);
68 actn =
new QAction(QIcon(), tr(
"Copy by references..."),
this);
69 actn->setShortcut(Qt::CTRL | Qt::Key_R);
70 addAction(QStringLiteral(
"copyByReferences"), actn);
72 actn =
new QAction(QIcon(), tr(
"Find..."),
this);
73 actn->setShortcut(QKeySequence::Find);
74 addAction(QStringLiteral(
"findText"), actn);
76 actn =
new QAction(QIcon(), tr(
"Change location"),
this);
77 actn->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_L));
78 addAction(QStringLiteral(
"openLocation"), actn);
80 actn =
new QAction(QIcon(), tr(
"Page down"),
this);
81 actn->setShortcut(QKeySequence(Qt::Key_PageDown));
82 addAction(QStringLiteral(
"pageDown"), actn);
84 actn =
new QAction(QIcon(), tr(
"Page up"),
this);
85 actn->setShortcut(QKeySequence(Qt::Key_PageUp));
86 addAction(QStringLiteral(
"pageUp"), actn);
88 actn =
new QAction(CResMgr::displaywindows::general::search::icon(),
89 tr(
"Search with works of this window"),
95 CResMgr::displaywindows::general::backInHistory::icon(),
96 tr(
"Back in history"),
103 CResMgr::displaywindows::general::forwardInHistory::icon(),
104 tr(
"Forward in history"),
111 actn =
new QAction(tr(
"Copy reference only"),
this);
112 addAction(QStringLiteral(
"copyReferenceOnly"), actn);
114 actn =
new QAction(tr(
"Save entry as HTML"),
this);
115 addAction(QStringLiteral(
"saveHtml"), actn);
117 actn =
new QAction(tr(
"Print reference only"),
this);
118 addAction(QStringLiteral(
"printReferenceOnly"), actn);
120 actn =
new QAction(tr(
"Entry with text"),
this);
121 addAction(QStringLiteral(
"copyEntryWithText"), actn);
123 actn =
new QAction(tr(
"Entry as plain text"),
this);
124 addAction(QStringLiteral(
"saveEntryAsPlain"), actn);
126 actn =
new QAction(tr(
"Entry with text"),
this);
127 addAction(QStringLiteral(
"printEntryWithText"), actn);
129 actn =
new QAction(tr(
"Strong's Search"),
this);
133 #ifdef BUILD_TEXT_TO_SPEECH
134 actn =
new QAction(tr(
"Speak selected text"),
this);
141 bool const addTextHeaderToolbar,
161 setMinimumSize(100, 100);
162 setFocusPolicy(Qt::ClickFocus);
173 setWindowIcon(
m_modules.first()->moduleIcon());
186 QStringLiteral(
"GUI/showTextWindowNavigator"),
208 "GUI/showTextWindowModuleSelectorButtons"),
220 QStringLiteral(
"GUI/showTextWindowToolButtons"),
226 if (addTextHeaderToolbar) {
229 auto *
const headerBar =
new QToolBar(
this);
230 headerBar->setMovable(
false);
231 headerBar->setWindowTitle(tr(
"Text area header"));
232 headerBar->setVisible(
234 QStringLiteral(
"GUI/showTextWindowHeaders"),
237 headerBar, &QToolBar::setVisible);
239 auto *
const headerWidget =
251 headerBar->addWidget(headerWidget);
253 addToolBar(headerBar);
262 QStringLiteral(
"openLocation"),
264 if (
btConfig().session().value<bool>(
265 QStringLiteral(
"GUI/showToolbarsInEachWindow"),
279 auto & copySelectedTextAction =
284 copySelectedTextAction.setEnabled(hasSelection);
285 #ifdef BUILD_TEXT_TO_SPEECH
286 auto & speakSelectedTextAction =
289 &BtModelViewReadDisplay::speakSelectedText);
290 speakSelectedTextAction.setEnabled(hasSelection);
295 [©SelectedTextAction
296 #ifdef BUILD_TEXT_TO_SPEECH
297 , &speakSelectedTextAction
300 std::optional<BtQmlInterface::Selection>
const & newSelection)
302 copySelectedTextAction.setEnabled(newSelection.has_value());
303 #ifdef BUILD_TEXT_TO_SPEECH
304 speakSelectedTextAction.setEnabled(newSelection.has_value());
334 for (
auto const & strongNumber
339 QStringLiteral(
"strong:%1 ")
345 [
this](QString
const & nodeInfo)
360 QStringLiteral(
"saveEntryAsPlain"),
373 QStringLiteral(
"saveHtml"),
394 [
this](QString
const & newActiveAnchor) {
395 bool const hasActiveAnchor = !newActiveAnchor.isEmpty();
399 #ifdef BUILD_TEXT_TO_SPEECH
405 QStringLiteral(
"Displaywindow shortcuts"));
430 setWindowTitle(tr(
"<NO WORKS>"));
432 setWindowTitle(QStringLiteral(
"%1 (%2)")
440 QWidget const *
const w = getProfileWindow(parentWidget());
448 const QRect rect(w->x(), w->y(), w->width(), w->height());
449 conf.
setValue<QRect>(QStringLiteral(
"windowRect"), rect);
450 conf.
setValue<
bool>(QStringLiteral(
"staysOnTop"),
451 w->windowFlags() & Qt::WindowStaysOnTopHint);
452 conf.
setValue<
bool>(QStringLiteral(
"staysOnBottom"),
453 w->windowFlags() & Qt::WindowStaysOnBottomHint);
454 conf.
setValue(QStringLiteral(
"maximized"), w->isMaximized());
456 bool const hasFocus =
458 conf.
setValue(QStringLiteral(
"hasFocus"), hasFocus);
467 conf.
setValue(QStringLiteral(
"writeWindowType"), int(0));
471 setUpdatesEnabled(
false);
473 QWidget *
const w = getProfileWindow(parentWidget());
481 const QRect rect = conf.
value<QRect>(QStringLiteral(
"windowRect"));
482 w->resize(rect.width(), rect.height());
483 w->move(rect.x(), rect.y());
484 if (conf.
value<
bool>(QStringLiteral(
"staysOnTop"),
false))
485 w->setWindowFlags(w->windowFlags() | Qt::WindowStaysOnTopHint);
486 if (conf.
value<
bool>(QStringLiteral(
"staysOnBottom"),
false))
487 w->setWindowFlags(w->windowFlags() | Qt::WindowStaysOnBottomHint);
488 if (conf.
value<
bool>(QStringLiteral(
"maximized")))
491 setUpdatesEnabled(
true);
500 [
this](
bool const backEnabled,
bool const fwEnabled) {
512 QMenu * menu = m_actions.backInHistory->popupMenu();
514 for (auto * const actionPtr
515 : m_history->getBackList())
516 menu->addAction(actionPtr);
523 QMenu* menu = m_actions.forwardInHistory->popupMenu();
525 for (auto * const actionPtr
526 : m_history->getFwList())
527 menu->addAction(actionPtr);
551 auto *
const popupMenu =
new QMenu(
this);
554 popupMenu->addSeparator();
581 #ifdef BUILD_TEXT_TO_SPEECH
582 popupMenu->addAction((
m_actions.speakSelectedText));
637 if (
auto *
const module = backend.findModuleByName(*it)) {
658 QStringLiteral(
"Displaywindow shortcuts"));
699 setWindowIcon(
m_modules.first()->moduleIcon());
711 auto *
const bibleModule =
713 QStringLiteral(
"standardBible"));
721 tr(
"Please choose a Bible in the Settings > "
722 "Configure dialog."));
764 if (!conf.session().value<
bool>(
765 QStringLiteral(
"GUI/showToolbarsInEachWindow"),
BtConfig & btConfig()
This is a shortchand for BtConfig::getInstance().
QList< CSwordModuleInfo * > BtModuleList
void historyMoved(QString newKey)
void add(CSwordKey *newKey)
void historyChanged(bool backEnabled, bool fwEnabled)
void toggledTextWindowToolButtons(bool newState)
void toggledTextWindowHeader(bool newState)
void openSearchDialog(BtConstModuleList modules, QString const &searchText={})
QToolBar * toolsToolBar() const noexcept
void toggledTextWindowNavigator(bool newState)
static BibleTime * instance() noexcept
BtModuleChooserBar * worksToolBar() const noexcept
void toggledTextWindowModuleChooser(bool newState)
QToolBar * navToolBar() const noexcept
CDisplayWindow * createReadDisplayWindow(QList< CSwordModuleInfo * > modules, QString const &key)
Creates a new presenter in the MDI area according to the type of the module.
void readShortcuts(QString const &group)
Read shortcuts from config.
void addAction(QString const &name, QAction *const action)
QAction & action(QString const &name) const
T & actionAs(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.
CSwordModuleInfo * getDefaultSwordModuleByType(const QString &moduleType)
Returns default sword module info class for a given module type.
void printAll(DisplayOptions const &displayOptions, FilterOptions const &filterOptions)
void printAnchorOnly(DisplayOptions const &displayOptions, FilterOptions const &filterOptions)
void copySelectedText()
Copies the currently selected text.
void scrollToKey(CSwordKey *key)
void setModules(QStringList const &modules)
void installPopup(QMenu *const popup)
Installs the popup which should be opened when the right mouse button was pressed.
void activeAnchorChanged(QString newActiveAnchor)
void copyByReferences()
Copies the given text specified by asking user for first and last references.
BtQuickWidget * quickWidget() const noexcept
void setOptions(DisplayOptions const &displayOptions, FilterOptions const &filterOptions)
BtQmlInterface * qmlInterface() const noexcept
void printAnchorWithText(DisplayOptions const &displayOptions, FilterOptions const &filterOptions)
void nodeInfoChanged(QString newNodeInfo)
void associateWithWindow(CDisplayWindow *window)
void selectionChanged(std::optional< Selection > newSelection)
std::optional< Selection > const & selection() const noexcept
ActionCollection(QObject *parent=nullptr)
The base class for all display windows of BibleTime.
virtual void modulesChanged()
FilterOptions m_filterOptions
QAction & initAddAction(Args &&... args)
void sigKeyChanged(CSwordKey *key)
void sigDisplayOptionsChanged(const DisplayOptions &displayOptions)
void printAnchorWithText()
BTHistory *const m_history
struct CDisplayWindow::ActionsStruct m_actions
void setDisplaySettingsButton(BtDisplaySettingsButton *button)
virtual void initConnections()
virtual void storeProfileSettings(BtConfigCore &windowConf) const
Stores the settings of this window to configuration.
FilterOptions const & filterOptions() const noexcept
CKeyChooser * keyChooser() const noexcept
QStringList m_moduleNames
ActionCollection *const m_actionCollection
void sigFilterOptionsChanged(const FilterOptions &filterOptions)
void sigModulesChanged(const BtConstModuleList &modules)
virtual CSwordModuleInfo::ModuleType moduleType() const
std::unique_ptr< CSwordKey > const m_swordKey
virtual void setupMainWindowToolBars()
DisplayOptions m_displayOptions
void clearMainWindowToolBars()
CKeyChooser * m_keyChooser
virtual void lookupSwordKey(CSwordKey *)
void lookupKey(QString const &key)
DisplayOptions const & displayOptions() const noexcept
bool m_isInitialized
Whether init() has been called.
BtConstModuleList constModules() const
BibleTime * btMainWindow()
void slotAddModule(int index, CSwordModuleInfo *module)
QToolBar * m_buttonsToolBar
virtual void initToolbars()
virtual void applyProfileSettings(BtConfigCore const &windowConf)
Loads the settings of this window from configuration.
virtual void initActions()=0
void sigModuleListChanged(BtModuleList newList)
~CDisplayWindow() override
BtModuleChooserBar * m_moduleChooserBar
void slotRemoveModule(int index)
ActionCollection * actionCollection() const noexcept
BtModelViewReadDisplay * m_displayWidget
BtModuleList const & modules() const noexcept
virtual QMenu * newDisplayWidgetPopupMenu()
void slotReplaceModule(int index, CSwordModuleInfo *newModule)
CSwordKey * getMouseClickedKey() const
void setBibleReference(const QString &reference)
virtual void copyDisplayedText()
CDisplayWindow(BtModuleList const &modules, QString const &key, bool const addTextHeaderToolbar, ActionCollection *actionCollection, CMDIArea *const parent)
bool saveKey(CSwordKey const *const key, Format const format, bool const addText, const BtConstModuleList &modules)
bool copyKey(CSwordKey const *const key, Format const format, bool const addText)
virtual void setModules(const BtConstModuleList &modules, bool refresh=true)=0
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)
virtual void setKey(CSwordKey *key)=0
virtual CSwordKey * key()=0
CSwordModuleInfo * findModuleByName(const QString &name) const
Searches for a module with the given name.
void sigSwordSetupChanged()
static CSwordBackend & instance() noexcept
virtual bool setKey(const QString &key)=0
virtual QString key() const =0
QString const & name() const
void prepareToolBar(QToolBar *bar, const QString &title, bool visible)
QWidget * getProfileWindow(QWidget *w)
QMessageBox::StandardButton showInformation(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
struct CDisplayWindow::ActionsStruct::@14 save
struct CDisplayWindow::ActionsStruct::@13 copy
struct CDisplayWindow::ActionsStruct::@15 print
BtToolBarPopupAction * forwardInHistory
BtToolBarPopupAction * backInHistory