Skip to content
This repository has been archived by the owner on May 28, 2022. It is now read-only.

153 error notification #479

Closed
wants to merge 12 commits into from

Conversation

numeron5
Copy link

@numeron5 numeron5 commented Feb 8, 2014

screenshot from 2014-02-08 18 25 29

adding notifications bar

@numeron5
Copy link
Author

numeron5 commented Feb 8, 2014

I haven't removed the pop up message ... just wanted to hear from you guys if this could be a way to notify the user

@dideler
Copy link
Member

dideler commented Feb 9, 2014

@numeron5 that style of notification works IMO. But for a more general notification system it may not work as well since the space is limited and other UIs in Freeseer have different layouts. But leave it as is until we hear more feedback from others.

@@ -91,6 +91,10 @@ def __init__(self, profile, config):
self.timer = QtCore.QTimer(self)
self.timer.timeout.connect(self.update_timer)

# Set variables for Warning message
self.warning_message_off = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable name can be improved IMO. It's a bit confusing because a "positive" value (True) is being assigned to a "negative" flag (off). Something such as display_warning_message = False is easier to read. It's usually better to use the "positive" option for flags or conditionals, it's easier to read.

FYI, it may seem pedantic pointing out stuff like this, but good naming makes a codebase much easier to understand. Related: http://programmers.stackexchange.com/a/41850/14467

@zxiiro
Copy link
Member

zxiiro commented Feb 9, 2014

I like the mockup. Don't worry about adding a notification to the configuration tool or the talk editor. I don't think notifications make sense in those UIs.

self.display_warning_message = False
if not self.display_warning_message and ((self.remaining_disk_space[1] == 'GB' and \
float(self.remaining_disk_space[0]) < self.low_space_threshold) or \
(self.remaining_disk_space[1] == 'MB' or self.remaining_disk_space[1] == 'KB')):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using intermediate variables to store the parts of the condition.

@zxiiro
Copy link
Member

zxiiro commented Feb 19, 2014

I think you have Disk Space and Error notification issues combined in this one pull request. To be honest I would prefer if you made them separate pull requests.

If we can get the Notification issue resolved quickly and merged in you can then use it as a base for your Disk Space issue. How about we up the priority of this bug and try to get this resolved quickly since I think a few projects depend on this. What do you think?

@numeron5
Copy link
Author

I agree, sorry about that.

I removed the warning message code. I will commit to it's corresponding branch as soon as I merge.

@zxiiro
Copy link
Member

zxiiro commented Feb 25, 2014

Can you rebase?

You have files in code review that is not part of your project. This is likely because you merged rather than rebased.

@mtomwing
Copy link
Member

As it stands right now, your NotificationList is essentially an ordered dictionary - see collections.OrderedDict. You should consider instead making some sort of notification manager that would:

  • maintain a collection of notifications (using OrderedDict)
  • have some sort of event-driven callback system (e.g. GUI can register a callback for the 'warning-added' event which will be called when someone does manager.add_warning(notification))

This will also allow you to remove a lot of the notification logic from the GUI code.

#!/usr/bin/python
# -*- coding: utf-8 -*-

class NotificationList:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to look at python queue implementation.

@numeron5
Copy link
Author

numeron5 commented Mar 1, 2014

I believe I made a mistake ... sorry

@dideler dideler added this to the Open Academy / UCOSP milestone Mar 1, 2014
@@ -0,0 +1,30 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where's the license header?

@zxiiro
Copy link
Member

zxiiro commented Mar 7, 2014

To be honest I was expecting the implementation to allow the display of multiple WARNING messages and ERROR messages as we've discussed numerous times. This was the whole reason I requested that you created a Notification Queue so that we could store multiple notifications at the same time. It's great that you were able to implement this queue but I think you completely missed the purpose of this queue which would enable you the ability to display multiple notifications at the same time.

Personally for the UI component I would create a new QWidget, this would be a basic container which can hold multiple QLabels, each QLabel corresponding to a notification. With this you will be able to display multiple notifications at the same time. The QLabels will need to be created dynamically at runtime. At runtime you will likely store some sort of key:value pair kinda list (I'm not sure how so you'll have to research what the best option is) which allows you to link a notification from the Queue back to the UI component it represents. This list will allow you to delete notifications that are no longer valid.

Hope this helps.


# freeseer - vga/presentation capture software
#
# Copyright (C) 2011, 2014 Free and Open Source Software Learning Centre
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is new, so the copyright should only be 2014, not 2011 to 2014.

@numeron5
Copy link
Author

ok, at the moment I have a QWidget that stores all the notifications. The QWidget is not resizeable and the user is allowed to close it (this is not ideal but at the moment but, I just want a bit of feedback before polishing up the widget). It has two buttons, and up and down button which allows the user to traverse the notification queue.

I've done the implementation so that, only the add_warning, add_error and delete_notification methods should be used on the front end side.

I've only debugged the addition and deletion of warnings. I'll finish debugging the addition and deletion of errors tomorrow.

@mtomwing
Copy link
Member

So you went from having a somewhat modular frontend/backend to having all your code in a bloated frontend component? It would be better if the notification system and presentation were separate.

self.update()

def add_error(self, name, message):
self.n_manager[name] = message
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if I re-use the name of an existing error or warning? Wouldn't it get overwritten?

@mtomwing
Copy link
Member

What reasoning do you have for using an OrderedDict instead of a list or some kind of queue? You seem to be using an index (which isn't the key in the dict) to look up your notifications which leads to me believe the wrong data structure was used.

@numeron5
Copy link
Author

  1. yes, if you re-use a name, the notification message will get over written. But this should never happen since each notification is unique.

  2. I agree, I should use index instead of keyword

  3. The reason why I'm using an ordered dictionary is because, I want a list of tuples such that: (notification ID : notification message) are linked. that way It allows for the direct deletion using the notification ID (or keyword). The reason why I'm using an index to traverse the dictionary is only GUI purposes ... it has nothing to do with the actual queue implementation.

@mtomwing
Copy link
Member

  1. I'm not sure if this is the best assumption as this requires all contributors to know about all possible notification names so that they don't collide. Maybe it would be better generate a unique identifier instead and let the caller use that to delete their notification in the future?

  2. If you go the unique identifier route then perhaps an OrderedDict could work. But without unique keys, I don't think it makes sense. Additionally, the GUI shouldn't necessarily have to know about the existence of this "queue".

@numeron5
Copy link
Author

here is what I have so far for the notification system design:
notification_system_design

@dideler
Copy link
Member

dideler commented Mar 13, 2014

Thanks for the diagrams @numeron5. I'll take a better look at it tomorrow and leave some feedback.

@numeron5
Copy link
Author

I've created a new pull request where the implementation of the notification system uses observer pattern.

link to the new pull request: #530

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants