mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-25 05:48:54 -04:00
Don't use gt function in the constructor of kiwixApp.
The `gt` function get the instance of the kiwixApp. So we cannot call this function in the constructor of kiwixApp itself. Move all the (complex) initialization step in another method call after the kiwixApp is created.
This commit is contained in:
parent
c8ed41dea5
commit
9f346f5f75
@ -37,30 +37,6 @@ KiwixApp::KiwixApp(int& argc, char *argv[])
|
||||
m_appTranslator.load(QLocale(), "kiwix-desktop", "_", ":/i18n/");
|
||||
installTranslator(&m_appTranslator);
|
||||
|
||||
try {
|
||||
mp_downloader = new kiwix::Downloader();
|
||||
} catch (exception& e) {
|
||||
QMessageBox::critical(nullptr, gt("error-downloader-window-title"),
|
||||
gt("error-downloader-launch-message") + "<br><br>" + e.what());
|
||||
}
|
||||
mp_manager = new ContentManager(&m_library, mp_downloader);
|
||||
|
||||
auto icon = QIcon();
|
||||
icon.addFile(":/icons/kiwix-app-icons-square.svg");
|
||||
setWindowIcon(icon);
|
||||
|
||||
setApplicationName("Kiwix");
|
||||
setDesktopFileName("kiwix.desktop");
|
||||
|
||||
setStyle(QStyleFactory::create("Windows"));
|
||||
QFile styleFile(":/css/style.css");
|
||||
styleFile.open(QIODevice::ReadOnly);
|
||||
auto byteContent = styleFile.readAll();
|
||||
styleFile.close();
|
||||
QString style(byteContent);
|
||||
setStyleSheet(style);
|
||||
|
||||
|
||||
QString fontName;
|
||||
if (platformName() == "windows") {
|
||||
QFontDatabase::addApplicationFont(":/fonts/SegoeUI/segoeuib.ttf");
|
||||
@ -88,6 +64,33 @@ KiwixApp::KiwixApp(int& argc, char *argv[])
|
||||
|
||||
auto font = QFont(fontName);
|
||||
setFont(font);
|
||||
}
|
||||
|
||||
void KiwixApp::init()
|
||||
{
|
||||
try {
|
||||
mp_downloader = new kiwix::Downloader();
|
||||
} catch (exception& e) {
|
||||
QMessageBox::critical(nullptr, gt("error-downloader-window-title"),
|
||||
gt("error-downloader-launch-message") + "<br><br>" + e.what());
|
||||
}
|
||||
mp_manager = new ContentManager(&m_library, mp_downloader);
|
||||
|
||||
auto icon = QIcon();
|
||||
icon.addFile(":/icons/kiwix-app-icons-square.svg");
|
||||
setWindowIcon(icon);
|
||||
|
||||
setApplicationName("Kiwix");
|
||||
setDesktopFileName("kiwix.desktop");
|
||||
|
||||
setStyle(QStyleFactory::create("Windows"));
|
||||
QFile styleFile(":/css/style.css");
|
||||
styleFile.open(QIODevice::ReadOnly);
|
||||
auto byteContent = styleFile.readAll();
|
||||
styleFile.close();
|
||||
QString style(byteContent);
|
||||
setStyleSheet(style);
|
||||
|
||||
|
||||
createAction();
|
||||
mp_mainWindow = new MainWindow;
|
||||
|
@ -63,6 +63,7 @@ public:
|
||||
KiwixApp(int& argc, char *argv[]);
|
||||
virtual ~KiwixApp();
|
||||
static KiwixApp* instance();
|
||||
void init();
|
||||
|
||||
void openRandomUrl(bool newTab=true);
|
||||
|
||||
|
@ -16,6 +16,7 @@ int main(int argc, char *argv[])
|
||||
QWebEngineUrlScheme::registerScheme(scheme);
|
||||
#endif
|
||||
KiwixApp a(argc, argv);
|
||||
a.init();
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.addPositionalArgument("zimfile", "The zim file");
|
||||
|
Loading…
x
Reference in New Issue
Block a user