16 #include <QCloseEvent>
18 #include <QFileDialog>
19 #include <QMdiSubWindow>
21 #include <QStringList>
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))
60 , m_swordKey((static_cast<void>(
BT_ASSERT(!modules.empty())),
61 m_modules.first()->createKey()))
69 setMinimumSize(100, 100);
70 setFocusPolicy(Qt::ClickFocus);
81 setWindowIcon(
m_modules.first()->moduleIcon());
107 setWindowTitle(tr(
"<NO WORKS>"));
109 setWindowTitle(QStringLiteral(
"%1 (%2)")
125 const QRect rect(w->x(), w->y(), w->width(), w->height());
126 conf.
setValue<QRect>(QStringLiteral(
"windowRect"), rect);
127 conf.
setValue<
bool>(QStringLiteral(
"staysOnTop"),
128 w->windowFlags() & Qt::WindowStaysOnTopHint);
129 conf.
setValue<
bool>(QStringLiteral(
"staysOnBottom"),
130 w->windowFlags() & Qt::WindowStaysOnBottomHint);
131 conf.
setValue(QStringLiteral(
"maximized"), w->isMaximized());
133 bool const hasFocus =
135 conf.
setValue(QStringLiteral(
"hasFocus"), hasFocus);
144 conf.
setValue(QStringLiteral(
"writeWindowType"), int(0));
148 setUpdatesEnabled(
false);
158 const QRect rect = conf.
value<QRect>(QStringLiteral(
"windowRect"));
159 w->resize(rect.width(), rect.height());
160 w->move(rect.x(), rect.y());
161 if (conf.
value<
bool>(QStringLiteral(
"staysOnTop"),
false))
162 w->setWindowFlags(w->windowFlags() | Qt::WindowStaysOnTopHint);
163 if (conf.
value<
bool>(QStringLiteral(
"staysOnBottom"),
false))
164 w->setWindowFlags(w->windowFlags() | Qt::WindowStaysOnBottomHint);
165 if (conf.
value<
bool>(QStringLiteral(
"maximized")))
168 setUpdatesEnabled(
true);
172 auto * actn =
new QAction(QIcon(), tr(
"Copy"), a);
173 actn->setShortcut(QKeySequence::Copy);
174 a->
addAction(QStringLiteral(
"copySelectedText"), actn);
176 actn =
new QAction(QIcon(), tr(
"Copy by references..."), a);
177 actn->setShortcut(Qt::CTRL | Qt::Key_R);
178 a->
addAction(QStringLiteral(
"copyByReferences"), actn);
180 actn =
new QAction(QIcon(), tr(
"Find..."), a);
181 actn->setShortcut(QKeySequence::Find);
182 a->
addAction(QStringLiteral(
"findText"), actn);
184 actn =
new QAction(QIcon(), tr(
"Change location"), a);
185 actn->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_L));
186 a->
addAction(QStringLiteral(
"openLocation"), actn);
188 actn =
new QAction(QIcon(), tr(
"Page down"), a);
189 actn->setShortcut(QKeySequence(Qt::Key_PageDown));
190 a->
addAction(QStringLiteral(
"pageDown"), actn);
192 actn =
new QAction(QIcon(), tr(
"Page up"), a);
193 actn->setShortcut(QKeySequence(Qt::Key_PageUp));
194 a->
addAction(QStringLiteral(
"pageUp"), actn);
196 actn =
new QAction(CResMgr::displaywindows::general::search::icon(),
197 tr(
"Search with works of this window"), a);
202 CResMgr::displaywindows::general::backInHistory::icon(),
203 tr(
"Back in history"),
211 CResMgr::displaywindows::general::forwardInHistory::icon(),
212 tr(
"Forward in history"),
220 actn =
new QAction(tr(
"Copy reference only"), a);
221 a->
addAction(QStringLiteral(
"copyReferenceOnly"), actn);
223 actn =
new QAction(tr(
"Save entry as HTML"), a);
224 a->
addAction(QStringLiteral(
"saveHtml"), actn);
226 actn =
new QAction(tr(
"Print reference only"), a);
227 a->
addAction(QStringLiteral(
"printReferenceOnly"), actn);
229 actn =
new QAction(tr(
"Entry with text"), a);
230 a->
addAction(QStringLiteral(
"copyEntryWithText"), actn);
232 actn =
new QAction(tr(
"Entry as plain text"), a);
233 a->
addAction(QStringLiteral(
"saveEntryAsPlain"), actn);
235 actn =
new QAction(tr(
"Entry with text"), a);
236 a->
addAction(QStringLiteral(
"printEntryWithText"), actn);
238 actn =
new QAction(tr(
"Strong's Search"), a);
252 QStringLiteral(
"openLocation"),
254 if (
btConfig().session().value<bool>(
255 QStringLiteral(
"GUI/showToolbarsInEachWindow"),
304 for (
auto const & strongNumber
309 QStringLiteral(
"strong:%1 ")
325 &ac->action(QStringLiteral(
"copySelectedText"));
328 &ac->action(QStringLiteral(
"copyByReferences"));
332 QStringLiteral(
"saveEntryAsPlain"),
346 QStringLiteral(
"saveHtml"),
370 QStringLiteral(
"Displaywindow shortcuts"));
379 [
this](
bool const backEnabled,
bool const fwEnabled) {
391 QMenu * menu = m_actions.backInHistory->popupMenu();
393 for (auto * const actionPtr
394 : m_history->getBackList())
395 menu->addAction(actionPtr);
402 QMenu* menu = m_actions.forwardInHistory->popupMenu();
404 for (auto * const actionPtr
405 : m_history->getFwList())
406 menu->addAction(actionPtr);
436 m_headerBar->setWindowTitle(tr(
"Text area header"));
439 QStringLiteral(
"GUI/showTextWindowHeaders"),
480 auto *
const popupMenu =
new QMenu(
this);
488 bool const hasActiveAnchor =
496 popupMenu->setTitle(tr(
"Lexicon window"));
497 popupMenu->setIcon(
m_modules.first()->moduleIcon());
500 popupMenu->addSeparator();
581 if (
auto *
const module =
backend.findModuleByName(*it)) {
602 QStringLiteral(
"Displaywindow shortcuts"));
604 QStringLiteral(
"Readwindow shortcuts"));
645 setWindowIcon(
m_modules.first()->moduleIcon());
657 auto *
const bibleModule =
659 QStringLiteral(
"standardBible"));
667 tr(
"Please choose a Bible in the Settings > "
668 "Configure dialog."));
721 "GUI/showTextWindowModuleSelectorButtons"),
740 if (!conf.session().value<
bool>(
741 QStringLiteral(
"GUI/showToolbarsInEachWindow"),
768 bar->setAllowedAreas(Qt::TopToolBarArea);
769 bar->setFloatable(
false);
770 bar->setWindowTitle(title);
771 bar->setVisible(visible);
780 QStringLiteral(
"GUI/showTextWindowNavigator"),
794 QStringLiteral(
"GUI/showTextWindowToolButtons"),
875 [newDisplay]{ newDisplay->
qmlInterface()->changeColorTheme(); });
BtConfig & btConfig()
This is a shortchand for BtConfig::getInstance().
QList< CSwordModuleInfo * > BtModuleList
static void prepareToolBar(QToolBar *bar, const QString &title, bool visible)
void historyMoved(QString newKey)
void add(CSwordKey *newKey)
void historyChanged(bool backEnabled, bool fwEnabled)
QToolBar * toolsToolBar() const noexcept
QToolBar * navToolBar() const noexcept
BtModuleChooserBar * worksToolBar() const noexcept
void toggledTextWindowToolButtons(bool newState)
void toggledTextWindowHeader(bool newState)
void openSearchDialog(BtConstModuleList modules, QString const &searchText={})
void toggledTextWindowNavigator(bool newState)
void toggledTextWindowModuleChooser(bool newState)
static BibleTime * instance() 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 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)
BtQmlInterface * qmlInterface() const noexcept
BtQuickWidget * quickWidget() const noexcept
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.
bool hasActiveAnchor() const
void copyByReferences()
Copies the given text specified by asking user for first and last references.
void printAnchorWithText(DisplayOptions const &displayOptions, FilterOptions const &filterOptions)
QString getCurrentNodeInfo() const
void setDisplayOptions(const DisplayOptions &displayOptions)
void setFilterOptions(FilterOptions filterOptions)
void associateWithWindow(CDisplayWindow *window)
bool hasSelectedText() const noexcept
The base class for all display windows of BibleTime.
void addModuleChooserBar()
virtual void modulesChanged()
FilterOptions m_filterOptions
void sigKeyChanged(CSwordKey *key)
void setDisplayWidget(BtModelViewReadDisplay *newDisplay)
DisplayOptions const & displayOptions() const
void sigDisplayOptionsChanged(const DisplayOptions &displayOptions)
void printAnchorWithText()
BTHistory *const m_history
QAction & initAddAction(Args &&... args)
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.
QStringList m_moduleNames
CDisplayWindow(BtModuleList const &modules, CMDIArea *const parent)
void sigFilterOptionsChanged(const FilterOptions &filterOptions)
virtual void initActions()
void sigModulesChanged(const BtConstModuleList &modules)
FilterOptions const & filterOptions() const
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)
void setKeyChooser(CKeyChooser *ck)
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.
void sigModuleListChanged(BtModuleList newList)
~CDisplayWindow() override
BtModuleChooserBar * m_moduleChooserBar
void slotRemoveModule(int index)
BtModelViewReadDisplay * m_displayWidget
virtual QMenu * newDisplayWidgetPopupMenu()
void slotReplaceModule(int index, CSwordModuleInfo *newModule)
static void insertKeyboardActions(BtActionCollection *const a)
CSwordKey * getMouseClickedKey() const
void setBibleReference(const QString &reference)
virtual void copyDisplayedText()
QToolBar * buttonsToolBar()
BtActionCollection *const m_actionCollection
QAction & initAction(Name &&name, Args &&... args)
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.
static CSwordBackend & instance() noexcept
void sigSwordSetupChanged()
virtual bool setKey(const QString &key)=0
virtual QString key() const =0
QString const & name() const
std::unique_ptr< CSwordBackend > backend(sword::InstallSource const &is)
QWidget * getProfileWindow(QWidget *w)
QMessageBox::StandardButton showInformation(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
struct CDisplayWindow::ActionsStruct::@7 print
BtToolBarPopupAction * forwardInHistory
BtToolBarPopupAction * backInHistory
struct CDisplayWindow::ActionsStruct::@6 save
struct CDisplayWindow::ActionsStruct::@5 copy