From c1df66f28d1a55b90b636ad005d19f804578ab68 Mon Sep 17 00:00:00 2001 From: Andreas Traczyk Date: Fri, 1 Dec 2023 16:34:51 -0500 Subject: [PATCH] manual Revert "Revert "app Store: disable donations"" Appstore is refusing the donations-enabled build for now. Change-Id: I16d9cc33ed577298565a5d92e0ee247ee54865a8 --- CMakeLists.txt | 1 + src/app/appsettingsmanager.h | 24 +++++++++++++------ src/app/mainapplication.cpp | 7 ++++++ .../components/SystemSettingsPage.qml | 2 +- src/app/tipsmodel.cpp | 3 +++ src/app/utilsadapter.h | 8 ++++--- 6 files changed, 34 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d9c9c51a..5fa7344b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -798,6 +798,7 @@ else() MACOSX_BUNDLE_COPYRIGHT "${PROJ_COPYRIGHT}") if(APPSTORE) message(STATUS "app store version") + add_definitions(-DAPPSTORE) set_target_properties(${PROJECT_NAME} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${CMAKE_CURRENT_SOURCE_DIR}/resources/entitlements/appstore/Jami.entitlements") else() diff --git a/src/app/appsettingsmanager.h b/src/app/appsettingsmanager.h index 826472cc..a12709ea 100644 --- a/src/app/appsettingsmanager.h +++ b/src/app/appsettingsmanager.h @@ -20,20 +20,21 @@ #pragma once -#include "utils.h" - #include #include #include #include #include // for QWindow::AutomaticVisibility +#include +#include #include extern const QString defaultDownloadPath; // clang-format off -#define KEYS \ +// Common key-value pairs for both APPSTORE and non-APPSTORE builds +#define COMMON_KEYS \ X(MinimizeOnClose, false) \ X(DownloadPath, defaultDownloadPath) \ X(ScreenshotPath, {}) \ @@ -64,11 +65,19 @@ extern const QString defaultDownloadPath; X(ShowMardownOption, false) \ X(ChatViewEnterIsNewLine, false) \ X(ShowSendOption, false) \ - X(Donation2023VisibleDate, "2023-11-27 05:00") \ - X(IsDonationVisible, true) \ - X(Donation2023EndDate, "2024-01-31 00:00") \ X(EnablePtt, false) \ X(PttKeys, 32) +#ifdef APPSTORE +#define KEYS COMMON_KEYS +#else +// Additional key-value pairs for non-APPSTORE builds including donation +// related settings. +#define KEYS COMMON_KEYS \ + X(Donation2023VisibleDate, "2023-11-27 05:00") \ + X(IsDonationVisible, true) \ + X(Donation2023EndDate, "2024-01-31 00:00") +#endif + /* * A class to expose settings keys in both c++ and QML. * Note: this is using a non-constructable class instead of a @@ -106,8 +115,9 @@ public: default: return {}; } } + private: - Settings() = delete; + Settings() = delete; }; Q_DECLARE_METATYPE(Settings::Key) // clang-format on diff --git a/src/app/mainapplication.cpp b/src/app/mainapplication.cpp index ded566d6..6594e8eb 100644 --- a/src/app/mainapplication.cpp +++ b/src/app/mainapplication.cpp @@ -200,12 +200,19 @@ MainApplication::init() auto startMinimizedSetting = settingsManager_->getValue(Settings::Key::StartMinimized).toBool(); // The presence of start URI should override the startMinimized setting for this instance. set_startMinimized(startMinimizedSetting && runOptions_[Option::StartUri].isNull()); + #ifdef WITH_WEBENGINE engine_.get()->rootContext()->setContextProperty("WITH_WEBENGINE", QVariant(true)); #else engine_.get()->rootContext()->setContextProperty("WITH_WEBENGINE", QVariant(false)); #endif +#ifdef APPSTORE + engine_.get()->rootContext()->setContextProperty("APPSTORE", QVariant(true)); +#else + engine_.get()->rootContext()->setContextProperty("APPSTORE", QVariant(false)); +#endif + initQmlLayer(); settingsManager_->setValue(Settings::Key::StartMinimized, diff --git a/src/app/settingsview/components/SystemSettingsPage.qml b/src/app/settingsview/components/SystemSettingsPage.qml index a637c870..07d800de 100644 --- a/src/app/settingsview/components/SystemSettingsPage.qml +++ b/src/app/settingsview/components/SystemSettingsPage.qml @@ -84,7 +84,7 @@ SettingsPageBase { ToggleSwitch { id: enableDonation Layout.fillWidth: true - visible: new Date() >= new Date(Date.parse("2023-11-01")) + visible: (new Date() >= new Date(Date.parse("2023-11-01")) && !APPSTORE) checked: UtilsAdapter.getAppValue(Settings.Key.IsDonationVisible) labelText: JamiStrings.enableDonation diff --git a/src/app/tipsmodel.cpp b/src/app/tipsmodel.cpp index 914713a6..516a77bc 100644 --- a/src/app/tipsmodel.cpp +++ b/src/app/tipsmodel.cpp @@ -75,10 +75,13 @@ TipsModel::reset() beginResetModel(); tips_.clear(); +#ifndef APPSTORE QDate date = QDate::currentDate(); if (date >= QDate::fromString("2023-11-27", "yyyy-MM-dd")) { tips_.append({{"id", "14"}, {"title", tr("Donate")}, {"desc", ""}, {"type", "donation"}}); } +#endif + tips_.append({{"id", "0"}, {"title", tr("Customize")}, {"desc", ""}, {"type", "customize"}}); tips_.append({{"id", "13"}, {"title", tr("Backup account")}, {"desc", ""}, {"type", "backup"}}); tips_.append({{"id", "1"}, diff --git a/src/app/utilsadapter.h b/src/app/utilsadapter.h index 33c10541..7bafca68 100644 --- a/src/app/utilsadapter.h +++ b/src/app/utilsadapter.h @@ -22,13 +22,15 @@ #pragma once -#include -#include - #include "qmladapterbase.h" #include "appsettingsmanager.h" #include "qtutils.h" +#include + +#include +#include + #if __has_include() #include #endif