87 lines
2.8 KiB
C++
87 lines
2.8 KiB
C++
/*******************************************************************************
|
|
#
|
|
# Copyright (C) 2010-2013 Matteo Paonessa <matteo.paonessa@gmail.com>
|
|
# 2021 Gary Wang <wzc782970009@gmail.com>
|
|
#
|
|
# This file is part of the Caesium distribution.
|
|
#
|
|
# Caesium is free software; you can redistribute it and/or
|
|
# modify it under the terms of the GNU General Public License
|
|
# as published by the Free Software Foundation; either version 2
|
|
# of the License, or (at your option) any later version.
|
|
#
|
|
# Caesium is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with Caesium; if not, write to the Free Software
|
|
# Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
|
|
#
|
|
# Author: Matteo Paonessa <matteo.paonessa@gmail.com>
|
|
# Gary Wang <wzc782970009@gmail.com>
|
|
#
|
|
# ******************************************************************************/
|
|
|
|
#include <QApplication>
|
|
#include <QSplashScreen>
|
|
#include <QString>
|
|
#include "caesium.h"
|
|
#include "global.h"
|
|
#include <QDebug>
|
|
#include <QTextStream>
|
|
#include <QDir>
|
|
#include <QTranslator>
|
|
#include <QBitmap>
|
|
|
|
// QM_FILE_INSTALL_DIR should be defined from the CMakeLists file.
|
|
#ifndef QM_FILE_INSTALL_DIR
|
|
#define QM_FILE_INSTALL_DIR ":/i18n/"
|
|
#endif // QM_FILE_INSTALL_DIR
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
QApplication a(argc, argv);
|
|
Q_INIT_RESOURCE(icons);
|
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
settings.setIniCodec("UTF-8");
|
|
#endif // QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
|
|
a.setApplicationDisplayName(QCoreApplication::translate("main", "Caesium - Image Compressor"));
|
|
a.addLibraryPath(a.applicationDirPath() + "/lib/");
|
|
|
|
QString locale = settings.value("Preferences/language").value<QString>();
|
|
|
|
QString qmDir;
|
|
#ifdef _WIN32
|
|
qmDir = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath("translations");
|
|
#else
|
|
qmDir = QT_STRINGIFY(QM_FILE_INSTALL_DIR);
|
|
#endif
|
|
|
|
QTranslator translator;
|
|
if(locale.isEmpty()) {
|
|
if (translator.load(QString("caesium_%1").arg(QLocale::system().name()), qmDir)) {
|
|
a.installTranslator(&translator);
|
|
}
|
|
} else {
|
|
if (translator.load(QString("caesium_%1").arg(locale), qmDir)) {
|
|
a.installTranslator(&translator);
|
|
}
|
|
}
|
|
|
|
QPixmap pixmap(":icons/splash.png");
|
|
QSplashScreen splash(pixmap, Qt::WindowStaysOnTopHint);
|
|
splash.setMask(pixmap.mask());
|
|
splash.show();
|
|
|
|
|
|
Caesium w;
|
|
QTimer::singleShot(400, &splash, SLOT(close()));
|
|
QTimer::singleShot(400, &w, SLOT(show()));
|
|
|
|
return a.exec();
|
|
}
|