1. Arne Babenhauserheide
  2. pyrad


Arne Babenhauserheide  committed 3f969b7

toplevel changes to the circle are now saved directly - doesn't yet work for folders; see TODO in save_config().

  • Participants
  • Parent commits ef0bde5
  • Branches default

Comments (0)

Files changed (1)

File rad.py

View file
 	    icon = self.main.icon_edit.text()
 	    if action == "": 
 		action = None
+		return str(icon), action
 	    return str(icon), str(action)
         """Close when we get a mouse release on a final item."""
         # Get the position
         pos = event.pos()
-	# TODO: button = event.button()
         for i in self.circle[:]: 
 	    if self.isInside(pos, i):
 		# If pyRad didn't reach a final action, we stop here. 
 		if event.button() == Qt.LeftButton: 
 		    if self.labelClicked(i) is None: 
-			return None
+			break
 		elif event.button() == Qt.RightButton: 
-		    return None
+		    break
 		else: # other buttons are ignored
-		    return None
-		# 		return self.editLabel(i)
-                # Otherwise we can close the pyRad
+		    break
+		# Otherwise we can close the pyRad
                 for label in self.circle: 
     def editLabel(self, label): # -> open message box -> set item.icon and item.action. -> save_config()
 	"""Edit a label. A click on the center item promts for adding a new label."""
 	    if item is None: 
 		return None
 	    icon, action = item
+	    if action is None: 
+		return None
 	    items = [(i.icon, i.action) for i in self.circle]
 	    items.append((icon, action))
         # otherwise edit the current label. 
 	    item = self.editor.edit(label.icon, label.action)
 	    if item is None: 
-		return None
+		return None # clicked cancel
 	    icon, action = item
 	    items = [(i.icon, i.action) for i in self.circle]
-	    items[items.index((label.icon, label.action))] = (icon, action)
+	    if action is not None: 
+		items[self.circle.index(label)] = (icon, action)
+	    else: 
+		idx = self.circle.index(label)
+		items = items[:idx] + items[idx + 1:]
-        self.die_on_focus_lost = True
+	self.save_config()
+	self.die_on_focus_lost = True
     def labelClicked(self, label): 
 	if label.action is not None and label.action[0] == "[":
 	    # then it's a folder!
 	    # get its contents
-	    print label.action
 	    items = eval(label.action)
 	    # and store the current items in the new center.
 	    # as long as the user didn't click the center
         for i in self.circle: 
-    def items_to_circle(self, items): # TODO: change to item_to_label(item) for access in editLabel. 
+    def items_to_circle(self, items): 
 	"""Create the circle list from the given items.
 	@return: circle (list of labels)"""
 	circle = []
 	# First we create a temporary copy of the current circle
 	items_tmp = [(i.icon, i.action) for i in self.circle]
 	# Now we roll back the circle to the top level
-	while self.circle[0] is not None: 
+	while self.circle[0].action is not None: 
+	    # TODO: Make this work for folders. => save changes in the upper layout to the center item. 
+	    # the upper layout (items) equals the evaled content of the correspondig item in the lower layout.
 	# And turn the circle into items. 
 	items = [(i.icon, i.action) for i in self.circle]
-	# Now we copy the previous circle back into the current circle. 
-	self.circle = circle_tmp
+	# Now we copy the previous circle back into the current circle.
+	self.arrange_in_circle(items_tmp)
 	# Finally we prepare the config data
 	config = "# v0.1 keep this line!\n"
 	config += str(items)