From 864940446db9b08c0238df8fc71782e0be10c3a4 Mon Sep 17 00:00:00 2001 From: Ivan Pelipenko Date: Wed, 13 May 2020 13:36:38 +0300 Subject: [PATCH 1/9] mobile about --- qad/application/aboutwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qad/application/aboutwindow.cpp b/qad/application/aboutwindow.cpp index 5e644be..49d605a 100644 --- a/qad/application/aboutwindow.cpp +++ b/qad/application/aboutwindow.cpp @@ -63,7 +63,7 @@ AboutWindow::AboutWindow(QWidget * parent): QDialog(parent), ui(new Ui::AboutWin //ui->verticalSpacer->changeSize(1, 1, QSizePolicy::Preferred, QSizePolicy::Preferred); #endif #ifdef MOBILE_VIEW -// ui->layoutMain->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Preferred, QSizePolicy::Expanding)); + ui->layoutMain->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Preferred, QSizePolicy::Expanding)); #else QRect r; # if QT_VERSION < 0x050000 From 30d1faff9a5549995e2bd7d411c5406042ee89be Mon Sep 17 00:00:00 2001 From: Ivan Pelipenko Date: Fri, 15 May 2020 22:49:08 +0300 Subject: [PATCH 2/9] qad_locations --- pip | 2 +- qad/qad_export.h | 2 +- qad/utils/qad_locations.cpp | 116 ++++++++++++++++++++++++++++++++++++ qad/utils/qad_locations.h | 59 ++++++++++++++++++ 4 files changed, 177 insertions(+), 2 deletions(-) create mode 100644 qad/utils/qad_locations.cpp create mode 100644 qad/utils/qad_locations.h diff --git a/pip b/pip index de17f93..2c5e4e9 160000 --- a/pip +++ b/pip @@ -1 +1 @@ -Subproject commit de17f93679c7ddb4b873c1873e4f6b911d894f04 +Subproject commit 2c5e4e9b4c8e72750232494514d3d552e28a6f57 diff --git a/qad/qad_export.h b/qad/qad_export.h index ebb2f2b..3d40d96 100644 --- a/qad/qad_export.h +++ b/qad/qad_export.h @@ -3,7 +3,7 @@ #include -#ifdef QAD_STATIC_DEFINE +#if defined(QAD_STATIC_DEFINE) || defined(Q_CC_GNU) || defined(DOXYGEN) # define QAD_EXPORT #else # ifdef QAD_SHARED_DEFINE diff --git a/qad/utils/qad_locations.cpp b/qad/utils/qad_locations.cpp new file mode 100644 index 0000000..8d1059d --- /dev/null +++ b/qad/utils/qad_locations.cpp @@ -0,0 +1,116 @@ +#include "qad_locations.h" +#include +#include +#include +#include +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +# include +#else +# include +#endif + +#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) +# define MOBILE_VIEW +#endif + + +QString QAD::userPath(QAD::LocationType loc, QString name) { + QString dir, ext; + switch (loc) { + case ctConfig: ext = ".conf"; break; + case ctCache : ext = ".cache"; break; + } +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + QStandardPaths::StandardLocation l = QStandardPaths::AppConfigLocation; + switch (loc) { + case ctConfig: l = QStandardPaths::AppConfigLocation; break; + case ctCache : l = QStandardPaths::CacheLocation; break; + } + dir = QStandardPaths::writableLocation(l); +#else + QDesktopServices::StandardLocation l = QDesktopServices::DataLocation; + switch (loc) { + case ctConfig: l = QDesktopServices::DataLocation; break; + case ctCache : l = QDesktopServices::CacheLocation; break; + } + dir = QDesktopServices::storageLocation(l); +#endif + if (!QDir(dir).exists()) + QDir().mkpath(dir); + return dir + "/" + name + ext; +} + + +QStringList QAD::resourcePaths(QString type) { + QStringList ret; + ret << (QApplication::applicationDirPath() + "/" + type); +#ifdef MOBILE_VIEW + ret << (":/" + type); +#elif defined(Q_OS_MACOS) + ret << (QApplication::applicationDirPath() + "/../Resources/" + type); +#elif defined(Q_OS_WINDOWS) +#else + ret << QString("/usr/share/%1/%2/%3").arg(QApplication::organizationName(), QApplication::applicationName(), type); + ret << QString("/usr/share/%1/%2").arg(QApplication::organizationName(), type); +#endif + return ret; +} + + +void QAD::loadTranslations(QString lang) { + if (lang.isEmpty()) + lang = QLocale().bcp47Name(); + QString short_lang = lang.left(2); + QStringList dirs = resourcePaths("lang"); + foreach (const QString & d, dirs) { + QDirIterator dit(d); + while (dit.hasNext()) { + dit.next(); + if (!dit.filePath().endsWith(".qm")) continue; + if (!dit.fileInfo().baseName().endsWith(lang) && + !dit.fileInfo().baseName().endsWith(short_lang)) continue; + QTranslator * tr = new QTranslator(); + if (tr->load(dit.filePath())) { + qApp->installTranslator(tr); + qDebug() << "Add tr" << dit.fileName(); + } else { + qDebug() << "Can`t load translation" << dit.fileName(); + delete tr; + } + } + } +} + + +QStringList QAD::availableTranslations() { + QSet ret; + QStringList dirs = resourcePaths("lang"); + foreach (const QString & d, dirs) { + QDirIterator dit(d); + while (dit.hasNext()) { + dit.next(); + if (!dit.filePath().endsWith(".qm")) continue; + QTranslator * tr = new QTranslator(); + if (tr->load(dit.filePath())) { + QString fn = dit.fileInfo().baseName(), lang[2]; + if (fn.contains("_")) { + lang[0] = fn.right(fn.size() - fn.lastIndexOf("_") - 1); + fn.chop(lang[0].size() + 1); + if (fn.contains("_")) { + lang[1] = fn.right(fn.size() - fn.lastIndexOf("_") - 1); + fn.chop(lang[1].size() + 1); + lang[1].append("_" + lang[0]); + } + } + for (int i = 0; i < 2; ++i) { + QLocale loc(lang[i]); + if (loc.language() != QLocale::C) + ret << lang[i]; + } + //qDebug() << "Can`t load translation" << dit.fileName(); + delete tr; + } + } + } + return ret.toList(); +} diff --git a/qad/utils/qad_locations.h b/qad/utils/qad_locations.h new file mode 100644 index 0000000..d1d8efd --- /dev/null +++ b/qad/utils/qad_locations.h @@ -0,0 +1,59 @@ +/* + QAD - Qt ADvanced + + Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ + +#ifndef QAD_LOCATIONS_H +#define QAD_LOCATIONS_H + +#include "qad_export.h" +#include + + +namespace QAD { + + enum QAD_EXPORT LocationType { + ctConfig, + ctCache, + }; + + //! Create QStandardPaths::writableLocation() directory + //! and returns file name ".". + //! Extension is selected by "loc": + //! * ctConfig - "conf" + //! * ctCache - "cache" + QAD_EXPORT QString userPath(LocationType loc, QString name = QString()); + + + //! Returns search directories for resource "type" + //! * / presents on all platforms + //! * :/ on mobile platforms + //! * <.app>/Resources/ on MacOS + //! * /usr/share/[organizationName/]/ on Linux + QAD_EXPORT QStringList resourcePaths(QString type); + + + QAD_EXPORT void loadTranslations(QString lang = QString()); + + + QAD_EXPORT QStringList availableTranslations(); + + +} + + +#endif // QAD_LOCATIONS_H From 9db04f5aa06a47ad925564e8920f9c2509c097aa Mon Sep 17 00:00:00 2001 From: Ivan Pelipenko Date: Sat, 16 May 2020 10:02:44 +0300 Subject: [PATCH 3/9] qad_locations --- qad/utils/qad_locations.cpp | 12 ++++++------ qad/utils/qad_locations.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/qad/utils/qad_locations.cpp b/qad/utils/qad_locations.cpp index 8d1059d..36164f2 100644 --- a/qad/utils/qad_locations.cpp +++ b/qad/utils/qad_locations.cpp @@ -17,21 +17,21 @@ QString QAD::userPath(QAD::LocationType loc, QString name) { QString dir, ext; switch (loc) { - case ctConfig: ext = ".conf"; break; - case ctCache : ext = ".cache"; break; + case ltConfig: ext = ".conf"; break; + case ltCache : ext = ".cache"; break; } #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QStandardPaths::StandardLocation l = QStandardPaths::AppConfigLocation; switch (loc) { - case ctConfig: l = QStandardPaths::AppConfigLocation; break; - case ctCache : l = QStandardPaths::CacheLocation; break; + case ltConfig: l = QStandardPaths::AppConfigLocation; break; + case ltCache : l = QStandardPaths::CacheLocation; break; } dir = QStandardPaths::writableLocation(l); #else QDesktopServices::StandardLocation l = QDesktopServices::DataLocation; switch (loc) { - case ctConfig: l = QDesktopServices::DataLocation; break; - case ctCache : l = QDesktopServices::CacheLocation; break; + case ltConfig: l = QDesktopServices::DataLocation; break; + case ltCache : l = QDesktopServices::CacheLocation; break; } dir = QDesktopServices::storageLocation(l); #endif diff --git a/qad/utils/qad_locations.h b/qad/utils/qad_locations.h index d1d8efd..860ce7f 100644 --- a/qad/utils/qad_locations.h +++ b/qad/utils/qad_locations.h @@ -27,8 +27,8 @@ namespace QAD { enum QAD_EXPORT LocationType { - ctConfig, - ctCache, + ltConfig, + ltCache, }; //! Create QStandardPaths::writableLocation() directory From 2e59133c665421e0a7a0a83083ab567a37eaceac Mon Sep 17 00:00:00 2001 From: Ivan Pelipenko Date: Sat, 16 May 2020 11:26:13 +0300 Subject: [PATCH 4/9] version 1.1.1_alpha --- pip | 2 +- qad/CMakeLists.txt | 4 ++-- qad/utils/qad_locations.cpp | 2 +- qad/utils/qad_locations.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pip b/pip index 2c5e4e9..abe8b76 160000 --- a/pip +++ b/pip @@ -1 +1 @@ -Subproject commit 2c5e4e9b4c8e72750232494514d3d552e28a6f57 +Subproject commit abe8b76046e882b8d89f7e957f5a39a336012f49 diff --git a/qad/CMakeLists.txt b/qad/CMakeLists.txt index 6ca6800..2808b14 100644 --- a/qad/CMakeLists.txt +++ b/qad/CMakeLists.txt @@ -3,8 +3,8 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake project(qad) set(_QAD_MAJOR 1) set(_QAD_MINOR 1) -set(_QAD_REVISION 0) -set(_QAD_SUFFIX ) +set(_QAD_REVISION 1) +set(_QAD_SUFFIX alpha) set(_QAD_COMPANY SHS) set(_QAD_DOMAIN org.SHS) diff --git a/qad/utils/qad_locations.cpp b/qad/utils/qad_locations.cpp index 36164f2..266fab5 100644 --- a/qad/utils/qad_locations.cpp +++ b/qad/utils/qad_locations.cpp @@ -112,5 +112,5 @@ QStringList QAD::availableTranslations() { } } } - return ret.toList(); + return ret.values(); } diff --git a/qad/utils/qad_locations.h b/qad/utils/qad_locations.h index 860ce7f..8fba7c0 100644 --- a/qad/utils/qad_locations.h +++ b/qad/utils/qad_locations.h @@ -34,8 +34,8 @@ namespace QAD { //! Create QStandardPaths::writableLocation() directory //! and returns file name ".". //! Extension is selected by "loc": - //! * ctConfig - "conf" - //! * ctCache - "cache" + //! * ltConfig - "conf" + //! * ltCache - "cache" QAD_EXPORT QString userPath(LocationType loc, QString name = QString()); From ada132e9929435091232cc79b10728933957df66 Mon Sep 17 00:00:00 2001 From: Ivan Pelipenko Date: Mon, 18 May 2020 16:39:37 +0300 Subject: [PATCH 5/9] pip, qad version --- pip | 2 +- qad/CMakeLists.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pip b/pip index abe8b76..caedece 160000 --- a/pip +++ b/pip @@ -1 +1 @@ -Subproject commit abe8b76046e882b8d89f7e957f5a39a336012f49 +Subproject commit caedece3525c841b8a2ef8f3c5209aabeb99c3e3 diff --git a/qad/CMakeLists.txt b/qad/CMakeLists.txt index 2808b14..69e7a44 100644 --- a/qad/CMakeLists.txt +++ b/qad/CMakeLists.txt @@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.0) cmake_policy(SET CMP0017 NEW) # need include() with .cmake project(qad) set(_QAD_MAJOR 1) -set(_QAD_MINOR 1) -set(_QAD_REVISION 1) +set(_QAD_MINOR 2) +set(_QAD_REVISION 0) set(_QAD_SUFFIX alpha) set(_QAD_COMPANY SHS) set(_QAD_DOMAIN org.SHS) From 03442306b94f6f4dc944862452e60c798016d089 Mon Sep 17 00:00:00 2001 From: Ivan Pelipenko Date: Mon, 18 May 2020 17:41:57 +0300 Subject: [PATCH 6/9] pip --- pip | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pip b/pip index caedece..d2cb72c 160000 --- a/pip +++ b/pip @@ -1 +1 @@ -Subproject commit caedece3525c841b8a2ef8f3c5209aabeb99c3e3 +Subproject commit d2cb72c67657b790a97f52ddefd51b6052a285a7 From b65f154f29ccd8d1aeef97352ff4e123554f1cc3 Mon Sep 17 00:00:00 2001 From: Ivan Pelipenko Date: Mon, 18 May 2020 19:18:21 +0300 Subject: [PATCH 7/9] docker --- Jenkinsfile | 1 + docker/debian-libs/Dockerfile | 4 ++-- pip | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e4ffc2c..7048edf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,6 +10,7 @@ def build_docker(name) { jobs = "${env.JOBS_COUNT}" } def args = "${pref} --build-arg LIBS_BUILD_NUMBER=${env.BUILD_NUMBER} --build-arg JOBS_COUNT=${jobs}" + args += " -v `pwd`:/soft/libs -v `pwd`/../libs_build_${name}:/soft/libs_build_${name} --build-arg HAS_SOURCES=1" dir ("docker/${image}") { //echo "build ${image} ${args}" sh "docker build ${args} --no-cache -t ${image} ." diff --git a/docker/debian-libs/Dockerfile b/docker/debian-libs/Dockerfile index af6ae8a..bbeb141 100644 --- a/docker/debian-libs/Dockerfile +++ b/docker/debian-libs/Dockerfile @@ -3,14 +3,14 @@ FROM ${DOCKER_PREFIX}debian ARG LIBS_BUILD_NUMBER=9999 ARG JOBS_COUNT=4 +ARG HAS_SOURCES=0 WORKDIR /soft -RUN git clone -b release --depth 1 --recursive https://git.shs.tools/SHS/libs.git +RUN if [ $HAS_SOURCES -eq 0 ]; then git clone -b release --depth 1 --recursive https://git.shs.tools/SHS/libs.git; fi WORKDIR /soft/libs_build_debian RUN cmake -DICU=0 -DLIB=1 -DQGLENGINE=1 -DQGLVIEW=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} ../libs \ && make install -j${JOBS_COUNT} \ - && rm -rf * \ && ldconfig WORKDIR /soft/src diff --git a/pip b/pip index d2cb72c..b860d8b 160000 --- a/pip +++ b/pip @@ -1 +1 @@ -Subproject commit d2cb72c67657b790a97f52ddefd51b6052a285a7 +Subproject commit b860d8bbafcde76290321b3e1b79b8ec400e0700 From 72e7b4281333394a1644e8f5667d23ff0806d3a2 Mon Sep 17 00:00:00 2001 From: Ivan Pelipenko Date: Mon, 18 May 2020 19:24:11 +0300 Subject: [PATCH 8/9] Jenkinsfile --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7048edf..78b9cac 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,8 +9,9 @@ def build_docker(name) { if (env.JOBS_COUNT) { jobs = "${env.JOBS_COUNT}" } + def _pwd = sh(script: "pwd", returnStdout: true).trim() def args = "${pref} --build-arg LIBS_BUILD_NUMBER=${env.BUILD_NUMBER} --build-arg JOBS_COUNT=${jobs}" - args += " -v `pwd`:/soft/libs -v `pwd`/../libs_build_${name}:/soft/libs_build_${name} --build-arg HAS_SOURCES=1" + args += " --build-arg HAS_SOURCES=1 -v ${_pwd}:/soft/libs -v ${_pwd}/../libs_build_${name}:/soft/libs_build_${name}" dir ("docker/${image}") { //echo "build ${image} ${args}" sh "docker build ${args} --no-cache -t ${image} ." From 4bc671584cb51725b3e9836588ceadcbacad0f03 Mon Sep 17 00:00:00 2001 From: Ivan Pelipenko Date: Mon, 18 May 2020 19:34:12 +0300 Subject: [PATCH 9/9] retry --- Jenkinsfile | 2 -- docker/debian-libs/Dockerfile | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 78b9cac..e4ffc2c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,9 +9,7 @@ def build_docker(name) { if (env.JOBS_COUNT) { jobs = "${env.JOBS_COUNT}" } - def _pwd = sh(script: "pwd", returnStdout: true).trim() def args = "${pref} --build-arg LIBS_BUILD_NUMBER=${env.BUILD_NUMBER} --build-arg JOBS_COUNT=${jobs}" - args += " --build-arg HAS_SOURCES=1 -v ${_pwd}:/soft/libs -v ${_pwd}/../libs_build_${name}:/soft/libs_build_${name}" dir ("docker/${image}") { //echo "build ${image} ${args}" sh "docker build ${args} --no-cache -t ${image} ." diff --git a/docker/debian-libs/Dockerfile b/docker/debian-libs/Dockerfile index bbeb141..af6ae8a 100644 --- a/docker/debian-libs/Dockerfile +++ b/docker/debian-libs/Dockerfile @@ -3,14 +3,14 @@ FROM ${DOCKER_PREFIX}debian ARG LIBS_BUILD_NUMBER=9999 ARG JOBS_COUNT=4 -ARG HAS_SOURCES=0 WORKDIR /soft -RUN if [ $HAS_SOURCES -eq 0 ]; then git clone -b release --depth 1 --recursive https://git.shs.tools/SHS/libs.git; fi +RUN git clone -b release --depth 1 --recursive https://git.shs.tools/SHS/libs.git WORKDIR /soft/libs_build_debian RUN cmake -DICU=0 -DLIB=1 -DQGLENGINE=1 -DQGLVIEW=1 -DBUILD_NUMBER=${LIBS_BUILD_NUMBER} ../libs \ && make install -j${JOBS_COUNT} \ + && rm -rf * \ && ldconfig WORKDIR /soft/src