On Thu, Mar 03, 2016 at 11:51:53AM +0100, Marco Martin wrote:
> On Wednesday 02 March 2016 14:50:52 Dirk Hohndel wrote:
> > If I want to use a PassiveNotification to give some information to the
> > user that either hides after a while or gets removed when it's no longer
> > valid (i.e.: accessing some web service), then I need a way to explicitly
> > hide the notification
> 
> since PassiveNotification is private, how do you access it? an 
> hideNotification 
> wrapper in ApplicationWindow is needed as well i think?
> 
> that gives me another question: right now this passivenotification is 
> intended 
> to be really simple, so there is one and only one (calling showNotification 
> with a notification already showing will just discard the old one)
> a more complex system system could be done , stacking them and whatnot, but 
> i'm very hesitand on that as i don't want another full notification system 
> (for 
> which there is the system-wide one)

AH, right, I forgot to post about that problem.

So for me the magic notification attached to the action button didn't seem
to work - or more precisely, I couldn't figure out how to access it from a
page that didn't have it's own action button. So I simply instantiated the
private component myself like this:

        Component.onCompleted: {
                notificationComponent = 
Qt.createComponent("PassiveNotification.qml");
                if( notificationComponent.status != Component.Ready ) {
                        print("notificationComponent isn't ready with status " 
+ notificationComponent.status)
                        if( notificationComponent.status == Component.Error )
                                print("Error:"+ 
notificationComponent.errorString() );
                }
        }

Now I can create a passive notification like this

        property QtObject notificationComponent
        var notification = 
notificationComponent.createObject(contentItem.parent);
        notification.showNotification("Dive deleted", 3000, "Undo",
                                      function() {
                                              manager.undoDelete(deletedId)
                                      });

(that's a more typical notification with an action that just disappears after a 
few seconds)

Or I can do a notification as discussed above that I can turn off when the
status I want to notify about ends

        property alias sharedNotificationComponent: 
detailsWindow.notificationComponent // this uses the notificationComponent above
        property alias accessingCloud: manager.accessingCloud // that's the 
status set in the logic C++ core of my app
        property QtObject notification: null
        onAccessingCloudChanged: {
                if (accessingCloud) {
                        notification = 
sharedNotificationComponent.createObject(rootItem);
                        notification.showNotification("Accessing Subsurface 
Cloud Storage", 5000);
                } else {
                        if (notification) {
                                notification.hideNotification();
                        }
                }
                sharedNotificationComponent.show
        }

This seems to mostly do what I want (except in one scenario where my UI
appears to hang and I haven't figured out why, yet.

So I guess that isn't how you envisioned this being used - I'm open to better
implementation, but the underlying desire to be able to actively hide the
notification when the need to show it ends is still valid.

/D
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel

Reply via email to