1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-09-10 12:03:18 +02:00

Donation campaign: add toggleswitch setting

GitLab: #1334
Change-Id: Ic0e2a4b08db7228e4a4bdab665f53adfa581e16c
This commit is contained in:
lcoursodon 2023-09-27 11:34:30 -04:00
parent 9d3b5cd0c5
commit 55415d6062
5 changed files with 41 additions and 13 deletions

View file

@ -64,7 +64,10 @@ extern const QString defaultDownloadPath;
X(ShowMardownOption, false) \
X(ChatViewEnterIsNewLine, false) \
X(ShowSendOption, false) \
X(DonateVisibleDate, "2999-02-01 05:00")
X(DonationVisibleDate, "2023-11-01 05:00") \
X(IsDonationVisible, true) \
X(DonationEndDate, "2024-01-01 00:00")
/*
* A class to expose settings keys in both c++ and QML.
* Note: this is using a non-constructable class instead of a

View file

@ -72,7 +72,11 @@ Item {
}
function isDonationBannerVisible() {
// The banner is visible if the current date is after the date set in the settings
return new Date() > new Date(Date.parse(UtilsAdapter.getAppValue(Settings.Key.DonateVisibleDate)));
// The banner is visible if the current date is after the date set in the settings and before the end date
// And if the donation toggle is checked
var isDonationVisible = UtilsAdapter.getAppValue(Settings.Key.IsDonationVisible);
var endDonationDate = new Date(Date.parse(UtilsAdapter.getAppValue(Settings.Key.DonationEndDate)));
var donationVisibleDate = new Date(Date.parse(UtilsAdapter.getAppValue(Settings.Key.DonationVisibleDate)));
return new Date() < endDonationDate && new Date() > donationVisibleDate && isDonationVisible;
}
}

View file

@ -843,4 +843,5 @@ Item {
property string donation: qsTr("Donate")
property string donationText: qsTr("If you enjoy using Jami and believe in our mission, would you make a donation?")
property string notNow: qsTr("Not now")
property string enableDonation: qsTr("Enable donation campaign")
}

View file

@ -109,8 +109,7 @@ Rectangle {
anchors.fill: parent
onClicked: {
// When the user clicks on "Not now", we set the donation date to 7 days from now (1 for the test)
// TODO reset to 7 days
UtilsAdapter.setAppValue(Settings.Key.DonateVisibleDate, new Date(new Date().getTime() + 1 * 24 * 60 * 60 * 1000).toISOString().slice(0, 16).replace("T", " "));
UtilsAdapter.setAppValue(Settings.Key.DonationVisibleDate, new Date(new Date().getTime() + 7 * 24 * 60 * 60 * 1000).toISOString().slice(0, 16).replace("T", " "));
donation.donationVisible = Qt.binding(() => JamiQmlUtils.isDonationBannerVisible());
}
}

View file

@ -49,11 +49,13 @@ SettingsPageBase {
anchors.left: parent.left
anchors.leftMargin: JamiTheme.preferredSettingsMarginSize
ColumnLayout {
Column {
id: enableAccount
width: parent.width
spacing: 10
FolderDialog {
id: downloadPathDialog
@ -71,7 +73,7 @@ SettingsPageBase {
ToggleSwitch {
id: notificationCheckBox
Layout.fillWidth: true
width: parent.width
checked: UtilsAdapter.getAppValue(Settings.EnableNotifications)
labelText: JamiStrings.showNotifications
@ -79,9 +81,25 @@ SettingsPageBase {
onSwitchToggled: UtilsAdapter.setAppValue(Settings.Key.EnableNotifications, checked)
}
ToggleSwitch {
id: enableDonation
width: parent.width
visible: new Date() >= new Date(Date.parse("2023-11-01"))
checked: UtilsAdapter.getAppValue(Settings.Key.IsDonationVisible)
labelText: JamiStrings.enableDonation
tooltipText: JamiStrings.enableDonation
onSwitchToggled: {
UtilsAdapter.setAppValue(Settings.Key.IsDonationVisible, checked);
if (checked) {
UtilsAdapter.setToDefault(Settings.Key.DonationVisibleDate);
}
}
}
ToggleSwitch {
id: closeOrMinCheckBox
Layout.fillWidth: true
width: parent.width
visible: UtilsAdapter.isSystemTrayIconVisible()
checked: UtilsAdapter.getAppValue(Settings.MinimizeOnClose) && UtilsAdapter.isSystemTrayIconVisible()
@ -91,7 +109,7 @@ SettingsPageBase {
ToggleSwitch {
id: applicationOnStartUpCheckBox
Layout.fillWidth: true
width: parent.width
checked: UtilsAdapter.checkStartupLink()
labelText: JamiStrings.runStartup
@ -100,8 +118,8 @@ SettingsPageBase {
}
RowLayout {
Layout.fillWidth: true
Layout.minimumHeight: JamiTheme.preferredFieldHeight
width: parent.width
height: JamiTheme.preferredFieldHeight
Text {
Layout.fillWidth: true
@ -138,8 +156,8 @@ SettingsPageBase {
SettingsComboBox {
id: langComboBoxSetting
Layout.fillWidth: true
Layout.preferredHeight: JamiTheme.preferredFieldHeight
width: parent.width
height: JamiTheme.preferredFieldHeight
labelText: JamiStrings.language
tipText: JamiStrings.language
@ -245,6 +263,9 @@ SettingsPageBase {
UtilsAdapter.setToDefault(Settings.Key.MinimizeOnClose);
UtilsAdapter.setToDefault(Settings.Key.LANG);
UtilsAdapter.setToDefault(Settings.Key.EnableExperimentalSwarm);
UtilsAdapter.setToDefault(Settings.Key.IsDonationVisible);
UtilsAdapter.setToDefault(Settings.Key.DonationVisibleDate);
enableDonation.checked = Qt.binding(() => UtilsAdapter.getAppValue(Settings.Key.IsDonationVisible));
}
}
}