Bug 342940

Summary: Replace popup dialog about network error with passive notification
Product: [Applications] trojita Reporter: Yaohan Chen <yaohan.chen>
Component: Desktop GUIAssignee: Trojita default assignee <trojita-bugs>
Status: RESOLVED FIXED    
Severity: minor CC: msjasinski, roberth.sjonoy, yaohan.chen
Priority: NOR    
Version First Reported In: git   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Crude patch demonstrating using system tray icon message instead of message boxes to show network errors

Description Yaohan Chen 2015-01-17 04:34:57 UTC
When there is a network error, Trojita displays a popup dialog. Since the desktop may be already set up to automatically reconnect, and the user may be working on other tasks, a popup dialog is not a good UI but gets in the way. It would be preferable to use a passive notification instead.

Reproducible: Always

Steps to Reproduce:
1. Open Trojita and connect to an IMAP server
2. Disconnect from the Internet

Actual Results:  
Trojita opens a popup dialog about the network error

Expected Results:  
Trojita should only show a passive notification
Comment 1 Thomas Lübking 2015-01-17 16:55:14 UTC
FTR, that's not abstracted by Qt.

We could

    if (QDBusConnection::sessionBus().interface()->isServiceRegistered("org.freedesktop.Notifications")) {
        QDBusInterface notifications("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications");
        QDBusMessage msg = notifications.call("Notify", "Trojitá", m_notificationId, "dialog-information", "Lost Network", "Trojitá lost the underlyig Network",
                                              QStringList() /*actions*/, QVariantMap() /*hints*/, int timeout); // this blocks!
        if (msg.arguments().count())
            m_notificationId = msg.arguments().at(0).toUInt();
        return;
    }
    QMessageBox::information(.);

But that's not portable.

Alternatives would be to just show a tooltip or to paint into the main window.
Comment 2 Yaohan Chen 2015-01-24 01:22:32 UTC
Created attachment 90619 [details]
Crude patch demonstrating using system tray icon message instead of message boxes to show network errors
Comment 3 Yaohan Chen 2015-01-24 01:26:26 UTC
I added a patch for using system tray icon messages to show network errors. These look kind of out of place, but at least they are not as annoying in my opinion.

When there are multiple network errors in a row, it's probably best to only show the message once instead of doing it on every check, and the patch doesn't do this.

For cross-platform notification, https://github.com/Snorenotify/Snorenotify/ looks like a good option.
Comment 4 Jan Kundrát 2015-03-18 00:47:23 UTC
OK, my previous DE wasn't switching virtual desktops on popups, but my current one does. I therefore understand that it gets a bit annoying.

I like the D-Bus approach -- it looks quite self-contained. I also like the snorenotify's cross-platformness, but it seems that they've since dropped Qt4 support, and that they aren't even packaged in EPEL.

-> Should we make a plugin for notifications? Or is that too much work?
Comment 5 Jan Kundrát 2016-02-22 13:15:45 UTC
*** Bug 359593 has been marked as a duplicate of this bug. ***
Comment 6 Jan Kundrát 2016-03-03 23:22:16 UTC
Git commit 9011214ae8b769da4b0294f372d02a722274054c by Jan Kundrát, on behalf of Thomas Lübking.
Committed on 29/02/2016 at 23:14.
Pushed by gerrit into branch 'master'.

only show network error if trojita is active

Helps with lousy WMs which let modal dialogs in other
windows interrupt work.

This dialog is still shown *once*, when any trojita window gets active
and the network error didn't auto-resolve (ie. you're offline)

Change-Id: I4f6130eca26db9c3dd9803146b0ccab5c149206a

M  +16   -1    src/Gui/Window.cpp

http://commits.kde.org/trojita/9011214ae8b769da4b0294f372d02a722274054c
Comment 7 Jan Kundrát 2016-03-03 23:22:16 UTC
Git commit 0216cc0eed22b502dc9a76dd7083f89d0b2b5c95 by Jan Kundrát, on behalf of Thomas Lübking.
Committed on 01/03/2016 at 00:17.
Pushed by gerrit into branch 'master'.

hint offline state and net error in systray

mail count text turns red whenever trojita is offline
and on network errors, the systray yells a message

this also catches a possible nullptr deref in handleTrayIconChange
and I took the liberty to revisit the icon overlay painting code ;-)

jkt: Do not use red-text-on-bnlue-background, that is visually too
annoying to me. When painting in red, change the background color to
gray. It would be nice to show a red-tinted icon when no text is to be
shown, but my QPainter-composition-fu is not high enough to do that.

Change-Id: Ib1a299cfcc61ad860d3e834deaa5441bd34516fc

M  +30   -19   src/Gui/Window.cpp

http://commits.kde.org/trojita/0216cc0eed22b502dc9a76dd7083f89d0b2b5c95
Comment 8 Jan Kundrát 2016-11-24 09:01:01 UTC
Looks like something which is no longer an issue with these two commits. Closing.