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));
320 if (
auto const *
const window =
m_mdi->activeSubWindow()) {
322 auto & widget = *
static_cast<CDisplayWindow const *
>(window->widget());
333 for (
auto const *
const subWindow :
m_mdi->subWindowList()) {
344 if (window ==
nullptr)
354 if (
auto const *
const bible =
355 btConfig().getDefaultSwordModuleByType(
356 QStringLiteral(
"standardBible")))
357 module.append(bible);
366 tr(
"Error locating handbook!"),
367 tr(
"A suitable installed handbook could not be found!"));
370 if (!QDesktopServices::openUrl(QUrl::fromLocalFile(url)))
373 tr(
"Error opening handbook!"),
374 tr(
"The installed handbook could not be opened!"));
382 tr(
"Error locating howto!"),
383 tr(
"A suitable installed howto could not be found!"));
386 if (!QDesktopServices::openUrl(QUrl::fromLocalFile(url)))
389 tr(
"Error opening howto!"),
390 tr(
"The installed howto could not be opened!"));
406 conf.
setValue(QStringLiteral(
"MainWindow/geometry"), saveGeometry());
407 conf.setValue(QStringLiteral(
"MainWindow/state"), saveState());
408 conf.setValue(QStringLiteral(
"MainWindow/MDIArrangementMode"),
411 conf.setValue(QStringLiteral(
"FindIsVisible"),
414 QStringList windowsList;
415 for (
auto const *
const w :
m_mdi->subWindowList(QMdiArea::StackingOrder)) {
420 const QString windowKey = QString::number(windowsList.size());
421 windowsList.append(windowKey);
422 auto windowConf = conf.group(QStringLiteral(
"window/") + windowKey);
425 conf.setValue(QStringLiteral(
"windowsList"), windowsList);
430 QVariant keyProperty = action->property(
"ProfileKey");
431 BT_ASSERT(keyProperty.typeId() == QMetaType::QString);
438 BT_ASSERT(conf.sessionNames().contains(profileKey));
441 if (profileKey == conf.currentSessionKey())
448 m_mdi->closeAllSubWindows();
451 conf.setCurrentSession(profileKey);
460 setUpdatesEnabled(
false);
463 m_mdi->closeAllSubWindows();
467 auto const mwConf = sessionConf.
group(QStringLiteral(
"MainWindow"));
468 restoreGeometry(mwConf.value<QByteArray>(QStringLiteral(
"geometry")));
469 restoreState(mwConf.value<QByteArray>(QStringLiteral(
"state")));
476 auto const guiConf = sessionConf.group(QStringLiteral(
"GUI"));
478 setQActionCheckedNoTrigger(
480 guiConf.value<
bool>(QStringLiteral(
"showTextWindowHeaders"),
482 setQActionCheckedNoTrigger(
484 guiConf.value<
bool>(QStringLiteral(
"showMainToolbar"),
true));
485 setQActionCheckedNoTrigger(
487 guiConf.value<
bool>(QStringLiteral(
"showTextWindowNavigator"),
489 setQActionCheckedNoTrigger(
492 QStringLiteral(
"showTextWindowModuleSelectorButtons"),
494 setQActionCheckedNoTrigger(
496 guiConf.value<
bool>(QStringLiteral(
"showTextWindowToolButtons"),
498 setQActionCheckedNoTrigger(
500 guiConf.value<
bool>(QStringLiteral(
"showToolbarsInEachWindow"),
505 mwConf.value<
int>(QStringLiteral(
"MDIArrangementMode"),
509 sessionConf.value<
bool>(QStringLiteral(
"FindIsVisible"),
512 QWidget * focusWindow =
nullptr;
513 struct WindowLoadStatus {
514 QStringList failedModules;
515 QList<CSwordModuleInfo *> okModules;
517 QMap<QString, WindowLoadStatus> failedWindows;
519 : sessionConf.value<QStringList>(QStringLiteral(
"windowsList")))
522 auto const windowConf =
523 sessionConf.group(QStringLiteral(
"window/") + w);
526 WindowLoadStatus wls;
527 for (
auto const & moduleName
528 : windowConf.value<QStringList>(QStringLiteral(
"modules")))
533 wls.okModules.append(m);
535 wls.failedModules.append(moduleName);
540 if (wls.okModules.isEmpty()) {
541 failedWindows.insert(w, wls);
546 if (!wls.failedModules.isEmpty())
547 failedWindows.insert(w, wls);
550 auto const key = windowConf.value<QString>(QStringLiteral(
"key"));
552 window->applyProfileSettings(windowConf);
553 if (windowConf.value<
bool>(QStringLiteral(
"hasFocus"),
false))
554 focusWindow = window;
556 failedWindows.insert(w, wls);
570 focusWindow->setFocus();
573 setUpdatesEnabled(
true);
582 QVariant keyProperty = action->property(
"ProfileKey");
583 BT_ASSERT(keyProperty.typeId() == QMetaType::QString);
592 setWindowState(windowState() ^ Qt::WindowFullScreen);
596template <
bool goingUp>
600 static constexpr int const intervals[21] = {
601 1, 2, 3, 5, 9, 15, 25, 43, 72, 120, 200,
602 120, 72, 43, 25, 15, 9, 5, 3, 2, 1
605 static constexpr int const nudgeSpeed = goingUp ? 1 : -1;
626template void BibleTime::autoScroll<true>();
627template void BibleTime::autoScroll<false>();
657 display->updateReferenceText();
669 name = QInputDialog::getText(
670 this, tr(
"New Session"),
671 tr(
"Please enter a name for the new session."),
672 QLineEdit::Normal, name, &ok);
676 if (!name.isEmpty()) {
680 tr(
"Session with the name \"%1\" "
681 "already exists. Please provide a "
682 "different name.").arg(name));
708 const bool enableActions = sessions.size() > 1;
714 for (
auto it = sessions.constBegin(); it != sessions.constEnd(); ++it) {
718 a->setProperty(
"ProfileKey", it.key());
720 a->setCheckable(
true);
725 a->setProperty(
"ProfileKey", it.key());
727 a->setDisabled(
true);
738 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 slotSearchActiveWindow()
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)