Skip to content

Commit

Permalink
Display existing cover art in file info dialog.
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul-raturi committed Mar 24, 2016
1 parent 66ed358 commit 04de250
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
27 changes: 22 additions & 5 deletions picard/ui/infodialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@ def _display_tabs(self):
self._display_info_tab()
self._display_artwork_tab()

def _display_artwork_tab(self):
tab = self.ui.artwork_tab
images = self.obj.metadata.images
def _display_artwork(self, tab, images, widget):
if not images:
self.tab_hide(tab)
return

self.ui.artwork_list.itemDoubleClicked.connect(self.show_item)
widget.itemDoubleClicked.connect(self.show_item)
for image in images:
data = None
try:
Expand Down Expand Up @@ -89,8 +87,14 @@ def _display_artwork_tab(self):
infos.append(u"%d x %d" % (image.width, image.height))
infos.append(image.mimetype)
item.setText(u"\n".join(infos))
self.ui.artwork_list.addItem(item)
widget.addItem(item)

def _display_artwork_tab(self):
tab = self.ui.artwork_tab
images = self.obj.metadata.images
widget = self.ui.artwork_list
self._display_artwork(tab, images, widget)

def tab_hide(self, widget):
tab = self.ui.tabWidget
index = tab.indexOf(widget)
Expand All @@ -108,6 +112,10 @@ class FileInfoDialog(InfoDialog):
def __init__(self, file, parent=None):
InfoDialog.__init__(self, file, parent)
self.setWindowTitle(_("Info") + " - " + file.base_filename)
if file.metadata.images == file.orig_metadata.images:
self.tab_hide(self.ui.old_artwork_tab)
else:
self._display_old_artwork_tab()

def _display_info_tab(self):
file = self.obj
Expand Down Expand Up @@ -143,11 +151,19 @@ def _display_info_tab(self):
cgi.escape(i[1])), info))
self.ui.info.setText(text)

def _display_old_artwork_tab(self):
file = self.obj
images = file.orig_metadata.images
tab = self.ui.old_artwork_tab
widget = self.ui.old_artwork_list
self._display_artwork(tab, images, widget)


class AlbumInfoDialog(InfoDialog):

def __init__(self, album, parent=None):
InfoDialog.__init__(self, album, parent)
self.tab_hide(self.ui.old_artwork_tab)
self.setWindowTitle(_("Album Info"))

def _display_info_tab(self):
Expand All @@ -174,6 +190,7 @@ class ClusterInfoDialog(InfoDialog):

def __init__(self, cluster, parent=None):
InfoDialog.__init__(self, cluster, parent)
self.tab_hide(self.ui.old_artwork_tab)
self.setWindowTitle(_("Cluster Info"))

def _display_info_tab(self):
Expand Down
17 changes: 17 additions & 0 deletions picard/ui/ui_infodialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@ def setupUi(self, InfoDialog):
self.artwork_list.setObjectName(_fromUtf8("artwork_list"))
self.vboxlayout1.addWidget(self.artwork_list)
self.tabWidget.addTab(self.artwork_tab, _fromUtf8(""))
self.old_artwork_tab = QtGui.QWidget()
self.old_artwork_tab.setObjectName(_fromUtf8("old_artwork_tab"))
self.vboxlayout2 = QtGui.QVBoxLayout(self.old_artwork_tab)
self.vboxlayout2.setObjectName(_fromUtf8("vboxlayout2"))
self.old_artwork_list = QtGui.QListWidget(self.old_artwork_tab)
self.old_artwork_list.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
self.old_artwork_list.setIconSize(QtCore.QSize(170, 170))
self.old_artwork_list.setMovement(QtGui.QListView.Static)
self.old_artwork_list.setFlow(QtGui.QListView.LeftToRight)
self.old_artwork_list.setProperty("isWrapping", False)
self.old_artwork_list.setResizeMode(QtGui.QListView.Fixed)
self.old_artwork_list.setSpacing(10)
self.old_artwork_list.setViewMode(QtGui.QListView.IconMode)
self.old_artwork_list.setObjectName(_fromUtf8("old_artwok_list"))
self.vboxlayout2.addWidget(self.old_artwork_list)
self.tabWidget.addTab(self.old_artwork_tab, _fromUtf8(""))
self.verticalLayout.addWidget(self.tabWidget)
self.buttonBox = QtGui.QDialogButtonBox(InfoDialog)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
Expand All @@ -72,4 +88,5 @@ def setupUi(self, InfoDialog):
def retranslateUi(self, InfoDialog):
self.tabWidget.setTabText(self.tabWidget.indexOf(self.info_tab), _("&Info"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.artwork_tab), _("A&rtwork"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.old_artwork_tab), _("&Old Artwork"))

0 comments on commit 04de250

Please sign in to comment.