-
Notifications
You must be signed in to change notification settings - Fork 2
Fix issues with Update Notifications.[CPP-569][CPP-586] #366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
john-michaelburke
merged 3 commits into
main
from
john-michaelburke/fix-update-notifications
Jan 17, 2022
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
import "Constants" | ||
import QtQuick 2.5 | ||
import QtQuick.Controls 2.15 | ||
import QtQuick.Layouts 1.15 | ||
import SwiftConsole 1.0 | ||
|
||
Item { | ||
id: updateTab | ||
|
||
property bool consoleVersionDialogAlready: false | ||
property bool firmwareVersionDialogAlready: false | ||
property bool v2DownloadDialogAlready: false | ||
property bool popupLock: false | ||
property int dialogWidthDivisor: 3 | ||
property int dialogHeightDivisor: 2 | ||
|
||
function consoleOutdatedDialogText(currentVersion, latestVersion) { | ||
let text = ""; | ||
text += "Current Console version:\n"; | ||
text += "\t" + currentVersion + "\n"; | ||
text += "Latest Console version:\n"; | ||
text += "\t" + latestVersion; | ||
return text; | ||
} | ||
|
||
function firmwareV2OutdatedDialogText() { | ||
let text = ""; | ||
text += "Upgrading to firmware v2.1.0 or later requires that the device be running "; | ||
text += "firmware v2.0.0 or later. Please upgrade to firmware version 2.0.0.\n\n"; | ||
text += "Would you like to download firmware version v2.0.0 now?\n"; | ||
return text; | ||
} | ||
|
||
function firmwareOutdatedDialogText(latestVersion) { | ||
let text = ""; | ||
text += "New Piksi firmware available.\n\n"; | ||
text += "Please use the Update tab to update.\n\n"; | ||
text += "Newest Firmware Version:\n"; | ||
text += "\t" + latestVersion + "\n"; | ||
return text; | ||
} | ||
|
||
Dialog { | ||
id: v2DownloadDialog | ||
|
||
anchors.centerIn: parent | ||
width: Globals.width / dialogWidthDivisor | ||
height: Globals.height / dialogHeightDivisor | ||
x: Globals.width / 2 - width / 2 | ||
y: Globals.height / 2 - height / 2 | ||
modal: true | ||
focus: true | ||
title: "Update to v2.0.0" | ||
standardButtons: Dialog.Ok | Dialog.Cancel | ||
onAccepted: { | ||
let downloadLatestFirmware = true; | ||
let updateFirmware = false; | ||
let sendFileToDevice = false; | ||
let serialPromptConfirm = false; | ||
let updateLocalFilepath = null; | ||
let downloadDirectory = null; | ||
let fileioLocalFilepath = null; | ||
let fileioDestinationFilepath = null; | ||
let updateLocalFilename = null; | ||
data_model.update_tab([downloadLatestFirmware, updateFirmware, sendFileToDevice, serialPromptConfirm], updateLocalFilepath, downloadDirectory, fileioLocalFilepath, fileioDestinationFilepath, updateLocalFilename); | ||
} | ||
|
||
contentItem: Label { | ||
text: firmwareV2OutdatedDialogText() | ||
verticalAlignment: Qt.AlignVCenter | ||
elide: Text.ElideRight | ||
clip: true | ||
wrapMode: Text.Wrap | ||
} | ||
|
||
} | ||
|
||
Dialog { | ||
id: consoleVersionDialog | ||
|
||
property alias versionText: versionTextLabel.text | ||
|
||
anchors.centerIn: parent | ||
width: Globals.width / dialogWidthDivisor | ||
height: Globals.height / dialogHeightDivisor | ||
x: Globals.width / 2 - width / 2 | ||
y: Globals.height / 2 - height / 2 | ||
modal: true | ||
focus: true | ||
title: "Swift Console Outdated" | ||
standardButtons: Dialog.Close | ||
onRejected: { | ||
popupLock = false; | ||
} | ||
|
||
contentItem: ColumnLayout { | ||
anchors.centerIn: parent | ||
spacing: 0 | ||
|
||
Label { | ||
Layout.fillWidth: true | ||
wrapMode: Text.Wrap | ||
text: { | ||
let text = ``; | ||
text += `Your console is out of date and may be incompatible with current firmware. `; | ||
text += `We highly recommend upgrading to ensure proper behavior.`; | ||
text; | ||
} | ||
} | ||
|
||
Label { | ||
readonly property string website: Constants.logoPopup.aboutMe.supportWebsite | ||
readonly property string websiteDisplay: website.slice(12) | ||
|
||
Layout.fillWidth: true | ||
wrapMode: Text.Wrap | ||
text: `Please visit <a href='${website}'>${websiteDisplay}</a> to download the latest version.\n\n` | ||
onLinkActivated: { | ||
Qt.openUrlExternally(website); | ||
} | ||
} | ||
|
||
Label { | ||
id: versionTextLabel | ||
|
||
Layout.fillWidth: true | ||
wrapMode: Text.Wrap | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
Dialog { | ||
id: fwVersionDialog | ||
|
||
anchors.centerIn: parent | ||
width: Globals.width / dialogWidthDivisor | ||
height: Globals.height / dialogHeightDivisor | ||
x: Globals.width / 2 - width / 2 | ||
y: Globals.height / 2 - height / 2 | ||
modal: true | ||
focus: true | ||
title: "Firmware Update" | ||
standardButtons: Dialog.Close | ||
onRejected: { | ||
popupLock = false; | ||
} | ||
|
||
contentItem: Label { | ||
verticalAlignment: Qt.AlignVCenter | ||
elide: Text.ElideRight | ||
clip: true | ||
wrapMode: Text.Wrap | ||
} | ||
|
||
} | ||
|
||
Timer { | ||
id: timer | ||
|
||
property var currentCallback: null | ||
|
||
function startTimer(callback) { | ||
currentCallback = callback; | ||
timer.start(); | ||
} | ||
|
||
interval: Constants.updateTab.popupDelayMilliseconds | ||
repeat: false | ||
onTriggered: { | ||
currentCallback(); | ||
} | ||
} | ||
|
||
Timer { | ||
interval: Utils.hzToMilliseconds(Constants.staticTimerNotificationIntervalRate) | ||
running: true | ||
repeat: true | ||
onTriggered: { | ||
if (!popupLock && Globals.showPrompts) { | ||
if (Globals.updateTabData.consoleVersionLatest) { | ||
if (!consoleVersionDialogAlready) { | ||
if (Globals.updateTabData.consoleOutdated) { | ||
popupLock = true; | ||
consoleVersionDialog.versionText = consoleOutdatedDialogText(Globals.updateTabData.consoleVersionCurrent, Globals.updateTabData.consoleVersionLatest); | ||
timer.startTimer(consoleVersionDialog.open); | ||
} | ||
consoleVersionDialogAlready = true; | ||
return ; | ||
} | ||
} | ||
if (Globals.updateTabData.fwVersionCurrent) { | ||
if (!v2DownloadDialogAlready) { | ||
if (Globals.updateTabData.fwV2Outdated) { | ||
popupLock = true; | ||
timer.startTimer(v2DownloadDialog.open); | ||
} | ||
v2DownloadDialogAlready = true; | ||
return ; | ||
} | ||
} else { | ||
// This will clear between device connections. | ||
v2DownloadDialogAlready = false; | ||
firmwareVersionDialogAlready = false; | ||
return ; | ||
} | ||
if (Globals.updateTabData.fwVersionCurrent && Globals.updateTabData.fwVersionLatest) { | ||
if (!firmwareVersionDialogAlready && !Globals.updateTabData.fwV2Outdated) { | ||
if (Globals.updateTabData.fwOutdated) { | ||
popupLock = true; | ||
fwVersionDialog.contentItem.text = firmwareOutdatedDialogText(Globals.updateTabData.fwVersionLatest); | ||
timer.startTimer(fwVersionDialog.open); | ||
} | ||
firmwareVersionDialogAlready = true; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to split this into multiple labels to get this href too work for some reason.