[feat] add a one-time sponsorship prompt

This commit is contained in:
dijunkun
2026-10-19 17:39:50 +08:00
parent 9661d56ed5
commit e7a49361f7
6 changed files with 125 additions and 4 deletions
@@ -131,6 +131,8 @@ int ConfigCenter::Load() {
portable_service_prompt_suppressed_ =
ini_->GetBoolValue(section_, "portable_service_prompt_suppressed",
portable_service_prompt_suppressed_);
sponsorship_prompt_dismissed_ =
ini_->GetBoolValue(section_, "sponsorship_prompt_dismissed", false);
const char* file_transfer_save_path_value =
ini_->GetValue(section_, "file_transfer_save_path", nullptr);
@@ -221,6 +223,8 @@ int ConfigCenter::Save() {
save_remote_previews_.load());
ini_->SetBoolValue(section_, "portable_service_prompt_suppressed",
portable_service_prompt_suppressed_);
ini_->SetBoolValue(section_, "sponsorship_prompt_dismissed",
sponsorship_prompt_dismissed_);
ini_->SetValue(section_, "file_transfer_save_path",
file_transfer_save_path_.c_str());
@@ -395,6 +399,15 @@ int ConfigCenter::SetPortableServicePromptSuppressed(bool suppressed) {
return 0;
}
int ConfigCenter::SetSponsorshipPromptDismissed(bool dismissed) {
if (StoreValues({{"sponsorship_prompt_dismissed",
dismissed ? "true" : "false"}}) != 0) {
return -1;
}
sponsorship_prompt_dismissed_ = dismissed;
return 0;
}
// getters
ConfigCenter::LANGUAGE ConfigCenter::GetLanguage() const { return language_; }
@@ -463,6 +476,10 @@ bool ConfigCenter::IsPortableServicePromptSuppressed() const {
return portable_service_prompt_suppressed_;
}
bool ConfigCenter::IsSponsorshipPromptDismissed() const {
return sponsorship_prompt_dismissed_;
}
int ConfigCenter::SetFileTransferSavePath(const std::string& path) {
if (path.size() >= 512 || std::any_of(path.begin(), path.end(), [](unsigned char c) { return c < 32 || c == 127; })) return -1;
std::lock_guard<std::mutex> lock(file_path_mutex_);
@@ -1,7 +1,7 @@
/*
* @Author: DI JUNKUN
* @Date: 2024-05-29
* Copyright (c) 2024 by DI JUNKUN, All Rights Reserved.
* Copyright (c) 2026 by DI JUNKUN, All Rights Reserved.
*/
#ifndef _CONFIG_CENTER_H_
@@ -49,6 +49,7 @@ class ConfigCenter {
int SetPrivacyScreen(bool enable_privacy_screen);
int SetSaveRemotePreviews(bool enabled);
int SetPortableServicePromptSuppressed(bool suppressed);
int SetSponsorshipPromptDismissed(bool dismissed);
int SetFileTransferSavePath(const std::string& path);
// read config
@@ -73,6 +74,7 @@ class ConfigCenter {
bool IsEnablePrivacyScreen() const;
bool IsSaveRemotePreviews() const;
bool IsPortableServicePromptSuppressed() const;
bool IsSponsorshipPromptDismissed() const;
std::string GetFileTransferSavePath() const;
int Load();
@@ -102,6 +104,7 @@ class ConfigCenter {
std::atomic<bool> enable_privacy_screen_{true};
std::atomic<bool> save_remote_previews_{true};
bool portable_service_prompt_suppressed_ = false;
bool sponsorship_prompt_dismissed_ = false;
std::string file_transfer_save_path_ = "";
};
} // namespace crossdesk