Notifications bar

Forum about the tweaking of the Eneco Toon.

Moderator: marcelr

Notifications bar

Postby Toonz » Sat Oct 07, 2017 3:51 pm

Hi all,

many are annoyed by the continuous display of messages in the Notification bar in version 4.7 and higher that there is no connection with the SC.
This simple modification will delete each message after being read once.
All future messages will be displayed as normal but also deleted after being read.

Make the following change in the file /qmf/qml/qb/notifications/NotificationsBar.qml:

Replace:


Code: Select all
            onAction: {
               if (canvas.dimState)
                  screenStateController.wakeup();

               if (actionUrl.toString().length)
                  notificationBar.hide();
               else if (model.uuid)
                  notifications.remove(model.uuid);
               else if (model.type)
                  notifications.removeByType(model.type);
            }


with

Code: Select all
            onAction: {
               if (canvas.dimState)
                  screenStateController.wakeup();

               if (model.uuid)
                  notifications.remove(model.uuid);
               else if (model.type)
                  notifications.removeByType(model.type);
            }


The messages will show up again after a reboot but can be removed again by clicking on it.
This workaround should be acceptable for now.
I expect quby to make improvements to this functionality in future releases.

Kind regardz,

Toonz
Toonz
Advanced Member
Advanced Member
 
Posts: 575
Joined: December 2016

Re: Notifications bar

Postby michel30 » Sat Oct 07, 2017 7:13 pm

@Toonz

Super, this works thanks for your TIP.

Regards,
Michel
michel30
Member
Member
 
Posts: 155
Joined: August 2017

Re: Notifications bar

Postby FunFair » Tue Oct 10, 2017 8:31 pm

Ì seem to have screwed up something... only getting a white screen without any information.
Ofcourse I forgot to make a backup of the file.... can someone please make a copy for me?
FunFair
Starting Member
Starting Member
 
Posts: 29
Joined: October 2017

Re: Notifications bar

Postby FunFair » Tue Oct 10, 2017 9:43 pm

Michel was kind enough to supply me with his file. But still I get a white screen. As if I deleted some file by accident or something...
Now I've got a white screen. A hard reset doesn't work, but everything in the background seems to work fine. I can still change things through domoticz.

Also the screen doesn't go into a dimmed state. I hope someone can help me with this. I am going to make a dump of the files.
FunFair
Starting Member
Starting Member
 
Posts: 29
Joined: October 2017

Re: Notifications bar

Postby marcelr » Tue Oct 10, 2017 10:22 pm

Looks like your qt-gui doesn't start properly anymore.
Please try to run the qt-gui from within a secure shell with this command:

killall qt-gui; /HCBv2/sbin/qt-gui -platform linuxfb -plugin Tslib --daemon 2>&1

... and check the (awful lot of) output for error messages. This should give you some hints as to where things go wrong.
marcelr
Advanced Member
Advanced Member
 
Posts: 815
Joined: May 2012
Location: Ehv

Re: Notifications bar

Postby FunFair » Wed Oct 11, 2017 5:59 am

Code: Select all
file:///HCBv2/qml/Canvas.qml:359:2: Type NotificationBar unavailable
        NotificationBar {
        ^
file:///qmf/qml/qb/notifications/NotificationBar.qml:6:1: Expected token `}'
     � � � � id: notificationBar
     ^



De hoeveelheid output valt gelukkig mee.


Dit staat er in mijn NotificationBar.qml
Code: Select all
import QtQuick 1.1
import QueuedConnection 1.0
import ScreenStateController 1.0

Item {
        id: notificationBar
        anchors {
                left: parent.left
                right: parent.right
                top: parent.top
                topMargin: -height
        }
        height: childrenRect.height
        visible: false

        signal queuedSignal();
        signal itemAdded();

        QtObject {
                id: p
                property bool expandOnDim: false
                property Timer hideTimer: null
                property Timer blackModeTimer: null
        }

        function show(expanded) {
                cancelHideTimer();
                if (!expanded)
                        collapse();
                if (state === "hidden") {
                        notificationColumn.animateAddItem = false;
                        if (notifications.count === 1)
                                addNextItem();
                        else if (expanded)
                                expand();
                        state = "shown";
                }
        }

        function hide(timeout) {
                if (state === "shown") {
                        if (timeout) {
                                cancelHideTimer();
                                p.hideTimer = util.delayedCall(timeout, hideImpl);
                        } else {
                                hideImpl();
                        }
                }
        }

        function hideImpl() {
                notificationColumn.animateAddItem = false;
                notificationBar.state = "hidden";
        }

        function collapse() {
                underlay.clicked.disconnect(collapse);
                underlay.visible = false;
                if (notificationColumn.headerItem !== null) {
                        notificationColumn.animateRemoveItem = true;
                        model.clear();
                        notificationColumn.headerItem.state = "collapsed";
                }
        }

        function expand() {
                if (notifications.count < 2)
                        return;

                if (canvas.dimState) {
                        p.expandOnDim = true;
                        screenStateController.wakeup();
                }
                underlay.clicked.connect(collapse);
                underlay.visible=  true;
                cancelHideTimer();
                if (notificationColumn.headerItem !== null)
                        notificationColumn.headerItem.state = "expanded";
                notificationColumn.animateAddItem = true;
                notificationBar.populate();
        }

        function populate() {
                if (globals.notificationAnimationsEnabled) {
                        itemAddedQueuedConn.signalEmitted.connect(addNextItem);
                        addNextItem();
                } else {
                        while(addNextItem());
                }
        }

        function addNextItem() {
                if (model.count < notifications.count) {
                        model.append(notifications.dataModel[model.count]);
                        return true;
                } else {
                        itemAddedQueuedConn.signalEmitted.disconnect(addNextItem);
                        return false;
                }
        }

        function cancelHideTimer() {
                if (p.hideTimer) {
                        p.hideTimer.destroy();
                        p.hideTimer = null;
                }
        }

        function setBlackMode(enable) {
                if (enable) {
                        screenStateController.screenOffBlackMode = true;
                        scheduleBlackModeTimer(true);
                } else {
                        screenStateController.screenOffBlackMode = false;
                        cancelBlackModeTimer();
                }
        }

        function scheduleBlackModeTimer(show) {
                if (screenStateController.screenState === ScreenStateController.ScreenOff) {
                        screenStateController.screenOffBlackMode = show;
                        var timeout  = (show ? notifications.conf_SHOW_TIME_SCREENOFF : notifications.conf_HIDE_TIME_SCREENOFF) * 1000;
                        cancelBlackModeTimer();
                        p.blackModeTimer = util.delayedCall(timeout, scheduleBlackModeTimer, !show);
                } else {
                        cancelBlackModeTimer();
                }
        }

        function cancelBlackModeTimer() {
                if (p.blackModeTimer) {
                        p.blackModeTimer.destroy();
                        p.blackModeTimer = null;
                }
        }

        state: "hidden"
        states: [
                State {
                        name: "hidden"
                        PropertyChanges { target: notificationBar; anchors.topMargin: -notificationBar.height }
                },
                State {
                        name: "shown"
                        PropertyChanges { target: notificationBar; anchors.topMargin: 0 }
                }
        ]

        transitions: [
                Transition {
                        from: "hidden"; to: "shown"
                        SequentialAnimation {
                                PropertyAction { target: notificationBar; property: "visible"; value: true }
                                NumberAnimation { target: notificationBar; easing.type: Easing.OutQuad; properties: "anchors.topMargin"; duration: 300 }
                        }
                },
                Transition {
                        from: "shown"; to: "hidden"
                        SequentialAnimation {
                                NumberAnimation { target: notificationBar; easing.type: Easing.InQuad; properties: "anchors.topMargin"; duration: 300 }
                                PropertyAction { target: notificationBar; property: "visible"; value: false }
                                ScriptAction {
                                        script: {
                                                collapse();
                                        }
                                }
                        }
                }
        ]

        Connections {
                target: screenStateController
                onScreenStateChanged: {
                        if ((screenStateController.screenState === ScreenStateController.ScreenColorDimmed ||
                                        screenStateController.screenState === ScreenStateController.ScreenOff) &&
                                        notifications.count) {
                                setBlackMode(true);
                                notificationBar.show();
                        } else if (screenStateController.screenState === ScreenStateController.ScreenActive) {
                                if (!p.expandOnDim)
                                        notificationBar.hide(notifications.conf_HIDE_TIMEOUT);
                                p.expandOnDim = false;
                                setBlackMode(false);
                        }
                }
        }

        Connections {
                target: stage
                onOnRootScreenChanged: {
                        if (!stage.onRootScreen)
                                notificationBar.hide();
                }
        }

        Connections {
                target: notifications
                onDataModelChanged: {
                        if (notifications.count === 0) {
                                notificationBar.hide();
                                setBlackMode(false);
                                return;
                        }

                        notificationColumn.animateRemoveItem = false;
                        model.clear();
                        if (notificationColumn.headerItem !== null &&
                                         notificationColumn.headerItem.state === "expanded" && notifications.count > 1) {
                                // TODO: add only the new items?
                                notificationColumn.animateAddItem = false;
                                notificationBar.populate();
                        } else if (notifications.count === 1) {
                                collapse();
                                notificationColumn.animateAddItem = false;
                                notificationBar.addNextItem();
                        }
                }
                onNotificationsAddedOrUpdated: {
                        if (p.hideTimer) {
                                cancelHideTimer();
                                p.hideTimer = util.delayedCall(notifications.conf_HIDE_TIMEOUT, hideImpl);
                        }
                        setBlackMode(true);
                        if (notificationBar.state === "hidden" && canvas.firstLoadingDone) {
                                notificationBar.show();
                                if (screenStateController.screenState === ScreenStateController.ScreenActive)
                                        notificationBar.hide(notifications.conf_HIDE_TIMEOUT);
                        }
                }
        }

        QueuedConnection {
                id: itemAddedQueuedConn
                target: notificationBar
        }

        Component.onCompleted: {
                itemAdded.connect(queuedSignal);
        }

        ListModel {
                id: model
        }

        Rectangle {
                id: notificationBarBg
                width: parent.width
                color: colors.notificationsBackground
                height: notificationColumn.childrenHeight + (notificationColumn.anchors.topMargin * 2)
                clip: true

                MouseArea {
                        anchors.fill: parent
                }

                Behavior on height {
                        enabled: globals.notificationAnimationsEnabled
                        SmoothedAnimation { easing.type: Easing.InQuad; duration: 300 }
                }

                Component {
                        id: notificationHeader
                        NotificationElement {
                                id: headerElement
                                header: true
                                iconSource: "drawables/notifications-icon.svg"
                                title: qsTr("notification-header-text")
                                        .arg(i18n.capitalizeFirstChar(i18n.greetingText))
                                        .arg(colors.notificationsTextHighlight.toString())
                                        .arg(notifications.dataset.length)
                                activeInDim: true
                                onAction: {
                                        if (state === "collapsed") {
                                                notificationBar.expand();
                                        } else {
                                                notificationBar.collapse();
                                        }
                                }
                                onClose: {
                                        notificationBar.hide();
                                }
                                Component.onCompleted: notificationColumn.headerItem = headerElement

                                state: "collapsed"
                                states: [
                                        State {
                                                name: "collapsed"
                                                PropertyChanges { target: headerElement; actionButtonIconRotation: 0; actionButtonRotationAnim.direction: RotationAnimation.Counterclockwise; bgColor: "#ffffff" }
                                        },
                                        State {
                                                name: "expanded"
                                                PropertyChanges { target: headerElement; actionButtonIconRotation: 180; actionButtonRotationAnim.direction: RotationAnimation.Clockwise; bgColor: colors.notificationsHeader }
                                        }
                                ]

                                transitions: [
                                        Transition {
                                                // duration conditional workaround for QtQuick1, on QQ2 it's possible to disable transition
                                                from: "collapsed"; to: "expanded"
                                                ColorAnimation { target: headerElement; property: "bgColor"; duration: globals.notificationAnimationsEnabled ? 200 : 0 }
                                        },
                                        Transition {
                                                from: "expanded"; to: "collapsed"
                                                SequentialAnimation {
                                                        PauseAnimation { duration: globals.notificationAnimationsEnabled ? 200 : 0 }
                                                        ColorAnimation { target: headerElement; property: "bgColor"; duration: globals.notificationAnimationsEnabled ? 200 : 0 }
                                                }
                                        }
                                ]
                        }
                }

                ListView {
                        id: notificationColumn
                        anchors {
                                left: parent.left
                                right: parent.right
                                top: parent.top
                                margins: 16
                        }
                        height: canvas.height
                        spacing: 4
                        interactive: false
                        property real childrenHeight: (header !== null && headerItem !== null ? headerItem.height : 0) + (count > 0 ? contentHeight : 0)

                        header: notifications.count > 1 ? notificationHeader : null
                        onHeaderChanged: {
                                if (header === null)
                                        headerItem = null;
                        }
                        property Item headerItem: null // already exists on QQ2
                        property bool animateAddItem: false
                        property bool animateRemoveItem: false

                        model: model
                        delegate: NotificationElement {
                                id: notificationElement
                                iconSource: notifications.getIconUrl(model.type, model.subType)
                                title: model.subType === "_grouped" ? model.text.arg(colors.notificationsTextHighlight.toString()) : model.text
                                actionUrl: notifications.getActionUrl(model.type, model.subType)
                                actionArgs: notifications.formatActionArgs(notifications.getActionArgsFormat(model.type, model.subType), model.args)
                                activeInDim: notifications.count === 1
                                showClose: notifications.count === 1
                                onAction: {
                                        if (canvas.dimState)
                                                screenStateController.wakeup();

                                        else if (model.uuid)
                                                notifications.remove(model.uuid);
                                        else if (model.type)
                                                notifications.removeByType(model.type);
                                }
                                onClose: {
                                        notificationBar.hide();
                                }
                                ListView.onAdd:        {
                                        if (notificationColumn.animateAddItem && globals.notificationAnimationsEnabled)
                                                addAnimation.restart()
                                        else
                                                itemAdded();
                                }
                                ListView.onRemove: {
                                        if (notificationColumn.animateRemoveItem && globals.notificationAnimationsEnabled)
                                                removeAnimation.restart()
                                }
                                SequentialAnimation {
                                        id: addAnimation
                                        PropertyAction { target: notificationElement; property: "height"; value: 0 }
                                        NumberAnimation { target: notificationElement; property: "height"; to: notificationElement.itemHeight; easing.type: Easing.InOutQuad; duration: 200 }
                                        ScriptAction { script: itemAdded() }
                                }
                                SequentialAnimation {
                                        id: removeAnimation
                                        PropertyAction { target: notificationElement; property: "ListView.delayRemove"; value: true }
                                        NumberAnimation { target: notificationElement; property: "height"; to: 0; easing.type: Easing.InQuad; duration: 200 }
                                        PropertyAction { target: notificationElement; property: "ListView.delayRemove"; value: false }
                                }
                        }
                }
        }

        Image {
                id: shadow
                width: parent.width
                anchors.top: notificationBarBg.bottom
                source: "./drawables/bar-shadow.png"
                fillMode: Image.TileHorizontally
                visible: !canvas.dimState
        }
}
FunFair
Starting Member
Starting Member
 
Posts: 29
Joined: October 2017

Re: Notifications bar

Postby FunFair » Wed Oct 11, 2017 8:21 am

It's working again! It turned out the text editor I used (included in WinSCP) turned all tabs into gibberish. When I opened the file with 'vi' I noticed it.
Copy pasted Michel's file in it trough vi and rebooted without a problem.

Thanks Marcelr and michel30 for the support!!!
FunFair
Starting Member
Starting Member
 
Posts: 29
Joined: October 2017

Re: Notifications bar

Postby Toonz » Wed Oct 11, 2017 2:45 pm

Hi all,

I have another idea to suppress the notifications, this one is a bit more intrusive because you will never see any notifications again :-)

In the file NotificationsBar.qml replace all occurrences of ' notificationBar.show()' by 'notificationBar.hide()'
I cannot test this myself as I don't get these notifications anymore.
If someone is willing to try just give your feedback here. Much appreciated.

Thanks in advance.

Toonz
Toonz
Advanced Member
Advanced Member
 
Posts: 575
Joined: December 2016

Re: Notifications bar

Postby marcelr » Wed Oct 11, 2017 6:40 pm

Slightly different approach:

(excerpt from NotificationBar.qml:)

Code: Select all
        function show(expanded) {                 
                cancelHideTimer();                 
                if (!expanded)                     
                        collapse();               
                if (state === "hidden") {         
                        notificationColumn.animateAddItem = false;
                        if (notifications.count === 1)           
                                addNextItem();                   
                        else if (expanded)                       
                        //MR    expand();                         
                        state = "shown";                         
                }                                                 
// added MR                                                       
                collapse();                                       
                state = "hidden";                                 
// end add                                                       
        }                                                         

This removes notifications altogether, just need to get rid of the systray icon as well, this is easily handled by setting the number of notifications required for display to an insane amount, in NotificationSystray.qml.
marcelr
Advanced Member
Advanced Member
 
Posts: 815
Joined: May 2012
Location: Ehv

Re: Notifications bar

Postby FunFair » Fri Oct 13, 2017 6:59 pm

marcelr wrote:Slightly different approach:

(excerpt from NotificationBar.qml:)

Code: Select all
        function show(expanded) {                 
                cancelHideTimer();                 
                if (!expanded)                     
                        collapse();               
                if (state === "hidden") {         
                        notificationColumn.animateAddItem = false;
                        if (notifications.count === 1)           
                                addNextItem();                   
                        else if (expanded)                       
                        //MR    expand();                         
                        state = "shown";                         
                }                                                 
// added MR                                                       
                collapse();                                       
                state = "hidden";                                 
// end add                                                       
        }                                                         

This removes notifications altogether, just need to get rid of the systray icon as well, this is easily handled by setting the number of notifications required for display to an insane amount, in NotificationSystray.qml.


works perfectly!
FunFair
Starting Member
Starting Member
 
Posts: 29
Joined: October 2017

Re: Notifications bar

Postby ams123 » Sat Oct 14, 2017 9:49 am

Toonz wrote:Hi all,

I have another idea to suppress the notifications, this one is a bit more intrusive because you will never see any notifications again :-)

In the file NotificationsBar.qml replace all occurrences of ' notificationBar.show()' by 'notificationBar.hide()'
I cannot test this myself as I don't get these notifications anymore.
If someone is willing to try just give your feedback here. Much appreciated.

Thanks in advance.

Toonz


yes work for me bar is gone
ams123
Starting Member
Starting Member
 
Posts: 30
Joined: August 2017
Location: Amersfoort

Re: Notifications bar

Postby Toonz » Sat Oct 14, 2017 1:33 pm

Thanks for the feedback. Nobody needs to worry anymore about notifications :D
Toonz
Advanced Member
Advanced Member
 
Posts: 575
Joined: December 2016

Re: Notifications bar

Postby Wunser » Sun Oct 15, 2017 1:43 pm

Different approach is to turn off the notifications alltogether:

in /HCBv2/qml/Canvas.qml

Code: Select all
                notifications = notificationsComponent.createObject(canvas);                             
                // notifications.init();                                                                 


Comment out the init part
Wunser
Starting Member
Starting Member
 
Posts: 9
Joined: September 2017

Re: Notifications bar

Postby michel30 » Mon Dec 04, 2017 6:49 pm

Hello,

I updated my Toon yesterday to version 4.9.23 but this notification icon stays on the upper right ( image below ).

This is because it can not connect to the service center error d03 no internet.
Does somebody know how hide this icon?
It is only the icon, there is no notification white balk.
Attachments
2017-12-04_18-34-51.jpg
2017-12-04_18-34-51.jpg (9.72 KiB) Viewed 1213 times
michel30
Member
Member
 
Posts: 155
Joined: August 2017

Re: Notifications bar

Postby Toonz » Mon Dec 04, 2017 7:54 pm

This is not a Notification icon, it is your internetsettings icon.

Two options here:
1. In the topic manuals is described how to get rid of this error caused by the fact that you have no VPN open to Eneco.

2. Another option, more convenient in my humble opinion, is to completely disable this icon. Saves space in your systray for other more useful icons.
To get rid of the icon comment out the following line in /HCBv2/qml/apps/internetSettings/InternetSettingsApp.qml:
registry.registerWidget("systrayIcon", p.internetSystrayUrl, this);

In this case no Wifi icon is shown ever........

Either option will work.....

Kind regardz,

Toonz
Toonz
Advanced Member
Advanced Member
 
Posts: 575
Joined: December 2016

Next

Return to Eneco Toon as Domotica controller

Who is online

Users browsing this forum: No registered users and 1 guest