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 "../bibletimeapp.h"
29#include "../cexportmanager.h"
30#include "../cmdiarea.h"
31#include "../display/btmodelviewreaddisplay.h"
32#include "../display/modelview/btqmlinterface.h"
33#include "../display/modelview/btquickwidget.h"
34#include "../keychooser/ckeychooser.h"
35#include "../keychooser/bthistory.h"
36#include "../messagedialog.h"
46 for (; w; w = w->parentWidget())
47 if (QMdiSubWindow *
const sw = qobject_cast<QMdiSubWindow *>(w))
53 bar->setAllowedAreas(Qt::TopToolBarArea);
54 bar->setFloatable(
false);
55 bar->setWindowTitle(title);
56 bar->setVisible(visible);
65 auto * actn =
new QAction(QIcon(), tr(
"Copy"),
this);
66 actn->setShortcut(QKeySequence::Copy);
67 addAction(QStringLiteral(
"copySelectedText"), actn);
69 actn =
new QAction(QIcon(), tr(
"Copy by references..."),
this);
70 actn->setShortcut(Qt::CTRL | Qt::Key_R);
71 addAction(QStringLiteral(
"copyByReferences"), actn);
73 actn =
new QAction(QIcon(), tr(
"Find..."),
this);
74 actn->setShortcut(QKeySequence::Find);
75 addAction(QStringLiteral(
"findText"), actn);
77 actn =
new QAction(QIcon(), tr(
"Change location"),
this);
78 actn->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_L));
79 addAction(QStringLiteral(
"openLocation"), actn);
81 actn =
new QAction(QIcon(), tr(
"Page down"),
this);
82 actn->setShortcut(QKeySequence(Qt::Key_PageDown));
83 addAction(QStringLiteral(
"pageDown"), actn);
85 actn =
new QAction(QIcon(), tr(
"Page up"),
this);
86 actn->setShortcut(QKeySequence(Qt::Key_PageUp));
87 addAction(QStringLiteral(
"pageUp"), actn);
89 actn =
new QAction(CResMgr::displaywindows::general::search::icon(),
90 tr(
"Search with works of this window"),
96 CResMgr::displaywindows::general::backInHistory::icon(),
97 tr(
"Back in history"),
105 CResMgr::displaywindows::general::forwardInHistory::icon(),
106 tr(
"Forward in history"),
108 action->setEnabled(
false);
114 actn =
new QAction(tr(
"Copy reference only"),
this);
115 addAction(QStringLiteral(
"copyReferenceOnly"), actn);
117 actn =
new QAction(tr(
"Save entry as HTML"),
this);
118 addAction(QStringLiteral(
"saveHtml"), actn);
120 actn =
new QAction(tr(
"Print reference only"),
this);
121 addAction(QStringLiteral(
"printReferenceOnly"), actn);
123 actn =
new QAction(tr(
"Entry with text"),
this);
124 addAction(QStringLiteral(
"copyEntryWithText"), actn);
126 actn =
new QAction(tr(
"Entry as plain text"),
this);
127 addAction(QStringLiteral(
"saveEntryAsPlain"), actn);
129 actn =
new QAction(tr(
"Entry with text"),
this);
130 addAction(QStringLiteral(
"printEntryWithText"), actn);
132 actn =
new QAction(tr(
"Strong's Search"),
this);
136 #ifdef BUILD_TEXT_TO_SPEECH
137 actn =
new QAction(tr(
"Speak selected text"),
this);
144 bool const addTextHeaderToolbar,
166 setMinimumSize(100, 100);
167 setFocusPolicy(Qt::ClickFocus);
178 setWindowIcon(
m_modules.first()->moduleIcon());
191 QStringLiteral(
"GUI/showTextWindowNavigator"),
213 "GUI/showTextWindowModuleSelectorButtons"),
225 QStringLiteral(
"GUI/showTextWindowToolButtons"),
231 if (addTextHeaderToolbar) {
234 auto *
const headerBar =
new QToolBar(
this);
235 headerBar->setMovable(
false);
236 headerBar->setWindowTitle(tr(
"Text area header"));
237 headerBar->setVisible(
239 QStringLiteral(
"GUI/showTextWindowHeaders"),
242 headerBar, &QToolBar::setVisible);
244 auto *
const headerWidget =
256 headerBar->addWidget(headerWidget);
258 addToolBar(headerBar);
267 QStringLiteral(
"openLocation"),
269 if (
btConfig().session().value<bool>(
270 QStringLiteral(
"GUI/showToolbarsInEachWindow"),
284 auto & copySelectedTextAction =
289 copySelectedTextAction.setEnabled(hasSelection);
290 #ifdef BUILD_TEXT_TO_SPEECH
291 auto & speakSelectedTextAction =
294 &BtModelViewReadDisplay::speakSelectedText);
295 speakSelectedTextAction.setEnabled(hasSelection);
296 #define BUILD_TEXT_TO_SPEECH_CAPTURE , &speakSelectedTextAction
297 #define BUILD_TEXT_TO_SPEECH_ACTION \
298 speakSelectedTextAction.setEnabled(newSelection.has_value());
300 #define BUILD_TEXT_TO_SPEECH_CAPTURE
301 #define BUILD_TEXT_TO_SPEECH_ACTION
307 std::optional<BtQmlInterface::Selection>
const & newSelection)
309 copySelectedTextAction.setEnabled(newSelection.has_value());
310 BUILD_TEXT_TO_SPEECH_ACTION
312 #undef BUILD_TEXT_TO_SPEECH_CAPTURE
313 #undef BUILD_TEXT_TO_SPEECH_ACTION
341 for (
auto const & strongNumber
346 QStringLiteral(
"strong:%1 ")
352 [
this](QString
const & nodeInfo)
367 QStringLiteral(
"saveEntryAsPlain"),
380 QStringLiteral(
"saveHtml"),
401 [
this](QString
const & newActiveAnchor) {
402 bool const hasActiveAnchor = !newActiveAnchor.isEmpty();
406 #ifdef BUILD_TEXT_TO_SPEECH
412 QStringLiteral(
"Displaywindow shortcuts"));
437 setWindowTitle(tr(
"<NO WORKS>"));
439 setWindowTitle(QStringLiteral(
"%1 (%2)")
447 QWidget const *
const w = getProfileWindow(parentWidget());
455 const QRect rect(w->x(), w->y(), w->width(), w->height());
456 conf.
setValue<QRect>(QStringLiteral(
"windowRect"), rect);
457 conf.
setValue<
bool>(QStringLiteral(
"staysOnTop"),
458 w->windowFlags() & Qt::WindowStaysOnTopHint);
459 conf.
setValue<
bool>(QStringLiteral(
"staysOnBottom"),
460 w->windowFlags() & Qt::WindowStaysOnBottomHint);
461 conf.
setValue(QStringLiteral(
"maximized"), w->isMaximized());
463 bool const hasFocus =
465 conf.
setValue(QStringLiteral(
"hasFocus"), hasFocus);
474 conf.
setValue(QStringLiteral(
"writeWindowType"), int(0));
478 setUpdatesEnabled(
false);
480 QWidget *
const w = getProfileWindow(parentWidget());
488 const QRect rect = conf.
value<QRect>(QStringLiteral(
"windowRect"));
489 w->resize(rect.width(), rect.height());
490 w->move(rect.x(), rect.y());
491 if (conf.
value<
bool>(QStringLiteral(
"staysOnTop"),
false))
492 w->setWindowFlags(w->windowFlags() | Qt::WindowStaysOnTopHint);
493 if (conf.
value<
bool>(QStringLiteral(
"staysOnBottom"),
false))
494 w->setWindowFlags(w->windowFlags() | Qt::WindowStaysOnBottomHint);
495 if (conf.
value<
bool>(QStringLiteral(
"maximized")))
498 setUpdatesEnabled(
true);
507 [
this](
bool const backEnabled,
bool const fwEnabled) {
519 QMenu * menu = m_actions.backInHistory->popupMenu();
521 for (auto * const actionPtr
522 : m_history->getBackList())
523 menu->addAction(actionPtr);
530 QMenu* menu = m_actions.forwardInHistory->popupMenu();
532 for (auto * const actionPtr
533 : m_history->getFwList())
534 menu->addAction(actionPtr);
558 auto *
const popupMenu =
new QMenu(
this);
561 popupMenu->addSeparator();
588 #ifdef BUILD_TEXT_TO_SPEECH
589 popupMenu->addAction((
m_actions.speakSelectedText));
596 if (
btApp->debugMode()) {
597 auto *
const debugAction =
598 new QAction(tr(
"DEBUG: Show raw text"),
this);
599 debugAction->setProperty(
"bibletime_show_raw_text",
true);
600 menu->addSeparator();
601 menu->addAction(debugAction);
655 if (
auto *
const module = backend.findModuleByName(*it)) {
676 QStringLiteral(
"Displaywindow shortcuts"));
717 setWindowIcon(
m_modules.first()->moduleIcon());
729 auto *
const bibleModule =
731 QStringLiteral(
"standardBible"));
739 tr(
"Please choose a Bible in the Settings > "
740 "Configure dialog."));
782 if (!conf.session().value<
bool>(
783 QStringLiteral(
"GUI/showToolbarsInEachWindow"),
BtConfig & btConfig()
This is a shortchand for BtConfig::getInstance().
QList< CSwordModuleInfo * > BtModuleList
#define BUILD_TEXT_TO_SPEECH_CAPTURE
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
QMenu * addDebugActions(QMenu *menu)
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