[feat] show sponsorship prompt once per version

This commit is contained in:
dijunkun
2026-10-19 23:06:14 +08:00
parent e7a49361f7
commit 8a7de23c7f
6 changed files with 31 additions and 23 deletions
@@ -1267,7 +1267,7 @@ void GuiApplication::InitializeUi() {
#endif
ui_ = std::make_unique<SlintUi>();
ui_->sponsorship_prompt_pending =
!config_center_->IsSponsorshipPromptDismissed();
config_center_->GetSponsorshipPromptDismissedVersion() != CROSSDESK_VERSION;
ui_->video_presenter =
std::make_unique<SlintVideoPresenter>(*video_renderer_);
#if _WIN32
@@ -1752,7 +1752,7 @@ void GuiApplication::BindMainCallbacks(bool gallery_window) {
main->on_dismiss_sponsorship([this, main] {
main->set_sponsorship_open(false);
ui_->sponsorship_prompt_pending = false;
if (config_center_->SetSponsorshipPromptDismissed(true) != 0) {
if (config_center_->SetSponsorshipPromptDismissedVersion(CROSSDESK_VERSION) != 0) {
LOG_WARN("Could not save sponsorship prompt dismissal");
}
});
@@ -293,9 +293,9 @@ struct TranslationRow {
X(sponsorship_message, u8"如果 CrossDesk 对你有帮助,欢迎赞助支持项目的持续开发、跨平台测试与日常维护。感谢你的支持!", \
"If CrossDesk is useful to you, consider supporting its continued development, cross-platform testing, and maintenance. Thank you for your support!", \
u8"Если CrossDesk вам полезен, поддержите его дальнейшую разработку, тестирование на разных платформах и сопровождение. Спасибо за вашу поддержку!") \
X(sponsorship_dismiss_hint, u8"关闭后不再自动弹出,你仍可在「关于」中找到赞助入口。", \
"This prompt will not appear again after you close it. Sponsorship links remain available in About.", \
u8"После закрытия это окно больше не появится автоматически. Ссылки для поддержки останутся в разделе «О программе».") \
X(sponsorship_dismiss_hint, u8"关闭后本版本不再提示,升级后再次显示。赞助入口仍在「关于」中。", \
"Once closed, this prompt stays hidden until the version changes. Sponsorship links remain available in About.", \
u8"После закрытия это окно появится только при смене версии. Ссылки для поддержки останутся в разделе «О программе».") \
X(sponsor_via_afdian, u8"爱发电", "AFDIAN", "AFDIAN") \
X(notification, u8"通知", "Notification", u8"Уведомление") \
X(new_version, u8"新版本", "New version", u8"Новая версия") \
+6 -4
View File
@@ -2289,15 +2289,16 @@ export component MainWindow inherits Window {
width: min(480px, parent.width - 40px);
height: self.content-top + sponsorship-content.preferred-height + 24px;
title: UiStrings.sponsorship-title;
close-label: MessageStrings.close;
close => { root.dismiss-sponsorship(); }
show-close-button: false;
sponsorship-content := VerticalLayout {
x: 24px; y: parent.content-top;
width: parent.width - 48px; height: self.preferred-height;
padding: 0px; spacing: 18px;
padding: 0px; spacing: 20px;
Text {
text: UiStrings.sponsorship-message;
color: WorkbenchStyle.text; font-size: 13px; wrap: word-wrap;
color: WorkbenchStyle.text; font-size: 14px; wrap: word-wrap;
// Match message bodies' 1.5em line height for wrapped text.
font-family: "CrossDesk Message Spacing";
}
SponsorshipSection {
show-title: false;
@@ -2308,6 +2309,7 @@ export component MainWindow inherits Window {
Text {
text: UiStrings.sponsorship-dismiss-hint;
color: WorkbenchStyle.muted; font-size: 12px; wrap: word-wrap;
font-family: "CrossDesk Message Spacing";
}
Rectangle { height: 1px; background: WorkbenchStyle.separator; }
HorizontalLayout {
@@ -49,6 +49,7 @@ export component SettingsButton inherits Rectangle {
export component SettingsDialog inherits DialogSurface {
in property <string> title;
in property <string> close-label;
in property <bool> show-close-button: true;
in property <int> badge-count: 0;
in property <string> badge-label;
in property <string> header-status;
@@ -92,7 +93,7 @@ export component SettingsDialog inherits DialogSurface {
clicked => { root.action(); }
action-label-metrics := Text { visible: false; text: root.action-text; font-size: 12px; }
}
IconButton {
if root.show-close-button: IconButton {
width: 28px; height: 28px;
icon: FontAwesomeIcons.xmark; icon-size: 14px;
icon-color: WorkbenchStyle.muted;