Added 'full' support for german language to test the localization

This commit is contained in:
Dilan Boskan 2021-03-08 23:20:13 +01:00
parent ec1dda493c
commit ac23ff3461
8 changed files with 138 additions and 195 deletions

View File

@ -265,8 +265,7 @@ class CustomApplication(QtWidgets.QApplication):
save_user_data()
def closeAllWindows(self):
"""Capture application close to save data
"""
"""Capture application close to save data"""
self.logger.info('--- Closing application ---',
indent_forwards=True)
@ -297,7 +296,7 @@ class Translator:
Default is english
"""
language_str = QtCore.QLocale.languageToString(language).lower()
self.logger.info(f'Translating to {language_str}...',
self.logger.info(f'Translating to "{language_str.capitalize()}"...',
indent_forwards=True)
# Get path where translation file should be
translation_path = os.path.join(self.app.resources.localizationDir, f'{language_str}.qm')

Binary file not shown.

View File

@ -1 +0,0 @@
Placeholder file so that the log folder gets added when commiting

View File

@ -206,6 +206,7 @@ class Ui_MainWindow(object):
self.label_arrow.setObjectName(u"label_arrow")
self.label_arrow.setMaximumSize(QSize(16777215, 60))
self.label_arrow.setStyleSheet(u"font-size: 40px;")
self.label_arrow.setText(u"\u2193")
self.label_arrow.setAlignment(Qt.AlignCenter)
self.verticalLayout.addWidget(self.label_arrow)
@ -486,8 +487,6 @@ class Ui_MainWindow(object):
"MainWindow", u"Vocal Remover", None))
self.pushButton_musicFiles.setText(QCoreApplication.translate(
"MainWindow", u"Drag your music files", None))
self.label_arrow.setText(
QCoreApplication.translate("MainWindow", u"\u2193", None))
self.label_vocalsFile.setText(
QCoreApplication.translate("MainWindow", u"Audio File", None))
self.pushButton_play_vocals.setText("")
@ -501,5 +500,5 @@ class Ui_MainWindow(object):
self.label_vocals.setText(
QCoreApplication.translate("MainWindow", u"Vocals", None))
self.pushButton_seperate.setText(
QCoreApplication.translate("MainWindow", u" Seperate", None))
QCoreApplication.translate("MainWindow", u" Separate", None))
# retranslateUi

View File

@ -77,6 +77,7 @@ class Ui_PresetsEditor(object):
self.pushButton_add.setObjectName(u"pushButton_add")
self.pushButton_add.setMinimumSize(QSize(35, 35))
self.pushButton_add.setMaximumSize(QSize(35, 35))
self.pushButton_add.setText(u"+")
self.horizontalLayout.addWidget(self.pushButton_add)
@ -84,6 +85,7 @@ class Ui_PresetsEditor(object):
self.pushButton_delete.setObjectName(u"pushButton_delete")
self.pushButton_delete.setMinimumSize(QSize(35, 35))
self.pushButton_delete.setMaximumSize(QSize(35, 35))
self.pushButton_delete.setText(u"-")
self.horizontalLayout.addWidget(self.pushButton_delete)
@ -91,6 +93,7 @@ class Ui_PresetsEditor(object):
self.pushButton_import.setObjectName(u"pushButton_import")
self.pushButton_import.setMinimumSize(QSize(35, 35))
self.pushButton_import.setMaximumSize(QSize(35, 35))
self.pushButton_import.setText(u"")
self.horizontalLayout.addWidget(self.pushButton_import)
@ -98,6 +101,7 @@ class Ui_PresetsEditor(object):
self.pushButton_export.setObjectName(u"pushButton_export")
self.pushButton_export.setMinimumSize(QSize(35, 35))
self.pushButton_export.setMaximumSize(QSize(35, 35))
self.pushButton_export.setText(u"")
self.horizontalLayout.addWidget(self.pushButton_export)
@ -113,10 +117,4 @@ class Ui_PresetsEditor(object):
"PresetsEditor", u"Presets Editor", None))
self.label.setText(QCoreApplication.translate(
"PresetsEditor", u"Seperation Presets", None))
self.pushButton_add.setText(
QCoreApplication.translate("PresetsEditor", u"+", None))
self.pushButton_delete.setText(
QCoreApplication.translate("PresetsEditor", u"-", None))
self.pushButton_import.setText("")
self.pushButton_export.setText("")
# retranslateUi

View File

@ -18,7 +18,7 @@ class Ui_SettingsWindow(object):
if not SettingsWindow.objectName():
SettingsWindow.setObjectName(u"SettingsWindow")
SettingsWindow.setEnabled(True)
SettingsWindow.resize(953, 453)
SettingsWindow.resize(927, 453)
SettingsWindow.setStyleSheet(u"/* Universal */\n"
"* {\n"
" font: 10pt \"Yu Gothic UI\"; \n"
@ -136,21 +136,21 @@ class Ui_SettingsWindow(object):
self.verticalLayout.setSpacing(0)
self.verticalLayout.setObjectName(u"verticalLayout")
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.radioButton_seperationSettings = QRadioButton(
self.radioButton_separationSettings = QRadioButton(
self.frame_settingsSelection)
self.radioButton_seperationSettings.setObjectName(
u"radioButton_seperationSettings")
self.radioButton_separationSettings.setObjectName(
u"radioButton_separationSettings")
sizePolicy1 = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
sizePolicy1.setHorizontalStretch(0)
sizePolicy1.setVerticalStretch(0)
sizePolicy1.setHeightForWidth(
self.radioButton_seperationSettings.sizePolicy().hasHeightForWidth())
self.radioButton_seperationSettings.setSizePolicy(sizePolicy1)
self.radioButton_seperationSettings.setMinimumSize(QSize(0, 40))
self.radioButton_seperationSettings.setCheckable(True)
self.radioButton_seperationSettings.setProperty("menu", True)
self.radioButton_separationSettings.sizePolicy().hasHeightForWidth())
self.radioButton_separationSettings.setSizePolicy(sizePolicy1)
self.radioButton_separationSettings.setMinimumSize(QSize(0, 40))
self.radioButton_separationSettings.setCheckable(True)
self.radioButton_separationSettings.setProperty("menu", True)
self.verticalLayout.addWidget(self.radioButton_seperationSettings)
self.verticalLayout.addWidget(self.radioButton_separationSettings)
self.radioButton_shortcuts = QRadioButton(self.frame_settingsSelection)
self.radioButton_shortcuts.setObjectName(u"radioButton_shortcuts")
@ -218,7 +218,7 @@ class Ui_SettingsWindow(object):
self.scrollAreaWidgetContents_2 = QWidget()
self.scrollAreaWidgetContents_2.setObjectName(
u"scrollAreaWidgetContents_2")
self.scrollAreaWidgetContents_2.setGeometry(QRect(0, 0, 740, 481))
self.scrollAreaWidgetContents_2.setGeometry(QRect(0, 0, 735, 418))
sizePolicy2 = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
sizePolicy2.setHorizontalStretch(0)
sizePolicy2.setVerticalStretch(0)
@ -448,8 +448,11 @@ class Ui_SettingsWindow(object):
self.pushButton_presetsEdit = QPushButton(self.groupBox)
self.pushButton_presetsEdit.setObjectName(u"pushButton_presetsEdit")
sizePolicy3.setHeightForWidth(
self.pushButton_presetsEdit.sizePolicy().hasHeightForWidth())
self.pushButton_presetsEdit.setSizePolicy(sizePolicy3)
self.pushButton_presetsEdit.setMinimumSize(QSize(65, 27))
self.pushButton_presetsEdit.setMaximumSize(QSize(65, 16777215))
self.pushButton_presetsEdit.setMaximumSize(QSize(16777215, 16777215))
self.horizontalLayout_10.addWidget(self.pushButton_presetsEdit)
@ -519,16 +522,16 @@ class Ui_SettingsWindow(object):
self.gridLayout_5.setObjectName(u"gridLayout_5")
self.gridLayout_5.setContentsMargins(-1, 5, -1, 3)
self.comboBox_winSize_stacked = QComboBox(self.frame_constants)
self.comboBox_winSize_stacked.addItem("")
self.comboBox_winSize_stacked.addItem("")
self.comboBox_winSize_stacked.addItem("")
self.comboBox_winSize_stacked.addItem("")
self.comboBox_winSize_stacked.addItem(u"272")
self.comboBox_winSize_stacked.addItem(u"320")
self.comboBox_winSize_stacked.addItem(u"512")
self.comboBox_winSize_stacked.addItem(u"1024")
self.comboBox_winSize_stacked.setObjectName(
u"comboBox_winSize_stacked")
self.comboBox_winSize_stacked.setMinimumSize(QSize(0, 25))
self.comboBox_winSize_stacked.setMaximumSize(QSize(60, 25))
self.comboBox_winSize_stacked.setEditable(True)
self.comboBox_winSize_stacked.setCurrentText(u"512")
self.comboBox_winSize_stacked.setCurrentText(u"272")
self.comboBox_winSize_stacked.setProperty("canEdit", True)
self.gridLayout_5.addWidget(self.comboBox_winSize_stacked, 2, 2, 1, 1)
@ -622,15 +625,15 @@ class Ui_SettingsWindow(object):
self.gridLayout_5.addWidget(self.lineEdit_hopLength, 1, 0, 1, 1)
self.comboBox_winSize = QComboBox(self.frame_constants)
self.comboBox_winSize.addItem("")
self.comboBox_winSize.addItem("")
self.comboBox_winSize.addItem("")
self.comboBox_winSize.addItem("")
self.comboBox_winSize.addItem(u"272")
self.comboBox_winSize.addItem(u"320")
self.comboBox_winSize.addItem(u"512")
self.comboBox_winSize.addItem(u"1024")
self.comboBox_winSize.setObjectName(u"comboBox_winSize")
self.comboBox_winSize.setMinimumSize(QSize(0, 25))
self.comboBox_winSize.setMaximumSize(QSize(60, 25))
self.comboBox_winSize.setEditable(True)
self.comboBox_winSize.setCurrentText(u"512")
self.comboBox_winSize.setCurrentText(u"272")
self.comboBox_winSize.setProperty("canEdit", True)
self.gridLayout_5.addWidget(self.comboBox_winSize, 2, 0, 1, 1)
@ -707,7 +710,7 @@ class Ui_SettingsWindow(object):
self.scrollAreaWidgetContents = QWidget()
self.scrollAreaWidgetContents.setObjectName(
u"scrollAreaWidgetContents")
self.scrollAreaWidgetContents.setGeometry(QRect(0, 0, 98, 35))
self.scrollAreaWidgetContents.setGeometry(QRect(0, 0, 747, 394))
self.scrollAreaWidgetContents.setStyleSheet(u"QFrame#frame_engine, QFrame#frame_modelOptions {\n"
" background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0.221409, y2:0.587, stop:0.119318 rgba(85, 78, 163, 255), stop:0.683616 rgba(0, 0, 0, 0));\n"
"}")
@ -742,7 +745,7 @@ class Ui_SettingsWindow(object):
self.scrollAreaWidgetContents_4 = QWidget()
self.scrollAreaWidgetContents_4.setObjectName(
u"scrollAreaWidgetContents_4")
self.scrollAreaWidgetContents_4.setGeometry(QRect(0, 0, 98, 35))
self.scrollAreaWidgetContents_4.setGeometry(QRect(0, 0, 747, 394))
self.scrollAreaWidgetContents_4.setStyleSheet(u"QFrame#frame_engine, QFrame#frame_modelOptions {\n"
" background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0.221409, y2:0.587, stop:0.119318 rgba(85, 78, 163, 255), stop:0.683616 rgba(0, 0, 0, 0));\n"
"}")
@ -778,7 +781,7 @@ class Ui_SettingsWindow(object):
self.scrollAreaWidgetContents_5 = QWidget()
self.scrollAreaWidgetContents_5.setObjectName(
u"scrollAreaWidgetContents_5")
self.scrollAreaWidgetContents_5.setGeometry(QRect(0, 0, 773, 394))
self.scrollAreaWidgetContents_5.setGeometry(QRect(0, 0, 747, 394))
self.scrollAreaWidgetContents_5.setMinimumSize(QSize(600, 0))
self.scrollAreaWidgetContents_5.setStyleSheet(u"QFrame#frame_engine, QFrame#frame_modelOptions {\n"
" background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0.221409, y2:0.587, stop:0.119318 rgba(85, 78, 163, 255), stop:0.683616 rgba(0, 0, 0, 0));\n"
@ -792,10 +795,9 @@ class Ui_SettingsWindow(object):
self.frame_4.setFrameShape(QFrame.NoFrame)
self.frame_4.setFrameShadow(QFrame.Raised)
self.frame_4.setLineWidth(0)
self.verticalLayout_17 = QVBoxLayout(self.frame_4)
self.verticalLayout_17.setSpacing(15)
self.verticalLayout_17.setObjectName(u"verticalLayout_17")
self.verticalLayout_17.setContentsMargins(0, 0, 0, 10)
self.gridLayout_7 = QGridLayout(self.frame_4)
self.gridLayout_7.setObjectName(u"gridLayout_7")
self.gridLayout_7.setContentsMargins(0, 0, 0, 0)
self.frame_5 = QFrame(self.frame_4)
self.frame_5.setObjectName(u"frame_5")
self.frame_5.setFrameShape(QFrame.NoFrame)
@ -894,23 +896,23 @@ class Ui_SettingsWindow(object):
self.gridLayout_4.addWidget(self.checkBox_notifyUpdates, 1, 0, 1, 2)
self.checkBox_settingsStartup = QCheckBox(self.frame_8)
self.checkBox_settingsStartup.setObjectName(
u"checkBox_settingsStartup")
self.gridLayout_4.addWidget(self.checkBox_settingsStartup, 2, 0, 1, 1)
self.checkBox_notifiyOnFinish = QCheckBox(self.frame_8)
self.checkBox_notifiyOnFinish.setObjectName(
u"checkBox_notifiyOnFinish")
self.gridLayout_4.addWidget(self.checkBox_notifiyOnFinish, 0, 0, 1, 2)
self.checkBox_settingsStartup = QCheckBox(self.frame_8)
self.checkBox_settingsStartup.setObjectName(
u"checkBox_settingsStartup")
self.gridLayout_4.addWidget(self.checkBox_settingsStartup, 2, 0, 1, 2)
self.checkBox_multiThreading = QCheckBox(self.frame_8)
self.checkBox_multiThreading.setObjectName(u"checkBox_multiThreading")
self.checkBox_multiThreading.setEnabled(False)
self.gridLayout_4.addWidget(self.checkBox_multiThreading, 5, 0, 1, 1)
self.gridLayout_4.addWidget(self.checkBox_multiThreading, 5, 0, 1, 2)
self.verticalLayout_13.addWidget(self.frame_8)
@ -921,13 +923,11 @@ class Ui_SettingsWindow(object):
self.groupBox_export.setMinimumSize(QSize(0, 104))
self.groupBox_export.setAcceptDrops(True)
self.groupBox_export.setFlat(True)
self.formLayout = QFormLayout(self.groupBox_export)
self.formLayout.setObjectName(u"formLayout")
self.formLayout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)
self.formLayout.setRowWrapPolicy(QFormLayout.DontWrapRows)
self.formLayout.setHorizontalSpacing(20)
self.formLayout.setVerticalSpacing(10)
self.formLayout.setContentsMargins(35, 10, 30, 10)
self.gridLayout_8 = QGridLayout(self.groupBox_export)
self.gridLayout_8.setObjectName(u"gridLayout_8")
self.gridLayout_8.setHorizontalSpacing(20)
self.gridLayout_8.setVerticalSpacing(10)
self.gridLayout_8.setContentsMargins(35, 10, 30, 10)
self.frame_13 = QFrame(self.groupBox_export)
self.frame_13.setObjectName(u"frame_13")
self.frame_13.setMinimumSize(QSize(100, 0))
@ -943,6 +943,8 @@ class Ui_SettingsWindow(object):
self.label_3.sizePolicy().hasHeightForWidth())
self.label_3.setSizePolicy(sizePolicy5)
self.label_3.setMinimumSize(QSize(110, 0))
self.label_3.setAlignment(
Qt.AlignLeading | Qt.AlignLeft | Qt.AlignVCenter)
self.horizontalLayout_8.addWidget(self.label_3)
@ -958,7 +960,7 @@ class Ui_SettingsWindow(object):
self.horizontalLayout_8.addWidget(self.pushButton_exportDirectory)
self.formLayout.setWidget(0, QFormLayout.LabelRole, self.frame_13)
self.gridLayout_8.addWidget(self.frame_13, 0, 0, 1, 1)
self.label_exportDirectory = QLabel(self.groupBox_export)
self.label_exportDirectory.setObjectName(u"label_exportDirectory")
@ -974,14 +976,14 @@ class Ui_SettingsWindow(object):
self.label_exportDirectory.setIndent(5)
self.label_exportDirectory.setProperty("path", True)
self.formLayout.setWidget(
0, QFormLayout.FieldRole, self.label_exportDirectory)
self.gridLayout_8.addWidget(self.label_exportDirectory, 0, 1, 1, 1)
self.label_autoSave = QLabel(self.groupBox_export)
self.label_autoSave.setObjectName(u"label_autoSave")
self.label_autoSave.setAlignment(
Qt.AlignLeading | Qt.AlignLeft | Qt.AlignVCenter)
self.formLayout.setWidget(
1, QFormLayout.LabelRole, self.label_autoSave)
self.gridLayout_8.addWidget(self.label_autoSave, 1, 0, 1, 1)
self.frame_7 = QFrame(self.groupBox_export)
self.frame_7.setObjectName(u"frame_7")
@ -1007,7 +1009,7 @@ class Ui_SettingsWindow(object):
self.horizontalLayout_7.setStretch(0, 1)
self.horizontalLayout_7.setStretch(1, 1)
self.formLayout.setWidget(1, QFormLayout.FieldRole, self.frame_7)
self.gridLayout_8.addWidget(self.frame_7, 1, 1, 1, 1)
self.verticalLayout_20.addWidget(self.groupBox_export)
@ -1089,7 +1091,7 @@ class Ui_SettingsWindow(object):
self.horizontalLayout_6.setStretch(1, 2)
self.verticalLayout_17.addWidget(self.frame_5, 0, Qt.AlignTop)
self.gridLayout_7.addWidget(self.frame_5, 0, 0, 1, 1)
self.verticalLayout_16.addWidget(self.frame_4, 0, Qt.AlignTop)
@ -1134,9 +1136,9 @@ class Ui_SettingsWindow(object):
self.retranslateUi(SettingsWindow)
self.stackedWidget.setCurrentIndex(3)
self.comboBox_winSize_stacked.setCurrentIndex(2)
self.comboBox_winSize.setCurrentIndex(2)
self.stackedWidget.setCurrentIndex(0)
self.comboBox_winSize_stacked.setCurrentIndex(0)
self.comboBox_winSize.setCurrentIndex(0)
self.pushButton_english.setDefault(False)
self.pushButton_german.setDefault(False)
@ -1146,8 +1148,8 @@ class Ui_SettingsWindow(object):
def retranslateUi(self, SettingsWindow):
SettingsWindow.setWindowTitle(QCoreApplication.translate(
"SettingsWindow", u"Settings", None))
self.radioButton_seperationSettings.setText(
QCoreApplication.translate("SettingsWindow", u"Seperation Settings", None))
self.radioButton_separationSettings.setText(
QCoreApplication.translate("SettingsWindow", u"Separation Settings", None))
self.radioButton_shortcuts.setText(
QCoreApplication.translate("SettingsWindow", u"Shortcuts", None))
self.radioButton_customization.setText(
@ -1194,14 +1196,6 @@ class Ui_SettingsWindow(object):
"SettingsWindow", u"Models ", None))
self.label_2.setText(QCoreApplication.translate(
"SettingsWindow", u"Instrumental Model", None))
self.comboBox_winSize_stacked.setItemText(
0, QCoreApplication.translate("SettingsWindow", u"272", None))
self.comboBox_winSize_stacked.setItemText(
1, QCoreApplication.translate("SettingsWindow", u"320", None))
self.comboBox_winSize_stacked.setItemText(
2, QCoreApplication.translate("SettingsWindow", u"512", None))
self.comboBox_winSize_stacked.setItemText(
3, QCoreApplication.translate("SettingsWindow", u"1024", None))
self.label_hopLength.setText(QCoreApplication.translate(
"SettingsWindow", u"Hop Length", None))
@ -1215,14 +1209,6 @@ class Ui_SettingsWindow(object):
"SettingsWindow", u"Window Size", None))
self.label_nfft.setText(QCoreApplication.translate(
"SettingsWindow", u"N_FFT", None))
self.comboBox_winSize.setItemText(
0, QCoreApplication.translate("SettingsWindow", u"272", None))
self.comboBox_winSize.setItemText(
1, QCoreApplication.translate("SettingsWindow", u"320", None))
self.comboBox_winSize.setItemText(
2, QCoreApplication.translate("SettingsWindow", u"512", None))
self.comboBox_winSize.setItemText(
3, QCoreApplication.translate("SettingsWindow", u"1024", None))
self.label_4.setText(QCoreApplication.translate(
"SettingsWindow", u"Stacked Model", None))
@ -1243,25 +1229,25 @@ class Ui_SettingsWindow(object):
"SettingsWindow", u"Disable Shortcuts", None))
self.checkBox_notifyUpdates.setText(QCoreApplication.translate(
"SettingsWindow", u"Notify me of application updates", None))
self.checkBox_notifiyOnFinish.setText(QCoreApplication.translate(
"SettingsWindow", u"Notify me on finish of separation", None))
self.checkBox_settingsStartup.setText(QCoreApplication.translate(
"SettingsWindow", u"Open Settings on application startup", None))
self.checkBox_notifiyOnFinish.setText(QCoreApplication.translate(
"SettingsWindow", u"Notify me on finish of seperation", None))
# if QT_CONFIG(tooltip)
self.checkBox_multiThreading.setToolTip(QCoreApplication.translate(
"SettingsWindow", u"Process multiple files simultaneously", None))
#endif // QT_CONFIG(tooltip)
self.checkBox_multiThreading.setText(QCoreApplication.translate(
"SettingsWindow", u"Multithreading (Experimental)", None))
"SettingsWindow", u"Multithreading (experimental)", None))
self.groupBox_export.setTitle(QCoreApplication.translate(
"SettingsWindow", u"Export Settings ", None))
self.label_3.setText(QCoreApplication.translate(
"SettingsWindow", u"Export Directory", None))
"SettingsWindow", u"Export Directory:", None))
self.pushButton_exportDirectory.setText("")
self.label_autoSave.setText(QCoreApplication.translate(
"SettingsWindow", u"Automatically Save:", None))
self.checkBox_autoSaveInstrumentals.setText(
QCoreApplication.translate("SettingsWindow", u"Instrumentals", None))
QCoreApplication.translate("SettingsWindow", u"Instrumental", None))
self.checkBox_autoSaveVocals.setText(
QCoreApplication.translate("SettingsWindow", u"Vocals", None))
self.groupBox_4.setTitle(QCoreApplication.translate(

View File

@ -129,7 +129,7 @@ class PresetsEditorWindow(QtWidgets.QWidget):
if settings is None:
settingsManager = self.app.settingsWindow.settingsManager
# Get current
settings = settingsManager.get_settings(page=0)
settings = settingsManager.get_settings(page_idx=0)
del settings['comboBox_presets']
name_to_json = {v: k for k, v in const.JSON_TO_NAME.items()} # Invert dict
for widget_objectName in list(settings.keys()):
@ -166,8 +166,14 @@ class PresetsEditorWindow(QtWidgets.QWidget):
"""
self.logger.info('Exporting Preset...',
indent_forwards=True)
#
item = self.ui.listWidget_presets.selectedItems()[0]
selected_items = self.ui.listWidget_presets.selectedItems()
if not selected_items:
# No item selected
self.logger.info('No item selected')
self.logger.indent_backwards()
return
item = selected_items[0]
itemText = item.text().replace(' ', '_')
file_name = f'{self.PRESET_PREFIX}{itemText}.json'
path = QtWidgets.QFileDialog().getSaveFileName(parent=self,
@ -182,6 +188,7 @@ class PresetsEditorWindow(QtWidgets.QWidget):
self.logger.info('Canceled preset export!',)
self.logger.indent_backwards()
return
self.presets_saveDir = os.path.dirname(path)
settings = item.data(Qt.UserRole)

View File

@ -150,7 +150,7 @@ class SettingsWindow(QtWidgets.QWidget):
self.ui.pushButton_resetDefault.clicked.connect(self.pushButton_resetDefault_clicked)
# Menu
self.menu_group.buttonClicked.connect(lambda btn:
self.menu_loadPage(index=self.menu_group.id(btn)))
self.menu_loadPage(page_idx=self.menu_group.id(btn)))
# -Seperation Settings Page-
self.ui.pushButton_presetsEdit.clicked.connect(self.pushButton_presetsEdit_clicked)
# Checkboxes
@ -208,7 +208,7 @@ class SettingsWindow(QtWidgets.QWidget):
self.settingsManager.fill_save_widgets()
# Connect button group for menu together
self.menu_group = QtWidgets.QButtonGroup(self) # Menu group
self.menu_group.addButton(self.ui.radioButton_seperationSettings,
self.menu_group.addButton(self.ui.radioButton_separationSettings,
id=0)
self.menu_group.addButton(self.ui.radioButton_shortcuts,
id=1)
@ -237,68 +237,6 @@ class SettingsWindow(QtWidgets.QWidget):
self.update_window()
self.logger.indent_backwards()
def _load_data(self, default: bool = False):
"""
Load the data for this window
(Only run right after window initialization or to reset settings)
Parameters:
default(bool):
Reset to the default settings
"""
self.logger.info('Loading data...',
indent_forwards=True)
self.settings.beginGroup('settingswindow')
if default:
# Delete settings group
self.settings.remove("")
# -Load Settings-
# Widgets
setting_widgets = [*self.ui.stackedWidget.findChildren(QtWidgets.QCheckBox),
*self.ui.stackedWidget.findChildren(QtWidgets.QComboBox),
*self.ui.stackedWidget.findChildren(QtWidgets.QLineEdit), ]
for widget in setting_widgets:
widgetObjectName = widget.objectName()
# -Errors-
if not widgetObjectName in const.DEFAULT_SETTINGS:
if not widgetObjectName:
# Empty object name no need to notify
continue
# Default settings do not exist
self.logger.warn(f'"{widgetObjectName}"; {widget.__class__} does not have a default setting!')
continue
# -Finding the instance and loading appropiately-
if isinstance(widget, QtWidgets.QCheckBox):
value = self.settings.value(widgetObjectName,
defaultValue=const.DEFAULT_SETTINGS[widgetObjectName],
type=bool)
widget.setChecked(value)
elif isinstance(widget, QtWidgets.QComboBox):
value = self.settings.value(widgetObjectName,
defaultValue=const.DEFAULT_SETTINGS[widgetObjectName],
type=str)
if widget.isEditable():
# Allows self-typing
widget.setCurrentText(value)
else:
# Only allows a list to choose from
all_items = [widget.itemText(i) for i in range(widget.count())]
for i, item in enumerate(all_items):
if item == value:
# Both have the same text
widget.setCurrentIndex(i)
elif isinstance(widget, QtWidgets.QLineEdit):
value = self.settings.value(widgetObjectName,
defaultValue=const.DEFAULT_SETTINGS[widgetObjectName],
type=str)
widget.setText(value)
# -Done-
self.settings.endGroup()
self.logger.indent_backwards()
# -Widget Binds-
def pushButton_clearCommand_clicked(self):
"""
@ -720,51 +658,66 @@ class SettingsWindow(QtWidgets.QWidget):
return model_name
def menu_loadPage(self, index: int):
"""
Load the given menu page by index and
adjust minimum size of window
def menu_loadPage(self, page_idx: int):
"""Load the given menu page by index
Parameters:
index(int):
0 = Seperation Settings
1 = Shortcuts
2 = Customization
3 = Preferences
Note:
Also adjust the minimum size of the window
based on the stored minimum width in the page
Args:
page_idx (int):
Which page to load.
0 - Seperation Settings Page
1 - Shortcuts Page
2 - Customization Page
3 - Preferences Page
"""
self.logger.info(f'Loading page with index {index}',
self.logger.info(f'Loading page with index {page_idx}',
indent_forwards=True)
def menu_loadPage():
# Load Page
stackedWidget = self.ui.stackedWidget
stackedWidget.setCurrentIndex(index)
stackedWidget.setCurrentIndex(page_idx)
# Check Radiobutton
self.menu_group.button(index).setChecked(True)
self.menu_group.button(page_idx).setChecked(True)
# Find Frame which specifies the minimum width
# Get specified minimum width from page
page = stackedWidget.currentWidget()
min_width = page.property('minimumFrameWidth')
self.ui.frame_14.setMinimumWidth(min_width)
# Update page based on index
self.menu_update_methods[index]()
self.menu_update_methods[page_idx]()
if self.ui.stackedWidget.currentIndex() == page_idx:
# Trying to load same page
self.logger.info('Skipping load -> page already loaded')
self.logger.indent_backwards()
return
if not self.ui.checkBox_disableAnimations.isChecked():
# Animations enabled
self.pages_ani.start()
# On half of whole aniamtion loaad new window
try:
# Disconnect last menu_loadPage
self.pageSwitchTimer.timeout.disconnect()
except RuntimeError:
# No signal to disconnect
pass
# On half of whole aniamtion load new window
self.pageSwitchTimer.timeout.connect(menu_loadPage)
self.pageSwitchTimer.start()
else:
menu_loadPage()
self.logger.indent_backwards()
# -Overriden methods-
def closeEvent(self, event: QtCore.QEvent):
"""
Catch close event of this window to save data
"""
"""Catch close event of this window to save data"""
# -Save the geometry for this window-
self.settings.setValue('settingswindow/size',
self.size())
@ -773,13 +726,12 @@ class SettingsWindow(QtWidgets.QWidget):
# Commit Save
self.settings.sync()
# -Close Window-
self.app.windows['presetsEditor'].hide()
# Hide the presets editor window (child window)
self.app.presetsEditorWindow.hide()
event.accept()
def update_translation(self):
"""
Update translation of this window
"""
"""Update translation of this window"""
self.logger.info('Settings: Retranslating UI')
self.ui.retranslateUi(self)
@ -791,6 +743,7 @@ class SettingsManager:
win (SettingsWindow): Settings window that is being managed
save_widgets (dict): Configurable widgets that the window contains
Key - Page number
Value - Widgets
"""
def __init__(self, win: SettingsWindow):
@ -812,7 +765,9 @@ class SettingsManager:
Assign all instances of the widgets on the
settings window to their corresponding page.
(Only run right after window initialization)
Note:
Only run right after window initialization
"""
# Get widgets
seperation_settings_widgets = [
@ -873,12 +828,12 @@ class SettingsManager:
self.save_widgets[2] = customization_widgets
self.save_widgets[3] = preferences_widgets
def get_settings(self, page: Optional[int] = None) -> Dict[str, Union[bool, str]]:
def get_settings(self, page_idx: Optional[int] = None) -> Dict[str, Union[bool, str]]:
"""Obtain states of the widgets
Args:
page (Optional[int], optional):
Which page to load the widgets from.
page_idx (Optional[int], optional):
Which page to load the widgets from to get the settings.
Defaults to None.
0 - Seperation Settings Page
@ -888,7 +843,7 @@ class SettingsManager:
None - All widgets
Raises:
TypeError: Invalid widget type in the settings (has to be either: QCheckBox, QLineEdit or QComboBox)
TypeError: Invalid widget type in the widgets (has to be either: QCheckBox, QLineEdit or QComboBox)
Returns:
Dict[str, Union[bool, str]]: Widget states
@ -897,7 +852,7 @@ class SettingsManager:
"""
settings = OrderedDict()
save_widgets = self.get_widgets(page=page)
save_widgets = self.get_widgets(page_idx=page_idx)
for widget in save_widgets:
# Get value
@ -938,7 +893,7 @@ class SettingsManager:
settings (Dict[str, Union[bool, str]]): States of the widgets to update
Raises:
TypeError: Invalid widget type in the settings (has to be either: QCheckBox, QLineEdit or QComboBox)
TypeError: Invalid widget type in the widgets (has to be either: QCheckBox, QLineEdit or QComboBox)
"""
self.win.suppress_settings_change_event = True
for widget_objectName, value in settings.items():
@ -970,7 +925,7 @@ class SettingsManager:
"""Load states of the widgets of the window
Raises:
TypeError: Invalid widget type in the settings (has to be either: QCheckBox, QLineEdit or QComboBox)
TypeError: Invalid widget type in the widgets (has to be either: QCheckBox, QLineEdit or QComboBox)
"""
# Before
self.win.logger.info('Settings: Loading window')
@ -1019,7 +974,7 @@ class SettingsManager:
"""Save states of the widgets of the window
Raises:
TypeError: Invalid widget type in the settings (has to be either: QCheckBox, QLineEdit or QComboBox)
TypeError: Invalid widget type in the widgets (has to be either: QCheckBox, QLineEdit or QComboBox)
"""
# Before
self.win.logger.info('Settings: Saving window')
@ -1048,11 +1003,11 @@ class SettingsManager:
value)
self.win.settings.endGroup()
def get_widgets(self, page: Optional[int] = None) -> list:
def get_widgets(self, page_idx: Optional[int] = None) -> list:
"""Obtain the configurable widgets in the window
Args:
page (Optional[int], optional):
page_idx (Optional[int], optional):
Which page to load the widgets from.
Defaults to None.
@ -1065,14 +1020,14 @@ class SettingsManager:
Returns:
list: Widgets of the given page
"""
if page is None:
if page_idx is None:
# Load all widgets
widgets = []
for widget_list in self.save_widgets.values():
widgets.extend(widget_list)
else:
# Load one page of widgets
assert page in self.save_widgets.keys(), "Invalid page index!"
widgets = self.save_widgets[page]
assert page_idx in self.save_widgets.keys(), "Invalid page index!"
widgets = self.save_widgets[page_idx]
return widgets