From 675f9b46dc93ae3ffbd7312e4452834efae13871 Mon Sep 17 00:00:00 2001 From: Alexander Stefanov-Khryukin Date: Mon, 20 Feb 2017 12:05:45 +0000 Subject: [PATCH] fix for https://github.com/Denvi/Candle/issues/121 1. Use linux'n'macos user config dirs instead of /usr/bin/settings.ini 2. Proper path to translations, in *nix it must be /usr/share/%{name}/translations/ --- src/frmabout.cpp | 5 ++++- src/frmmain.cpp | 6 ++++++ src/main.cpp | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/frmabout.cpp b/src/frmabout.cpp index d77774b8..fbf6ab48 100644 --- a/src/frmabout.cpp +++ b/src/frmabout.cpp @@ -12,8 +12,11 @@ frmAbout::frmAbout(QWidget *parent) : ui->setupUi(this); ui->lblAbout->setText(ui->lblAbout->text().arg(qApp->applicationVersion())); - +#ifdef UNIX + QFile file("/usr/share/doc/" + qApp->applicationDisplayName() + "/LICENSE"); +#else QFile file(qApp->applicationDirPath() + "/LICENSE"); +#endif if (file.open(QIODevice::ReadOnly)) { ui->txtLicense->setPlainText(file.readAll()); diff --git a/src/frmmain.cpp b/src/frmmain.cpp index 5c3b4590..3834d2b7 100644 --- a/src/frmmain.cpp +++ b/src/frmmain.cpp @@ -30,6 +30,8 @@ #include #include #include +#include + #include "frmmain.h" #include "ui_frmmain.h" @@ -43,7 +45,11 @@ frmMain::frmMain(QWidget *parent) : m_statusForeColors << "white" << "palette(text)" << "white" << "black" << "black" << "black" << "black" << "palette(text)" << "white"; // Loading settings +#ifdef UNIX + m_settingsFileName = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)+ "/candle/" + "/settings.ini"; +#else m_settingsFileName = qApp->applicationDirPath() + "/settings.ini"; +#endif preloadSettings(); m_settings = new frmSettings(this); diff --git a/src/main.cpp b/src/main.cpp index aeed2e05..6e1e21ab 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -44,7 +44,11 @@ int main(int argc, char *argv[]) // QLocale::setDefault(QLocale("es")); QString loc = QLocale().name().left(2); +#ifdef UNIX + QString translationsFolder = "/usr/share/" + qApp->applicationDisplayName() + "/translations/"; +#else QString translationsFolder = qApp->applicationDirPath() + "/translations/"; +#endif QString translationFileName = translationsFolder + qApp->applicationDisplayName() + "_" + loc + ".qm"; qDebug() << "locale:" << loc;