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);
300 [©SelectedTextAction
301 #ifdef BUILD_TEXT_TO_SPEECH
302 , &speakSelectedTextAction
305 std::optional<BtQmlInterface::Selection>
const & newSelection)
307 copySelectedTextAction.setEnabled(newSelection.has_value());
308 #ifdef BUILD_TEXT_TO_SPEECH
309 speakSelectedTextAction.setEnabled(newSelection.has_value());
339 for (
auto const & strongNumber
344 QStringLiteral(
"strong:%1 ")
350 [
this](QString
const & nodeInfo)
365 QStringLiteral(
"saveEntryAsPlain"),
378 QStringLiteral(
"saveHtml"),
399 [
this](QString
const & newActiveAnchor) {
400 bool const hasActiveAnchor = !newActiveAnchor.isEmpty();
404 #ifdef BUILD_TEXT_TO_SPEECH
410 QStringLiteral(
"Displaywindow shortcuts"));
435 setWindowTitle(tr(
"<NO WORKS>"));
437 setWindowTitle(QStringLiteral(
"%1 (%2)")
445 QWidget const *
const w = getProfileWindow(parentWidget());
453 const QRect rect(w->x(), w->y(), w->width(), w->height());
454 conf.
setValue<QRect>(QStringLiteral(
"windowRect"), rect);
455 conf.
setValue<
bool>(QStringLiteral(
"staysOnTop"),
456 w->windowFlags() & Qt::WindowStaysOnTopHint);
457 conf.
setValue<
bool>(QStringLiteral(
"staysOnBottom"),
458 w->windowFlags() & Qt::WindowStaysOnBottomHint);
459 conf.
setValue(QStringLiteral(
"maximized"), w->isMaximized());
461 bool const hasFocus =
463 conf.
setValue(QStringLiteral(
"hasFocus"), hasFocus);
472 conf.
setValue(QStringLiteral(
"writeWindowType"), int(0));
476 setUpdatesEnabled(
false);
478 QWidget *
const w = getProfileWindow(parentWidget());
486 const QRect rect = conf.
value<QRect>(QStringLiteral(
"windowRect"));
487 w->resize(rect.width(), rect.height());
488 w->move(rect.x(), rect.y());
489 if (conf.
value<
bool>(QStringLiteral(
"staysOnTop"),
false))
490 w->setWindowFlags(w->windowFlags() | Qt::WindowStaysOnTopHint);
491 if (conf.
value<
bool>(QStringLiteral(
"staysOnBottom"),
false))
492 w->setWindowFlags(w->windowFlags() | Qt::WindowStaysOnBottomHint);
493 if (conf.
value<
bool>(QStringLiteral(
"maximized")))
496 setUpdatesEnabled(
true);
505 [
this](
bool const backEnabled,
bool const fwEnabled) {
517 QMenu * menu = m_actions.backInHistory->popupMenu();
519 for (auto * const actionPtr
520 : m_history->getBackList())
521 menu->addAction(actionPtr);
528 QMenu* menu = m_actions.forwardInHistory->popupMenu();
530 for (auto * const actionPtr
531 : m_history->getFwList())
532 menu->addAction(actionPtr);
556 auto *
const popupMenu =
new QMenu(
this);
559 popupMenu->addSeparator();
586 #ifdef BUILD_TEXT_TO_SPEECH
587 popupMenu->addAction((
m_actions.speakSelectedText));
594 if (
btApp->debugMode()) {
595 auto *
const debugAction =
596 new QAction(tr(
"DEBUG: Show raw text"),
this);
597 debugAction->setProperty(
"bibletime_show_raw_text",
true);
598 menu->addSeparator();
599 menu->addAction(debugAction);
653 if (
auto *
const module = backend.findModuleByName(*it)) {
674 QStringLiteral(
"Displaywindow shortcuts"));
715 setWindowIcon(
m_modules.first()->moduleIcon());
727 auto *
const bibleModule =
729 QStringLiteral(
"standardBible"));
737 tr(
"Please choose a Bible in the Settings > "
738 "Configure dialog."));
780 if (!conf.session().value<
bool>(
781 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
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