Commits

Mathias Panzenböck committed c78b884

show icon in config page

Comments (0)

Files changed (3)

contents/code/commandsform.py

 from PyQt4.QtCore import Qt, pyqtSlot, pyqtSignal
 from PyQt4 import QtGui
 from PyQt4.QtGui import QWidget, QListWidgetItem, QMessageBox
+from PyKDE4.kdeui import KIcon
+
 from commands_ui import Ui_Commands
 from editform import EditForm
 
 def get_data(item):
-	return dict((unicode(key),unicode(val)) for key, val in item.data(Qt.UserRole).toPyObject().iteritems())
+	return dict(
+		(unicode(key),unicode(val))
+		for key, val in item.data(Qt.UserRole).toPyObject().iteritems()
+		if val)
 
 class CommandsForm(Ui_Commands,QWidget):
 	__slots__ = 'editForm',
 		self.editForm.accepted.connect(self.on_editForm_accepted)
 		if commands:
 			for cmd in commands:
-				item = QListWidgetItem(cmd["identity"])
+				icon = KIcon(cmd.get('icon',None) or "applications-multimedia")
+				item = QListWidgetItem(icon, cmd["identity"])
 				item.setData(Qt.UserRole,cmd)
 				self.listPlayers.addItem(item)
 			
 		data = {"identity": name}
 		item = QListWidgetItem(name)
 		item.setData(Qt.UserRole,data)
+		icon = KIcon("applications-multimedia")
+		item.setIcon(icon)
 		self.listPlayers.addItem(item)
 		self.listPlayers.sortItems()
 		self.settingsChanged.emit()
 		item = self.listPlayers.currentItem()
 		if item:
 			data = self.editForm.data()
+			icon = KIcon(data.get('icon',None) or "applications-multimedia")
 			item.setData(Qt.UserRole,data)
 			item.setText(data["identity"])
+			item.setIcon(icon)
 			self.listPlayers.sortItems()
 			self.settingsChanged.emit()
 

contents/code/main.py

 		parent.addPage(shortcuts, "Global Media Player Shortcuts", "preferences-desktop-keyboard")
 		self.commandsConfig = CommandsForm(parent,self._commands)
 		self.commandsConfig.settingsChanged.connect(parent.settingsChangedSlot)
-		parent.addPage(self.commandsConfig, "Command Based Player Control")
+		parent.addPage(self.commandsConfig, "Command Based Player Control", "application-x-executable-script")
 		parent.okClicked.connect(self.configAccepted)
 		parent.applyClicked.connect(self.configAccepted)
 

contents/ui/commands.ui

     </layout>
    </item>
    <item row="1" column="0">
-    <widget class="QListWidget" name="listPlayers"/>
+    <widget class="QListWidget" name="listPlayers">
+     <property name="iconSize">
+      <size>
+       <width>48</width>
+       <height>48</height>
+      </size>
+     </property>
+     <property name="gridSize">
+      <size>
+       <width>0</width>
+       <height>48</height>
+      </size>
+     </property>
+     <property name="viewMode">
+      <enum>QListView::ListMode</enum>
+     </property>
+     <property name="uniformItemSizes">
+      <bool>true</bool>
+     </property>
+    </widget>
    </item>
   </layout>
  </widget>