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.

124 lines
4.3 KiB

  1. from PyQt5.QtWidgets import QApplication, QAction, QLabel, QDialogButtonBox, QDialog, QFileDialog, QMessageBox, QPushButton, QLineEdit, QCheckBox, QSpinBox, QDoubleSpinBox, QTableWidgetItem, QTabWidget, QComboBox, QWidget, QScrollArea, QMainWindow, QShortcut, QDialogButtonBox
  2. import sys
  3. class UnsavedMessageBox(QMessageBox):
  4. """
  5. Message box to alert the user of unsaved changes and allow them to choose how to act.
  6. """
  7. def __init__(self, fileName):
  8. super().__init__()
  9. self.setIcon(QMessageBox.Information)
  10. self.setWindowTitle("Unsaved changes")
  11. self.setText(f"The document \"{fileName}\" has been modified.")
  12. self.setInformativeText("Do you want to save your changes?")
  13. self.setStandardButtons(
  14. QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)
  15. self.setDefaultButton(QMessageBox.Save)
  16. # If we are running on Haiku, use the MacOS button style to fit in more
  17. # with native applications
  18. if sys.platform.startswith("haiku"):
  19. buttonBox = self.findChild(QDialogButtonBox)
  20. buttonBox.setStyleSheet("* { button-layout: 1}")
  21. class UnreadableMessageBox(QMessageBox):
  22. """
  23. Message box to warn the user that the chosen file cannot be opened.
  24. """
  25. def __init__(self, fileName):
  26. super().__init__()
  27. self.setIcon(QMessageBox.Information)
  28. self.setWindowTitle(f"File \"{fileName}\" cannot be opened")
  29. self.setText("The file you have selected cannot be opened.")
  30. self.setInformativeText("Please make sure it is in the right format.")
  31. self.setStandardButtons(QMessageBox.Ok)
  32. self.setDefaultButton(QMessageBox.Ok)
  33. class ChordNameWarningMessageBox(QMessageBox):
  34. """
  35. Message box to warn the user that a chord must have a name
  36. """
  37. def __init__(self):
  38. super().__init__()
  39. self.setIcon(QMessageBox.Information)
  40. self.setWindowTitle("Unnamed chord")
  41. self.setText("Chords must have a name.")
  42. self.setInformativeText("Please give your chord a name and try again.")
  43. self.setStandardButtons(QMessageBox.Ok)
  44. self.setDefaultButton(QMessageBox.Ok)
  45. class SectionNameWarningMessageBox(QMessageBox):
  46. """
  47. Message box to warn the user that a section must have a name
  48. """
  49. def __init__(self):
  50. super().__init__()
  51. self.setIcon(QMessageBox.Information)
  52. self.setWindowTitle("Unnamed section")
  53. self.setText("Sections must have a unique name.")
  54. self.setInformativeText(
  55. "Please give your section a unique name and try again.")
  56. self.setStandardButtons(QMessageBox.Ok)
  57. self.setDefaultButton(QMessageBox.Ok)
  58. class BlockMustHaveSectionWarningMessageBox(QMessageBox):
  59. """
  60. Message box to warn the user that a block must belong to a section
  61. """
  62. def __init__(self):
  63. super().__init__()
  64. self.setIcon(QMessageBox.Information)
  65. self.setWindowTitle("No sections found")
  66. self.setText("Each block must belong to a section, but no sections have yet been created.")
  67. self.setInformativeText(
  68. "Please create a section before adding blocks.")
  69. self.setStandardButtons(QMessageBox.Ok)
  70. self.setDefaultButton(QMessageBox.Ok)
  71. class VoicingWarningMessageBox(QMessageBox):
  72. """
  73. Message box to warn the user that the voicing entered could not be parsed
  74. """
  75. def __init__(self):
  76. super().__init__()
  77. self.setIcon(QMessageBox.Information)
  78. self.setWindowTitle("Malformed voicing")
  79. self.setText(
  80. "The voicing you entered was not understood and has not been applied.")
  81. self.setInformativeText(
  82. "Please try re-entering it in the correct format.")
  83. self.setStandardButtons(QMessageBox.Ok)
  84. self.setDefaultButton(QMessageBox.Ok)
  85. class LengthWarningMessageBox(QMessageBox):
  86. """
  87. Message box to warn the user that a block must have a length
  88. """
  89. def __init__(self):
  90. super().__init__()
  91. self.setIcon(QMessageBox.Information)
  92. self.setWindowTitle("Block without valid length")
  93. self.setText("Blocks must have a length.")
  94. self.setInformativeText(
  95. "Please enter a valid length for your block and try again.")
  96. self.setStandardButtons(QMessageBox.Ok)
  97. self.setDefaultButton(QMessageBox.Ok)