lint
This commit is contained in:
@@ -1,27 +1,34 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from PyQt6.QtCore import Qt, pyqtSlot
|
from PyQt6.QtCore import Qt, pyqtSlot
|
||||||
from PyQt6.QtWidgets import QDialog, QListWidgetItem, QAbstractItemView
|
|
||||||
from PyQt6.QtMultimedia import QMediaDevices
|
from PyQt6.QtMultimedia import QMediaDevices
|
||||||
|
from PyQt6.QtWidgets import QAbstractItemView, QDialog, QListWidgetItem
|
||||||
|
|
||||||
from ui.Preferences import Ui_Dialog
|
from ui.Preferences import Ui_Dialog
|
||||||
|
|
||||||
|
|
||||||
class Preferences(QDialog, Ui_Dialog):
|
class Preferences(QDialog, Ui_Dialog):
|
||||||
_instance = None
|
_instance = None
|
||||||
|
|
||||||
def __new__(cls):
|
def __new__(cls):
|
||||||
if cls._instance:
|
if cls._instance:
|
||||||
return cls._instance
|
return cls._instance
|
||||||
cls._instance = super(Preferences, cls).__new__(cls)
|
cls._instance = super(Preferences, cls).__new__(cls)
|
||||||
return cls._instance
|
return cls._instance
|
||||||
|
|
||||||
@pyqtSlot(int)
|
@pyqtSlot(int)
|
||||||
def done(self,r):
|
def done(self, r):
|
||||||
self.hide()
|
self.hide()
|
||||||
super().done(r)
|
super().done(r)
|
||||||
return
|
return
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def exec(self):
|
def exec(self):
|
||||||
self.show()
|
self.show()
|
||||||
super().exec()
|
super().exec()
|
||||||
return
|
return
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def open(self):
|
def open(self):
|
||||||
self.show()
|
self.show()
|
||||||
@@ -35,8 +42,12 @@ class Preferences(QDialog, Ui_Dialog):
|
|||||||
#
|
#
|
||||||
# Overrides
|
# Overrides
|
||||||
#
|
#
|
||||||
self.alertList.setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection)
|
self.alertList.setSelectionMode(
|
||||||
self.playerList.setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection)
|
QAbstractItemView.SelectionMode.MultiSelection
|
||||||
|
)
|
||||||
|
self.playerList.setSelectionMode(
|
||||||
|
QAbstractItemView.SelectionMode.MultiSelection
|
||||||
|
)
|
||||||
self.readerCombo.setEditable(False)
|
self.readerCombo.setEditable(False)
|
||||||
self.phoneticsCombo.setEditable(False)
|
self.phoneticsCombo.setEditable(False)
|
||||||
#
|
#
|
||||||
@@ -51,45 +62,57 @@ class Preferences(QDialog, Ui_Dialog):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def setCurrent(self):
|
def setCurrent(self):
|
||||||
if os.path.exists('preferences.json'):
|
if os.path.exists("preferences.json"):
|
||||||
with open('preferences.json','r') as f:
|
with open("preferences.json", "r") as f:
|
||||||
self.preferences = json.load(f)
|
self.preferences = json.load(f)
|
||||||
else:
|
else:
|
||||||
self.preferences = {
|
self.preferences = {
|
||||||
'readerFont': 'OpenDyslexic',
|
"readerFont": "OpenDyslexic",
|
||||||
'phoneticFont': 'Gentium',
|
"phoneticFont": "Gentium",
|
||||||
'alertOutputs': [ 'default' ],
|
"alertOutputs": ["default"],
|
||||||
'playerOutputs': [ 'Feed for virtual microphone' ]
|
"playerOutputs": ["Feed for virtual microphone"],
|
||||||
}
|
}
|
||||||
for output in self.preferences['alertOutputs']:
|
for output in self.preferences["alertOutputs"]:
|
||||||
if output == 'default':
|
if output == "default":
|
||||||
output = QMediaDevices.defaultAudioOutput().description()
|
output = QMediaDevices.defaultAudioOutput().description()
|
||||||
for item in self.alertList.findItems(output,Qt.MatchFlag.MatchExactly):
|
for item in self.alertList.findItems(
|
||||||
|
output, Qt.MatchFlag.MatchExactly
|
||||||
|
):
|
||||||
item.setSelected(True)
|
item.setSelected(True)
|
||||||
for output in self.preferences['playerOutputs']:
|
for output in self.preferences["playerOutputs"]:
|
||||||
if output == 'default':
|
if output == "default":
|
||||||
output = QMediaDevices.defaultAudioOutput().description()
|
output = QMediaDevices.defaultAudioOutput().description()
|
||||||
for item in self.playerList.findItems(output,Qt.MatchFlag.MatchExactly ):
|
for item in self.playerList.findItems(
|
||||||
|
output, Qt.MatchFlag.MatchExactly
|
||||||
|
):
|
||||||
item.setSelected(True)
|
item.setSelected(True)
|
||||||
index = self.readerCombo.findText(self.preferences['readerFont'])
|
index = self.readerCombo.findText(self.preferences["readerFont"])
|
||||||
if index >= 0:
|
if index >= 0:
|
||||||
self.readerCombo.setCurrentIndex(index)
|
self.readerCombo.setCurrentIndex(index)
|
||||||
index = self.phoneticsCombo.findText(self.preferences['phoneticFont'])
|
index = self.phoneticsCombo.findText(self.preferences["phoneticFont"])
|
||||||
if index >= 0:
|
if index >= 0:
|
||||||
self.phoneticsCombo.setCurrentIndex(index)
|
self.phoneticsCombo.setCurrentIndex(index)
|
||||||
return
|
return
|
||||||
|
|
||||||
def get(self, name:str =None):
|
def get(self, name: str = None):
|
||||||
if not name:
|
if not name:
|
||||||
return self.preferences
|
return self.preferences
|
||||||
return self.preferences[name]
|
return self.preferences[name]
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
self.preferences['readerFont'] = self.readerCombo.currentFont().family()
|
self.preferences["readerFont"] = self.readerCombo.currentFont().family()
|
||||||
self.preferences['phoneticFont'] =self.phoneticsCombo.currentFont().family()
|
self.preferences[
|
||||||
self.preferences['alertOutputs'] = [ x.data(Qt.ItemDataRole.DisplayRole) for x in self.alertList.selectedItems() ]
|
"phoneticFont"
|
||||||
self.preferences['playerOutputs'] = [ x.data(Qt.ItemDataRole.DisplayRole) for x in self.playerList.selectedItems() ]
|
] = self.phoneticsCombo.currentFont().family()
|
||||||
with open('preferences.json','w') as f:
|
self.preferences["alertOutputs"] = [
|
||||||
json.dump(self.preferences,f,indent=2)
|
x.data(Qt.ItemDataRole.DisplayRole)
|
||||||
|
for x in self.alertList.selectedItems()
|
||||||
|
]
|
||||||
|
self.preferences["playerOutputs"] = [
|
||||||
|
x.data(Qt.ItemDataRole.DisplayRole)
|
||||||
|
for x in self.playerList.selectedItems()
|
||||||
|
]
|
||||||
|
with open("preferences.json", "w") as f:
|
||||||
|
json.dump(self.preferences, f, indent=2)
|
||||||
super().accept()
|
super().accept()
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -12,12 +12,13 @@ from PyQt6.QtMultimedia import (
|
|||||||
|
|
||||||
class SoundOff(QObject):
|
class SoundOff(QObject):
|
||||||
_instance = None
|
_instance = None
|
||||||
|
|
||||||
def __new__(cls):
|
def __new__(cls):
|
||||||
if cls._instance:
|
if cls._instance:
|
||||||
return cls._instance
|
return cls._instance
|
||||||
cls._instance = super(SoundOff, cls).__new__(cls)
|
cls._instance = super(SoundOff, cls).__new__(cls)
|
||||||
return cls._instance
|
return cls._instance
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
#
|
#
|
||||||
|
|||||||
7
main.py
7
main.py
@@ -61,7 +61,6 @@ def query_error(query: QSqlQuery) -> None:
|
|||||||
|
|
||||||
|
|
||||||
class MainWindow(QMainWindow, Ui_MainWindow):
|
class MainWindow(QMainWindow, Ui_MainWindow):
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super(MainWindow, self).__init__()
|
super(MainWindow, self).__init__()
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
@@ -72,7 +71,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||||||
os.path.join(os.path.dirname(__file__), "ui/resources.rcc"), "/"
|
os.path.join(os.path.dirname(__file__), "ui/resources.rcc"), "/"
|
||||||
):
|
):
|
||||||
raise Exception("Unable to register resources.rcc")
|
raise Exception("Unable to register resources.rcc")
|
||||||
|
|
||||||
model = QSqlQueryModel()
|
model = QSqlQueryModel()
|
||||||
query = QSqlQuery("SELECT * FROM people ORDER BY name")
|
query = QSqlQuery("SELECT * FROM people ORDER BY name")
|
||||||
model.setQuery(query)
|
model.setQuery(query)
|
||||||
@@ -91,9 +90,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||||||
self.actionRead.enabledChanged.connect(self.readBtn.setEnabled)
|
self.actionRead.enabledChanged.connect(self.readBtn.setEnabled)
|
||||||
self.actionAddPerson.triggered.connect(self.addPerson)
|
self.actionAddPerson.triggered.connect(self.addPerson)
|
||||||
self.actionEditPerson.triggered.connect(self.editPerson)
|
self.actionEditPerson.triggered.connect(self.editPerson)
|
||||||
self.actionEditPerson.enabledChanged.connect(
|
self.actionEditPerson.enabledChanged.connect(self.editBtn.setEnabled)
|
||||||
self.editBtn.setEnabled
|
|
||||||
)
|
|
||||||
self.actionPreferences.triggered.connect(self.editPreferences)
|
self.actionPreferences.triggered.connect(self.editPreferences)
|
||||||
self.peopleView.doubleClicked.connect(self.editPerson)
|
self.peopleView.doubleClicked.connect(self.editPerson)
|
||||||
self.peopleView.clicked.connect(self.selectedPerson)
|
self.peopleView.clicked.connect(self.selectedPerson)
|
||||||
|
|||||||
Reference in New Issue
Block a user