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

  1. import os
  2. from PyQt5.QtWidgets import QApplication, QAction, QLabel, QDialogButtonBox, QDialog, QFileDialog, QMessageBox, QPushButton, QLineEdit, QCheckBox, QSpinBox, QDoubleSpinBox, QTableWidgetItem, QTabWidget, QComboBox, QWidget, QScrollArea, QMainWindow, QShortcut
  3. from PyQt5.QtCore import QFile, QObject, Qt
  4. from PyQt5.QtGui import QImage, QPixmap
  5. from PyQt5 import uic
  6. from chordsheet.common import scriptDir
  7. import _version
  8. class GuitarDialog(QDialog):
  9. """
  10. Dialogue to allow the user to enter a guitar chord voicing. Not particularly advanced at present!
  11. May be extended in future.
  12. """
  13. def __init__(self):
  14. super().__init__()
  15. self.UIFileLoader(
  16. str(os.path.join(scriptDir, 'ui', 'guitardialog.ui')))
  17. def UIFileLoader(self, ui_file):
  18. ui_file = QFile(ui_file)
  19. ui_file.open(QFile.ReadOnly)
  20. self.dialog = uic.loadUi(ui_file)
  21. ui_file.close()
  22. def getVoicing(self, existingVoicing):
  23. """
  24. Show the dialogue and return the voicing that has been entered.
  25. """
  26. lineEditsList = [
  27. self.dialog.ELineEdit,
  28. self.dialog.ALineEdit,
  29. self.dialog.DLineEdit,
  30. self.dialog.GLineEdit,
  31. self.dialog.BLineEdit,
  32. self.dialog.eLineEdit
  33. ]
  34. # Read the present voicing
  35. if type(existingVoicing) == list:
  36. for count in range(len(existingVoicing)):
  37. lineEditsList[count].setText(existingVoicing[count])
  38. if self.dialog.exec_() == QDialog.Accepted:
  39. result = [self.dialog.ELineEdit.text() or 'x',
  40. self.dialog.ALineEdit.text() or 'x',
  41. self.dialog.DLineEdit.text() or 'x',
  42. self.dialog.GLineEdit.text() or 'x',
  43. self.dialog.BLineEdit.text() or 'x',
  44. self.dialog.eLineEdit.text() or 'x']
  45. resultJoined = ",".join(result)
  46. return resultJoined
  47. else:
  48. return None
  49. class AboutDialog(QDialog):
  50. """
  51. Dialogue showing information about the program.
  52. """
  53. def __init__(self):
  54. super().__init__()
  55. self.UIFileLoader(str(os.path.join(scriptDir, 'ui', 'aboutdialog.ui')))
  56. icon = QImage(str(os.path.join(scriptDir, 'ui', 'icon.png')))
  57. self.dialog.iconLabel.setPixmap(QPixmap.fromImage(icon).scaled(self.dialog.iconLabel.width(
  58. ), self.dialog.iconLabel.height(), Qt.KeepAspectRatio, transformMode=Qt.SmoothTransformation))
  59. self.dialog.versionLabel.setText("Version " + _version.version)
  60. self.dialog.exec()
  61. def UIFileLoader(self, ui_file):
  62. ui_file = QFile(ui_file)
  63. ui_file.open(QFile.ReadOnly)
  64. self.dialog = uic.loadUi(ui_file)
  65. ui_file.close()