from PyQt5.QtWidgets import QApplication, QAction, QLabel, QDialogButtonBox, QDialog, QFileDialog, QMessageBox, QPushButton, QLineEdit, QCheckBox, QSpinBox, QDoubleSpinBox, QTableWidgetItem, QTabWidget, QComboBox, QWidget, QScrollArea, QMainWindow, QShortcut, QDialogButtonBox import sys class UnsavedMessageBox(QMessageBox): """ Message box to alert the user of unsaved changes and allow them to choose how to act. """ def __init__(self, fileName): super().__init__() self.setIcon(QMessageBox.Information) self.setWindowTitle("Unsaved changes") self.setText(f"The document \"{fileName}\" has been modified.") self.setInformativeText("Do you want to save your changes?") self.setStandardButtons( QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel) self.setDefaultButton(QMessageBox.Save) # If we are running on Haiku, use the MacOS button style to fit in more # with native applications if sys.platform.startswith("haiku"): buttonBox = self.findChild(QDialogButtonBox) buttonBox.setStyleSheet("* { button-layout: 1}") class UnreadableMessageBox(QMessageBox): """ Message box to warn the user that the chosen file cannot be opened. """ def __init__(self, fileName): super().__init__() self.setIcon(QMessageBox.Information) self.setWindowTitle(f"File \"{fileName}\" cannot be opened") self.setText("The file you have selected cannot be opened.") self.setInformativeText("Please make sure it is in the right format.") self.setStandardButtons(QMessageBox.Ok) self.setDefaultButton(QMessageBox.Ok) class ChordNameWarningMessageBox(QMessageBox): """ Message box to warn the user that a chord must have a name """ def __init__(self): super().__init__() self.setIcon(QMessageBox.Information) self.setWindowTitle("Unnamed chord") self.setText("Chords must have a name.") self.setInformativeText("Please give your chord a name and try again.") self.setStandardButtons(QMessageBox.Ok) self.setDefaultButton(QMessageBox.Ok) class SectionNameWarningMessageBox(QMessageBox): """ Message box to warn the user that a section must have a name """ def __init__(self): super().__init__() self.setIcon(QMessageBox.Information) self.setWindowTitle("Unnamed section") self.setText("Sections must have a unique name.") self.setInformativeText( "Please give your section a unique name and try again.") self.setStandardButtons(QMessageBox.Ok) self.setDefaultButton(QMessageBox.Ok) class BlockMustHaveSectionWarningMessageBox(QMessageBox): """ Message box to warn the user that a block must belong to a section """ def __init__(self): super().__init__() self.setIcon(QMessageBox.Information) self.setWindowTitle("No sections found") self.setText("Each block must belong to a section, but no sections have yet been created.") self.setInformativeText( "Please create a section before adding blocks.") self.setStandardButtons(QMessageBox.Ok) self.setDefaultButton(QMessageBox.Ok) class VoicingWarningMessageBox(QMessageBox): """ Message box to warn the user that the voicing entered could not be parsed """ def __init__(self): super().__init__() self.setIcon(QMessageBox.Information) self.setWindowTitle("Malformed voicing") self.setText( "The voicing you entered was not understood and has not been applied.") self.setInformativeText( "Please try re-entering it in the correct format.") self.setStandardButtons(QMessageBox.Ok) self.setDefaultButton(QMessageBox.Ok) class LengthWarningMessageBox(QMessageBox): """ Message box to warn the user that a block must have a length """ def __init__(self): super().__init__() self.setIcon(QMessageBox.Information) self.setWindowTitle("Block without valid length") self.setText("Blocks must have a length.") self.setInformativeText( "Please enter a valid length for your block and try again.") self.setStandardButtons(QMessageBox.Ok) self.setDefaultButton(QMessageBox.Ok)