diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 3590c862a..95ab4fe63 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -41,6 +41,7 @@ set(MM_SRCS position/mapposition.cpp position/positiondirection.cpp position/positionkit.cpp + appcustomisation.cpp activelayer.cpp activeproject.cpp androidutils.cpp @@ -123,6 +124,7 @@ set(MM_HDRS position/mapposition.h position/positiondirection.h position/positionkit.h + appcustomisation.h activelayer.h activeproject.h androidutils.h diff --git a/app/appcustomisation.cpp b/app/appcustomisation.cpp new file mode 100644 index 000000000..8aeb0b03a --- /dev/null +++ b/app/appcustomisation.cpp @@ -0,0 +1,17 @@ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "appcustomisation.h" + +AppCustomisation::AppCustomisation( QObject *parent ): QObject( parent ) +{ + // This file will have only empty contructor in main production MM app; + // in whitelabelled apps it will have the overriden properties like AC_ORG_NAME + mValues[AC_ORG_NAME] = "blabllba"; +} diff --git a/app/appcustomisation.h b/app/appcustomisation.h new file mode 100644 index 000000000..294f02d68 --- /dev/null +++ b/app/appcustomisation.h @@ -0,0 +1,48 @@ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef APPCUSTOMISATION_H +#define APPCUSTOMISATION_H + +#include +#include +#include +#include +#include + +// Like this or pure string in code? If we use AC_* (like App Customization, ..) +// then at least we have here list of all entries that could be whitelabeled? +const QString AC_ORG_NAME = QStringLiteral("organizationName"); + +class AppCustomisation: public QObject +{ + public: + explicit AppCustomisation( QObject *parent = nullptr ); + Q_INVOKABLE QString value( const QString &key, const QString &defaultValue ) {return getValue(key, defaultValue);} + Q_INVOKABLE QColor color( const QString &key, const QColor &defaultValue ){return getValue(key, defaultValue);} + + // maybe for some on -off things like allow switching default server (so in the QML we can read this and do not need to patch the file) + Q_INVOKABLE bool boolean( const QString &key, bool defaultValue ){return getValue(key, defaultValue);} + + private: + // Template, ou yeah! + template T getValue(const QString &key, const T &defaultValue ) + { + const auto it = mValues.find(key); + if (it == mValues.constEnd()) { + return defaultValue; + } else { + return it->value(); + } + } + + QHash mValues; +}; + +#endif // APPCUSTOMISATION_H diff --git a/app/main.cpp b/app/main.cpp index 4462bc4b3..93220b20d 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -27,6 +27,7 @@ #include "test/inputtests.h" #endif #include +#include "appcustomisation.h" #include #include "qgsconfig.h" #include "qgsproviderregistry.h" @@ -380,9 +381,11 @@ int main( int argc, char *argv[] ) { QgsApplication app( argc, argv, true ); + AppCustomisation appCustomisation; + const QString version = CoreUtils::appVersion(); // Set up the QSettings environment must be done after qapp is created - QCoreApplication::setOrganizationName( "Lutra Consulting" ); + QCoreApplication::setOrganizationName( appCustomisation.value(AC_ORG_NAME, "Lutra Consulting") ); QCoreApplication::setOrganizationDomain( "lutraconsulting.co.uk" ); QCoreApplication::setApplicationName( "Input" ); // used by QSettings QCoreApplication::setApplicationVersion( version ); diff --git a/app/mmstyle.h b/app/mmstyle.h index 0b548ad7f..360f0d269 100644 --- a/app/mmstyle.h +++ b/app/mmstyle.h @@ -10,6 +10,8 @@ #ifndef MMSTYLE_H #define MMSTYLE_H +#include "appcustomisation.h" + #include #include #include @@ -337,7 +339,7 @@ class MMStyle: public QObject QFont p6() {return fontFactory( 12, false );} QFont p7() {return fontFactory( 10, false );} - QColor grassColor() {return QColor::fromString( "#73D19C" );} + QColor grassColor() {return colorFactory( "grass", "#73D19C" );} QColor forestColor() {return QColor::fromString( "#004C45" );} QColor nightColor() {return QColor::fromString( "#12181F" );} QColor polarColor() {return QColor::fromString( "#FFFFFF" );} @@ -739,6 +741,13 @@ class MMStyle: public QObject return f; } + QColor colorFactory( const QString& name, const QString& color ) + { + QColor defaultColor = QColor::fromString( color ); + return mAppCustomisation.color(name, defaultColor); + } + + AppCustomisation mAppCustomisation; // Add to constructor... qreal mDp; double mSafeAreaTop = 0;