Skip to content

Commit

Permalink
Fix App Added Alert (#2037)
Browse files Browse the repository at this point in the history
* Fix App Added Alert

* Apply suggestions from code review

Co-authored-by: Florian Zia <[email protected]>

Co-authored-by: Florian Zia <[email protected]>
  • Loading branch information
strseb and flozia authored Oct 18, 2021
1 parent 942a091 commit be68bf0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/ui/components/VPNAlert.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Rectangle {
property var duration: 0
// Delete itself after closing
property var destructive: false
// Fixes the Y on show() if the alert does not use Layout
property var setY: 0

Layout.minimumHeight: style.alertHeight
Layout.maximumHeight: style.alertHeight
Expand Down Expand Up @@ -320,12 +322,16 @@ Rectangle {
if (!isLayout) {
height = style.alertHeight;
width = Math.min(window.width - Theme.windowMargin, Theme.maxHorizontalContentWidth);
y = fullscreenRequired()? iosSafeAreaTopMargin.height + Theme.windowMargin : Theme.windowMargin;
if (setY > 0) {
y = setY;
} else {
y = fullscreenRequired() ? iosSafeAreaTopMargin.height + Theme.windowMargin : Theme.windowMargin;
}
anchors.horizontalCenter = parent.horizontalCenter;
anchors.margins = Theme.windowMargin / 2;
}
if(alertBox.duration > 0){
console.log("Toasbox timer start")
console.log("Toastbox timer start")
autoHideTimer.start()
}
}
Expand Down
14 changes: 12 additions & 2 deletions src/ui/settings/ViewAppPermissions.qml
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,27 @@ Item {
target: VPNAppPermissions
function onNotification(type,message,action) {
console.log("Got notification: "+type + " message:"+message);
var component = Qt.createComponent("qrc://components/components/VPNAlert.qml");
component.createObject(root, {
var component = Qt.createComponent("qrc:/components/components/VPNAlert.qml");
if(component.status !== Component.Ready)
{
if( component.status == Component.Error )
console.debug("Error:"+ component.errorString() );

}
var alert = component.createObject(root, {
isLayout:false,
visible:true,
alertText: message,
alertType: type,
alertActionText: action,
duration:type === "warning"? 0: 2000,
destructive:true,
// Pin y hight to be below the alert bar as we can't render above it
setY: vpnFlickable.y+Theme.windowMargin,
onActionPressed: ()=>{VPNAppPermissions.openFilePicker();},
});

alert.show();
}
}

Expand Down

0 comments on commit be68bf0

Please sign in to comment.