16 #include <QApplication>
19 #include <QDesktopServices>
20 #include <QInputDialog>
21 #include <QMdiSubWindow>
23 #include <QMetaObject>
27 #include <QTimerEvent>
30 #include "../backend/config/btconfig.h"
31 #include "../backend/managers/cswordbackend.h"
32 #include "../util/btassert.h"
33 #include "../util/btconnect.h"
34 #include "../util/directory.h"
56 , m_updateTimerId(startTimer(100))
58 setWindowFlags(Qt::Dialog);
59 setAttribute(Qt::WA_DeleteOnClose);
66 { setWindowTitle(tr(
"What's this widget?")); }
69 if (event->timerId() == m_updateTimerId) {
70 if (
QObject const * w = QApplication::widgetAt(QCursor::pos())) {
71 QString objectHierarchy;
73 QMetaObject
const * m = w->metaObject();
74 QString classHierarchy;
76 if (!classHierarchy.isEmpty())
77 classHierarchy += QStringLiteral(
": ");
78 classHierarchy += m->className();
81 if (!objectHierarchy.isEmpty()) {
83 .append(QStringLiteral(
"<br/>"))
84 .append(tr(
"<b>child of:</b> %1").arg(
87 objectHierarchy.append(
88 tr(
"<b>This widget is:</b> %1").arg(
93 setHtml(objectHierarchy);
95 setText(tr(
"No widget"));
98 QTextEdit::timerEvent(event);
125 QStringLiteral(
"Application shortcuts"));
146 const int numSubWindows =
m_mdi->subWindowList().count();
151 const bool enableManualArrangeActions = numSubWindows > 1;
165 openWindowAction->setCheckable(
true);
166 openWindowAction->setChecked(window ==
m_mdi->activeSubWindow());
167 BT_CONNECT(openWindowAction, &QAction::triggered,
187 guiConfig.setValue(QStringLiteral(
"alignmentMode"),
autoTile);
191 guiConfig.setValue(QStringLiteral(
"alignmentMode"),
autoTabbed);
195 guiConfig.setValue(QStringLiteral(
"alignmentMode"),
autoCascade);
209 guiConfig.setValue(QStringLiteral(
"alignmentMode"),
manual);
246 bool const currentState =
247 guiConf.
value<
bool>(QStringLiteral(
"showMainToolbar"),
true);
248 guiConf.setValue(QStringLiteral(
"showMainToolbar"), !currentState);
259 bool const currentState =
260 guiConfig.
value<
bool>(QStringLiteral(
"showTextWindowHeaders"),
262 guiConfig.setValue(QStringLiteral(
"showTextWindowHeaders"), !currentState);
268 bool const currentState =
269 guiConfig.
value<
bool>(QStringLiteral(
"showTextWindowNavigator"),
271 guiConfig.setValue(QStringLiteral(
"showTextWindowNavigator"),
273 if (guiConfig.value<
bool>(QStringLiteral(
"showToolbarsInEachWindow"),
true))
278 guiConfig.value<
bool>(
279 QStringLiteral(
"showTextWindowNavigator"),
286 bool const currentState =
287 guiConfig.
value<
bool>(QStringLiteral(
"showTextWindowToolButtons"),
289 guiConfig.setValue(QStringLiteral(
"showTextWindowToolButtons"),
291 if (guiConfig.value<
bool>(QStringLiteral(
"showToolbarsInEachWindow"),
true))
296 guiConfig.value<
bool>(
297 QStringLiteral(
"showTextWindowToolButtons"),
304 bool const currentState =
305 guiConfig.
value<
bool>(
306 QStringLiteral(
"showTextWindowModuleSelectorButtons"),
308 guiConfig.setValue(QStringLiteral(
"showTextWindowModuleSelectorButtons"),
310 if (guiConfig.value<
bool>(QStringLiteral(
"showToolbarsInEachWindow"),
true))
315 guiConfig.value<
bool>(
316 QStringLiteral(
"showTextWindowModuleSelectorButtons"),
323 bool const currentState =
324 guiConfig.
value<
bool>(QStringLiteral(
"showToolbarsInEachWindow"),
326 guiConfig.setValue(QStringLiteral(
"showToolbarsInEachWindow"),
333 if (guiConfig.value<
bool>(QStringLiteral(
"showToolbarsInEachWindow"),
true))
341 guiConfig.value<
bool>(
342 QStringLiteral(
"showTextWindowNavigator"),
345 guiConfig.value<
bool>(
346 QStringLiteral(
"showTextWindowModuleSelectorButtons"),
349 guiConfig.value<
bool>(
350 QStringLiteral(
"showTextWindowToolButtons"),
355 guiConfig.value<
bool>(
356 QStringLiteral(
"showTextWindowNavigator"),
359 guiConfig.value<
bool>(
360 QStringLiteral(
"showTextWindowModuleSelectorButtons"),
363 guiConfig.value<
bool>(
364 QStringLiteral(
"showTextWindowToolButtons"),
377 m_mdi->setActiveSubWindow(
dynamic_cast<QMdiSubWindow*
>(window));
384 for (
auto const *
const subWindow :
m_mdi->subWindowList()) {
395 if (window ==
nullptr)
405 if (
auto const *
const bible =
406 btConfig().getDefaultSwordModuleByType(
407 QStringLiteral(
"standardBible")))
408 module.append(bible);
417 tr(
"Error locating handbook!"),
418 tr(
"A suitable installed handbook could not be found!"));
421 if (!QDesktopServices::openUrl(QUrl::fromLocalFile(url)))
424 tr(
"Error opening handbook!"),
425 tr(
"The installed handbook could not be opened!"));
433 tr(
"Error locating howto!"),
434 tr(
"A suitable installed howto could not be found!"));
437 if (!QDesktopServices::openUrl(QUrl::fromLocalFile(url)))
440 tr(
"Error opening howto!"),
441 tr(
"The installed howto could not be opened!"));
457 conf.
setValue(QStringLiteral(
"MainWindow/geometry"), saveGeometry());
458 conf.setValue(QStringLiteral(
"MainWindow/state"), saveState());
459 conf.setValue(QStringLiteral(
"MainWindow/MDIArrangementMode"),
462 conf.setValue(QStringLiteral(
"FindIsVisible"),
465 QStringList windowsList;
466 for (
auto const *
const w :
m_mdi->subWindowList(QMdiArea::StackingOrder)) {
471 const QString windowKey = QString::number(windowsList.size());
472 windowsList.append(windowKey);
473 auto windowConf = conf.group(QStringLiteral(
"window/") + windowKey);
476 conf.setValue(QStringLiteral(
"windowsList"), windowsList);
481 QVariant keyProperty = action->property(
"ProfileKey");
482 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
483 BT_ASSERT(keyProperty.type() == QVariant::String);
485 BT_ASSERT(keyProperty.typeId() == QMetaType::QString);
493 BT_ASSERT(conf.sessionNames().contains(profileKey));
496 if (profileKey == conf.currentSessionKey())
503 m_mdi->closeAllSubWindows();
506 conf.setCurrentSession(profileKey);
515 setUpdatesEnabled(
false);
518 m_mdi->closeAllSubWindows();
522 auto const mwConf = sessionConf.
group(QStringLiteral(
"MainWindow"));
523 restoreGeometry(mwConf.value<QByteArray>(QStringLiteral(
"geometry")));
524 restoreState(mwConf.value<QByteArray>(QStringLiteral(
"state")));
531 auto const guiConf = sessionConf.group(QStringLiteral(
"GUI"));
535 guiConf.value<
bool>(QStringLiteral(
"showTextWindowHeaders"),
539 guiConf.value<
bool>(QStringLiteral(
"showMainToolbar"),
true));
542 guiConf.value<
bool>(QStringLiteral(
"showTextWindowNavigator"),
547 QStringLiteral(
"showTextWindowModuleSelectorButtons"),
551 guiConf.value<
bool>(QStringLiteral(
"showTextWindowToolButtons"),
555 guiConf.value<
bool>(QStringLiteral(
"showToolbarsInEachWindow"),
560 mwConf.value<
int>(QStringLiteral(
"MDIArrangementMode"),
564 sessionConf.value<
bool>(QStringLiteral(
"FindIsVisible"),
567 QWidget * focusWindow =
nullptr;
568 struct WindowLoadStatus {
569 QStringList failedModules;
572 QMap<QString, WindowLoadStatus> failedWindows;
574 : sessionConf.value<QStringList>(QStringLiteral(
"windowsList")))
577 auto const windowConf =
578 sessionConf.group(QStringLiteral(
"window/") + w);
581 WindowLoadStatus wls;
582 for (
auto const & moduleName
583 : windowConf.value<QStringList>(QStringLiteral(
"modules")))
588 wls.okModules.append(m);
590 wls.failedModules.append(moduleName);
595 if (wls.okModules.isEmpty()) {
596 failedWindows.insert(w, wls);
601 if (!wls.failedModules.isEmpty())
602 failedWindows.insert(w, wls);
605 auto const key = windowConf.value<QString>(QStringLiteral(
"key"));
607 window->applyProfileSettings(windowConf);
608 if (windowConf.value<
bool>(QStringLiteral(
"hasFocus"),
false))
609 focusWindow = window;
611 failedWindows.insert(w, wls);
625 focusWindow->setFocus();
628 setUpdatesEnabled(
true);
637 QVariant keyProperty = action->property(
"ProfileKey");
638 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
639 BT_ASSERT(keyProperty.type() == QVariant::String);
641 BT_ASSERT(keyProperty.typeId() == QMetaType::QString);
651 setWindowState(windowState() ^ Qt::WindowFullScreen);
655 template <
bool goingUp>
659 static constexpr
int const intervals[21] = {
660 1, 2, 3, 5, 9, 15, 25, 43, 72, 120, 200,
661 120, 72, 43, 25, 15, 9, 5, 3, 2, 1
664 static constexpr
int const nudgeSpeed = goingUp ? 1 : -1;
685 template void BibleTime::autoScroll<true>();
686 template void BibleTime::autoScroll<false>();
716 display->updateReferenceText();
728 name = QInputDialog::getText(
729 this, tr(
"New Session"),
730 tr(
"Please enter a name for the new session."),
731 QLineEdit::Normal, name, &ok);
735 if (!name.isEmpty()) {
739 tr(
"Session with the name \"%1\" "
740 "already exists. Please provide a "
741 "different name.").arg(name));
767 const bool enableActions = sessions.size() > 1;
773 for (
auto it = sessions.constBegin(); it != sessions.constEnd(); ++it) {
777 a->setProperty(
"ProfileKey", it.key());
779 a->setCheckable(
true);
784 a->setProperty(
"ProfileKey", it.key());
786 a->setDisabled(
true);
797 Qt::DirectConnection);
BtConfig & btConfig()
This is a shortchand for BtConfig::getInstance().
QList< CSwordModuleInfo const * > BtConstModuleList
QAction * m_windowCloseAction
void loadProfile(QAction *action)
QPointer< QWidget > m_debugWindow
BtModuleChooserBar * m_worksToolBar
QAction * m_autoScrollPauseAction
void slotBookshelfWizard()
QAction * m_windowTileVerticalAction
QAction * m_windowAutoTileVerticalAction
QAction * m_windowCascadeAction
void slotShowDebugWindow(bool)
QAction * m_debugWidgetAction
void slotActiveWindowChanged(QMdiSubWindow *window)
QAction * m_windowTileAction
QAction * m_windowAutoCascadeAction
QAction * m_showTextWindowNavigationAction
void deleteProfile(QAction *action)
QAction * m_windowAutoTileHorizontalAction
void slotTileHorizontal()
InfoDisplay::CInfoDisplay * m_infoDisplay
void slotUpdateWindowArrangementActions(QAction *trigerredAction)
void toggledTextWindowToolButtons(bool newState)
void slotToggleWorksToolbar()
void slotOpenAboutDialog()
void toggledTextWindowHeader(bool newState)
void openSearchDialog(BtConstModuleList modules, QString const &searchText={})
void slotSearchDefaultBible()
void slotSettingsOptions()
void slotToggleMainToolbar()
QAction * m_showTextAreaHeadersAction
void slotToggleTextWindowHeader()
void showOrHideToolBars()
void toggledTextWindowNavigator(bool newState)
void slotOpenWindowsMenuAboutToShow()
void openOnlineHelp_Handbook()
QAction * m_windowAutoTileAction
QAction * m_showTextWindowModuleChooserAction
QAction * m_windowTileHorizontalAction
QAction * m_showMainWindowToolbarAction
QMenu * m_windowDeleteProfileMenu
void refreshProfileMenus()
QAction * m_showTextWindowToolButtonsAction
void slotToggleToolsToolbar()
QToolBar * m_toolsToolBar
void slotToggleToolBarsInEachWindow()
void toggledTextWindowModuleChooser(bool newState)
QAction * m_windowManualModeAction
BtFindWidget * m_findWidget
BtModelViewReadDisplay * getCurrentDisplay()
void openOnlineHelp_Howto()
void slotWindowMenuAboutToShow()
QAction * m_windowAutoTabbedAction
QAction * m_windowFullscreenAction
void saveConfigSettings()
QMenu * m_windowLoadProfileMenu
QActionGroup * m_windowLoadProfileActionGroup
CDisplayWindow * createReadDisplayWindow(QList< CSwordModuleInfo * > modules, QString const &key)
Creates a new presenter in the MDI area according to the type of the module.
void refreshDisplayWindows() const
QAction * m_toolbarsInEachWindow
void slotToggleNavigatorToolbar()
QAction * m_windowCloseAllAction
BtActionCollection * m_actionCollection
QMenu * m_openWindowsMenu
void slotSetActiveSubWindow(QWidget *window)
void readShortcuts(QString const &group)
Read shortcuts from config.
The Bookshelf Manager wizard.
BtConfigCore group(Prefix &&prefix) 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.
void signalSettingsChanged()
BtConfigCore session() const
QHash< QString, QString > sessionNames() const
QString addSession(const QString &name)
Creates a new session with the given name.
void setCurrentSession(const QString &key)
Notifies the configuration system that the session settings should be read from and saved to the give...
QString const & currentSessionKey() const
void deleteSession(const QString &key)
Deletes the session with the given key.
The base class for all display windows of BibleTime.
virtual void storeProfileSettings(BtConfigCore &windowConf) const
Stores the settings of this window to configuration.
BtConstModuleList constModules() const
@ ArrangementModeTileVertical
@ ArrangementModeTileHorizontal
void setMDIArrangementMode(const MDIArrangementMode mode)
void enableWindowMinMaxFlags(bool enable)
void triggerWindowUpdate()
QList< QMdiSubWindow * > usableWindowList() const
MDIArrangementMode getMDIArrangementMode() const
static CSwordBackend & instance() noexcept
void setBooknameLanguage(QString const &langName)
Sets the language for the international booknames of Sword.
void timerEvent(QTimerEvent *const event) override
int const m_updateTimerId
void setQActionCheckedNoTrigger(QAction *const action, const bool checked)
QMessageBox::StandardButton showInformation(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
QMessageBox::StandardButton showCritical(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)