Commits

Anonymous committed 317e77f

more blind cleanup. Added folders and the option to return by clicking the center icon.

Comments (0)

Files changed (1)

 	icon = QIcon(self.iconloader.loadIcon(PROGRAM_ICON, 0))
 	self.setWindowIcon(icon)
 	
-		
-	self.center = QLabel(self)
-	self.center.action = None
-	self.center.setPixmap(self.iconloader.loadIcon(CENTER_ICON, 0))
-        self.center.move(0.5*self.width() - 0.25*self.center.width(), 0.5*self.height() - 0.75*self.center.height())
-        
         # Add a circle-list for all the icons
 	self.circle = []
 
-        items = [("kate","kate"), ("kmail","kmail"), ("kmix","kmix"), ("wesnoth","wesnoth"),
-                 ("krita","[('gimp','gimp')]")]
+        items = [(CENTER_ICON, None), # the center item
+                 ("kate","kate"), ("kmail","kmail"), ("kmix","kmix"), ("wesnoth","wesnoth"), # normal items
+                 ("krita","[('gimp','gimp')]") # a folder
+                 ]
 		    
 	self.arrange_in_circle(items)
 	
         self.close()
 
     def mouseReleaseEvent(self, event):
-        """Close when we get a mouse release
-
-        TODO: Only close when the mouse is released on a final item or outside.
-        """
+        """Close when we get a mouse release on a final item."""
+        # Get the position
+        pos = event.pos()
+                
         for i in self.circle[:]: 
-	    if self.isInside(event.pos(), i):
+	    if self.isInside(pos, i):
                 if i.action[0] == "[":
                     # then it's a folder!
+                    # get its contents
                     items = eval(i.action)
+                    # and store the current items in the new center.
+                    # as long as the user didn't click the center
+                    if not i == self.circle[0]: 
+                        items[0] = ( CENTER_ICON , str(self.circle) )
                     self.arrange_in_circle(items)
                     # We don't do anything else in that case. 
                     return None
-                # if it's no folder, we start the program
+                # if it's no folder and not None, we start the program
                 # if this fails, the code ends here 
-                # and the circle stays visible. 
-                Popen(i.action)
+                # and the circle stays visible.
+                if i.action is not None: 
+                    Popen(i.action)
+
+                # Otherwise we can close the pyRad
                 for label in self.circle: 
                     label.destroy()
                 self.close()
 	    label.setPixmap(self.iconloader.loadIcon(icon, 0))
 	    self.circle.append(label)
 
-	# Finally arrange the items into a circle around the center. 
-	for i in self.circle: 
+        # Now set the center icon
+        self.circle[0].move(0.5*self.width() - 0.25*self.circle[0].width(), 0.5*self.height() - 0.75*self.circle[0].height())
+
+	# And finally arrange all other items in a circle around the center.
+        for i in self.circle[1:]: 
 	    angle = 2 * pi * (self.circle.index(i) -1 ) / len(self.circle[1:])
 	    x_displacement = sin(angle)*CIRCLE_RADIUS
 	    y_displacement = cos(angle)*CIRCLE_RADIUS