Exemple #1
0
 def check_valid_regex(self):
     regex = util.kurl_to_path(self.general_page.kcfg_TagRegex.text())
     try:
         re.compile(regex)
     except re.error, e:
         msg = 'The introduced regular expression is not valid:\n%s' % e
         kdeui.KMessageBox.error(self, msg, 'Invalid regular expression')
         return False
Exemple #2
0
    def slot_set_url(self, url):
        if isinstance(url, kdecore.KUrl):
            # We can only store QStrings.
            url = url.pathOrUrl()

        directory = os.path.expanduser(util.kurl_to_path(url))

        if os.path.isdir(directory):
            urls = self.urls()
            urls.removeAll(url)
            urls.prepend(url)
            self.setUrls(urls, kio.KUrlComboBox.RemoveBottom)

        self.emit(QtCore.SIGNAL('new_directory_selected'), directory)
Exemple #3
0
 def tag_regex(self):
     return util.kurl_to_path(self._tag_regex_value)
Exemple #4
0
def main():
    def translate(text):
        if sys.version_info.major >= 3:
            return kdecore.ki18n(text.encode("utf-8"))
        else:
            return kdecore.ki18n(text)
    
    _ = translate
    emptyloc = kdecore.KLocalizedString()

    about_data = kdecore.KAboutData(
        minirok.__appname__,
        "", # catalog name
        _(minirok.__progname__),
        minirok.__version__,
        _(minirok.__description__),
        kdecore.KAboutData.License_Custom,
        _(minirok.__copyright__),
        emptyloc, # extra text
        minirok.__homepage__,
        minirok.__bts__)

    about_data.setLicenseText(_(minirok.__license__))
    about_data.setCustomAuthorText(
        emptyloc,
        _('Please report bugs to <a href="%s">%s</a>.<br>'
          'See README.Bugs for instructions.' % (
              minirok.__bts__, minirok.__bts__)))

    for name, task, email in minirok.__authors__:
        about_data.addAuthor(_(name), _(task), email)

    for name, task, email, webpage in minirok.__thanksto__:
        about_data.addCredit(_(name), _(task), email, webpage)

    options = kdecore.KCmdLineOptions()
    options.add('a')
    options.add('append',
                _('Try to append files to an existing Minirok instance'))
    options.add('+[files]', _('Files to load into the playlist'))

    kdecore.KCmdLineArgs.init(sys.argv, about_data)
    kdecore.KCmdLineArgs.addCmdLineOptions(options)

    args = kdecore.KCmdLineArgs.parsedArgs()
    count = args.count()
    files = []

    if count > 0:
        from minirok import util
        for i in range(count):
            files.append(util.kurl_to_path(args.url(i)))
        if (args.isSet('append') and
                append_to_remote_minirok_successful(files)):
            sys.exit(0)

    ##

    # These imports happen here rather than at the top level because if gst
    # gets imported before the above KCmdLineArgs.init() call, it steals our
    # --help option
    from minirok import engine, main_window as mw
    if minirok._has_scrobble == True:
        from minirok import scrobble

    minirok.Globals.engine = engine.Engine()
    application = kdeui.KApplication()
    main_window = mw.MainWindow()
    if minirok._has_scrobble == True:
        scrobbler = scrobble.Scrobbler()
        scrobbler.start()

    if minirok._has_dbus:
        import dbus
        import dbus.service
        import dbus.mainloop.qt
        from minirok import dbusface

        dbus.mainloop.qt.DBusQtMainLoop(set_as_default=True)
        name = dbus.service.BusName('org.kde.minirok', dbus.SessionBus())
        player = dbusface.Player()

    if files:
        minirok.Globals.playlist.add_files_untrusted(files, clear_playlist=True)

    ##

    if main_window.canBeRestored(1):
        main_window.restore(1, False)  # False: do not force show().
    else:
        main_window.show()

    application.exec_()