20#include <QApplication>
23#include <QInputDialog>
25#include <QMdiSubWindow>
26#include <QSplashScreen>
29#include "../backend/config/btconfig.h"
30#include "../backend/drivers/cswordmoduleinfo.h"
31#include "../backend/keys/cswordversekey.h"
32#include "../backend/managers/cswordbackend.h"
33#include "../util/btassert.h"
34#include "../util/cresmgr.h"
35#include "../util/directory.h"
56 -> std::enable_if_t<std::is_integral_v<std::decay_t<T>>,
T>
58 static std::mt19937 rng((std::random_device()()));
59 return std::uniform_int_distribution<std::decay_t<T>>(min, max)(rng);
63 QStringLiteral(
"startuplogo.png"),
64 QStringLiteral(
"startuplogo_christmas.png"),
65 QStringLiteral(
"startuplogo_easter.jpg"),
70 "<div style='background:transparent;color:white;font-weight:bold'>"
85 QSplashScreen * splash =
nullptr;
86 constexpr static auto const splashTextAlignment =
87 Qt::AlignHCenter | Qt::AlignTop;
89 if (
btConfig().value<bool>(QStringLiteral(
"GUI/showSplashScreen"),
true)) {
90 auto const splashNumber =
91 randInt<std::size_t>(0u,
92 std::extent_v<
decltype(splashes)> - 1u);
94 if (pm.load(DU::getPicsDir().filePath(splashes[splashNumber]))) {
95 splash =
new QSplashScreen(pm);
97 splashHtml.arg(tr(
"Initializing the SWORD engine...")),
100 qApp->processEvents();
102 qWarning(
"Can't load startuplogo! Check your installation.");
110 tr(
"Creating BibleTime's user interface...")),
111 splashTextAlignment);
112 qApp->processEvents();
118 splashHtml.arg(tr(
"Initializing menu- and toolbars...")),
119 splashTextAlignment);
120 qApp->processEvents();
121 splash->setAttribute(Qt::WA_DeleteOnClose);
122 splash->finish(
this);
129 setWindowTitle(QStringLiteral(
"BibleTime " BT_VERSION));
130 setWindowIcon(CResMgr::mainWindow::icon());
146 QList<CSwordModuleInfo *> modules,
149 qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
152 switch (modules.first()->type()) {
166 qFatal(
"unknown module type");
170 displayWindow->show();
174 qApp->processEvents();
175 qApp->restoreOverrideCursor();
176 return displayWindow;
193 tr(
"Enter the unlock key for %1.").arg(module->
name()),
199 while (unlockKeyInputDialog.exec() == QDialog::Accepted) {
200 module->unlock(unlockKeyInputDialog.getUserInput());
208 auto const moduleName(module->
name());
210 backend.reloadModules();
211 module = backend.findModuleByName(moduleName);
221 tr(
"Warning: Invalid unlock key!"),
222 tr(
"The unlock key you provided did not properly unlock "
223 "this module. Please try again."));
234 dialog->setAttribute(Qt::WA_DeleteOnClose);
241 for (
auto const *
const subWindow :
m_mdi->subWindowList())
248 QString
const & bibleKey)
250 if (
btConfig().value<bool>(QStringLiteral(
"state/crashedTwoTimes"),
false))
257 if (
btConfig().value<bool>(QStringLiteral(
"state/crashedLastTime"),
false))
260 if (!bibleKey.isNull()) {
263 QStringLiteral(
"standardBible"));
264 if (bibleKey == QStringLiteral(
"random")) {
266 auto const newIndex = randInt<
decltype(vk.
index())>(0, 31100);
281 if (
btConfig().value<bool>(QStringLiteral(
"state/crashedLastTime"),
false)){
293 if (
event->type() == QEvent::PaletteChange) {
296 }
else if (
event->type() == QEvent::KeyPress) {
297 if (
static_cast<QKeyEvent *
>(
event)->modifiers() > 0)
302 return QMainWindow::event(
event);
306 if (
auto *
const activeSubWindow =
m_mdi->activeSubWindow())
307 if (
auto *
const displayWindow =
309 return displayWindow->firstModule();
314 if (
auto *
const activeSubWindow =
m_mdi->activeSubWindow())
315 if (
auto *
const displayWindow =
317 return displayWindow->displayWidget();
327 QString
const & searchText)
BtConfig & btConfig()
This is a shortchand for BtConfig::getInstance().
QList< CSwordModuleInfo const * > BtConstModuleList
QPointer< QWidget > m_debugWindow
void slotModuleUnlock(CSwordModuleInfo *module)
BtBookshelfDockWidget * m_bookshelfDock
static bool moduleUnlock(CSwordModuleInfo *module, QWidget *parent=nullptr)
void moduleAbout(CSwordModuleInfo *module)
bool event(QEvent *event) override
void openSearchDialog(BtConstModuleList modules, QString const &searchText={})
static BibleTime * m_instance
BtFindWidget * m_findWidget
QPointer< Search::CSearchDialog > m_searchDialog
CSwordModuleInfo const * getCurrentModule()
BtModelViewReadDisplay * getCurrentDisplay()
void processCommandline(bool ignoreSession, QString const &bibleKey)
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
BibleTime(BibleTimeApp &app, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags())
void sync()
Synchronizes the configuration to disk.
void setValue(QString const &key, T const &value)
Sets a value for a key.
CSwordModuleInfo * getDefaultSwordModuleByType(const QString &moduleType)
Returns default sword module info class for a given module type.
The base class for all display windows of BibleTime.
The class used to display lexicons.
QMdiSubWindow * addDisplayWindow(CDisplayWindow *displayWindow)
static CSwordBackend & instance() noexcept
QString config(const CSwordModuleInfo::ConfigEntry entry) const
QString const & name() const
CSwordKey implementation for Sword's VerseKey.
QString key() const final override
auto randInt(T min, T max) -> std::enable_if_t< std::is_integral_v< std::decay_t< T > >, T >
QMessageBox::StandardButton showWarning(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)