forked from MrBesen/lolautoaccept
appimage fixes
This commit is contained in:
parent
31b058e63e
commit
ee5a0017ea
|
@ -9,7 +9,10 @@ private:
|
|||
int32_t posx = -1;
|
||||
int32_t posy = -1;
|
||||
|
||||
static std::string pathbase;
|
||||
public:
|
||||
static void setPathBase(const std::string& pa);
|
||||
|
||||
Matcher(const std::string& filename);
|
||||
Matcher(const cv::Mat& templ);
|
||||
~Matcher();
|
||||
|
|
|
@ -98,7 +98,11 @@ unix {
|
|||
$$MOC_DIR/lolautoaccept.svg.commands = touch $$MOC_DIR/lolautoaccept.svg
|
||||
|
||||
appimg.depends = $$PWD/linuxdeploy-x86_64.AppImage $${TARGET} $$MOC_DIR/lolautoaccept.svg
|
||||
appimg.commands = rm -rf AppDir ; mkdir -p AppDir/ts; cp $$PWD/ts/*.qm ./AppDir/ts ; ./linuxdeploy-x86_64.AppImage --appdir=AppDir -e lolautoaccept -i $$MOC_DIR/lolautoaccept.svg -d lolautoaccept.desktop --output appimage
|
||||
appimg.commands = rm -rf AppDir ; \
|
||||
mkdir -p AppDir/ts AppDir/imgs; \
|
||||
cp $$PWD/ts/*.qm ./AppDir/ts ; \
|
||||
cp $$PWD/imgs/*.png ./AppDir/imgs; \
|
||||
./linuxdeploy-x86_64.AppImage --appdir=AppDir -e lolautoaccept -i $$MOC_DIR/lolautoaccept.svg -d lolautoaccept.desktop --output appimage
|
||||
|
||||
QMAKE_EXTRA_TARGETS += appimg $$PWD/linuxdeploy-x86_64.AppImage $$MOC_DIR/lolautoaccept.svg
|
||||
|
||||
|
|
28
src/main.cpp
28
src/main.cpp
|
@ -1,6 +1,9 @@
|
|||
#include <thread>
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QFile>
|
||||
#include <QMessageBox>
|
||||
#include <QTranslator>
|
||||
|
||||
|
@ -9,6 +12,20 @@
|
|||
#include "mainwindow.h"
|
||||
#include "lolautoaccept.h"
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
Log::init();
|
||||
Log::setConsoleLogLevel(Log::Level::INFO);
|
||||
|
@ -20,10 +37,19 @@ int main(int argc, char** argv) {
|
|||
Log::info << "Hello, World!";
|
||||
Log::note << "Using Locale: " << QLocale().name().toStdString();
|
||||
|
||||
if(argc == 0) {
|
||||
Log::fatal << "arg[0] is not set";
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string base = getBaseString(argv);
|
||||
Log::info << "appbase: " << base;
|
||||
Matcher::setPathBase(base);
|
||||
|
||||
LolAutoAccept lolaa;
|
||||
QApplication app(argc, argv);
|
||||
QTranslator translator;
|
||||
if(translator.load(QLocale().name(), QLatin1String("ts"))) {
|
||||
if(translator.load(QLocale().name(), QString::fromStdString(base + "ts"))) {
|
||||
app.installTranslator(&translator);
|
||||
} else {
|
||||
Log::warn << "translation not found";
|
||||
|
|
|
@ -4,8 +4,14 @@
|
|||
|
||||
#include "util.h"
|
||||
|
||||
std::string Matcher::pathbase;
|
||||
|
||||
void Matcher::setPathBase(const std::string& pa) {
|
||||
pathbase = pa;
|
||||
}
|
||||
|
||||
Matcher::Matcher(const std::string& filename) {
|
||||
templ = cv::imread(filename, cv::IMREAD_UNCHANGED); // unchanged so alpha channel does not get dropped
|
||||
templ = cv::imread(pathbase + filename, cv::IMREAD_UNCHANGED); // unchanged so alpha channel does not get dropped
|
||||
maskFromTemplate();
|
||||
}
|
||||
Matcher::Matcher(const cv::Mat& templ) {
|
||||
|
|
Loading…
Reference in New Issue