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()
def document_fonts(self): """ Menu action Document Fonts. Depending on the LilyPond version associated with the current document show either the new or the old document font dialog. """ mainwin = self.mainwindow() view = mainwin.currentView() doc = mainwin.currentDocument() import documentinfo info = documentinfo.lilyinfo(doc) if info.version() >= (2, 19, 12): # Show the new Document Fonts dialog from . import dialog dlg = dialog.FontsDialog(mainwin, lilypond_info=info) qutil.saveDialogSize(dlg, "document-fonts-dialog/dialog-size", QSize(1024, 700)) dlg.exec_() if dlg.result: # is populated when the user has clicked "Use" cmd = (dlg.result if dlg.result[-1] == '\n' else dlg.result + '\n') view.textCursor().insertText(cmd) else: # Show the old "Set Document Fonts" dialog from . import oldfontsdialog dlg = oldfontsdialog.DocumentFontsDialog(self.mainwindow()) if dlg.exec_(): cmd = dlg.document_font_code() # NOTE: How to translate this to the dialog context? # if state[-1] != "paper": cmd = "\\paper {{\n{0}}}\n".format(cmd) view.textCursor().insertText(cmd)
def report_failed(self): """Show a warning message box if extension(s) could either not be loaded or produced errors while parsing the extension infos.""" from PyQt5.QtCore import QCoreApplication import appinfo import qutil import widgets.dialog dlg = widgets.dialog.Dialog( self.mainwindow(), icon='warning', buttons=('ok',), title=appinfo.appname, message=_( "There were problems loading the extensions.\n" "The following details are also available from the " "Preferences dialog.")) dlg.setMainWidget(FailedTree(self.mainwindow())) qutil.saveDialogSize( dlg, "extensions/error-dialog/size", QSize(600, 300)) dlg.setGeometry(QStyle.alignedRect( Qt.RightToLeft, Qt.AlignCenter, dlg.size(), app.qApp.desktop().availableGeometry())) dlg.exec()
def __init__(self, parent=None): super(Dialog, self).__init__(parent) self._filename = None self._page = None self._rect = None self.imageViewer = widgets.imageviewer.ImageViewer() self.dpiLabel = QLabel() self.dpiCombo = QComboBox(insertPolicy=QComboBox.NoInsert, editable=True) self.dpiCombo.lineEdit().setCompleter(None) self.dpiCombo.setValidator( QDoubleValidator(10.0, 1200.0, 4, self.dpiCombo)) self.dpiCombo.addItems( [format(i) for i in (72, 100, 200, 300, 600, 1200)]) self.colorButton = widgets.colorbutton.ColorButton() self.colorButton.setColor(QColor(Qt.white)) self.crop = QCheckBox() self.antialias = QCheckBox(checked=True) self.scaleup = QCheckBox(checked=False) self.dragfile = QPushButton(icons.get("image-x-generic"), None, None) self.fileDragger = FileDragger(self.dragfile) self.buttons = QDialogButtonBox(QDialogButtonBox.Close) self.copyButton = self.buttons.addButton('', QDialogButtonBox.ApplyRole) self.copyButton.setIcon(icons.get('edit-copy')) self.saveButton = self.buttons.addButton('', QDialogButtonBox.ApplyRole) self.saveButton.setIcon(icons.get('document-save')) layout = QVBoxLayout() self.setLayout(layout) layout.addWidget(self.imageViewer) controls = QHBoxLayout() layout.addLayout(controls) controls.addWidget(self.dpiLabel) controls.addWidget(self.dpiCombo) controls.addWidget(self.colorButton) controls.addWidget(self.crop) controls.addWidget(self.antialias) controls.addWidget(self.scaleup) controls.addStretch() controls.addWidget(self.dragfile) layout.addWidget(widgets.Separator()) layout.addWidget(self.buttons) app.translateUI(self) self.readSettings() self.finished.connect(self.writeSettings) self.dpiCombo.editTextChanged.connect(self.drawImage) self.colorButton.colorChanged.connect(self.drawImage) self.antialias.toggled.connect(self.drawImage) self.scaleup.toggled.connect(self.drawImage) self.crop.toggled.connect(self.cropImage) self.buttons.rejected.connect(self.reject) self.copyButton.clicked.connect(self.copyToClipboard) self.saveButton.clicked.connect(self.saveAs) qutil.saveDialogSize(self, "copy_image/dialog/size", QSize(480, 320))
def slotButtonShowDiff(self): """Called when the user clicks Show Difference.""" docs = self.selectedDocuments() or self.allDocuments() if not docs: return d = docs[0] if documentwatcher.DocumentWatcher.instance(d).isdeleted(): return filename = d.url().toLocalFile() try: with open(filename) as f: disktext = util.decode(f.read()) except (IOError, OSError): return currenttext = d.toPlainText() html = htmldiff.htmldiff( currenttext, disktext, _("Current Document"), _("Document on Disk"), numlines=5) dlg = widgets.dialog.Dialog(self, buttons=('close',)) view = QTextBrowser(lineWrapMode=QTextBrowser.NoWrap) view.setHtml(html) dlg.setMainWidget(view) dlg.setWindowTitle(app.caption("Differences")) dlg.setMessage(_( "Document: {url}\n" "Difference between the current document and the file on disk:").format( url=filename)) dlg.setWindowModality(Qt.NonModal) dlg.setAttribute(Qt.WA_QuitOnClose, False) dlg.setAttribute(Qt.WA_DeleteOnClose) qutil.saveDialogSize(dlg, "externalchanges/diff/dialog/size", QSize(600, 300)) dlg.show()
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)
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("preferences-desktop-keyboard-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) qutil.saveDialogSize(self, "snippettool/editor/size", QSize(400, 300)) self.show()
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)
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) qutil.saveDialogSize(self, "global_font_dialog/dialog/size")
def __init__(self, parent=None): super(Dialog, self).__init__(parent) self._filename = None self._page = None self._rect = None self.imageViewer = widgets.imageviewer.ImageViewer() self.dpiLabel = QLabel() self.dpiCombo = QComboBox(insertPolicy=QComboBox.NoInsert, editable=True) self.dpiCombo.lineEdit().setCompleter(None) self.dpiCombo.setValidator(QDoubleValidator(10.0, 1200.0, 4, self.dpiCombo)) self.dpiCombo.addItems([format(i) for i in (72, 100, 200, 300, 600, 1200)]) self.colorButton = widgets.colorbutton.ColorButton() self.colorButton.setColor(QColor(Qt.white)) self.grayscale = QCheckBox(checked=False) self.crop = QCheckBox() self.antialias = QCheckBox(checked=True) self.scaleup = QCheckBox(checked=False) self.dragfile = QPushButton(icons.get("image-x-generic"), None, None) self.fileDragger = FileDragger(self.dragfile) self.buttons = QDialogButtonBox(QDialogButtonBox.Close) self.copyButton = self.buttons.addButton('', QDialogButtonBox.ApplyRole) self.copyButton.setIcon(icons.get('edit-copy')) self.saveButton = self.buttons.addButton('', QDialogButtonBox.ApplyRole) self.saveButton.setIcon(icons.get('document-save')) layout = QVBoxLayout() self.setLayout(layout) layout.addWidget(self.imageViewer) controls = QHBoxLayout() layout.addLayout(controls) controls.addWidget(self.dpiLabel) controls.addWidget(self.dpiCombo) controls.addWidget(self.colorButton) controls.addWidget(self.grayscale) controls.addWidget(self.crop) controls.addWidget(self.antialias) controls.addWidget(self.scaleup) controls.addStretch() controls.addWidget(self.dragfile) layout.addWidget(widgets.Separator()) layout.addWidget(self.buttons) app.translateUI(self) self.readSettings() self.finished.connect(self.writeSettings) self.dpiCombo.editTextChanged.connect(self.drawImage) self.colorButton.colorChanged.connect(self.drawImage) self.grayscale.toggled.connect(self.drawImage) self.antialias.toggled.connect(self.drawImage) self.scaleup.toggled.connect(self.drawImage) self.crop.toggled.connect(self.cropImage) self.buttons.rejected.connect(self.reject) self.copyButton.clicked.connect(self.copyToClipboard) self.saveButton.clicked.connect(self.saveAs) qutil.saveDialogSize(self, "copy_image/dialog/size", QSize(480, 320))
def __init__(self, parent=None): super(Dialog, self).__init__(parent) self._info = None self._text = '' self._convertedtext = '' self._encoding = None self.mainwindow = parent self.fromVersionLabel = QLabel() self.fromVersion = QLineEdit() self.reason = QLabel() self.toVersionLabel = QLabel() self.toVersion = QLineEdit() self.lilyChooser = lilychooser.LilyChooser() self.messages = QTextBrowser() self.diff = QTextBrowser(lineWrapMode=QTextBrowser.NoWrap) self.uni_diff = QTextBrowser(lineWrapMode=QTextBrowser.NoWrap) self.copyCheck = QCheckBox(checked= QSettings().value('convert_ly/copy_messages', True, bool)) self.tabw = QTabWidget() self.tabw.addTab(self.messages, '') self.tabw.addTab(self.diff, '') self.tabw.addTab(self.uni_diff, '') self.buttons = QDialogButtonBox( QDialogButtonBox.Reset | QDialogButtonBox.Save | QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.buttons.button(QDialogButtonBox.Ok).clicked .connect(self.accept) self.buttons.rejected.connect(self.reject) self.buttons.button(QDialogButtonBox.Reset).clicked.connect(self.run) self.buttons.button(QDialogButtonBox.Save).clicked.connect(self.saveFile) layout = QVBoxLayout() self.setLayout(layout) grid = QGridLayout() grid.addWidget(self.fromVersionLabel, 0, 0) grid.addWidget(self.fromVersion, 0, 1) grid.addWidget(self.reason, 0, 2, 1, 3) grid.addWidget(self.toVersionLabel, 1, 0) grid.addWidget(self.toVersion, 1, 1) grid.addWidget(self.lilyChooser, 1, 3, 1, 2) layout.addLayout(grid) layout.addWidget(self.tabw) layout.addWidget(self.copyCheck) layout.addWidget(widgets.Separator()) layout.addWidget(self.buttons) app.translateUI(self) qutil.saveDialogSize(self, 'convert_ly/dialog/size', QSize(600, 300)) app.settingsChanged.connect(self.readSettings) self.readSettings() self.finished.connect(self.saveCopyCheckSetting) self.lilyChooser.currentIndexChanged.connect(self.slotLilyPondVersionChanged) self.slotLilyPondVersionChanged()
def show_available_fonts(mainwin, info): """Display a dialog with the available fonts of LilyPond specified by info.""" dlg = Dialog(mainwin) dlg.setWindowTitle(app.caption("Available Fonts")) dlg.run_command(info, ['-dshow-available-fonts'], _("Available Fonts")) dlg.setMessage(_( "List of fonts detected by {version}").format(version=info.prettyName())) qutil.saveDialogSize(dlg, "engrave/tools/available-fonts/dialog/size", QSize(640, 400)) dlg.show()
def show_available_fonts(mainwin, info): """Display a dialog with the available fonts of LilyPond specified by info.""" dlg = Dialog(mainwin) dlg.setWindowTitle(app.caption(_("Available Fonts"))) dlg.run_command(info, ['-dshow-available-fonts'], _("Available Fonts")) dlg.setMessage(_( "List of fonts detected by {version}").format(version=info.prettyName())) qutil.saveDialogSize(dlg, "engrave/tools/available-fonts/dialog/size", QSize(640, 400)) dlg.setAttribute(Qt.WA_DeleteOnClose) dlg.show()
def __init__(self, parent, auto_accept=False): super(Dialog, self).__init__(parent, buttons=( 'cancel', 'ok', )) self.setWindowModality(Qt.WindowModal) self.setIconSize(32) self.auto_accept = auto_accept self.log = log.Log(self) self.job = None self.setMainWidget(self.log) qutil.saveDialogSize(self, "job-dialog/dialog/size", QSize(480, 800))
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, bool)) 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) qutil.saveDialogSize(self, 'convert_ly/dialog/size', QSize(600, 300)) app.settingsChanged.connect(self.readSettings) self.readSettings() self.finished.connect(self.saveCopyCheckSetting)
def __init__(self, mainwindow): super(PreferencesDialog, self).__init__(mainwindow) self.setWindowModality(Qt.WindowModal) if mainwindow: 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 qutil.saveDialogSize(self, "preferences/dialog/size", QSize(500, 300)) self.pagelist.setCurrentRow(_prefsindex)
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")
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() qutil.saveDialogSize(self, "musicpreview/dialog/size", QSize(500, 350)) app.translateUI(self)
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()
def __init__(self, parent=None): self.useAbsCheck = QCheckBox() self.impChecks = [self.useAbsCheck] self.useAbsCheck.setObjectName("absolute-mode") self.impExtra = [] super(Dialog, self).__init__(parent, imp_prgm='midi2ly', userg='midi_import') app.translateUI(self) qutil.saveDialogSize(self, "midi_import/dialog/size", QSize(480, 260)) self.loadSettings()
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) qutil.saveDialogSize(self, "helpbrowser/sourceviewer/size", QSize(400, 300))
def __init__(self, parent=None): self.nobeamCheck = QCheckBox() self.impChecks = [self.nobeamCheck] self.nobeamCheck.setObjectName("import-beaming") self.impExtra = [] super(Dialog, self).__init__( parent, imp_prgm='abc2ly', userg='abc_import') app.translateUI(self) qutil.saveDialogSize(self, "abc_import/dialog/size", QSize(480, 160)) self.loadSettings()
def __init__(self, parent=None): self.imp_prgm = "musicxml2ly" self.userg = "musicxml_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.noartCheck.setObjectName("articulation-directions") self.norestCheck.setObjectName("rest-positions") self.nolayoutCheck.setObjectName("page-layout") self.nobeamCheck.setObjectName("import-beaming") self.useAbsCheck.setObjectName("absolute-mode") self.commMidiCheck.setObjectName("comment-out-midi") self.langCombo.addItem('') self.langCombo.addItems(_langlist) self.impExtra = [self.langLabel, self.langCombo] super(Dialog, self).__init__(parent) self.langCombo.currentIndexChanged.connect(self.makeCommandLine) app.translateUI(self) qutil.saveDialogSize(self, "musicxml_import/dialog/size", QSize(480, 260)) self.makeCommandLine() self.loadSettings()
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()
def __init__(self, parent=None): super(Dialog, self).__init__(parent) self._document = None self._path = None layout = QGridLayout() self.setLayout(layout) self.noartCheck = QCheckBox() self.norestCheck = QCheckBox() self.nolayoutCheck = QCheckBox() self.nobeamCheck = QCheckBox() self.commandLineLabel = QLabel() self.commandLine = QTextEdit(acceptRichText=False) self.buttons = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel) help.addButton(self.buttons, help_importXML) layout.addWidget(self.noartCheck, 0, 0, 1, 2) layout.addWidget(self.norestCheck, 1, 0, 1, 2) layout.addWidget(self.nolayoutCheck, 2, 0, 1, 2) layout.addWidget(self.nobeamCheck, 3, 0, 1, 2) layout.addWidget(self.commandLineLabel, 4, 0, 1, 2) layout.addWidget(self.commandLine, 5, 0, 1, 2) layout.addWidget(widgets.Separator(), 6, 0, 1, 2) layout.addWidget(self.buttons, 7, 0, 1, 2) app.translateUI(self) qutil.saveDialogSize(self, "importXML/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.makeCommandLine()
def __init__(self, parent=None): self.imp_prgm = "midi2ly" self.userg = "midi_import" self.useAbsCheck = QCheckBox() self.impChecks = [self.useAbsCheck] self.useAbsCheck.setObjectName("absolute-mode") self.impExtra = [] super(Dialog, self).__init__(parent) app.translateUI(self) qutil.saveDialogSize(self, "midi_import/dialog/size", QSize(480, 260)) self.makeCommandLine() self.loadSettings()
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")
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) qutil.saveDialogSize(self, "hyphenation/dialog/size")
def slotButtonShowDiff(self): """Called when the user clicks Show Difference.""" docs = self.selectedDocuments() or self.allDocuments() if not docs: return d = docs[0] if documentwatcher.DocumentWatcher.instance(d).isdeleted(): return filename = d.url().toLocalFile() try: with open(filename, 'rb') as f: disktext = util.decode(f.read()) except (IOError, OSError): return currenttext = d.toPlainText() html = htmldiff.htmldiff(currenttext, disktext, _("Current Document"), _("Document on Disk"), numlines=5) dlg = widgets.dialog.Dialog(self, buttons=('close', )) view = QTextBrowser(lineWrapMode=QTextBrowser.NoWrap) view.setHtml(html) dlg.setMainWidget(view) dlg.setWindowTitle(app.caption("Differences")) dlg.setMessage( _("Document: {url}\n" "Difference between the current document and the file on disk:"). format(url=filename)) dlg.setWindowModality(Qt.NonModal) dlg.setAttribute(Qt.WA_QuitOnClose, False) dlg.setAttribute(Qt.WA_DeleteOnClose) qutil.saveDialogSize(dlg, "externalchanges/diff/dialog/size", QSize(600, 300)) dlg.show()
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()
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()
def __init__(self, parent, caption): super(AudioExportDialog, self).__init__(parent) self.setWindowModality(Qt.NonModal) self.setWindowTitle(caption) qutil.saveDialogSize(self, "audio_export/dialog/size", QSize(640, 400))
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()
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()
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")
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()
def __init__(self, parent=None): super(Dialog, self).__init__(parent) self._filename = None self._page = None self._rect = None self._exporter = None self.runJob = qpageview.backgroundjob.SingleRun() self.imageViewer = qpageview.imageview.ImageView() self.typeLabel = QLabel() self.typeCombo = QComboBox() self.typeCombo.addItems([''] * len(self.exportTypes())) self.dpiLabel = QLabel() self.dpiCombo = QComboBox(insertPolicy=QComboBox.NoInsert, editable=True) self.dpiCombo.lineEdit().setCompleter(None) self.dpiCombo.setValidator( QDoubleValidator(10.0, 1200.0, 4, self.dpiCombo)) self.dpiCombo.addItems( [format(i) for i in (72, 100, 200, 300, 600, 1200)]) self.colorCheck = QCheckBox(checked=False) self.colorButton = widgets.colorbutton.ColorButton() self.colorButton.setColor(QColor(Qt.white)) self.grayscale = QCheckBox(checked=False) self.crop = QCheckBox() self.antialias = QCheckBox(checked=True) self.scaleup = QCheckBox(checked=False) self.dragfile = QPushButton(icons.get("image-x-generic"), None, None) self.copyfile = QPushButton(icons.get('edit-copy'), None, None) self.dragdata = QPushButton(icons.get("image-x-generic"), None, None) self.copydata = QPushButton(icons.get('edit-copy'), None, None) self.buttons = QDialogButtonBox(QDialogButtonBox.Close) self.saveButton = self.buttons.addButton('', QDialogButtonBox.ApplyRole) self.saveButton.setIcon(icons.get('document-save')) layout = QVBoxLayout() self.setLayout(layout) hlayout = QHBoxLayout() hlayout.addWidget(self.imageViewer) controls = QGridLayout() hlayout.addLayout(controls) controls.addWidget(self.typeLabel, 0, 0) controls.addWidget(self.typeCombo, 0, 1) controls.addWidget(self.dpiLabel, 1, 0) controls.addWidget(self.dpiCombo, 1, 1) colorLayout = QHBoxLayout(margin=0) colorLayout.addWidget(self.colorCheck) colorLayout.addWidget(self.colorButton) controls.addLayout(colorLayout, 2, 0, 1, 2) controls.addWidget(self.grayscale, 3, 0, 1, 2) controls.addWidget(self.crop, 4, 0, 1, 2) controls.addWidget(self.antialias, 5, 0, 1, 2) controls.addWidget(self.scaleup, 6, 0, 1, 2) controls.addWidget(self.copydata, 8, 0, 1, 2) controls.addWidget(self.copyfile, 9, 0, 1, 2) controls.addWidget(self.dragdata, 10, 0, 1, 2) controls.addWidget(self.dragfile, 11, 0, 1, 2) controls.setRowStretch(7, 1) layout.addLayout(hlayout) layout.addWidget(widgets.Separator()) layout.addWidget(self.buttons) app.translateUI(self) self.readSettings() self.finished.connect(self.writeSettings) self.typeCombo.currentIndexChanged.connect(self.updateExport) self.dpiCombo.editTextChanged.connect(self.updateExport) self.colorCheck.toggled.connect(self.updateExport) self.colorButton.colorChanged.connect(self.updateExport) self.grayscale.toggled.connect(self.updateExport) self.scaleup.toggled.connect(self.updateExport) self.crop.toggled.connect(self.updateExport) self.antialias.toggled.connect(self.updateExport) self.buttons.rejected.connect(self.reject) self.copydata.clicked.connect(self.copyDataToClipboard) self.copyfile.clicked.connect(self.copyFileToClipboard) self.dragdata.pressed.connect(self.dragData) self.dragfile.pressed.connect(self.dragFile) self.dragdata.setFocusPolicy(Qt.NoFocus) self.dragfile.setFocusPolicy(Qt.NoFocus) self.saveButton.clicked.connect(self.saveAs) qutil.saveDialogSize(self, "copy_image/dialog/size", QSize(480, 320))
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) 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)) 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()
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()
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()
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)
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)
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()