mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-28 20:25:34 +08:00
Ref T554, trigger auto publish dialog when shutting down
This commit is contained in:
@@ -161,8 +161,18 @@ void SwiftGuiStd::closeEvent(QCloseEvent *event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->triggerAutoPublishDialog())
|
||||||
|
{
|
||||||
|
event->ignore();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// save settings
|
// save settings
|
||||||
if (sGui->showCloseDialog(this, event) == QDialog::Rejected) { return; }
|
if (sGui->showCloseDialog(this, event) == QDialog::Rejected)
|
||||||
|
{
|
||||||
|
// already ignored
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this->performGracefulShutdown();
|
this->performGracefulShutdown();
|
||||||
}
|
}
|
||||||
@@ -554,3 +564,29 @@ void SwiftGuiStd::onShowOverlayInlineTextMessageCallsign(const CCallsign &callsi
|
|||||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||||
ui->fr_CentralFrameInside->showOverlayInlineTextMessage(callsign);
|
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