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));
317 for (
auto const *
const subWindow :
m_mdi->subWindowList()) {
328 if (window ==
nullptr)
338 if (
auto const *
const bible =
339 btConfig().getDefaultSwordModuleByType(
340 QStringLiteral(
"standardBible")))
341 module.append(bible);
350 tr(
"Error locating handbook!"),
351 tr(
"A suitable installed handbook could not be found!"));
354 if (!QDesktopServices::openUrl(QUrl::fromLocalFile(url)))
357 tr(
"Error opening handbook!"),
358 tr(
"The installed handbook could not be opened!"));
366 tr(
"Error locating howto!"),
367 tr(
"A suitable installed howto could not be found!"));
370 if (!QDesktopServices::openUrl(QUrl::fromLocalFile(url)))
373 tr(
"Error opening howto!"),
374 tr(
"The installed howto could not be opened!"));
390 conf.
setValue(QStringLiteral(
"MainWindow/geometry"), saveGeometry());
391 conf.setValue(QStringLiteral(
"MainWindow/state"), saveState());
392 conf.setValue(QStringLiteral(
"MainWindow/MDIArrangementMode"),
395 conf.setValue(QStringLiteral(
"FindIsVisible"),
398 QStringList windowsList;
399 for (
auto const *
const w :
m_mdi->subWindowList(QMdiArea::StackingOrder)) {
404 const QString windowKey = QString::number(windowsList.size());
405 windowsList.append(windowKey);
406 auto windowConf = conf.group(QStringLiteral(
"window/") + windowKey);
409 conf.setValue(QStringLiteral(
"windowsList"), windowsList);
414 QVariant keyProperty = action->property(
"ProfileKey");
415 BT_ASSERT(keyProperty.typeId() == QMetaType::QString);
422 BT_ASSERT(conf.sessionNames().contains(profileKey));
425 if (profileKey == conf.currentSessionKey())
432 m_mdi->closeAllSubWindows();
435 conf.setCurrentSession(profileKey);
444 setUpdatesEnabled(
false);
447 m_mdi->closeAllSubWindows();
451 auto const mwConf = sessionConf.
group(QStringLiteral(
"MainWindow"));
452 restoreGeometry(mwConf.value<QByteArray>(QStringLiteral(
"geometry")));
453 restoreState(mwConf.value<QByteArray>(QStringLiteral(
"state")));
460 auto const guiConf = sessionConf.group(QStringLiteral(
"GUI"));
462 setQActionCheckedNoTrigger(
464 guiConf.value<
bool>(QStringLiteral(
"showTextWindowHeaders"),
466 setQActionCheckedNoTrigger(
468 guiConf.value<
bool>(QStringLiteral(
"showMainToolbar"),
true));
469 setQActionCheckedNoTrigger(
471 guiConf.value<
bool>(QStringLiteral(
"showTextWindowNavigator"),
473 setQActionCheckedNoTrigger(
476 QStringLiteral(
"showTextWindowModuleSelectorButtons"),
478 setQActionCheckedNoTrigger(
480 guiConf.value<
bool>(QStringLiteral(
"showTextWindowToolButtons"),
482 setQActionCheckedNoTrigger(
484 guiConf.value<
bool>(QStringLiteral(
"showToolbarsInEachWindow"),
489 mwConf.value<
int>(QStringLiteral(
"MDIArrangementMode"),
493 sessionConf.value<
bool>(QStringLiteral(
"FindIsVisible"),
496 QWidget * focusWindow =
nullptr;
497 struct WindowLoadStatus {
498 QStringList failedModules;
499 QList<CSwordModuleInfo *> okModules;
501 QMap<QString, WindowLoadStatus> failedWindows;
503 : sessionConf.value<QStringList>(QStringLiteral(
"windowsList")))
506 auto const windowConf =
507 sessionConf.group(QStringLiteral(
"window/") + w);
510 WindowLoadStatus wls;
511 for (
auto const & moduleName
512 : windowConf.value<QStringList>(QStringLiteral(
"modules")))
517 wls.okModules.append(m);
519 wls.failedModules.append(moduleName);
524 if (wls.okModules.isEmpty()) {
525 failedWindows.insert(w, wls);
530 if (!wls.failedModules.isEmpty())
531 failedWindows.insert(w, wls);
534 auto const key = windowConf.value<QString>(QStringLiteral(
"key"));
536 window->applyProfileSettings(windowConf);
537 if (windowConf.value<
bool>(QStringLiteral(
"hasFocus"),
false))
538 focusWindow = window;
540 failedWindows.insert(w, wls);
554 focusWindow->setFocus();
557 setUpdatesEnabled(
true);
566 QVariant keyProperty = action->property(
"ProfileKey");
567 BT_ASSERT(keyProperty.typeId() == QMetaType::QString);
576 setWindowState(windowState() ^ Qt::WindowFullScreen);
580template <
bool goingUp>
584 static constexpr int const intervals[21] = {
585 1, 2, 3, 5, 9, 15, 25, 43, 72, 120, 200,
586 120, 72, 43, 25, 15, 9, 5, 3, 2, 1
589 static constexpr int const nudgeSpeed = goingUp ? 1 : -1;
610template void BibleTime::autoScroll<true>();
611template void BibleTime::autoScroll<false>();
641 display->updateReferenceText();
653 name = QInputDialog::getText(
654 this, tr(
"New Session"),
655 tr(
"Please enter a name for the new session."),
656 QLineEdit::Normal, name, &ok);
660 if (!name.isEmpty()) {
664 tr(
"Session with the name \"%1\" "
665 "already exists. Please provide a "
666 "different name.").arg(name));
692 const bool enableActions = sessions.size() > 1;
698 for (
auto it = sessions.constBegin(); it != sessions.constEnd(); ++it) {
702 a->setProperty(
"ProfileKey", it.key());
704 a->setCheckable(
true);
709 a->setProperty(
"ProfileKey", it.key());
711 a->setDisabled(
true);
722 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)