Esempio n. 1
0
 def settings_updated(self):
     """
     Called when settings are updated
     """
     self.ui.webView.setZoomFactor(self.default_zoom_factor*int(settings.get('content', 'zoom_factor'))/100)
     self.current_zoom_factor = self.ui.webView.zoomFactor()
     self.ui.webView.page().user_agent = settings.get('content', 'user_agent')
Esempio n. 2
0
 def display_banner(self, text):
     if not text or settings.get('info', 'banner_position') == 'hide':
         return
     self.stop_banner_sliding()
     self.banner.setText(text)
     self.show_banner()
     if settings.get('info', 'banner_hide'):
         self.start_banner_sliding()
Esempio n. 3
0
    def read_inputs(self):
        self.google_credentials_changed = False
        
        google_account  = self.ui.inputSettingsAccount.text()
        google_password = self.ui.inputSettingsPassword.text()

        if settings.get('google', 'account') != google_account \
        or settings.get('google', 'password') != google_password:
            settings.set('google', 'verified', False)
            settings.set('google', 'auth_token', '')
            settings.set('google', 'token', '')
            self.google_credentials_changed = True
        settings.set('google', 'account', google_account)
        settings.set('google', 'password', google_password)
    
        try:
            settings.set('feeds', 'default', settings.helpers['feeds_default'][self.ui.selectSettingsHomeDefault.currentIndex()])
        except:
            pass
    
        settings.set('feeds', 'unread_only', self.ui.checkSettingsHomeShowUnread.isChecked())
    
        settings.set('feeds', 'show_broadcast',         self.ui.checkSettingsShowShared.isChecked())
        settings.set('feeds', 'show_starred',           self.ui.checkSettingsShowStarred.isChecked())
        settings.set('feeds', 'show_created',           self.ui.checkSettingsShowNotes.isChecked())
        settings.set('feeds', 'show_reading-list',      self.ui.checkSettingsShowAll.isChecked())
        settings.set('feeds', 'show_read',              self.ui.checkSettingsShowRead.isChecked())
        settings.set('feeds', 'show_broadcast-friends', self.ui.checkSettingsShowFriends.isChecked())
        # old stuff
        settings.set('feeds', 'show_kept-unread',       False)
    
        try:
            settings.set('items', 'show_mode', settings.helpers['items_show_mode'][self.ui.selectSettingsItemsShowMode.currentIndex()])
        except:
            pass
            
        settings.set('content', 'feed_in_title', self.ui.checkSettingsDisplayFeedsTitleItemView.isChecked())
        settings.set('content', 'user_agent', self.ui.inputSettingsUserAgent.text())
        settings.set('content', 'zoom_factor', self.ui.spinSettingsZoomFactor.value())

        settings.set('feeds', 'unread_number',  self.ui.spinSettingsItemsToFetch.value())
    
        try:
            settings.set('info', 'banner_position', settings.helpers['info_banner_position'][self.ui.selectSettingsBannerPosition.currentIndex()])
        except:
            pass
    
        settings.set('info', 'banner_hide', self.ui.checkSettingsBannerHide.isChecked())

        settings.set('info', 'banner_hide_delay', self.ui.spinSettingsBannerHideDelay.value())
Esempio n. 4
0
    def dist_authenticate(self):
        """
        Authenticate the account with Google Reader
        """
        was_authenticated = self.is_authenticated
        self.is_authenticated = False
        try:
            # if this account was previously authenticated, we try to get
            # another token
            if self.g_auth and was_authenticated:
                try:
                    sys.stderr.write("AUTH: update token\n")
                    self.g_auth.token = self.g_auth._getToken()
                    sys.stderr.write("AUTH: token=%s\n" % self.g_auth.token)
                    self.is_authenticated = True
                    settings.set('google', 'token', self.g_auth.token, save_all=True)
                except:
                    pass

            # else, but if we already had tokens by the past, try with them
            elif settings.get('google', 'auth_token') and settings.get('google', 'token'):
                sys.stderr.write("AUTH: load saved auth\n")
                self.g_auth = SavedAuth(settings.get('google', 'account'), \
                                        settings.get('google', 'password'), \
                                        settings.get('google', 'auth_token'), \
                                        settings.get('google', 'token'))
                try:
                    # test if the token is still valid
                    self.g_auth.token = self.g_auth._getToken()
                except:
                    pass
                else:
                    # it's valid so we are authenticated
                    settings.set('google', 'token', self.g_auth.token, save_all=True)
                    self.is_authenticated = True
                    
            # here, we have not a valid token, so we do a full authentication
            if not self.is_authenticated:
                sys.stderr.write("AUTH: full auth\n")
                self.g_auth = ClientAuth(settings.get('google', 'account'), settings.get('google', 'password'))
                self.is_authenticated = True
                settings.set('google', 'verified', True)
                settings.set('google', 'auth_token', self.g_auth.auth_token)
                settings.set('google', 'token', self.g_auth.token, save_all=True)

            # finally if we are authenticated, update, or create, a new 
            # GoogleReadr object
            if self.is_authenticated:
                if self.g_object:
                    self.g_object.auth = self.g_auth
                else:
                    self.create_g_object()

        # an exception was raised during the authentication. 
        # it is either a authentication failure, or a network failure
        # but let the caller manage this
        except:
            self.is_authenticated = False
            raise
Esempio n. 5
0
 def set_current_category(self, category=None):
     """
     Set the new current category and update the feed list
     """
     if category is None and self.current_category is None:
         return
     if category is not None and self.current_category is not None \
         and category == self.current_category:
         # close the current category
         self.current_category = None
     else:
         self.current_category = category
     if settings.get('feeds', 'default') == 'labels':
         self.update_feed_list()
         # display maximum of content for the category
         if self.current_category:
             feed_unread_only = self.unread_only and not isinstance(self.current_category, SpecialCategory)
             feeds = self.current_category.get_feeds(unread_only=feed_unread_only)
             try:
                 # start with last
                 max_index = self.ui.listFeedList.model().index_of(feeds[-1])
                 self.ui.listFeedList.scrollTo(max_index)
                 # then scroll again to category
                 min_index = self.ui.listFeedList.model().index_of(self.current_category)
                 self.ui.listFeedList.scrollTo(min_index)
             except:
                 pass
Esempio n. 6
0
 def __init__(self, id=None, password=None):
     """
     Instantiate a new Account
     """
     if not id:
         id = str(settings.get('google', 'account'))
     self.id               = id
     self.categories       = []
     self.categories_by_id = {}
     self.is_authenticated = False
     
     # An operation manager for this account
     self.operations_manager = OperationsManager(self,  callbacks = {
         'get_feed_content_done':      self.operation_get_feed_content_done, 
         'get_more_feed_content_done': self.operation_get_feed_content_done, 
     })
     # ClientAuth object (from libgreader)
     self.g_auth = None
     # GoogleReader object (from libgreader)
     self.g_object = None
     
     # category for special feeds
     self.special_category = None
     # and one for orphan feeds
     self.orphan_feeds_category = None
     
     # total unread count
     self.unread = 0
Esempio n. 7
0
 def get_content(self, unread_only=False, current_category=None):
     """
     Compute the content to be displayed in the list.
     """
     result = []
     for category in self.controller.account.get_categories(unread_only=unread_only):
         result.append(category)
         if settings.get('feeds', 'default') == 'feeds' \
             or (current_category is not None and category == current_category):
             feed_unread_only = unread_only and not isinstance(category, SpecialCategory)
             feeds = category.get_feeds(unread_only=feed_unread_only)
             if category == self.controller.account.special_category:
                 s_feeds = [feed for feed in feeds if settings.get('feeds', 'show_%s' % feed.special_type)]
                 feeds = s_feeds
             for feed in feeds:
                 result.append(feed)
     return result
Esempio n. 8
0
 def settings_updated(self):
     """
     Called when settings are updated
     """
     super(ItemListView,  self).settings_updated()
     show_mode = str(settings.get('items', 'show_mode'))
     self.unread_only_default = show_mode.find('unread') != -1
     self.show_mode_save      = show_mode.find('nosave') == -1
Esempio n. 9
0
    def __init__(self, controller):
        super(FeedListView, self).__init__(controller, Ui_winFeedList)
        
        self.current_category = None
        self.unread_only     = settings.get('feeds', 'unread_only')

        self.selected_category = None
        self.selected_feed     = None

        # menu bar

        self.add_orientation_menu()
        
        # simple menu boutons
        self.action_settings = QAction("Settings", self.win)
        self.action_settings.setObjectName('actionSettings')
        self.action_sync = QAction("Synchronize all", self.win)
        self.action_sync.setDisabled(not settings.auth_ready())
        self.action_sync.setObjectName('actionSync')
        self.ui.menuBar.addAction(self.action_settings)
        self.ui.menuBar.addAction(self.action_sync)
        self.action_settings.triggered.connect(self.controller.trigger_settings)
        self.action_sync.triggered.connect(self.trigger_sync)

        # menu boutons : group for show all/unread
        self.group_show = QActionGroup(self.win)
        self.action_show_all = QAction("Show all", self.group_show)
        self.action_show_all.setCheckable(True)
        self.action_show_all.setDisabled(True)
        self.action_show_unread_only = QAction("Show unread", self.group_show)
        self.action_show_unread_only.setCheckable(True)
        self.action_show_unread_only.setDisabled(True)
        if settings.get('feeds', 'unread_only'):
            self.action_show_unread_only.setChecked(True)
        else:
            self.action_show_all.setChecked(True)
        self.ui.menuBar.addActions(self.group_show.actions())
        self.action_show_unread_only.toggled.connect(self.toggle_unread_only)
        
        # feed list
        flm = FeedListModel(data=[], view=self)
        fld = FeedListDelegate(self.win)
        self.ui.listFeedList.setModel(flm)
        self.ui.listFeedList.setItemDelegate(fld)
        self.ui.listFeedList.activated.connect(self.activate_entry)
Esempio n. 10
0
 def settings_updated(self):
     """
     Called when settings are updated
     """
     super(FeedListView, self).settings_updated()
     self.unread_only = not not settings.get('feeds', 'unread_only')
     self.manage_actions()
     if not self.sync_running and settings.auth_ready():
         self.update_feed_list()
Esempio n. 11
0
 def settings_updated(self):
     """
     Called when settings are updated
     """
     super(FeedListView, self).settings_updated()
     self.unread_only = not not settings.get('feeds', 'unread_only')
     self.action_sync.setDisabled(not settings.auth_ready())
     if settings.auth_ready():
         self.update_feed_list()
Esempio n. 12
0
    def __init__(self, *args, **kwargs):
        super(Controller, self).__init__(*args, **kwargs)

        # manage orientation
        self.portrait_mode = False
        self.set_portrait_mode(settings.get('other', 'portrait_mode'))

        # manage scrolling titles
        self.title_timer = QTimer()
        QObject.connect(self.title_timer, SIGNAL("timeout()"), self.timeout_title_timer)
Esempio n. 13
0
 def fetch_content(self, unread_only=False, max_fetch=None):
     """
     Create an asynchronous operation to fetch content for this category.
     If max_fetch == -1, fetch while items are present in the category
     else stop when all or at least max_fetch is retrieved.
     """
     if max_fetch == None:
         max_fetch = int(settings.get('feeds', 'unread_number'))
     for feed in self.get_feeds(unread_only=unread_only):
         feed.fetch_content(unread_only=unread_only, max_fetch=max_fetch) 
Esempio n. 14
0
 def show(self, app_just_launched=False):
     """
     Diplay the window and if the account is ok, launch a 
     sync, else display settings
     """
     super(FeedListView, self).show(app_just_launched)
     if app_just_launched:
         if settings.get('google', 'verified'):
             self.trigger_sync()
         else:
             self.controller.trigger_settings()
Esempio n. 15
0
 def update_display_title(self):
     max = self.get_max_title_length()
     if not settings.get('other', 'scroll_titles') or len(self.title) <= max:
         display_title = self.title
         self.controller.title_timer.stop()
     else:
         self.title_start += self.title_step
         if self.title_start < 0 or len(self.title) - self.title_start < max:
             self.title_step = self.title_step * -1
             self.title_start += self.title_step
         display_title = self.title[self.title_start:]
     self.win.setWindowTitle(display_title)
Esempio n. 16
0
 def settings_updated(self):
     old_banner = self.banner
     if settings.get('info', 'banner_position') == 'top':
         self.banner = self.ui.bannerTop
     else:
         self.banner = self.ui.bannerBottom
     if old_banner != self.banner:
         self.stop_banner_sliding()
         if self.banner_animation:
             self.banner_animation.setTargetObject(self.banner)
         self.display_banner(old_banner.text())
         old_banner.setMaximumHeight(0)
         old_banner.hide()
Esempio n. 17
0
 def fetch_content(self, unread_only=False, max_fetch=None):
     """
     Create an asynchronous operation to fetch content for this category.
     If max_fetch == -1, fetch while items are present in the category
     else stop when all or at least max_fetch is retrieved.
     """
     if max_fetch == None:
         max_fetch = int(settings.get('feeds', 'unread_number'))
     for feed in self.get_feeds(unread_only==False, exclude=[
             self.special_feeds[GoogleReader.READING_LIST], 
             self.special_feeds[GoogleReader.READ_LIST], 
         ]):
         feed.fetch_content(unread_only=False, max_fetch=max_fetch) 
Esempio n. 18
0
 def set_current_category(self, category=None):
     """
     Set the new current category and update the feed list
     """
     if category is None and self.current_category is None:
         return
     if category is not None and self.current_category is not None \
         and category == self.current_category:
         # close the current category
         self.current_category = None
     else:
         self.current_category = category
     if settings.get('feeds', 'default') == 'labels':
         self.update_feed_list()
Esempio n. 19
0
    def read_inputs(self):
        self.google_credentials_changed = False
        self.google_was_verified        = settings.get('google', 'verified')
        
        google_account  = self.ui.inputSettingsAccount.text()
        google_password = self.ui.inputSettingsPassword.text()

        if settings.get('google', 'account') != google_account \
        or settings.get('google', 'password') != google_password:
            settings.set('google', 'verified', False)
            settings.set('google', 'auth_token', '')
            settings.set('google', 'token', '')
            self.google_credentials_changed = True
        settings.set('google', 'account', google_account)
        settings.set('google', 'password', google_password)
    
        try:
            settings.set('feeds', 'default', settings.helpers['feeds_default'][self.ui.selectSettingsHomeDefault.currentIndex()])
        except:
            pass
    
        settings.set('feeds', 'unread_only', self.ui.checkSettingsHomeShowUnread.isChecked())
    
        settings.set('feeds', 'show_broadcast',         self.ui.checkSettingsShowShared.isChecked())
        settings.set('feeds', 'show_starred',           self.ui.checkSettingsShowStarred.isChecked())
        settings.set('feeds', 'show_created',           self.ui.checkSettingsShowNotes.isChecked())
        settings.set('feeds', 'show_reading-list',      self.ui.checkSettingsShowAll.isChecked())
        settings.set('feeds', 'show_read',              self.ui.checkSettingsShowRead.isChecked())
        settings.set('feeds', 'show_broadcast-friends', self.ui.checkSettingsShowFriends.isChecked())
        # old stuff
        settings.set('feeds', 'show_kept-unread',       False)
    
        try:
            settings.set('items', 'show_mode', settings.helpers['items_show_mode'][self.ui.selectSettingsItemsShowMode.currentIndex()])
        except:
            pass
Esempio n. 20
0
 def update_inputs(self):
     self.ui.inputSettingsAccount.setText( settings.get('google', 'account'))
     self.ui.inputSettingsPassword.setText(settings.get('google', 'password'))
     try:
         self.ui.selectSettingsHomeDefault.setCurrentIndex(settings.helpers['feeds_default'].index(settings.get('feeds', 'default')))
     except:
         self.ui.selectSettingsHomeDefault.setCurrentIndex(0)
 
     self.ui.checkSettingsHomeShowUnread.setChecked(settings.get('feeds', 'unread_only'))
 
     self.ui.checkSettingsShowShared.setChecked(    settings.get('feeds', 'show_broadcast'))
     self.ui.checkSettingsShowStarred.setChecked(   settings.get('feeds', 'show_starred'))
     self.ui.checkSettingsShowNotes.setChecked(     settings.get('feeds', 'show_created'))
     self.ui.checkSettingsShowAll.setChecked(       settings.get('feeds', 'show_reading-list'))
     self.ui.checkSettingsShowRead.setChecked(      settings.get('feeds', 'show_read'))
     self.ui.checkSettingsShowFriends.setChecked(   settings.get('feeds', 'show_broadcast-friends'))
 
     try:
         self.ui.selectSettingsItemsShowMode.setCurrentIndex(settings.helpers['items_show_mode'].index(settings.get('items', 'show_mode')))
     except:
         self.ui.selectSettingsItemsShowMode.setCurrentIndex(0)
Esempio n. 21
0
 def get_title(self):
     """
     Return the current item's title
     """
     title = ""
     if self.current_item:
         if settings.get('content', 'feed_in_title'):
             try:
                 title = self.current_item.normal_feeds[0].title\
                     or self.current_item.g_item.origin['title']\
                     or self.current_item.g_item.origin['url']
             except:
                 pass
         if not title:
             title = self.current_item.title
     return title
Esempio n. 22
0
    def init_menu(self):
        super(FeedListView, self).init_menu()
        
        menu_container = self.get_menu_container()
        
        # simple menu boutons
        self.action_settings = QAction("Settings", self.win)
        self.action_settings.setObjectName('actionSettings')
        self.action_sync = QAction("Synchronize all", self.win)
        self.action_sync.setDisabled(not settings.auth_ready())
        self.action_sync.setObjectName('actionSync')
        menu_container.addAction(self.action_settings)
        menu_container.addAction(self.action_sync)
        self.action_settings.triggered.connect(self.controller.trigger_settings)
        self.action_sync.triggered.connect(self.trigger_sync)
        
        menu_container.addSeparator()

        # menu boutons : group for show all/unread
        self.group_show = QActionGroup(self.win)
        self.action_show_all = QAction("Show all", self.group_show)
        self.action_show_all.setCheckable(True)
        self.action_show_all.setDisabled(True)
        self.action_show_unread_only = QAction("Unread only", self.group_show)
        self.action_show_unread_only.setCheckable(True)
        self.action_show_unread_only.setDisabled(True)
        if settings.get('feeds', 'unread_only'):
            self.action_show_unread_only.setChecked(True)
        else:
            self.action_show_all.setChecked(True)
        menu_container.addActions(self.group_show.actions())
        self.action_show_unread_only.toggled.connect(self.trigger_unread_only)
        
        # context menu
        self.make_context_menu(self.ui.listFeedList)
        
        self.action_mark_selected_as_read = QAction("Mark as read", self.win)
        self.action_mark_selected_as_read.triggered.connect(self.trigger_mark_selected_as_read)
        self.context_menu.addAction(self.action_mark_selected_as_read)

        self.context_menu.addSeparator()
        self.context_menu.addActions(self.group_show.actions())
        self.context_menu.addSeparator()
        self.context_menu.addAction(self.action_sync)
        self.context_menu.addAction(self.action_settings)
        
        self.manage_actions()
Esempio n. 23
0
    def __init__(self, controller):
        self.current_category = None
        self.unread_only     = settings.get('feeds', 'unread_only')

        self.selected_category = None
        self.selected_feed     = None
        
        self.sync_running = False

        super(FeedListView, self).__init__(controller, self.get_ui_class())
        
        # feed list
        flm = FeedListModel(data=[], view=self)
        fld = self.get_feedlist_delegate_class()(self.win)
        self.ui.listFeedList.setModel(flm)
        self.ui.listFeedList.setItemDelegate(fld)
        self.ui.listFeedList.activated.connect(self.activate_entry)
Esempio n. 24
0
    def __init__(self, controller, ui, parent=None):
        """
        Initialize window
        """
        self.controller = controller
        self.controller.add_view(self)
        
        self.launched = False
        
        self.win = QMainWindow(parent, Qt.Window)

        self.win.view = self
        self.ui = ui()
        self.ui.setupUi(self.win)
        self.win.setWindowTitle(QApplication.applicationName())
        
        self.win.installEventFilter(WindowEventFilter(self.win))

        # banner 
        if settings.get('info', 'banner_position') == 'top':
            self.banner = self.ui.bannerTop
            self.ui.bannerBottom.hide()
        else:
            self.banner = self.ui.bannerBottom
            self.ui.bannerTop.hide()

        try:
            self.banner_animation = QPropertyAnimation(self.banner, 'maximumHeight')
        except:
            self.banner_animation = None
            self.banner_timer = QTimer()
            self.banner_timer.setSingleShot(True)
            self.banner_timer.timeout.connect(self.hide_banner)
        else:
            self.banner_animation.finished.connect(self.hide_banner)
            self.banner_timer = None
        banner_event_filter = BannerEventFilter(self.win)
        self.ui.bannerTop.installEventFilter(banner_event_filter)
        self.ui.bannerBottom.installEventFilter(banner_event_filter)
        QObject.connect(banner_event_filter, SIGNAL("hide_banner"), self.hide_banner)
        
        # menu & events
        self.init_menu()
        self.post_init_menu()
        self.init_events()
Esempio n. 25
0
    def __init__(self, controller):
        # item displayed
        self.current_item = None
        self.current_page_is_content = False
        
        super(ItemViewView, self).__init__(controller, self.get_ui_class(), controller.itemlist_view.win)
        
        # web view
        self.ui.webView.setPage(WebPage(parent=self.ui.webView))
        self.ui.webView.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
        self.ui.webView.page().linkClicked.connect(self.link_clicked)
        self.ui.webView.loadFinished.connect(self.trigger_web_view_loaded)
        self.default_zoom_factor = self.ui.webView.zoomFactor()
        self.ui.webView.setZoomFactor(self.default_zoom_factor*int(settings.get('content', 'zoom_factor'))/100)
        self.current_zoom_factor = self.ui.webView.zoomFactor()
        self.ui.webView.setStyleSheet('background: white')

        self.init_toolbars()
Esempio n. 26
0
    def leave(self, user):
        world = worlds.get(user.wid)

        self.server.send_to_world(world.wid, {
            "route": "Worlds:left",
            "iso": user.iso,
        })

        self.server.client_leave_world(user.client)

        if settings.get('client.leave_world_on_disconnect'):
            user.wid = None
            user.iso = None
            users.set_world(user.uid, None, None)

        # delete match if it hasn't started yet
        if world.rounds == 0:
            clients = self.server.onlineMatches[str(world.wid)]
            if len(clients) == 0:
                print("DELETING MATCH", world.wid)
                worlds.delete(world)

        return {}
Esempio n. 27
0
def get_K(elo, n_games):
    if n_games < 30 and elo < 2300:
        return 400
    elif elo < 2400:
        return 200
    return 100


def elo_change(eloA, eloB, sA, nA=0):
    expA = get_expected(eloA, eloB)

    Ka = 32
    return round(Ka * (sA - expA))


divisions = settings.get('rating.divisions')
MAX_DIV = divisions.index('marshal')


def handle_divisions(user: User, sa):
    if user.division >= MAX_DIV:
        # user is already at max division
        return False

    if user.elo > 1800 and sa==1:
        # user has ascended beyond promo elo
        user.division += 1
        return True

    elif user.elo < 900 and sa==0 and user.division > 0:
        # user has fallen 1 division below
Esempio n. 28
0
    def update_inputs(self):
        super(SettingsDialog, self).update_inputs()

        self.ui.checkSettingsScrollTitles.setChecked(settings.get("other", "scroll_titles"))
Esempio n. 29
0
    def paint(self, painter, option, index):
        """
        Paint the list entry with the default options, then add the unread counter
        """
        painter.save()
        
        try:
            # entry to work with
            is_category = False            
            model = index.model()
            entry = model.listdata[index.row()]

            text_style_option = QStyleOptionViewItemV4(option)
            palette = text_style_option.palette
            text_font = text_style_option.font
            if isinstance(entry, Feed):
                # it's a feed
                text = entry.title
                # add a blank to the left to mimic a treeview
                text_style_option.rect.adjust(15, 0, 0, 0)
                if entry.__class__ != Feed:
                    text_font.setStyle(QFont.StyleItalic)
                if entry.unread and not model.view.unread_only:
                    text_font.setWeight(QFont.Bold)
            else:
                # it's a category
                is_category = True
                text = entry.title
                if entry.unread and not model.view.unread_only:
                    text_font.setWeight(QFont.Bold)
                if isinstance(entry, SpecialCategory):
                    text_font.setStyle(QFont.StyleItalic)

            # draw background and borders
            self.parent().style().drawControl(QStyle.CE_ItemViewItem, text_style_option, painter)

            # prepare the text_rect. Will be reduced for displaying unread count
            text_rect  = text_style_option.rect

            # display unread count
            if entry.unread:
                if is_category:
                    if isinstance(entry, SpecialCategory):
                        count = sum([1 for special_type in settings.special_feeds\
                            if settings.get('feeds', 'show_%s' % special_type) and entry.special_feeds[special_type].unread])
                    else:
                        count = entry.count_feeds(unread_only=True)
                    str_unread = "%d/%d" % (entry.unread, count)
                else:
                    str_unread = "%d" % entry.unread
                unread_rect = painter.boundingRect(option.rect, Qt.AlignRight | Qt.AlignVCenter, str_unread)
                unread_rect.adjust(-8, -3, -2, +3)
                painter.setBrush(palette.highlight())
                painter.setPen(palette.color(palette.Highlight))
                painter.setRenderHint(QPainter.Antialiasing);
                painter.drawRoundedRect(unread_rect, 4, 4);
                painter.setPen(palette.color(palette.HighlightedText))
                painter.drawText(unread_rect, Qt.AlignCenter | Qt.AlignVCenter, str_unread)
                text_rect.adjust(0, 0, -(unread_rect.width()+4), 0)

            # display category/feed title
            painter.restore()
            painter.save()
            text_option = QTextOption(Qt.AlignLeft | Qt.AlignVCenter)
            text_option.setWrapMode(QTextOption.WordWrap)
            painter.setFont(text_font)
            if option.state & QStyle.State_Selected:
                painter.setPen(palette.color(palette.HighlightedText))
            text_rect.adjust(8, 4, 0, -4)
            painter.drawText(QRectF(text_rect), text, text_option)
            
            # draw a bar for unread category/feeds
            if entry.unread:# and not model.view.unread_only:
                bar_option = QStyleOptionViewItemV4(option)
                if is_category:
                    bar_option.rect.setLeft(1)
                else:
                    bar_option.rect.setLeft(16)
                bar_option.rect.setWidth(1)
                bar_option.rect.adjust(0, 1, 0, -1)
                painter.setPen(palette.color(palette.Highlight))
                painter.setBrush(palette.highlight())
                painter.setRenderHint(QPainter.Antialiasing);
                painter.drawRoundedRect(bar_option.rect, 4, 4);

        finally:
            painter.restore()
Esempio n. 30
0
 def update_inputs(self):
     super(SettingsDialog, self).update_inputs()
     
     self.ui.checkSettingsPortraitMode.setChecked(settings.get('other', 'portrait_mode'))
Esempio n. 31
0
 def __init__(self, *args, **kwargs):
     super(WebPage, self).__init__(*args, **kwargs)
     self.user_agent = settings.get('content', 'user_agent')
Esempio n. 32
0
 def banner_delay(self):
     delay = int(settings.get('info', 'banner_hide_delay'))
     len_text = len(self.banner.text())
     if len_text > 50:
         delay += 300 * int(len(self.banner.text())/50)
     return delay