15 #include <QLibraryInfo>
18 #include <QTranslator>
19 #include "../backend/bookshelfmodel/btbookshelftreemodel.h"
20 #include "../backend/config/btconfig.h"
21 #include "../backend/managers/cswordbackend.h"
22 #include "../util/directory.h"
44 std::cout << qPrintable(executable) << std::endl << std::endl
45 <<
" --help, -h" << std::endl <<
" "
46 << qPrintable(QObject::tr(
"Show this help message and exit"))
47 << std::endl << std::endl
48 <<
" --version, -V" << std::endl <<
" "
49 << qPrintable(QObject::tr(
"Output BibleTime version and exit"))
50 << std::endl << std::endl
51 <<
" --ignore-session" << std::endl <<
" "
52 << qPrintable(QObject::tr(
"Open a clean session"))
53 << std::endl << std::endl
54 <<
" --open-default-bible <ref>" << std::endl <<
" "
55 << qPrintable(QObject::tr(
"Open the default Bible with the "
57 << std::endl << std::endl
58 << qPrintable(QObject::tr(
"For command-line arguments parsed by the"
59 " Qt toolkit, see %1.")
60 .arg(
"http://doc.qt.nokia.com/latest/qapplication.html"))
79 QString & openBibleKey)
81 QStringList args = BibleTimeApp::arguments();
82 for (
int i = 1; i < args.size(); i++) {
83 const QString &arg = args.at(i);
84 if (arg == QStringLiteral(
"--help")
85 || arg == QStringLiteral(
"-h")
86 || arg == QStringLiteral(
"/?")
87 || arg == QStringLiteral(
"/h"))
91 }
else if (arg == QStringLiteral(
"--version")
92 || arg == QStringLiteral(
"-V")
93 || arg == QStringLiteral(
"/V"))
95 std::cout <<
"BibleTime " BT_VERSION << std::endl;
97 }
else if (arg == QStringLiteral(
"--debug")) {
98 showDebugMessages =
true;
99 }
else if (arg == QStringLiteral(
"--ignore-session")) {
100 ignoreSession =
true;
101 }
else if (arg == QStringLiteral(
"--open-default-bible")) {
103 if (i < args.size()) {
104 openBibleKey = args.at(i);
108 QObject::tr(
"Error: %1 expects an argument. See "
109 "--help for details.")
110 .arg(QStringLiteral(
"--open-default-bible")))
115 std::cerr << qPrintable(QObject::tr(
116 "Error: Invalid command-line argument: %1")
117 .arg(arg)) << std::endl;
129 qRegisterMetaType<FilterOptions>(
"FilterOptions");
130 qRegisterMetaType<DisplayOptions>(
"DisplayOptions");
131 qRegisterMetaType<alignmentMode>(
"alignmentMode");
132 qRegisterMetaType<CSwordModuleSearch::SearchType>(
"SearchType");
133 qRegisterMetaType<BtConfig::StringMap>(
"StringMap");
134 qRegisterMetaType<QList<int> >(
"QList<int>");
135 qRegisterMetaType<BtBookshelfTreeModel::Grouping>(
136 "BtBookshelfTreeModel::Grouping");
138 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
139 qRegisterMetaTypeStreamOperators<BtBookshelfTreeModel::Grouping>(
140 "BtBookshelfTreeModel::Grouping");
141 qRegisterMetaTypeStreamOperators<alignmentMode>(
"alignmentMode");
142 qRegisterMetaTypeStreamOperators<CSwordModuleSearch::SearchType>(
144 qRegisterMetaTypeStreamOperators<BtConfig::StringMap>(
"StringMap");
145 qRegisterMetaTypeStreamOperators<QList<int> >(
"QList<int>");
149 qmlRegisterSingletonType<BtQmlInterface>(
164 int main(
int argc,
char* argv[]) {
167 if (!sword::SWMgr::isICU) {
168 qFatal(
"SWORD library is required to be built against ICU!");
177 bool ignoreSession =
false;
178 QString openBibleKey;
180 bool showDebugMessages =
false;
184 return r < 0 ? EXIT_SUCCESS : EXIT_FAILURE;
189 qFatal(
"Error initializing directory cache!");
205 dir.setCurrent(homeSwordDir);
213 dir.setCurrent(homeSwordDir);
217 QLocale
const defaultLocale;
218 QTranslator qtTranslator;
219 if (qtTranslator.load(defaultLocale,
220 QStringLiteral(
"qt_"),
222 #
if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
223 QLibraryInfo::location(
227 QLibraryInfo::TranslationsPath)))
228 app.installTranslator(&qtTranslator);
230 QTranslator bibleTimeTranslator;
231 if (bibleTimeTranslator.load(
233 QStringLiteral(
"bibletime_ui_"),
236 app.installTranslator(&bibleTimeTranslator);
240 qFatal(
"Error initializing display template manager!");
246 auto *
const mainWindow =
new BibleTime(app);
247 mainWindow->setAttribute(Qt::WA_DeleteOnClose);
250 if (
btConfig().value<QString>(QStringLiteral(
"bibletimeVersion"),
251 BT_VERSION) != BT_VERSION)
254 QString(BT_VERSION));
255 mainWindow->saveConfigSettings();
260 mainWindow->slotBookshelfWizard();
265 mainWindow->processCommandline(ignoreSession, openBibleKey);
268 &&
btConfig().value<bool>(QStringLiteral(
"GUI/showTipAtStartup"),
true))
269 mainWindow->slotOpenTipDialog();
BtConfig & btConfig()
This is a shortchand for BtConfig::getInstance().
bool initDisplayTemplateManager()
void setDebugMode(bool const debugMode) noexcept
void initLightDarkPalette()
void setValue(QString const &key, T const &value)
Sets a value for a key.
QList< CSwordModuleInfo * > const & moduleList() const
static CSwordBackend & instance() noexcept
QStringList r(content.left(bodyIndex))
int main(int argc, char *argv[])
int parseCommandLine(bool &showDebugMessages, bool &ignoreSession, QString &openBibleKey)
void printHelp(const QString &executable)
const QDir & getLocaleDir()
const QDir & getUserHomeSwordDir()
const QDir & getUserHomeDir()
bool initDirectoryCache()
Initializes the directory cache and returns whether it was successful.