예제 #1
0
    def __init__(self, mainwindow):
        super(ScoreWizardDialog, self).__init__(mainwindow)
        self.addAction(mainwindow.actionCollection.help_whatsthis)
        self._pitchLanguage = None

        layout = QVBoxLayout()
        self.setLayout(layout)

        self.tabs = QTabWidget()
        b = self.dialogButtons = QDialogButtonBox()
        b.setStandardButtons(QDialogButtonBox.Reset
                             | QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        b.accepted.connect(self.accept)
        b.rejected.connect(self.reject)
        userguide.addButton(b, "scorewiz")
        b.button(QDialogButtonBox.Reset).clicked.connect(self.reset)
        self.previewButton = b.addButton('', QDialogButtonBox.ActionRole)
        self.previewButton.clicked.connect(self.showPreview)
        layout.addWidget(self.tabs)
        layout.addWidget(b)

        self.header = Header(self)
        self.tabs.addTab(self.header, '')
        self.parts = Parts(self)
        self.tabs.addTab(self.parts, '')
        self.settings = Settings(self)
        self.tabs.addTab(self.settings, '')

        self.tabs.setCurrentIndex(0)
        self.tabs.widget(0).widget()  # activate it
        self.tabs.currentChanged.connect(self.slotCurrentChanged)
        qutil.saveDialogSize(self, "scorewiz/dialog/size")
        app.translateUI(self)
        self.accepted.connect(self.slotAccepted)
예제 #2
0
    def __init__(self, parent=None):
        super(SessionEditor, self).__init__(parent)
        self.setWindowModality(Qt.WindowModal)

        layout = QVBoxLayout()
        self.setLayout(layout)

        grid = QGridLayout()
        layout.addLayout(grid)

        self.name = QLineEdit()
        self.nameLabel = l = QLabel()
        l.setBuddy(self.name)
        grid.addWidget(l, 0, 0)
        grid.addWidget(self.name, 0, 1)

        self.autosave = QCheckBox()
        grid.addWidget(self.autosave, 1, 1)

        self.basedir = widgets.urlrequester.UrlRequester()
        self.basedirLabel = l = QLabel()
        l.setBuddy(self.basedir)
        grid.addWidget(l, 2, 0)
        grid.addWidget(self.basedir, 2, 1)

        layout.addWidget(widgets.Separator())
        self.buttons = b = QDialogButtonBox(self)
        layout.addWidget(b)
        b.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        b.accepted.connect(self.accept)
        b.rejected.connect(self.reject)
        userguide.addButton(b, "sessions")
        app.translateUI(self)
예제 #3
0
    def __init__(self, mainwindow):
        super(ScoreWizardDialog, self).__init__(mainwindow)
        self.addAction(mainwindow.actionCollection.help_whatsthis)
        self._pitchLanguage = None

        layout = QVBoxLayout()
        self.setLayout(layout)

        self.tabs = QTabWidget()
        b = self.dialogButtons = QDialogButtonBox()
        b.setStandardButtons(
            QDialogButtonBox.Reset
            | QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        b.accepted.connect(self.accept)
        b.rejected.connect(self.reject)
        userguide.addButton(b, "scorewiz")
        b.button(QDialogButtonBox.Reset).clicked.connect(self.reset)
        self.previewButton = b.addButton('', QDialogButtonBox.ActionRole)
        self.previewButton.clicked.connect(self.showPreview)
        layout.addWidget(self.tabs)
        layout.addWidget(b)

        self.header = Header(self)
        self.tabs.addTab(self.header, '')
        self.parts = Parts(self)
        self.tabs.addTab(self.parts, '')
        self.settings = Settings(self)
        self.tabs.addTab(self.settings, '')

        self.tabs.setCurrentIndex(0)
        self.tabs.widget(0).widget() # activate it
        self.tabs.currentChanged.connect(self.slotCurrentChanged)
        qutil.saveDialogSize(self, "scorewiz/dialog/size")
        app.translateUI(self)
        self.accepted.connect(self.slotAccepted)
예제 #4
0
 def __init__(self, mainwindow):
     super(SessionManagerDialog, self).__init__(mainwindow)
     self.setWindowModality(Qt.WindowModal)
     layout = QVBoxLayout()
     self.setLayout(layout)
     
     self.sessions = SessionList(self)
     layout.addWidget(self.sessions)
     
     self.imp = QPushButton(self)
     self.exp = QPushButton(self)
     self.act = QPushButton(self)
     self.imp.clicked.connect(self.importSession)
     self.exp.clicked.connect(self.exportSession)
     self.act.clicked.connect(self.activateSession)
     
     self.sessions.layout().addWidget(self.imp, 5, 1)
     self.sessions.layout().addWidget(self.exp, 6, 1)
     self.sessions.layout().addWidget(self.act, 7, 1)
     
     layout.addWidget(widgets.Separator())
     
     self.buttons = b = QDialogButtonBox(self)
     layout.addWidget(b)
     b.setStandardButtons(QDialogButtonBox.Close)
     b.rejected.connect(self.accept)
     userguide.addButton(b, "sessions")
     self.sessions.load()
     app.translateUI(self)
     self.sessions.changed.connect(self.enableButtons)
     self.sessions.listBox.itemSelectionChanged.connect(self.enableButtons)
     self.enableButtons()
예제 #5
0
 def __init__(self, parent=None):
     super(SessionEditor, self).__init__(parent)
     self.setWindowModality(Qt.WindowModal)
     
     layout = QVBoxLayout()
     self.setLayout(layout)
     
     grid = QGridLayout()
     layout.addLayout(grid)
     
     self.name = QLineEdit()
     self.nameLabel = l = QLabel()
     l.setBuddy(self.name)
     grid.addWidget(l, 0, 0)
     grid.addWidget(self.name, 0, 1)
     
     self.autosave = QCheckBox()
     grid.addWidget(self.autosave, 1, 1)
     
     self.basedir = widgets.urlrequester.UrlRequester()
     self.basedirLabel = l = QLabel()
     l.setBuddy(self.basedir)
     grid.addWidget(l, 2, 0)
     grid.addWidget(self.basedir, 2, 1)
     
     layout.addWidget(widgets.Separator())
     self.buttons = b = QDialogButtonBox(self)
     layout.addWidget(b)
     b.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
     b.accepted.connect(self.accept)
     b.rejected.connect(self.reject)
     userguide.addButton(b, "sessions")
     app.translateUI(self)
예제 #6
0
    def __init__(self, mainwindow):
        super(SessionManagerDialog, self).__init__(mainwindow)
        self.setWindowModality(Qt.WindowModal)
        layout = QVBoxLayout()
        self.setLayout(layout)

        self.sessions = SessionList(self)
        layout.addWidget(self.sessions)

        self.imp = QPushButton(self)
        self.exp = QPushButton(self)
        self.act = QPushButton(self)
        self.imp.clicked.connect(self.importSession)
        self.exp.clicked.connect(self.exportSession)
        self.act.clicked.connect(self.activateSession)

        self.sessions.layout().addWidget(self.imp, 5, 1)
        self.sessions.layout().addWidget(self.exp, 6, 1)
        self.sessions.layout().addWidget(self.act, 7, 1)

        layout.addWidget(widgets.Separator())

        self.buttons = b = QDialogButtonBox(self)
        layout.addWidget(b)
        b.setStandardButtons(QDialogButtonBox.Close)
        b.rejected.connect(self.accept)
        userguide.addButton(b, "sessions")
        self.sessions.load()
        app.translateUI(self)
        self.sessions.changed.connect(self.enableButtons)
        self.sessions.listBox.itemSelectionChanged.connect(self.enableButtons)
        self.enableButtons()
예제 #7
0
    def __init__(self, parent=None):
        super(ModeShiftDialog, self).__init__(parent)
        
        mainLayout = QGridLayout()
        self.setLayout(mainLayout)
        
        self.keyLabel = QLabel()
        self.keyInput = QLineEdit()
        self.modeCombo = QComboBox()
        self.modeLabel = QLabel()
        
        self.buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        userguide.addButton(self.buttons, "mode_shift")
        
        for m in sorted(modes.keys()):
            self.modeCombo.addItem(m)

        mainLayout.addWidget(self.keyLabel, 0, 0, 1, 1)
        mainLayout.addWidget(self.keyInput, 0, 1, 1, 1)
        mainLayout.addWidget(self.modeLabel, 1, 0, 1, 1)
        mainLayout.addWidget(self.modeCombo, 1, 1, 1, 1)
        mainLayout.addWidget(self.buttons, 9, 0, 2, 2)
        
        app.translateUI(self)
        qutil.saveDialogSize(self, "mode_shift/dialog/size", QSize(80, 60))
        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)
        
        self.keyInput.textEdited.connect(self.readKeyInput)
        self.modeCombo.currentIndexChanged.connect(self.readSettings)
        
        self.loadSettings()
예제 #8
0
 def __init__(self, parent=None):
     super(SessionEditor, self).__init__(parent)
     self.setWindowModality(Qt.WindowModal)
     
     layout = QVBoxLayout()
     self.setLayout(layout)
     
     grid = QGridLayout()
     layout.addLayout(grid)
     
     self.name = QLineEdit()
     self.nameLabel = l = QLabel()
     l.setBuddy(self.name)
     grid.addWidget(l, 0, 0)
     grid.addWidget(self.name, 0, 1)
     
     self.autosave = QCheckBox()
     grid.addWidget(self.autosave, 1, 1)
     
     self.basedir = widgets.urlrequester.UrlRequester()
     self.basedirLabel = l = QLabel()
     l.setBuddy(self.basedir)
     grid.addWidget(l, 2, 0)
     grid.addWidget(self.basedir, 2, 1)
     
     self.setPaths = QCheckBox()
     grid.addWidget(self.setPaths, 3, 1)
     
     self.inclPaths = ip = QWidget(self)
     ipLayout = QVBoxLayout()
     ip.setLayout(ipLayout)
     
     self.include = widgets.listedit.FilePathEdit()
     self.include.listBox.setDragDropMode(QAbstractItemView.InternalMove)
     ipLayout.addWidget(self.include)
     
     grid.addWidget(ip, 4, 1)
     
     self.revt = QPushButton(self)
     self.clean = QPushButton(self)
     self.revt.clicked.connect(self.revertPaths)
     self.clean.clicked.connect(self.cleanPaths)
    
     self.include.layout().addWidget(self.revt, 5, 1)
     self.include.layout().addWidget(self.clean, 6, 1)
     
     self.setPaths.toggled.connect(self.showInclPaths)
     
     layout.addWidget(widgets.Separator())
     self.buttons = b = QDialogButtonBox(self)
     layout.addWidget(b)
     b.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
     b.accepted.connect(self.accept)
     b.rejected.connect(self.reject)
     userguide.addButton(b, "sessions")
     app.translateUI(self)
예제 #9
0
    def __init__(self, parent=None):
        super(SessionEditor, self).__init__(parent)
        self.setWindowModality(Qt.WindowModal)

        layout = QVBoxLayout()
        self.setLayout(layout)

        grid = QGridLayout()
        layout.addLayout(grid)

        self.name = QLineEdit()
        self.nameLabel = l = QLabel()
        l.setBuddy(self.name)
        grid.addWidget(l, 0, 0)
        grid.addWidget(self.name, 0, 1)

        self.autosave = QCheckBox()
        grid.addWidget(self.autosave, 1, 1)

        self.basedir = widgets.urlrequester.UrlRequester()
        self.basedirLabel = l = QLabel()
        l.setBuddy(self.basedir)
        grid.addWidget(l, 2, 0)
        grid.addWidget(self.basedir, 2, 1)

        self.inclPaths = ip = QGroupBox(self, checkable=True, checked=False)
        ipLayout = QVBoxLayout()
        ip.setLayout(ipLayout)

        self.replPaths = QCheckBox()
        ipLayout.addWidget(self.replPaths)
        self.replPaths.toggled.connect(self.toggleReplace)

        self.include = widgets.listedit.FilePathEdit()
        self.include.listBox.setDragDropMode(QAbstractItemView.InternalMove)
        ipLayout.addWidget(self.include)

        grid.addWidget(ip, 3, 1)

        self.revt = QPushButton(self)
        self.clear = QPushButton(self)
        self.revt.clicked.connect(self.revertPaths)
        self.clear.clicked.connect(self.clearPaths)

        self.include.layout().addWidget(self.revt, 5, 1)
        self.include.layout().addWidget(self.clear, 6, 1)

        layout.addWidget(widgets.Separator())
        self.buttons = b = QDialogButtonBox(self)
        layout.addWidget(b)
        b.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        b.accepted.connect(self.accept)
        b.rejected.connect(self.reject)
        userguide.addButton(b, "sessions")
        app.translateUI(self)
예제 #10
0
파일: tools.py 프로젝트: shimpe/frescobaldi
 def openEditor(self, item):
     dlg = widgets.dialog.TextDialog(
         None, _("Enter a regular expression to match:"),
         app.caption("Outline"))
     userguide.addButton(dlg.buttonBox(), "outline_configure")
     dlg.setValidateFunction(is_regex)
     dlg.setText(item.text())
     if dlg.exec_():
         item.setText(dlg.text())
         return True
     return False
예제 #11
0
 def openEditor(self, item):
     dlg = widgets.dialog.TextDialog(None,
         _("Enter a regular expression to match:"),
         app.caption("Outline"))
     userguide.addButton(dlg.buttonBox(), "outline_configure")
     dlg.setValidateFunction(is_regex)
     dlg.setText(item.text())
     if dlg.exec_():
         item.setText(dlg.text())
         return True
     return False
예제 #12
0
def getText(
    parent=None,
    title="",
    message="",
    text="",
    icon=None,
    help=None,
    validate=None,
    regexp=None,
    wordWrap=True,
    complete=None,
):
    """Asks a string of text from the user.
    
    Arguments:
    
    parent: parent widget or None
    title: dialog window title (without appname)
    message: message, question
    text: pre-entered text in the line edit
    icon: which icon to show
    help: help page or name
    validate: a function that accepts text and returns whether it is valid.
    regexp: a regular expression string. If given it provides an alternate
        validation method using a QRegExpValidator.
    wordWrap: whether to word-wrap the message text (default: True).
    complete: a string list or QAbstractItemModel to provide completions.
    
    """
    dlg = widgets.dialog.TextDialog(parent,
                                    title=app.caption(title),
                                    message=message,
                                    icon=icon)
    dlg.setText(text)
    dlg.setMinimumWidth(320)
    dlg.messageLabel().setWordWrap(wordWrap)
    if help is not None:
        userguide.addButton(dlg.buttonBox(), help)
        dlg.setWindowModality(Qt.WindowModal)
    else:
        dlg.setWindowModality(Qt.ApplicationModal)
    if regexp:
        dlg.setValidateRegExp(regexp)
    elif validate:
        dlg.setValidateFunction(validate)
    if complete:
        c = QCompleter(complete, dlg.lineEdit())
        dlg.lineEdit().setCompleter(c)
    if dlg.exec_():
        return dlg.text()
예제 #13
0
 def __init__(self, parent):
     super(InfoDialog, self).__init__(parent)
     self.setWindowModality(Qt.WindowModal)
     
     layout = QVBoxLayout()
     layout.setSpacing(10)
     self.setLayout(layout)
     grid = QGridLayout()
     grid.setSpacing(4)
     layout.addLayout(grid)
     
     self.lilyname = QLineEdit()
     self.lilynameLabel = l = QLabel()
     l.setBuddy(self.lilyname)
     grid.addWidget(l, 0, 0)
     grid.addWidget(self.lilyname, 0, 1)
     
     self.lilypond = widgets.urlrequester.UrlRequester()
     self.lilypond.setFileMode(QFileDialog.ExistingFile)
     self.lilypondLabel = l = QLabel()
     l.setBuddy(self.lilypond)
     grid.addWidget(l, 1, 0, 1, 2)
     grid.addWidget(self.lilypond, 2, 0, 1, 2)
     
     self.convert_ly = QLineEdit()
     self.convert_lyLabel = l = QLabel()
     l.setBuddy(self.convert_ly)
     grid.addWidget(l, 3, 0)
     grid.addWidget(self.convert_ly, 3, 1)
     
     self.lilypond_book = QLineEdit()
     self.lilypond_bookLabel = l = QLabel()
     l.setBuddy(self.lilypond_book)
     grid.addWidget(l, 4, 0)
     grid.addWidget(self.lilypond_book, 4, 1)
     
     self.auto = QCheckBox()
     grid.addWidget(self.auto, 5, 1)
     
     layout.addWidget(widgets.Separator())
     b = self.buttons = QDialogButtonBox(self)
     layout.addWidget(b)
     
     b.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
     b.accepted.connect(self.accept)
     b.rejected.connect(self.reject)
     userguide.addButton(b, "prefs_lilypond")
     app.translateUI(self)
예제 #14
0
 def __init__(self, parent):
     super(InfoDialog, self).__init__(parent)
     self.setWindowModality(Qt.WindowModal)
     
     layout = QVBoxLayout()
     layout.setSpacing(10)
     self.setLayout(layout)
     grid = QGridLayout()
     grid.setSpacing(4)
     layout.addLayout(grid)
     
     self.lilyname = QLineEdit()
     self.lilynameLabel = l = QLabel()
     l.setBuddy(self.lilyname)
     grid.addWidget(l, 0, 0)
     grid.addWidget(self.lilyname, 0, 1)
     
     self.lilypond = widgets.urlrequester.UrlRequester()
     self.lilypond.setFileMode(QFileDialog.ExistingFile)
     self.lilypondLabel = l = QLabel()
     l.setBuddy(self.lilypond)
     grid.addWidget(l, 1, 0, 1, 2)
     grid.addWidget(self.lilypond, 2, 0, 1, 2)
     
     self.convert_ly = QLineEdit()
     self.convert_lyLabel = l = QLabel()
     l.setBuddy(self.convert_ly)
     grid.addWidget(l, 3, 0)
     grid.addWidget(self.convert_ly, 3, 1)
     
     self.lilypond_book = QLineEdit()
     self.lilypond_bookLabel = l = QLabel()
     l.setBuddy(self.lilypond_book)
     grid.addWidget(l, 4, 0)
     grid.addWidget(self.lilypond_book, 4, 1)
     
     self.auto = QCheckBox()
     grid.addWidget(self.auto, 5, 1)
     
     layout.addWidget(widgets.Separator())
     b = self.buttons = QDialogButtonBox(self)
     layout.addWidget(b)
     
     b.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
     b.accepted.connect(self.accept)
     b.rejected.connect(self.reject)
     userguide.addButton(b, "prefs_lilypond")
     app.translateUI(self)
예제 #15
0
def getText(
        parent = None,
        title = "",
        message = "",
        text = "",
        icon = None,
        help = None,
        validate = None,
        regexp = None,
        wordWrap = True,
        complete = None,
        ):
    """Asks a string of text from the user.

    Arguments:

    parent: parent widget or None
    title: dialog window title (without appname)
    message: message, question
    text: pre-entered text in the line edit
    icon: which icon to show
    help: help page or name
    validate: a function that accepts text and returns whether it is valid.
    regexp: a regular expression string. If given it provides an alternate
        validation method using a QRegExpValidator.
    wordWrap: whether to word-wrap the message text (default: True).
    complete: a string list or QAbstractItemModel to provide completions.

    """
    dlg = widgets.dialog.TextDialog(parent,
        title=app.caption(title), message=message, icon=icon)
    dlg.setText(text)
    dlg.setMinimumWidth(320)
    dlg.messageLabel().setWordWrap(wordWrap)
    if help is not None:
        userguide.addButton(dlg.buttonBox(), help)
        dlg.setWindowModality(Qt.WindowModal)
    else:
        dlg.setWindowModality(Qt.ApplicationModal)
    if regexp:
        dlg.setValidateRegExp(regexp)
    elif validate:
        dlg.setValidateFunction(validate)
    if complete:
        c = QCompleter(complete, dlg.lineEdit())
        dlg.lineEdit().setCompleter(c)
    if dlg.exec_():
        return dlg.text()
예제 #16
0
    def __init__(self, parent=None):
        super(RestoreDialog, self).__init__(parent)
        self.messageLabel().setWordWrap(True)
        userguide.addButton(self.buttonBox(), "snippets")
        self.tree = QTreeWidget(headerHidden=True, rootIsDecorated=False)
        self.setMainWidget(self.tree)

        self.deletedItem = QTreeWidgetItem(self.tree)
        self.deletedItem.setFlags(Qt.ItemIsUserCheckable)
        self.changedItem = QTreeWidgetItem(self.tree)
        self.changedItem.setFlags(Qt.ItemIsUserCheckable)
        self.tree.itemChanged.connect(self.slotItemChanged)

        app.translateUI(self)
        app.languageChanged.connect(self.populate)
        self.accepted.connect(self.updateSnippets)
        qutil.saveDialogSize(self, "snippettool/restoredialog/size")
예제 #17
0
 def __init__(self, mainwindow):
     super(SessionManagerDialog, self).__init__(mainwindow)
     self.setWindowModality(Qt.WindowModal)
     self.setWindowTitle(app.caption(_("Manage Sessions")))
     layout = QVBoxLayout()
     self.setLayout(layout)
     
     self.sessions = SessionList(self)
     layout.addWidget(self.sessions)
     layout.addWidget(widgets.Separator())
     
     self.buttons = b = QDialogButtonBox(self)
     layout.addWidget(b)
     b.setStandardButtons(QDialogButtonBox.Close)
     b.rejected.connect(self.accept)
     userguide.addButton(b, "sessions")
     self.sessions.load()
예제 #18
0
 def __init__(self, parent=None):
     super(RestoreDialog, self).__init__(parent)
     self.messageLabel().setWordWrap(True)
     userguide.addButton(self.buttonBox(), "snippets")
     self.tree = QTreeWidget(headerHidden=True, rootIsDecorated=False)
     self.setMainWidget(self.tree)
     
     self.deletedItem = QTreeWidgetItem(self.tree)
     self.deletedItem.setFlags(Qt.ItemIsUserCheckable)
     self.changedItem = QTreeWidgetItem(self.tree)
     self.changedItem.setFlags(Qt.ItemIsUserCheckable)
     self.tree.itemChanged.connect(self.slotItemChanged)
     
     app.translateUI(self)
     app.languageChanged.connect(self.populate)
     self.accepted.connect(self.updateSnippets)
     qutil.saveDialogSize(self, "snippettool/restoredialog/size")
예제 #19
0
    def __init__(self, mainwindow):
        super(SessionManagerDialog, self).__init__(mainwindow)
        self.setWindowModality(Qt.WindowModal)
        self.setWindowTitle(app.caption(_("Manage Sessions")))
        layout = QVBoxLayout()
        self.setLayout(layout)

        self.sessions = SessionList(self)
        layout.addWidget(self.sessions)
        layout.addWidget(widgets.Separator())

        self.buttons = b = QDialogButtonBox(self)
        layout.addWidget(b)
        b.setStandardButtons(QDialogButtonBox.Close)
        b.rejected.connect(self.accept)
        userguide.addButton(b, "sessions")
        self.sessions.load()
예제 #20
0
    def __init__(self):
        super(ChangedDocumentsListDialog, self).__init__(buttons=('close', ))
        self.setWindowModality(Qt.NonModal)
        self.setAttribute(Qt.WA_QuitOnClose, False)

        layout = QGridLayout(margin=0)
        self.mainWidget().setLayout(layout)
        self.tree = QTreeWidget(headerHidden=True,
                                rootIsDecorated=False,
                                columnCount=2,
                                itemsExpandable=False)
        self.tree.setSelectionMode(QTreeWidget.ExtendedSelection)

        self.buttonReload = QPushButton()
        self.buttonReloadAll = QPushButton()
        self.buttonSave = QPushButton()
        self.buttonSaveAll = QPushButton()
        self.buttonShowDiff = QPushButton()
        self.checkWatchingEnabled = QCheckBox(checked=enabled())

        layout.addWidget(self.tree, 0, 0, 6, 1)
        layout.addWidget(self.buttonReload, 0, 1)
        layout.addWidget(self.buttonReloadAll, 1, 1)
        layout.addWidget(self.buttonSave, 2, 1)
        layout.addWidget(self.buttonSaveAll, 3, 1)
        layout.addWidget(self.buttonShowDiff, 4, 1)
        layout.addWidget(self.checkWatchingEnabled, 6, 0, 1, 2)
        layout.setRowStretch(5, 10)

        app.documentClosed.connect(self.removeDocument)
        app.documentSaved.connect(self.removeDocument)
        app.documentUrlChanged.connect(self.removeDocument)
        app.documentLoaded.connect(self.removeDocument)
        self.tree.itemSelectionChanged.connect(self.updateButtons)
        self.buttonReload.clicked.connect(self.slotButtonReload)
        self.buttonReloadAll.clicked.connect(self.slotButtonReloadAll)
        self.buttonSave.clicked.connect(self.slotButtonSave)
        self.buttonSaveAll.clicked.connect(self.slotButtonSaveAll)
        self.buttonShowDiff.clicked.connect(self.slotButtonShowDiff)
        self.checkWatchingEnabled.toggled.connect(setEnabled)

        app.translateUI(self)
        qutil.saveDialogSize(self, 'externalchanges/dialog/size',
                             QSize(400, 200))
        userguide.addButton(self.buttonBox(), "externalchanges")
        self.button('close').setFocus()
예제 #21
0
 def __init__(self):
     super(ChangedDocumentsListDialog, self).__init__(buttons=('close',))
     self.setWindowModality(Qt.NonModal)
     self.setAttribute(Qt.WA_QuitOnClose, False)
     
     layout = QGridLayout(margin=0)
     self.mainWidget().setLayout(layout)
     self.tree = QTreeWidget(headerHidden=True, rootIsDecorated=False,
                             columnCount=2, itemsExpandable=False)
     self.tree.setSelectionMode(QTreeWidget.ExtendedSelection)
     
     self.buttonReload = QPushButton()
     self.buttonReloadAll = QPushButton()
     self.buttonSave = QPushButton()
     self.buttonSaveAll = QPushButton()
     self.buttonShowDiff = QPushButton()
     self.checkWatchingEnabled = QCheckBox(checked=enabled())
     
     layout.addWidget(self.tree, 0, 0, 6, 1)
     layout.addWidget(self.buttonReload, 0, 1)
     layout.addWidget(self.buttonReloadAll, 1, 1)
     layout.addWidget(self.buttonSave, 2, 1)
     layout.addWidget(self.buttonSaveAll, 3, 1)
     layout.addWidget(self.buttonShowDiff, 4, 1)
     layout.addWidget(self.checkWatchingEnabled, 6, 0, 1, 2)
     layout.setRowStretch(5, 10)
     
     app.documentClosed.connect(self.removeDocument)
     app.documentSaved.connect(self.removeDocument)
     app.documentUrlChanged.connect(self.removeDocument)
     app.documentLoaded.connect(self.removeDocument)
     self.tree.itemSelectionChanged.connect(self.updateButtons)
     self.buttonReload.clicked.connect(self.slotButtonReload)
     self.buttonReloadAll.clicked.connect(self.slotButtonReloadAll)
     self.buttonSave.clicked.connect(self.slotButtonSave)
     self.buttonSaveAll.clicked.connect(self.slotButtonSaveAll)
     self.buttonShowDiff.clicked.connect(self.slotButtonShowDiff)
     self.checkWatchingEnabled.toggled.connect(setEnabled)
 
     app.translateUI(self)
     qutil.saveDialogSize(self, 'externalchanges/dialog/size', QSize(400, 200))
     userguide.addButton(self.buttonBox(), "externalchanges")
     self.button('close').setFocus()
예제 #22
0
    def __init__(self, mainwindow):
        super(HyphenDialog, self).__init__(mainwindow)
        self.setWindowModality(Qt.WindowModal)
        layout = QVBoxLayout()
        self.setLayout(layout)
        self.topLabel = QLabel()
        self.listWidget = QListWidget()

        layout.addWidget(self.topLabel)
        layout.addWidget(self.listWidget)
        layout.addWidget(widgets.Separator())

        self.buttons = b = QDialogButtonBox()
        layout.addWidget(b)
        b.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        userguide.addButton(b, "lyrics")
        b.rejected.connect(self.reject)
        b.accepted.connect(self.accept)

        self.load()
        app.translateUI(self)
        qutil.saveDialogSize(self, "hyphenation/dialog/size")
예제 #23
0
    def __init__(self, mainwindow):
        super(HyphenDialog, self).__init__(mainwindow)
        self.setWindowModality(Qt.WindowModal)
        layout = QVBoxLayout()
        self.setLayout(layout)
        self.topLabel = QLabel()
        self.listWidget = QListWidget()

        layout.addWidget(self.topLabel)
        layout.addWidget(self.listWidget)
        layout.addWidget(widgets.Separator())

        self.buttons = b = QDialogButtonBox()
        layout.addWidget(b)
        b.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        userguide.addButton(b, "lyrics")
        b.rejected.connect(self.reject)
        b.accepted.connect(self.accept)

        self.load()
        app.translateUI(self)
        qutil.saveDialogSize(self, "hyphenation/dialog/size")
예제 #24
0
 def __init__(self, parent=None):
     super(Dialog, self).__init__(parent)
     self._document = None
     self.messageLabel().setWordWrap(True)
     self.document = d = QTextDocument()
     d.setDocumentLayout(QPlainTextDocumentLayout(d))
     self.highlighter = highlighter.highlighter(d)
     self.view = View(d)
     self.matcher = Matcher(self.view)
     self.completer = Completer(self.view)
     self.setMainWidget(self.view)
     userguide.addButton(self.buttonBox(), "musicview_editinplace")
     # action for completion popup
     self._showPopupAction = QAction(None, triggered=self.slotCompletionPopup)
     self.addAction(self._showPopupAction)
     # make Ctrl+Return accept the dialog
     self.button("ok").setShortcut(QKeySequence("Ctrl+Return"))
     qutil.saveDialogSize(self, "editinplace/dialog/size")
     
     self.accepted.connect(self.save)
     app.translateUI(self)
     app.settingsChanged.connect(self.readSettings)
     self.readSettings()
예제 #25
0
    def __init__(self, parent=None):
        super(Dialog, self).__init__(parent)
        self._document = None
        self.messageLabel().setWordWrap(True)
        self.document = d = QTextDocument()
        d.setDocumentLayout(QPlainTextDocumentLayout(d))
        self.highlighter = highlighter.highlighter(d)
        self.view = View(d)
        self.matcher = Matcher(self.view)
        self.completer = Completer(self.view)
        self.setMainWidget(self.view)
        userguide.addButton(self.buttonBox(), "musicview_editinplace")
        # action for completion popup
        self._showPopupAction = QAction(None,
                                        triggered=self.slotCompletionPopup)
        self.addAction(self._showPopupAction)
        # make Ctrl+Return accept the dialog
        self.button("ok").setShortcut(QKeySequence("Ctrl+Return"))
        qutil.saveDialogSize(self, "musicview/editinplace/dialog/size")

        self.accepted.connect(self.save)
        app.translateUI(self)
        app.settingsChanged.connect(self.readSettings)
        self.readSettings()
예제 #26
0
    def __init__(self, parent, lilypond_info=None, show_music=True):
        QApplication.setOverrideCursor(Qt.WaitCursor)
        super(FontsDialog, self).__init__(parent, )
        self.info = lilypond_info
        if not lilypond_info:
            import documentinfo
            self.info = documentinfo.lilyinfo(parent.currentDocument())

        self.result = ''
        self.available_fonts = fonts.available(self.info)

        # Notation fonts (and preview) are limited to LilyPond >= 2.19.12
        # At some point we may remove the old dialog altogether
        # and instead make this dialog behave differently
        # (i.e. hide the music font stuff and use old font selection code)
        # self.show_music = self.info.version() >= (2, 19, 12).
        # For now this distinction is made by the action and simply
        # the dialog to be used is chosen. At some point the old
        # "Set document fonts" dialog should be dropped.
        #
        # Also, it may at some point be indicated to make this
        # dialog usable to *only* choose text fonts, e.g. from
        # the "Fonts & Colors" Preference page.
        #
        # NOTE: All facilities that *seemed* to support this functionality
        # have been removed to avoid confusion.
        self.show_music = show_music

        # Basic dialog attributes
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowModality(Qt.WindowModal)

        layout = QVBoxLayout()
        self.setLayout(layout)

        # Create a QSplitter as main widget
        self.splitter = QSplitter()
        self.splitter.setOrientation(Qt.Horizontal)
        layout.addWidget(self.splitter)

        # Left side layout
        self.left_column = QWidget()
        left_layout = QVBoxLayout()
        self.left_column.setLayout(left_layout)
        self.splitter.addWidget(self.left_column)

        # Status area
        # TODO: Populate that widget with a QStackedLayout where
        # different widgets are shown corresponding to the visible tab.
        self.status_area = QWidget()
        left_layout.addWidget(self.status_area)

        # Create the QTabWidget for the dialog's left part
        self.tab_widget = QTabWidget()
        left_layout.addWidget(self.tab_widget)

        # Text Fonts Tab
        self.tab_widget.addTab(textfonts.TextFontsWidget(self), '')
        # Music Fonts Tab
        self.tab_widget.addTab(musicfonts.MusicFontsWidget(self), '')
        # Show/configure the generated font setting command
        self.font_command_tab = fontcommand.FontCommandWidget(self)
        self.tab_widget.addTab(self.font_command_tab, '')
        # Show various fontconfig information
        self.tab_widget.addTab(
            textfonts.MiscFontsInfoWidget(self.available_fonts), '')

        # Create the RHS score preview pane.
        self.preview_pane = preview.FontsPreviewWidget(self)
        self.splitter.addWidget(self.preview_pane)

        # Bottom area: button box
        self._button_box = bb = QDialogButtonBox()
        layout.addWidget(bb)
        self.restore_button = bb.addButton(QDialogButtonBox.RestoreDefaults)
        self.copy_button = bb.addButton(QDialogButtonBox.Save)
        self.insert_button = bb.addButton(QDialogButtonBox.Ok)
        self.close_button = bb.addButton(QDialogButtonBox.Close)
        # Add and connect help button
        userguide.addButton(self._button_box, "documentfonts")

        app.translateUI(self)
        self.loadSettings()
        self.connectSignals()

        # Trigger the generation of a preview
        self.invalidate_command()
예제 #27
0
def load(filename, widget):
    """Loads snippets from a file, displaying them in a list.
    
    The user can then choose:
    - overwrite builtin snippets or not
    - overwrite own snippets with same title or not
    - select and view snippets contents.
    
    """
    try:
        d = ET.parse(filename)
        elements = list(d.findall('snippet'))
        if not elements:
            raise ValueError(_("No snippets found."))
    except Exception as e:
        QMessageBox.critical(
            widget, app.caption(_("Error")),
            _("Can't read from source:\n\n{url}\n\n{error}").format(
                url=filename, error=e))
        return

    dlg = widgets.dialog.Dialog(widget)
    dlg.setWindowModality(Qt.WindowModal)
    dlg.setWindowTitle(app.caption(_("dialog title", "Import Snippets")))
    tree = QTreeWidget(headerHidden=True, rootIsDecorated=False)
    dlg.setMainWidget(tree)
    userguide.addButton(dlg.buttonBox(), "snippet_import_export")

    allnames = frozenset(snippets.names())
    builtins = frozenset(builtin.builtin_snippets)
    titles = dict(
        (snippets.title(n), n) for n in allnames if n not in builtins)

    new = QTreeWidgetItem(tree, [_("New Snippets")])
    updated = QTreeWidgetItem(tree, [_("Updated Snippets")])
    unchanged = QTreeWidgetItem(tree, [_("Unchanged Snippets")])

    new.setFlags(Qt.ItemIsEnabled)
    updated.setFlags(Qt.ItemIsEnabled)
    unchanged.setFlags(Qt.ItemIsEnabled)

    new.setExpanded(True)
    updated.setExpanded(True)

    items = []
    for snip in elements:
        item = QTreeWidgetItem()

        item.body = snip.find('body').text
        item.title = snip.find('title').text
        item.shortcuts = list(e.text
                              for e in snip.findall('shortcuts/shortcut'))

        title = item.title or snippets.maketitle(
            snippets.parse(item.body).text)
        item.setText(0, title)

        name = snip.get('id')
        name = name if name in builtins else None

        # determine if new, updated or unchanged
        if not name:
            name = titles.get(title)
        item.name = name

        if not name or name not in allnames:
            new.addChild(item)
            items.append(item)
            item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
            item.setCheckState(0, Qt.Checked)
        elif name:
            if (item.body != snippets.text(name)
                    or title != snippets.title(name)
                    or (item.shortcuts and item.shortcuts !=
                        [s.toString() for s in model.shortcuts(name) or ()])):
                updated.addChild(item)
                items.append(item)
                item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
                item.setCheckState(0, Qt.Checked)
            else:
                unchanged.addChild(item)
                item.setFlags(Qt.ItemIsEnabled)
    # count:
    for i in new, updated, unchanged:
        i.setText(0, i.text(0) + " ({0})".format(i.childCount()))
    for i in new, updated:
        if i.childCount():
            i.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
            i.setCheckState(0, Qt.Checked)

    def changed(item):
        if item in (new, updated):
            for i in range(item.childCount()):
                c = item.child(i)
                c.setCheckState(0, item.checkState(0))

    tree.itemChanged.connect(changed)

    importShortcuts = QTreeWidgetItem([_("Import Keyboard Shortcuts")])
    if items:
        tree.addTopLevelItem(importShortcuts)
        importShortcuts.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
        importShortcuts.setCheckState(0, Qt.Checked)
        dlg.setMessage(_("Choose which snippets you want to import:"))
    else:
        dlg.setMessage(_("There are no new or updated snippets in the file."))
        unchanged.setExpanded(True)

    tree.setWhatsThis(
        _("<p>Here the snippets from {filename} are displayed.</p>\n"
          "<p>If there are new or updated snippets, you can select or deselect "
          "them one by one, or all at once, using the checkbox of the group. "
          "Then click OK to import all the selected snippets.</p>\n"
          "<p>Existing, unchanged snippets can't be imported.</p>\n").format(
              filename=os.path.basename(filename)))

    qutil.saveDialogSize(dlg, "snippettool/import/size", QSize(400, 300))
    if not dlg.exec_() or not items:
        return
    ac = model.collection()
    m = model.model()
    with qutil.busyCursor():
        for i in items:
            if i.checkState(0) == Qt.Checked:
                index = m.saveSnippet(i.name, i.body, i.title)
                if i.shortcuts and importShortcuts.checkState(0):
                    shortcuts = list(map(QKeySequence.fromString, i.shortcuts))
                    ac.setShortcuts(m.name(index), shortcuts)
        widget.updateColumnSizes()
예제 #28
0
    def __init__(self,
                 parent=None,
                 job_class=job.Job,
                 imp_prgm='',
                 input=None,
                 userg=''):
        super(ToLyDialog, self).__init__(parent)
        self._info = None
        self._imp_prgm = imp_prgm
        self._userg = userg
        self._input = input
        self._path = None
        self._job_class = job_class
        self._job = None

        self.addAction(parent.actionCollection.help_whatsthis)
        self.setWindowModality(Qt.WindowModal)
        mainLayout = QGridLayout()
        self.setLayout(mainLayout)

        tabs = QTabWidget()

        import_tab = QWidget()
        post_tab = QWidget()

        itabLayout = QGridLayout(import_tab)
        ptabLayout = QGridLayout(post_tab)

        tabs.addTab(import_tab, self._imp_prgm)
        tabs.addTab(post_tab, _("After Import"))

        self.formatCheck = QCheckBox()
        self.trimDurCheck = QCheckBox()
        self.removeScalesCheck = QCheckBox()
        self.runEngraverCheck = QCheckBox()

        self.postChecks = [self.formatCheck,
                           self.trimDurCheck,
                           self.removeScalesCheck,
                           self.runEngraverCheck]

        self.versionLabel = QLabel()
        self.lilyChooser = lilychooser.LilyChooser(toolcommand=self._imp_prgm)

        self.formatCheck.setObjectName("reformat")
        self.trimDurCheck.setObjectName("trim-durations")
        self.removeScalesCheck.setObjectName("remove-scaling")
        self.runEngraverCheck.setObjectName("engrave-directly")

        self.buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        userguide.addButton(self.buttons, self._userg)

        row = 0
        for r, w in enumerate(self.impChecks):
            row += r
            itabLayout.addWidget(w, row, 0, 1, 2)
        row += 1
        for r, w in enumerate(self.impExtra):
            row += r
            itabLayout.addWidget(w, row, 0, 1, 2)

        itabLayout.addWidget(widgets.Separator(), row + 1, 0, 1, 2)
        itabLayout.addWidget(self.versionLabel, row + 2, 0, 1, 0)
        itabLayout.addWidget(self.lilyChooser, row + 3, 0, 1, 2)
        itabLayout.setRowStretch(row + 4, 10)

        ptabLayout.addWidget(self.formatCheck, 0, 0, 1, 2)
        ptabLayout.addWidget(self.trimDurCheck, 1, 0, 1, 2)
        ptabLayout.addWidget(self.removeScalesCheck, 2, 0, 1, 2)
        ptabLayout.addWidget(self.runEngraverCheck, 3, 0, 1, 2)
        ptabLayout.setRowStretch(4, 6)

        mainLayout.addWidget(tabs, 0, 0, 6, 2)
        mainLayout.addWidget(self.buttons, 7, 0, 1, 2)

        self.buttons.accepted.connect(self.about_to_accept)
        self.buttons.rejected.connect(self.reject)

        self.lilyChooser.currentIndexChanged.connect(self.slot_lilypond_version_changed)
        self.slot_lilypond_version_changed()
예제 #29
0
    def __init__(self, parent=None):
        super(Dialog, self).__init__(parent)
        self._document = None
        self._path = None

        mainLayout = QGridLayout()
        self.setLayout(mainLayout)

        tabs = QTabWidget()

        import_tab = QWidget()
        post_tab = QWidget()

        itabLayout = QGridLayout(import_tab)
        ptabLayout = QGridLayout(post_tab)

        tabs.addTab(import_tab, "musicxml2ly")
        tabs.addTab(post_tab, "after import")

        self.noartCheck = QCheckBox()
        self.norestCheck = QCheckBox()
        self.nolayoutCheck = QCheckBox()
        self.nobeamCheck = QCheckBox()
        self.useAbsCheck = QCheckBox()

        self.langCombo = QComboBox()
        self.langLabel = QLabel()

        self.impChecks = [
            self.noartCheck, self.norestCheck, self.nolayoutCheck,
            self.nobeamCheck, self.useAbsCheck
        ]

        self.formatCheck = QCheckBox()
        self.trimDurCheck = QCheckBox()
        self.removeScalesCheck = QCheckBox()
        self.runEngraverCheck = QCheckBox()

        self.postChecks = [
            self.formatCheck, self.trimDurCheck, self.removeScalesCheck,
            self.runEngraverCheck
        ]

        self.commandLineLabel = QLabel()
        self.commandLine = QTextEdit(acceptRichText=False)

        self.setChecksObjectNames()

        self.buttons = QDialogButtonBox(QDialogButtonBox.Ok
                                        | QDialogButtonBox.Cancel)
        userguide.addButton(self.buttons, "musicxml_import")

        self.langCombo.addItem('')
        self.langCombo.addItems(_langlist)

        itabLayout.addWidget(self.noartCheck, 0, 0, 1, 2)
        itabLayout.addWidget(self.norestCheck, 1, 0, 1, 2)
        itabLayout.addWidget(self.nolayoutCheck, 2, 0, 1, 2)
        itabLayout.addWidget(self.nobeamCheck, 3, 0, 1, 2)
        itabLayout.addWidget(self.useAbsCheck, 4, 0, 1, 2)
        itabLayout.addWidget(self.langLabel, 5, 0, 1, 2)
        itabLayout.addWidget(self.langCombo, 6, 0, 1, 2)
        itabLayout.addWidget(widgets.Separator(), 7, 0, 1, 2)
        itabLayout.addWidget(self.commandLineLabel, 8, 0, 1, 2)
        itabLayout.addWidget(self.commandLine, 9, 0, 1, 2)

        ptabLayout.addWidget(self.formatCheck, 0, 0, 1, 2)
        ptabLayout.addWidget(self.trimDurCheck, 1, 0, 1, 2)
        ptabLayout.addWidget(self.removeScalesCheck, 2, 0, 1, 2)
        ptabLayout.addWidget(self.runEngraverCheck, 3, 0, 1, 2)
        ptabLayout.setRowStretch(4, 10)

        mainLayout.addWidget(tabs, 0, 0, 9, 2)
        mainLayout.addWidget(self.buttons, 10, 0, 1, 2)

        app.translateUI(self)
        qutil.saveDialogSize(self, "xml_import/dialog/size", QSize(480, 260))
        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)

        self.noartCheck.toggled.connect(self.makeCommandLine)
        self.norestCheck.toggled.connect(self.makeCommandLine)
        self.nolayoutCheck.toggled.connect(self.makeCommandLine)
        self.nobeamCheck.toggled.connect(self.makeCommandLine)
        self.useAbsCheck.toggled.connect(self.makeCommandLine)
        self.langCombo.currentIndexChanged.connect(self.makeCommandLine)
        self.makeCommandLine()

        self.loadSettings()
예제 #30
0
    def __init__(self, parent):
        super(InfoDialog, self).__init__(parent)
        self.setWindowModality(Qt.WindowModal)

        layout = QVBoxLayout()
        layout.setSpacing(10)
        self.setLayout(layout)

        self.tab = QTabWidget()
        tab_general = QWidget()
        tab_toolcommands = QWidget()
        self.tab.addTab(tab_general, "")
        self.tab.addTab(tab_toolcommands, "")

        # general tab
        vbox = QVBoxLayout()
        vbox.setSpacing(4)
        tab_general.setLayout(vbox)

        hbox = QHBoxLayout()
        self.lilyname = QLineEdit()
        self.lilynameLabel = l = QLabel()
        l.setBuddy(self.lilyname)
        hbox.addWidget(l)
        hbox.addWidget(self.lilyname)
        vbox.addLayout(hbox)

        self.lilypond = widgets.urlrequester.UrlRequester()
        self.lilypond.setFileMode(QFileDialog.ExistingFile)
        self.lilypondLabel = l = QLabel()
        l.setBuddy(self.lilypond)
        vbox.addWidget(l)
        vbox.addWidget(self.lilypond)

        self.auto = QCheckBox()
        vbox.addWidget(self.auto)
        vbox.addStretch(1)

        # toolcommands tab
        grid = QGridLayout()
        grid.setSpacing(4)
        tab_toolcommands.setLayout(grid)

        self.ly_tool_widgets = {}
        row = 0
        for name, gui in self.toolnames():
            w = QLineEdit()
            l = QLabel()
            l.setBuddy(w)
            grid.addWidget(l, row, 0)
            grid.addWidget(w, row, 1)
            row += 1
            self.ly_tool_widgets[name] = (l, w)

        layout.addWidget(self.tab)
        layout.addWidget(widgets.Separator())
        b = self.buttons = QDialogButtonBox(self)
        layout.addWidget(b)

        b.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        b.accepted.connect(self.accept)
        b.rejected.connect(self.reject)
        userguide.addButton(b, "prefs_lilypond")
        app.translateUI(self)
        qutil.saveDialogSize(self,
                             "/preferences/lilypond/lilypondinfo/dialog/size")
예제 #31
0
    def __init__(self,
                 parent=None,
                 job_class=job.Job,
                 imp_prgm='',
                 input=None,
                 userg=''):
        super(ToLyDialog, self).__init__(parent)
        self._info = None
        self._imp_prgm = imp_prgm
        self._userg = userg
        self._input = input
        self._path = None
        self._job_class = job_class
        self._job = None

        self.addAction(parent.actionCollection.help_whatsthis)
        self.setWindowModality(Qt.WindowModal)
        mainLayout = QGridLayout()
        self.setLayout(mainLayout)

        tabs = QTabWidget()

        import_tab = QWidget()
        post_tab = QWidget()

        itabLayout = QGridLayout(import_tab)
        ptabLayout = QGridLayout(post_tab)

        tabs.addTab(import_tab, self._imp_prgm)
        tabs.addTab(post_tab, _("After Import"))

        self.formatCheck = QCheckBox()
        self.trimDurCheck = QCheckBox()
        self.removeScalesCheck = QCheckBox()
        self.runEngraverCheck = QCheckBox()

        self.postChecks = [self.formatCheck,
                           self.trimDurCheck,
                           self.removeScalesCheck,
                           self.runEngraverCheck]

        self.versionLabel = QLabel()
        self.lilyChooser = lilychooser.LilyChooser()

        self.formatCheck.setObjectName("reformat")
        self.trimDurCheck.setObjectName("trim-durations")
        self.removeScalesCheck.setObjectName("remove-scaling")
        self.runEngraverCheck.setObjectName("engrave-directly")

        self.buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        userguide.addButton(self.buttons, self._userg)

        row = 0
        for r, w in enumerate(self.impChecks):
            row += r
            itabLayout.addWidget(w, row, 0, 1, 2)
        row += 1
        for r, w in enumerate(self.impExtra):
            row += r
            itabLayout.addWidget(w, row, 0, 1, 2)

        itabLayout.addWidget(widgets.Separator(), row + 1, 0, 1, 2)
        itabLayout.addWidget(self.versionLabel, row + 2, 0, 1, 0)
        itabLayout.addWidget(self.lilyChooser, row + 3, 0, 1, 2)
        itabLayout.setRowStretch(row + 4, 10)

        ptabLayout.addWidget(self.formatCheck, 0, 0, 1, 2)
        ptabLayout.addWidget(self.trimDurCheck, 1, 0, 1, 2)
        ptabLayout.addWidget(self.removeScalesCheck, 2, 0, 1, 2)
        ptabLayout.addWidget(self.runEngraverCheck, 3, 0, 1, 2)
        ptabLayout.setRowStretch(4, 6)

        mainLayout.addWidget(tabs, 0, 0, 6, 2)
        mainLayout.addWidget(self.buttons, 7, 0, 1, 2)

        self.buttons.accepted.connect(self.about_to_accept)
        self.buttons.rejected.connect(self.reject)

        self.lilyChooser.currentIndexChanged.connect(self.slot_lilypond_version_changed)
        self.slot_lilypond_version_changed()
예제 #32
0
    def __init__(self, mainwindow):
        super(Dialog, self).__init__(mainwindow)
        self._document = None

        layout = QGridLayout()
        self.setLayout(layout)

        self.versionLabel = QLabel()
        self.lilyChooser = lilychooser.LilyChooser()

        self.outputLabel = QLabel()
        self.outputCombo = QComboBox()

        self.resolutionLabel = QLabel()
        self.resolutionCombo = QComboBox(editable=True)

        self.antialiasLabel = QLabel()
        self.antialiasSpin = QSpinBox(minimum=1, maximum=128, value=1)

        self.modeLabel = QLabel()
        self.modeCombo = QComboBox()

        self.deleteCheck = QCheckBox()
        self.embedSourceCodeCheck = QCheckBox()
        self.englishCheck = QCheckBox()

        self.commandLineLabel = QLabel()
        self.commandLine = QTextEdit(acceptRichText=False)

        self.buttons = QDialogButtonBox(QDialogButtonBox.Ok
                                        | QDialogButtonBox.Cancel)
        self.buttons.button(QDialogButtonBox.Ok).setIcon(
            icons.get("lilypond-run"))
        userguide.addButton(self.buttons, "engrave_custom")

        self.resolutionCombo.addItems(['100', '200', '300', '600', '1200'])
        self.resolutionCombo.setCurrentIndex(2)

        self.modeCombo.addItems(['preview', 'publish', 'debug'])
        layout.addWidget(self.versionLabel, 0, 0)
        layout.addWidget(self.lilyChooser, 0, 1, 1, 3)
        layout.addWidget(self.outputLabel, 1, 0)
        layout.addWidget(self.outputCombo, 1, 1, 1, 3)
        layout.addWidget(self.resolutionLabel, 2, 0)
        layout.addWidget(self.resolutionCombo, 2, 1)
        layout.addWidget(self.antialiasLabel, 2, 2, Qt.AlignRight)
        layout.addWidget(self.antialiasSpin, 2, 3)
        layout.addWidget(self.modeLabel, 3, 0)
        layout.addWidget(self.modeCombo, 3, 1, 1, 3)
        layout.addWidget(self.deleteCheck, 4, 0, 1, 4)
        layout.addWidget(self.embedSourceCodeCheck, 5, 0, 1, 4)
        layout.addWidget(self.englishCheck, 6, 0, 1, 4)
        layout.addWidget(self.commandLineLabel, 7, 0, 1, 4)
        layout.addWidget(self.commandLine, 8, 0, 1, 4)
        layout.addWidget(widgets.Separator(), 9, 0, 1, 4)
        layout.addWidget(self.buttons, 10, 0, 1, 4)

        app.translateUI(self)
        qutil.saveDialogSize(self, "engrave/custom/dialog/size",
                             QSize(480, 260))
        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)

        model = listmodel.ListModel(formats,
                                    display=lambda f: f.title(),
                                    icon=lambda f: icons.file_type(f.type))
        self.outputCombo.setModel(model)

        s = QSettings()
        s.beginGroup("lilypond_settings")
        self.englishCheck.setChecked(s.value("no_translation", False, bool))
        self.deleteCheck.setChecked(
            s.value("delete_intermediate_files", True, bool))

        if s.value("default_output_target", "pdf", str) == "svg":
            self.outputCombo.setCurrentIndex(3)

        app.jobFinished.connect(self.slotJobFinished)
        self.outputCombo.currentIndexChanged.connect(self.makeCommandLine)
        self.modeCombo.currentIndexChanged.connect(self.makeCommandLine)
        self.deleteCheck.toggled.connect(self.makeCommandLine)
        self.embedSourceCodeCheck.toggled.connect(self.makeCommandLine)
        self.resolutionCombo.editTextChanged.connect(self.makeCommandLine)
        self.antialiasSpin.valueChanged.connect(self.makeCommandLine)
        self.makeCommandLine()
        panelmanager.manager(
            mainwindow).layoutcontrol.widget().optionsChanged.connect(
                self.makeCommandLine)
예제 #33
0
    def __init__(self, parent=None):
        super(ToLyDialog, self).__init__(parent)
        self._info = None
        self._document = None
        self._path = None

        mainLayout = QGridLayout()
        self.setLayout(mainLayout)

        tabs = QTabWidget()

        import_tab = QWidget()
        post_tab = QWidget()

        itabLayout = QGridLayout(import_tab)
        ptabLayout = QGridLayout(post_tab)

        tabs.addTab(import_tab, self.imp_prgm)
        tabs.addTab(post_tab, "after import")

        self.formatCheck = QCheckBox()
        self.trimDurCheck = QCheckBox()
        self.removeScalesCheck = QCheckBox()
        self.runEngraverCheck = QCheckBox()

        self.postChecks = [
            self.formatCheck, self.trimDurCheck, self.removeScalesCheck,
            self.runEngraverCheck
        ]

        self.versionLabel = QLabel()
        self.lilyChooser = lilychooser.LilyChooser()

        self.commandLineLabel = QLabel()
        self.commandLine = QTextEdit(acceptRichText=False)

        self.formatCheck.setObjectName("reformat")
        self.trimDurCheck.setObjectName("trim-durations")
        self.removeScalesCheck.setObjectName("remove-scaling")
        self.runEngraverCheck.setObjectName("engrave-directly")

        self.buttons = QDialogButtonBox(QDialogButtonBox.Ok
                                        | QDialogButtonBox.Cancel)
        userguide.addButton(self.buttons, self.userg)

        row = 0
        for r, w in enumerate(self.impChecks):
            row += r
            itabLayout.addWidget(w, row, 0, 1, 2)
            w.toggled.connect(self.makeCommandLine)
        row += 1
        for r, w in enumerate(self.impExtra):
            row += r
            itabLayout.addWidget(w, row, 0, 1, 2)

        itabLayout.addWidget(widgets.Separator(), row + 1, 0, 1, 2)
        itabLayout.addWidget(self.versionLabel, row + 2, 0, 1, 0)
        itabLayout.addWidget(self.lilyChooser, row + 3, 0, 1, 2)
        itabLayout.addWidget(widgets.Separator(), row + 4, 0, 1, 2)
        itabLayout.addWidget(self.commandLineLabel, row + 5, 0, 1, 2)
        itabLayout.addWidget(self.commandLine, row + 6, 0, 1, 2)

        ptabLayout.addWidget(self.formatCheck, 0, 0, 1, 2)
        ptabLayout.addWidget(self.trimDurCheck, 1, 0, 1, 2)
        ptabLayout.addWidget(self.removeScalesCheck, 2, 0, 1, 2)
        ptabLayout.addWidget(self.runEngraverCheck, 3, 0, 1, 2)
        ptabLayout.setRowStretch(4, 10)

        mainLayout.addWidget(tabs, 0, 0, 9, 2)
        mainLayout.addWidget(self.buttons, 10, 0, 1, 2)

        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)

        self.lilyChooser.currentIndexChanged.connect(
            self.slotLilyPondVersionChanged)
        self.slotLilyPondVersionChanged()
예제 #34
0
    def __init__(self, widget, name, text=""):
        super(Edit, self).__init__(widget)

        self._name = name

        layout = QVBoxLayout()
        self.setLayout(layout)

        self.topLabel = QLabel()
        self.text = QTextEdit(cursorWidth=2, acceptRichText=False)
        self.titleLabel = QLabel()
        self.titleEntry = QLineEdit()
        self.shortcutLabel = QLabel()
        self.shortcutButton = ShortcutButton(clicked=self.editShortcuts)

        layout.addWidget(self.topLabel)
        layout.addWidget(self.text)

        grid = QGridLayout()
        layout.addLayout(grid)

        grid.addWidget(self.titleLabel, 0, 0)
        grid.addWidget(self.titleEntry, 0, 1)
        grid.addWidget(self.shortcutLabel, 1, 0)
        grid.addWidget(self.shortcutButton, 1, 1)

        layout.addWidget(widgets.Separator())

        b = QDialogButtonBox(accepted=self.accept, rejected=self.reject)
        layout.addWidget(b)

        buttons = QDialogButtonBox.Ok | QDialogButtonBox.Cancel
        if name and name in builtin.builtin_snippets:
            b.setStandardButtons(buttons | QDialogButtonBox.RestoreDefaults)
            b.button(QDialogButtonBox.RestoreDefaults).clicked.connect(self.slotDefaults)
        else:
            b.setStandardButtons(buttons)
        userguide.addButton(b, "snippet_editor")

        # PyQt5.10 en sip4.14.5 delete the Highlighter, even though it is
        # constructed with a parent, that's why we save it in an unused attribute.
        self._highlighter = highlight.Highlighter(self.text.document())
        Matcher(self.text)
        gadgets.indenter.Indenter(self.text)
        self.text.installEventFilter(cursorkeys.handler)
        wordboundary.handler.install_textedit(self.text)
        completer.Completer(self.text)

        if name:
            self.titleEntry.setText(snippets.title(name, False) or '')
            self.text.setPlainText(snippets.text(name))
            ac = self.parent().parent().snippetActions
            self.setShortcuts(ac.shortcuts(name))
        else:
            self.text.setPlainText(text)
            self.setShortcuts(None)

        app.translateUI(self)

        self.readSettings()
        app.settingsChanged.connect(self.readSettings)
        qutil.saveDialogSize(self, "snippettool/editor/size", QSize(400, 300))
        self.show()
예제 #35
0
    def __init__(self, parent=None):
        super(ToLyDialog, self).__init__(parent)
        self._info = None
        self._document = None
        self._path = None
        
        mainLayout = QGridLayout()
        self.setLayout(mainLayout)
        
        tabs = QTabWidget()
        
        import_tab = QWidget()
        post_tab = QWidget()
        
        itabLayout = QGridLayout(import_tab)
        ptabLayout = QGridLayout(post_tab)
        
        tabs.addTab(import_tab, self.imp_prgm)
        tabs.addTab(post_tab, "after import")

        self.formatCheck = QCheckBox()
        self.trimDurCheck = QCheckBox()
        self.removeScalesCheck = QCheckBox()
        self.runEngraverCheck = QCheckBox()

        self.postChecks = [self.formatCheck,
                           self.trimDurCheck,
                           self.removeScalesCheck,
                           self.runEngraverCheck]
                           
        self.versionLabel = QLabel()
        self.lilyChooser = lilychooser.LilyChooser()

        self.commandLineLabel = QLabel()
        self.commandLine = QTextEdit(acceptRichText=False)
        
        self.formatCheck.setObjectName("reformat")
        self.trimDurCheck.setObjectName("trim-durations")
        self.removeScalesCheck.setObjectName("remove-scaling")
        self.runEngraverCheck.setObjectName("engrave-directly")
        
        self.buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        userguide.addButton(self.buttons, self.userg)
        
        row = 0
        for r, w in enumerate(self.impChecks):
            row += r
            itabLayout.addWidget(w, row, 0, 1, 2)
            w.toggled.connect(self.makeCommandLine)
        row += 1    
        for r, w in enumerate(self.impExtra):
            row += r 
            itabLayout.addWidget(w, row, 0, 1, 2)
        
        itabLayout.addWidget(widgets.Separator(), row + 1, 0, 1, 2)
        itabLayout.addWidget(self.versionLabel, row + 2, 0, 1, 0)
        itabLayout.addWidget(self.lilyChooser, row + 3, 0, 1, 2)
        itabLayout.addWidget(widgets.Separator(), row + 4, 0, 1, 2)
        itabLayout.addWidget(self.commandLineLabel, row + 5, 0, 1, 2)
        itabLayout.addWidget(self.commandLine, row + 6, 0, 1, 2)
        
        ptabLayout.addWidget(self.formatCheck, 0, 0, 1, 2)
        ptabLayout.addWidget(self.trimDurCheck, 1, 0, 1, 2)       
        ptabLayout.addWidget(self.removeScalesCheck, 2, 0, 1, 2)
        ptabLayout.addWidget(self.runEngraverCheck, 3, 0, 1, 2)
        ptabLayout.setRowStretch(4, 10)
        
        mainLayout.addWidget(tabs, 0, 0, 9, 2)
        mainLayout.addWidget(self.buttons, 10, 0, 1, 2)
        
        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)
        
        self.lilyChooser.currentIndexChanged.connect(self.slotLilyPondVersionChanged)
        self.slotLilyPondVersionChanged()
예제 #36
0
def load(filename, widget):
    """Loads snippets from a file, displaying them in a list.
    
    The user can then choose:
    - overwrite builtin snippets or not
    - overwrite own snippets with same title or not
    - select and view snippets contents.
    
    """
    try:
        d = ET.parse(filename)
        elements = list(d.findall('snippet'))
        if not elements:
            raise ValueError(_("No snippets found."))
    except Exception as e:
        QMessageBox.critical(widget, app.caption(_("Error")),
        _("Can't read from source:\n\n{url}\n\n{error}").format(
            url=filename, error=e))
        return


    dlg = widgets.dialog.Dialog(widget)
    dlg.setWindowModality(Qt.WindowModal)
    dlg.setWindowTitle(app.caption(_("dialog title", "Import Snippets")))
    tree = QTreeWidget(headerHidden=True, rootIsDecorated=False)
    dlg.setMainWidget(tree)
    userguide.addButton(dlg.buttonBox(), "snippet_import_export")
    
    allnames = frozenset(snippets.names())
    builtins = frozenset(builtin.builtin_snippets)
    titles = dict((snippets.title(n), n) for n in allnames if n not in builtins)
    
    new = QTreeWidgetItem(tree, [_("New Snippets")])
    updated = QTreeWidgetItem(tree, [_("Updated Snippets")])
    unchanged = QTreeWidgetItem(tree, [_("Unchanged Snippets")])
    
    new.setFlags(Qt.ItemIsEnabled)
    updated.setFlags(Qt.ItemIsEnabled)
    unchanged.setFlags(Qt.ItemIsEnabled)
    
    new.setExpanded(True)
    updated.setExpanded(True)
    
    items = []
    for snip in elements:
        item = QTreeWidgetItem()
        
        item.body = snip.find('body').text
        item.title = snip.find('title').text
        item.shortcuts = list(e.text for e in snip.findall('shortcuts/shortcut'))
        
        title = item.title or snippets.maketitle(snippets.parse(item.body).text)
        item.setText(0, title)
        
        name = snip.get('id')
        name = name if name in builtins else None
        
        
        # determine if new, updated or unchanged
        if not name:
            name = titles.get(title)
        item.name = name
        
        if not name or name not in allnames:
            new.addChild(item)
            items.append(item)
            item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
            item.setCheckState(0, Qt.Checked)
        elif name:
            if (item.body != snippets.text(name)
                or title != snippets.title(name)
                or (item.shortcuts and item.shortcuts != 
                    [s.toString() for s in model.shortcuts(name) or ()])):
                updated.addChild(item)
                items.append(item)
                item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
                item.setCheckState(0, Qt.Checked)
            else:
                unchanged.addChild(item)
                item.setFlags(Qt.ItemIsEnabled)
    # count:
    for i in new, updated, unchanged:
        i.setText(0, i.text(0) + " ({0})".format(i.childCount()))
    for i in new, updated:
        if i.childCount():
            i.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
            i.setCheckState(0, Qt.Checked)
    
    def changed(item):
        if item in (new, updated):
            for i in range(item.childCount()):
                c = item.child(i)
                c.setCheckState(0, item.checkState(0))
            
    tree.itemChanged.connect(changed)
    
    importShortcuts = QTreeWidgetItem([_("Import Keyboard Shortcuts")])
    if items:
        tree.addTopLevelItem(importShortcuts)
        importShortcuts.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
        importShortcuts.setCheckState(0, Qt.Checked)
        dlg.setMessage(_("Choose which snippets you want to import:"))
    else:
        dlg.setMessage(_("There are no new or updated snippets in the file."))
        unchanged.setExpanded(True)
    
    tree.setWhatsThis(_(
        "<p>Here the snippets from {filename} are displayed.</p>\n"
        "<p>If there are new or updated snippets, you can select or deselect "
        "them one by one, or all at once, using the checkbox of the group. "
        "Then click OK to import all the selected snippets.</p>\n"
        "<p>Existing, unchanged snippets can't be imported.</p>\n"
        ).format(filename=os.path.basename(filename)))
        
    qutil.saveDialogSize(dlg, "snippettool/import/size", QSize(400, 300))
    if not dlg.exec_() or not items:
        return
    ac = model.collection()
    m = model.model()
    with qutil.busyCursor():
        for i in items:
            if i.checkState(0) == Qt.Checked:
                index = m.saveSnippet(i.name, i.body, i.title)
                if i.shortcuts and importShortcuts.checkState(0):
                    shortcuts = list(map(QKeySequence.fromString, i.shortcuts))
                    ac.setShortcuts(m.name(index), shortcuts)
        widget.updateColumnSizes()
예제 #37
0
    def __init__(self, parent=None):
        super(Dialog, self).__init__(parent)
        self._document = None
        self._path = None
        
        mainLayout = QGridLayout()
        self.setLayout(mainLayout)
        
        tabs = QTabWidget()
        
        import_tab = QWidget()
        post_tab = QWidget()
        
        itabLayout = QGridLayout(import_tab)
        ptabLayout = QGridLayout(post_tab)
        
        tabs.addTab(import_tab, "musicxml2ly")
        tabs.addTab(post_tab, "after import")
        
        self.noartCheck = QCheckBox()
        self.norestCheck = QCheckBox()
        self.nolayoutCheck = QCheckBox()
        self.nobeamCheck = QCheckBox()
        self.useAbsCheck = QCheckBox()
        self.commMidiCheck = QCheckBox()
        
        self.langCombo = QComboBox()
        self.langLabel = QLabel()
        
        self.impChecks = [self.noartCheck,
						  self.norestCheck,
						  self.nolayoutCheck,
						  self.nobeamCheck,
						  self.useAbsCheck,
						  self.commMidiCheck]
		
        self.formatCheck = QCheckBox()
        self.trimDurCheck = QCheckBox()
        self.removeScalesCheck = QCheckBox()
        self.runEngraverCheck = QCheckBox()
						   
        self.postChecks = [self.formatCheck,
						   self.trimDurCheck,
						   self.removeScalesCheck,
						   self.runEngraverCheck]								  
        
        self.commandLineLabel = QLabel()
        self.commandLine = QTextEdit(acceptRichText=False)
        
        self.setChecksObjectNames()
        
        self.buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        userguide.addButton(self.buttons, "musicxml_import")
        
        self.langCombo.addItem('')
        self.langCombo.addItems(_langlist)

        itabLayout.addWidget(self.noartCheck, 0, 0, 1, 2)
        itabLayout.addWidget(self.norestCheck, 1, 0, 1, 2)
        itabLayout.addWidget(self.nolayoutCheck, 2, 0, 1, 2)
        itabLayout.addWidget(self.nobeamCheck, 3, 0, 1, 2)
        itabLayout.addWidget(self.useAbsCheck, 4, 0, 1, 2)
        itabLayout.addWidget(self.commMidiCheck, 5, 0, 1, 2)
        itabLayout.addWidget(self.langLabel, 6, 0, 1, 2)
        itabLayout.addWidget(self.langCombo, 7, 0, 1, 2)
        itabLayout.addWidget(widgets.Separator(), 8, 0, 1, 2)
        itabLayout.addWidget(self.commandLineLabel, 9, 0, 1, 2)
        itabLayout.addWidget(self.commandLine, 10, 0, 1, 2)
        
        ptabLayout.addWidget(self.formatCheck, 0, 0, 1, 2)
        ptabLayout.addWidget(self.trimDurCheck, 1, 0, 1, 2)       
        ptabLayout.addWidget(self.removeScalesCheck, 2, 0, 1, 2)
        ptabLayout.addWidget(self.runEngraverCheck, 3, 0, 1, 2)
        ptabLayout.setRowStretch(4, 10)
        
        mainLayout.addWidget(tabs, 0, 0, 9, 2)
        mainLayout.addWidget(self.buttons, 10, 0, 1, 2)
        
        app.translateUI(self)
        qutil.saveDialogSize(self, "xml_import/dialog/size", QSize(480, 260))
        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)
        
        self.noartCheck.toggled.connect(self.makeCommandLine)
        self.norestCheck.toggled.connect(self.makeCommandLine)
        self.nolayoutCheck.toggled.connect(self.makeCommandLine)
        self.nobeamCheck.toggled.connect(self.makeCommandLine)
        self.useAbsCheck.toggled.connect(self.makeCommandLine)
        self.commMidiCheck.toggled.connect(self.makeCommandLine)
        self.langCombo.currentIndexChanged.connect(self.makeCommandLine)
        self.makeCommandLine()
        
        self.loadSettings()
예제 #38
0
    def __init__(self, widget, name, text=""):
        super(Edit, self).__init__(widget)

        self._name = name

        layout = QVBoxLayout()
        self.setLayout(layout)

        self.topLabel = QLabel()
        self.text = QTextEdit(cursorWidth=2, acceptRichText=False)
        self.titleLabel = QLabel()
        self.titleEntry = QLineEdit()
        self.shortcutLabel = QLabel()
        self.shortcutButton = ShortcutButton(clicked=self.editShortcuts)

        layout.addWidget(self.topLabel)
        layout.addWidget(self.text)

        grid = QGridLayout()
        layout.addLayout(grid)

        grid.addWidget(self.titleLabel, 0, 0)
        grid.addWidget(self.titleEntry, 0, 1)
        grid.addWidget(self.shortcutLabel, 1, 0)
        grid.addWidget(self.shortcutButton, 1, 1)

        layout.addWidget(widgets.Separator())

        b = QDialogButtonBox(accepted=self.accept, rejected=self.reject)
        layout.addWidget(b)

        buttons = QDialogButtonBox.Ok | QDialogButtonBox.Cancel
        if name and name in builtin.builtin_snippets:
            b.setStandardButtons(buttons | QDialogButtonBox.RestoreDefaults)
            b.button(QDialogButtonBox.RestoreDefaults).clicked.connect(
                self.slotDefaults)
        else:
            b.setStandardButtons(buttons)
        userguide.addButton(b, "snippet_editor")

        # PyQt4.10 en sip4.14.5 delete the Highlighter, even though it is
        # constructed with a parent, that's why we save it in an unused attribute.
        self._highlighter = highlight.Highlighter(self.text.document())
        Matcher(self.text)
        widgets.indenter.Indenter(self.text)
        self.text.installEventFilter(homekey.handler)
        wordboundary.handler.install_textedit(self.text)
        completer.Completer(self.text)

        if name:
            self.titleEntry.setText(snippets.title(name, False) or '')
            self.text.setPlainText(snippets.text(name))
            ac = self.parent().parent().snippetActions
            self.setShortcuts(ac.shortcuts(name))
        else:
            self.text.setPlainText(text)
            self.setShortcuts(None)

        app.translateUI(self)

        self.readSettings()
        app.settingsChanged.connect(self.readSettings)
        qutil.saveDialogSize(self, "snippettool/editor/size", QSize(400, 300))
        self.show()
예제 #39
0
 def __init__(self, mainwindow):
     super(Dialog, self).__init__(mainwindow)
     self._document = None
     
     layout = QGridLayout()
     self.setLayout(layout)
     
     self.versionLabel = QLabel()
     self.lilyChooser = lilychooser.LilyChooser()
     
     self.outputLabel = QLabel()
     self.outputCombo = QComboBox()
     
     self.resolutionLabel = QLabel()
     self.resolutionCombo = QComboBox(editable=True)
     
     self.antialiasLabel = QLabel()
     self.antialiasSpin = QSpinBox(minimum=1, maximum=128, value=1)
     
     self.modeLabel = QLabel()
     self.modeCombo = QComboBox()
     
     self.englishCheck = QCheckBox()
     self.deleteCheck = QCheckBox()
     
     self.commandLineLabel = QLabel()
     self.commandLine = QTextEdit(acceptRichText=False)
     
     self.buttons = QDialogButtonBox(
         QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
     self.buttons.button(QDialogButtonBox.Ok).setIcon(icons.get("lilypond-run"))
     userguide.addButton(self.buttons, "engrave_custom")
     
     self.resolutionCombo.addItems(['100', '200', '300', '600', '1200'])
     self.resolutionCombo.setCurrentIndex(2)
     
     self.modeCombo.addItems(['preview', 'publish', 'debug'])
     layout.addWidget(self.versionLabel, 0, 0)
     layout.addWidget(self.lilyChooser, 0, 1, 1, 3)
     layout.addWidget(self.outputLabel, 1, 0)
     layout.addWidget(self.outputCombo, 1, 1, 1, 3)
     layout.addWidget(self.resolutionLabel, 2, 0)
     layout.addWidget(self.resolutionCombo, 2, 1)
     layout.addWidget(self.antialiasLabel, 2, 2, Qt.AlignRight)
     layout.addWidget(self.antialiasSpin, 2, 3)
     layout.addWidget(self.modeLabel, 3, 0)
     layout.addWidget(self.modeCombo, 3, 1, 1, 3)
     layout.addWidget(self.englishCheck, 4, 0, 1, 4)
     layout.addWidget(self.deleteCheck, 5, 0, 1, 4)
     layout.addWidget(self.commandLineLabel, 6, 0, 1, 4)
     layout.addWidget(self.commandLine, 7, 0, 1, 4)
     layout.addWidget(widgets.Separator(), 8, 0, 1, 4)
     layout.addWidget(self.buttons, 9, 0, 1, 4)
     
     app.translateUI(self)
     qutil.saveDialogSize(self, "engrave/custom/dialog/size", QSize(480, 260))
     self.buttons.accepted.connect(self.accept)
     self.buttons.rejected.connect(self.reject)
     
     model = listmodel.ListModel(formats, display=lambda f: f.title(),
         icon=lambda f: icons.file_type(f.type))
     self.outputCombo.setModel(model)
     
     s = QSettings()
     s.beginGroup("lilypond_settings")
     self.englishCheck.setChecked(
         s.value("no_translation", False, bool))
     self.deleteCheck.setChecked(
         s.value("delete_intermediate_files", True, bool))
     
     if s.value("default_output_target", "pdf", type("")) == "svg":
         self.outputCombo.setCurrentIndex(3)
     
     app.jobFinished.connect(self.slotJobFinished)
     self.outputCombo.currentIndexChanged.connect(self.makeCommandLine)
     self.modeCombo.currentIndexChanged.connect(self.makeCommandLine)
     self.deleteCheck.toggled.connect(self.makeCommandLine)
     self.resolutionCombo.editTextChanged.connect(self.makeCommandLine)
     self.antialiasSpin.valueChanged.connect(self.makeCommandLine)
     self.makeCommandLine()
     panelmanager.manager(mainwindow).layoutcontrol.widget().optionsChanged.connect(self.makeCommandLine)
예제 #40
0
    def __init__(self, parent):
        super(InfoDialog, self).__init__(parent)
        self.setWindowModality(Qt.WindowModal)
        
        layout = QVBoxLayout()
        layout.setSpacing(10)
        self.setLayout(layout)

        self.tab = QTabWidget()
        tab_general = QWidget()
        tab_toolcommands = QWidget()
        self.tab.addTab(tab_general, "")
        self.tab.addTab(tab_toolcommands, "")
        
        # general tab
        vbox = QVBoxLayout()
        vbox.setSpacing(4)
        tab_general.setLayout(vbox)
        
        hbox = QHBoxLayout()
        self.lilyname = QLineEdit()
        self.lilynameLabel = l = QLabel()
        l.setBuddy(self.lilyname)
        hbox.addWidget(l)
        hbox.addWidget(self.lilyname)
        vbox.addLayout(hbox)
        
        self.lilypond = widgets.urlrequester.UrlRequester()
        self.lilypond.setFileMode(QFileDialog.ExistingFile)
        self.lilypondLabel = l = QLabel()
        l.setBuddy(self.lilypond)
        vbox.addWidget(l)
        vbox.addWidget(self.lilypond)
        
        self.auto = QCheckBox()
        vbox.addWidget(self.auto)
        vbox.addStretch(1)

        # toolcommands tab
        grid = QGridLayout()
        grid.setSpacing(4)
        tab_toolcommands.setLayout(grid)
        
        self.ly_tool_widgets = {}
        row = 0
        for name, gui in self.toolnames():
            w = QLineEdit()
            l = QLabel()
            l.setBuddy(w)
            grid.addWidget(l, row, 0)
            grid.addWidget(w, row, 1)
            row += 1
            self.ly_tool_widgets[name] = (l, w)
        
        layout.addWidget(self.tab)
        layout.addWidget(widgets.Separator())
        b = self.buttons = QDialogButtonBox(self)
        layout.addWidget(b)
        
        b.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        b.accepted.connect(self.accept)
        b.rejected.connect(self.reject)
        userguide.addButton(b, "prefs_lilypond")
        app.translateUI(self)
        qutil.saveDialogSize(self, "/preferences/lilypond/lilypondinfo/dialog/size")