forked from MrBesen/lolautoaccept
use resource file for translation and icon
This commit is contained in:
parent
a6f391cc4b
commit
7789e7cfbb
|
@ -99,8 +99,8 @@ INCLUDEPATH += $$PWD/include/ \
|
|||
|
||||
LANGUAGES = de_DE en
|
||||
|
||||
TRANSLATIONS = $$prependAll(LANGUAGES, $$PWD/ts/, .ts)
|
||||
TRANSLATIONSQM = $$prependAll(LANGUAGES, $$PWD/ts/, .qm)
|
||||
TRANSLATIONS = $$prependAll(LANGUAGES, $$PWD/resources/ts/, .ts)
|
||||
TRANSLATIONSQM = $$prependAll(LANGUAGES, $$PWD/resources/ts/, .qm)
|
||||
|
||||
makelang.commands = lrelease $$_PRO_FILE_
|
||||
updatelang.commands = lupdate $$_PRO_FILE_
|
||||
|
@ -113,18 +113,18 @@ QMAKE_CLEAN += $$TRANSLATIONSQM
|
|||
unix {
|
||||
linuxdeploy-x86_64.AppImage.commands = wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage && chmod u+x linuxdeploy-x86_64.AppImage
|
||||
|
||||
lolautoaccept.png.depends = lolautoaccept.svg
|
||||
lolautoaccept.png.commands = rsvg-convert -w 512 -h 512 lolautoaccept.svg -o lolautoaccept.png
|
||||
lolautoaccept.png.depends = resources/lolautoaccept.svg
|
||||
lolautoaccept.png.commands = rsvg-convert -w 512 -h 512 resources/lolautoaccept.svg -o resources/lolautoaccept.png
|
||||
|
||||
appimg.depends = linuxdeploy-x86_64.AppImage $${TARGET} lolautoaccept.png
|
||||
appimg.depends = linuxdeploy-x86_64.AppImage $${TARGET} resources/lolautoaccept.png
|
||||
appimg.commands = rm -rf AppDir ; \
|
||||
mkdir -p AppDir/ts ; \
|
||||
cp ./ts/*.qm ./AppDir/ts ; \
|
||||
./linuxdeploy-x86_64.AppImage --appdir=AppDir -e lolautoaccept -i lolautoaccept.png -d lolautoaccept.desktop --output appimage
|
||||
cp ./resources/ts/*.qm ./AppDir/ts ; \
|
||||
./linuxdeploy-x86_64.AppImage --appdir=AppDir -e lolautoaccept -i resources/lolautoaccept.png -d resources/lolautoaccept.desktop --output appimage
|
||||
|
||||
QMAKE_EXTRA_TARGETS += appimg linuxdeploy-x86_64.AppImage lolautoaccept.png
|
||||
QMAKE_EXTRA_TARGETS += appimg linuxdeploy-x86_64.AppImage resources/lolautoaccept.png
|
||||
|
||||
QMAKE_CLEAN += linuxdeploy-x86_64.AppImage lolautoaccept.png
|
||||
QMAKE_CLEAN += linuxdeploy-x86_64.AppImage resources/lolautoaccept.png
|
||||
}
|
||||
|
||||
win32 {
|
||||
|
@ -139,3 +139,6 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
|
|||
|
||||
|
||||
# https://wiki.qt.io/Automating_generation_of_qm_files
|
||||
|
||||
RESOURCES += \
|
||||
resources/res.qrc
|
||||
|
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
@ -0,0 +1,8 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>ts/de_DE.qm</file>
|
||||
<file>ts/de_DE.ts</file>
|
||||
<file>lolautoaccept.png</file>
|
||||
<file>lolautoaccept.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
|
@ -138,7 +138,7 @@ ID: %4</translation>
|
|||
<message>
|
||||
<location filename="../ui/runedisplay.ui" line="26"/>
|
||||
<source>Apply Runes</source>
|
||||
<translation>Runnen Anwenden</translation>
|
||||
<translation>Runen Anwenden</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
29
src/main.cpp
29
src/main.cpp
|
@ -14,28 +14,6 @@
|
|||
#include "clientaccess.h"
|
||||
#include "clientapi.h"
|
||||
|
||||
#ifdef WIN32
|
||||
static std::string getBaseString(char** argv) {
|
||||
// TODO
|
||||
(void) argv;
|
||||
return "./";
|
||||
}
|
||||
#else
|
||||
static std::string getBaseString(char** argv) {
|
||||
std::string base;
|
||||
|
||||
char* appbase = getenv("APPDIR");
|
||||
if(appbase) {
|
||||
return std::string(appbase) + '/';
|
||||
}
|
||||
|
||||
char* cresolved = realpath(argv[0], NULL);
|
||||
std::string resolved(cresolved);
|
||||
free(cresolved);
|
||||
return resolved.substr(0, resolved.rfind('/')+1);
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
Log::init();
|
||||
Log::setConsoleLogLevel(Log::Level::INFO);
|
||||
|
@ -58,18 +36,15 @@ int main(int argc, char** argv) {
|
|||
Log::info << "Hello, World!";
|
||||
Log::note << "Using Locale: " << QLocale().name().toStdString();
|
||||
|
||||
std::string base = getBaseString(argv);
|
||||
Log::info << "appbase: " << base;
|
||||
|
||||
QApplication app(argc, argv);
|
||||
QTranslator translator;
|
||||
if(translator.load(QLocale().name(), QString::fromStdString(base + "ts"))) {
|
||||
if(translator.load(QLocale().name(), ":/ts")) {
|
||||
app.installTranslator(&translator);
|
||||
} else {
|
||||
Log::warn << "translation not found";
|
||||
}
|
||||
MainWindow win;
|
||||
QIcon icon(QString::fromStdString(base + "lolautoaccept.png"));
|
||||
QIcon icon(":/lolautoaccept.png");
|
||||
win.setWindowIcon(icon);
|
||||
|
||||
win.show();
|
||||
|
|
Loading…
Reference in New Issue