예제 #1
0
    def _update_widgets_for_selected_show(self):
        if not self._current_page.selected_show:
            self.set_buttons_sensitive(False, lists_too=False)
            return

        self.set_buttons_sensitive(True, lists_too=False)
        show = self._engine.get_show_info(self._current_page.selected_show)

        # Block handlers
        self.statusbox.handler_block(self.statusbox_handler)

        if self._image_thread is not None:
            self._image_thread.cancel()

        self.show_title.set_text('<span size="14000"><b>{0}</b></span>'.format(
            html.escape(show['title'])))
        self.show_title.set_use_markup(True)

        # Episode selector
        self.btn_episode_show_entry.set_label(str(show['my_progress']))
        self._hide_episode_entry()

        # Status selector
        for i in self.statusmodel:
            if str(i[0]) == str(show['my_status']):
                self.statusbox.set_active_iter(i.iter)
                break

        # Score selector
        self.spinbtn_score.set_value(show['my_score'])

        # Image
        if show.get('image_thumb') or show.get('image'):
            utils.make_dir(utils.to_cache_path())
            filename = utils.to_cache_path(
                "%s_%s_%s.jpg" %
                (self._engine.api_info['shortname'],
                 self._engine.api_info['mediatype'], show['id']))

            if os.path.isfile(filename):
                self.show_image.image_show(filename)
            else:
                if imaging_available:
                    self.show_image.pholder_show('Loading...')
                    self._image_thread = ImageTask(
                        self.show_image,
                        show.get('image_thumb') or show['image'], filename,
                        (100, 149))
                    self._image_thread.start()
                else:
                    self.show_image.pholder_show("PIL library\nnot available")
        else:
            self.show_image.pholder_show("No Image")

        # Unblock handlers
        self.statusbox.handler_unblock(self.statusbox_handler)
예제 #2
0
파일: mainview.py 프로젝트: z411/trackma
    def _update_widgets_for_selected_show(self):
        if not self._current_page.selected_show:
            self.set_buttons_sensitive(False, lists_too=False)
            return

        self.set_buttons_sensitive(True, lists_too=False)
        show = self._engine.get_show_info(self._current_page.selected_show)

        # Block handlers
        self.statusbox.handler_block(self.statusbox_handler)

        if self._image_thread is not None:
            self._image_thread.cancel()

        self.show_title.set_text('<span size="14000"><b>{0}</b></span>'.format(html.escape(show['title'])))
        self.show_title.set_use_markup(True)

        # Episode selector
        self.btn_episode_show_entry.set_label(str(show['my_progress']))
        self._hide_episode_entry()

        # Status selector
        for i in self.statusmodel:
            if str(i[0]) == str(show['my_status']):
                self.statusbox.set_active_iter(i.iter)
                break

        # Score selector
        self.spinbtn_score.set_value(show['my_score'])

        # Image
        if show.get('image_thumb') or show.get('image'):
            utils.make_dir(utils.to_cache_path())
            filename = utils.to_cache_path(
                "%s_%s_%s.jpg" % (self._engine.api_info['shortname'],
                                  self._engine.api_info['mediatype'],
                                  show['id']))

            if os.path.isfile(filename):
                self.show_image.image_show(filename)
            else:
                if imaging_available:
                    self.show_image.pholder_show('Loading...')
                    self._image_thread = ImageTask(self.show_image,
                                                   show.get('image_thumb') or show['image'],
                                                   filename,
                                                   (100, 149))
                    self._image_thread.start()
                else:
                    self.show_image.pholder_show("PIL library\nnot available")
        else:
            self.show_image.pholder_show("No Image")

        # Unblock handlers
        self.statusbox.handler_unblock(self.statusbox_handler)
예제 #3
0
    def _update_widgets_for_selected_show(self):
        if not (self._current_page and self._current_page.selected_show):
            self.set_buttons_sensitive(False, lists_too=False)
            return

        self.set_buttons_sensitive(True, lists_too=False)
        try:
            show = self._engine.get_show_info(self._current_page.selected_show)
        except utils.EngineError:
            self._list.remove(id=self._current_page.selected_show)
            self.set_buttons_sensitive(False, lists_too=False)
            return

        # Block handlers
        self.statusbox.handler_block(self.statusbox_handler)

        if self._image_thread is not None:
            self._image_thread.cancel()

        self.show_title.set_text('<span size="14000"><b>{0}</b></span>'.format(
            html.escape(show['title'])))
        self.show_title.set_use_markup(True)

        # Episode selector
        self.btn_episode_show_entry.set_label(str(show['my_progress']))

        # Status selector
        for i in self.statusmodel:
            if str(i[0]) == str(show['my_status']):
                self.statusbox.set_active_iter(i.iter)
                break

        # Score selector
        self.spinbtn_score.set_value(show['my_score'])

        # Image
        if show.get('image_thumb') or show.get('image'):
            utils.make_dir(utils.to_cache_path())
            filename = utils.to_cache_path(
                "%s_%s_%s.jpg" %
                (self._engine.api_info['shortname'],
                 self._engine.api_info['mediatype'], show['id']))

            if os.path.isfile(filename):
                self.image_box.set_image(filename)
            else:
                self.image_box.set_image_remote(
                    show.get('image_thumb') or show['image'], filename)
        else:
            self.image_box.set_text('No Image')

        # Unblock handlers
        self.statusbox.handler_unblock(self.statusbox_handler)
예제 #4
0
    def setResults(self, new_results):
        """ This method will process a new list of shows and get their
        thumbnails if necessary. """

        self.beginResetModel()

        self.results = new_results

        self.thumbs.clear()

        if self.results:
            for row, item in enumerate(self.results):
                if item.get('image'):
                    filename = utils.to_cache_path(
                        "%s_%s_f_%s.jpg" %
                        (self.api_info['shortname'],
                         self.api_info['mediatype'], item['id']))

                    if self.pool.exists(filename):
                        self.thumbs[row] = self.pool.getThumb(filename).scaled(
                            100, 140, QtCore.Qt.KeepAspectRatio,
                            QtCore.Qt.SmoothTransformation)
                    else:
                        self.pool.queueDownload(row, item['image'], filename)

        self.endResetModel()
예제 #5
0
    def load(self, show):
        metrics = QtGui.QFontMetrics(self.show_title.font())
        title = metrics.elidedText(show['title'], QtCore.Qt.ElideRight,
                                   self.show_title.width())

        self.show_title.setText("<a href=\"%s\">%s</a>" % (show['url'], title))
        self.show_title.setTextFormat(QtCore.Qt.RichText)
        self.show_title.setTextInteractionFlags(
            QtCore.Qt.TextBrowserInteraction)
        self.show_title.setOpenExternalLinks(True)

        # Load show info
        self.show_info.setText('Wait...')
        self.worker_call('get_show_details', self.r_details_loaded, show)
        api_info = self.worker.engine.api_info

        # Load show image
        if show.get('image'):
            filename = utils.to_cache_path(
                "%s_%s_f_%s.jpg" %
                (api_info['shortname'], api_info['mediatype'], show['id']))

            if os.path.isfile(filename):
                self.s_show_image(filename)
            else:
                self.show_image.setText('Downloading...')
                self.image_worker = ImageWorker(show['image'], filename,
                                                (200, 280))
                self.image_worker.finished.connect(self.s_show_image)
                self.image_worker.start()
        else:
            self.show_image.setText('No image')
예제 #6
0
def playback_status(engine, show, is_playing, is_open, episode):
    def rounded(_path, rad=10):
        from io import BytesIO
        if path.isfile(_path):
            try:
                from PIL import Image, ImageDraw
                im = Image.open(_path)
                circle = Image.new('L', (rad * 2, rad * 2), 0)
                draw = ImageDraw.Draw(circle)
                draw.ellipse((0, 0, rad * 2, rad * 2), fill=255)
                alpha = Image.new('L', im.size, 255)
                w, h = im.size
                alpha.paste(circle.crop((0, 0, rad, rad)), (0, 0))
                alpha.paste(circle.crop((0, rad, rad, rad * 2)), (0, h - rad))
                alpha.paste(circle.crop((rad, 0, rad * 2, rad)), (w - rad, 0))
                alpha.paste(circle.crop((rad, rad, rad * 2, rad * 2)),
                            (w - rad, h - rad))
                im.putalpha(alpha)
                IM = BytesIO()
                im.save(IM, format='png')
                im = IM.getvalue()
                IM.close()
            except ModuleNotFoundError:
                with open(_path, 'rb') as f:
                    im = f.read()
            try:
                loader = GdkPixbuf.PixbufLoader.new_with_type('png')
                loader.write(im)
                pixbuf = loader.get_pixbuf()
                loader.close()
                return pixbuf
            except:
                pass
        return icon_pixbuf

    filename = utils.to_cache_path("%s_%s_%s.jpg" %
                                   (engine.api_info['shortname'],
                                    engine.api_info['mediatype'], show['id']))
    notif.update(
        "Playing" if is_playing else ("Paused" if is_open else "Stopped"),
        "%s %d" % (show['title'], episode), 'trackma')
    notif.set_image_from_pixbuf(rounded(filename))
    try:
        notif.show()
    except GLib.Error:
        pass
예제 #7
0
    def load(self, show):
        self._show = show

        # Load image
        if show.get('image'):
            imagefile = utils.to_cache_path("%s_%s_f_%s.jpg" % (self._engine.api_info['shortname'],
                                                                self._engine.api_info['mediatype'],
                                                                show['id']))

            if os.path.isfile(imagefile):
                self.image_box.set_image(imagefile)
            else:
                self.image_box.set_image_remote(show['image'], imagefile)
        else:
            self.image_box.set_text('No Image')

        # Start info loading thread
        threading.Thread(target=self._show_load_start_task).start()
예제 #8
0
파일: models.py 프로젝트: z411/trackma
    def setResults(self, new_results):
        """ This method will process a new list of shows and get their
        thumbnails if necessary. """

        self.beginResetModel()

        self.results = new_results

        self.thumbs.clear()

        if self.results:
            for row, item in enumerate(self.results):
                if item.get('image'):
                    filename = utils.to_cache_path("%s_%s_f_%s.jpg" % (self.api_info['shortname'], self.api_info['mediatype'], item['id']))

                    if self.pool.exists(filename):
                        self.thumbs[row] = self.pool.getThumb(filename).scaled(100, 140, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation);
                    else:
                        self.pool.queueDownload(row, item['image'], filename)

        self.endResetModel()
예제 #9
0
    def load(self, show):
        self._show = show

        # Load image
        if show.get('image'):
            imagefile = utils.to_cache_path(
                "%s_%s_f_%s.jpg" %
                (self._engine.api_info['shortname'],
                 self._engine.api_info['mediatype'], show['id']))

            if os.path.isfile(imagefile):
                self.image_box.image_show(imagefile)
            else:
                self.image_box.pholder_show('Loading...')
                self.image_thread = ImageTask(self.image_box, show['image'],
                                              imagefile, (200, 298))
                self.image_thread.start()
        else:
            self.image_box.pholder_show('No Image')

        # Start info loading thread
        threading.Thread(target=self._show_load_start_task).start()