Example #1
0
    def load_calibre_style(self):
        # On OS X QtCurve resets the palette, so we preserve it explicitly
        orig_pal = QPalette(self.palette())

        path = os.path.join(sys.extensions_location,
                            'calibre_style.' + ('pyd' if iswindows else 'so'))
        if not self.pi.load_style(path, 'Calibre'):
            prints('Failed to load calibre style')
        # On OSX, on some machines, colors can be invalid. See https://bugs.launchpad.net/bugs/1014900
        for role in (orig_pal.Button, orig_pal.Window):
            c = orig_pal.brush(role).color()
            if not c.isValid() or not c.toRgb().isValid():
                orig_pal.setColor(role, QColor(u'lightgray'))

        self.setPalette(orig_pal)
        style = self.style()
        icon_map = {}
        pcache = {}
        for k, v in {
                'DialogYesButton': u'ok.png',
                'DialogNoButton': u'window-close.png',
                'DialogCloseButton': u'window-close.png',
                'DialogOkButton': u'ok.png',
                'DialogCancelButton': u'window-close.png',
                'DialogHelpButton': u'help.png',
                'DialogOpenButton': u'document_open.png',
                'DialogSaveButton': u'save.png',
                'DialogApplyButton': u'ok.png',
                'DialogDiscardButton': u'trash.png',
                'MessageBoxInformation': u'dialog_information.png',
                'MessageBoxWarning': u'dialog_warning.png',
                'MessageBoxCritical': u'dialog_error.png',
                'MessageBoxQuestion': u'dialog_question.png',
                'BrowserReload': u'view-refresh.png',
                # These two are used to calculate the sizes for the doc widget
                # title bar buttons, therefore, they have to exist. The actual
                # icon is not used.
                'TitleBarCloseButton': u'window-close.png',
                'TitleBarNormalButton': u'window-close.png',
                'DockWidgetCloseButton': u'window-close.png',
        }.iteritems():
            if v not in pcache:
                p = I(v)
                if isinstance(p, bytes):
                    p = p.decode(filesystem_encoding)
                # if not os.path.exists(p): raise ValueError(p)
                pcache[v] = p
            v = pcache[v]
            icon_map[type('')(getattr(style, 'SP_' + k))] = v
        style.setProperty(u'calibre_icon_map', icon_map)
        self.__icon_map_memory_ = icon_map
Example #2
0
    def load_calibre_style(self):
        # On OS X QtCurve resets the palette, so we preserve it explicitly
        orig_pal = QPalette(self.palette())

        path = os.path.join(sys.extensions_location, 'calibre_style.'+(
            'pyd' if iswindows else 'so'))
        if not self.pi.load_style(path, 'Calibre'):
            prints('Failed to load calibre style')
        # On OSX, on some machines, colors can be invalid. See https://bugs.launchpad.net/bugs/1014900
        for role in (orig_pal.Button, orig_pal.Window):
            c = orig_pal.brush(role).color()
            if not c.isValid() or not c.toRgb().isValid():
                orig_pal.setColor(role, QColor(u'lightgray'))

        self.setPalette(orig_pal)
        style = self.style()
        icon_map = {}
        pcache = {}
        for k, v in {
            'DialogYesButton': u'ok.png',
            'DialogNoButton': u'window-close.png',
            'DialogCloseButton': u'window-close.png',
            'DialogOkButton': u'ok.png',
            'DialogCancelButton': u'window-close.png',
            'DialogHelpButton': u'help.png',
            'DialogOpenButton': u'document_open.png',
            'DialogSaveButton': u'save.png',
            'DialogApplyButton': u'ok.png',
            'DialogDiscardButton': u'trash.png',
            'MessageBoxInformation': u'dialog_information.png',
            'MessageBoxWarning': u'dialog_warning.png',
            'MessageBoxCritical': u'dialog_error.png',
            'MessageBoxQuestion': u'dialog_question.png',
            'BrowserReload': u'view-refresh.png',
            # These two are used to calculate the sizes for the doc widget
            # title bar buttons, therefore, they have to exist. The actual
            # icon is not used.
            'TitleBarCloseButton': u'window-close.png',
            'TitleBarNormalButton': u'window-close.png',
            'DockWidgetCloseButton': u'window-close.png',
        }.iteritems():
            if v not in pcache:
                p = I(v)
                if isinstance(p, bytes):
                    p = p.decode(filesystem_encoding)
                # if not os.path.exists(p): raise ValueError(p)
                pcache[v] = p
            v = pcache[v]
            icon_map[type('')(getattr(style, 'SP_'+k))] = v
        style.setProperty(u'calibre_icon_map', icon_map)
        self.__icon_map_memory_ = icon_map
Example #3
0
    def load_calibre_style(self):
        # On OS X QtCurve resets the palette, so we preserve it explicitly
        orig_pal = QPalette(self.palette())

        from calibre.constants import plugins
        pi = plugins['progress_indicator'][0]
        path = os.path.join(sys.extensions_location,
                            'calibre_style.' + ('pyd' if iswindows else 'so'))
        pi.load_style(path, 'Calibre')
        # On OSX, on some machines, colors can be invalid. See https://bugs.launchpad.net/bugs/1014900
        for role in (orig_pal.Button, orig_pal.Window):
            c = orig_pal.brush(role).color()
            if not c.isValid() or not c.toRgb().isValid():
                orig_pal.setColor(role, QColor(u'lightgray'))

        self.setPalette(orig_pal)
        style = self.style()
        icon_map = {}
        pcache = {}
        for k, v in {
                'DialogYesButton': u'ok.png',
                'DialogNoButton': u'window-close.png',
                'DialogCloseButton': u'window-close.png',
                'DialogOkButton': u'ok.png',
                'DialogCancelButton': u'window-close.png',
                'DialogHelpButton': u'help.png',
                'DialogOpenButton': u'document_open.png',
                'DialogSaveButton': u'save.png',
                'DialogApplyButton': u'ok.png',
                'DialogDiscardButton': u'trash.png',
                'MessageBoxInformation': u'dialog_information.png',
                'MessageBoxWarning': u'dialog_warning.png',
                'MessageBoxCritical': u'dialog_error.png',
                'MessageBoxQuestion': u'dialog_question.png',
        }.iteritems():
            if v not in pcache:
                p = I(v)
                if isinstance(p, bytes):
                    p = p.decode(filesystem_encoding)
                # if not os.path.exists(p): raise ValueError(p)
                pcache[v] = p
            v = pcache[v]
            icon_map[type('')(getattr(style, 'SP_' + k))] = v
        style.setProperty(u'calibre_icon_map', icon_map)
        self.__icon_map_memory_ = icon_map