Avoid polling if the Qt window is minimized

This commit is contained in:
Cameron Gutman
2018-08-13 19:47:42 -07:00
parent 860d317330
commit f3309087ab
4 changed files with 23 additions and 29 deletions
+1 -17
View File
@@ -2,6 +2,7 @@ import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Dialogs 1.3
import QtQuick.Layouts 1.3
import QtQuick.Window 2.2
import ComputerModel 1.0
@@ -42,25 +43,11 @@ GridView {
}
}
onVisibleChanged: {
if (visible) {
// Start polling when this view is shown
ComputerManager.startPolling()
}
else {
// Stop polling when this view is not top-most
ComputerManager.stopPollingAsync()
}
}
function pairingComplete(error)
{
// Close the PIN dialog
pairDialog.close()
// Start polling again
ComputerManager.startPolling()
// Display a failed dialog if we got an error
if (error !== null) {
errorDialog.text = error
@@ -176,9 +163,6 @@ GridView {
if (!model.busy) {
var pin = ("0000" + Math.floor(Math.random() * 10000)).slice(-4)
// Stop polling, since pairing may make GFE unresponsive
ComputerManager.stopPollingAsync()
// Kick off pairing in the background
computerModel.pairComputer(index, pin)