20 #include <QApplication>
21 #include <QCloseEvent>
23 #include <QInputDialog>
25 #include <QMdiSubWindow>
26 #include <QSplashScreen>
28 #include <type_traits>
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);
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());
149 qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
152 switch (modules.first()->type()) {
166 qFatal(
"unknown module type");
170 displayWindow->show();
175 qApp->processEvents();
176 qApp->restoreOverrideCursor();
177 return displayWindow;
194 tr(
"Enter the unlock key for %1.").arg(module->
name()),
200 while (unlockKeyInputDialog.exec() == QDialog::Accepted) {
209 auto const moduleName(module->
name());
212 module =
backend.findModuleByName(moduleName);
222 tr(
"Warning: Invalid unlock key!"),
223 tr(
"The unlock key you provided did not properly unlock "
224 "this module. Please try again."));
235 dialog->setAttribute(Qt::WA_DeleteOnClose);
242 for (
auto const *
const subWindow :
m_mdi->subWindowList())
249 QString
const & bibleKey)
251 if (
btConfig().value<bool>(QStringLiteral(
"state/crashedTwoTimes"),
false))
258 if (
btConfig().value<bool>(QStringLiteral(
"state/crashedLastTime"),
false))
261 if (!bibleKey.isNull()) {
264 QStringLiteral(
"standardBible"));
265 if (bibleKey == QStringLiteral(
"random")) {
267 auto const newIndex =
randInt<decltype(vk.
index())>(0, 31100);
282 if (
btConfig().value<bool>(QStringLiteral(
"state/crashedLastTime"),
false)){
294 if (
event->type() == QEvent::PaletteChange) {
297 }
else if (
event->type() == QEvent::KeyPress) {
298 if (
static_cast<QKeyEvent *
>(
event)->modifiers() > 0)
303 return QMainWindow::event(
event);
307 if (
auto *
const activeSubWindow =
m_mdi->activeSubWindow())
308 if (
auto *
const displayWindow =
310 return displayWindow->firstModule();
315 if (
auto *
const activeSubWindow =
m_mdi->activeSubWindow())
316 if (
auto *
const displayWindow =
318 return displayWindow->displayWidget();
324 display->setDisplayFocus();
328 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.
void lookupKey(QString const &key)
The class used to display lexicons.
QMdiSubWindow * addDisplayWindow(CDisplayWindow *displayWindow)
static CSwordBackend & instance() noexcept
QString config(const CSwordModuleInfo::ConfigEntry entry) const
bool unlock(const QString &unlockKey)
QString const & name() const
CSwordKey implementation for Sword's VerseKey.
QString key() const final override
std::unique_ptr< CSwordBackend > backend(sword::InstallSource const &is)
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)
const QDir & getPicsDir()