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"));
83 const int numSubWindows =
m_mdi->subWindowList().count();
88 const bool enableManualArrangeActions = numSubWindows > 1;
102 openWindowAction->setCheckable(
true);
103 openWindowAction->setChecked(window ==
m_mdi->activeSubWindow());
104 BT_CONNECT(openWindowAction, &QAction::triggered,
124 guiConfig.setValue(QStringLiteral(
"alignmentMode"),
autoTile);
128 guiConfig.setValue(QStringLiteral(
"alignmentMode"),
autoTabbed);
132 guiConfig.setValue(QStringLiteral(
"alignmentMode"),
autoCascade);
146 guiConfig.setValue(QStringLiteral(
"alignmentMode"),
manual);
179 bool const currentState =
180 guiConf.
value<
bool>(QStringLiteral(
"showMainToolbar"),
true);
181 guiConf.setValue(QStringLiteral(
"showMainToolbar"), !currentState);
192 bool const currentState =
193 guiConfig.
value<
bool>(QStringLiteral(
"showTextWindowHeaders"),
195 guiConfig.setValue(QStringLiteral(
"showTextWindowHeaders"), !currentState);
201 bool const currentState =
202 guiConfig.
value<
bool>(QStringLiteral(
"showTextWindowNavigator"),
204 guiConfig.setValue(QStringLiteral(
"showTextWindowNavigator"),
206 if (guiConfig.value<
bool>(QStringLiteral(
"showToolbarsInEachWindow"),
true))
211 guiConfig.value<
bool>(
212 QStringLiteral(
"showTextWindowNavigator"),
219 bool const currentState =
220 guiConfig.
value<
bool>(QStringLiteral(
"showTextWindowToolButtons"),
222 guiConfig.setValue(QStringLiteral(
"showTextWindowToolButtons"),
224 if (guiConfig.value<
bool>(QStringLiteral(
"showToolbarsInEachWindow"),
true))
229 guiConfig.value<
bool>(
230 QStringLiteral(
"showTextWindowToolButtons"),
237 bool const currentState =
238 guiConfig.
value<
bool>(
239 QStringLiteral(
"showTextWindowModuleSelectorButtons"),
241 guiConfig.setValue(QStringLiteral(
"showTextWindowModuleSelectorButtons"),
243 if (guiConfig.value<
bool>(QStringLiteral(
"showToolbarsInEachWindow"),
true))
248 guiConfig.value<
bool>(
249 QStringLiteral(
"showTextWindowModuleSelectorButtons"),
256 bool const currentState =
257 guiConfig.
value<
bool>(QStringLiteral(
"showToolbarsInEachWindow"),
259 guiConfig.setValue(QStringLiteral(
"showToolbarsInEachWindow"),
266 if (guiConfig.value<
bool>(QStringLiteral(
"showToolbarsInEachWindow"),
true))
274 guiConfig.value<
bool>(
275 QStringLiteral(
"showTextWindowNavigator"),
278 guiConfig.value<
bool>(
279 QStringLiteral(
"showTextWindowModuleSelectorButtons"),
282 guiConfig.value<
bool>(
283 QStringLiteral(
"showTextWindowToolButtons"),
288 guiConfig.value<
bool>(
289 QStringLiteral(
"showTextWindowNavigator"),
292 guiConfig.value<
bool>(
293 QStringLiteral(
"showTextWindowModuleSelectorButtons"),
296 guiConfig.value<
bool>(
297 QStringLiteral(
"showTextWindowToolButtons"),
310 m_mdi->setActiveSubWindow(
dynamic_cast<QMdiSubWindow*
>(window));
314 if (
auto const *
const window =
m_mdi->activeSubWindow()) {
316 auto & widget = *
static_cast<CDisplayWindow const *
>(window->widget());
327 for (
auto const *
const subWindow :
m_mdi->subWindowList()) {
338 if (window ==
nullptr)
348 if (
auto const *
const bible =
349 btConfig().getDefaultSwordModuleByType(
350 QStringLiteral(
"standardBible")))
351 module.append(bible);
360 tr(
"Error locating handbook!"),
361 tr(
"A suitable installed handbook could not be found!"));
364 if (!QDesktopServices::openUrl(QUrl::fromLocalFile(url)))
367 tr(
"Error opening handbook!"),
368 tr(
"The installed handbook could not be opened!"));
376 tr(
"Error locating howto!"),
377 tr(
"A suitable installed howto could not be found!"));
380 if (!QDesktopServices::openUrl(QUrl::fromLocalFile(url)))
383 tr(
"Error opening howto!"),
384 tr(
"The installed howto could not be opened!"));
400 conf.
setValue(QStringLiteral(
"MainWindow/geometry"), saveGeometry());
401 conf.setValue(QStringLiteral(
"MainWindow/state"), saveState());
402 conf.setValue(QStringLiteral(
"MainWindow/MDIArrangementMode"),
405 conf.setValue(QStringLiteral(
"FindIsVisible"),
408 QStringList windowsList;
409 for (
auto const *
const w :
m_mdi->subWindowList(QMdiArea::StackingOrder)) {
414 const QString windowKey = QString::number(windowsList.size());
415 windowsList.append(windowKey);
416 auto windowConf = conf.group(QStringLiteral(
"window/") + windowKey);
419 conf.setValue(QStringLiteral(
"windowsList"), windowsList);
424 QVariant keyProperty = action->property(
"ProfileKey");
425 BT_ASSERT(keyProperty.typeId() == QMetaType::QString);
432 BT_ASSERT(conf.sessionNames().contains(profileKey));
435 if (profileKey == conf.currentSessionKey())
442 m_mdi->closeAllSubWindows();
445 conf.setCurrentSession(profileKey);
454 setUpdatesEnabled(
false);
457 m_mdi->closeAllSubWindows();
461 auto const mwConf = sessionConf.
group(QStringLiteral(
"MainWindow"));
462 restoreGeometry(mwConf.value<QByteArray>(QStringLiteral(
"geometry")));
463 restoreState(mwConf.value<QByteArray>(QStringLiteral(
"state")));
470 auto const guiConf = sessionConf.group(QStringLiteral(
"GUI"));
472 setQActionCheckedNoTrigger(
474 guiConf.value<
bool>(QStringLiteral(
"showTextWindowHeaders"),
476 setQActionCheckedNoTrigger(
478 guiConf.value<
bool>(QStringLiteral(
"showMainToolbar"),
true));
479 setQActionCheckedNoTrigger(
481 guiConf.value<
bool>(QStringLiteral(
"showTextWindowNavigator"),
483 setQActionCheckedNoTrigger(
486 QStringLiteral(
"showTextWindowModuleSelectorButtons"),
488 setQActionCheckedNoTrigger(
490 guiConf.value<
bool>(QStringLiteral(
"showTextWindowToolButtons"),
492 setQActionCheckedNoTrigger(
494 guiConf.value<
bool>(QStringLiteral(
"showToolbarsInEachWindow"),
499 mwConf.value<
int>(QStringLiteral(
"MDIArrangementMode"),
503 sessionConf.value<
bool>(QStringLiteral(
"FindIsVisible"),
506 QWidget * focusWindow =
nullptr;
507 struct WindowLoadStatus {
508 QStringList failedModules;
509 QList<CSwordModuleInfo *> okModules;
511 QMap<QString, WindowLoadStatus> failedWindows;
513 : sessionConf.value<QStringList>(QStringLiteral(
"windowsList")))
516 auto const windowConf =
517 sessionConf.group(QStringLiteral(
"window/") + w);
520 WindowLoadStatus wls;
521 for (
auto const & moduleName
522 : windowConf.value<QStringList>(QStringLiteral(
"modules")))
527 wls.okModules.append(m);
529 wls.failedModules.append(moduleName);
534 if (wls.okModules.isEmpty()) {
535 failedWindows.insert(w, wls);
540 if (!wls.failedModules.isEmpty())
541 failedWindows.insert(w, wls);
544 auto const key = windowConf.value<QString>(QStringLiteral(
"key"));
546 window->applyProfileSettings(windowConf);
547 if (windowConf.value<
bool>(QStringLiteral(
"hasFocus"),
false))
548 focusWindow = window;
550 failedWindows.insert(w, wls);
564 focusWindow->setFocus();
567 setUpdatesEnabled(
true);
576 QVariant keyProperty = action->property(
"ProfileKey");
577 BT_ASSERT(keyProperty.typeId() == QMetaType::QString);
586 setWindowState(windowState() ^ Qt::WindowFullScreen);
590template <
bool goingUp>
594 static constexpr int const intervals[21] = {
595 1, 2, 3, 5, 9, 15, 25, 43, 72, 120, 200,
596 120, 72, 43, 25, 15, 9, 5, 3, 2, 1
599 static constexpr int const nudgeSpeed = goingUp ? 1 : -1;
620template void BibleTime::autoScroll<true>();
621template void BibleTime::autoScroll<false>();
651 display->updateReferenceText();
663 name = QInputDialog::getText(
664 this, tr(
"New Session"),
665 tr(
"Please enter a name for the new session."),
666 QLineEdit::Normal, name, &ok);
670 if (!name.isEmpty()) {
674 tr(
"Session with the name \"%1\" "
675 "already exists. Please provide a "
676 "different name.").arg(name));
702 const bool enableActions = sessions.size() > 1;
708 for (
auto it = sessions.constBegin(); it != sessions.constEnd(); ++it) {
712 a->setProperty(
"ProfileKey", it.key());
714 a->setCheckable(
true);
719 a->setProperty(
"ProfileKey", it.key());
721 a->setDisabled(
true);
732 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)