You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.8 KiB
81 lines
2.8 KiB
import os
|
|
from PyQt5.QtWidgets import QApplication, QAction, QLabel, QDialogButtonBox, QDialog, QFileDialog, QMessageBox, QPushButton, QLineEdit, QCheckBox, QSpinBox, QDoubleSpinBox, QTableWidgetItem, QTabWidget, QComboBox, QWidget, QScrollArea, QMainWindow, QShortcut
|
|
from PyQt5.QtCore import QFile, QObject, Qt
|
|
from PyQt5.QtGui import QImage, QPixmap
|
|
from PyQt5 import uic
|
|
|
|
from chordsheet.common import scriptDir
|
|
import _version
|
|
|
|
class GuitarDialog(QDialog):
|
|
"""
|
|
Dialogue to allow the user to enter a guitar chord voicing. Not particularly advanced at present!
|
|
May be extended in future.
|
|
"""
|
|
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.UIFileLoader(
|
|
str(os.path.join(scriptDir, 'ui', 'guitardialog.ui')))
|
|
|
|
def UIFileLoader(self, ui_file):
|
|
ui_file = QFile(ui_file)
|
|
ui_file.open(QFile.ReadOnly)
|
|
|
|
self.dialog = uic.loadUi(ui_file)
|
|
ui_file.close()
|
|
|
|
def getVoicing(self, existingVoicing):
|
|
"""
|
|
Show the dialogue and return the voicing that has been entered.
|
|
"""
|
|
lineEditsList = [
|
|
self.dialog.ELineEdit,
|
|
self.dialog.ALineEdit,
|
|
self.dialog.DLineEdit,
|
|
self.dialog.GLineEdit,
|
|
self.dialog.BLineEdit,
|
|
self.dialog.eLineEdit
|
|
]
|
|
|
|
# Read the present voicing
|
|
if type(existingVoicing) == list:
|
|
for count in range(len(existingVoicing)):
|
|
lineEditsList[count].setText(existingVoicing[count])
|
|
|
|
if self.dialog.exec_() == QDialog.Accepted:
|
|
result = [self.dialog.ELineEdit.text() or 'x',
|
|
self.dialog.ALineEdit.text() or 'x',
|
|
self.dialog.DLineEdit.text() or 'x',
|
|
self.dialog.GLineEdit.text() or 'x',
|
|
self.dialog.BLineEdit.text() or 'x',
|
|
self.dialog.eLineEdit.text() or 'x']
|
|
resultJoined = ",".join(result)
|
|
return resultJoined
|
|
else:
|
|
return None
|
|
|
|
|
|
class AboutDialog(QDialog):
|
|
"""
|
|
Dialogue showing information about the program.
|
|
"""
|
|
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.UIFileLoader(str(os.path.join(scriptDir, 'ui', 'aboutdialog.ui')))
|
|
|
|
icon = QImage(str(os.path.join(scriptDir, 'ui', 'icon.png')))
|
|
self.dialog.iconLabel.setPixmap(QPixmap.fromImage(icon).scaled(self.dialog.iconLabel.width(
|
|
), self.dialog.iconLabel.height(), Qt.KeepAspectRatio, transformMode=Qt.SmoothTransformation))
|
|
|
|
self.dialog.versionLabel.setText("Version " + _version.version)
|
|
|
|
self.dialog.exec()
|
|
|
|
def UIFileLoader(self, ui_file):
|
|
ui_file = QFile(ui_file)
|
|
ui_file.open(QFile.ReadOnly)
|
|
|
|
self.dialog = uic.loadUi(ui_file)
|
|
ui_file.close()
|