mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
Ref T554, trigger auto publish dialog when shutting down
This commit is contained in:
committed by
Mat Sutcliffe
parent
7b03ed5aec
commit
9753173c9f
@@ -161,8 +161,18 @@ void SwiftGuiStd::closeEvent(QCloseEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->triggerAutoPublishDialog())
|
||||
{
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
// save settings
|
||||
if (sGui->showCloseDialog(this, event) == QDialog::Rejected) { return; }
|
||||
if (sGui->showCloseDialog(this, event) == QDialog::Rejected)
|
||||
{
|
||||
// already ignored
|
||||
return;
|
||||
}
|
||||
}
|
||||
this->performGracefulShutdown();
|
||||
}
|
||||
@@ -554,3 +564,29 @@ void SwiftGuiStd::onShowOverlayInlineTextMessageCallsign(const CCallsign &callsi
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
ui->fr_CentralFrameInside->showOverlayInlineTextMessage(callsign);
|
||||
}
|
||||
|
||||
bool SwiftGuiStd::triggerAutoPublishDialog()
|
||||
{
|
||||
if (!CAutoPublishData::existAutoPublishFiles()) { return false; }
|
||||
|
||||
constexpr qint64 deltaT = 48 * 60 * 60 * 1000;
|
||||
const qint64 lastDialogTs = m_lastAutoPublish.get();
|
||||
bool showAutoPublish = lastDialogTs < 0 || (QDateTime::currentMSecsSinceEpoch() - lastDialogTs) > deltaT;
|
||||
if (!showAutoPublish) { return false; }
|
||||
|
||||
const QMessageBox::StandardButton reply = QMessageBox::question(
|
||||
this,
|
||||
QStringLiteral("Upload data?"),
|
||||
QStringLiteral("Do you want to help improving swift by uploading anonymized data?"),
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
|
||||
if (reply != QMessageBox::Yes)
|
||||
{
|
||||
m_lastAutoPublish.set(QDateTime::currentMSecsSinceEpoch());
|
||||
return false;
|
||||
}
|
||||
|
||||
this->autoPublishDialog(); // updates m_lastAutoPublish
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user