Commits

Anonymous committed 0a4bfed

the icon editor now shows a preview of the icon.

  • Participants
  • Parent commits 923d27e

Comments (0)

Files changed (1)

 ### Window ###
 
 class ItemEditWidget(QWidget):
-    def __init__(self, parent=None, icon="", action=None):
+    def __init__(self, parent=None, icon="konqueror", action=None):
         QWidget.__init__(self, parent)
         # First add a Layout
         self.lay = QGridLayout()
         self.setLayout(self.lay)
         # Now add a description text
         self.description = QLabel("Edit the icon (KDE progam name) and the action (commandline input). To delete the item, just delete the action line (set to empty).")
-        self.lay.addWidget(self.description, 0, 0, 1, 2)
-        # Then add a text field with name
+        self.lay.addWidget(self.description, 0, 0, 1, 3)
+        # Then add a text field with name        
         self.icon_label = QLabel("Icon:", self)
         self.icon_edit = QLineEdit(self)
+
+        # and the icon, updated live
+        self.iconloader = KIconLoader()
+        self.icon = QLabel(self)
+        self.icon.icon = icon
+        self.icon.action = action
+
         self.lay.addWidget(self.icon_label, 1, 0)
         self.lay.addWidget(self.icon_edit, 1, 1)
+        self.lay.addWidget(self.icon, 1, 2)
         # Also add the same for the action
         self.action_label = QLabel("Action:", self)
         self.action_edit = QLineEdit(self)
         self.lay.addWidget(self.action_label, 2, 0)
-        self.lay.addWidget(self.action_edit, 2, 1)
+        self.lay.addWidget(self.action_edit, 2, 1, 1, 2)
+
+        # make the icon update automatically
+        self.icon_edit.connect(self.icon_edit, SIGNAL("textChanged(QString)"), self.reload_icon)
+
+    def reload_icon(self, name):
+        """reload the icon from the new name"""
+        self.icon.icon = name
+        self.icon.setPixmap(self.iconloader.loadIcon(name, 0))
+        
 
 # First we need a message box for editing the entries
 class ItemEditor(KDialog):