Example #1
0
 def __init__(self, mainwin, pdfs):
     KDialog.__init__(self, mainwin)
     self.mainwin = mainwin
     self.setAttribute(Qt.WA_DeleteOnClose)
     self.setButtons(KDialog.ButtonCode(
         KDialog.User1 | KDialog.Ok | KDialog.Cancel))
     self.setButtonGuiItem(KDialog.Ok, KStandardGuiItem.print_())
     self.setButtonIcon(KDialog.User1, KIcon("edit-select-all"))
     self.setButtonText(KDialog.User1, i18n("Select all"))
     self.setCaption(i18n("Print documents"))
     b = KVBox(self)
     b.setSpacing(4)
     QLabel(i18n("Please select the files you want to print:"), b)
     fileList = QListWidget(b)
     fileList.setIconSize(QSize(22, 22))
     fileList.setWhatsThis(i18n(
         "These are the PDF documents that are up-to-date (i.e. newer than "
         "the LilyPond source document). "
         "Check the documents you want to send to the printer."))
     
     for pdf in pdfs:
         i = QListWidgetItem(KIcon("application-pdf"), os.path.basename(pdf),
             fileList)
         i.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable |
             Qt.ItemIsUserCheckable)
         i.setCheckState(Qt.Unchecked)
     
     fileList.item(0).setCheckState(Qt.Checked)
     self.fileList = fileList
     self.setMainWidget(b)
     self.resize(350, 200)
     self.pdfs = pdfs
     self.user1Clicked.connect(self.selectAll)
Example #2
0
 def __init__(self, mainwin):
     self.mainwin = mainwin
     KDialog.__init__(self, mainwin)
     self.setCaption(i18n("Run LilyPond"))
     self.setButtons(KDialog.ButtonCode(
         KDialog.Help | KDialog.Ok | KDialog.Cancel ))
     self.setButtonText(KDialog.Ok, i18n("Run LilyPond"))
     self.setButtonIcon(KDialog.Ok, KIcon("run-lilypond"))
     self.setHelp("running")
     
     layout = QVBoxLayout(self.mainWidget())
     
     layout.addWidget(QLabel(i18n(
         "Select which LilyPond version you want to run:")))
         
     self.lilypond = QListWidget()
     self.lilypond.setIconSize(QSize(22, 22))
     self.lilypond.setSpacing(4)
     layout.addWidget(self.lilypond)
     
     self.preview = QCheckBox(i18n(
         "Run LilyPond in preview mode (with Point and Click)"))
     layout.addWidget(self.preview)
     
     self.verbose = QCheckBox(i18n("Run LilyPond with verbose output"))
     layout.addWidget(self.verbose)
Example #3
0
    def __init__(self, parent):
        KDialog.__init__(self, parent)
        self.setCaption(i18n("Transpose"))
        self.setHelp("transpose")
        self.setButtons(KDialog.ButtonCode(KDialog.Ok | KDialog.Cancel | KDialog.Help))
        self.language = ""
        self.initialPitchSet = False
        w = self.mainWidget()
        w.setLayout(QtGui.QGridLayout())
        l = QtGui.QLabel(i18n("Please enter a start pitch and a destination pitch:"))
        w.layout().addWidget(l, 0, 0, 1, 4)
        self.fromPitch = QtGui.QComboBox()
        self.toPitch = QtGui.QComboBox()
        l = QtGui.QLabel(i18n("Transpose from:"))
        l.setBuddy(self.fromPitch)
        w.layout().addWidget(l, 1, 0, QtCore.Qt.AlignRight)
        w.layout().addWidget(self.fromPitch, 1, 1)
        l = QtGui.QLabel(i18n("to:"))
        l.setBuddy(self.toPitch)
        w.layout().addWidget(l, 1, 2, QtCore.Qt.AlignRight)
        w.layout().addWidget(self.toPitch, 1, 3)

        for c in self.fromPitch, self.toPitch:
            c.setEditable(True)
            c.setInsertPolicy(QtGui.QComboBox.NoInsert)
            c.setCompleter(None)
        self.fromPitch.setModel(self.toPitch.model())
Example #4
0
    def __init__(self, parent):
        KDialog.__init__(self, parent)
        self.setButtons(KDialog.ButtonCode(KDialog.Ok | KDialog.Cancel | KDialog.Help | KDialog.User1))
        self.setCaption(i18n("LilyPond"))
        self.setHelp("settings-paths-lilypond")
        self.setButtonText(KDialog.User1, i18n("Download..."))
        self.setButtonIcon(KDialog.User1, KIcon("download"))
        self.setButtonToolTip(KDialog.User1, i18n("Download new binary LilyPond releases."))
        self.user1Clicked.connect(self.downloadLilyPond)
        layout = QGridLayout(self.mainWidget())

        l = QLabel(i18n("LilyPond Command:"))
        self.lilypond = KUrlRequester()
        l.setBuddy(self.lilypond)
        self.lilypond.lineEdit().setToolTip(i18n("Name or full path of the LilyPond program."))
        self.lilypond.fileDialog().setCaption(i18n("LilyPond Command"))
        layout.addWidget(l, 0, 0, 1, 2)
        layout.addWidget(self.lilypond, 1, 0, 1, 2)

        self.commands = {}
        row = 2
        for name, description in LilyPondInfo.commandNames():
            l = QLabel(description)
            e = self.commands[name] = QLineEdit()
            l.setBuddy(e)
            layout.addWidget(l, row, 0, Qt.AlignRight)
            layout.addWidget(e, row, 1)
            row += 1
        self.default = QCheckBox(i18n("Set as default"))
        layout.addWidget(self.default, row, 1)
        self.auto = QCheckBox(i18n("Include in automatic version selection"))
        layout.addWidget(self.auto, row + 1, 1)
Example #5
0
 def __init__(self, manager):
     KDialog.__init__(self, manager.mainwin)
     self.sm = manager
     self.setCaption(i18n("Manage Sessions"))
     self.setButtons(KDialog.ButtonCode(KDialog.Help | KDialog.Close))
     self.setHelp("sessions")
     self.sessions = SessionList(self)
     self.setMainWidget(self.sessions)
     self.sm.sessionAdded.connect(self.load)
Example #6
0
 def __init__(self, parent):
     KDialog.__init__(self, parent)
     self.setCaption(i18n("PDF Preview"))
     self.setButtons(KDialog.ButtonCode(KDialog.Close))
     self.preview = LilyPreviewWidget(self)
     self.setMainWidget(self.preview)
     self.setMinimumSize(QSize(400, 300))
     self.loadSettings()
     self.finished.connect(self.slotFinished)
Example #7
0
 def __init__(self, parent, item):
     KDialog.__init__(self,parent)
     self.setCaption(i18n("Item editor"))
     self.setButtons(KDialog.ButtonCode(KDialog.Ok | KDialog.Cancel|KDialog.Apply))
     
     w = ItemEditorWidget(self)
     self.setMainWidget(w)
     self.connect(self, SIGNAL("applyClicked()"), self.configAccepted)
     self.connect(self, SIGNAL("okClicked()"), self.configAccepted)
     self.connect(w, SIGNAL("changed(bool)"), self, SLOT("enableButtonApply(bool)"))
         
     self.enableButtonApply(False);
     
     self.item = item
     self.updateUi()
Example #8
0
 def __init__(self, mainwin):
     KDialog.__init__(self, mainwin)
     ShortcutClient.__init__(self, mainwin.charSelectShortcuts)
     self.mainwin = mainwin
     self.setButtons(KDialog.ButtonCode(
         KDialog.Help | KDialog.Apply | KDialog.Ok | KDialog.Close))
     self.setCaption(i18n("Special Characters"))
     self.setHelp("charselect")
     
     # trick key button in the DialogButtonBox
     self.keySelector = key = KKeySequenceWidget()
     key.layout().setContentsMargins(20, 0, 0, 0)
     self.findChild(QDialogButtonBox).layout().insertWidget(1, key)
     
     self.charSelect = KCharSelect(None)
     self.setMainWidget(self.charSelect)
     self.charSelect.charSelected.connect(self.insertText)
     self.charSelect.currentCharChanged.connect(self.slotCurrentCharChanged)
     self.keySelector.keySequenceChanged.connect(self.slotKeySequenceChanged)
     self.okClicked.connect(self.insertCurrentChar)
     self.applyClicked.connect(self.insertCurrentChar)
     self.finished.connect(self.saveSettings)
     self.loadSettings()
Example #9
0
    def __init__(self, mainWindow, renderThread, pluginConfig=None):
        KDialog.__init__(self, mainWindow)
        self.renderThread = renderThread

        self.databaseUrl = None
        if pluginConfig:
            self.databaseUrl = util.readConfigString(self.pluginConfig,
                "Update database url", None)

        if not self.databaseUrl:
            self.databaseUrl = unicode('sqlite:///'
                + util.getLocalData('dictionaries.db'))

        self.renderThread.setObject(DictionaryInfo,
            databaseUrl=self.databaseUrl)

        self.setCaption(i18n("Install/Update Dictionaries"))
        self.setButtons(KDialog.ButtonCode(KDialog.Close))
        self.enableButton(KDialog.Cancel, False)

        # TODO can we defer the creation of the update widget until the dialog is shown?
        self.updateWidget = UpdateWidget(mainWindow, renderThread, pluginConfig)
        self.connect(self.updateWidget, SIGNAL("working(bool)"),
            self.slotUpdateWorking)
        self.setMainWidget(self.updateWidget)

        self.connect(self, SIGNAL("finished()"), self.slotFinish)

        self.initialised = False

        self.connect(self.renderThread, SIGNAL("jobFinished"),
            self.contentRendered)
        self.connect(self.renderThread, SIGNAL("jobErrorneous"),
            self.renderingFailed)

        self.actionCollection = KActionCollection(self)
        self.setupActions()
Example #10
0
    def __init__(self, info):
        """info is a LilyPondInfoDialog (see settings.py)"""
        KDialog.__init__(self, info)
        self.info = info
        
        # local attributes
        self.job = None
        self.unpackJob = None
        
        self.setButtons(KDialog.ButtonCode(
            KDialog.Help | KDialog.Details | KDialog.Ok | KDialog.Cancel))
        layout = QGridLayout(self.mainWidget())
        
        self.setButtonText(KDialog.Ok, i18n("Install"))
        self.setButtonIcon(KDialog.Ok, KIcon("download"))
        self.setCaption(i18n("Download LilyPond"))
        self.setHelp("download-lilypond")
        
        l = QLabel(i18n(
            "With this tool you can download packaged binary releases "
            "of LilyPond for your operating system."))
        l.setWordWrap(True)
        layout.addWidget(l, 0, 0, 1, 2)
        
        v = self.lilyVersion = QComboBox()
        v.currentIndexChanged.connect(self.selectVersion, Qt.QueuedConnection)
        v.setToolTip(i18n(
            "Select the LilyPond version you want to download."))
        l = QLabel(i18n("Version:"))
        l.setBuddy(v)
        layout.addWidget(l, 1, 0)
        layout.addWidget(v, 1, 1)
        
        d = self.installDest = KUrlRequester()
        d.setMode(KFile.Mode(KFile.Directory | KFile.LocalOnly))
        d.setPath(config().readPathEntry(
            'lilypond install path', os.path.expanduser('~/lilypond_bin/')))
        d.setToolTip(i18n(
            "Select a writable directory you want to install LilyPond to.\n"
            "(A version-numbered directory will be created in this directory.)"))
        l = QLabel(i18n("Install into:"))
        l.setBuddy(d)
        layout.addWidget(l, 2, 0)
        layout.addWidget(d, 2, 1)
        
        s = self.status = QLabel()
        layout.addWidget(s, 3, 0, 1, 2)
        
        p = self.progress = QProgressBar()
        layout.addWidget(p, 4, 0, 1, 2)
        
        details = QGroupBox(i18n("Details"))
        layout.addWidget(details, 5, 0, 1, 2)
        layout = QGridLayout()
        details.setLayout(layout)

        b = self.baseUrl = QComboBox()
        b.setEditable(True)
        b.setToolTip(i18n(
            "The website where LilyPond binaries can be downloaded."))
        b.addItems(['http://download.linuxaudio.org/lilypond/binaries/'])
        b.setCurrentIndex(0)
        
        l = QLabel(i18n("Download from:"))
        l.setBuddy(b)
        layout.addWidget(l, 0, 0)
        layout.addWidget(b, 0, 1)
        
        m = self.machineType = QComboBox()
        items = [
            'linux-x86',
            'linux-64',
            'linux-ppc',
            'freebsd-x86',
            'freebsd-64',
            'darwin-x86',
            'darwin-ppc',
            ]
        m.addItems(items)

        l = QLabel(i18n("Machine type:"))
        l.setBuddy(m)
        layout.addWidget(l, 1, 0)
        layout.addWidget(m, 1, 1)
        
        u = self.packageUrl = KUrlRequester()
        u.setToolTip(i18n(
            "This is the URL to the package that will be downloaded and "
            "installed.\n"
            "You can also browse to other places to select a LilyPond package."))
        l = QLabel(i18n("Package Url:"))
        l.setBuddy(u)
        layout.addWidget(l, 2, 0)
        layout.addWidget(u, 2, 1)
        
        self.setDetailsWidget(details)
        
        # default for machine
        platform, machine = os.uname()[0::4]
        if '64' in machine:
            machine = '64'
        elif '86' in machine:
            machine = 'x86'
        elif 'ower' in machine or 'ppc' in machine:
            machine = 'ppc'
        mtype = platform.lower() + '-' + machine
        if mtype in items:
            m.setCurrentIndex(items.index(mtype))
        else:
            self.setDetailsWidgetVisible(True)
        m.currentIndexChanged.connect(self.downloadVersions)
        self.downloadVersions()
Example #11
0
    def __init__(self, mainwin):
        KDialog.__init__(self, mainwin)
        self.jobs = []
        self.mainwin = mainwin
        self.setButtons(KDialog.ButtonCode(
            KDialog.Try | KDialog.Help |
            KDialog.Details | KDialog.Reset |
            KDialog.Ok | KDialog.Cancel))
        self.setButtonIcon(KDialog.Try, KIcon("run-lilypond"))
        self.setCaption(i18n("Create blank staff paper"))
        self.setHelp("blankpaper")
        self.setDefaultButton(KDialog.Ok)

        layout = QGridLayout(self.mainWidget())
        self.typeChooser = QComboBox()
        self.stack = QStackedWidget()
        StackFader(self.stack)
        paperSettings = QWidget(self)
        paperSettings.setLayout(QHBoxLayout())
        self.actionChooser = QComboBox(self)
        layout.addWidget(self.typeChooser, 0, 1)
        layout.addWidget(self.stack, 1, 0, 1, 3)
        layout.addWidget(self.actionChooser, 2, 1)
        l = QLabel(i18n("Type:"))
        l.setBuddy(self.typeChooser)
        layout.addWidget(l, 0, 0, Qt.AlignRight)
        l = QLabel(i18n("Action:"))
        l.setBuddy(self.actionChooser)
        layout.addWidget(l, 2, 0, Qt.AlignRight)
        
        # tool tips
        self.typeChooser.setToolTip(i18n(
            "Choose what kind of empty staves you want to create."))
        self.actionChooser.setToolTip(i18n(
            "Choose which action happens when clicking \"Ok\"."))
        self.setButtonToolTip(KDialog.Try, i18n(
            "Preview the empty staff paper."))
        self.setButtonToolTip(KDialog.Details, i18n(
            "Click to see more settings."))
        
        # paper stuff
        paper = QGroupBox(i18n("Paper"))
        paperSettings.layout().addWidget(paper)
        settings = QGroupBox(i18n("Settings"))
        paperSettings.layout().addWidget(settings)
        
        paper.setLayout(QGridLayout())
        
        self.paperSize = QComboBox()
        l = QLabel(i18n("Paper size:"))
        l.setBuddy(self.paperSize)
        paper.layout().addWidget(l, 0, 0, Qt.AlignRight)
        paper.layout().addWidget(self.paperSize, 0, 1)
        self.paperSize.addItem(i18n("Default"))
        self.paperSize.addItems(ly.paperSizes)

        self.staffSize = QSpinBox()
        l = QLabel(i18n("Staff Size:"))
        l.setBuddy(self.staffSize)
        paper.layout().addWidget(l, 1, 0, Qt.AlignRight)
        paper.layout().addWidget(self.staffSize, 1, 1)
        self.staffSize.setRange(8, 40)
        
        self.pageCount = QSpinBox()
        l = QLabel(i18n("Page count:"))
        l.setBuddy(self.pageCount)
        paper.layout().addWidget(l, 2, 0, Qt.AlignRight)
        paper.layout().addWidget(self.pageCount, 2, 1)
        self.pageCount.setRange(1, 1000)
        
        self.removeTagline = QCheckBox(i18n("Remove default tagline"))
        paper.layout().addWidget(self.removeTagline, 3, 0, 1, 2)
        
        settings.setLayout(QGridLayout())
        
        self.barLines = QCheckBox(i18n("Print Bar Lines"))
        self.barsPerLine = QSpinBox()
        l = QLabel(i18n("Bars per line:"))
        l.setBuddy(self.barsPerLine)
        settings.layout().addWidget(self.barLines, 0, 0, 1, 2)
        settings.layout().addWidget(l, 1, 0, Qt.AlignRight)
        settings.layout().addWidget(self.barsPerLine, 1, 1)
        self.barsPerLine.setRange(1, 20)
        
        self.pageNumbers = QCheckBox(i18n("Print Page Numbers"))
        self.pageNumStart = QSpinBox()
        l = QLabel(i18n("Start with:"))
        l.setBuddy(self.pageNumStart)
        settings.layout().addWidget(self.pageNumbers, 2, 0, 1, 2)
        settings.layout().addWidget(l, 3, 0, Qt.AlignRight)
        settings.layout().addWidget(self.pageNumStart, 3, 1)
        self.barLines.toggled.connect(self.barsPerLine.setEnabled)
        self.pageNumbers.toggled.connect(self.pageNumStart.setEnabled)
        
        # types
        self.typeWidgets = [
            SingleStaff(self),
            PianoStaff(self),
            OrganStaff(self),
            ChoirStaff(self),
            CustomStaff(self),
            ]
        for widget in self.typeWidgets:
            self.stack.addWidget(widget)
            self.typeChooser.addItem(widget.name())
        self.typeChooser.currentIndexChanged.connect(lambda index:
            self.stack.setCurrentWidget(self.typeWidgets[index]))

        self.actors = [
            PrintPDF,
            SavePDF,
            OpenPDF,
            CopyToEditor,
            ]
        for actor in self.actors:
            self.actionChooser.addItem(actor.name())
        
        self.setDetailsWidget(paperSettings)
        # cleanup on exit
        mainwin.aboutToClose.connect(self.cleanup)
        # buttons
        self.resetClicked.connect(self.default)
        self.tryClicked.connect(self.showPreview)
        self.setInitialSize(QSize(400, 240))
        self.default()
        self.loadSettings()
Example #12
0
    def __init__(self, mainwin):
        KDialog.__init__(self, mainwin)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setCaption(i18n("Rumor Settings"))
        self.setButtons(KDialog.ButtonCode(
            KDialog.Ok | KDialog.Cancel | KDialog.Help))
        self.setHelp("rumor")

        layout = QGridLayout(self.mainWidget())
        # MIDI input and output.
        # Get the list of available OSS and ALSA devices
        oslist = [('oss:{0}'.format(i), i18n("OSS device %1", i))
            for i in range(getOSSnrMIDIs())]
        i = oslist + parseAconnect('i') + [("keyboard", i18n("Keyboard"))]
        o = oslist + parseAconnect('o')
        self.ilist, ititles = map(list, zip(*i))
        self.olist, otitles = map(list, zip(*o))

        # input
        l = QLabel(i18n("MIDI input:"))
        layout.addWidget(l, 1, 0)
        self.ibut = QComboBox()
        self.ibut.addItems(ititles)
        self.ibut.setToolTip(i18n("MIDI input to use. Choose 'Keyboard' if "
            "you want to play on the keyboard of your computer."))
        layout.addWidget(self.ibut, 1, 1)
        l.setBuddy(self.ibut)
        
        # output
        l = QLabel(i18n("MIDI output:"))
        layout.addWidget(l, 2, 0)
        self.obut = QComboBox()
        self.obut.addItems(otitles)
        self.obut.setToolTip(i18n("MIDI output to use."))
        layout.addWidget(self.obut, 2, 1)
        l.setBuddy(self.obut)
        
        # Language
        l = QLabel(i18n("Language:"))
        layout.addWidget(l, 3, 0)
        self.lang = QComboBox()
        self.lang.addItems((
            AUTO(), 'ne', 'en', 'en-short', 'de', 'no', 'sv', 'it', 'ca', 'es'))
        self.lang.setToolTip(i18n("The LilyPond language you want Rumor to "
            "output the pitches in."))
        layout.addWidget(self.lang, 3, 1)
        l.setBuddy(self.lang)

        hb = QHBoxLayout()
        layout.addLayout(hb, 4, 0, 1, 2)
        # explicit durations
        self.explDur = QCheckBox(i18n("Explicit durations"))
        self.explDur.setToolTip(i18n(
            "Add a duration after every note, even if it is the same as the "
            "preceding note."))
        hb.addWidget(self.explDur)

        # absolute pitches
        self.absPitches = QCheckBox(i18n("Absolute pitch"))
        self.absPitches.setToolTip(i18n(
            "Use absolute pitches instead of relative."))
        hb.addWidget(self.absPitches)

        hb = QHBoxLayout()
        layout.addLayout(hb, 5, 0, 1, 2)
        # No Barlines
        self.noBar = QCheckBox(i18n("No barlines"))
        self.noBar.setToolTip(i18n(
            "Filter the barlines out of Rumor's output."))
        hb.addWidget(self.noBar)

        # No dots
        self.noDots = QCheckBox(i18n("No dots"))
        self.noDots.setToolTip(i18n(
            "Do not use dotted notes, but ties instead."))
        hb.addWidget(self.noDots)

        # Legato
        self.legato = QCheckBox(i18n("Legato"))
        self.legato.setToolTip(i18n("Do not use rests, but give all notes "
            "the maximum length."))
        hb.addWidget(self.legato)

        # Strip rests
        self.stripRests = QCheckBox(i18n("Strip rests"))
        self.stripRests.setToolTip(i18n(
            "Strip leading and trialing rests from output."))
        hb.addWidget(self.stripRests)

        layout.addWidget(QLabel(i18n(
            "Guile scripts to load:")), 6, 0, 1, 2)

        # Guile scripts listview
        self.scripts = QTreeWidget()
        self.scripts.setRootIsDecorated(False)
        self.scripts.setHeaderLabels((i18n("Name"), i18n("Description")))
        self.scripts.setToolTip(i18n(
            "Here you can select which Guile scripts you want Rumor to load. "
            "Check \"What's this\" for more information."))
        localRumorDir = "~/.kde/share/apps/frescobaldi/rumor/"
        self.scripts.setWhatsThis(i18n(
            "Here you can select which Guile scripts you want Rumor to load. "
            "You can add your own scripts by putting them in %1. "
            "If the first line of your script starts with a semicolon (;) "
            "that line will be shown as description.", localRumorDir))
        layout.addWidget(self.scripts, 7, 0, 1, 2)
        
        self.loadSettings()
Example #13
0
    def __init__(self, parent, updatedFiles, warnpreview):
        KDialog.__init__(self, parent)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setButtons(KDialog.ButtonCode(KDialog.Ok | KDialog.Cancel))
        self.setCaption(i18n("Email documents"))
        self.showButtonSeparator(True)
        b = KVBox(self)
        b.setSpacing(4)
        QLabel(i18n("Please select the files you want to send:"), b)
        fileList = QListWidget(b)
        fileList.setIconSize(QSize(22, 22))
        fileList.setWhatsThis(i18n(
            "These are the files that are up-to-date (i.e. newer than "
            "the LilyPond source document). Also LilyPond files included "
            "by the source document are shown."))
        
        lyFiles = ly.parse.findIncludeFiles(updatedFiles.lyfile,
            config("preferences").readPathEntry("lilypond include path", []))
        pdfFiles = updatedFiles("pdf")
        midiFiles = updatedFiles("mid*")
        
        if warnpreview and pdfFiles:
            QLabel(i18np(
                "Note: this PDF file has been created with "
                "embedded point-and-click URLs (preview mode), which "
                "increases the file size dramatically. "
                "Please consider to rebuild the file in publish mode, "
                "because then the PDF file is much smaller.",
                "Note: these PDF files have been created with "
                "embedded point-and-click URLs (preview mode), which "
                "increases the file size dramatically. "
                "Please consider to rebuild the files in publish mode, "
                "because then the PDF files are much smaller.",
                len(pdfFiles)), b).setWordWrap(True)
        
        if not pdfFiles and not midiFiles:
            QLabel(i18n(
                "Note: If there are no PDF and no MIDI files, you "
                "probably need to run LilyPond to update those files, "
                "before sending the e-mail."),
                b).setWordWrap(True)
            
        self.fileList = fileList
        self.setMainWidget(b)
        self.resize(450, 300)
        
        basedir = os.path.dirname(updatedFiles.lyfile)
        exts = config("general").readEntry("email_extensions", [".pdf"])
        
        def item(icon, fileName):
            """ Add item to the fileList list widget. """
            directory, name = os.path.split(fileName)
            if directory != basedir:
                name += " ({0})".format(os.path.normpath(directory))
            i = QListWidgetItem(KIcon(icon), name, fileList)
            i.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable)
            i.ext = os.path.splitext(fileName)[1]
            i.url = KUrl.fromPath(fileName).url()
            i.setCheckState(Qt.Checked if i.ext in exts else Qt.Unchecked)

        # insert the files
        for lyfile in lyFiles:
            item("text-x-lilypond", lyfile)
        for pdf in pdfFiles:
            item("application-pdf", pdf)
        for midi in midiFiles:
            item("audio-midi", midi)
Example #14
0
    def __init__(self, manager):
        self.manager = manager
        KDialog.__init__(self, manager.mainwin)
        self.setCaption(i18n("Expansion Manager"))
        self.setButtons(KDialog.ButtonCode(
            KDialog.Help |
            KDialog.Ok | KDialog.Close | KDialog.User1 | KDialog.User2 ))
        self.setButtonGuiItem(KDialog.User1, KStandardGuiItem.remove())
        self.setButtonGuiItem(KDialog.User2, KStandardGuiItem.add())
        self.setHelp("expand")
        
        layout = QVBoxLayout(self.mainWidget())
        layout.setContentsMargins(0, 0, 0, 0)
        
        search = KTreeWidgetSearchLine()
        search.setClickMessage(i18n("Search..."))
        layout.addWidget(search)
        
        splitter = QSplitter()
        splitter.setOrientation(Qt.Vertical)
        layout.addWidget(splitter)

        tree = QTreeWidget()
        tree.setColumnCount(3)
        tree.setHeaderLabels((i18n("Name"), i18n("Description"), i18n("Shortcut")))
        tree.setRootIsDecorated(False)
        tree.setAllColumnsShowFocus(True)
        search.setTreeWidget(tree)
        splitter.addWidget(tree)
        
        box = KVBox()
        splitter.addWidget(box)
        
        key = KKeySequenceWidget(box)
        key.layout().setContentsMargins(0, 0, 0, 0)
        key.layout().insertStretch(0, 1)
        key.setEnabled(False)
        
        edit = QTextEdit(box)
        edit.setAcceptRichText(False)
        edit.setStyleSheet("QTextEdit { font-family: monospace; }")
        edit.item = None
        edit.dirty = False
        ExpandHighlighter(edit.document())
        
        # whats this etc.
        tree.setWhatsThis(i18n(
            "This is the list of defined expansions.\n\n"
            "Click on a row to see or change the associated text. "
            "Doubleclick a shortcut or its description to change it. "
            "You can also press F2 to edit the current shortcut.\n\n"
            "Use the buttons below to add or remove expansions.\n\n"
            "There are two ways to use the expansion: either type the "
            "shortcut in the text and then call the Expand function, or "
            "just call the Expand function (default shortcut: Ctrl+.), "
            "choose the expansion from the list and press Enter or click Ok."
            ))
            
        edit.setWhatsThis(
            "<html><head><style type='text/css'>"
            "td.short {{ font-family: monospace; font-weight: bold; }}"
            "</style></head><body>"
            "<p>{0}</p><table border=0 width=300 cellspacing=2><tbody>"
            "<tr><td class=short align=center>(|)</td><td>{1}</td></tr>"
            "<tr><td class=short align=center>@</td><td>{2}</td></tr>"
            "</tbody></table></body></html>".format(
            i18n("This is the text associated with the selected shortcut. "
                 "Some characters have special meaning:"),
            i18n("Place the cursor on this spot."),
            i18n("Translate the following pitch."),
            ))
        
        self.searchLine = search
        self.treeWidget = tree
        self.key = key
        self.edit = edit
        
        self.restoreDialogSize(config())
        
        # load the expansions
        for name in sorted(self.manager.expansionsList()):
            self.createItem(name, self.manager.description(name))

        tree.sortByColumn(1, Qt.AscendingOrder)
        tree.setSortingEnabled(True)
        tree.resizeColumnToContents(1)
        
        self.user1Clicked.connect(self.removeItem)
        self.user2Clicked.connect(self.addItem)
        edit.textChanged.connect(self.editChanged)
        search.textChanged.connect(self.checkMatch)
        tree.itemSelectionChanged.connect(self.updateSelection)
        tree.itemChanged.connect(self.itemChanged, Qt.QueuedConnection)
        key.keySequenceChanged.connect(self.keySequenceChanged)