Skip to content

Commit

Permalink
Merge pull request metabrainz#452 from zas/fixcovertoggle
Browse files Browse the repository at this point in the history
Fix PICARD-782: restore state of linked checkbox on load
  • Loading branch information
zas committed Dec 25, 2015
2 parents 2be1572 + 64f13a9 commit d0d23aa
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 36 deletions.
10 changes: 9 additions & 1 deletion picard/ui/options/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(self, parent=None):
self.ui = Ui_CoverOptionsPage()
self.ui.setupUi(self)
self.ui.save_images_to_files.clicked.connect(self.update_filename)
self.ui.save_images_to_tags.clicked.connect(self.update_save_images_to_tags)

def load_cover_art_providers(self):
"""Load available providers, initialize provider-specific options, restore state of each
Expand All @@ -82,8 +83,8 @@ def load(self):
self.ui.save_images_to_files.setChecked(config.setting["save_images_to_files"])
self.ui.cover_image_filename.setText(config.setting["cover_image_filename"])
self.ui.save_images_overwrite.setChecked(config.setting["save_images_overwrite"])
self.update_filename()
self.load_cover_art_providers()
self.update_all()

def save(self):
config.setting["save_images_to_tags"] = self.ui.save_images_to_tags.isChecked()
Expand All @@ -92,10 +93,17 @@ def save(self):
config.setting["cover_image_filename"] = unicode(self.ui.cover_image_filename.text())
config.setting["save_images_overwrite"] = self.ui.save_images_overwrite.isChecked()

def update_all(self):
self.update_filename()
self.update_save_images_to_tags()

def update_filename(self):
enabled = self.ui.save_images_to_files.isChecked()
self.ui.cover_image_filename.setEnabled(enabled)
self.ui.save_images_overwrite.setEnabled(enabled)

def update_save_images_to_tags(self):
enabled = self.ui.save_images_to_tags.isChecked()
self.ui.cb_embed_front_only.setEnabled(enabled)

register_options_page(CoverOptionsPage)
29 changes: 14 additions & 15 deletions picard/ui/ui_options_cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,31 @@ def setupUi(self, CoverOptionsPage):
CoverOptionsPage.resize(632, 560)
self.verticalLayout = QtGui.QVBoxLayout(CoverOptionsPage)
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.rename_files = QtGui.QGroupBox(CoverOptionsPage)
self.rename_files.setObjectName(_fromUtf8("rename_files"))
self.vboxlayout = QtGui.QVBoxLayout(self.rename_files)
self.location = QtGui.QGroupBox(CoverOptionsPage)
self.location.setObjectName(_fromUtf8("location"))
self.vboxlayout = QtGui.QVBoxLayout(self.location)
self.vboxlayout.setSpacing(2)
self.vboxlayout.setMargin(9)
self.vboxlayout.setObjectName(_fromUtf8("vboxlayout"))
self.save_images_to_tags = QtGui.QCheckBox(self.rename_files)
self.save_images_to_tags = QtGui.QCheckBox(self.location)
self.save_images_to_tags.setObjectName(_fromUtf8("save_images_to_tags"))
self.vboxlayout.addWidget(self.save_images_to_tags)
self.cb_embed_front_only = QtGui.QCheckBox(self.rename_files)
self.cb_embed_front_only = QtGui.QCheckBox(self.location)
self.cb_embed_front_only.setObjectName(_fromUtf8("cb_embed_front_only"))
self.vboxlayout.addWidget(self.cb_embed_front_only)
self.save_images_to_files = QtGui.QCheckBox(self.rename_files)
self.save_images_to_files = QtGui.QCheckBox(self.location)
self.save_images_to_files.setObjectName(_fromUtf8("save_images_to_files"))
self.vboxlayout.addWidget(self.save_images_to_files)
self.label_3 = QtGui.QLabel(self.rename_files)
self.label_3.setObjectName(_fromUtf8("label_3"))
self.vboxlayout.addWidget(self.label_3)
self.cover_image_filename = QtGui.QLineEdit(self.rename_files)
self.label_use_filename = QtGui.QLabel(self.location)
self.label_use_filename.setObjectName(_fromUtf8("label_use_filename"))
self.vboxlayout.addWidget(self.label_use_filename)
self.cover_image_filename = QtGui.QLineEdit(self.location)
self.cover_image_filename.setObjectName(_fromUtf8("cover_image_filename"))
self.vboxlayout.addWidget(self.cover_image_filename)
self.save_images_overwrite = QtGui.QCheckBox(self.rename_files)
self.save_images_overwrite = QtGui.QCheckBox(self.location)
self.save_images_overwrite.setObjectName(_fromUtf8("save_images_overwrite"))
self.vboxlayout.addWidget(self.save_images_overwrite)
self.verticalLayout.addWidget(self.rename_files)
self.verticalLayout.addWidget(self.location)
self.ca_providers_groupbox = QtGui.QGroupBox(CoverOptionsPage)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
Expand All @@ -69,19 +69,18 @@ def setupUi(self, CoverOptionsPage):
self.verticalLayout.addItem(spacerItem1)

self.retranslateUi(CoverOptionsPage)
QtCore.QObject.connect(self.save_images_to_tags, QtCore.SIGNAL(_fromUtf8("clicked(bool)")), self.cb_embed_front_only.setEnabled)
QtCore.QMetaObject.connectSlotsByName(CoverOptionsPage)
CoverOptionsPage.setTabOrder(self.save_images_to_tags, self.cb_embed_front_only)
CoverOptionsPage.setTabOrder(self.cb_embed_front_only, self.save_images_to_files)
CoverOptionsPage.setTabOrder(self.save_images_to_files, self.cover_image_filename)
CoverOptionsPage.setTabOrder(self.cover_image_filename, self.save_images_overwrite)

def retranslateUi(self, CoverOptionsPage):
self.rename_files.setTitle(_("Location"))
self.location.setTitle(_("Location"))
self.save_images_to_tags.setText(_("Embed cover images into tags"))
self.cb_embed_front_only.setText(_("Only embed a front image"))
self.save_images_to_files.setText(_("Save cover images as separate files"))
self.label_3.setText(_("Use the following file name for images:"))
self.label_use_filename.setText(_("Use the following file name for images:"))
self.save_images_overwrite.setText(_("Overwrite the file if it already exists"))
self.ca_providers_groupbox.setTitle(_("Cover Art Providers"))

23 changes: 3 additions & 20 deletions ui/options_cover.ui
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="rename_files">
<widget class="QGroupBox" name="location">
<property name="title">
<string>Location</string>
</property>
Expand Down Expand Up @@ -45,7 +45,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="label_use_filename">
<property name="text">
<string>Use the following file name for images:</string>
</property>
Expand Down Expand Up @@ -119,22 +119,5 @@
<tabstop>save_images_overwrite</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>save_images_to_tags</sender>
<signal>clicked(bool)</signal>
<receiver>cb_embed_front_only</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>266</x>
<y>44</y>
</hint>
<hint type="destinationlabel">
<x>266</x>
<y>67</y>
</hint>
</hints>
</connection>
</connections>
<connections/>
</ui>

0 comments on commit d0d23aa

Please sign in to comment.