def createActions(self, parent):
        self.edit_cut_assign = QAction(parent)
        self.edit_move_to_include_file = QAction(parent)
        self.view_highlighting = QAction(parent)
        self.view_highlighting.setCheckable(True)
        self.view_goto_file_or_definition = QAction(parent)
        self.tools_indent_auto = QAction(parent)
        self.tools_indent_auto.setCheckable(True)
        self.tools_indent_indent = QAction(parent)
        self.tools_reformat = QAction(parent)
        self.tools_remove_trailing_whitespace = QAction(parent)
        self.tools_convert_ly = QAction(parent)
        self.tools_quick_remove_comments = QAction(parent)
        self.tools_quick_remove_articulations = QAction(parent)
        self.tools_quick_remove_ornaments = QAction(parent)
        self.tools_quick_remove_instrument_scripts = QAction(parent)
        self.tools_quick_remove_slurs = QAction(parent)
        self.tools_quick_remove_dynamics = QAction(parent)
        self.tools_quick_remove_fingerings = QAction(parent)
        self.tools_quick_remove_markup = QAction(parent)
        
        self.edit_cut_assign.setIcon(icons.get('edit-cut'))
        self.edit_move_to_include_file.setIcon(icons.get('edit-cut'))

        self.view_goto_file_or_definition.setShortcut(QKeySequence(Qt.ALT + Qt.Key_Return))
        self.edit_cut_assign.setShortcut(QKeySequence(Qt.SHIFT + Qt.CTRL + Qt.Key_X))
Beispiel #2
0
    def __init__(self, *args, **kwargs):
        QWidget.__init__(self, *args, **kwargs)
        layout = QGridLayout(self)
        self.setLayout(layout)

        self.addButton = QPushButton(icons.get('list-add'), '')
        self.editButton = QPushButton(icons.get('document-edit'), '')
        self.removeButton = QPushButton(icons.get('list-remove'), '')
        self.listBox = QListWidget()

        layout.setContentsMargins(1, 1, 1, 1)
        layout.setSpacing(0)
        layout.addWidget(self.listBox, 0, 0, 8, 1)
        layout.addWidget(self.addButton, 0, 1)
        layout.addWidget(self.editButton, 1, 1)
        layout.addWidget(self.removeButton, 2, 1)

        def updateSelection():
            selected = bool(self.listBox.currentItem())
            self.editButton.setEnabled(selected)
            self.removeButton.setEnabled(selected)

        self.changed.connect(updateSelection)
        self.listBox.itemSelectionChanged.connect(updateSelection)
        updateSelection()
        self.connectSlots()
        app.translateUI(self)
Beispiel #3
0
 def createActions(self, parent=None):
     self.scorewiz = QAction(parent)
     self.scorewiz.setIcon(icons.get("tools-score-wizard"))
     self.scorewiz.setShortcut(QKeySequence("Ctrl+Shift+N"))
     self.newwithwiz = QAction(parent)
     self.newwithwiz.setIcon(icons.get("tools-score-wizard"))
     self.scorewiz.setMenuRole(QAction.NoRole)
Beispiel #4
0
 def setFileMode(self, mode):
     """Sets the mode for the dialog, is a QFileDialog.FileMode value."""
     if mode == QFileDialog.Directory:
         self.button.setIcon(icons.get('folder-open'))
     else:
         self.button.setIcon(icons.get('document-open'))
     self._fileMode = mode
Beispiel #5
0
    def createActions(self):
        # These actions are for the main menus
        self.newViewerAct = QAction(icons.get("file-new"), "&New Viewer", self)
        self.newViewerAct.setShortcut("Ctrl+N")
        self.connect(self.newViewerAct, SIGNAL("triggered()"), self.newViewer)

        self.newTerminalAct = QAction(icons.get("terminal"), "New &Terminal", self)
        self.newTerminalAct.setShortcut("Ctrl+T")
        self.connect(self.newViewerAct, SIGNAL("triggered()"), self.newTerminal)

        self.openDirAct = QAction(icons.get("folder"), "&Open Effort Directory...", self)
        self.openDirAct.setShortcut("Ctrl+O")
        self.connect(self.openDirAct, SIGNAL("triggered()"), self.open)

        self.quitAct = QAction("&Quit", self)
        self.quitAct.setShortcut("Ctrl+Q")
        self.connect(self.quitAct, SIGNAL("triggered()"), self, SLOT("close()"))

        self.clusterSelectionAct = QAction(icons.get("dendrogram"), "Cluster Selection", self)
        self.clusterSelectionAct.setShortcut("Ctrl+K")
        self.connect(self.clusterSelectionAct, SIGNAL("triggered()"), self.newClustering)

        self.toggleSourceAct = self.sourceDock.toggleViewAction()
        self.toggleSourceAct.setShortcut("Alt+0")

        self.linkViewersAct = QAction("Link Viewers", self)
        self.linkViewersAct.setShortcut("Ctrl+L")
        self.linkViewersAct.setCheckable(True)
        self.linkViewersAct.setChecked(self.viewers.getLink())
        self.connect(self.linkViewersAct, SIGNAL("toggled(bool)"), self.viewers.setLink)

        self.aboutAct = QAction(icons.get("libra_icon64"), "About Libra", self)
        self.aboutAct.setShortcut("Ctrl+H")
        self.connect(self.aboutAct, SIGNAL("triggered()"), self.about)
Beispiel #6
0
 def _updateLayoutDirection(self):
     b = self._clearButton
     if self.layoutDirection() == Qt.RightToLeft:
         self.setTextMargins(b.width(), 0, 0, 0)
         b.setIcon(icons.get('edit-clear-locationbar-ltr'))
     else:
         self.setTextMargins(0, 0, b.width(), 0)
         b.setIcon(icons.get('edit-clear-locationbar-rtl'))
Beispiel #7
0
 def _updateLayoutDirection(self):
     b = self._clearButton
     if self.layoutDirection() == Qt.RightToLeft:
         self.setTextMargins(b.width(), 0, 0, 0)
         b.setIcon(icons.get('edit-clear-locationbar-ltr'))
     else:
         self.setTextMargins(0, 0, b.width(), 0)
         b.setIcon(icons.get('edit-clear-locationbar-rtl'))
Beispiel #8
0
    def createActions(self, panel):
        self.svg_zoom_in = QAction(panel)
        self.svg_zoom_out = QAction(panel)
        self.svg_zoom_original = QAction(panel)

        self.svg_zoom_in.setIcon(icons.get('zoom-in'))
        self.svg_zoom_out.setIcon(icons.get('zoom-out'))
        self.svg_zoom_original.setIcon(icons.get('zoom-original'))
Beispiel #9
0
    def createActions(self, parent):
        self.pitch_language = QAction(parent)
        self.pitch_rel2abs = QAction(parent)
        self.pitch_abs2rel = QAction(parent)
        self.pitch_transpose = QAction(parent)

        self.pitch_language.setIcon(icons.get('tools-pitch-language'))
        self.pitch_transpose.setIcon(icons.get('tools-transpose'))
Beispiel #10
0
    def createActions(self, panel):
        self.svg_zoom_in = QAction(panel)
        self.svg_zoom_out = QAction(panel)
        self.svg_zoom_original = QAction(panel)

        self.svg_zoom_in.setIcon(icons.get("zoom-in"))
        self.svg_zoom_out.setIcon(icons.get("zoom-out"))
        self.svg_zoom_original.setIcon(icons.get("zoom-original"))
Beispiel #11
0
    def __init__(self, parent):
        super(ScorePartsWidget, self).__init__(parent)

        self.typesLabel = QLabel()
        self.typesView = QTreeView(selectionMode=QTreeView.ExtendedSelection,
                                   selectionBehavior=QTreeView.SelectRows,
                                   animated=True,
                                   headerHidden=True)
        self.scoreLabel = QLabel()
        self.scoreView = widgets.treewidget.TreeWidget(
            selectionMode=QTreeView.ExtendedSelection,
            selectionBehavior=QTreeView.SelectRows,
            headerHidden=True,
            animated=True,
            dragDropMode=QTreeView.InternalMove)
        self.addButton = QPushButton(icon=icons.get("list-add"))
        self.removeButton = QPushButton(icon=icons.get("list-remove"))
        self.upButton = QToolButton(icon=icons.get("go-up"))
        self.downButton = QToolButton(icon=icons.get("go-down"))
        self.partSettings = QStackedWidget()

        w = QWidget()
        self.addWidget(w)
        layout = QVBoxLayout(spacing=0)
        w.setLayout(layout)

        layout.addWidget(self.typesLabel)
        layout.addWidget(self.typesView)
        layout.addWidget(self.addButton)

        w = QWidget()
        self.addWidget(w)
        layout = QVBoxLayout(spacing=0)
        w.setLayout(layout)

        layout.addWidget(self.scoreLabel)
        layout.addWidget(self.scoreView)

        box = QHBoxLayout(spacing=0)
        layout.addLayout(box)

        box.addWidget(self.removeButton)
        box.addWidget(self.upButton)
        box.addWidget(self.downButton)

        self.addWidget(self.partSettings)

        self.typesView.setModel(parts.model())
        app.translateUI(self)

        # signal connections
        self.addButton.clicked.connect(self.slotAddButtonClicked)
        self.removeButton.clicked.connect(self.slotRemoveButtonClicked)
        self.typesView.doubleClicked.connect(self.slotDoubleClicked)
        self.scoreView.currentItemChanged.connect(self.slotCurrentItemChanged)
        self.upButton.clicked.connect(self.scoreView.moveSelectedChildrenUp)
        self.downButton.clicked.connect(
            self.scoreView.moveSelectedChildrenDown)
Beispiel #12
0
    def __init__(self, parent):
        super(ScorePartsWidget, self).__init__(parent)
        
        self.typesLabel = QLabel()
        self.typesView = QTreeView(
            selectionMode=QTreeView.ExtendedSelection,
            selectionBehavior=QTreeView.SelectRows,
            animated=True,
            headerHidden=True)
        self.scoreLabel = QLabel()
        self.scoreView = widgets.treewidget.TreeWidget(
            selectionMode=QTreeView.ExtendedSelection,
            selectionBehavior=QTreeView.SelectRows,
            headerHidden=True,
            animated=True,
            dragDropMode=QTreeView.InternalMove)
        self.addButton = QPushButton(icon = icons.get("list-add"))
        self.removeButton = QPushButton(icon = icons.get("list-remove"))
        self.upButton = QToolButton(icon = icons.get("go-up"))
        self.downButton = QToolButton(icon = icons.get("go-down"))
        self.partSettings = QStackedWidget()
        
        w = QWidget()
        self.addWidget(w)
        layout = QVBoxLayout(spacing=0)
        w.setLayout(layout)
        
        layout.addWidget(self.typesLabel)
        layout.addWidget(self.typesView)
        layout.addWidget(self.addButton)
        
        w = QWidget()
        self.addWidget(w)
        layout = QVBoxLayout(spacing=0)
        w.setLayout(layout)
        
        layout.addWidget(self.scoreLabel)
        layout.addWidget(self.scoreView)
        
        box = QHBoxLayout(spacing=0)
        layout.addLayout(box)
        
        box.addWidget(self.removeButton)
        box.addWidget(self.upButton)
        box.addWidget(self.downButton)
        
        self.addWidget(self.partSettings)

        self.typesView.setModel(parts.model())
        app.translateUI(self)
        
        # signal connections
        self.addButton.clicked.connect(self.slotAddButtonClicked)
        self.removeButton.clicked.connect(self.slotRemoveButtonClicked)
        self.typesView.doubleClicked.connect(self.slotDoubleClicked)
        self.scoreView.currentItemChanged.connect(self.slotCurrentItemChanged)
        self.upButton.clicked.connect(self.scoreView.moveSelectedChildrenUp)
        self.downButton.clicked.connect(self.scoreView.moveSelectedChildrenDown)
Beispiel #13
0
    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))
Beispiel #14
0
    def createActions(self, parent=None):
        self.capture_start = QAction(parent)
        self.capture_stop = QAction(parent)
        self.accidental_switch = QAction(parent)

        self.capture_start.setIcon(icons.get('media-record'))
        self.capture_stop.setIcon(icons.get('process-stop'))

        self.accidental_switch.setShortcut(QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_3))
Beispiel #15
0
    def createActions(self, parent):
        self.go_back = QAction(parent)
        self.go_forward = QAction(parent)

        self.go_back.setIcon(icons.get('go-previous'))
        self.go_forward.setIcon(icons.get('go-next'))

        self.go_back.setShortcut(QKeySequence(Qt.ALT + Qt.Key_Backspace))
        self.go_forward.setShortcut(QKeySequence(Qt.ALT + Qt.Key_End))
 def createActions(self):
     self.doc_save = self.addAction(icons.get('document-save'), '')
     self.doc_save_as = self.addAction(icons.get('document-save-as'), '')
     self.addSeparator()
     self.doc_close = self.addAction(icons.get('document-close'), '')
     
     self.doc_save.triggered.connect(self.docSave)
     self.doc_save_as.triggered.connect(self.docSaveAs)
     self.doc_close.triggered.connect(self.docClose)
Beispiel #17
0
    def __init__(self,
                 regions=dict(),
                 showRect=None,
                 gridSpcing=5,
                 useGrid=True,
                 hideOnClose=True):
        super(WindowRegionSelector, self).__init__()
        self.curr_dir = None
        self.press_pos = QPoint()
        self.startRect = QRect()
        self.useGrid = useGrid
        self.gridPixelSize = gridSpcing
        self.savedRegions = regions
        self.showRect = showRect
        self.hideOnClose = hideOnClose

        self.maximizeButton = QPushButton('Maximize')
        self.maximizeButton.clicked.connect(self.toggleFullScreen)

        def makeEdit(value):
            edit = QLineEdit(value)
            edit.returnPressed.connect(self.updateRectFromText)
            v = QIntValidator()
            v.setBottom(0)
            edit.setValidator(v)
            return edit

        self.xEdit = makeEdit('100')
        self.yEdit = makeEdit('100')
        self.wEdit = makeEdit('200')
        self.hEdit = makeEdit('100')
        self.editWidget = QWidget()

        self.takeScreenshot = QPushButton()
        self.takeScreenshot.setIcon(icons.get('screenshot'))
        self.takeScreenshot.setToolTip('Take screenshot now')
        self.takeScreenshot.clicked.connect(lambda: self.doScreenShot(0))

        delay = 5
        self.takeScreenshotDelayed = QPushButton()
        self.takeScreenshotDelayed.setIcon(icons.get('screenshot'))
        self.takeScreenshotDelayed.setToolTip(
            'Take screenshot in {} seconds'.format(delay))
        self.takeScreenshotDelayed.setText('{} s'.format(delay))
        self.takeScreenshotDelayed.clicked.connect(
            lambda: self.doScreenShot(delay))

        self.namedRegionsSelector = QComboBox()
        self.namedRegionsSelector.addItem('Custom')
        for name in self.savedRegions:
            self.namedRegionsSelector.addItem(name)
        self.namedRegionsSelector.addItem('Save Current')
        self.namedRegionsSelector.currentIndexChanged.connect(
            self.handleNamedRegionSelection)
        self.initUI()

        self.updateTextFromRect()
Beispiel #18
0
def show(position, panel, link, cursor):
    """Shows a context menu.
    
    position: The global position to pop up
    panel: The music view panel, giving access to mainwindow and view widget
    link: a popplerqt4 LinkBrowse instance or None
    cursor: a QTextCursor instance or None
    
    """
    m = QMenu(panel)

    # selection? -> Copy
    if panel.widget().view.surface().hasSelection():
        m.addAction(panel.actionCollection.music_copy_image)

    if cursor:
        a = m.addAction(icons.get("document-edit"), _("Edit in Place"))

        @a.triggered.connect
        def edit():
            from . import editinplace
            editinplace.edit(panel.widget(), cursor, position)
    elif link:
        a = m.addAction(icons.get("window-new"), _("Open Link in &New Window"))

        @a.triggered.connect
        def open_in_browser():
            import helpers
            helpers.openUrl(QUrl(link.url()))

        a = m.addAction(icons.get("edit-copy"), _("Copy &Link"))

        @a.triggered.connect
        def copy_link():
            QApplication.clipboard().setText(link.url())

    # no actions yet? insert Fit Width/Height
    if not m.actions():
        m.addAction(panel.actionCollection.music_fit_width)
        m.addAction(panel.actionCollection.music_fit_height)
        m.addAction(panel.actionCollection.music_zoom_original)
        m.addSeparator()
        m.addAction(panel.actionCollection.music_sync_cursor)

    # help
    m.addSeparator()
    a = m.addAction(icons.get("help-contents"), _("Help"))

    @a.triggered.connect
    def help():
        import userguide
        userguide.show("musicview")

    # show it!
    if m.actions():
        m.exec_(position)
    m.deleteLater()
Beispiel #19
0
 def createActions(self, parent):
     self.go_back = QAction(parent)
     self.go_forward = QAction(parent)
     
     self.go_back.setIcon(icons.get('go-previous'))
     self.go_forward.setIcon(icons.get('go-next'))
     
     self.go_back.setShortcut(QKeySequence(Qt.ALT + Qt.Key_Backspace))
     self.go_forward.setShortcut(QKeySequence(Qt.ALT + Qt.Key_End))
Beispiel #20
0
 def display(self):
     text = self._info.prettyName()
     if self._info.version():
         self.setIcon(icons.get("lilypond-run"))
     else:
         self.setIcon(icons.get("dialog-error"))
     if self._info.command == self.listWidget().parentWidget().parentWidget()._defaultCommand:
         text += " [{0}]".format(_("default"))
     self.setText(text)
Beispiel #21
0
 def display(self):
     text = self._info.prettyName()
     if self._info.version():
         self.setIcon(icons.get("lilypond-run"))
     else:
         self.setIcon(icons.get("dialog-error"))
     if self._info.command == self.listWidget().parentWidget().parentWidget()._defaultCommand:
         text += " [{0}]".format(_("default"))
     self.setText(text)
Beispiel #22
0
    def __init__(self, models):
        super(Modeler, self).__init__()

        self.setLayout(vlayout())

        toolbar = hlayout()

        self._viewport = ModelerViewport(models)
        self._viewport.modifierModeChanged.connect(self._modifierModeChanged)

        self._selectButton = QPushButton(icons.get('icons8-cursor-50'), '')
        self._selectButton.clicked.connect(self._viewport.setModifierModeSelect)
        self._selectButton.setIconSize(QSize(24, 24))
        self._selectButton.setToolTip('Select')
        self._selectButton.setStatusTip('Select')
        self._selectButton.setCheckable(True)
        self._selectButton.setChecked(True)
        toolbar.addWidget(self._selectButton)

        self._translateButton = QPushButton(icons.get('icons8-move-50'), '')
        self._translateButton.clicked.connect(self._viewport.setModifierModeTranslate)
        self._translateButton.setIconSize(QSize(24, 24))
        self._translateButton.setToolTip('Translate')
        self._translateButton.setStatusTip('Translate')
        self._translateButton.setCheckable(True)
        toolbar.addWidget(self._translateButton)

        self._rotateButton = QPushButton(icons.get('icons8-3d-rotate-50'), '')
        self._rotateButton.clicked.connect(self._viewport.setModifierModeRotate)
        self._rotateButton.setIconSize(QSize(24, 24))
        self._rotateButton.setToolTip('Rotate')
        self._rotateButton.setStatusTip('Rotate')
        self._rotateButton.setCheckable(True)
        toolbar.addWidget(self._rotateButton)

        self._scaleButton = QPushButton(icons.get('icons8-scale-tool-50'), '')
        self._scaleButton.clicked.connect(self._viewport.setModifierModeScale)
        self._scaleButton.setIconSize(QSize(24, 24))
        self._scaleButton.setToolTip('Scale')
        self._scaleButton.setStatusTip('Scale')
        self._scaleButton.setCheckable(True)
        toolbar.addWidget(self._scaleButton)

        toolbar.addSpacing(10)

        centerViewButton = QPushButton(icons.get('icons8-zoom-to-extents-50'), '')
        centerViewButton.clicked.connect(self._viewport.centerView)
        centerViewButton.setIconSize(QSize(24, 24))
        centerViewButton.setToolTip('Center View (f)')
        centerViewButton.setStatusTip('Center View (f)')
        toolbar.addWidget(centerViewButton)

        toolbar.addStretch(1)

        self.layout().addLayout(toolbar)
        self.layout().addWidget(self._viewport)
        self.layout().setStretch(1, 1)
Beispiel #23
0
    def contextMenuEvent(self, ev):
        item = self.itemAt(ev.pos())
        if not item:
            return

        mainwindow = self.parentWidget().mainwindow()

        selection = self.selectedItems()
        doc = self.document(item)

        if len(selection) <= 1 and doc:
            # a single document is right-clicked
            import documentcontextmenu
            menu = documentcontextmenu.DocumentContextMenu(mainwindow)
            menu.exec_(doc, ev.globalPos())
            menu.deleteLater()
            return

        menu = QMenu(mainwindow)
        save = menu.addAction(icons.get('document-save'), '')
        menu.addSeparator()
        close = menu.addAction(icons.get('document-close'), '')

        if len(selection) > 1:
            # multiple documents are selected
            save.setText(_("Save selected documents"))
            close.setText(_("Close selected documents"))
            documents = [self.document(item) for item in selection]
        else:
            documents = [
                self.document(item.child(i)) for i in range(item.childCount())
            ]
            if item._path:
                # a directory item is right-clicked
                save.setText(_("Save documents in this folder"))
                close.setText(_("Close documents in this folder"))
            else:
                # the "Untitled" group is right-clicked
                save.setText(_("Save all untitled documents"))
                close.setText(_("Close all untitled documents"))

        @save.triggered.connect
        def savedocuments():
            for d in documents:
                if d.url().isEmpty() or d.isModified():
                    mainwindow.setCurrentDocument(d)
                if not mainwindow.saveDocument(d):
                    break

        @close.triggered.connect
        def close_documents():
            for d in documents:
                if not mainwindow.closeDocument(d):
                    break

        menu.exec_(ev.globalPos())
        menu.deleteLater()
Beispiel #24
0
    def contextMenuEvent(self, ev):
        item = self.itemAt(ev.pos())
        if not item:
            return

        mainwindow = self.parentWidget().mainwindow()

        selection = self.selectedItems()
        doc = self.document(item)

        if len(selection) <= 1 and doc:
            # a single document is right-clicked
            import documentcontextmenu

            menu = documentcontextmenu.DocumentContextMenu(mainwindow)
            menu.exec_(doc, ev.globalPos())
            menu.deleteLater()
            return

        menu = QMenu(mainwindow)
        save = menu.addAction(icons.get("document-save"), "")
        menu.addSeparator()
        close = menu.addAction(icons.get("document-close"), "")

        if len(selection) > 1:
            # multiple documents are selected
            save.setText(_("Save selected documents"))
            close.setText(_("Close selected documents"))
            documents = [self.document(item) for item in selection]
        else:
            documents = [self.document(item.child(i)) for i in range(item.childCount())]
            if item._path:
                # a directory item is right-clicked
                save.setText(_("Save documents in this folder"))
                close.setText(_("Close documents in this folder"))
            else:
                # the "Untitled" group is right-clicked
                save.setText(_("Save all untitled documents"))
                close.setText(_("Close all untitled documents"))

        @save.triggered.connect
        def savedocuments():
            for d in documents:
                if d.url().isEmpty() or d.isModified():
                    mainwindow.setCurrentDocument(d)
                if not mainwindow.saveDocument(d):
                    break

        @close.triggered.connect
        def close_documents():
            for d in documents:
                if not mainwindow.closeDocument(d):
                    break

        menu.exec_(ev.globalPos())
        menu.deleteLater()
Beispiel #25
0
 def toggle(self, *args):
     self.__cameraControlActive = not self.__cameraControlActive
     if self.__cameraControlActive:
         self.__enabled.setIcon(icons.get('Toggle Off-48'))
         self.__enabled.setToolTip('Enable camera animation')
         self.__enabled.setStatusTip('Enable camera animation')
     else:
         self.__enabled.setIcon(icons.get('Toggle On-48'))
         self.__enabled.setToolTip('Disable camera animation')
         self.__enabled.setStatusTip('Disable camera animation')
Beispiel #26
0
 def display(self):
     text = util.homify(self._info.command)
     if self._info.version():
         text += " ({0})".format(self._info.versionString())
         self.setIcon(icons.get("lilypond-run"))
     else:
         self.setIcon(icons.get("dialog-error"))
     if self._info.command == self.listWidget().parentWidget().parentWidget()._defaultCommand:
         text += " [{0}]".format(_("default"))
     self.setText(text)
Beispiel #27
0
    def createActions(self, parent=None):
        self.session_new = QAction(parent)
        self.session_save = QAction(parent)
        self.session_manage = QAction(parent)
        self.session_none = QAction(parent)
        self.session_none.setCheckable(True)

        self.session_new.setIcon(icons.get("document-new"))
        self.session_save.setIcon(icons.get("document-save"))
        self.session_manage.setIcon(icons.get("view-choose"))
Beispiel #28
0
    def createActions(self, parent):
        self.pitch_language = QAction(parent)
        self.pitch_rel2abs = QAction(parent)
        self.pitch_abs2rel = QAction(parent)
        self.pitch_transpose = QAction(parent)
        self.pitch_modal_transpose = QAction(parent)

        self.pitch_language.setIcon(icons.get('tools-pitch-language'))
        self.pitch_transpose.setIcon(icons.get('tools-transpose'))
        self.pitch_modal_transpose.setIcon(icons.get('tools-transpose'))
Beispiel #29
0
    def createActions(self, parent=None):
        self.capture_start = QAction(parent)
        self.capture_stop = QAction(parent)
        self.accidental_switch = QAction(parent)

        self.capture_start.setIcon(icons.get('media-record'))
        self.capture_stop.setIcon(icons.get('process-stop'))

        self.accidental_switch.setShortcut(
            QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_3))
Beispiel #30
0
    def createActions(self, parent=None):
        self.session_new = QAction(parent)
        self.session_save = QAction(parent)
        self.session_manage = QAction(parent)
        self.session_none = QAction(parent)
        self.session_none.setCheckable(True)

        self.session_new.setIcon(icons.get('document-new'))
        self.session_save.setIcon(icons.get('document-save'))
        self.session_manage.setIcon(icons.get('view-choose'))
Beispiel #31
0
    def __toggleMute(self):
        isMuted = not muteState()
        setMuteState(isMuted)

        self.__mute.setIcon(icons.get('Mute') if isMuted else icons.get('Medium Volume'))
        self.__mute.setToolTip('Un-mute' if isMuted else 'Mute')
        self.__mute.setStatusTip('Un-mute' if isMuted else 'Mute')

        if self.__soundtrack:  # re-applies the mute state if soundtrack already exists
            self.__soundtrack.volume = 0 if muteState() else 100
Beispiel #32
0
def show(position, panel, link, cursor):
    """Shows a context menu.

    position: The global position to pop up
    panel: The music view panel, giving access to mainwindow and view widget
    link: a popplerqt5 LinkBrowse instance or None
    cursor: a QTextCursor instance or None

    """
    m = QMenu(panel)

    # selection? -> Copy
    if panel.widget().view.surface().hasSelection():
        if panel.widget().view.surface().selectedText():
            m.addAction(panel.actionCollection.music_copy_text)
        m.addAction(panel.actionCollection.music_copy_image)

    if cursor:
        a = m.addAction(icons.get("document-edit"), _("Edit in Place"))
        @a.triggered.connect
        def edit():
            import editinplace
            editinplace.edit(panel.widget(), cursor, position)
    elif link:
        a = m.addAction(icons.get("window-new"), _("Open Link in &New Window"))
        @a.triggered.connect
        def open_in_browser():
            import helpers
            helpers.openUrl(QUrl(link.url()))

        a = m.addAction(icons.get("edit-copy"), _("Copy &Link"))
        @a.triggered.connect
        def copy_link():
            QApplication.clipboard().setText(link.url())

    # no actions yet? insert Fit Width/Height
    if not m.actions():
        m.addAction(panel.actionCollection.music_fit_width)
        m.addAction(panel.actionCollection.music_fit_height)
        m.addAction(panel.actionCollection.music_zoom_original)
        m.addSeparator()
        m.addAction(panel.actionCollection.music_sync_cursor)

    # help
    m.addSeparator()
    a = m.addAction(icons.get("help-contents"), _("Help"))
    @a.triggered.connect
    def help():
        import userguide
        userguide.show("musicview")

    # show it!
    if m.actions():
        m.exec_(position)
    m.deleteLater()
Beispiel #33
0
 def pinned(self, value):
     if value:
         self.enabled = True
     self._pinned = value
     if value:
         self.items[0].setIcon(icons.get('Pin'))
     else:
         if not self._enabled:
             self.items[0].setIcon(icons.get('Unchecked Checkbox'))
         else:
             self.items[0].setIcon(icons.get('Checked Checkbox'))
Beispiel #34
0
 def __togglePlayPause(self):
     if self.__playPause.toolTip() == 'Play':
         self.__playPause.setIcon(icons.get('Pause'))
         self.__playPause.setToolTip('Pause')
         self.__playPause.setStatusTip('Pause')
         self.__playSoundtrack()
     else:
         self.__playPause.setIcon(icons.get('Play'))
         self.__playPause.setToolTip('Play')
         self.__playPause.setStatusTip('Play')
         self.__stopSoundtrack()
Beispiel #35
0
 def __init__(self):
     super(ShotManager, self).__init__()
     mainLayout = vlayout()
     self.setLayout(mainLayout)
     beltLayout = hlayout()
     btn = QPushButton(icons.get('Film Reel Create'), '')
     btn.setToolTip('Create shot')
     btn.setStatusTip('Create shot')
     btn.clicked.connect(self.createShot)
     beltLayout.addWidget(btn)
     btn = QPushButton(icons.get('Film Reel Copy'), '')
     btn.setToolTip('Duplicate shot')
     btn.setStatusTip('Duplicate shot')
     btn.clicked.connect(self.__duplicateSelectedShots)
     beltLayout.addWidget(btn)
     # btn = QPushButton(icons.get('Film Reel Merge'), '') # what do we do when selected shots are not adjacent?
     # btn.setToolTip('Merge shots')
     # beltLayout.addWidget(btn)
     # btn = QPushButton(icons.get('Film Reel Cut'), '')
     # btn.setToolTip('Cut shots')
     # beltLayout.addWidget(btn)
     btn = QPushButton(icons.get('Film Reel Delete'), '')
     btn.setToolTip('Delete shots')
     btn.setStatusTip('Delete shots')
     btn.clicked.connect(self.__deleteSelectedShots)
     beltLayout.addWidget(btn)
     mainLayout.addLayout(beltLayout)
     self.__table = ShotView()
     self.findSceneRequest = self.__table.findSceneRequest
     self.viewShotAction = self.__table.viewShotAction
     self.__table.pinShotAction.connect(self.onPinShot)
     self.shotsEnabled = self.__table.shotsEnabled
     self.shotsDisabled = self.__table.shotsDisabled
     delegate = FloatItemDelegate()
     self.__table.setItemDelegateForColumn(2, delegate)
     self.__table.setItemDelegateForColumn(3, delegate)
     mainLayout.addWidget(self.__table)
     self.__model = ShotItemModel()
     shots = ShotModel()
     shots.setSourceModel(self.__model)
     self.__model.setColumnCount(7)
     self.__model.setHorizontalHeaderLabels(
         ['Name', 'Scene', 'Start', 'End', 'Duration', 'Speed', 'Preroll'])
     self.__table.setModel(shots)
     self.__table.setSelectionBehavior(QAbstractItemView.SelectRows)
     self.__table.setSortingEnabled(True)
     self.__table.sortByColumn(2)
     self.__table.selectionModel().currentChanged.connect(
         self.__onCurrentChanged)
     self.__loadAllShots()
     # Duration changes end, start changes end, end changes duration.
     self.shotChanged.connect(self.__onPropagateShotChange)
 def createActions(self):
     self.doc_save = self.addAction(icons.get('document-save'), '')
     self.doc_save_as = self.addAction(icons.get('document-save-as'), '')
     self.addSeparator()
     self.doc_close = self.addAction(icons.get('document-close'), '')
     self.addSeparator()
     self.doc_toggle_sticky = self.addAction(icons.get('pushpin'), '')
     self.doc_toggle_sticky.setCheckable(True)
     
     self.doc_save.triggered.connect(self.docSave)
     self.doc_save_as.triggered.connect(self.docSaveAs)
     self.doc_close.triggered.connect(self.docClose)
     self.doc_toggle_sticky.triggered.connect(self.docToggleSticky)
Beispiel #37
0
    def addLinkAction(self, link):
        """Add action if on an arbitrary link"""
        m = self._menu
        a = m.addAction(icons.get("window-new"), _("Open Link in &New Window"))
        @a.triggered.connect
        def open_in_browser():
            import helpers
            helpers.openUrl(QUrl(link.url()))

        a = m.addAction(icons.get("edit-copy"), _("Copy &Link"))
        @a.triggered.connect
        def copy_link():
            QApplication.clipboard().setText(link.url())
Beispiel #38
0
    def __init__(self, dockwidget):
        super(QuickInsert, self).__init__(dockwidget)
        self._dockwidget = weakref.ref(dockwidget)
        # filled in by ButtonGroup subclasses
        self.actionDict = {}

        layout = QVBoxLayout()
        self.setLayout(layout)
        layout.setContentsMargins(0, 0, 0, 0)

        self.helpButton = QToolButton(
            icon=icons.get("help-contents"),
            autoRaise=True,
            clicked=lambda: userguide.show("quickinsert"))
        self.directionLabel = QLabel()
        self.direction = QComboBox()
        self.direction.addItems(['', '', ''])
        self.direction.setItemIcon(0, icons.get("go-up"))
        self.direction.setItemIcon(2, icons.get("go-down"))
        self.direction.setCurrentIndex(1)
        hor = QHBoxLayout()
        hor.setContentsMargins(0, 0, 0, 0)
        hor.addWidget(self.helpButton)
        hor.addWidget(self.directionLabel)
        hor.addWidget(self.direction)
        layout.addLayout(hor)

        self.toolbox = QToolBox(self)
        gadgets.toolboxwheeler.ToolBoxWheeler(self.toolbox)
        layout.addWidget(self.toolbox)

        for cls in (
                articulations.Articulations,
                dynamics.Dynamics,
                spanners.Spanners,
                barlines.BarLines,
        ):
            widget = cls(self)
            self.toolbox.addItem(widget, widget.icon(), '')

        app.translateUI(self)
        userguide.openWhatsThis(self)

        # restore remembered current page
        name = QSettings().value("quickinsert/current_tool", "", str)
        if name:
            for i in range(self.toolbox.count()):
                if name == self.toolbox.widget(i).__class__.__name__.lower():
                    self.toolbox.setCurrentIndex(i)
                    break
        self.toolbox.currentChanged.connect(self.slotCurrentChanged)
Beispiel #39
0
 def __init__(self, dockwidget):
     super(QuickInsert, self).__init__(dockwidget)
     self._dockwidget = weakref.ref(dockwidget)
     # filled in by ButtonGroup subclasses
     self.actionDict = {}
     
     layout = QVBoxLayout()
     self.setLayout(layout)
     layout.setContentsMargins(0, 0, 0, 0)
     
     self.helpButton = QToolButton(
         icon = icons.get("help-contents"),
         autoRaise = True,
         clicked = lambda: userguide.show("quickinsert"))
     self.directionLabel = QLabel()
     self.direction = QComboBox()
     self.direction.addItems(['', '', ''])
     self.direction.setItemIcon(0, icons.get("go-up"))
     self.direction.setItemIcon(2, icons.get("go-down"))
     self.direction.setCurrentIndex(1)
     hor = QHBoxLayout()
     hor.setContentsMargins(0, 0, 0, 0)
     hor.addWidget(self.helpButton)
     hor.addWidget(self.directionLabel)
     hor.addWidget(self.direction)
     layout.addLayout(hor)
     
     self.toolbox = QToolBox(self)
     widgets.toolboxwheeler.ToolBoxWheeler(self.toolbox)
     layout.addWidget(self.toolbox)
     
     for cls in (
             articulations.Articulations,
             dynamics.Dynamics,
             spanners.Spanners,
             barlines.BarLines,
         ):
         widget = cls(self)
         self.toolbox.addItem(widget, widget.icon(), '')
     
     app.translateUI(self)
     userguide.openWhatsThis(self)
     
     # restore remembered current page
     name = QSettings().value("quickinsert/current_tool", "", type(""))
     if name:
         for i in range(self.toolbox.count()):
             if name == self.toolbox.widget(i).__class__.__name__.lower():
                 self.toolbox.setCurrentIndex(i)
                 break
     self.toolbox.currentChanged.connect(self.slotCurrentChanged)
Beispiel #40
0
    def createActions(self, parent):
        self.view_bookmark = QAction(parent)
        self.view_bookmark.setCheckable(True)
        self.view_clear_error_marks = QAction(parent)
        self.view_clear_all_marks = QAction(parent)
        self.view_next_mark = QAction(parent)
        self.view_previous_mark = QAction(parent)

        self.view_bookmark.setShortcut(Qt.CTRL + Qt.Key_B)
        self.view_next_mark.setShortcut(Qt.ALT + Qt.Key_PageDown)
        self.view_previous_mark.setShortcut(Qt.ALT + Qt.Key_PageUp)

        self.view_bookmark.setIcon(icons.get('bookmark-new'))
        self.view_clear_all_marks.setIcon(icons.get('edit-clear'))
    def createActions(self, parent):
        self.view_bookmark = QAction(parent)
        self.view_bookmark.setCheckable(True)
        self.view_clear_error_marks = QAction(parent)
        self.view_clear_all_marks = QAction(parent)
        self.view_next_mark = QAction(parent)
        self.view_previous_mark = QAction(parent)

        self.view_bookmark.setShortcut(Qt.CTRL + Qt.Key_B)
        self.view_next_mark.setShortcut(Qt.ALT + Qt.Key_PageDown)
        self.view_previous_mark.setShortcut(Qt.ALT + Qt.Key_PageUp)

        self.view_bookmark.setIcon(icons.get('bookmark-new'))
        self.view_clear_all_marks.setIcon(icons.get('edit-clear'))
Beispiel #42
0
    def __init__(self, *args, **kwargs):
        QWidget.__init__(self, *args, **kwargs)
        layout = QGridLayout(self)
        self.setLayout(layout)

        self.addButton = QPushButton(icons.get('list-add'), '')
        self.editButton = QPushButton(icons.get('document-edit'), '')
        self.removeButton = QPushButton(icons.get('list-remove'), '')
        self.listBox = QListWidget()

        layout.setContentsMargins(1, 1, 1, 1)
        layout.setSpacing(0)
        layout.addWidget(self.listBox, 0, 0, 4, 1)
        layout.addWidget(self.addButton, 0, 1)
        layout.addWidget(self.editButton, 1, 1)
        layout.addWidget(self.removeButton, 2, 1)

        @self.addButton.clicked.connect
        def addClicked():
            item = self.createItem()
            if self.openEditor(item):
                self.addItem(item)

        @self.editButton.clicked.connect
        def editClicked():
            item = self.listBox.currentItem()
            item and self.editItem(item)

        @self.removeButton.clicked.connect
        def removeClicked():
            item = self.listBox.currentItem()
            if item:
                self.removeItem(item)

        @self.listBox.itemDoubleClicked.connect
        def itemDoubleClicked(item):
            item and self.editItem(item)

        self.listBox.model().layoutChanged.connect(self.changed)

        def updateSelection():
            selected = bool(self.listBox.currentItem())
            self.editButton.setEnabled(selected)
            self.removeButton.setEnabled(selected)

        self.changed.connect(updateSelection)
        self.listBox.itemSelectionChanged.connect(updateSelection)
        updateSelection()
        app.translateUI(self)
Beispiel #43
0
 def __init__(self, *args, **kwargs):
     QWidget.__init__(self, *args, **kwargs)
     layout = QGridLayout(self)
     self.setLayout(layout)
     
     self.addButton = QPushButton(icons.get('list-add'), '')
     self.editButton = QPushButton(icons.get('document-edit'), '')
     self.removeButton = QPushButton(icons.get('list-remove'), '')
     self.listBox = QListWidget()
     
     layout.setContentsMargins(1, 1, 1, 1)
     layout.setSpacing(0)
     layout.addWidget(self.listBox, 0, 0, 8, 1)
     layout.addWidget(self.addButton, 0, 1)
     layout.addWidget(self.editButton, 1, 1)
     layout.addWidget(self.removeButton, 2, 1)
     
     @self.addButton.clicked.connect
     def addClicked():
         item = self.createItem()
         if self.openEditor(item):
             self.addItem(item)
             
     @self.editButton.clicked.connect
     def editClicked():
         item = self.listBox.currentItem()
         item and self.editItem(item)
     
     @self.removeButton.clicked.connect
     def removeClicked():
         item = self.listBox.currentItem()
         if item:
             self.removeItem(item)
     
     @self.listBox.itemDoubleClicked.connect
     def itemDoubleClicked(item):
         item and self.editItem(item)
         
     self.listBox.model().layoutChanged.connect(self.changed)
 
     def updateSelection():
         selected = bool(self.listBox.currentItem())
         self.editButton.setEnabled(selected)
         self.removeButton.setEnabled(selected)
     
     self.changed.connect(updateSelection)
     self.listBox.itemSelectionChanged.connect(updateSelection)
     updateSelection()
     app.translateUI(self)
Beispiel #44
0
def menu_file(parent):
    m = QMenu(parent)
    m.setTitle(_("menu title", "&File"))
    m.addAction(icons.get('document-new'), _("action: new document", "&New"), file_new)
    m.addMenu(menu_file_new_from_template(m))
    m.addAction(icons.get('tools-score-wizard'), _("New Score with &Wizard..."), file_new_with_wizard)
    m.addSeparator()
    m.addAction(icons.get('document-open'), _("&Open..."), file_open)
    m.addMenu(menu_file_open_recent(m))
    m.addSeparator()
    m.addMenu(menu_file_import(m))
    m.addSeparator()
    role = QAction.QuitRole if use_osx_menu_roles() else QAction.NoRole
    m.addAction(icons.get('application-exit'), _("&Quit"), app.qApp.quit).setMenuRole(role)
    return m
Beispiel #45
0
    def __toggleMute(self):
        isMuted = not muteState()
        setMuteState(isMuted)

        self.__mute.setIcon(icons.get('Mute-48') if isMuted else icons.get('Medium Volume-48'))
        self.__mute.setToolTip('Un-mute' if isMuted else 'Mute')
        self.__mute.setStatusTip('Un-mute' if isMuted else 'Mute')

        if self.__soundtrack:  # re-applies the mute state if soundtrack already exists
            # self.__soundtrack.volume = 0 if muteState() else 100
            # play on unmute if already playing
            if self.__timer.isPlaying() and not isMuted:
                self.__soundtrack.seekAndPlay(self.__timer.beatsToSeconds(self.__timer.time))
            else:
                self.__soundtrack.stop()
    def createActions(self):
        self.doc_save = self.addAction(icons.get('document-save'), '')
        self.doc_save_as = self.addAction(icons.get('document-save-as'), '')
        self.addSeparator()
        self.doc_close = self.addAction(icons.get('document-close'), '')
        self.doc_close_others = self.addAction(icons.get('document-close'), '')
        self.addSeparator()
        self.doc_toggle_sticky = self.addAction(icons.get('pushpin'), '')
        self.doc_toggle_sticky.setCheckable(True)

        self.doc_save.triggered.connect(self.docSave)
        self.doc_save_as.triggered.connect(self.docSaveAs)
        self.doc_close.triggered.connect(self.docClose)
        self.doc_close_others.triggered.connect(self.docCloseOther)
        self.doc_toggle_sticky.triggered.connect(self.docToggleSticky)
Beispiel #47
0
    def addLinkAction(self, link):
        """Add action if on an arbitrary link"""
        m = self._menu
        a = m.addAction(icons.get("window-new"), _("Open Link in &New Window"))

        @a.triggered.connect
        def open_in_browser():
            import helpers
            helpers.openUrl(QUrl(link.url()))

        a = m.addAction(icons.get("edit-copy"), _("Copy &Link"))

        @a.triggered.connect
        def copy_link():
            QApplication.clipboard().setText(link.url())
Beispiel #48
0
    def __init__(self, subFolder=''):
        """"
        @param subFolder: make this scene list represent a "Scenes, Templates"
        folder pair in a sub-folder instead of the project root.
        """
        super(SceneList, self).__init__()

        self.__subFolder = subFolder
        self.__shotsManager = None

        main = vlayout()
        self.setLayout(main)
        belt = hlayout()

        addScene = QPushButton(icons.get('Add Image'), '')
        addScene.clicked.connect(self.__onAddScene)
        addScene.setIconSize(QSize(24, 24))
        addScene.setToolTip('Add scene')
        addScene.setStatusTip('Add scene')
        belt.addWidget(addScene)

        delScene = QPushButton(icons.get('Remove Image'), '')
        delScene.clicked.connect(self.__onDeleteScene)
        delScene.setIconSize(QSize(24, 24))
        delScene.setToolTip('Delete scene')
        delScene.setStatusTip('Delete scene')
        belt.addWidget(delScene)

        belt.addStretch(1)
        main.addLayout(belt)
        self.__model = MimeDataItemModel()
        self.view = QTreeView()
        self.view.setModel(self.__model)
        self.view.activated.connect(self.__onOpenFile)
        self.view.setEditTriggers(self.view.NoEditTriggers)
        main.addWidget(self.view)
        main.setStretch(1, 1)
        self.view.selectionModel().currentChanged.connect(
            self.__onCurrentChanged)

        self.view.setContextMenuPolicy(Qt.CustomContextMenu)
        self.view.customContextMenuRequested.connect(self.__contextMenu)
        self.contextMenu = QMenu()
        action = self.contextMenu.addAction('Show in explorer')
        action.triggered.connect(self.__showInExplorer)
        action = self.contextMenu.addAction('Create shot')
        action.triggered.connect(self.__createShot)
        self.__contextMenuItem = None
Beispiel #49
0
    def __init__(self, session, settings):
        QWidget.__init__(self)

        self._settings_ = settings
        self._session_ = session
        self.visible_files = []
        self.selected_file = None

        self.list = QListWidget()
        self.list.itemSelectionChanged.connect(self._handle_selection_)

        self.buttons_bar = QFrame()

        self.insert_button = QPushButton()
        self.insert_button.setIcon(icons.get('insert_image'))
        self.insert_button.setToolTip('Insert as image')
        self.insert_button.clicked.connect(self._do_insert_)

        self.add_files_button = QPushButton()
        self.add_files_button.setIcon(self.style().standardIcon(
            QStyle.SP_DialogOpenButton))
        self.add_files_button.setToolTip('Import images to repository')
        self.add_files_button.clicked.connect(self._open_import_)

        self.screenshot_button = QPushButton()
        self.screenshot_button.setIcon(icons.get('screenshot'))
        self.screenshot_button.setToolTip('Take screenshot')
        self.screenshot_button.clicked.connect(self.startScreenshot)

        self.delete_button = QPushButton()
        self.delete_button.setIcon(self.style().standardIcon(
            QStyle.SP_TrashIcon))
        self.delete_button.setToolTip('Delete selected images')
        self.delete_button.clicked.connect(self._delete_selection_)

        self.edit_image = QPushButton()
        self.edit_image.setToolTip('Edit image')
        self.edit_image.setIcon(icons.get('edit-image'))
        self.edit_image.clicked.connect(self._open_edit_window_)

        self.screenshot_selector = WindowRegionSelector()
        self.screenshot_selector.on_take_screenshot.connect(
            self.takeScreenshot)
        self.screenshot_selector.on_quit.connect(self.moveWindowBack)

        self._revalidate_()

        self._do_layout_()
Beispiel #50
0
def getTransposer(document, mainwindow):
    """Show a dialog and return the desired transposer.
    
    Returns None if the dialog was cancelled.
    
    """
    language = documentinfo.info(document).pitchLanguage() or 'nederlands'
    
    def readpitches(text):
        """Reads pitches from text."""
        result = []
        for pitch, octave in re.findall(r"([a-z]+)([,']*)", text):
            r = ly.pitch.pitchReader(language)(pitch)
            if r:
                result.append(ly.pitch.Pitch(*r, octave=ly.pitch.octaveToNum(octave)))
        return result
    
    def validate(text):
        """Returns whether the text contains exactly two pitches."""
        return len(readpitches(text)) == 2
    
    text = inputdialog.getText(mainwindow, _("Transpose"), _(
        "Please enter two absolute pitches, separated by a space, "
        "using the pitch name language \"{language}\"."
        ).format(language=language), icon = icons.get('tools-transpose'),
        help = transpose_help, validate = validate)
    
    if text:
        return ly.pitch.Transposer(*readpitches(text))
Beispiel #51
0
    def __init__(self, exctype, excvalue, exctb):
        super(ExceptionDialog, self).__init__()
        
        self._tbshort = ''.join(traceback.format_exception_only(exctype, excvalue))
        self._tbfull = ''.join(traceback.format_exception(exctype, excvalue, exctb))
 
        layout = QVBoxLayout()
        self.setLayout(layout)
        
        self.errorLabel = QLabel()
        layout.addWidget(self.errorLabel)
        textview = QTextBrowser()
        layout.addWidget(textview)
        textview.setText(self._tbfull)
        textview.moveCursor(QTextCursor.End)
        
        layout.addWidget(widgets.Separator())
        
        b = self.buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        b.button(QDialogButtonBox.Ok).setIcon(icons.get("tools-report-bug"))
        layout.addWidget(b)
        
        b.accepted.connect(self.accept)
        b.rejected.connect(self.reject)
        self.resize(600,300)
        app.translateUI(self)
        self.exec_()
Beispiel #52
0
 def updateActions(self):
     running = bool(self.runningJob())
     ac = self.actionCollection
     ac.engrave_preview.setEnabled(not running)
     ac.engrave_publish.setEnabled(not running)
     ac.engrave_abort.setEnabled(running)
     ac.engrave_runner.setIcon(icons.get('process-stop' if running else 'lilypond-run'))
Beispiel #53
0
    def __init__(self, path, settings = None):
        super(MainWindow, self).__init__()
        self.path = path
        self.setWindowTitle("gpuip")
        self.setWindowIcon(icons.get("pug"))
        self.setStyleSheet(stylesheet.data)
        # Start in center of the screen, covering 80%
        r = QtGui.QDesktopWidget().availableGeometry()
        self.setGeometry(r.width()*0.10, r.height() * 0.10,
                         r.width() * 0.80, r.height() * 0.80)

        self.toolbarIconSize = QtCore.QSize(32,32)
        self.interactive = False
        self.createMenuAndActions()
        self.createDockWidgets()

        # Central tab widget (main part of the gui)
        self.kernelTabWidget = QtGui.QTabWidget(self)
        self.setCentralWidget(self.kernelTabWidget)

        self.reset()

        self.settings = settings
        if self.settings:
            self.initFromSettings()
        else:
            self.new()

        self.needsBuild = True
        self.needsAllocate = True
        self.needsImport = True
Beispiel #54
0
    def __init__(self, panel):
        super(Articulations, self).__init__(panel)
        self.shorthands = QCheckBox(self)
        self.shorthands.setChecked(True)
        self.removemenu = QToolButton(self,
                                      autoRaise=True,
                                      popupMode=QToolButton.InstantPopup,
                                      icon=icons.get('edit-clear'))

        mainwindow = panel.parent().mainwindow()
        mainwindow.selectionStateChanged.connect(self.removemenu.setEnabled)
        self.removemenu.setEnabled(mainwindow.hasSelection())

        ac = documentactions.DocumentActions.instance(
            mainwindow).actionCollection
        self.removemenu.addAction(ac.tools_quick_remove_articulations)
        self.removemenu.addAction(ac.tools_quick_remove_ornaments)
        self.removemenu.addAction(ac.tools_quick_remove_instrument_scripts)

        layout = QHBoxLayout()
        layout.addWidget(self.shorthands)
        layout.addWidget(self.removemenu)
        layout.addStretch(1)

        self.layout().addLayout(layout)
        for cls in (
                ArticulationsGroup,
                OrnamentsGroup,
                SignsGroup,
                OtherGroup,
        ):
            self.layout().addWidget(cls(self))
        self.layout().addStretch(1)
        app.translateUI(self)
Beispiel #55
0
    def createActions(self, parent):
        self.import_any = QAction(parent)
        self.import_musicxml = QAction(parent)
        self.import_midi = QAction(parent)
        self.import_abc = QAction(parent)

        self.import_any.setIcon(icons.get("document-import"))
Beispiel #56
0
    def createActions(self, parent=None):
        self.help_back = QAction(parent)
        self.help_forward = QAction(parent)
        self.help_home = QAction(parent)
        self.help_print = QAction(parent)
        self.help_lilypond_doc= QAction(parent)
        self.help_lilypond_context = QAction(parent)

        self.help_back.setIcon(icons.get("go-previous"))
        self.help_forward.setIcon(icons.get("go-next"))
        self.help_home.setIcon(icons.get("go-home"))
        self.help_lilypond_doc.setIcon(icons.get("lilypond-run"))
        self.help_print.setIcon(icons.get("document-print"))

        self.help_lilypond_doc.setShortcut(QKeySequence("F9"))
        self.help_lilypond_context.setShortcut(QKeySequence("Shift+F9"))
Beispiel #57
0
    def __init__(self, panel):
        super(Spanners, self).__init__(panel)
        self.removemenu = QToolButton(self,
                                      autoRaise=True,
                                      popupMode=QToolButton.InstantPopup,
                                      icon=icons.get('edit-clear'))

        mainwindow = panel.parent().mainwindow()
        mainwindow.selectionStateChanged.connect(self.removemenu.setEnabled)
        self.removemenu.setEnabled(mainwindow.hasSelection())

        ac = documentactions.DocumentActions.instance(
            mainwindow).actionCollection
        self.removemenu.addAction(ac.tools_quick_remove_slurs)

        layout = QHBoxLayout()
        layout.addWidget(self.removemenu)
        layout.addStretch(1)

        self.layout().addLayout(layout)
        self.layout().addWidget(ArpeggioGroup(self))
        self.layout().addWidget(GlissandoGroup(self))
        self.layout().addWidget(SpannerGroup(self))
        self.layout().addWidget(GraceGroup(self))
        self.layout().addStretch(1)