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))
52 bar->setAllowedAreas(Qt::TopToolBarArea);
53 bar->setFloatable(
false);
54 bar->setWindowTitle(title);
55 bar->setVisible(visible);
62 bool const addTextHeaderToolbar,
68 , m_swordKey((static_cast<void>(
BT_ASSERT(!modules.empty())),
69 m_modules.first()->createKey()))
77 setMinimumSize(100, 100);
78 setFocusPolicy(Qt::ClickFocus);
89 setWindowIcon(
m_modules.first()->moduleIcon());
102 QStringLiteral(
"GUI/showTextWindowNavigator"),
120 "GUI/showTextWindowModuleSelectorButtons"),
132 QStringLiteral(
"GUI/showTextWindowToolButtons"),
138 if (addTextHeaderToolbar) {
143 m_headerBar->setWindowTitle(tr(
"Text area header"));
146 QStringLiteral(
"GUI/showTextWindowHeaders"),
176 setWindowTitle(tr(
"<NO WORKS>"));
178 setWindowTitle(QStringLiteral(
"%1 (%2)")
194 const QRect rect(w->x(), w->y(), w->width(), w->height());
195 conf.
setValue<QRect>(QStringLiteral(
"windowRect"), rect);
196 conf.
setValue<
bool>(QStringLiteral(
"staysOnTop"),
197 w->windowFlags() & Qt::WindowStaysOnTopHint);
198 conf.
setValue<
bool>(QStringLiteral(
"staysOnBottom"),
199 w->windowFlags() & Qt::WindowStaysOnBottomHint);
200 conf.
setValue(QStringLiteral(
"maximized"), w->isMaximized());
202 bool const hasFocus =
204 conf.
setValue(QStringLiteral(
"hasFocus"), hasFocus);
213 conf.
setValue(QStringLiteral(
"writeWindowType"), int(0));
217 setUpdatesEnabled(
false);
227 const QRect rect = conf.
value<QRect>(QStringLiteral(
"windowRect"));
228 w->resize(rect.width(), rect.height());
229 w->move(rect.x(), rect.y());
230 if (conf.
value<
bool>(QStringLiteral(
"staysOnTop"),
false))
231 w->setWindowFlags(w->windowFlags() | Qt::WindowStaysOnTopHint);
232 if (conf.
value<
bool>(QStringLiteral(
"staysOnBottom"),
false))
233 w->setWindowFlags(w->windowFlags() | Qt::WindowStaysOnBottomHint);
234 if (conf.
value<
bool>(QStringLiteral(
"maximized")))
237 setUpdatesEnabled(
true);
241 auto * actn =
new QAction(QIcon(), tr(
"Copy"), a);
242 actn->setShortcut(QKeySequence::Copy);
243 a->
addAction(QStringLiteral(
"copySelectedText"), actn);
245 actn =
new QAction(QIcon(), tr(
"Copy by references..."), a);
246 actn->setShortcut(Qt::CTRL | Qt::Key_R);
247 a->
addAction(QStringLiteral(
"copyByReferences"), actn);
249 actn =
new QAction(QIcon(), tr(
"Find..."), a);
250 actn->setShortcut(QKeySequence::Find);
251 a->
addAction(QStringLiteral(
"findText"), actn);
253 actn =
new QAction(QIcon(), tr(
"Change location"), a);
254 actn->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_L));
255 a->
addAction(QStringLiteral(
"openLocation"), actn);
257 actn =
new QAction(QIcon(), tr(
"Page down"), a);
258 actn->setShortcut(QKeySequence(Qt::Key_PageDown));
259 a->
addAction(QStringLiteral(
"pageDown"), actn);
261 actn =
new QAction(QIcon(), tr(
"Page up"), a);
262 actn->setShortcut(QKeySequence(Qt::Key_PageUp));
263 a->
addAction(QStringLiteral(
"pageUp"), actn);
265 actn =
new QAction(CResMgr::displaywindows::general::search::icon(),
266 tr(
"Search with works of this window"), a);
271 CResMgr::displaywindows::general::backInHistory::icon(),
272 tr(
"Back in history"),
280 CResMgr::displaywindows::general::forwardInHistory::icon(),
281 tr(
"Forward in history"),
289 actn =
new QAction(tr(
"Copy reference only"), a);
290 a->
addAction(QStringLiteral(
"copyReferenceOnly"), actn);
292 actn =
new QAction(tr(
"Save entry as HTML"), a);
293 a->
addAction(QStringLiteral(
"saveHtml"), actn);
295 actn =
new QAction(tr(
"Print reference only"), a);
296 a->
addAction(QStringLiteral(
"printReferenceOnly"), actn);
298 actn =
new QAction(tr(
"Entry with text"), a);
299 a->
addAction(QStringLiteral(
"copyEntryWithText"), actn);
301 actn =
new QAction(tr(
"Entry as plain text"), a);
302 a->
addAction(QStringLiteral(
"saveEntryAsPlain"), actn);
304 actn =
new QAction(tr(
"Entry with text"), a);
305 a->
addAction(QStringLiteral(
"printEntryWithText"), actn);
307 actn =
new QAction(tr(
"Strong's Search"), a);
321 QStringLiteral(
"openLocation"),
323 if (
btConfig().session().value<bool>(
324 QStringLiteral(
"GUI/showToolbarsInEachWindow"),
373 for (
auto const & strongNumber
378 QStringLiteral(
"strong:%1 ")
394 &ac->action(QStringLiteral(
"copySelectedText"));
397 &ac->action(QStringLiteral(
"copyByReferences"));
401 QStringLiteral(
"saveEntryAsPlain"),
415 QStringLiteral(
"saveHtml"),
439 QStringLiteral(
"Displaywindow shortcuts"));
448 [
this](
bool const backEnabled,
bool const fwEnabled) {
460 QMenu * menu = m_actions.backInHistory->popupMenu();
462 for (auto * const actionPtr
463 : m_history->getBackList())
464 menu->addAction(actionPtr);
471 QMenu* menu = m_actions.forwardInHistory->popupMenu();
473 for (auto * const actionPtr
474 : m_history->getFwList())
475 menu->addAction(actionPtr);
514 auto *
const popupMenu =
new QMenu(
this);
522 bool const hasActiveAnchor =
530 popupMenu->setTitle(tr(
"Lexicon window"));
531 popupMenu->setIcon(
m_modules.first()->moduleIcon());
534 popupMenu->addSeparator();
615 if (
auto *
const module =
backend.findModuleByName(*it)) {
636 QStringLiteral(
"Displaywindow shortcuts"));
638 QStringLiteral(
"Readwindow shortcuts"));
679 setWindowIcon(
m_modules.first()->moduleIcon());
691 auto *
const bibleModule =
693 QStringLiteral(
"standardBible"));
701 tr(
"Please choose a Bible in the Settings > "
702 "Configure dialog."));
754 if (!conf.session().value<
bool>(
755 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)
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.
virtual void modulesChanged()
FilterOptions m_filterOptions
void sigKeyChanged(CSwordKey *key)
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
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.
CDisplayWindow(BtModuleList const &modules, bool const addTextHeaderToolbar, CMDIArea *const parent)
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()
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)
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::@7 print
BtToolBarPopupAction * forwardInHistory
BtToolBarPopupAction * backInHistory
struct CDisplayWindow::ActionsStruct::@6 save
struct CDisplayWindow::ActionsStruct::@5 copy