summaryrefslogtreecommitdiff
path: root/src/rateapp.cpp
diff options
context:
space:
mode:
authorLibravatar Mubashshir <[email protected]>2023-09-19 02:01:41 +0600
committerLibravatar Mubashshir <[email protected]>2023-09-19 02:01:41 +0600
commit36d10b4b6359b5cf3ff0e37f2330dfaf91cbf530 (patch)
treecad68505e3dcff4e8d37c5a6a052240d8a935efb /src/rateapp.cpp
parent35d85d38d02d97e1c63729bb3301f46bb6f96728 (diff)
parent906ca7eb436dc9944d43f5b7f6ae7b44afc2a3e7 (diff)
downloadwhatsie-36d10b4b6359b5cf3ff0e37f2330dfaf91cbf530.tar.gz
whatsie-36d10b4b6359b5cf3ff0e37f2330dfaf91cbf530.zip
Update upstream source from tag 'upstream/4.14.1'
Update to upstream version '4.14.1' with Debian dir 267b96a979689ac47077c72b576cf79da29f8ff2
Diffstat (limited to 'src/rateapp.cpp')
-rw-r--r--src/rateapp.cpp56
1 files changed, 40 insertions, 16 deletions
diff --git a/src/rateapp.cpp b/src/rateapp.cpp
index 5c370a9..c258c37 100644
--- a/src/rateapp.cpp
+++ b/src/rateapp.cpp
@@ -22,7 +22,7 @@ RateApp::RateApp(QWidget *parent, QString app_rating_url, int app_launch_count,
showTimer = new QTimer(this);
showTimer->setInterval(this->present_delay);
- connect(showTimer, &QTimer::timeout, [=]() {
+ connect(showTimer, &QTimer::timeout, this, [=]() {
qDebug() << "Rate timer timeout";
emit showRateDialog();
if (this->isVisible())
@@ -30,15 +30,26 @@ RateApp::RateApp(QWidget *parent, QString app_rating_url, int app_launch_count,
});
// increase the app_launched_count by one
- int app_launched = settings.value("app_launched_count", 0).toInt();
- settings.setValue("app_launched_count", app_launched + 1);
+ int app_launched = SettingsManager::instance()
+ .settings()
+ .value("app_launched_count", 0)
+ .toInt();
+ SettingsManager::instance().settings().setValue("app_launched_count",
+ app_launched + 1);
// check if app install time is set in settings
- if (settings.value("app_install_time").isNull()) {
- settings.setValue("app_install_time", QDateTime::currentSecsSinceEpoch());
-
- } else if (settings.value("app_install_time").isValid()) {
- //qDebug() << "RATEAPP should show:" << shouldShow();
+ if (SettingsManager::instance()
+ .settings()
+ .value("app_install_time")
+ .isNull()) {
+ SettingsManager::instance().settings().setValue(
+ "app_install_time", QDateTime::currentSecsSinceEpoch());
+
+ } else if (SettingsManager::instance()
+ .settings()
+ .value("app_install_time")
+ .isValid()) {
+ // qDebug() << "RATEAPP should show:" << shouldShow();
if (shouldShow()) {
showTimer->start();
} else {
@@ -49,7 +60,10 @@ RateApp::RateApp(QWidget *parent, QString app_rating_url, int app_launch_count,
}
// if already reated delete this obj to free resources
- if (settings.value("rated_already", false).toBool()) {
+ if (SettingsManager::instance()
+ .settings()
+ .value("rated_already", false)
+ .toBool()) {
this->deleteLater();
}
}
@@ -70,10 +84,19 @@ void RateApp::delayShowEvent() {
*/
bool RateApp::shouldShow() {
bool shouldShow = false;
- int app_launched_count = settings.value("app_launched_count", 0).toInt();
+ int app_launched_count = SettingsManager::instance()
+ .settings()
+ .value("app_launched_count", 0)
+ .toInt();
qint64 currentDateTime = QDateTime::currentSecsSinceEpoch();
- qint64 installed_date_time = settings.value("app_install_time").toLongLong();
- bool ratedAlready = settings.value("rated_already", false).toBool();
+ qint64 installed_date_time = SettingsManager::instance()
+ .settings()
+ .value("app_install_time")
+ .toLongLong();
+ bool ratedAlready = SettingsManager::instance()
+ .settings()
+ .value("rated_already", false)
+ .toBool();
if (ratedAlready) // return false if already reated;
return false;
@@ -99,7 +122,7 @@ void RateApp::on_rateNowBtn_clicked() {
}
void RateApp::on_alreadyDoneBtn_clicked() {
- settings.setValue("rated_already", true);
+ SettingsManager::instance().settings().setValue("rated_already", true);
this->close();
}
@@ -109,9 +132,10 @@ void RateApp::on_laterBtn_clicked() {
}
void RateApp::reset() {
- settings.setValue("rated_already", false);
- settings.setValue("app_launched_count", 0);
- settings.setValue("app_install_time", QDateTime::currentSecsSinceEpoch());
+ SettingsManager::instance().settings().setValue("rated_already", false);
+ SettingsManager::instance().settings().setValue("app_launched_count", 0);
+ SettingsManager::instance().settings().setValue(
+ "app_install_time", QDateTime::currentSecsSinceEpoch());
}
void RateApp::on_rateOnGithub_clicked() {