Add graphical feedback on no file selected

This commit is contained in:
Anton Thomasson 2021-05-28 20:45:50 +02:00
parent 0e78e74100
commit c5217bb9de

View file

@ -59,6 +59,7 @@ Page {
} }
signal refreshed() signal refreshed()
signal noFileSelected()
Component.onCompleted: { Component.onCompleted: {
IppDiscovery.discover(); IppDiscovery.discover();
@ -206,15 +207,17 @@ Page {
return; return;
} }
debugCountReset.restart(); debugCountReset.restart();
if(!canPrint) if(selectedFile == "")
return;
if(selectedFile != "")
{ {
pageStack.push(Qt.resolvedUrl("PrinterPage.qml"), {printer: printer, selectedFile: selectedFile, jobParams: maybeGetParams()}) noFileSelected();
}
else if(!canPrint)
{
return;
} }
else else
{ {
notifier.notify(qsTr("No file selected")) pageStack.push(Qt.resolvedUrl("PrinterPage.qml"), {printer: printer, selectedFile: selectedFile, jobParams: maybeGetParams()})
} }
} }
@ -383,6 +386,23 @@ Page {
horizontalAlignment: contentWidth > width ? Text.AlignRight : Text.AlignHCenter horizontalAlignment: contentWidth > width ? Text.AlignRight : Text.AlignHCenter
truncationMode: TruncationMode.Fade truncationMode: TruncationMode.Fade
text: selectedFile != "" ? selectedFile : qsTr("No file selected") text: selectedFile != "" ? selectedFile : qsTr("No file selected")
SequentialAnimation {
id: noFileSelectedAnimation
loops: 3
ColorAnimation {target: fileLabel; property: "color"; from: Theme.primaryColor; to: Theme.highlightColor; duration: 200 }
ColorAnimation {target: fileLabel; property: "color"; from: Theme.highlightColor; to: Theme.primaryColor; duration: 200 }
}
Connections {
target: page
onNoFileSelected: {
console.log("onNoFileSelected")
noFileSelectedAnimation.start()
}
}
} }