diff options
author | r.kuznetsov <r.kuznetsov@corp.mail.ru> | 2017-05-30 12:02:20 +0300 |
---|---|---|
committer | Ilya Zverev <ilya@zverev.info> | 2017-07-04 11:26:12 +0300 |
commit | 1fafff5b00b81e89056bc754589c2f3bc3a6aacd (patch) | |
tree | 7ec2809ea4feaf6b98a07b8a03672b7d9e6ed1ec /qt | |
parent | accc48d7b86be276efa07c2a7ee33bd72e66cd56 (diff) |
Added possibility to run from IDE
Diffstat (limited to 'qt')
30 files changed, 387 insertions, 378 deletions
diff --git a/qt/CMakeLists.txt b/qt/CMakeLists.txt index 38528d35b1..da92a04fa9 100644 --- a/qt/CMakeLists.txt +++ b/qt/CMakeLists.txt @@ -9,9 +9,22 @@ set(RESOURCES_FOLDER ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.app/Contents/Resources) set(DATA_DIR ${OMIM_ROOT}/data) execute_process( - COMMAND mkdir -p ${RESOURCES_FOLDER} + COMMAND mkdir -p ${RESOURCES_FOLDER} ) +if (BUILD_DESIGNER) + execute_process( + COMMAND cp -rf ${OMIM_ROOT}/data/resources-mdpi_clear/ ${OMIM_ROOT}/data/resources-mdpi_design/ + COMMAND cp -rf ${OMIM_ROOT}/data/resources-hdpi_clear/ ${OMIM_ROOT}/data/resources-hdpi_design/ + COMMAND cp -rf ${OMIM_ROOT}/data/resources-xhdpi_clear/ ${OMIM_ROOT}/data/resources-xhdpi_design/ + COMMAND cp -rf ${OMIM_ROOT}/data/resources-xxhdpi_clear/ ${OMIM_ROOT}/data/resources-xxhdpi_design/ + COMMAND cp -rf ${OMIM_ROOT}/data/resources-6plus_clear/ ${OMIM_ROOT}/data/resources-6plus_design/ + COMMAND cp -f ${OMIM_ROOT}/data/drules_proto_clear.bin ${OMIM_ROOT}/data/drules_proto_design.bin + COMMAND cp -f ${OMIM_ROOT}/data/colors.txt ${OMIM_ROOT}/data/colors_design.txt + COMMAND cp -f ${OMIM_ROOT}/data/patterns.txt ${OMIM_ROOT}/data/patterns_design.txt + ) +endif() + include_directories( ${OMIM_ROOT}/3party/glm ${OMIM_ROOT}/3party/gflags/src @@ -180,4 +193,17 @@ copy_resources( ../tools/shaders_compiler ) +if (BUILD_DESIGNER) + copy_resources( + resources-mdpi_design + resources-hdpi_design + resources-xhdpi_design + resources-xxhdpi_design + resources-6plus_design + colors_design.txt + patterns_design.txt + drules_proto_design.bin + ) +endif() + add_subdirectory(qt_common) diff --git a/qt/about.cpp b/qt/about.cpp index 37c1920fc2..7a4ca0bd11 100644 --- a/qt/about.cpp +++ b/qt/about.cpp @@ -7,23 +7,18 @@ #include <QtCore/QFile> #include <QtGui/QIcon> +#include <QtWidgets/QMenuBar> +#include <QtWidgets/QHBoxLayout> +#include <QtWidgets/QVBoxLayout> +#include <QtWidgets/QLabel> +#include <QtWidgets/QTextBrowser> -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - #include <QtGui/QMenuBar> - #include <QtGui/QHBoxLayout> - #include <QtGui/QVBoxLayout> - #include <QtGui/QLabel> - #include <QtGui/QTextBrowser> -#else - #include <QtWidgets/QMenuBar> - #include <QtWidgets/QHBoxLayout> - #include <QtWidgets/QVBoxLayout> - #include <QtWidgets/QLabel> - #include <QtWidgets/QTextBrowser> -#endif - -#ifdef BUILD_DESIGNER +#ifdef USE_DESIGNER_VERSION #include "designer_version.h" +#else + #define DESIGNER_APP_VERSION "" + #define DESIGNER_CODEBASE_SHA "" + #define DESIGNER_DATA_VERSION "" #endif // BUILD_DESIGNER AboutDialog::AboutDialog(QWidget * parent) diff --git a/qt/about.hpp b/qt/about.hpp index 792521877f..1fdebf710b 100644 --- a/qt/about.hpp +++ b/qt/about.hpp @@ -1,11 +1,7 @@ #pragma once #include <QtWidgets/QApplication> -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - #include <QtGui/QDialog> -#else - #include <QtWidgets/QDialog> -#endif +#include <QtWidgets/QDialog> class AboutDialog : public QDialog { diff --git a/qt/build_style/build_common.cpp b/qt/build_style/build_common.cpp index 9c563ca25f..dcf1dbafff 100644 --- a/qt/build_style/build_common.cpp +++ b/qt/build_style/build_common.cpp @@ -1,10 +1,16 @@ #include "build_common.h" +#include "platform/platform.hpp" + +#include <QCoreApplication> #include <QDir> #include <QFile> #include <QProcess> +#include <QRegExp> + +#include <exception> -pair<int, QString> ExecProcess(QString const & cmd, QProcessEnvironment const * env) +std::pair<int, QString> ExecProcess(QString const & cmd, QProcessEnvironment const * env) { QProcess p; if (nullptr != env) @@ -23,11 +29,13 @@ pair<int, QString> ExecProcess(QString const & cmd, QProcessEnvironment const * output += error; } - return make_pair(exitCode, output); + return std::make_pair(exitCode, output); } bool CopyFile(QString const & oldFile, QString const & newFile) { + if (oldFile == newFile) + return true; if (!QFile::exists(oldFile)) return false; if (QFile::exists(newFile) && !QFile::remove(newFile)) @@ -35,14 +43,71 @@ bool CopyFile(QString const & oldFile, QString const & newFile) return QFile::copy(oldFile, newFile); } +void CopyFromResources(QString const & name, QString const & output) +{ + QString const resourceDir = GetPlatform().ResourcesDir().c_str(); + if (!CopyFile(JoinFoldersToPath({resourceDir, name}), + JoinFoldersToPath({output, name}))) + { + throw std::runtime_error(std::string("Cannot copy file ") + + name.toStdString() + + " to " + output.toStdString()); + } +} + +void CopyToResources(QString const & name, QString const & input, QString const & newName) +{ + QString const resourceDir = GetPlatform().ResourcesDir().c_str(); + if (!CopyFile(JoinFoldersToPath({input, name}), + JoinFoldersToPath({resourceDir, newName.isEmpty() ? name : newName}))) + { + throw std::runtime_error(std::string("Cannot copy file ") + + name.toStdString() + + " from " + input.toStdString()); + } +} + QString JoinFoldersToPath(std::initializer_list<QString> const & folders) { QString result; + bool firstInserted = false; for (auto it = folders.begin(); it != folders.end(); ++it) { - if (it != folders.begin()) + if (it->isEmpty() || *it == QDir::separator()) + continue; + + if (firstInserted) result.append(QDir::separator()); + result.append(*it); + firstInserted = true; } return QDir::cleanPath(result); } + +QString GetExternalPath(QString const & name, QString const & primaryPath, + QString const & secondaryPath) +{ + QString const resourceDir = GetPlatform().ResourcesDir().c_str(); + QString path = JoinFoldersToPath({resourceDir, primaryPath, name}); + if (!QFileInfo::exists(path)) + path = JoinFoldersToPath({resourceDir, secondaryPath, name}); + + // Special case for looking for in application folder. + if (!QFileInfo::exists(path) && secondaryPath.isEmpty()) + { + QString const appPath = QCoreApplication::applicationDirPath(); + QRegExp rx("(/[^/]*\\.app)", Qt::CaseInsensitive); + int i = rx.indexIn(appPath); + if (i >= 0) + path = JoinFoldersToPath({appPath.left(i), name}); + } + + ASSERT(QFileInfo::exists(path), (path.toStdString())); + return path; +} + +QString GetProtobufEggPath() +{ + return GetExternalPath("protobuf-2.6.1-py2.7.egg", "kothic", "../protobuf"); +} diff --git a/qt/build_style/build_common.h b/qt/build_style/build_common.h index 55500c9af1..113a219a57 100644 --- a/qt/build_style/build_common.h +++ b/qt/build_style/build_common.h @@ -1,17 +1,23 @@ #pragma once -#include "std/string.hpp" -#include "std/utility.hpp" - #include <QString> #include <QProcessEnvironment> #include <initializer_list> +#include <string> +#include <utility> -inline string to_string(const QString & qs) { return qs.toUtf8().constData(); } +inline std::string to_string(const QString & qs) { return qs.toUtf8().constData(); } -pair<int, QString> ExecProcess(QString const & cmd, QProcessEnvironment const * env = nullptr); +std::pair<int, QString> ExecProcess(QString const & cmd, QProcessEnvironment const * env = nullptr); bool CopyFile(QString const & oldFile, QString const & newFile); +void CopyFromResources(QString const & name, QString const & output); +void CopyToResources(QString const & name, QString const & input, QString const & newName = ""); + QString JoinFoldersToPath(std::initializer_list<QString> const & folders); + +QString GetExternalPath(QString const & name, QString const & primaryPath, + QString const & secondaryPath); +QString GetProtobufEggPath(); diff --git a/qt/build_style/build_drules.cpp b/qt/build_style/build_drules.cpp index 2e9a108593..7f6ec59258 100644 --- a/qt/build_style/build_drules.cpp +++ b/qt/build_style/build_drules.cpp @@ -3,8 +3,7 @@ #include "platform/platform.hpp" -#include "std/exception.hpp" - +#include <exception> #include <fstream> #include <streambuf> @@ -15,32 +14,22 @@ namespace { - QString GetScriptPath() { - QString const resourceDir = GetPlatform().ResourcesDir().c_str(); - return resourceDir + "kothic/src/libkomwm.py"; -} - -QString GetProtobufEggPath() -{ - QString const resourceDir = GetPlatform().ResourcesDir().c_str(); - return resourceDir + "kothic/protobuf-2.6.1-py2.7.egg"; + return GetExternalPath("libkomwm.py", "kothic/src", "../tools/kothic/src"); } - } // namespace namespace build_style { - void BuildDrawingRulesImpl(QString const & mapcssFile, QString const & outputDir) { - QString const outputTemplate = outputDir + "drules_proto"; + QString const outputTemplate = JoinFoldersToPath({outputDir, "drules_proto_design"}); QString const outputFile = outputTemplate + ".bin"; // Caller ensures that output directory is clear if (QFile(outputFile).exists()) - throw runtime_error("Output directory is not clear"); + throw std::runtime_error("Output directory is not clear"); // Prepare command line QStringList params; @@ -64,41 +53,27 @@ void BuildDrawingRulesImpl(QString const & mapcssFile, QString const & outputDir QString msg = QString("System error ") + to_string(res.first).c_str(); if (!res.second.isEmpty()) msg = msg + "\n" + res.second; - throw runtime_error(to_string(msg)); + throw std::runtime_error(to_string(msg)); } // Ensure generated files has non-zero size if (QFile(outputFile).size() == 0) - throw runtime_error("Drawing rules file has zero size"); + throw std::runtime_error("Drawing rules file has zero size"); } void BuildDrawingRules(QString const & mapcssFile, QString const & outputDir) { - QString const resourceDir = GetPlatform().ResourcesDir().c_str(); - - if (!QFile::copy(resourceDir + "mapcss-mapping.csv", outputDir + "mapcss-mapping.csv")) - throw runtime_error("Unable to copy mapcss-mapping.csv file"); - - if (!QFile::copy(resourceDir + "mapcss-dynamic.txt", outputDir + "mapcss-dynamic.txt")) - throw runtime_error("Unable to copy mapcss-dynamic.txt file"); - + CopyFromResources("mapcss-mapping.csv", outputDir); + CopyFromResources("mapcss-dynamic.txt", outputDir); BuildDrawingRulesImpl(mapcssFile, outputDir); } void ApplyDrawingRules(QString const & outputDir) { - QString const resourceDir = GetPlatform().ResourcesDir().c_str(); - - if (!CopyFile(outputDir + "drules_proto.bin", resourceDir + "drules_proto.bin")) - throw runtime_error("Cannot copy drawing rules file"); - if (!CopyFile(outputDir + "classificator.txt", resourceDir + "classificator.txt")) - throw runtime_error("Cannot copy classificator file"); - if (!CopyFile(outputDir + "types.txt", resourceDir + "types.txt")) - throw runtime_error("Cannot copy types file"); - if (!CopyFile(outputDir + "patterns.txt", resourceDir + "patterns.txt")) - throw runtime_error("Cannot copy patterns file"); - if (!CopyFile(outputDir + "colors.txt", resourceDir + "colors.txt")) - throw runtime_error("Cannot copy colors file"); + CopyToResources("drules_proto_design.bin", outputDir); + CopyToResources("classificator.txt", outputDir); + CopyToResources("types.txt", outputDir); + CopyToResources("patterns.txt", outputDir, "patterns_design.txt"); + CopyToResources("colors.txt", outputDir, "colors_design.txt"); } - } // namespace build_style diff --git a/qt/build_style/build_drules.h b/qt/build_style/build_drules.h index f476e4d345..61f718abe8 100644 --- a/qt/build_style/build_drules.h +++ b/qt/build_style/build_drules.h @@ -4,8 +4,6 @@ namespace build_style { - void BuildDrawingRules(QString const & mapcssFile, QString const & outputDir); void ApplyDrawingRules(QString const & outputDir); - } // build_style diff --git a/qt/build_style/build_phone_pack.cpp b/qt/build_style/build_phone_pack.cpp index 822ea80390..ff91adea94 100644 --- a/qt/build_style/build_phone_pack.cpp +++ b/qt/build_style/build_phone_pack.cpp @@ -13,11 +13,7 @@ namespace { QString GetScriptPath() { - QString const kScriptName = "generate_styles_override.py"; - QString const resourceDir = GetPlatform().ResourcesDir().c_str(); - if (resourceDir.isEmpty()) - return kScriptName; - return JoinFoldersToPath({resourceDir, kScriptName}); + return GetExternalPath("generate_styles_override.py", "", "../tools/python"); } } // namespace diff --git a/qt/build_style/build_phone_pack.h b/qt/build_style/build_phone_pack.h index fcc055819f..dae66a0a05 100644 --- a/qt/build_style/build_phone_pack.h +++ b/qt/build_style/build_phone_pack.h @@ -4,7 +4,5 @@ namespace build_style { - QString RunBuildingPhonePack(QString const & stylesFolder, QString const & targetFolder); - } // namespace build_style diff --git a/qt/build_style/build_skins.cpp b/qt/build_style/build_skins.cpp index 7fcb7573ed..8f1fcad0be 100644 --- a/qt/build_style/build_skins.cpp +++ b/qt/build_style/build_skins.cpp @@ -3,22 +3,20 @@ #include "platform/platform.hpp" -#include "std/array.hpp" -#include "std/algorithm.hpp" -#include "std/exception.hpp" -#include "std/tuple.hpp" -#include "std/unordered_map.hpp" -#include "std/fstream.hpp" +#include <array> +#include <algorithm> +#include <exception> +#include <tuple> +#include <unordered_map> +#include <utility> +#include <fstream> #include <QDir> namespace { - enum SkinType { - SkinYota, - SkinLDPI, SkinMDPI, SkinHDPI, SkinXHDPI, @@ -29,22 +27,18 @@ enum SkinType SkinCount }; -typedef tuple<const char*, int, bool> SkinInfo; -const SkinInfo g_skinInfo[SkinCount] = +using SkinInfo = std::tuple<const char*, int, bool>; +SkinInfo const g_skinInfo[SkinCount] = { - make_tuple("yota", 19, true), - make_tuple("ldpi", 18, false), - make_tuple("mdpi", 18, false), - make_tuple("hdpi", 27, false), - make_tuple("xhdpi", 36, false), - make_tuple("xxhdpi", 54, false), - make_tuple("6plus", 54, false), + std::make_tuple("mdpi", 18, false), + std::make_tuple("hdpi", 27, false), + std::make_tuple("xhdpi", 36, false), + std::make_tuple("xxhdpi", 54, false), + std::make_tuple("6plus", 54, false), }; -const array<SkinType, SkinCount> g_skinTypes = +std::array<SkinType, SkinCount> const g_skinTypes = {{ - SkinYota, - SkinLDPI, SkinMDPI, SkinHDPI, SkinXHDPI, @@ -58,53 +52,50 @@ inline bool SkinCoorrectColor(SkinType s) { return std::get<2>(g_skinInfo[s]); } QString GetSkinGeneratorPath() { - QString const resourceDir = GetPlatform().ResourcesDir().c_str(); - return resourceDir + "skin_generator.app/Contents/MacOS/skin_generator"; + return GetExternalPath("skin_generator", "skin_generator.app/Contents/MacOS", ""); } class RAII { public: - RAII(function<void()> && f) : m_f(move(f)) {} + RAII(std::function<void()> && f) : m_f(std::move(f)) {} ~RAII() { m_f(); } private: function<void()> const m_f; }; -string trim(string && s) +std::string trim(std::string && s) { - s.erase(remove_if(s.begin(), s.end(), &isspace), s.end()); + s.erase(std::remove_if(s.begin(), s.end(), &isspace), s.end()); return s; } - } // namespace namespace build_style { - -unordered_map<string, int> GetSkinSizes(QString const & file) +std::unordered_map<string, int> GetSkinSizes(QString const & file) { - unordered_map<string, int> skinSizes; + std::unordered_map<string, int> skinSizes; for (SkinType s : g_skinTypes) skinSizes.insert(make_pair(SkinSuffix(s), SkinSize(s))); try { - ifstream ifs(to_string(file)); + std::ifstream ifs(to_string(file)); - string line; + std::string line; while (std::getline(ifs, line)) { size_t const pos = line.find('='); - if (pos == string::npos) + if (pos == std::string::npos) continue; - string name(line.begin(), line.begin() + pos); - string valueTxt(line.begin() + pos + 1, line.end()); + std::string name(line.begin(), line.begin() + pos); + std::string valueTxt(line.begin() + pos + 1, line.end()); - name = trim(move(name)); - int value = std::stoi(trim(move(valueTxt))); + name = trim(std::move(name)); + int value = std::stoi(trim(std::move(valueTxt))); if (value <= 0) continue; @@ -122,29 +113,29 @@ unordered_map<string, int> GetSkinSizes(QString const & file) return skinSizes; } -void BuildSkinImpl(QString const & styleDir, QString const & suffix, int size, bool colorCorrection, - QString const & outputDir) +void BuildSkinImpl(QString const & styleDir, QString const & suffix, + int size, bool colorCorrection, QString const & outputDir) { - QString const symbolsDir = styleDir + "symbols/"; + QString const symbolsDir = JoinFoldersToPath({styleDir, "symbols"}); // Check symbols directory exists if (!QDir(symbolsDir).exists()) - throw runtime_error("Symbols directory does not exist"); + throw std::runtime_error("Symbols directory does not exist"); // Caller ensures that output directory is clear if (QDir(outputDir).exists()) - throw runtime_error("Output directory is not clear"); + throw std::runtime_error("Output directory is not clear"); // Create output skin directory if (!QDir().mkdir(outputDir)) - throw runtime_error("Cannot create output skin directory"); + throw std::runtime_error("Cannot create output skin directory"); // Create symbolic link for symbols/png QString const pngOriginDir = styleDir + suffix; - QString const pngDir = styleDir + "symbols/png"; + QString const pngDir = JoinFoldersToPath({styleDir, "symbols", "png"}); QFile::remove(pngDir); if (!QFile::link(pngOriginDir, pngDir)) - throw runtime_error("Unable to create symbols/png link"); + throw std::runtime_error("Unable to create symbols/png link"); RAII const cleaner([=]() { QFile::remove(pngDir); }); // Prepare command line @@ -153,7 +144,7 @@ void BuildSkinImpl(QString const & styleDir, QString const & suffix, int size, b "--symbolWidth" << to_string(size).c_str() << "--symbolHeight" << to_string(size).c_str() << "--symbolsDir" << symbolsDir << - "--skinName" << outputDir + "basic" << + "--skinName" << JoinFoldersToPath({outputDir, "basic"}) << "--skinSuffix=\"\""; if (colorCorrection) params << "--colorCorrection true"; @@ -168,27 +159,27 @@ void BuildSkinImpl(QString const & styleDir, QString const & suffix, int size, b QString msg = QString("System error ") + to_string(res.first).c_str(); if (!res.second.isEmpty()) msg = msg + "\n" + res.second; - throw runtime_error(to_string(msg)); + throw std::runtime_error(to_string(msg)); } // Check files were created - if (QFile(outputDir + "symbols.png").size() == 0 || - QFile(outputDir + "symbols.sdf").size() == 0) + if (QFile(JoinFoldersToPath({outputDir, "symbols.png"})).size() == 0 || + QFile(JoinFoldersToPath({outputDir, "symbols.sdf"})).size() == 0) { - throw runtime_error("Skin files have not been created"); + throw std::runtime_error("Skin files have not been created"); } } void BuildSkins(QString const & styleDir, QString const & outputDir) { - QString const resolutionFilePath = styleDir + "resolutions.txt"; + QString const resolutionFilePath = JoinFoldersToPath({styleDir, "resolutions.txt"}); - unordered_map<string, int> const resolution2size = GetSkinSizes(resolutionFilePath); + auto const resolution2size = GetSkinSizes(resolutionFilePath); for (SkinType s : g_skinTypes) { QString const suffix = SkinSuffix(s); - QString const outputSkinDir = outputDir + "resources-" + suffix + "/"; + QString const outputSkinDir = JoinFoldersToPath({outputDir, "resources-" + suffix + "_design"}); int const size = resolution2size.at(to_string(suffix)); // SkinSize(s); bool const colorCorrection = SkinCoorrectColor(s); @@ -203,18 +194,19 @@ void ApplySkins(QString const & outputDir) for (SkinType s : g_skinTypes) { QString const suffix = SkinSuffix(s); - QString const outputSkinDir = outputDir + "resources-" + suffix + "/"; - QString const resourceSkinDir = resourceDir + "resources-" + suffix + "/"; + QString const outputSkinDir = JoinFoldersToPath({outputDir, "resources-" + suffix + "_design"}); + QString const resourceSkinDir = JoinFoldersToPath({resourceDir, "resources-" + suffix + "_design"}); - if (!QDir(resourceSkinDir).exists() && !QDir().mkdir(resourceSkinDir)) - throw runtime_error("Cannot create resource skin directory"); + if (!QFileInfo::exists(resourceSkinDir) && !QDir().mkdir(resourceSkinDir)) + throw std::runtime_error("Cannot create resource skin directory: " + resourceSkinDir.toStdString()); - if (!CopyFile(outputSkinDir + "symbols.png", resourceSkinDir + "symbols.png") || - !CopyFile(outputSkinDir + "symbols.sdf", resourceSkinDir + "symbols.sdf")) + if (!CopyFile(JoinFoldersToPath({outputSkinDir, "symbols.png"}), + JoinFoldersToPath({resourceSkinDir, "symbols.png"})) || + !CopyFile(JoinFoldersToPath({outputSkinDir, "symbols.sdf"}), + JoinFoldersToPath({resourceSkinDir, "symbols.sdf"}))) { - throw runtime_error("Cannot copy skins files"); + throw std::runtime_error("Cannot copy skins files"); } } } - } // namespace build_style diff --git a/qt/build_style/build_skins.h b/qt/build_style/build_skins.h index 77728c2b99..50ca7312af 100644 --- a/qt/build_style/build_skins.h +++ b/qt/build_style/build_skins.h @@ -4,8 +4,6 @@ namespace build_style { - void BuildSkins(QString const & styleDir, QString const & outputDir); void ApplySkins(QString const & outputDir); - } // namespace build_style diff --git a/qt/build_style/build_statistics.cpp b/qt/build_style/build_statistics.cpp index fbe63f15af..0c6b3577ee 100644 --- a/qt/build_style/build_statistics.cpp +++ b/qt/build_style/build_statistics.cpp @@ -2,8 +2,6 @@ #include "build_common.h" -#include "std/exception.hpp" - #include "platform/platform.hpp" #include <QDir> @@ -11,21 +9,14 @@ #include <QFileInfo> #include <QStringList> +#include <exception> + namespace { - QString GetScriptPath() { - QString const resourceDir = GetPlatform().ResourcesDir().c_str(); - return resourceDir + "kothic/src/drules_info.py"; -} - -QString GetProtobufEggPath() -{ - QString const resourceDir = GetPlatform().ResourcesDir().c_str(); - return resourceDir + "kothic/protobuf-2.6.1-py2.7.egg"; + return GetExternalPath("drules_info.py", "kothic/src", "../tools/python/stylesheet"); } - } // namespace namespace build_style @@ -34,10 +25,10 @@ namespace build_style QString GetStyleStatistics(QString const & mapcssMappingFile, QString const & drulesFile) { if (!QFile(mapcssMappingFile).exists()) - throw runtime_error("mapcss-mapping file does not exist"); + throw std::runtime_error("mapcss-mapping file does not exist"); if (!QFile(drulesFile).exists()) - throw runtime_error("drawing-rules file does not exist"); + throw std::runtime_error("drawing-rules file does not exist"); // Prepare command line QStringList params; @@ -67,10 +58,9 @@ QString GetStyleStatistics(QString const & mapcssMappingFile, QString const & dr QString GetCurrentStyleStatistics() { QString const resourceDir = GetPlatform().ResourcesDir().c_str(); - QString const mappingPath = resourceDir + "mapcss-mapping.csv"; - QString const drulesPath = resourceDir + "drules_proto.bin"; + QString const mappingPath = JoinFoldersToPath({resourceDir, "mapcss-mapping.csv"}); + QString const drulesPath = JoinFoldersToPath({resourceDir, "drules_proto_design.bin"}); return GetStyleStatistics(mappingPath, drulesPath); } - } // namespace build_style diff --git a/qt/build_style/build_statistics.h b/qt/build_style/build_statistics.h index 3247bda0cd..9291f5fea7 100644 --- a/qt/build_style/build_statistics.h +++ b/qt/build_style/build_statistics.h @@ -4,9 +4,6 @@ namespace build_style { - QString GetStyleStatistics(QString const & mapcssMappingFile, QString const & drulesFile); - QString GetCurrentStyleStatistics(); - } // namespace build_style diff --git a/qt/build_style/build_style.cpp b/qt/build_style/build_style.cpp index ddfcfa0ea3..09d393da67 100644 --- a/qt/build_style/build_style.cpp +++ b/qt/build_style/build_style.cpp @@ -8,7 +8,7 @@ #include "base/logging.hpp" -#include "std/exception.hpp" +#include <exception> #include <future> #include <QFile> @@ -17,35 +17,29 @@ namespace { - QString GetRecalculateGeometryScriptPath() { - QString const resourceDir = GetPlatform().ResourcesDir().c_str(); - return resourceDir + "recalculate_geom_index.py"; + return GetExternalPath("recalculate_geom_index.py", "", "../tools/python"); } QString GetGeometryToolPath() { - QString const resourceDir = GetPlatform().ResourcesDir().c_str(); - return resourceDir + "generator_tool.app/Contents/MacOS/generator_tool"; + return GetExternalPath("generator_tool", "generator_tool.app/Contents/MacOS", ""); } QString GetGeometryToolResourceDir() { - QString const resourceDir = GetPlatform().ResourcesDir().c_str(); - return resourceDir + "generator_tool.app/Contents/Resources/"; + return GetExternalPath("", "generator_tool.app/Contents/Resources", ""); } - } // namespace namespace build_style { - void BuildAndApply(QString const & mapcssFile) { // Ensure mapcss exists if (!QFile(mapcssFile).exists()) - throw runtime_error("mapcss files does not exist"); + throw std::runtime_error("mapcss files does not exist"); QDir const projectDir = QFileInfo(mapcssFile).absoluteDir(); QString const styleDir = projectDir.absolutePath() + QDir::separator(); @@ -53,9 +47,9 @@ void BuildAndApply(QString const & mapcssFile) // Ensure output directory is clear if (QDir(outputDir).exists() && !QDir(outputDir).removeRecursively()) - throw runtime_error("Unable to remove the output directory"); + throw std::runtime_error("Unable to remove the output directory"); if (!QDir().mkdir(outputDir)) - throw runtime_error("Unable to make the output directory"); + throw std::runtime_error("Unable to make the output directory"); bool const hasSymbols = QDir(styleDir + "symbols/").exists(); if (hasSymbols) @@ -84,12 +78,9 @@ void RunRecalculationGeometryScript(QString const & mapcssFile) QString const geometryToolResourceDir = GetGeometryToolResourceDir(); - if (!CopyFile(resourceDir + "drules_proto.bin", geometryToolResourceDir + "drules_proto.bin")) - throw runtime_error("Cannot copy drawing rules file"); - if (!CopyFile(resourceDir + "classificator.txt", geometryToolResourceDir + "classificator.txt")) - throw runtime_error("Cannot copy classificator file"); - if (!CopyFile(resourceDir + "types.txt", geometryToolResourceDir + "types.txt")) - throw runtime_error("Cannot copy types file"); + CopyFromResources("drules_proto_design.bin", geometryToolResourceDir); + CopyFromResources("classificator.txt", geometryToolResourceDir); + CopyFromResources("types.txt", geometryToolResourceDir); QStringList params; params << "python" << @@ -109,10 +100,9 @@ void RunRecalculationGeometryScript(QString const & mapcssFile) QString msg = QString("System error ") + to_string(res.first).c_str(); if (!res.second.isEmpty()) msg = msg + "\n" + res.second; - throw runtime_error(to_string(msg)); + throw std::runtime_error(to_string(msg)); } } bool NeedRecalculate = false; - } // namespace build_style diff --git a/qt/build_style/build_style.h b/qt/build_style/build_style.h index 49c70a6f2d..9b3bf45004 100644 --- a/qt/build_style/build_style.h +++ b/qt/build_style/build_style.h @@ -4,11 +4,8 @@ namespace build_style { - void BuildAndApply(QString const & mapcssFile); - void RunRecalculationGeometryScript(QString const & mapcssFile); extern bool NeedRecalculate; - } // namespace build_style diff --git a/qt/build_style/run_tests.cpp b/qt/build_style/run_tests.cpp index 7edb143d1e..ecc4eac2e2 100644 --- a/qt/build_style/run_tests.cpp +++ b/qt/build_style/run_tests.cpp @@ -6,19 +6,15 @@ namespace { - QString GetStyleTestPath() { - QString const resourceDir = GetPlatform().ResourcesDir().c_str(); - return resourceDir + "style_tests.app/Contents/MacOS/style_tests"; + return GetExternalPath("style_tests", "style_tests.app/Contents/MacOS", ""); } - } // namespace namespace build_style { - -pair<bool, QString> RunCurrentStyleTests() +std::pair<bool, QString> RunCurrentStyleTests() { QString const resourceDir = GetPlatform().ResourcesDir().c_str(); @@ -32,7 +28,6 @@ pair<bool, QString> RunCurrentStyleTests() // Unfortunately test process returns 0 even if some test failed, // therefore phrase 'All tests passed.' is looked to be sure that everything is OK. - return make_pair(res.second.contains("All tests passed."), res.second); + return std::make_pair(res.second.contains("All tests passed."), res.second); } - } // namespace build_style diff --git a/qt/build_style/run_tests.h b/qt/build_style/run_tests.h index bffa11c5b1..c3e721b807 100644 --- a/qt/build_style/run_tests.h +++ b/qt/build_style/run_tests.h @@ -1,12 +1,10 @@ #pragma once -#include "std/utility.hpp" - #include <QString> +#include <utility> + namespace build_style { - -pair<bool, QString> RunCurrentStyleTests(); - +std::pair<bool, QString> RunCurrentStyleTests(); } // namespace build_style diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp index 69adde3a65..858b17236f 100644 --- a/qt/draw_widget.cpp +++ b/qt/draw_widget.cpp @@ -509,11 +509,10 @@ void DrawWidget::SetDefaultSurfaceFormat(bool apiOpenGLES3) } //fmt.setOption(QSurfaceFormat::DebugContext); QSurfaceFormat::setDefaultFormat(fmt); - +} void DrawWidget::RefreshDrawingRules() { SetMapStyle(MapStyleClear); } - -} +} // namespace qt diff --git a/qt/info_dialog.cpp b/qt/info_dialog.cpp index 59fa34375a..06583b4758 100644 --- a/qt/info_dialog.cpp +++ b/qt/info_dialog.cpp @@ -3,20 +3,11 @@ #include "base/assert.hpp" #include <QtGui/QIcon> - -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - #include <QtGui/QTextBrowser> - #include <QtGui/QPushButton> - #include <QtGui/QHBoxLayout> - #include <QtGui/QVBoxLayout> - #include <QtGui/QLabel> -#else - #include <QtWidgets/QTextBrowser> - #include <QtWidgets/QPushButton> - #include <QtWidgets/QHBoxLayout> - #include <QtWidgets/QVBoxLayout> - #include <QtWidgets/QLabel> -#endif +#include <QtWidgets/QTextBrowser> +#include <QtWidgets/QPushButton> +#include <QtWidgets/QHBoxLayout> +#include <QtWidgets/QVBoxLayout> +#include <QtWidgets/QLabel> namespace qt { diff --git a/qt/info_dialog.hpp b/qt/info_dialog.hpp index 859f7c6076..fa987ab631 100644 --- a/qt/info_dialog.hpp +++ b/qt/info_dialog.hpp @@ -1,11 +1,7 @@ #pragma once #include <QtWidgets/QApplication> -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - #include <QtGui/QDialog> -#else - #include <QtWidgets/QDialog> -#endif +#include <QtWidgets/QDialog> namespace qt { diff --git a/qt/main.cpp b/qt/main.cpp index 46e7294621..e53f4e208c 100644 --- a/qt/main.cpp +++ b/qt/main.cpp @@ -21,15 +21,8 @@ #include "3party/gflags/src/gflags/gflags.h" #include <QMessageBox> - #include <QtCore/QDir> - -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - #include <QtGui/QApplication> -#else - #include <QtWidgets/QApplication> -#endif - +#include <QtWidgets/QApplication> #include <QFileDialog> DEFINE_string(log_abort_level, my::ToString(my::GetDefaultLogAbortLevel()), @@ -152,13 +145,16 @@ int main(int argc, char * argv[]) #endif qt::MainWindow::SetDefaultSurfaceFormat(apiOpenGLES3); - QString mapcssFilePath; #ifdef BUILD_DESIGNER if (argc >= 2 && GetPlatform().IsFileExistsByFullPath(argv[1])) mapcssFilePath = argv[1]; if (0 == mapcssFilePath.length()) - mapcssFilePath = QFileDialog::getOpenFileName(nullptr, - "Open MapCSS file", "~/", "MapCSS Files (*.mapcss)"); + { + mapcssFilePath = QFileDialog::getOpenFileName(nullptr, "Open MapCSS file", "~/", + "MapCSS Files (*.mapcss)"); + } + if (mapcssFilePath.isEmpty()) + return returnCode; #endif // BUILD_DESIGNER Framework framework; @@ -167,7 +163,8 @@ int main(int argc, char * argv[]) returnCode = a.exec(); } - if (build_style::NeedRecalculate && mapcssFilePath.length() != 0) +#ifdef BUILD_DESIGNER + if (build_style::NeedRecalculate && !mapcssFilePath.isEmpty()) { try { @@ -183,6 +180,7 @@ int main(int argc, char * argv[]) msgBox.exec(); } } +#endif // BUILD_DESIGNER LOG_SHORT(LINFO, ("MapsWithMe finished with code", returnCode)); return returnCode; diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp index 3a66c20d36..49cdb7c552 100644 --- a/qt/mainwindow.cpp +++ b/qt/mainwindow.cpp @@ -10,6 +10,8 @@ #include "qt/traffic_panel.hpp" #include "qt/trafficmodeinitdlg.h" +#include "drape/debug_rect_renderer.hpp" + #include "openlr/openlr_sample.hpp" #include "platform/settings.hpp" @@ -38,6 +40,7 @@ #include <QtWidgets/QLabel> #include <QtWidgets/QMenu> #include <QtWidgets/QMenuBar> +#include <QtWidgets/QMessageBox> #include <QtWidgets/QPushButton> #include <QtWidgets/QToolBar> #include <QtWidgets/QToolButton> @@ -55,8 +58,6 @@ #endif // NO_DOWNLOADER -#include "drape/debug_rect_renderer.hpp" - namespace { // TODO(mgsergio): Consider getting rid of this class: just put everything @@ -113,7 +114,6 @@ private: namespace qt { - // Defined in osm_auth_dialog.cpp. extern char const * kTokenKeySetting; extern char const * kTokenSecretSetting; @@ -123,12 +123,6 @@ MainWindow::MainWindow(Framework & framework, bool apiOpenGLES3, QString const & , m_locationService(CreateDesktopLocationService(*this)) #ifdef BUILD_DESIGNER , m_mapcssFilePath(mapcssFilePath) - , m_pBuildStyleAction(nullptr) - , m_pRecalculateGeomIndex(nullptr) - , m_pDrawDebugRectAction(nullptr) - , m_pGetStatisticsAction(nullptr) - , m_pRunTestsAction(nullptr) - , m_pBuildPhonePackAction(nullptr) #endif { // Always runs on the first desktop @@ -145,8 +139,10 @@ MainWindow::MainWindow(Framework & framework, bool apiOpenGLES3, QString const & CreateSearchBarAndPanel(); QString caption = qAppName(); +#ifdef BUILD_DESIGNER if (!m_mapcssFilePath.isEmpty()) caption += QString(" - ") + m_mapcssFilePath; +#endif setWindowTitle(caption); setWindowIcon(QIcon(":/ui/logo.png")); @@ -271,45 +267,45 @@ void MainWindow::LocationStateModeChanged(location::EMyPositionMode mode) namespace { - struct button_t - { - QString name; - char const * icon; - char const * slot; - }; +struct button_t +{ + QString name; + char const * icon; + char const * slot; +}; - void add_buttons(QToolBar * pBar, button_t buttons[], size_t count, QObject * pReceiver) +void add_buttons(QToolBar * pBar, button_t buttons[], size_t count, QObject * pReceiver) +{ + for (size_t i = 0; i < count; ++i) { - for (size_t i = 0; i < count; ++i) - { - if (buttons[i].icon) - pBar->addAction(QIcon(buttons[i].icon), buttons[i].name, pReceiver, buttons[i].slot); - else - pBar->addSeparator(); - } + if (buttons[i].icon) + pBar->addAction(QIcon(buttons[i].icon), buttons[i].name, pReceiver, buttons[i].slot); + else + pBar->addSeparator(); } +} - void FormatMapSize(uint64_t sizeInBytes, string & units, size_t & sizeToDownload) +void FormatMapSize(uint64_t sizeInBytes, string & units, size_t & sizeToDownload) +{ + int const mbInBytes = 1024 * 1024; + int const kbInBytes = 1024; + if (sizeInBytes > mbInBytes) { - int const mbInBytes = 1024 * 1024; - int const kbInBytes = 1024; - if (sizeInBytes > mbInBytes) - { - sizeToDownload = (sizeInBytes + mbInBytes - 1) / mbInBytes; - units = "MB"; - } - else if (sizeInBytes > kbInBytes) - { - sizeToDownload = (sizeInBytes + kbInBytes -1) / kbInBytes; - units = "KB"; - } - else - { - sizeToDownload = sizeInBytes; - units = "B"; - } + sizeToDownload = (sizeInBytes + mbInBytes - 1) / mbInBytes; + units = "MB"; + } + else if (sizeInBytes > kbInBytes) + { + sizeToDownload = (sizeInBytes + kbInBytes -1) / kbInBytes; + units = "KB"; + } + else + { + sizeToDownload = sizeInBytes; + units = "B"; } } +} // namespace void MainWindow::CreateNavigationBar() { @@ -343,6 +339,7 @@ void MainWindow::CreateNavigationBar() m_trafficEnableAction->setChecked(m_pDrawWidget->GetFramework().LoadTrafficEnabled()); pToolBar->addSeparator(); +#ifndef BUILD_DESIGNER m_selectStartRoutePoint = new QAction(QIcon(":/navig64/point-start.png"), tr("Start point"), this); connect(m_selectStartRoutePoint, SIGNAL(triggered()), this, SLOT(OnStartPointSelected())); @@ -402,6 +399,7 @@ void MainWindow::CreateNavigationBar() m_clearSelection->setToolTip(tr("Clear selection")); pToolBar->addSeparator(); +#endif // NOT BUILD_DESIGNER // Add search button with "checked" behavior. m_pSearchAction = pToolBar->addAction(QIcon(":/navig64/search.png"), tr("Search"), @@ -681,8 +679,10 @@ void MainWindow::OnBuildStyle() build_style::BuildAndApply(m_mapcssFilePath); // m_pDrawWidget->RefreshDrawingRules(); - bool enabled = false; - settings::Get(kEnabledAutoRegenGeomIndex, enabled); + bool enabled; + if (!settings::Get(kEnabledAutoRegenGeomIndex, enabled)) + enabled = false; + if (enabled) { build_style::NeedRecalculate = true; @@ -964,5 +964,4 @@ void MainWindow::SetDefaultSurfaceFormat(bool apiOpenGLES3) { DrawWidget::SetDefaultSurfaceFormat(apiOpenGLES3); } - } // namespace qt diff --git a/qt/mainwindow.hpp b/qt/mainwindow.hpp index f4ae03d9c8..425243c7ec 100644 --- a/qt/mainwindow.hpp +++ b/qt/mainwindow.hpp @@ -7,12 +7,12 @@ #include "platform/location.hpp" #include "platform/location_service.hpp" -#include "std/array.hpp" -#include "std/unique_ptr.hpp" - #include <QtWidgets/QApplication> #include <QtWidgets/QMainWindow> +#include <array> +#include <memory> + class Framework; class QDockWidget; class QLabel; @@ -26,57 +26,56 @@ namespace qt { class MainWindow : public QMainWindow, location::LocationObserver { - QAction * m_pMyPositionAction; - QAction * m_pCreateFeatureAction; - QAction * m_selectionMode; - QAction * m_clearSelection; - QAction * m_pSearchAction; - QAction * m_trafficEnableAction; - QAction * m_saveTrafficSampleAction; - QAction * m_quitTrafficModeAction; - QToolButton * m_routePointsToolButton; - QAction * m_selectStartRoutePoint; - QAction * m_selectFinishRoutePoint; - QAction * m_selectIntermediateRoutePoint; -#ifdef BUILD_DESIGNER - QString const m_mapcssFilePath; - QAction * m_pBuildStyleAction; - QAction * m_pRecalculateGeomIndex; - QAction * m_pDrawDebugRectAction; - QAction * m_pGetStatisticsAction; - QAction * m_pRunTestsAction; - QAction * m_pBuildPhonePackAction; -#endif // BUILD_DESIGNER - DrawWidget * m_pDrawWidget; - - // TODO(mgsergio): Make indexing more informative. - array<QDockWidget *, 2> m_Docks; + DrawWidget * m_pDrawWidget = nullptr; // TODO(mgsergio): Make indexing more informative. + std::array<QDockWidget *, 2> m_Docks; + + QPushButton * m_downloadButton = nullptr; + QPushButton * m_retryButton = nullptr; + QLabel * m_downloadingStatusLabel = nullptr; - QPushButton * m_downloadButton; - QPushButton * m_retryButton; - QLabel * m_downloadingStatusLabel; storage::TCountryId m_lastCountry; - unique_ptr<location::LocationService> const m_locationService; + std::unique_ptr<location::LocationService> const m_locationService; // This object is managed by Qt memory system. TrafficMode * m_trafficMode = nullptr; + QAction * m_pMyPositionAction = nullptr; + QAction * m_pCreateFeatureAction = nullptr; + QAction * m_selectionMode = nullptr; + QAction * m_clearSelection = nullptr; + QAction * m_pSearchAction = nullptr; + QAction * m_trafficEnableAction = nullptr; + QAction * m_saveTrafficSampleAction = nullptr; + QAction * m_quitTrafficModeAction = nullptr; + QToolButton * m_routePointsToolButton = nullptr; + QAction * m_selectStartRoutePoint = nullptr; + QAction * m_selectFinishRoutePoint = nullptr; + QAction * m_selectIntermediateRoutePoint = nullptr; +#ifdef BUILD_DESIGNER + QString const m_mapcssFilePath = nullptr; + QAction * m_pBuildStyleAction = nullptr; + QAction * m_pRecalculateGeomIndex = nullptr; + QAction * m_pDrawDebugRectAction = nullptr; + QAction * m_pGetStatisticsAction = nullptr; + QAction * m_pRunTestsAction = nullptr; + QAction * m_pBuildPhonePackAction = nullptr; +#endif // BUILD_DESIGNER + Q_OBJECT public: MainWindow(Framework & framework, bool apiOpenGLES3, QString const & mapcssFilePath = QString()); -Q_OBJECT - static void SetDefaultSurfaceFormat(bool apiOpenGLES3); protected: string GetIniFile(); + void OnLocationError(location::TLocationError errorCode) override; + void OnLocationUpdated(location::GpsInfo const & info) override; void LocationStateModeChanged(location::EMyPositionMode mode); -protected: void CreatePanelImpl(size_t i, Qt::DockWidgetArea area, QString const & name, QKeySequence const & hotkey, char const * slot); void CreateNavigationBar(); @@ -88,10 +87,10 @@ protected: #if defined(Q_WS_WIN) /// to handle menu messages - virtual bool winEvent(MSG * msg, long * result); + bool winEvent(MSG * msg, long * result) override; #endif - virtual void closeEvent(QCloseEvent * e); + void closeEvent(QCloseEvent * e) override; protected Q_SLOTS: #ifndef NO_DOWNLOADER @@ -134,4 +133,4 @@ protected Q_SLOTS: void OnBuildPhonePackage(); #endif // BUILD_DESIGNER }; -} +} // namespace qt diff --git a/qt/preferences_dialog.cpp b/qt/preferences_dialog.cpp index cce3e0bcde..d785d4a6e4 100644 --- a/qt/preferences_dialog.cpp +++ b/qt/preferences_dialog.cpp @@ -4,28 +4,15 @@ #include "platform/settings.hpp" #include <QtGui/QIcon> - -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - #include <QtGui/QCheckBox> - #include <QtGui/QHBoxLayout> - #include <QtGui/QVBoxLayout> - #include <QtGui/QTableWidget> - #include <QtGui/QHeaderView> - #include <QtGui/QPushButton> - #include <QtGui/QGroupBox> - #include <QtGui/QButtonGroup> - #include <QtGui/QRadioButton> -#else - #include <QtWidgets/QCheckBox> - #include <QtWidgets/QHBoxLayout> - #include <QtWidgets/QVBoxLayout> - #include <QtWidgets/QTableWidget> - #include <QtWidgets/QHeaderView> - #include <QtWidgets/QPushButton> - #include <QtWidgets/QGroupBox> - #include <QtWidgets/QButtonGroup> - #include <QtWidgets/QRadioButton> -#endif +#include <QtWidgets/QCheckBox> +#include <QtWidgets/QHBoxLayout> +#include <QtWidgets/QVBoxLayout> +#include <QtWidgets/QTableWidget> +#include <QtWidgets/QHeaderView> +#include <QtWidgets/QPushButton> +#include <QtWidgets/QGroupBox> +#include <QtWidgets/QButtonGroup> +#include <QtWidgets/QRadioButton> using namespace measurement_utils; diff --git a/qt/preferences_dialog.hpp b/qt/preferences_dialog.hpp index 3442344b4d..97d528bc98 100644 --- a/qt/preferences_dialog.hpp +++ b/qt/preferences_dialog.hpp @@ -3,11 +3,7 @@ #include "std/string.hpp" #include <QtWidgets/QApplication> -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - #include <QtGui/QDialog> -#else - #include <QtWidgets/QDialog> -#endif +#include <QtWidgets/QDialog> class QTableWidget; class QButtonGroup; @@ -18,6 +18,17 @@ map_designer { TARGET = MAPS.ME } +map_designer { + CP_MDPI = $$system(cp -rf $$PWD/../data/resources-mdpi_clear $$PWD/../data/resources-mdpi_design) + CP_HDPI = $$system(cp -rf $$PWD/../data/resources-hdpi_clear $$PWD/../data/resources-hdpi_design) + CP_XHDPI = $$system(cp -rf $$PWD/../data/resources-xhdpi_clear $$PWD/../data/resources-xhdpi_design) + CP_XXHDPI = $$system(cp -rf $$PWD/../data/resources-xxhdpi_clear $$PWD/../data/resources-xxhdpi_design) + CP_6PLUS = $$system(cp -rf $$PWD/../data/resources-6plus_clear $$PWD/../data/resources-6plus_design) + CP_DRULES = $$system(cp -f $$PWD/../data/drules_proto_clear.bin $$PWD/../data/drules_proto_design.bin) + CP_COLORS = $$system(cp -f $$PWD/../data/colors.txt $$PWD/../data/colors_design.txt) + CP_PATTERNS = $$system(cp -f $$PWD/../data/patterns.txt $$PWD/../data/patterns_design.txt) +} + TEMPLATE = app CONFIG += warn_on QT *= core widgets gui opengl @@ -88,6 +99,53 @@ MDPI_SKIN_RES.files = ../data/resources-mdpi_clear/symbols.sdf ../data/resources XHDPI_SKIN_RES.path = $$DATADIR/resources-xhdpi_clear XHDPI_SKIN_RES.files = ../data/resources-xhdpi_clear/symbols.sdf ../data/resources-xhdpi_clear/symbols.png +map_designer { + DESIGN_TOOL_RES.path = $$DATADIR + DESIGN_TOOL_RES.files = ../data/drules_proto_design.bin \ + ../data/colors_design.txt \ + ../data/patterns_design.txt + + DESIGN_TOOL_MDPI_RES.path = $$DATADIR/resources-mdpi_design + DESIGN_TOOL_MDPI_RES.files = ../data/resources-mdpi_design/symbols.png \ + ../data/resources-mdpi_design/symbols.sdf \ + ../data/resources-mdpi_design/symbols-ad.png \ + ../data/resources-mdpi_design/symbols-ad.sdf \ + ../data/resources-mdpi_design/area-hatching.png \ + ../data/resources-mdpi_design/traffic-arrow.png + + DESIGN_TOOL_HDPI_RES.path = $$DATADIR/resources-hdpi_design + DESIGN_TOOL_HDPI_RES.files = ../data/resources-hdpi_design/symbols.png \ + ../data/resources-hdpi_design/symbols.sdf \ + ../data/resources-hdpi_design/symbols-ad.png \ + ../data/resources-hdpi_design/symbols-ad.sdf \ + ../data/resources-hdpi_design/area-hatching.png \ + ../data/resources-hdpi_design/traffic-arrow.png + + DESIGN_TOOL_XHDPI_RES.path = $$DATADIR/resources-xhdpi_design + DESIGN_TOOL_XHDPI_RES.files = ../data/resources-xhdpi_design/symbols.png \ + ../data/resources-xhdpi_design/symbols.sdf \ + ../data/resources-xhdpi_design/symbols-ad.png \ + ../data/resources-xhdpi_design/symbols-ad.sdf \ + ../data/resources-xhdpi_design/area-hatching.png \ + ../data/resources-xhdpi_design/traffic-arrow.png + + DESIGN_TOOL_XXHDPI_RES.path = $$DATADIR/resources-xxhdpi_design + DESIGN_TOOL_XXHDPI_RES.files = ../data/resources-xxhdpi_design/symbols.png \ + ../data/resources-xxhdpi_design/symbols.sdf \ + ../data/resources-xxhdpi_design/symbols-ad.png \ + ../data/resources-xxhdpi_design/symbols-ad.sdf \ + ../data/resources-xxhdpi_design/area-hatching.png \ + ../data/resources-xxhdpi_design/traffic-arrow.png + + DESIGN_TOOL_6PLUS_RES.path = $$DATADIR/resources-6plus_design + DESIGN_TOOL_6PLUS_RES.files = ../data/resources-6plus_design/symbols.png \ + ../data/resources-6plus_design/symbols.sdf \ + ../data/resources-6plus_design/symbols-ad.png \ + ../data/resources-6plus_design/symbols-ad.sdf \ + ../data/resources-6plus_design/area-hatching.png \ + ../data/resources-6plus_design/traffic-arrow.png +} + FONT_RES.path = $$FONTSDIR FONT_RES.files = ../data/01_dejavusans.ttf \ ../data/02_droidsans-fallback.ttf \ @@ -108,6 +166,10 @@ MWM_RES.path = $$DATADIR MWM_RES.files = ../data/World.mwm ../data/WorldCoasts.mwm ALL_RESOURCES = OTHER_RES CLASSIFICATOR_RES MDPI_SKIN_RES XHDPI_SKIN_RES FONT_RES MWM_RES ICU_RES +map_designer { + ALL_RESOURCES += DESIGN_TOOL_RES DESIGN_TOOL_MDPI_RES DESIGN_TOOL_HDPI_RES DESIGN_TOOL_XHDPI_RES \ + DESIGN_TOOL_XXHDPI_RES DESIGN_TOOL_6PLUS_RES +} #ALL_RESOURCES += DEFAULT_SKIN_RES linux* { diff --git a/qt/search_panel.cpp b/qt/search_panel.cpp index 87de683290..52111c8573 100644 --- a/qt/search_panel.cpp +++ b/qt/search_panel.cpp @@ -15,26 +15,14 @@ #include <functional> #include <QtCore/QTimer> - #include <QtGui/QBitmap> - -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - #include <QtGui/QHeaderView> - #include <QtGui/QTableWidget> - #include <QtGui/QLineEdit> - #include <QtGui/QVBoxLayout> - #include <QtGui/QHBoxLayout> - #include <QtGui/QPushButton> - #include <QtGui/QLabel> -#else - #include <QtWidgets/QHeaderView> - #include <QtWidgets/QTableWidget> - #include <QtWidgets/QLineEdit> - #include <QtWidgets/QVBoxLayout> - #include <QtWidgets/QHBoxLayout> - #include <QtWidgets/QPushButton> - #include <QtWidgets/QLabel> -#endif +#include <QtWidgets/QHeaderView> +#include <QtWidgets/QTableWidget> +#include <QtWidgets/QLineEdit> +#include <QtWidgets/QVBoxLayout> +#include <QtWidgets/QHBoxLayout> +#include <QtWidgets/QPushButton> +#include <QtWidgets/QLabel> namespace qt { @@ -55,11 +43,7 @@ SearchPanel::SearchPanel(DrawWidget * drawWidget, QWidget * parent) m_pTable->setSelectionBehavior(QAbstractItemView::SelectRows); m_pTable->verticalHeader()->setVisible(false); m_pTable->horizontalHeader()->setVisible(false); -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - m_pTable->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); -#else m_pTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); -#endif connect(m_pTable, SIGNAL(cellClicked(int, int)), this, SLOT(OnSearchPanelItemClicked(int,int))); diff --git a/qt/search_panel.hpp b/qt/search_panel.hpp index 2dfac7e0b2..26bb25f60d 100644 --- a/qt/search_panel.hpp +++ b/qt/search_panel.hpp @@ -9,12 +9,7 @@ #include <vector> #include <QtGui/QPixmap> - -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - #include <QtGui/QWidget> -#else - #include <QtWidgets/QWidget> -#endif +#include <QtWidgets/QWidget> class QTableWidget; class QLineEdit; diff --git a/qt/update_dialog.cpp b/qt/update_dialog.cpp index 4576a837e4..1fe2d25a99 100644 --- a/qt/update_dialog.cpp +++ b/qt/update_dialog.cpp @@ -400,13 +400,8 @@ namespace qt m_tree->sortByColumn(KColumnIndexCountry, Qt::AscendingOrder); m_tree->setSortingEnabled(true); -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - m_tree->header()->setResizeMode(KColumnIndexCountry, QHeaderView::ResizeToContents); - m_tree->header()->setResizeMode(KColumnIndexStatus, QHeaderView::ResizeToContents); -#else m_tree->header()->setSectionResizeMode(KColumnIndexCountry, QHeaderView::ResizeToContents); m_tree->header()->setSectionResizeMode(KColumnIndexStatus, QHeaderView::ResizeToContents); -#endif } void UpdateDialog::OnCountryChanged(TCountryId const & countryId) diff --git a/qt/update_dialog.hpp b/qt/update_dialog.hpp index bcc03b3b43..2d958e233d 100644 --- a/qt/update_dialog.hpp +++ b/qt/update_dialog.hpp @@ -6,11 +6,7 @@ #include "std/vector.hpp" #include <QtWidgets/QApplication> -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - #include <QtGui/QDialog> -#else - #include <QtWidgets/QDialog> -#endif +#include <QtWidgets/QDialog> class QTreeWidget; class QTreeWidgetItem; |