コード例 #1
0
 def __init__(self, parent=None):
     super(GlobalFontDialog, self).__init__(parent)
     self._messageLabel.setWordWrap(True)
     
     layout = QGridLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     self.mainWidget().setLayout(layout)
     
     self.romanLabel = QLabel()
     self.romanCombo = QFontComboBox()
     self.sansLabel = QLabel()
     self.sansCombo = QFontComboBox()
     self.typewriterLabel = QLabel()
     self.typewriterCombo = QFontComboBox(fontFilters=QFontComboBox.MonospacedFonts)
     self.staffSizeLabel = QLabel()
     self.staffSizeChooser = QSpinBox(minimum=1, maximum=200, value=20)
     
     layout.addWidget(self.romanLabel, 0, 0)
     layout.addWidget(self.romanCombo, 0, 1, 1, 2)
     layout.addWidget(self.sansLabel, 1, 0)
     layout.addWidget(self.sansCombo, 1, 1, 1, 2)
     layout.addWidget(self.typewriterLabel, 2, 0)
     layout.addWidget(self.typewriterCombo, 2, 1, 1, 2)
     layout.addWidget(self.staffSizeLabel, 3, 0)
     layout.addWidget(self.staffSizeChooser, 3, 1)
     
     self.loadSettings()
     self.finished.connect(self.saveSettings)
     app.translateUI(self)
     util.saveDialogSize(self, "global_font_dialog/dialog/size")
コード例 #2
0
ファイル: dialog.py プロジェクト: mbsrz1972/frescobaldi
 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)
     help.addButton(b, scorewiz_help)
     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)
     util.saveDialogSize(self, "scorewiz/dialog/size")
     app.translateUI(self)
     self.accepted.connect(self.slotAccepted)
コード例 #3
0
ファイル: edit.py プロジェクト: mbsrz1972/frescobaldi
 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 = QPushButton(icon=icons.get("configure-shortcuts"),
         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)
     help.addButton(b, snippet_edit_help)
     
     highlight.Highlighter(self.text.document())
     Matcher(self.text)
     widgets.indenter.Indenter(self.text)
     self.text.installEventFilter(homekey.handler)
     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)
     util.saveDialogSize(self, "snippettool/editor/size", QSize(400, 300))
     self.show()
コード例 #4
0
ファイル: convert_ly.py プロジェクト: mbsrz1972/frescobaldi
    def __init__(self, parent=None):
        super(Dialog, self).__init__(parent)

        self._info = None
        self._text = ""
        self._convertedtext = ""
        self._encoding = None

        self.fromVersionLabel = QLabel()
        self.fromVersion = QLineEdit()
        self.reason = QLabel()
        self.toVersionLabel = QLabel()
        self.toVersion = QLineEdit()
        self.messages = QTextBrowser()
        self.diff = QTextBrowser(lineWrapMode=QTextBrowser.NoWrap)
        self.copyCheck = QCheckBox(checked=QSettings().value("convert_ly/copy_messages", True) not in (False, "false"))
        self.tabw = QTabWidget()

        self.tabw.addTab(self.messages, "")
        self.tabw.addTab(self.diff, "")

        self.buttons = QDialogButtonBox(QDialogButtonBox.Reset | QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)
        self.buttons.button(QDialogButtonBox.Reset).clicked.connect(self.run)

        layout = QVBoxLayout()
        self.setLayout(layout)

        top = QHBoxLayout()
        top.addWidget(self.fromVersionLabel)
        top.addWidget(self.fromVersion)
        top.addWidget(self.reason)
        top.addStretch()
        top.addWidget(self.toVersionLabel)
        top.addWidget(self.toVersion)

        layout.addLayout(top)
        layout.addWidget(self.tabw)
        layout.addWidget(self.copyCheck)
        layout.addWidget(widgets.Separator())
        layout.addWidget(self.buttons)

        app.translateUI(self)
        util.saveDialogSize(self, "convert_ly/dialog/size", QSize(600, 300))
        app.settingsChanged.connect(self.readSettings)
        self.readSettings()
        self.finished.connect(self.saveCopyCheckSetting)
コード例 #5
0
ファイル: __init__.py プロジェクト: mbsrz1972/frescobaldi
 def __init__(self, mainwindow):
     super(PreferencesDialog, self).__init__(mainwindow)
     self.setWindowModality(Qt.WindowModal)
     self.addAction(mainwindow.actionCollection.help_whatsthis)
     layout = QVBoxLayout()
     layout.setSpacing(10)
     self.setLayout(layout)
     
     # listview to the left, stacked widget to the right
     top = QHBoxLayout()
     layout.addLayout(top)
     
     self.pagelist = QListWidget(self)
     self.stack = QStackedWidget(self)
     top.addWidget(self.pagelist, 0)
     top.addWidget(self.stack, 2)
     
     layout.addWidget(widgets.Separator(self))
     
     b = self.buttons = QDialogButtonBox(self)
     b.setStandardButtons(
         QDialogButtonBox.Ok
         | QDialogButtonBox.Cancel
         | QDialogButtonBox.Apply
         | QDialogButtonBox.Reset
         | QDialogButtonBox.Help)
     layout.addWidget(b)
     b.accepted.connect(self.accept)
     b.rejected.connect(self.reject)
     b.button(QDialogButtonBox.Apply).clicked.connect(self.saveSettings)
     b.button(QDialogButtonBox.Reset).clicked.connect(self.loadSettings)
     b.button(QDialogButtonBox.Help).clicked.connect(self.showHelp)
     b.button(QDialogButtonBox.Help).setShortcut(QKeySequence.HelpContents)
     b.button(QDialogButtonBox.Apply).setEnabled(False)
     
     # fill the pagelist
     self.pagelist.setIconSize(QSize(32, 32))
     self.pagelist.setSpacing(2)
     for item in pageorder():
         self.pagelist.addItem(item())
     self.pagelist.currentItemChanged.connect(self.slotCurrentItemChanged)
     
     app.translateUI(self, 100)
     # read our size and selected page
     util.saveDialogSize(self, "preferences/dialog/size", QSize(500, 300))
     self.pagelist.setCurrentRow(_prefsindex)
コード例 #6
0
ファイル: musicpreview.py プロジェクト: mbsrz1972/frescobaldi
 def __init__(self, parent=None):
     super(MusicPreviewDialog, self).__init__(parent)
     layout = QVBoxLayout()
     self.setLayout(layout)
     self._widget = MusicPreviewWidget()
     layout.addWidget(self._widget)
     layout.addWidget(widgets.Separator())
     b = QDialogButtonBox()
     layout.addWidget(b)
     b.addButton(QDialogButtonBox.Close)
     b.rejected.connect(self.accept)
     self._printButton = b.addButton("", QDialogButtonBox.ActionRole)
     self._printButton.setIcon(icons.get("document-print"))
     self._printButton.clicked.connect(self._widget.print_)
     self._printButton.hide()
     util.saveDialogSize(self, "musicpreview/dialog/size", QSize(500, 350))
     app.translateUI(self)
コード例 #7
0
ファイル: sourceviewer.py プロジェクト: mbsrz1972/frescobaldi
    def __init__(self, browser):
        super(SourceViewer, self).__init__(browser.parentWidget())

        layout = QVBoxLayout()
        layout.setContentsMargins(4, 4, 4, 4)
        self.setLayout(layout)
        
        self.urlLabel = QLabel(wordWrap=True)
        layout.addWidget(self.urlLabel)
        self.textbrowser = QTextBrowser()
        layout.addWidget(self.textbrowser)
        
        self.urlLabel.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        self.textbrowser.setLineWrapMode(QTextBrowser.NoWrap)
        
        app.settingsChanged.connect(self.readSettings)
        self.readSettings()
        app.translateUI(self)
        util.saveDialogSize(self, "helpbrowser/sourceviewer/size", QSize(400, 300))
コード例 #8
0
ファイル: hyphendialog.py プロジェクト: mbsrz1972/frescobaldi
 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)
     help.addButton(b, lyrics_help)
     b.rejected.connect(self.reject)
     b.accepted.connect(self.accept)
     
     self.load()
     app.translateUI(self)
     util.saveDialogSize(self, "hyphenation/dialog/size")
コード例 #9
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.setWindowTitle(app.caption(_("dialog title", "Import Snippets")))
    tree = QTreeWidget(headerHidden=True, rootIsDecorated=False)
    dlg.setMainWidget(tree)
    
    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)))
        
    util.saveDialogSize(dlg, "snippettool/import/size", QSize(400, 300))
    if not dlg.exec_() or not items:
        return
    ac = model.collection()
    m = model.model()
    with util.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()
コード例 #10
0
ファイル: custom.py プロジェクト: mbsrz1972/frescobaldi
 def __init__(self, parent=None):
     super(Dialog, self).__init__(parent)
     self._document = None
     
     layout = QGridLayout()
     self.setLayout(layout)
     
     self.versionLabel = QLabel()
     self.versionCombo = QComboBox()
     
     self.outputLabel = QLabel()
     self.outputCombo = QComboBox()
     
     self.resolutionLabel = QLabel()
     self.resolutionCombo = QComboBox(editable=True)
     
     self.previewCheck = QCheckBox()
     self.verboseCheck = QCheckBox()
     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"))
     help.addButton(self.buttons, help_engrave_custom)
     
     self.resolutionCombo.addItems(['100', '200', '300', '600', '1200'])
     self.resolutionCombo.setCurrentIndex(2)
     
     layout.addWidget(self.versionLabel, 0, 0)
     layout.addWidget(self.versionCombo, 0, 1)
     layout.addWidget(self.outputLabel, 1, 0)
     layout.addWidget(self.outputCombo, 1, 1)
     layout.addWidget(self.resolutionLabel, 2, 0)
     layout.addWidget(self.resolutionCombo, 2, 1)
     layout.addWidget(self.previewCheck, 3, 0, 1, 2)
     layout.addWidget(self.verboseCheck, 4, 0, 1, 2)
     layout.addWidget(self.englishCheck, 5, 0, 1, 2)
     layout.addWidget(self.deleteCheck, 6, 0, 1, 2)
     layout.addWidget(self.commandLineLabel, 7, 0, 1, 2)
     layout.addWidget(self.commandLine, 8, 0, 1, 2)
     layout.addWidget(widgets.Separator(), 9, 0, 1, 2)
     layout.addWidget(self.buttons, 10, 0, 1, 2)
     
     app.translateUI(self)
     util.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) in (True, "true"))
     self.deleteCheck.setChecked(
         s.value("delete_intermediate_files", True) not in (False, "false"))
     
     self.loadLilyPondVersions()
     self.selectLilyPondInfo(lilypondinfo.preferred())
     app.settingsChanged.connect(self.loadLilyPondVersions)
     app.jobFinished.connect(self.slotJobFinished)
     self.outputCombo.currentIndexChanged.connect(self.makeCommandLine)
     self.previewCheck.toggled.connect(self.makeCommandLine)
     self.verboseCheck.toggled.connect(self.makeCommandLine)
     self.deleteCheck.toggled.connect(self.makeCommandLine)
     self.resolutionCombo.editTextChanged.connect(self.makeCommandLine)
     self.makeCommandLine()