Merge pull request #400 from kiwix/fix_translation

Don't use `gt` in the contructor.
This commit is contained in:
Matthieu Gautier 2020-04-08 11:52:16 +02:00 committed by GitHub
commit 638d3816a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 24 deletions

View File

@ -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;

View File

@ -63,6 +63,7 @@ public:
KiwixApp(int& argc, char *argv[]);
virtual ~KiwixApp();
static KiwixApp* instance();
void init();
void openRandomUrl(bool newTab=true);

View File

@ -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");