Added translation infrastructure. Added markdown info boxes. Improved performance on window closing. Changed language identifiers to ISO-639

This commit is contained in:
Dilan Boskan 2021-07-10 00:57:48 +02:00
parent a046908550
commit 99e06d983f
38 changed files with 509 additions and 211 deletions

View File

@ -3,7 +3,7 @@ $PYDir = ".\windows\design"
$TS_Dir = "..\languages"
$QM_Dir = ".\resources\translations"
$PY_Dir = ".\windows"
$Languages = "german", "japanese", "filipino", "russian"
$Languages = "en", "de", "ja", "fil", "ru", "tr"
Set-Location $(Split-Path -Path $MyInvocation.MyCommand.Path)
# Get Files
$FileNames = New-Object Collections.Generic.List[String]
@ -46,10 +46,15 @@ for () {
$files += "$UIDir\$basename.ui "
$files += "$PY_Dir\$basename.py "
}
Foreach ($language in $Languages) {
cmd.exe /c "pyside2-lupdate -noobsolete $files -ts $TS_Dir/$language.qt.ts"
cmd.exe /c "lrelease -silent -removeidentical $TS_Dir/$language.qt.ts -qm $QM_Dir/$language.qm"
New-Item -ItemType Directory -Force -Path $QM_Dir/$language | Out-Null
New-Item -ItemType Directory -Force -Path $QM_Dir/$language/infos | Out-Null
if ($language -ne "en") {
Copy-Item -Path "$QM_Dir/en/infos/*" -Destination "$QM_Dir/$language/infos" -PassThru
}
cmd.exe /c "lrelease -silent -removeidentical $TS_Dir/$language.qt.ts -qm $QM_Dir/$language/$language.qm"
}
$ChangedFiles.Clear()
Write-Output "Done!"

View File

@ -10,6 +10,7 @@ from PySide2.QtGui import Qt
# -Root imports-
from .resources.resources_manager import (ResourcePaths, Logger)
from .inference import converter
from .translator import Translator
from . import constants as const
# -Other-
# Logging
@ -63,12 +64,13 @@ class CustomApplication(QtWidgets.QApplication):
self.threadpool = QtCore.QThreadPool(self)
# -Load Windows-
# Workaround for circular dependency
from .windows import (mainwindow, settingswindow, presetseditorwindow)
from .windows import (mainwindow, settingswindow, presetseditorwindow, infowindow)
# Collection of windows
self.windows: Dict[str, QtWidgets.QWidget] = {
'main': mainwindow.MainWindow(self),
'settings': settingswindow.SettingsWindow(self),
'presetsEditor': presetseditorwindow.PresetsEditorWindow(self),
'info': infowindow.InfoWindow(self),
}
self.mainWindow = self.windows['main']
self.settingsWindow = self.windows['settings']
@ -126,9 +128,9 @@ class CustomApplication(QtWidgets.QApplication):
# -After-
# Load language
language = QtCore.QLocale(self.settings.value('user/language',
const.DEFAULT_SETTINGS['language'])).language()
self.translator.load_language(language)
lang_code = self.settings.value('user/language',
const.DEFAULT_SETTINGS['language'])
self.translator.load_language(self.translator.LANGUAGES[lang_code]) # nopep8
# Load Theme
theme = self.settings.value('user/theme',
const.DEFAULT_SETTINGS['theme'])
@ -221,7 +223,7 @@ class CustomApplication(QtWidgets.QApplication):
self.settings.setValue('user/exportDirectory',
self.windows['settings'].exportDirectory)
self.settings.setValue('user/language',
self.translator.loaded_language)
self.translator.loaded_language.code)
self.settings.setValue('user/inputPaths',
self.windows['main'].inputPaths)
self.settings.setValue('user/inputsDirectory',
@ -266,78 +268,6 @@ class CustomApplication(QtWidgets.QApplication):
self.logger.info('--- Done! ---')
class Translator:
"""Localizer for the application
Manages the languages for the applications
Args:
loaded_language (str):
Currently loaded language in the application. To change, run method load_language.
"""
def __init__(self, app: CustomApplication):
self.app = app
self.logger = app.logger
self.loaded_language: str
self._translator = QtCore.QTranslator(self.app)
def load_language(self, language: QtCore.QLocale.Language = QtCore.QLocale.English) -> bool:
"""Load a language on the application
Note:
language arg info:
If the language given is not supported, a warning message will be reported to the logger
and the language will be set to english
Args:
language (QtCore.QLocale.Language, optional): Language to load. Defaults to English.
Returns:
bool: Whether the applications language was successfully changed to the given language
"""
language_str = QtCore.QLocale.languageToString(language).lower()
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')
if (not os.path.isfile(translation_path) and
language != QtCore.QLocale.English):
# Translation file does not exist
# Load default language (english)
self.logger.warning(f'Translation file does not exist! Switching to English. Language: {language_str}')
self.logger.indent_backwards()
self.load_language()
return False
# get language name to later store in settings
self.loaded_language = QtCore.QLocale(language).name()
# Load language
if language == QtCore.QLocale.English:
# English is base language so remove translator
self.app.removeTranslator(self._translator)
else:
self._translator.load(translation_path)
self.app.installTranslator(self._translator)
# -Windows are initialized-
# Update translation on all windows
for window in self.app.windows.values():
window.update_translation()
# Update settings window
for button in self.app.windows['settings'].ui.frame_languages.findChildren(QtWidgets.QPushButton):
language_str = QtCore.QLocale.languageToString(language).lower()
button_name = f'pushButton_{language_str}'
if button.objectName() == button_name:
# Language found
button.setChecked(True)
else:
# Not selected language
button.setChecked(False)
self.logger.indent_backwards()
return True
class ThemeManager:
"""Theme Manager for the application

View File

@ -6,6 +6,7 @@ Store Appliation info and default data
from PySide2 import QtCore
# -Root imports-
from .inference import converter
from .translator import Translator
from collections import OrderedDict
import torch
@ -43,7 +44,7 @@ DEFAULT_SETTINGS = {
# Export path (Default: desktop)
'exportDirectory': QtCore.QStandardPaths.writableLocation(QtCore.QStandardPaths.DesktopLocation),
# Language in format {language}_{country} (Default: system language)
'language': QtCore.QLocale.system().name(),
'language': Translator.SUPPORTED_LANGUAGES[QtCore.QLocale.system().language().name.decode('utf-8')],
# Presets for seperations
'presets': [
['ALL', {

View File

@ -5,19 +5,6 @@ import torch.nn.functional as F
from . import spec_utils
model_size_converter = {
'33966KB': {
},
'123821KB': {
},
'129605KB': {
}
}
class Conv2DBNActiv(nn.Module):
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, dilation=1, activ=nn.ReLU):

View File

@ -1,2 +0,0 @@
CONVERTER_TITLE = "Conversion Section"
CONVERTER_TEXT = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."

View File

@ -52,14 +52,6 @@ class ResourcePaths:
upload = os.path.join(abs_path, IMAGE_FOLDER, 'upload.png')
download = os.path.join(abs_path, IMAGE_FOLDER, 'download.png')
class flags:
_FLAG_FOLDER = 'flags'
english = os.path.join(abs_path, IMAGE_FOLDER, _FLAG_FOLDER, 'english.png')
german = os.path.join(abs_path, IMAGE_FOLDER, _FLAG_FOLDER, 'german.png')
japanese = os.path.join(abs_path, IMAGE_FOLDER, _FLAG_FOLDER, 'japan.png')
filipino = os.path.join(abs_path, IMAGE_FOLDER, _FLAG_FOLDER, 'filipino.png')
turkish = os.path.join(abs_path, IMAGE_FOLDER, _FLAG_FOLDER, 'turkish.png')
class themes:
dark_path = os.path.join(abs_path, THEMES_FOLDER, 'dark.qss')
light_path = os.path.join(abs_path, THEMES_FOLDER, 'light.qss')

View File

@ -146,9 +146,12 @@ QListWidget#listWidget_presets::item:selected {
}
/* Command Line*/
QTextBrowser {
border: none;
background-color: #2d2d2d;
}
QTextBrowser#textBrowser_command {
font: 8pt "Courier";
color: #EEE;
background-color: #2d2d2d;
}
/* Audio Player */
QLabel[audioPlayer="true"] {

View File

@ -0,0 +1 @@
<クd<>箆!ソ`。スン

View File

Before

Width:  |  Height:  |  Size: 668 B

After

Width:  |  Height:  |  Size: 668 B

View File

@ -0,0 +1 @@
German

View File

@ -0,0 +1 @@
<クd<>箆!ソ`。スン

View File

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 61 KiB

View File

@ -0,0 +1,11 @@
# Ultimate Vocal Remover GUI v5.0.0
## About
This application is a heavily modified version of the vocal remover AI created and posted by GitHub user [tsurumeso](https://github.com/tsurumeso). You can find tsurumeso's original command line version [here](https://github.com/tsurumeso/vocal-remover). The official v5 GUI is still under developement and will be released some time in Q3 2021. The v5 beta is available via command line only at this time. You can test it [here](https://github.com/Anjok07/ultimatevocalremovergui/tree/v5-beta-cml).
- **The Developers**
- [Anjok07](https://github.com/anjok07)- Model collaborator & UVR developer.
- [aufr33](https://github.com/aufr33) - Model collaborator & fellow UVR developer. This project wouldn't be what it is without your help, thank you for your continued support!
- [DilanBoskan](https://github.com/DilanBoskan) - The main UVR GUI developer. Thank you for helping bring the GUI to life! Your hard work and continued support is greatly appreciated.
- [tsurumeso](https://github.com/tsurumeso) - The engineer who authored the original AI code. Thank you for the hard work and dedication you put into the AI code UVR is built on!

View File

@ -0,0 +1 @@
<クd<>箆!ソ`。スン

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1 @@
Filipino

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -0,0 +1 @@
Japanese

View File

@ -0,0 +1 @@
<クd<>箆!ソ`。スン

View File

@ -0,0 +1 @@
Russian

View File

@ -0,0 +1 @@
<クd<>箆!ソ`。スン

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -0,0 +1,2 @@
Turkish
Turkish

View File

@ -0,0 +1 @@
<クd<>箆!ソ`。スン

View File

@ -1,18 +1,18 @@
[settingswindow]
size=@Size(940 483)
pos=@Point(133 193)
size=@Size(940 551)
pos=@Point(371 253)
checkBox_gpuConversion=false
checkBox_tta=false
checkBox_tta=true
checkBox_modelFolder=false
checkBox_outputImage=false
checkBox_postProcess=false
checkBox_deepExtraction=false
checkBox_postProcess=true
checkBox_deepExtraction=true
comboBox_instrumental=MGM-v5-2Band-32000-BETA1
comboBox_vocal=
comboBox_winSize=352
doubleSpinBox_aggressiveness=-0.1
comboBox_winSize=320
doubleSpinBox_aggressiveness=0.02
comboBox_highEndProcess=Mirroring
comboBox_presets=NONE
comboBox_presets=Custom
checkBox_notifiyOnFinish=false
checkBox_notifyUpdates=true
checkBox_settingsStartup=false
@ -23,17 +23,22 @@ comboBox_command=Off
checkBox_autoSaveInstrumentals=true
checkBox_autoSaveVocals=true
[mainwindow]
size=@Size(947 559)
pos=@Point(185 175)
isMaximized=false
[user]
exportDirectory=C:/Users/boska/Desktop
language=en_US
inputPaths=C:/Users/boska/Desktop/BagsdreedBoys.png
language=en
inputPaths=@Invalid()
inputsDirectory=C:/Users/boska/Desktop
presets=@Variant(\0\0\0\x7f\0\0\0\x18PySide::PyObjectWrapper\0\0\0\0\xc3\x80\x3X\x3\0\0\0\x41LLq\0}q\x1(X\xe\0\0\0\x61ggressivenessq\x2G?\xb9\x99\x99\x99\x99\x99\x9aX\xe\0\0\0\x64\x65\x65pExtractionq\x3\x88X\xe\0\0\0highEndProcessq\x4X\x6\0\0\0\x42ypassq\x5X\v\0\0\0modelFolderq\x6\x88X\v\0\0\0outputImageq\a\x88X\v\0\0\0postProcessq\b\x88X\x3\0\0\0ttaq\t\x88X\n\0\0\0windowSizeq\nM\0\x4u\x86q\v.), @Variant(\0\0\0\x7f\0\0\0\x18PySide::PyObjectWrapper\0\0\0\0\xc7\x80\x3X\x4\0\0\0NONEq\0}q\x1(X\xe\0\0\0\x61ggressivenessq\x2G\xbf\xb9\x99\x99\x99\x99\x99\x9aX\xe\0\0\0\x64\x65\x65pExtractionq\x3\x89X\xe\0\0\0highEndProcessq\x4X\t\0\0\0Mirroringq\x5X\v\0\0\0modelFolderq\x6\x89X\v\0\0\0outputImageq\a\x89X\v\0\0\0postProcessq\b\x89X\x3\0\0\0ttaq\t\x89X\n\0\0\0windowSizeq\nM`\x1u\x86q\v.)
presets_loadDir=C:/Users/boska/Desktop
presets_saveDir=C:/Users/boska/Desktop
theme=dark
[mainwindow]
size=@Size(946 559)
pos=@Point(486 260)
isMaximized=false
[infowindow]
size=@Size(555 462)
pos=@Point(1316 273)
isMaximized=false

103
src/translator.py Normal file
View File

@ -0,0 +1,103 @@
"""
Translator Class File
"""
# pylint: disable=no-name-in-module, import-error
# -GUI-
from typing import DefaultDict, Dict
from PySide2 import QtWidgets
from PySide2 import QtCore
from PySide2 import QtGui
import PySide2
from PySide2.QtGui import Qt
# -Root imports-
# None
# -Other-
# System
import os
import sys
class Language:
"""
Single language in the UVR System
"""
def __init__(self, name: str, code: str, folder_path: str):
self.name = name
self.code = code
self.folder_path = folder_path
self.flag_path = os.path.join(folder_path, 'flag.png')
self.qm_path = os.path.join(folder_path, f'{code}.qm')
self.load_infos()
def load_infos(self):
with open(os.path.join(self.folder_path, 'infos', 'settings_conversion.md')) as f:
self.settings_conversion = "\n".join(f.readlines())
class Translator:
"""Localizer for the application
Manages the languages for the applications
Args:
loaded_language (str):
Currently loaded language in the application. To change, run method load_language.
"""
SUPPORTED_LANGUAGES = DefaultDict(lambda: "en", **{
'english': 'en',
'german': 'de',
'japanese': 'ja',
'filipino': 'fil',
'russian': 'ru',
'turkish': 'tr',
})
LANGUAGES: Dict[str, Language] = {}
def __init__(self, app):
self.app = app
self.logger = app.logger
self.loaded_language: Language
self._translator = QtCore.QTranslator(self.app)
for lang_name, lang_code in self.SUPPORTED_LANGUAGES.items():
self.LANGUAGES[lang_code] = Language(lang_name, lang_code,
os.path.join(self.app.resources.localizationDir, lang_code))
def load_language(self, language: Language) -> bool:
"""Load a language on the application
Note:
language arg info:
If the language given is not supported, a warning message will be reported to the logger
and the language will be set to english
Args:
language (QtCore.QLocale.Language, optional): Language to load. Defaults to English.
Returns:
bool: Whether the applications language was successfully changed to the given language
"""
self.logger.info(f'Translating to "{language.name}"...',
indent_forwards=True)
# Load language
self._translator.load(language.qm_path)
self.app.installTranslator(self._translator)
# -Windows are initialized-
# Update translation on all windows
for window in self.app.windows.values():
window.update_translation()
# Update settings window
for button in self.app.windows['settings'].ui.frame_languages.findChildren(QtWidgets.QPushButton):
button_name = f'pushButton_{language.code}'
if button.objectName() == button_name:
# Language found
button.setChecked(True)
else:
# Not selected language
button.setChecked(False)
self.logger.indent_backwards()
self.loaded_language = language
return True

View File

@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
################################################################################
# Form generated from reading UI file 'infowindow.ui'
##
# Created by: Qt User Interface Compiler version 5.15.2
##
# WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
class Ui_InfoWindow(object):
def setupUi(self, InfoWindow):
if not InfoWindow.objectName():
InfoWindow.setObjectName(u"InfoWindow")
InfoWindow.resize(450, 357)
self.verticalLayout = QVBoxLayout(InfoWindow)
self.verticalLayout.setSpacing(0)
self.verticalLayout.setObjectName(u"verticalLayout")
self.verticalLayout.setContentsMargins(5, 0, 0, 0)
self.textEdit = QTextBrowser(InfoWindow)
self.textEdit.setObjectName(u"textEdit")
self.textEdit.setUndoRedoEnabled(False)
self.textEdit.setReadOnly(True)
self.textEdit.setHtml(u"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>")
self.textEdit.setTextInteractionFlags(
Qt.LinksAccessibleByMouse | Qt.TextSelectableByMouse)
self.textEdit.setOpenExternalLinks(True)
self.verticalLayout.addWidget(self.textEdit)
self.retranslateUi(InfoWindow)
QMetaObject.connectSlotsByName(InfoWindow)
# setupUi
def retranslateUi(self, InfoWindow):
InfoWindow.setWindowTitle(
QCoreApplication.translate("InfoWindow", u"Form", None))
# retranslateUi

View File

@ -132,7 +132,7 @@ class Ui_SettingsWindow(object):
self.scrollAreaWidgetContents_2 = QWidget()
self.scrollAreaWidgetContents_2.setObjectName(
u"scrollAreaWidgetContents_2")
self.scrollAreaWidgetContents_2.setGeometry(QRect(0, 0, 677, 504))
self.scrollAreaWidgetContents_2.setGeometry(QRect(0, 0, 566, 248))
sizePolicy2 = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
sizePolicy2.setHorizontalStretch(0)
sizePolicy2.setVerticalStretch(0)
@ -553,7 +553,7 @@ class Ui_SettingsWindow(object):
self.scrollAreaWidgetContents = QWidget()
self.scrollAreaWidgetContents.setObjectName(
u"scrollAreaWidgetContents")
self.scrollAreaWidgetContents.setGeometry(QRect(0, 0, 53, 35))
self.scrollAreaWidgetContents.setGeometry(QRect(0, 0, 98, 35))
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"
"}")
@ -588,7 +588,7 @@ class Ui_SettingsWindow(object):
self.scrollAreaWidgetContents_4 = QWidget()
self.scrollAreaWidgetContents_4.setObjectName(
u"scrollAreaWidgetContents_4")
self.scrollAreaWidgetContents_4.setGeometry(QRect(0, 0, 53, 35))
self.scrollAreaWidgetContents_4.setGeometry(QRect(0, 0, 98, 35))
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"
"}")
@ -866,8 +866,8 @@ class Ui_SettingsWindow(object):
self.frame_export_2.setObjectName(u"frame_export_2")
self.frame_export_2.setProperty("settingsContent", True)
self.gridLayout_10 = QGridLayout(self.frame_export_2)
self.gridLayout_10.setSpacing(10)
self.gridLayout_10.setObjectName(u"gridLayout_10")
self.gridLayout_10.setHorizontalSpacing(10)
self.gridLayout_10.setContentsMargins(35, 10, 30, 10)
self.pushButton_exportDirectory = QPushButton(self.frame_export_2)
self.pushButton_exportDirectory.setObjectName(
@ -976,58 +976,58 @@ class Ui_SettingsWindow(object):
self.gridLayout_3.setObjectName(u"gridLayout_3")
self.gridLayout_3.setHorizontalSpacing(6)
self.gridLayout_3.setContentsMargins(0, 0, 0, 0)
self.pushButton_german = QPushButton(self.frame_languages)
self.pushButton_german.setObjectName(u"pushButton_german")
self.pushButton_german.setMinimumSize(QSize(80, 49))
self.pushButton_german.setMaximumSize(QSize(80, 49))
self.pushButton_german.setText(u"")
self.pushButton_german.setCheckable(True)
self.pushButton_german.setChecked(False)
self.pushButton_german.setFlat(False)
self.pushButton_german.setProperty("language", True)
self.pushButton_de = QPushButton(self.frame_languages)
self.pushButton_de.setObjectName(u"pushButton_de")
self.pushButton_de.setMinimumSize(QSize(80, 49))
self.pushButton_de.setMaximumSize(QSize(80, 49))
self.pushButton_de.setText(u"")
self.pushButton_de.setCheckable(True)
self.pushButton_de.setChecked(False)
self.pushButton_de.setFlat(False)
self.pushButton_de.setProperty("language", True)
self.gridLayout_3.addWidget(self.pushButton_german, 0, 1, 1, 1)
self.gridLayout_3.addWidget(self.pushButton_de, 0, 1, 1, 1)
self.pushButton_english = QPushButton(self.frame_languages)
self.pushButton_english.setObjectName(u"pushButton_english")
self.pushButton_english.setMinimumSize(QSize(80, 49))
self.pushButton_english.setMaximumSize(QSize(80, 49))
self.pushButton_english.setText(u"")
self.pushButton_english.setCheckable(True)
self.pushButton_english.setChecked(False)
self.pushButton_english.setFlat(False)
self.pushButton_english.setProperty("language", True)
self.pushButton_en = QPushButton(self.frame_languages)
self.pushButton_en.setObjectName(u"pushButton_en")
self.pushButton_en.setMinimumSize(QSize(80, 49))
self.pushButton_en.setMaximumSize(QSize(80, 49))
self.pushButton_en.setText(u"")
self.pushButton_en.setCheckable(True)
self.pushButton_en.setChecked(False)
self.pushButton_en.setFlat(False)
self.pushButton_en.setProperty("language", True)
self.gridLayout_3.addWidget(self.pushButton_english, 0, 0, 1, 1)
self.gridLayout_3.addWidget(self.pushButton_en, 0, 0, 1, 1)
self.pushButton_japanese = QPushButton(self.frame_languages)
self.pushButton_japanese.setObjectName(u"pushButton_japanese")
self.pushButton_japanese.setMinimumSize(QSize(80, 49))
self.pushButton_japanese.setMaximumSize(QSize(80, 49))
self.pushButton_japanese.setToolTipDuration(-1)
self.pushButton_japanese.setCheckable(True)
self.pushButton_japanese.setProperty("language", True)
self.pushButton_ja = QPushButton(self.frame_languages)
self.pushButton_ja.setObjectName(u"pushButton_ja")
self.pushButton_ja.setMinimumSize(QSize(80, 49))
self.pushButton_ja.setMaximumSize(QSize(80, 49))
self.pushButton_ja.setToolTipDuration(-1)
self.pushButton_ja.setCheckable(True)
self.pushButton_ja.setProperty("language", True)
self.gridLayout_3.addWidget(self.pushButton_japanese, 1, 1, 1, 1)
self.gridLayout_3.addWidget(self.pushButton_ja, 1, 1, 1, 1)
self.pushButton_filipino = QPushButton(self.frame_languages)
self.pushButton_filipino.setObjectName(u"pushButton_filipino")
self.pushButton_filipino.setMinimumSize(QSize(80, 49))
self.pushButton_filipino.setMaximumSize(QSize(80, 49))
self.pushButton_filipino.setCheckable(True)
self.pushButton_filipino.setProperty("language", True)
self.pushButton_fil = QPushButton(self.frame_languages)
self.pushButton_fil.setObjectName(u"pushButton_fil")
self.pushButton_fil.setMinimumSize(QSize(80, 49))
self.pushButton_fil.setMaximumSize(QSize(80, 49))
self.pushButton_fil.setCheckable(True)
self.pushButton_fil.setProperty("language", True)
self.gridLayout_3.addWidget(self.pushButton_filipino, 1, 0, 1, 1)
self.gridLayout_3.addWidget(self.pushButton_fil, 1, 0, 1, 1)
self.pushButton_turkish = QPushButton(self.frame_languages)
self.pushButton_turkish.setObjectName(u"pushButton_turkish")
self.pushButton_turkish.setMinimumSize(QSize(80, 49))
self.pushButton_turkish.setMaximumSize(QSize(80, 49))
self.pushButton_turkish.setCheckable(True)
self.pushButton_turkish.setFlat(True)
self.pushButton_turkish.setProperty("language", True)
self.pushButton_tr = QPushButton(self.frame_languages)
self.pushButton_tr.setObjectName(u"pushButton_tr")
self.pushButton_tr.setMinimumSize(QSize(80, 49))
self.pushButton_tr.setMaximumSize(QSize(80, 49))
self.pushButton_tr.setCheckable(True)
self.pushButton_tr.setFlat(False)
self.pushButton_tr.setProperty("language", True)
self.gridLayout_3.addWidget(self.pushButton_turkish, 2, 0, 1, 1)
self.gridLayout_3.addWidget(self.pushButton_tr, 2, 0, 1, 1)
self.gridLayout_15.addWidget(
self.frame_languages, 0, 0, 1, 1, Qt.AlignTop)
@ -1059,8 +1059,8 @@ class Ui_SettingsWindow(object):
self.stackedWidget.setCurrentIndex(3)
self.comboBox_highEndProcess.setCurrentIndex(4)
self.comboBox_winSize.setCurrentIndex(0)
self.pushButton_german.setDefault(False)
self.pushButton_english.setDefault(False)
self.pushButton_de.setDefault(False)
self.pushButton_en.setDefault(False)
QMetaObject.connectSlotsByName(SettingsWindow)
# setupUi
@ -1179,22 +1179,26 @@ class Ui_SettingsWindow(object):
self.label_14.setText(QCoreApplication.translate(
"SettingsWindow", u"Language", None))
# if QT_CONFIG(tooltip)
self.pushButton_german.setToolTip(
self.pushButton_de.setToolTip(
QCoreApplication.translate("SettingsWindow", u"German", None))
#endif // QT_CONFIG(tooltip)
# if QT_CONFIG(tooltip)
self.pushButton_english.setToolTip(
self.pushButton_en.setToolTip(
QCoreApplication.translate("SettingsWindow", u"English", None))
#endif // QT_CONFIG(tooltip)
# if QT_CONFIG(tooltip)
self.pushButton_japanese.setToolTip(
QCoreApplication.translate("SettingsWindow", u"Japanese", None))
self.pushButton_ja.setToolTip(QCoreApplication.translate(
"SettingsWindow", u"Japanese", None))
#endif // QT_CONFIG(tooltip)
self.pushButton_japanese.setText("")
self.pushButton_ja.setText("")
# if QT_CONFIG(tooltip)
self.pushButton_filipino.setToolTip(
self.pushButton_fil.setToolTip(
QCoreApplication.translate("SettingsWindow", u"Filipino", None))
#endif // QT_CONFIG(tooltip)
self.pushButton_filipino.setText("")
self.pushButton_turkish.setText("")
self.pushButton_fil.setText("")
# if QT_CONFIG(tooltip)
self.pushButton_tr.setToolTip(
QCoreApplication.translate("SettingsWindow", u"Turkish", None))
#endif // QT_CONFIG(tooltip)
self.pushButton_tr.setText("")
# retranslateUi

140
src/windows/infowindow.py Normal file
View File

@ -0,0 +1,140 @@
# pylint: disable=no-name-in-module, import-error
# -GUI-
from PySide2 import QtWidgets
from PySide2 import QtCore
from PySide2 import QtGui
from PySide2.QtGui import Qt
from PySide2 import QtMultimedia
# -Root imports-
from ..resources.resources_manager import (ResourcePaths)
from ..inference import converter
from ..app import CustomApplication
from .. import constants as const
from .design import infowindow_ui
# -Other-
import subprocess
# System
import os
# Code annotation
from typing import (Tuple, Optional)
class InfoWindow(QtWidgets.QWidget):
"""
Main Window of UVR where seperation, progress and embedded seperated song-playing takes place
"""
def __init__(self, app: CustomApplication):
# -Window setup-
super(InfoWindow, self).__init__()
self.ui = infowindow_ui.Ui_InfoWindow()
self.ui.setupUi(self)
self.app = app
self.logger = app.logger
self.settings = self.app.settings
# -Other Variables-
# -Widget Binds-
# -Initialization methods-
def setup_window(self):
"""
Set up the window with binds, images, saved settings
(Only run right after window initialization of main and settings window)
"""
def load_geometry():
"""
Load the geometry of this window
"""
# Window is centered on primary window
default_size = self.size()
default_pos = QtCore.QPoint()
default_pos.setX((self.app.primaryScreen().size().width() / 2) - default_size.width() / 2)
default_pos.setY((self.app.primaryScreen().size().height() / 2) - default_size.height() / 2)
# Get data
self.settings.beginGroup(self.__class__.__name__.lower())
size = self.settings.value('size',
default_size)
pos = self.settings.value('pos',
default_pos)
isMaximized = self.settings.value('isMaximized',
False,
type=bool)
self.settings.endGroup()
# Apply data
self.move(pos)
if isMaximized:
self.setWindowState(Qt.WindowMaximized)
else:
self.resize(size)
def load_images():
"""
Load the images for this window and assign them to their widgets
"""
def bind_widgets():
"""
Bind the widgets here
"""
# -Before setup-
self.logger.info('InfoWindow -> Setting up',
indent_forwards=True)
# -Setup-
load_geometry()
load_images()
bind_widgets()
# -After setup-
# Late update
self.update_window()
self.logger.indent_backwards()
# -Other Methods-
def update_window(self):
"""
Update the text and states of widgets
in this window
"""
self.logger.info('Updating info window...',
indent_forwards=True)
self.logger.indent_backwards()
def save_window(self):
"""Save window
Save states of the widgets in this window
"""
def set_text(self, text: str):
self.ui.textEdit.setMarkdown(text)
# -Overriden methods-
def closeEvent(self, event: QtCore.QEvent):
"""
Catch close event of this window to save data
"""
# -Close all windows-
event.accept()
# -Save the geometry for this window-
self.settings.beginGroup(self.__class__.__name__.lower())
self.settings.setValue('size',
self.size())
self.settings.setValue('pos',
self.pos())
self.settings.setValue('isMaximized',
self.isMaximized())
self.settings.endGroup()
# Commit Save
self.settings.sync()
def update_translation(self):
"""
Update translation of this window
"""
self.logger.info('InfoWindow: Retranslating UI')
self.ui.retranslateUi(self)

View File

@ -578,6 +578,8 @@ class MainWindow(QtWidgets.QWidget):
"""
Catch close event of this window to save data
"""
# -Close all windows-
self.app.closeAllWindows()
# -Save the geometry for this window-
self.settings.beginGroup(self.__class__.__name__.lower())
self.settings.setValue('size',
@ -589,8 +591,6 @@ class MainWindow(QtWidgets.QWidget):
self.settings.endGroup()
# Commit Save
self.settings.sync()
# -Close all windows-
self.app.closeAllWindows()
def update_translation(self):
"""

View File

@ -167,7 +167,7 @@ class PresetsEditorWindow(QtWidgets.QWidget):
# Some paths already selected
msg = QtWidgets.QMessageBox()
msg.setWindowTitle(self.tr('Confirmation'))
msg.setWindowTitle(self.tr('Test', 'Confirmation', 'A'))
msg.setIcon(QtWidgets.QMessageBox.Icon.Warning)
msg.setText(f'You will delete {len(selected_items)} items. Do you wish to continue?')
msg.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
@ -311,6 +311,8 @@ class PresetsEditorWindow(QtWidgets.QWidget):
"""
Catch close event of this window to save data
"""
# -Close window-
event.accept()
# -Save the geometry for this window-
self.settings.beginGroup(self.__class__.__name__.lower())
self.settings.setValue('size',
@ -318,8 +320,6 @@ class PresetsEditorWindow(QtWidgets.QWidget):
self.settings.setValue('pos',
self.pos())
self.settings.endGroup()
# -Close window-
event.accept()
def update_translation(self):
"""

View File

@ -10,12 +10,11 @@ from ..inference.lib.model_param_init import ModelParameters
from ..resources.resources_manager import ResourcePaths
from ..app import CustomApplication
from .. import constants as const
from .. import infos as INFOS
from .design import settingswindow_ui
from .infowindow import InfoWindow
# -Other-
import datetime as dt
from collections import OrderedDict
import torch
# System
import hashlib
import os
@ -224,12 +223,9 @@ class SettingsWindow(QtWidgets.QWidget):
title (str): Title of Message
text (str): Content of Message
"""
msg = QtWidgets.QMessageBox()
msg.setWindowTitle(title)
msg.setIcon(QtWidgets.QMessageBox.Icon.Information)
msg.setText(text)
msg.setStandardButtons(QtWidgets.QMessageBox.Ok)
msg.exec_()
self.app.windows['info'].setWindowTitle(title)
self.app.windows['info'].set_text(text)
self.app.windows['info'].show()
# -Window Setup Methods-
@ -269,12 +265,12 @@ class SettingsWindow(QtWidgets.QWidget):
# Flag images
for button in self.ui.frame_languages.findChildren(QtWidgets.QPushButton):
# Loop through every button in the languages frame
language = button.objectName().split('_')[1]
lang_code = button.objectName().split('_')[1]
button.setText('')
# -Prepare rounded image-
# Load original image
img_path = getattr(ResourcePaths.images.flags, language)
img_path = self.app.translator.LANGUAGES[lang_code].flag_path
origin_img = QtGui.QPixmap(img_path)
origin_img = origin_img.scaled(button.width(), button.height(),
mode=Qt.TransformationMode.SmoothTransformation)
@ -341,9 +337,9 @@ class SettingsWindow(QtWidgets.QWidget):
for button in self.ui.frame_languages.findChildren(QtWidgets.QPushButton):
# Loop through every button in the languages frame
# Get capitalized language from button name
language_str = button.objectName().split('_')[1].capitalize()
lang_code = button.objectName().split('_')[1]
# Get language as QtCore.QLocale.Language
language: QtCore.QLocale.Language = getattr(QtCore.QLocale, language_str)
language = self.app.translator.LANGUAGES[lang_code]
# Call load language on button click
button.clicked.connect(lambda *args, lan=language: self.app.translator.load_language(lan))
# Pushbuttons
@ -355,7 +351,8 @@ class SettingsWindow(QtWidgets.QWidget):
self.ui.radioButton_lightTheme.clicked.connect(lambda: self.app.themeManager.load_theme('light'))
self.ui.radioButton_darkTheme.clicked.connect(lambda: self.app.themeManager.load_theme('dark'))
self.ui.info_conversion.clicked.connect(lambda: self.show_info(INFOS.CONVERTER_TITLE, INFOS.CONVERTER_TEXT))
self.ui.info_conversion.clicked.connect(lambda: self.show_info(self.tr("Conversion Info"),
self.app.translator.loaded_language.settings_conversion))
bind_settings_changed()
@ -618,6 +615,10 @@ class SettingsWindow(QtWidgets.QWidget):
# -Overriden methods-
def closeEvent(self, event: QtCore.QEvent):
"""Catch close event of this window to save data"""
# -Close Window-
# Hide the presets editor window (child window)
self.app.presetsEditorWindow.hide()
event.accept()
# -Save the geometry for this window-
self.settings.beginGroup(self.__class__.__name__.lower())
self.settings.setValue('size',
@ -627,10 +628,6 @@ class SettingsWindow(QtWidgets.QWidget):
self.settings.endGroup()
# Commit Save
self.settings.sync()
# -Close Window-
# Hide the presets editor window (child window)
self.app.presetsEditorWindow.hide()
event.accept()
def update_translation(self):
"""Update translation of this window"""

59
ui_files/infowindow.ui Normal file
View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>InfoWindow</class>
<widget class="QWidget" name="InfoWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>450</width>
<height>357</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QTextBrowser" name="textEdit">
<property name="undoRedoEnabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="html">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -287,8 +287,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>677</width>
<height>504</height>
<width>566</width>
<height>248</height>
</rect>
</property>
<property name="sizePolicy">
@ -761,7 +761,7 @@
<property name="settingsContent" stdset="0">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_17" rowstretch="0,0">
<layout class="QGridLayout" name="gridLayout_17" rowstretch="0">
<property name="leftMargin">
<number>20</number>
</property>
@ -1253,7 +1253,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>53</width>
<width>98</width>
<height>35</height>
</rect>
</property>
@ -1330,7 +1330,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>53</width>
<width>98</width>
<height>35</height>
</rect>
</property>
@ -1979,7 +1979,7 @@
<property name="bottomMargin">
<number>10</number>
</property>
<property name="horizontalSpacing">
<property name="spacing">
<number>10</number>
</property>
<item row="0" column="1">
@ -2198,7 +2198,7 @@
<number>6</number>
</property>
<item row="0" column="1">
<widget class="QPushButton" name="pushButton_german">
<widget class="QPushButton" name="pushButton_de">
<property name="minimumSize">
<size>
<width>80</width>
@ -2235,7 +2235,7 @@
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="pushButton_english">
<widget class="QPushButton" name="pushButton_en">
<property name="minimumSize">
<size>
<width>80</width>
@ -2272,7 +2272,7 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pushButton_japanese">
<widget class="QPushButton" name="pushButton_ja">
<property name="minimumSize">
<size>
<width>80</width>
@ -2303,7 +2303,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pushButton_filipino">
<widget class="QPushButton" name="pushButton_fil">
<property name="minimumSize">
<size>
<width>80</width>
@ -2331,7 +2331,7 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="pushButton_turkish">
<widget class="QPushButton" name="pushButton_tr">
<property name="minimumSize">
<size>
<width>80</width>
@ -2344,6 +2344,9 @@
<height>49</height>
</size>
</property>
<property name="toolTip">
<string>Turkish</string>
</property>
<property name="text">
<string/>
</property>
@ -2351,7 +2354,7 @@
<bool>true</bool>
</property>
<property name="flat">
<bool>true</bool>
<bool>false</bool>
</property>
<property name="language" stdset="0">
<bool>true</bool>