18#include <QDesktopServices>
19#include <QInputDialog>
20#include <QMdiSubWindow>
28#include "../backend/config/btconfig.h"
29#include "../backend/managers/cswordbackend.h"
30#include "../util/btassert.h"
31#include "../util/btconnect.h"
32#include "../util/directory.h"
62 QStringLiteral(
"Application shortcuts"));
67 #ifdef BUILD_TEXT_TO_SPEECH
70 m_textToSpeech.reset();
89 const int numSubWindows =
m_mdi->subWindowList().count();
94 const bool enableManualArrangeActions = numSubWindows > 1;
108 openWindowAction->setCheckable(
true);
109 openWindowAction->setChecked(window ==
m_mdi->activeSubWindow());
110 BT_CONNECT(openWindowAction, &QAction::triggered,
130 guiConfig.setValue(QStringLiteral(
"alignmentMode"),
autoTile);
134 guiConfig.setValue(QStringLiteral(
"alignmentMode"),
autoTabbed);
138 guiConfig.setValue(QStringLiteral(
"alignmentMode"),
autoCascade);
152 guiConfig.setValue(QStringLiteral(
"alignmentMode"),
manual);
185 bool const currentState =
186 guiConf.
value<
bool>(QStringLiteral(
"showMainToolbar"),
true);
187 guiConf.setValue(QStringLiteral(
"showMainToolbar"), !currentState);
198 bool const currentState =
199 guiConfig.
value<
bool>(QStringLiteral(
"showTextWindowHeaders"),
201 guiConfig.setValue(QStringLiteral(
"showTextWindowHeaders"), !currentState);
207 bool const currentState =
208 guiConfig.
value<
bool>(QStringLiteral(
"showTextWindowNavigator"),
210 guiConfig.setValue(QStringLiteral(
"showTextWindowNavigator"),
212 if (guiConfig.value<
bool>(QStringLiteral(
"showToolbarsInEachWindow"),
true))
217 guiConfig.value<
bool>(
218 QStringLiteral(
"showTextWindowNavigator"),
225 bool const currentState =
226 guiConfig.
value<
bool>(QStringLiteral(
"showTextWindowToolButtons"),
228 guiConfig.setValue(QStringLiteral(
"showTextWindowToolButtons"),
230 if (guiConfig.value<
bool>(QStringLiteral(
"showToolbarsInEachWindow"),
true))
235 guiConfig.value<
bool>(
236 QStringLiteral(
"showTextWindowToolButtons"),
243 bool const currentState =
244 guiConfig.
value<
bool>(
245 QStringLiteral(
"showTextWindowModuleSelectorButtons"),
247 guiConfig.setValue(QStringLiteral(
"showTextWindowModuleSelectorButtons"),
249 if (guiConfig.value<
bool>(QStringLiteral(
"showToolbarsInEachWindow"),
true))
254 guiConfig.value<
bool>(
255 QStringLiteral(
"showTextWindowModuleSelectorButtons"),
262 bool const currentState =
263 guiConfig.
value<
bool>(QStringLiteral(
"showToolbarsInEachWindow"),
265 guiConfig.setValue(QStringLiteral(
"showToolbarsInEachWindow"),
272 if (guiConfig.value<
bool>(QStringLiteral(
"showToolbarsInEachWindow"),
true))
280 guiConfig.value<
bool>(
281 QStringLiteral(
"showTextWindowNavigator"),
284 guiConfig.value<
bool>(
285 QStringLiteral(
"showTextWindowModuleSelectorButtons"),
288 guiConfig.value<
bool>(
289 QStringLiteral(
"showTextWindowToolButtons"),
294 guiConfig.value<
bool>(
295 QStringLiteral(
"showTextWindowNavigator"),
298 guiConfig.value<
bool>(
299 QStringLiteral(
"showTextWindowModuleSelectorButtons"),
302 guiConfig.value<
bool>(
303 QStringLiteral(
"showTextWindowToolButtons"),
316 m_mdi->setActiveSubWindow(
dynamic_cast<QMdiSubWindow*
>(window));
323 for (
auto const *
const subWindow :
m_mdi->subWindowList()) {
334 if (window ==
nullptr)
344 if (
auto const *
const bible =
345 btConfig().getDefaultSwordModuleByType(
346 QStringLiteral(
"standardBible")))
347 module.append(bible);
356 tr(
"Error locating handbook!"),
357 tr(
"A suitable installed handbook could not be found!"));
360 if (!QDesktopServices::openUrl(QUrl::fromLocalFile(url)))
363 tr(
"Error opening handbook!"),
364 tr(
"The installed handbook could not be opened!"));
372 tr(
"Error locating howto!"),
373 tr(
"A suitable installed howto could not be found!"));
376 if (!QDesktopServices::openUrl(QUrl::fromLocalFile(url)))
379 tr(
"Error opening howto!"),
380 tr(
"The installed howto could not be opened!"));
396 conf.
setValue(QStringLiteral(
"MainWindow/geometry"), saveGeometry());
397 conf.setValue(QStringLiteral(
"MainWindow/state"), saveState());
398 conf.setValue(QStringLiteral(
"MainWindow/MDIArrangementMode"),
401 conf.setValue(QStringLiteral(
"FindIsVisible"),
404 QStringList windowsList;
405 for (
auto const *
const w :
m_mdi->subWindowList(QMdiArea::StackingOrder)) {
410 const QString windowKey = QString::number(windowsList.size());
411 windowsList.append(windowKey);
412 auto windowConf = conf.group(QStringLiteral(
"window/") + windowKey);
415 conf.setValue(QStringLiteral(
"windowsList"), windowsList);
420 QVariant keyProperty = action->property(
"ProfileKey");
421 BT_ASSERT(keyProperty.typeId() == QMetaType::QString);
428 BT_ASSERT(conf.sessionNames().contains(profileKey));
431 if (profileKey == conf.currentSessionKey())
438 m_mdi->closeAllSubWindows();
441 conf.setCurrentSession(profileKey);
450 setUpdatesEnabled(
false);
453 m_mdi->closeAllSubWindows();
457 auto const mwConf = sessionConf.
group(QStringLiteral(
"MainWindow"));
458 restoreGeometry(mwConf.value<QByteArray>(QStringLiteral(
"geometry")));
459 restoreState(mwConf.value<QByteArray>(QStringLiteral(
"state")));
466 auto const guiConf = sessionConf.group(QStringLiteral(
"GUI"));
468 setQActionCheckedNoTrigger(
470 guiConf.value<
bool>(QStringLiteral(
"showTextWindowHeaders"),
472 setQActionCheckedNoTrigger(
474 guiConf.value<
bool>(QStringLiteral(
"showMainToolbar"),
true));
475 setQActionCheckedNoTrigger(
477 guiConf.value<
bool>(QStringLiteral(
"showTextWindowNavigator"),
479 setQActionCheckedNoTrigger(
482 QStringLiteral(
"showTextWindowModuleSelectorButtons"),
484 setQActionCheckedNoTrigger(
486 guiConf.value<
bool>(QStringLiteral(
"showTextWindowToolButtons"),
488 setQActionCheckedNoTrigger(
490 guiConf.value<
bool>(QStringLiteral(
"showToolbarsInEachWindow"),
495 mwConf.value<
int>(QStringLiteral(
"MDIArrangementMode"),
499 sessionConf.value<
bool>(QStringLiteral(
"FindIsVisible"),
502 QWidget * focusWindow =
nullptr;
503 struct WindowLoadStatus {
504 QStringList failedModules;
505 QList<CSwordModuleInfo *> okModules;
507 QMap<QString, WindowLoadStatus> failedWindows;
509 : sessionConf.value<QStringList>(QStringLiteral(
"windowsList")))
512 auto const windowConf =
513 sessionConf.group(QStringLiteral(
"window/") + w);
516 WindowLoadStatus wls;
517 for (
auto const & moduleName
518 : windowConf.value<QStringList>(QStringLiteral(
"modules")))
523 wls.okModules.append(m);
525 wls.failedModules.append(moduleName);
530 if (wls.okModules.isEmpty()) {
531 failedWindows.insert(w, wls);
536 if (!wls.failedModules.isEmpty())
537 failedWindows.insert(w, wls);
540 auto const key = windowConf.value<QString>(QStringLiteral(
"key"));
542 window->applyProfileSettings(windowConf);
543 if (windowConf.value<
bool>(QStringLiteral(
"hasFocus"),
false))
544 focusWindow = window;
546 failedWindows.insert(w, wls);
560 focusWindow->setFocus();
563 setUpdatesEnabled(
true);
572 QVariant keyProperty = action->property(
"ProfileKey");
573 BT_ASSERT(keyProperty.typeId() == QMetaType::QString);
582 setWindowState(windowState() ^ Qt::WindowFullScreen);
586template <
bool goingUp>
590 static constexpr int const intervals[21] = {
591 1, 2, 3, 5, 9, 15, 25, 43, 72, 120, 200,
592 120, 72, 43, 25, 15, 9, 5, 3, 2, 1
595 static constexpr int const nudgeSpeed = goingUp ? 1 : -1;
616template void BibleTime::autoScroll<true>();
617template void BibleTime::autoScroll<false>();
647 display->updateReferenceText();
659 name = QInputDialog::getText(
660 this, tr(
"New Session"),
661 tr(
"Please enter a name for the new session."),
662 QLineEdit::Normal, name, &ok);
666 if (!name.isEmpty()) {
670 tr(
"Session with the name \"%1\" "
671 "already exists. Please provide a "
672 "different name.").arg(name));
698 const bool enableActions = sessions.size() > 1;
704 for (
auto it = sessions.constBegin(); it != sessions.constEnd(); ++it) {
708 a->setProperty(
"ProfileKey", it.key());
710 a->setCheckable(
true);
715 a->setProperty(
"ProfileKey", it.key());
717 a->setDisabled(
true);
728 Qt::DirectConnection);
BtConfig & btConfig()
This is a shortchand for BtConfig::getInstance().
QList< CSwordModuleInfo const * > BtConstModuleList
QAction * pauseAutoScroll
QAction * autoTileVertically
QAction * showToolsToolbar
QAction * showWorksToolbar
QAction * showMainToolbar
QAction * closeAllWindows
QAction * autoTileHorizontally
struct BibleTime::ActionCollection::@4 windows
QAction * showParallelTextHeadings
struct BibleTime::ActionCollection::@2 view
struct BibleTime::ActionCollection::@2::@7 scroll
struct BibleTime::ActionCollection::@2::@6 toolbars
struct BibleTime::ActionCollection::@4::@8 arrangementMode
QAction * tileHorizontally
QAction * showNavigationToolbar
QAction * showToolbarsInTextWindows
void loadProfile(QAction *action)
QPointer< QWidget > m_debugWindow
BtModuleChooserBar * m_worksToolBar
void slotBookshelfWizard()
void slotShowDebugWindow(bool)
QAction * m_debugWidgetAction
void slotActiveWindowChanged(QMdiSubWindow *window)
ActionCollection * m_actions
void deleteProfile(QAction *action)
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()
void slotToggleTextWindowHeader()
void showOrHideToolBars()
void toggledTextWindowNavigator(bool newState)
void slotOpenWindowsMenuAboutToShow()
void openOnlineHelp_Handbook()
QMenu * m_windowDeleteProfileMenu
void refreshProfileMenus()
void slotToggleToolsToolbar()
QToolBar * m_toolsToolBar
void slotToggleToolBarsInEachWindow()
void toggledTextWindowModuleChooser(bool newState)
BtFindWidget * m_findWidget
BtModelViewReadDisplay * getCurrentDisplay()
void openOnlineHelp_Howto()
void slotWindowMenuAboutToShow()
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
void slotToggleNavigatorToolbar()
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
QString addSession(const QString &name)
Creates a new session with the given name.
QString const & currentSessionKey() const
void setCurrentSession(const QString &key)
Notifies the configuration system that the session settings should be read from and saved to the give...
QHash< QString, QString > sessionNames() 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
CSwordModuleInfo * findModuleByName(const QString &name) const
Searches for a module with the given name.
static CSwordBackend & instance() noexcept
void setBooknameLanguage(QString const &langName)
Sets the language for the international booknames of Sword.
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)