コード例 #1
0
ファイル: controller.py プロジェクト: travnick/gpodder
    def __init__(self, args, gpodder_core, dbus_bus_name):
        QmlCommonQtPodder.__init__(self, args, gpodder_core, dbus_bus_name)

        self.controller = Controller(self)
        self.media_buttons_handler = helper.MediaButtonsHandler()
        self.tracker_miner_config = helper.TrackerMinerConfig()
        self.podcast_model = qml.model.gPodderPodcastListModel()
        self.episode_model = desktopModel.gPodderEpisodeListModel(self.config)
        self.last_episode = None

        # A dictionary of episodes that are currently active
        # in some way (i.e. playing back or downloading)
        self.active_episode_wrappers = {}

        # Add the cover art image provider
        self.cover_provider = images.LocalCachedImageProvider()

        # TODO: clear it, only for debug
        try:
            self._create_qml_gui('MainWindow.qml')

            # Proxy to the "main" QML mainWindow
            # for direct access to Qt Properties
            self.main = QObjectProxy(self.mainWindow.object)

        except AttributeError as ex:
            print "main: ", type(ex)
            print ex.args
            return

        self.main.podcastModel = self._create_model_filter(self.podcast_model)
        self.main.episodeModel = self._create_model_filter(self.episode_model)

        self.mainWindow.setVisible(True)

        self.do_start_progress.connect(self.on_start_progress)
        self.do_end_progress.connect(self.on_end_progress)
        self.do_show_message.connect(self.on_show_message)

        podcasts = self.load_podcasts()

        self.resumable_episodes = None
        self.do_offer_download_resume.connect(self.on_offer_download_resume)
        util.run_in_background(self.find_partial_downloads(podcasts))
コード例 #2
0
ファイル: controller.py プロジェクト: travnick/gpodder
class qtPodder(QmlCommonQtPodder):
    def __init__(self, args, gpodder_core, dbus_bus_name):
        QmlCommonQtPodder.__init__(self, args, gpodder_core, dbus_bus_name)

        self.controller = Controller(self)
        self.media_buttons_handler = helper.MediaButtonsHandler()
        self.tracker_miner_config = helper.TrackerMinerConfig()
        self.podcast_model = qml.model.gPodderPodcastListModel()
        self.episode_model = desktopModel.gPodderEpisodeListModel(self.config)
        self.last_episode = None

        # A dictionary of episodes that are currently active
        # in some way (i.e. playing back or downloading)
        self.active_episode_wrappers = {}

        # Add the cover art image provider
        self.cover_provider = images.LocalCachedImageProvider()

        # TODO: clear it, only for debug
        try:
            self._create_qml_gui('MainWindow.qml')

            # Proxy to the "main" QML mainWindow
            # for direct access to Qt Properties
            self.main = QObjectProxy(self.mainWindow.object)

        except AttributeError as ex:
            print "main: ", type(ex)
            print ex.args
            return

        self.main.podcastModel = self._create_model_filter(self.podcast_model)
        self.main.episodeModel = self._create_model_filter(self.episode_model)

        self.mainWindow.setVisible(True)

        self.do_start_progress.connect(self.on_start_progress)
        self.do_end_progress.connect(self.on_end_progress)
        self.do_show_message.connect(self.on_show_message)

        podcasts = self.load_podcasts()

        self.resumable_episodes = None
        self.do_offer_download_resume.connect(self.on_offer_download_resume)
        util.run_in_background(self.find_partial_downloads(podcasts))

    def _create_qml_gui(self, filename):
        self.qmlEngine = QDeclarativeEngine()
        self.qmlEngine.addImageProvider('cover', self.cover_provider)

        context = self.qmlEngine.rootContext()

        context.setContextProperty('controller', self.controller)
        context.setContextProperty('configProxy', self.config_proxy)
        context.setContextProperty('mediaButtonsHandler',
                self.media_buttons_handler)
        context.setContextProperty('trackerMinerConfig',
                self.tracker_miner_config)

        # Load the QML UI (this could take a while...)
        self.mainWindow = createQmlComponent(
            filename, self.qmlEngine, context, self
        )
#        self.view.setWindowTitle('gPodder')

    def _create_model_filter(self, model):
        sortFilterProxyModel = desktopModel.SortFilterProxyModel(self)

        sortFilterProxyModel.setSourceModel(model)
        sortFilterProxyModel.setDynamicSortFilter(True)

        return sortFilterProxyModel

    quit = Signal()

    def on_quit(self):
        # Make sure the audio playback is stopped immediately
#        self.main.togglePlayback(None)
        self.save_pending_data()
        self.mainWindow.setVisible(True)
        del self.mainWindow
        self.core.shutdown()
        self.app.quit()

    do_start_progress = Signal(str, int)

    @Slot(str, int)
    def on_start_progress(self, text, value):
        self.main.startProgress(text, value)

    def start_progress(self, text=_('Please wait...'), progress=0):
        self.do_start_progress.emit(text, progress)
コード例 #3
0
ファイル: __init__.py プロジェクト: travnick/gpodder
    def __init__(self, args, gpodder_core, dbus_bus_name):
        QmlCommonQtPodder.__init__(self, args, gpodder_core, dbus_bus_name)

        self.episodeUpdated.connect(self.on_episode_updated)
        self.setEpisodeListModel.connect(self.on_set_episode_list_model)

        self.view = DeclarativeView()
        self.view.closing.connect(self.on_quit)
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)

        self.controller = Controller(self)
        self.media_buttons_handler = helper.MediaButtonsHandler()
        self.tracker_miner_config = helper.TrackerMinerConfig()
        self.podcast_model = qml.model.gPodderPodcastListModel()
        self.episode_model = mobileModel.gPodderEpisodeListModel(self.config, self)
        self.last_episode = None

        # A dictionary of episodes that are currently active
        # in some way (i.e. playing back or downloading)
        self.active_episode_wrappers = {}

        engine = self.view.engine()

        # Add the cover art image provider
        self.cover_provider = images.LocalCachedImageProvider()
        engine.addImageProvider('cover', self.cover_provider)

        root_context = self.view.rootContext()
        root_context.setContextProperty('controller', self.controller)
        root_context.setContextProperty('configProxy', self.config_proxy)
        root_context.setContextProperty('mediaButtonsHandler',
                self.media_buttons_handler)
        root_context.setContextProperty('trackerMinerConfig',
                self.tracker_miner_config)

        # Load the QML UI (this could take a while...)
        self.view.setSource(QUrl.fromLocalFile(QML('main_default.qml')))

        # Proxy to the "main" QML object for direct access to Qt Properties
        self.main = QObjectProxy(self.view.rootObject().property('main'))

        self.main.podcastModel = self.podcast_model
        self.main.episodeModel = self.episode_model

        self.view.setWindowTitle('gPodder')

        if gpodder.ui.harmattan:
            self.view.showFullScreen()
        else:
            # On the Desktop, scale to fit my small laptop screen..
            desktop = self.app.desktop()
            if desktop.height() < 1000:
                FACTOR = .8
                self.view.scale(FACTOR, FACTOR)
                size = self.view.size()
                size *= FACTOR
                self.view.resize(size)
            self.view.show()

        self.do_start_progress.connect(self.on_start_progress)
        self.do_end_progress.connect(self.on_end_progress)
        self.do_show_message.connect(self.on_show_message)

        podcasts = self.load_podcasts()

        self.resumable_episodes = None
        self.do_offer_download_resume.connect(self.on_offer_download_resume)
        util.run_in_background(self.find_partial_downloads(podcasts))