Notifications bar

Forum about the Toon firmware, and its extensions

Moderators: marcelr, TheHogNL, Toonz

Toonz
Forum Moderator
Forum Moderator
Posts: 1873
Joined: Mon Dec 19, 2016 1:58 pm

Notifications bar

Post by Toonz »

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
member of the Toon Software Collective
michel30
Member
Member
Posts: 286
Joined: Fri Aug 25, 2017 4:42 pm

Re: Notifications bar

Post by michel30 »

@Toonz

Super, this works thanks for your TIP.

Regards,
Michel
FunFair
Starting Member
Starting Member
Posts: 42
Joined: Sun Oct 01, 2017 11:40 am

Re: Notifications bar

Post by FunFair »

Ì 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: 42
Joined: Sun Oct 01, 2017 11:40 am

Re: Notifications bar

Post by FunFair »

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.
marcelr
Global Moderator
Global Moderator
Posts: 1153
Joined: Thu May 10, 2012 10:58 pm
Location: Ehv

Re: Notifications bar

Post by marcelr »

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.
FunFair
Starting Member
Starting Member
Posts: 42
Joined: Sun Oct 01, 2017 11:40 am

Re: Notifications bar

Post by FunFair »

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: 42
Joined: Sun Oct 01, 2017 11:40 am

Re: Notifications bar

Post by FunFair »

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!!!
Toonz
Forum Moderator
Forum Moderator
Posts: 1873
Joined: Mon Dec 19, 2016 1:58 pm

Re: Notifications bar

Post by Toonz »

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
member of the Toon Software Collective
marcelr
Global Moderator
Global Moderator
Posts: 1153
Joined: Thu May 10, 2012 10:58 pm
Location: Ehv

Re: Notifications bar

Post by marcelr »

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.
FunFair
Starting Member
Starting Member
Posts: 42
Joined: Sun Oct 01, 2017 11:40 am

Re: Notifications bar

Post by FunFair »

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!
ams123
Member
Member
Posts: 73
Joined: Thu Aug 31, 2017 5:27 pm
Location: Amersfoort

Re: Notifications bar

Post by ams123 »

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
Toon solarpannels
Toonz
Forum Moderator
Forum Moderator
Posts: 1873
Joined: Mon Dec 19, 2016 1:58 pm

Re: Notifications bar

Post by Toonz »

Thanks for the feedback. Nobody needs to worry anymore about notifications :D
member of the Toon Software Collective
Wunser
Starting Member
Starting Member
Posts: 14
Joined: Sat Sep 09, 2017 6:35 pm

Re: Notifications bar

Post by Wunser »

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
michel30
Member
Member
Posts: 286
Joined: Fri Aug 25, 2017 4:42 pm

Re: Notifications bar

Post by michel30 »

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 16003 times
Toonz
Forum Moderator
Forum Moderator
Posts: 1873
Joined: Mon Dec 19, 2016 1:58 pm

Re: Notifications bar

Post by Toonz »

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
member of the Toon Software Collective
Post Reply

Return to “Toon Firmware”