Add a combobox to select a metadata source in the main window Fixes #508

This commit is contained in:
Timmy Welch 2023-09-05 03:53:18 -04:00
parent d70a98ed29
commit 8b1bcd93e6
2 changed files with 27 additions and 4 deletions

View File

@ -212,6 +212,7 @@ class TaggerWindow(QtWidgets.QMainWindow):
# hook up the callbacks
self.cbLoadDataStyle.currentIndexChanged.connect(self.set_load_data_style)
self.cbSaveDataStyle.currentIndexChanged.connect(self.set_save_data_style)
self.cbx_sources.currentIndexChanged.connect(self.set_source)
self.btnEditCredit.clicked.connect(self.edit_credit)
self.btnAddCredit.clicked.connect(self.add_credit)
self.btnRemoveCredit.clicked.connect(self.remove_credit)
@ -1155,6 +1156,9 @@ class TaggerWindow(QtWidgets.QMainWindow):
self.update_style_tweaks()
self.update_menus()
def set_source(self, s: int) -> None:
self.config[0].Sources_source = self.cbx_sources.itemData(s)
def update_credit_colors(self) -> None:
# !!!ATB qt5 porting TODO
inactive_color = QtGui.QColor(255, 170, 150)
@ -1372,6 +1376,7 @@ class TaggerWindow(QtWidgets.QMainWindow):
settingswin.setModal(True)
settingswin.exec()
settingswin.result()
self.adjust_source_combo()
def set_app_position(self) -> None:
if self.config[0].internal_window_width != 0:
@ -1382,6 +1387,9 @@ class TaggerWindow(QtWidgets.QMainWindow):
size = self.frameGeometry()
self.move(int((screen.width() - size.width()) / 2), int((screen.height() - size.height()) / 2))
def adjust_source_combo(self) -> None:
self.cbx_sources.setCurrentIndex(self.cbx_sources.findData(self.config[0].Sources_source))
def adjust_load_style_combo(self) -> None:
# select the current style
if self.load_data_style == MetaDataStyle.CBI:
@ -1407,6 +1415,11 @@ class TaggerWindow(QtWidgets.QMainWindow):
self.cbSaveDataStyle.addItem("ComicRack", MetaDataStyle.CIX)
self.adjust_save_style_combo()
# Add talker entries
for t_id, talker in self.talkers.items():
self.cbx_sources.addItem(talker.name, t_id)
self.adjust_source_combo()
# Add the entries to the country combobox
self.cbCountry.addItem("", "")
for f in natsort.humansorted(utils.countries().items(), operator.itemgetter(1)):

View File

@ -59,26 +59,36 @@
<property name="formAlignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
<item row="0" column="0">
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Read Style</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="1">
<widget class="QComboBox" name="cbLoadDataStyle"/>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="saveStyleLabel">
<property name="text">
<string>Modify Style</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QComboBox" name="cbSaveDataStyle"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_md_source">
<property name="text">
<string>Metadata Source</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cbx_sources"/>
</item>
</layout>
</item>
<item>