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);
136 bool const addTextHeaderToolbar,
156 setMinimumSize(100, 100);
157 setFocusPolicy(Qt::ClickFocus);
168 setWindowIcon(
m_modules.first()->moduleIcon());
181 QStringLiteral(
"GUI/showTextWindowNavigator"),
203 "GUI/showTextWindowModuleSelectorButtons"),
215 QStringLiteral(
"GUI/showTextWindowToolButtons"),
221 if (addTextHeaderToolbar) {
224 auto *
const headerBar =
new QToolBar(
this);
225 headerBar->setMovable(
false);
226 headerBar->setWindowTitle(tr(
"Text area header"));
227 headerBar->setVisible(
229 QStringLiteral(
"GUI/showTextWindowHeaders"),
232 headerBar, &QToolBar::setVisible);
234 auto *
const headerWidget =
246 headerBar->addWidget(headerWidget);
248 addToolBar(headerBar);
257 QStringLiteral(
"openLocation"),
259 if (
btConfig().session().value<bool>(
260 QStringLiteral(
"GUI/showToolbarsInEachWindow"),
274 auto & copySelectedTextAction =
281 [©SelectedTextAction](
282 std::optional<BtQmlInterface::Selection>
const & newSelection)
284 copySelectedTextAction.setEnabled(newSelection.has_value());
313 for (
auto const & strongNumber
318 QStringLiteral(
"strong:%1 ")
324 [
this](QString
const & nodeInfo)
339 QStringLiteral(
"saveEntryAsPlain"),
352 QStringLiteral(
"saveHtml"),
373 [
this](QString
const & newActiveAnchor) {
374 bool const hasActiveAnchor = !newActiveAnchor.isEmpty();
379 QStringLiteral(
"Displaywindow shortcuts"));
404 setWindowTitle(tr(
"<NO WORKS>"));
406 setWindowTitle(QStringLiteral(
"%1 (%2)")
414 QWidget const *
const w = getProfileWindow(parentWidget());
422 const QRect rect(w->x(), w->y(), w->width(), w->height());
423 conf.
setValue<QRect>(QStringLiteral(
"windowRect"), rect);
424 conf.
setValue<
bool>(QStringLiteral(
"staysOnTop"),
425 w->windowFlags() & Qt::WindowStaysOnTopHint);
426 conf.
setValue<
bool>(QStringLiteral(
"staysOnBottom"),
427 w->windowFlags() & Qt::WindowStaysOnBottomHint);
428 conf.
setValue(QStringLiteral(
"maximized"), w->isMaximized());
430 bool const hasFocus =
432 conf.
setValue(QStringLiteral(
"hasFocus"), hasFocus);
441 conf.
setValue(QStringLiteral(
"writeWindowType"), int(0));
445 setUpdatesEnabled(
false);
447 QWidget *
const w = getProfileWindow(parentWidget());
455 const QRect rect = conf.
value<QRect>(QStringLiteral(
"windowRect"));
456 w->resize(rect.width(), rect.height());
457 w->move(rect.x(), rect.y());
458 if (conf.
value<
bool>(QStringLiteral(
"staysOnTop"),
false))
459 w->setWindowFlags(w->windowFlags() | Qt::WindowStaysOnTopHint);
460 if (conf.
value<
bool>(QStringLiteral(
"staysOnBottom"),
false))
461 w->setWindowFlags(w->windowFlags() | Qt::WindowStaysOnBottomHint);
462 if (conf.
value<
bool>(QStringLiteral(
"maximized")))
465 setUpdatesEnabled(
true);
474 [
this](
bool const backEnabled,
bool const fwEnabled) {
486 QMenu * menu = m_actions.backInHistory->popupMenu();
488 for (auto * const actionPtr
489 : m_history->getBackList())
490 menu->addAction(actionPtr);
497 QMenu* menu = m_actions.forwardInHistory->popupMenu();
499 for (auto * const actionPtr
500 : m_history->getFwList())
501 menu->addAction(actionPtr);
525 auto *
const popupMenu =
new QMenu(
this);
528 popupMenu->addSeparator();
606 if (
auto *
const module = backend.findModuleByName(*it)) {
627 QStringLiteral(
"Displaywindow shortcuts"));
668 setWindowIcon(
m_modules.first()->moduleIcon());
680 auto *
const bibleModule =
682 QStringLiteral(
"standardBible"));
690 tr(
"Please choose a Bible in the Settings > "
691 "Configure dialog."));
733 if (!conf.session().value<
bool>(
734 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)
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