Exemple #1
0
 def changed(self, field):
     w = self.widgets[field]
     if not w.new.same_as(w.old) and (not self.blank_as_equal
                                      or not w.new.is_blank):
         w.label.setFont(self.changed_font)
     else:
         w.label.setFont(QApplication.font())
Exemple #2
0
    def setupTextActions(self):
        tb = QToolBar(self)
        tb.setWindowTitle("Format Actions")
        self.addToolBar(tb)

        tb = QToolBar(self)
        tb.setAllowedAreas(Qt.TopToolBarArea | Qt.BottomToolBarArea)
        tb.setWindowTitle("Format Actions")
        self.addToolBarBreak(Qt.TopToolBarArea)
        self.addToolBar(tb)

        self.comboFont = QFontComboBox(tb)
        tb.addWidget(self.comboFont)
        self.comboFont.activated[str].connect(self.textFamily)

        self.comboSize = QComboBox(tb)
        self.comboSize.setObjectName("comboSize")
        tb.addWidget(self.comboSize)
        self.comboSize.setEditable(True)

        db = QFontDatabase()
        for size in db.standardSizes():
            self.comboSize.addItem('{}'.format(size))

        self.comboSize.activated[str].connect(self.textSize)
        self.comboSize.setCurrentIndex(self.comboSize.findText('{}'.format(QApplication.font().pointSize())))
Exemple #3
0
    def show_data(self, html):
        def color_to_string(col):
            ans = '#000000'
            if col.isValid():
                col = col.toRgb()
                if col.isValid():
                    ans = unicode_type(col.name())
            return ans

        fi = QFontInfo(QApplication.font(self.parent()))
        f = fi.pixelSize()+1+int(tweaks['change_book_details_font_size_by'])
        fam = unicode_type(fi.family()).strip().replace('"', '')
        if not fam:
            fam = 'sans-serif'

        c = color_to_string(QApplication.palette().color(QPalette.Normal,
                        QPalette.WindowText))
        templ = '''\
        <html>
            <head>
            <style type="text/css">
                body, td {background-color: transparent; font-family: "%s"; font-size: %dpx; color: %s }
                a { text-decoration: none; color: blue }
                div.description { margin-top: 0; padding-top: 0; text-indent: 0 }
                table { margin-bottom: 0; padding-bottom: 0; }
            </style>
            </head>
            <body>
            <div class="description">
            %%s
            </div>
            </body>
        <html>
        '''%(fam, f, c)
        self.setHtml(templ%html)
Exemple #4
0
    def show_data(self, html):
        def color_to_string(col):
            ans = '#000000'
            if col.isValid():
                col = col.toRgb()
                if col.isValid():
                    ans = unicode_type(col.name())
            return ans

        fi = QFontInfo(QApplication.font(self.parent()))
        f = fi.pixelSize()+1+int(tweaks['change_book_details_font_size_by'])
        fam = unicode_type(fi.family()).strip().replace('"', '')
        if not fam:
            fam = 'sans-serif'

        c = color_to_string(QApplication.palette().color(QPalette.Normal,
                        QPalette.WindowText))
        templ = '''\
        <html>
            <head>
            <style type="text/css">
                body, td {background-color: transparent; font-family: "%s"; font-size: %dpx; color: %s }
                a { text-decoration: none; color: blue }
                div.description { margin-top: 0; padding-top: 0; text-indent: 0 }
                table { margin-bottom: 0; padding-bottom: 0; }
            </style>
            </head>
            <body>
            <div class="description">
            %%s
            </div>
            </body>
        <html>
        '''%(fam, f, c)
        self.setHtml(templ%html)
Exemple #5
0
def render_html(mi,
                css,
                vertical,
                widget,
                all_fields=False,
                render_data_func=None):  # {{{
    table, comment_fields = (render_data_func or render_data)(
        mi,
        all_fields=all_fields,
        use_roman_numbers=config['use_roman_numerals_for_series_number'])

    def color_to_string(col):
        ans = '#000000'
        if col.isValid():
            col = col.toRgb()
            if col.isValid():
                ans = unicode(col.name())
        return ans

    fi = QFontInfo(QApplication.font(widget))
    f = fi.pixelSize() + 1 + int(tweaks['change_book_details_font_size_by'])
    fam = unicode(fi.family()).strip().replace('"', '')
    if not fam:
        fam = 'sans-serif'

    c = color_to_string(QApplication.palette().color(QPalette.Normal,
                                                     QPalette.WindowText))
    templ = u'''\
    <html>
        <head>
        <style type="text/css">
            body, td {
                background-color: transparent;
                font-size: %dpx;
                font-family: "%s",sans-serif;
                color: %s
            }
        </style>
        <style type="text/css">
            %s
        </style>
        </head>
        <body>
        %%s
        </body>
    <html>
    ''' % (f, fam, c, css)
    comments = u''
    if comment_fields:
        comments = '\n'.join(u'<div>%s</div>' % x for x in comment_fields)
    right_pane = u'<div id="comments" class="comments">%s</div>' % comments

    if vertical:
        ans = templ % (table + right_pane)
    else:
        ans = templ % (
            u'<table><tr><td valign="top" '
            'style="padding-right:2em; width:40%%">%s</td><td valign="top">%s</td></tr></table>'
            % (table, right_pane))
    return ans
Exemple #6
0
 def _initFonts():
     """Initializes fonts on fitrst call"""
     if SkyModelTreeWidgetItem._fonts is None:
         stdfont = QApplication.font()
         boldfont = QFont(stdfont)
         boldfont.setBold(True)
         SkyModelTreeWidgetItem._fonts = [stdfont, boldfont]
         SkyModelTreeWidgetItem._fontmetrics = QFontMetrics(boldfont)
Exemple #7
0
 def __init__(self, *args, **kwargs):
     QStyledItemDelegate.__init__(self, *args, **kwargs)
     self.rf = QFont(rating_font())
     self.em = Qt.ElideMiddle
     delta = 0
     if iswindows and sys.getwindowsversion().major >= 6:
         delta = 2
     self.rf.setPointSize(QFontInfo(QApplication.font()).pointSize()+delta)
Exemple #8
0
def render_html(mi, css, vertical, widget, all_fields=False, render_data_func=None):  # {{{
    table, comment_fields = (render_data_func or render_data)(
        mi, all_fields=all_fields, use_roman_numbers=config["use_roman_numerals_for_series_number"]
    )

    def color_to_string(col):
        ans = "#000000"
        if col.isValid():
            col = col.toRgb()
            if col.isValid():
                ans = unicode(col.name())
        return ans

    fi = QFontInfo(QApplication.font(widget))
    f = fi.pixelSize() + 1 + int(tweaks["change_book_details_font_size_by"])
    fam = unicode(fi.family()).strip().replace('"', "")
    if not fam:
        fam = "sans-serif"

    c = color_to_string(QApplication.palette().color(QPalette.Normal, QPalette.WindowText))
    templ = u"""\
    <html>
        <head>
        <style type="text/css">
            body, td {
                background-color: transparent;
                font-size: %dpx;
                font-family: "%s",sans-serif;
                color: %s
            }
        </style>
        <style type="text/css">
            %s
        </style>
        </head>
        <body>
        %%s
        </body>
    <html>
    """ % (
        f,
        fam,
        c,
        css,
    )
    comments = u""
    if comment_fields:
        comments = "\n".join(u"<div>%s</div>" % x for x in comment_fields)
    right_pane = u'<div id="comments" class="comments">%s</div>' % comments

    if vertical:
        ans = templ % (table + right_pane)
    else:
        ans = templ % (
            u'<table><tr><td valign="top" '
            'style="padding-right:2em; width:40%%">%s</td><td valign="top">%s</td></tr></table>' % (table, right_pane)
        )
    return ans
Exemple #9
0
 def __init__(self, *args, **kwargs):
     QStyledItemDelegate.__init__(self, *args, **kwargs)
     self.table_widget = args[0]
     self.rf = QFont(rating_font())
     self.em = Qt.ElideMiddle
     delta = 0
     if iswindows and sys.getwindowsversion().major >= 6:
         delta = 2
     self.rf.setPointSize(QFontInfo(QApplication.font()).pointSize()+delta)
Exemple #10
0
 def __init__(self, *args, **kwargs):
     QStyledItemDelegate.__init__(self, *args, **kwargs)
     self.is_half_star = kwargs.get('is_half_star', False)
     self.table_widget = args[0]
     self.rf = QFont(rating_font())
     self.em = Qt.ElideMiddle
     delta = 0
     if iswindows and sys.getwindowsversion().major >= 6:
         delta = 2
     self.rf.setPointSize(QFontInfo(QApplication.font()).pointSize()+delta)
Exemple #11
0
    def __init__(self, args, force_calibre_style=False, override_program_name=None, headless=False, color_prefs=gprefs):
        self.file_event_hook = None
        if override_program_name:
            args = [override_program_name] + args[1:]
        if headless:
            if not args:
                args = sys.argv[:1]
            args.extend(['-platformpluginpath', sys.extensions_location, '-platform', 'headless'])
        qargs = [i.encode('utf-8') if isinstance(i, unicode) else i for i in args]
        self.pi = plugins['progress_indicator'][0]
        QApplication.__init__(self, qargs)
        self.setup_styles(force_calibre_style)
        f = QFont(QApplication.font())
        if (f.family(), f.pointSize()) == ('Sans Serif', 9):  # Hard coded Qt settings, no user preference detected
            f.setPointSize(10)
            QApplication.setFont(f)
        f = QFontInfo(f)
        self.original_font = (f.family(), f.pointSize(), f.weight(), f.italic(), 100)
        if not self.using_calibre_style and self.style().objectName() == 'fusion':
            # Since Qt is using the fusion style anyway, specialize it
            self.load_calibre_style()
        fi = gprefs['font']
        if fi is not None:
            font = QFont(*(fi[:4]))
            s = gprefs.get('font_stretch', None)
            if s is not None:
                font.setStretch(s)
            QApplication.setFont(font)

        dl = QLocale(get_lang())
        if unicode(dl.bcp47Name()) != u'C':
            QLocale.setDefault(dl)
        global gui_thread, qt_app
        gui_thread = QThread.currentThread()
        self._translator = None
        self.load_translations()
        qt_app = self
        self._file_open_paths = []
        self._file_open_lock = RLock()

        if not isosx:
            # OS X uses a native color dialog that does not support custom
            # colors
            self.color_prefs = color_prefs
            self.read_custom_colors()
            self.lastWindowClosed.connect(self.save_custom_colors)

        if isxp:
            error_dialog(None, _('Windows XP not supported'), '<p>' + _(
                'calibre versions newer than 2.0 do not run on Windows XP. This is'
                ' because the graphics toolkit calibre uses (Qt 5) crashes a lot'
                ' on Windows XP. We suggest you stay with <a href="%s">calibre 1.48</a>'
                ' which works well on Windows XP.') % 'http://download.calibre-ebook.com/1.48.0/', show=True)
            raise SystemExit(1)
Exemple #12
0
    def start():
        os.environ['XDG_SESSION_TYPE'] = ""
        app = QApplication(sys.argv)

        f = app.font()
        f.setPointSize(8 if sys.platform[:3] == 'win' else 10)
        app.setFont(f)

        install_translators()
        MainWindow()
        app.exec_()
Exemple #13
0
    def set_font_style(self):
        fi = QFontInfo(QApplication.font(self))
        f  = fi.pixelSize() + 1 + int(tweaks['change_book_details_font_size_by'])
        fam = unicode(fi.family()).strip().replace('"', '')
        if not fam:
            fam = 'sans-serif'
        style = 'font-size: %fpx; font-family:"%s",sans-serif;' % (f, fam)

        # toList() is needed because PyQt on Debian is old/broken
        for body in self.page().mainFrame().documentElement().findAll('body').toList():
            body.setAttribute('style', style)
        self.page().setContentEditable(not self.readonly)
Exemple #14
0
    def set_font_style(self):
        fi = QFontInfo(QApplication.font(self))
        f  = fi.pixelSize() + 1 + int(tweaks['change_book_details_font_size_by'])
        fam = unicode(fi.family()).strip().replace('"', '')
        if not fam:
            fam = 'sans-serif'
        style = 'font-size: %fpx; font-family:"%s",sans-serif;' % (f, fam)

        # toList() is needed because PyQt on Debian is old/broken
        for body in self.page().mainFrame().documentElement().findAll('body').toList():
            body.setAttribute('style', style)
        self.page().setContentEditable(not self.readonly)
Exemple #15
0
    def __init__(self,
                 args,
                 force_calibre_style=False,
                 override_program_name=None,
                 headless=False):
        self.file_event_hook = None
        if override_program_name:
            args = [override_program_name] + args[1:]
        if headless:
            if not args:
                args = sys.argv[:1]
            args.extend([
                '-platformpluginpath', sys.extensions_location, '-platform',
                'headless'
            ])
        qargs = [
            i.encode('utf-8') if isinstance(i, unicode) else i for i in args
        ]
        self.pi = plugins['progress_indicator'][0]
        self.setup_styles(force_calibre_style)
        QApplication.__init__(self, qargs)
        f = QFont(QApplication.font())
        if (f.family(), f.pointSize()) == (
                'Sans Serif',
                9):  # Hard coded Qt settings, no user preference detected
            f.setPointSize(10)
            QApplication.setFont(f)
        f = QFontInfo(f)
        self.original_font = (f.family(), f.pointSize(), f.weight(),
                              f.italic(), 100)
        if not self.using_calibre_style and self.style().objectName(
        ) == 'fusion':
            # Since Qt is using the fusion style anyway, specialize it
            self.load_calibre_style()
        fi = gprefs['font']
        if fi is not None:
            font = QFont(*(fi[:4]))
            s = gprefs.get('font_stretch', None)
            if s is not None:
                font.setStretch(s)
            QApplication.setFont(font)

        dl = QLocale(get_lang())
        if unicode(dl.bcp47Name()) != u'C':
            QLocale.setDefault(dl)
        global gui_thread, qt_app
        gui_thread = QThread.currentThread()
        self._translator = None
        self.load_translations()
        qt_app = self
        self._file_open_paths = []
        self._file_open_lock = RLock()
def main():
    app = QApplication(sys.argv)

    font = app.font()
    if sys.platform.startswith("win"):
        font.setFamily("Microsoft YaHei")
    else:
        font.setFamily("Ubuntu")
    app.setFont(font)

    main_window = MainWindow()
    main_window.setWindowTitle("Image Downloader")
    main_window.show()

    sys.exit(app.exec_())
def main():
    app = QApplication(sys.argv)

    font = app.font()
    if sys.platform.startswith("win"):
        font.setFamily("Microsoft YaHei")
    else:
        font.setFamily("Ubuntu")
    app.setFont(font)

    main_window = MainWindow()
    main_window.setWindowTitle("Image Downloader")
    main_window.show()

    sys.exit(app.exec_())
Exemple #18
0
 def setup_ui_font(self):
     f = QFont(QApplication.font())
     q = (f.family(), f.pointSize())
     if iswindows:
         if q == ('MS Shell Dlg 2', 8):  # Qt default setting
             # Microsoft recommends the default font be Segoe UI at 9 pt
             # https://msdn.microsoft.com/en-us/library/windows/desktop/dn742483(v=vs.85).aspx
             f.setFamily('Segoe UI')
             f.setPointSize(9)
             QApplication.setFont(f)
     else:
         if q == ('Sans Serif', 9):  # Hard coded Qt settings, no user preference detected
             f.setPointSize(10)
             QApplication.setFont(f)
     f = QFontInfo(f)
     self.original_font = (f.family(), f.pointSize(), f.weight(), f.italic(), 100)
Exemple #19
0
    def __init__(self, args, force_calibre_style=False, override_program_name=None, headless=False):
        self.file_event_hook = None
        if override_program_name:
            args = [override_program_name] + args[1:]
        if headless:
            if not args:
                args = sys.argv[:1]
            args.extend(['-platformpluginpath', sys.extensions_location, '-platform', 'headless'])
        qargs = [i.encode('utf-8') if isinstance(i, unicode) else i for i in args]
        self.pi = plugins['progress_indicator'][0]
        self.setup_styles(force_calibre_style)
        QApplication.__init__(self, qargs)
        f = QFont(QApplication.font())
        if (f.family(), f.pointSize()) == ('Sans Serif', 9):  # Hard coded Qt settings, no user preference detected
            f.setPointSize(10)
            QApplication.setFont(f)
        f = QFontInfo(f)
        self.original_font = (f.family(), f.pointSize(), f.weight(), f.italic(), 100)
        if not self.using_calibre_style and self.style().objectName() == 'fusion':
            # Since Qt is using the fusion style anyway, specialize it
            self.load_calibre_style()
        fi = gprefs['font']
        if fi is not None:
            font = QFont(*(fi[:4]))
            s = gprefs.get('font_stretch', None)
            if s is not None:
                font.setStretch(s)
            QApplication.setFont(font)

        dl = QLocale(get_lang())
        if unicode(dl.bcp47Name()) != u'C':
            QLocale.setDefault(dl)
        global gui_thread, qt_app
        gui_thread = QThread.currentThread()
        self._translator = None
        self.load_translations()
        qt_app = self
        self._file_open_paths = []
        self._file_open_lock = RLock()
Exemple #20
0
    def __init__(self, parent=None):
        QAbstractItemModel.__init__(self, parent)
        self.categories = (
            (_('Favorites'), ()),  # {{{
            (_('European scripts'), (
                (_('Armenian'), (0x530, 0x58F)),
                (_('Armenian ligatures'), (0xFB13, 0xFB17)),
                (_('Coptic'), (0x2C80, 0x2CFF)),
                (_('Coptic in Greek block'), (0x3E2, 0x3EF)),
                (_('Cypriot Syllabary'), (0x10800, 0x1083F)),
                (_('Cyrillic'), (0x400, 0x4FF)),
                (_('Cyrillic Supplement'), (0x500, 0x52F)),
                (_('Cyrillic Extended-A'), (0x2DE0, 0x2DFF)),
                (_('Cyrillic Extended-B'), (0xA640, 0xA69F)),
                (_('Georgian'), (0x10A0, 0x10FF)),
                (_('Georgian Supplement'), (0x2D00, 0x2D2F)),
                (_('Glagolitic'), (0x2C00, 0x2C5F)),
                (_('Gothic'), (0x10330, 0x1034F)),
                (_('Greek and Coptic'), (0x370, 0x3FF)),
                (_('Greek Extended'), (0x1F00, 0x1FFF)),
                (_('Latin, Basic & Latin-1 Supplement'), (0x20, 0xFF)),
                (_('Latin Extended-A'), (0x100, 0x17F)),
                (_('Latin Extended-B'), (0x180, 0x24F)),
                (_('Latin Extended-C'), (0x2C60, 0x2C7F)),
                (_('Latin Extended-D'), (0xA720, 0xA7FF)),
                (_('Latin Extended Additional'), (0x1E00, 0x1EFF)),
                (_('Latin ligatures'), (0xFB00, 0xFB06)),
                (_('Fullwidth Latin letters'), (0xFF00, 0xFF5E)),
                (_('Linear B Syllabary'), (0x10000, 0x1007F)),
                (_('Linear B Ideograms'), (0x10080, 0x100FF)),
                (_('Ogham'), (0x1680, 0x169F)),
                (_('Old Italic'), (0x10300, 0x1032F)),
                (_('Phaistos Disc'), (0x101D0, 0x101FF)),
                (_('Runic'), (0x16A0, 0x16FF)),
                (_('Shavian'), (0x10450, 0x1047F)),
            )),
            (_('Phonetic Symbols'), (
                (_('IPA Extensions'), (0x250, 0x2AF)),
                (_('Phonetic Extensions'), (0x1D00, 0x1D7F)),
                (_('Phonetic Extensions Supplement'), (0x1D80, 0x1DBF)),
                (_('Modifier Tone Letters'), (0xA700, 0xA71F)),
                (_('Spacing Modifier Letters'), (0x2B0, 0x2FF)),
                (_('Superscripts and Subscripts'), (0x2070, 0x209F)),
            )),
            (_('Combining Diacritics'), (
                (_('Combining Diacritical Marks'), (0x300, 0x36F)),
                (_('Combining Diacritical Marks for Symbols'), (0x20D0,
                                                                0x20FF)),
                (_('Combining Diacritical Marks Supplement'), (0x1DC0,
                                                               0x1DFF)),
                (_('Combining Half Marks'), (0xFE20, 0xFE2F)),
            )),
            (_('African Scripts'), (
                (_('Bamum'), (0xA6A0, 0xA6FF)),
                (_('Bamum Supplement'), (0x16800, 0x16A3F)),
                (_('Egyptian Hieroglyphs'), (0x13000, 0x1342F)),
                (_('Ethiopic'), (0x1200, 0x137F)),
                (_('Ethiopic Supplement'), (0x1380, 0x139F)),
                (_('Ethiopic Extended'), (0x2D80, 0x2DDF)),
                (_('Ethiopic Extended-A'), (0xAB00, 0xAB2F)),
                (_('Meroitic Cursive'), (0x109A0, 0x109FF)),
                (_('Meroitic Hieroglyphs*'), (0x10980, 0x1099F)),
                (_('N\'Ko'), (0x7C0, 0x7FF)),
                (_('Osmanya'), (0x10480, 0x104AF)),
                (_('Tifinagh'), (0x2D30, 0x2D7F)),
                (_('Vai'), (0xA500, 0xA63F)),
            )),
            (_('Middle Eastern Scripts'), (
                (_('Arabic'), (0x600, 0x6FF)),
                (_('Arabic Supplement'), (0x750, 0x77F)),
                (_('Arabic Extended-A'), (0x8A0, 0x8FF)),
                (_('Arabic Presentation Forms-A'), (0xFB50, 0xFDFF)),
                (_('Arabic Presentation Forms-B'), (0xFE70, 0xFEFF)),
                (_('Avestan'), (0x10B00, 0x10B3F)),
                (_('Carian'), (0x102A0, 0x102DF)),
                (_('Cuneiform'), (0x12000, 0x123FF)),
                (_('Cuneiform Numbers and Punctuation'), (0x12400, 0x1247F)),
                (_('Hebrew'), (0x590, 0x5FF)),
                (_('Hebrew Presentation Forms'), (0xFB1D, 0xFB4F)),
                (_('Imperial Aramaic'), (0x10840, 0x1085F)),
                (_('Inscriptional Pahlavi'), (0x10B60, 0x10B7F)),
                (_('Inscriptional Parthian'), (0x10B40, 0x10B5F)),
                (_('Lycian'), (0x10280, 0x1029F)),
                (_('Lydian'), (0x10920, 0x1093F)),
                (_('Mandaic'), (0x840, 0x85F)),
                (_('Old Persian'), (0x103A0, 0x103DF)),
                (_('Old South Arabian'), (0x10A60, 0x10A7F)),
                (_('Phoenician'), (0x10900, 0x1091F)),
                (_('Samaritan'), (0x800, 0x83F)),
                (_('Syriac'), (0x700, 0x74F)),
                (_('Ugaritic'), (0x10380, 0x1039F)),
            )),
            (_('Central Asian Scripts'), (
                (_('Mongolian'), (0x1800, 0x18AF)),
                (_('Old Turkic'), (0x10C00, 0x10C4F)),
                (_('Phags-pa'), (0xA840, 0xA87F)),
                (_('Tibetan'), (0xF00, 0xFFF)),
            )),
            (_('South Asian Scripts'), (
                (_('Bengali'), (0x980, 0x9FF)),
                (_('Brahmi'), (0x11000, 0x1107F)),
                (_('Chakma'), (0x11100, 0x1114F)),
                (_('Devanagari'), (0x900, 0x97F)),
                (_('Devanagari Extended'), (0xA8E0, 0xA8FF)),
                (_('Gujarati'), (0xA80, 0xAFF)),
                (_('Gurmukhi'), (0xA00, 0xA7F)),
                (_('Kaithi'), (0x11080, 0x110CF)),
                (_('Kannada'), (0xC80, 0xCFF)),
                (_('Kharoshthi'), (0x10A00, 0x10A5F)),
                (_('Lepcha'), (0x1C00, 0x1C4F)),
                (_('Limbu'), (0x1900, 0x194F)),
                (_('Malayalam'), (0xD00, 0xD7F)),
                (_('Meetei Mayek'), (0xABC0, 0xABFF)),
                (_('Meetei Mayek Extensions*'), (0xAAE0, 0xAAEF)),
                (_('Ol Chiki'), (0x1C50, 0x1C7F)),
                (_('Oriya'), (0xB00, 0xB7F)),
                (_('Saurashtra'), (0xA880, 0xA8DF)),
                (_('Sinhala'), (0xD80, 0xDFF)),
                (_('Sharada'), (0x11180, 0x111DF)),
                (_('Sora Sompeng'), (0x110D0, 0x110FF)),
                (_('Syloti Nagri'), (0xA800, 0xA82F)),
                (_('Takri'), (0x11680, 0x116CF)),
                (_('Tamil'), (0xB80, 0xBFF)),
                (_('Telugu'), (0xC00, 0xC7F)),
                (_('Thaana'), (0x780, 0x7BF)),
                (_('Vedic Extensions'), (0x1CD0, 0x1CFF)),
            )),
            (_('Southeast Asian Scripts'), (
                (_('Balinese'), (0x1B00, 0x1B7F)),
                (_('Batak'), (0x1BC0, 0x1BFF)),
                (_('Buginese'), (0x1A00, 0x1A1F)),
                (_('Cham'), (0xAA00, 0xAA5F)),
                (_('Javanese'), (0xA980, 0xA9DF)),
                (_('Kayah Li'), (0xA900, 0xA92F)),
                (_('Khmer'), (0x1780, 0x17FF)),
                (_('Khmer Symbols'), (0x19E0, 0x19FF)),
                (_('Lao'), (0xE80, 0xEFF)),
                (_('Myanmar'), (0x1000, 0x109F)),
                (_('Myanmar Extended-A'), (0xAA60, 0xAA7F)),
                (_('New Tai Lue'), (0x1980, 0x19DF)),
                (_('Rejang'), (0xA930, 0xA95F)),
                (_('Sundanese'), (0x1B80, 0x1BBF)),
                (_('Sundanese Supplement'), (0x1CC0, 0x1CCF)),
                (_('Tai Le'), (0x1950, 0x197F)),
                (_('Tai Tham'), (0x1A20, 0x1AAF)),
                (_('Tai Viet'), (0xAA80, 0xAADF)),
                (_('Thai'), (0xE00, 0xE7F)),
            )),
            (_('Philippine Scripts'), (
                (_('Buhid'), (0x1740, 0x175F)),
                (_('Hanunoo'), (0x1720, 0x173F)),
                (_('Tagalog'), (0x1700, 0x171F)),
                (_('Tagbanwa'), (0x1760, 0x177F)),
            )),
            (_('East Asian Scripts'), (
                (_('Bopomofo'), (0x3100, 0x312F)),
                (_('Bopomofo Extended'), (0x31A0, 0x31BF)),
                (_('CJK Unified Ideographs'), (0x4E00, 0x9FFF)),
                (_('CJK Unified Ideographs Extension-A'), (0x3400, 0x4DBF)),
                (_('CJK Unified Ideographs Extension B'), (0x20000, 0x2A6DF)),
                (_('CJK Unified Ideographs Extension C'), (0x2A700, 0x2B73F)),
                (_('CJK Unified Ideographs Extension D'), (0x2B740, 0x2B81F)),
                (_('CJK Compatibility Ideographs'), (0xF900, 0xFAFF)),
                (_('CJK Compatibility Ideographs Supplement'), (0x2F800,
                                                                0x2FA1F)),
                (_('Kangxi Radicals'), (0x2F00, 0x2FDF)),
                (_('CJK Radicals Supplement'), (0x2E80, 0x2EFF)),
                (_('CJK Strokes'), (0x31C0, 0x31EF)),
                (_('Ideographic Description Characters'), (0x2FF0, 0x2FFF)),
                (_('Hiragana'), (0x3040, 0x309F)),
                (_('Katakana'), (0x30A0, 0x30FF)),
                (_('Katakana Phonetic Extensions'), (0x31F0, 0x31FF)),
                (_('Kana Supplement'), (0x1B000, 0x1B0FF)),
                (_('Halfwidth Katakana'), (0xFF65, 0xFF9F)),
                (_('Kanbun'), (0x3190, 0x319F)),
                (_('Hangul Syllables'), (0xAC00, 0xD7AF)),
                (_('Hangul Jamo'), (0x1100, 0x11FF)),
                (_('Hangul Jamo Extended-A'), (0xA960, 0xA97F)),
                (_('Hangul Jamo Extended-B'), (0xD7B0, 0xD7FF)),
                (_('Hangul Compatibility Jamo'), (0x3130, 0x318F)),
                (_('Halfwidth Jamo'), (0xFFA0, 0xFFDC)),
                (_('Lisu'), (0xA4D0, 0xA4FF)),
                (_('Miao'), (0x16F00, 0x16F9F)),
                (_('Yi Syllables'), (0xA000, 0xA48F)),
                (_('Yi Radicals'), (0xA490, 0xA4CF)),
            )),
            (_('American Scripts'), (
                (_('Cherokee'), (0x13A0, 0x13FF)),
                (_('Deseret'), (0x10400, 0x1044F)),
                (_('Unified Canadian Aboriginal Syllabics'), (0x1400, 0x167F)),
                (_('UCAS Extended'), (0x18B0, 0x18FF)),
            )),
            (_('Other'), (
                (_('Alphabetic Presentation Forms'), (0xFB00, 0xFB4F)),
                (_('Halfwidth and Fullwidth Forms'), (0xFF00, 0xFFEF)),
            )),
            (_('Punctuation'), (
                (_('General Punctuation'), (0x2000, 0x206F)),
                (_('ASCII Punctuation'), (0x21, 0x7F)),
                (_('Cuneiform Numbers and Punctuation'), (0x12400, 0x1247F)),
                (_('Latin-1 Punctuation'), (0xA1, 0xBF)),
                (_('Small Form Variants'), (0xFE50, 0xFE6F)),
                (_('Supplemental Punctuation'), (0x2E00, 0x2E7F)),
                (_('CJK Symbols and Punctuation'), (0x3000, 0x303F)),
                (_('CJK Compatibility Forms'), (0xFE30, 0xFE4F)),
                (_('Fullwidth ASCII Punctuation'), (0xFF01, 0xFF60)),
                (_('Vertical Forms'), (0xFE10, 0xFE1F)),
            )),
            (_('Alphanumeric Symbols'), (
                (_('Arabic Mathematical Alphabetic Symbols'), (0x1EE00,
                                                               0x1EEFF)),
                (_('Letterlike Symbols'), (0x2100, 0x214F)),
                (_('Roman Symbols'), (0x10190, 0x101CF)),
                (_('Mathematical Alphanumeric Symbols'), (0x1D400, 0x1D7FF)),
                (_('Enclosed Alphanumerics'), (0x2460, 0x24FF)),
                (_('Enclosed Alphanumeric Supplement'), (0x1F100, 0x1F1FF)),
                (_('Enclosed CJK Letters and Months'), (0x3200, 0x32FF)),
                (_('Enclosed Ideographic Supplement'), (0x1F200, 0x1F2FF)),
                (_('CJK Compatibility'), (0x3300, 0x33FF)),
            )),
            (_('Technical Symbols'), (
                (_('Miscellaneous Technical'), (0x2300, 0x23FF)),
                (_('Control Pictures'), (0x2400, 0x243F)),
                (_('Optical Character Recognition'), (0x2440, 0x245F)),
            )),
            (_('Numbers and Digits'), (
                (_('Aegean Numbers'), (0x10100, 0x1013F)),
                (_('Ancient Greek Numbers'), (0x10140, 0x1018F)),
                (_('Common Indic Number Forms'), (0xA830, 0xA83F)),
                (_('Counting Rod Numerals'), (0x1D360, 0x1D37F)),
                (_('Cuneiform Numbers and Punctuation'), (0x12400, 0x1247F)),
                (_('Fullwidth ASCII Digits'), (0xFF10, 0xFF19)),
                (_('Number Forms'), (0x2150, 0x218F)),
                (_('Rumi Numeral Symbols'), (0x10E60, 0x10E7F)),
                (_('Superscripts and Subscripts'), (0x2070, 0x209F)),
            )),
            (_('Mathematical Symbols'), (
                (_('Arrows'), (0x2190, 0x21FF)),
                (_('Supplemental Arrows-A'), (0x27F0, 0x27FF)),
                (_('Supplemental Arrows-B'), (0x2900, 0x297F)),
                (_('Miscellaneous Symbols and Arrows'), (0x2B00, 0x2BFF)),
                (_('Mathematical Alphanumeric Symbols'), (0x1D400, 0x1D7FF)),
                (_('Letterlike Symbols'), (0x2100, 0x214F)),
                (_('Mathematical Operators'), (0x2200, 0x22FF)),
                (_('Miscellaneous Mathematical Symbols-A'), (0x27C0, 0x27EF)),
                (_('Miscellaneous Mathematical Symbols-B'), (0x2980, 0x29FF)),
                (_('Supplemental Mathematical Operators'), (0x2A00, 0x2AFF)),
                (_('Ceilings and Floors'), (0x2308, 0x230B)),
                (_('Geometric Shapes'), (0x25A0, 0x25FF)),
                (_('Box Drawing'), (0x2500, 0x257F)),
                (_('Block Elements'), (0x2580, 0x259F)),
            )),
            (_('Musical Symbols'), (
                (_('Musical Symbols'), (0x1D100, 0x1D1FF)),
                (_('More Musical Symbols'), (0x2669, 0x266F)),
                (_('Ancient Greek Musical Notation'), (0x1D200, 0x1D24F)),
                (_('Byzantine Musical Symbols'), (0x1D000, 0x1D0FF)),
            )),
            (_('Game Symbols'), (
                (_('Chess'), (0x2654, 0x265F)),
                (_('Domino Tiles'), (0x1F030, 0x1F09F)),
                (_('Draughts'), (0x26C0, 0x26C3)),
                (_('Japanese Chess'), (0x2616, 0x2617)),
                (_('Mahjong Tiles'), (0x1F000, 0x1F02F)),
                (_('Playing Cards'), (0x1F0A0, 0x1F0FF)),
                (_('Playing Card Suits'), (0x2660, 0x2667)),
            )),
            (_('Other Symbols'), (
                (_('Alchemical Symbols'), (0x1F700, 0x1F77F)),
                (_('Ancient Symbols'), (0x10190, 0x101CF)),
                (_('Braille Patterns'), (0x2800, 0x28FF)),
                (_('Currency Symbols'), (0x20A0, 0x20CF)),
                (_('Combining Diacritical Marks for Symbols'), (0x20D0,
                                                                0x20FF)),
                (_('Dingbats'), (0x2700, 0x27BF)),
                (_('Emoticons'), (0x1F600, 0x1F64F)),
                (_('Miscellaneous Symbols'), (0x2600, 0x26FF)),
                (_('Miscellaneous Symbols and Arrows'), (0x2B00, 0x2BFF)),
                (_('Miscellaneous Symbols And Pictographs'), (0x1F300,
                                                              0x1F5FF)),
                (_('Yijing Hexagram Symbols'), (0x4DC0, 0x4DFF)),
                (_('Yijing Mono and Digrams'), (0x268A, 0x268F)),
                (_('Yijing Trigrams'), (0x2630, 0x2637)),
                (_('Tai Xuan Jing Symbols'), (0x1D300, 0x1D35F)),
                (_('Transport And Map Symbols'), (0x1F680, 0x1F6FF)),
            )),
            (_('Other'), (
                (_('Specials'), (0xFFF0, 0xFFFF)),
                (_('Tags'), (0xE0000, 0xE007F)),
                (_('Variation Selectors'), (0xFE00, 0xFE0F)),
                (_('Variation Selectors Supplement'), (0xE0100, 0xE01EF)),
            )),
        )  # }}}

        self.category_map = {}
        self.starts = []
        for tlname, items in self.categories[1:]:
            for name, (start, end) in items:
                self.category_map[start] = (tlname, name)
                self.starts.append(start)
        self.starts.sort()
        self.bold_font = f = QApplication.font()
        f.setBold(True)
        self.fav_icon = QIcon(I('rating.png'))
Exemple #21
0
def render_html(mi, css, vertical, widget, all_fields=False, render_data_func=None, pref_name='book_display_fields'):  # {{{
    func = render_data_func or render_data
    try:
        table, comment_fields = func(mi, all_fields=all_fields,
                use_roman_numbers=config['use_roman_numerals_for_series_number'], pref_name=pref_name)
    except TypeError:
        table, comment_fields = func(mi, all_fields=all_fields,
                use_roman_numbers=config['use_roman_numerals_for_series_number'])

    def color_to_string(col):
        ans = '#000000'
        if col.isValid():
            col = col.toRgb()
            if col.isValid():
                ans = unicode(col.name())
        return ans

    fi = QFontInfo(QApplication.font(widget))
    f = fi.pixelSize() + 1 + int(tweaks['change_book_details_font_size_by'])
    fam = unicode(fi.family()).strip().replace('"', '')
    if not fam:
        fam = 'sans-serif'

    c = color_to_string(QApplication.palette().color(QPalette.Normal,
                    QPalette.WindowText))
    templ = u'''\
    <html>
        <head>
        <style type="text/css">
            body, td {
                background-color: transparent;
                font-size: %dpx;
                font-family: "%s",sans-serif;
                color: %s
            }
        </style>
        <style type="text/css">
            %s
        </style>
        </head>
        <body>
        %%s
        </body>
    <html>
    '''%(f, fam, c, css)
    comments = u''
    if comment_fields:
        comments = '\n'.join(u'<div>%s</div>' % x for x in comment_fields)
    right_pane = u'<div id="comments" class="comments">%s</div>'%comments

    if vertical:
        ans = templ%(table+right_pane)
    else:
        if gprefs['book_details_narrow_comments_layout'] == 'columns':
            ans = templ%(u'<table><tr><td valign="top" '
                'style="padding-right:2em; width:40%%">%s</td><td valign="top">%s</td></tr></table>'
                    % (table, right_pane))
        else:
            ans = templ%(u'<div style="float: left; margin-right: 1em; margin-bottom: 1em; max-width: 40%">{}</div><div>{}</div>'.format(
                    table, right_pane))
    return ans
Exemple #22
0
 def changed(self, field):
     w = self.widgets[field]
     if not w.new.same_as(w.old) and (not self.blank_as_equal or not w.new.is_blank):
         w.label.setFont(self.changed_font)
     else:
         w.label.setFont(QApplication.font())
Exemple #23
0
    def __init__(
            self, field_metadata, parent=None, revert_tooltip=None,
            datetime_fmt='MMMM yyyy', blank_as_equal=True,
            fields=('title', 'authors', 'series', 'tags', 'rating', 'publisher', 'pubdate', 'identifiers', 'languages', 'comments', 'cover'), db=None):
        QWidget.__init__(self, parent)
        self.l = l = QGridLayout()
        l.setContentsMargins(0, 0, 0, 0)
        self.setLayout(l)
        revert_tooltip = revert_tooltip or _('Revert %s')
        self.current_mi = None
        self.changed_font = QFont(QApplication.font())
        self.changed_font.setBold(True)
        self.changed_font.setItalic(True)
        self.blank_as_equal = blank_as_equal

        self.widgets = OrderedDict()
        row = 0

        for field in fields:
            m = field_metadata[field]
            dt = m['datatype']
            extra = None
            if 'series' in {field, dt}:
                cls = SeriesEdit
            elif field == 'identifiers':
                cls = IdentifiersEdit
            elif field == 'languages':
                cls = LanguagesEdit
            elif 'comments' in {field, dt}:
                cls = CommentsEdit
            elif 'rating' in {field, dt}:
                cls = RatingsEdit
            elif dt == 'datetime':
                extra = datetime_fmt
                cls = DateEdit
            elif field == 'cover':
                cls = CoverView
            elif dt in {'text', 'enum'}:
                cls = LineEdit
            else:
                continue
            neww = cls(field, True, self, m, extra)
            neww.changed.connect(partial(self.changed, field))
            if isinstance(neww, EditWithComplete):
                try:
                    neww.update_items_cache(db.new_api.all_field_names(field))
                except ValueError:
                    pass  # A one-one field like title
            if isinstance(neww, SeriesEdit):
                neww.set_db(db.new_api)
            oldw = cls(field, False, self, m, extra)
            newl = QLabel('&%s:' % m['name'])
            newl.setBuddy(neww)
            button = RightClickButton(self)
            button.setIcon(QIcon(I('back.png')))
            button.clicked.connect(partial(self.revert, field))
            button.setToolTip(revert_tooltip % m['name'])
            if field == 'identifiers':
                button.m = m = QMenu(button)
                button.setMenu(m)
                button.setPopupMode(QToolButton.DelayedPopup)
                m.addAction(button.toolTip()).triggered.connect(button.click)
                m.actions()[0].setIcon(button.icon())
                m.addAction(_('Merge identifiers')).triggered.connect(self.merge_identifiers)
                m.actions()[1].setIcon(QIcon(I('merge.png')))
            elif field == 'tags':
                button.m = m = QMenu(button)
                button.setMenu(m)
                button.setPopupMode(QToolButton.DelayedPopup)
                m.addAction(button.toolTip()).triggered.connect(button.click)
                m.actions()[0].setIcon(button.icon())
                m.addAction(_('Merge tags')).triggered.connect(self.merge_tags)
                m.actions()[1].setIcon(QIcon(I('merge.png')))

            self.widgets[field] = Widgets(neww, oldw, newl, button)
            for i, w in enumerate((newl, neww, button, oldw)):
                c = i if i < 2 else i + 1
                if w is oldw:
                    c += 1
                l.addWidget(w, row, c)
            row += 1

        self.sep = f = QFrame(self)
        f.setFrameShape(f.VLine)
        l.addWidget(f, 0, 2, row, 1)
        self.sep2 = f = QFrame(self)
        f.setFrameShape(f.VLine)
        l.addWidget(f, 0, 4, row, 1)
        if 'comments' in self.widgets and not gprefs.get('diff_widget_show_comments_controls', True):
            self.widgets['comments'].new.hide_toolbars()
Exemple #24
0
    def __init__(self, args, force_calibre_style=False, override_program_name=None, headless=False, color_prefs=gprefs):
        self.file_event_hook = None
        if override_program_name:
            args = [override_program_name] + args[1:]
        if headless:
            if not args:
                args = sys.argv[:1]
            args.extend(['-platformpluginpath', sys.extensions_location, '-platform', 'headless'])
        self.headless = headless
        qargs = [i.encode('utf-8') if isinstance(i, unicode) else i for i in args]
        self.pi = plugins['progress_indicator'][0]
        QApplication.__init__(self, qargs)
        if islinux or isbsd:
            self.setAttribute(Qt.AA_DontUseNativeMenuBar, 'CALIBRE_NO_NATIVE_MENUBAR' in os.environ)
        self.setup_styles(force_calibre_style)
        f = QFont(QApplication.font())
        if (f.family(), f.pointSize()) == ('Sans Serif', 9):  # Hard coded Qt settings, no user preference detected
            f.setPointSize(10)
            QApplication.setFont(f)
        f = QFontInfo(f)
        self.original_font = (f.family(), f.pointSize(), f.weight(), f.italic(), 100)
        if not self.using_calibre_style and self.style().objectName() == 'fusion':
            # Since Qt is using the fusion style anyway, specialize it
            self.load_calibre_style()
        fi = gprefs['font']
        if fi is not None:
            font = QFont(*(fi[:4]))
            s = gprefs.get('font_stretch', None)
            if s is not None:
                font.setStretch(s)
            QApplication.setFont(font)

        dl = QLocale(get_lang())
        if unicode(dl.bcp47Name()) != u'C':
            QLocale.setDefault(dl)
        global gui_thread, qt_app
        gui_thread = QThread.currentThread()
        self._translator = None
        self.load_translations()
        qt_app = self
        self._file_open_paths = []
        self._file_open_lock = RLock()

        if not isosx:
            # OS X uses a native color dialog that does not support custom
            # colors
            self.color_prefs = color_prefs
            self.read_custom_colors()
            self.lastWindowClosed.connect(self.save_custom_colors)

        if isxp:
            error_dialog(None, _('Windows XP not supported'), '<p>' + _(
                'calibre versions newer than 2.0 do not run on Windows XP. This is'
                ' because the graphics toolkit calibre uses (Qt 5) crashes a lot'
                ' on Windows XP. We suggest you stay with <a href="%s">calibre 1.48</a>'
                ' which works well on Windows XP.') % 'http://download.calibre-ebook.com/1.48.0/', show=True)
            raise SystemExit(1)

        if iswindows:
            # On windows the highlighted colors for inactive widgets are the
            # same as non highlighted colors. This is a regression from Qt 4.
            # https://bugreports.qt-project.org/browse/QTBUG-41060
            p = self.palette()
            for role in (p.Highlight, p.HighlightedText, p.Base, p.AlternateBase):
                p.setColor(p.Inactive, role, p.color(p.Active, role))
            self.setPalette(p)

            # Prevent text copied to the clipboard from being lost on quit due to
            # Qt 5 bug: https://bugreports.qt-project.org/browse/QTBUG-41125
            self.aboutToQuit.connect(self.flush_clipboard)
Exemple #25
0
    def __init__(
            self, field_metadata, parent=None, revert_tooltip=None,
            datetime_fmt='MMMM yyyy', blank_as_equal=True,
            fields=('title', 'authors', 'series', 'tags', 'rating', 'publisher', 'pubdate', 'identifiers', 'languages', 'comments', 'cover')):
        QWidget.__init__(self, parent)
        self.l = l = QGridLayout()
        l.setContentsMargins(0, 0, 0, 0)
        self.setLayout(l)
        revert_tooltip = revert_tooltip or _('Revert %s')
        self.current_mi = None
        self.changed_font = QFont(QApplication.font())
        self.changed_font.setBold(True)
        self.changed_font.setItalic(True)
        self.blank_as_equal = blank_as_equal

        self.widgets = OrderedDict()
        row = 0

        for field in fields:
            m = field_metadata[field]
            dt = m['datatype']
            extra = None
            if 'series' in {field, dt}:
                cls = SeriesEdit
            elif field == 'identifiers':
                cls = IdentifiersEdit
            elif field == 'languages':
                cls = LanguagesEdit
            elif 'comments' in {field, dt}:
                cls = CommentsEdit
            elif 'rating' in {field, dt}:
                cls = RatingsEdit
            elif dt == 'datetime':
                extra = datetime_fmt
                cls = DateEdit
            elif field == 'cover':
                cls = CoverView
            elif dt in {'text', 'enum'}:
                cls = LineEdit
            else:
                continue
            neww = cls(field, True, self, m, extra)
            neww.changed.connect(partial(self.changed, field))
            oldw = cls(field, False, self, m, extra)
            newl = QLabel('&%s:' % m['name'])
            newl.setBuddy(neww)
            button = QToolButton(self)
            button.setIcon(QIcon(I('back.png')))
            button.clicked.connect(partial(self.revert, field))
            button.setToolTip(revert_tooltip % m['name'])
            self.widgets[field] = Widgets(neww, oldw, newl, button)
            for i, w in enumerate((newl, neww, button, oldw)):
                c = i if i < 2 else i + 1
                if w is oldw:
                    c += 1
                l.addWidget(w, row, c)
            row += 1

        self.sep = f = QFrame(self)
        f.setFrameShape(f.VLine)
        l.addWidget(f, 0, 2, row, 1)
        self.sep2 = f = QFrame(self)
        f.setFrameShape(f.VLine)
        l.addWidget(f, 0, 4, row, 1)
        if 'comments' in self.widgets and not gprefs.get('diff_widget_show_comments_controls', True):
            self.widgets['comments'].new.hide_toolbars()
Exemple #26
0
 def _setupHistogramPlot(self):
     self._histplot.setCanvasBackground(QColor("lightgray"))
     self._histplot.setAxisFont(QwtPlot.yLeft, QApplication.font())
     self._histplot.setAxisFont(QwtPlot.xBottom, QApplication.font())
     # add histogram curves
     self._histcurve1 = TiggerPlotCurve()
     self._histcurve1.setRenderHint(QwtPlotItem.RenderAntialiased)
     self._histcurve2 = TiggerPlotCurve()
     self._histcurve2.setRenderHint(QwtPlotItem.RenderAntialiased)
     self._histcurve1.setStyle(QwtPlotCurve.Steps)
     self._histcurve2.setStyle(QwtPlotCurve.Steps)
     self._histcurve1.setPen(QPen(Qt.NoPen))
     self._histcurve1.setBrush(QBrush(QColor("slategrey")))
     pen = QPen(QColor("red"))
     pen.setWidth(1)
     self._histcurve2.setPen(pen)
     self._histcurve1.setZ(0)
     self._histcurve2.setZ(100)
     #    self._histcurve1.attach(self._histplot)
     self._histcurve2.attach(self._histplot)
     # add maxbin and half-max curves
     self._line_0 = self.HistogramLineMarker(self._histplot, color="grey50", linestyle=Qt.SolidLine,
                                             align=Qt.AlignTop | Qt.AlignLeft, z=90)
     self._line_mean = self.HistogramLineMarker(self._histplot, color="black", linestyle=Qt.SolidLine,
                                                align=Qt.AlignBottom | Qt.AlignRight, z=91,
                                                label="mean", zlabel=151)
     self._line_std = self.HistogramLineMarker(self._histplot, color="black", linestyle=Qt.SolidLine,
                                               align=Qt.AlignTop | Qt.AlignRight, z=91,
                                               label="std", zlabel=151)
     sym = QwtSymbol()
     sym.setStyle(QwtSymbol.VLine)
     sym.setSize(8)
     self._line_std.line.setSymbol(sym)
     self._line_maxbin = self.HistogramLineMarker(self._histplot, color="green", linestyle=Qt.DotLine,
                                                  align=Qt.AlignTop | Qt.AlignRight, z=92,
                                                  label="max bin", zlabel=150)
     self._line_halfmax = self.HistogramLineMarker(self._histplot, color="green", linestyle=Qt.DotLine,
                                                   align=Qt.AlignBottom | Qt.AlignRight, z=90,
                                                   label="half-max", yaxis=QwtPlot.yLeft)
     # add current range
     self._rangebox = TiggerPlotCurve()
     self._rangebox.setRenderHint(QwtPlotItem.RenderAntialiased)
     self._rangebox.setStyle(QwtPlotCurve.Steps)
     self._rangebox.setYAxis(QwtPlot.yRight)
     self._rangebox.setPen(QPen(Qt.NoPen))
     self._rangebox.setBrush(QBrush(QColor("darkgray")))
     self._rangebox.setZ(50)
     self._rangebox.attach(self._histplot)
     self._rangebox2 = TiggerPlotCurve()
     self._rangebox2.setRenderHint(QwtPlotItem.RenderAntialiased)
     self._rangebox2.setStyle(QwtPlotCurve.Sticks)
     self._rangebox2.setYAxis(QwtPlot.yRight)
     self._rangebox2.setZ(60)
     #  self._rangebox2.attach(self._histplot)
     # add intensity transfer function
     self._itfcurve = TiggerPlotCurve()
     self._itfcurve.setRenderHint(QwtPlotItem.RenderAntialiased)
     self._itfcurve.setStyle(QwtPlotCurve.Lines)
     self._itfcurve.setPen(QPen(QColor("blue")))
     self._itfcurve.setYAxis(QwtPlot.yRight)
     self._itfcurve.setZ(120)
     self._itfcurve.attach(self._histplot)
     self._itfmarker = TiggerPlotMarker()
     self._itfmarker.setRenderHint(QwtPlotItem.RenderAntialiased)
     label = QwtText("ITF")
     label.setColor(QColor("blue"))
     self._itfmarker.setLabel(label)
     try:
         self._itfmarker.setSpacing(0)
     except AttributeError:
         pass
     self._itfmarker.setLabelAlignment(Qt.AlignTop | Qt.AlignRight)
     self._itfmarker.setZ(120)
     self._itfmarker.attach(self._histplot)
     # add colorbar
     self._cb_item = self.ColorBarPlotItem(1, 1 + self.ColorBarHeight)
     self._cb_item.setYAxis(QwtPlot.yRight)
     self._cb_item.attach(self._histplot)
     # add pickers
     self._hist_minpicker = self.HistLimitPicker(self._histplot, "low: %(x).4g")
     self._hist_minpicker.setMousePattern(QwtEventPattern.MouseSelect1, Qt.LeftButton)
     self._hist_minpicker.selected.connect(self._selectLowLimit)
     self._hist_maxpicker = self.HistLimitPicker(self._histplot, "high: %(x).4g")
     self._hist_maxpicker.setMousePattern(QwtEventPattern.MouseSelect1, Qt.RightButton)
     self._hist_maxpicker.selected.connect(self._selectHighLimit)
     self._hist_maxpicker1 = self.HistLimitPicker(self._histplot, "high: %(x).4g")
     self._hist_maxpicker1.setMousePattern(QwtEventPattern.MouseSelect1, Qt.LeftButton, Qt.ControlModifier)
     self._hist_maxpicker1.selected.connect(self._selectHighLimit)
     self._hist_zoompicker = self.HistLimitPicker(self._histplot, label="zoom",
                                                  tracker_mode=QwtPicker.AlwaysOn, track=self._trackHistCoordinates,
                                                  color="black",
                                                  mode=QwtPickerClickRectMachine(),
                                                  rubber_band=QwtPicker.RectRubberBand)
     self._hist_zoompicker.setMousePattern(QwtEventPattern.MouseSelect1, Qt.LeftButton, Qt.ShiftModifier)
     # self._hist_zoompicker.selected[QRectF].connect(self._zoomHistogramIntoRect)
     self._hist_zoompicker.selected.connect(self._zoomHistogramIntoRect)
Exemple #27
0
    def __init__(self,
                 field_metadata,
                 parent=None,
                 revert_tooltip=None,
                 datetime_fmt='MMMM yyyy',
                 blank_as_equal=True,
                 fields=('title', 'authors', 'series', 'tags', 'rating',
                         'publisher', 'pubdate', 'identifiers', 'languages',
                         'comments', 'cover')):
        QWidget.__init__(self, parent)
        self.l = l = QGridLayout()
        l.setContentsMargins(0, 0, 0, 0)
        self.setLayout(l)
        revert_tooltip = revert_tooltip or _('Revert %s')
        self.current_mi = None
        self.changed_font = QFont(QApplication.font())
        self.changed_font.setBold(True)
        self.changed_font.setItalic(True)
        self.blank_as_equal = blank_as_equal

        self.widgets = OrderedDict()
        row = 0

        for field in fields:
            m = field_metadata[field]
            dt = m['datatype']
            extra = None
            if 'series' in {field, dt}:
                cls = SeriesEdit
            elif field == 'identifiers':
                cls = IdentifiersEdit
            elif field == 'languages':
                cls = LanguagesEdit
            elif 'comments' in {field, dt}:
                cls = CommentsEdit
            elif 'rating' in {field, dt}:
                cls = RatingsEdit
            elif dt == 'datetime':
                extra = datetime_fmt
                cls = DateEdit
            elif field == 'cover':
                cls = CoverView
            elif dt in {'text', 'enum'}:
                cls = LineEdit
            else:
                continue
            neww = cls(field, True, self, m, extra)
            neww.changed.connect(partial(self.changed, field))
            oldw = cls(field, False, self, m, extra)
            newl = QLabel('&%s:' % m['name'])
            newl.setBuddy(neww)
            button = QToolButton(self)
            button.setIcon(QIcon(I('back.png')))
            button.clicked.connect(partial(self.revert, field))
            button.setToolTip(revert_tooltip % m['name'])
            self.widgets[field] = Widgets(neww, oldw, newl, button)
            for i, w in enumerate((newl, neww, button, oldw)):
                c = i if i < 2 else i + 1
                if w is oldw:
                    c += 1
                l.addWidget(w, row, c)
            row += 1

        self.sep = f = QFrame(self)
        f.setFrameShape(f.VLine)
        l.addWidget(f, 0, 2, row, 1)
        self.sep2 = f = QFrame(self)
        f.setFrameShape(f.VLine)
        l.addWidget(f, 0, 4, row, 1)
        if 'comments' in self.widgets and not gprefs.get(
                'diff_widget_show_comments_controls', True):
            self.widgets['comments'].new.hide_toolbars()
Exemple #28
0
    def __init__(self,
                 field_metadata,
                 parent=None,
                 revert_tooltip=None,
                 datetime_fmt='MMMM yyyy',
                 blank_as_equal=True,
                 fields=('title', 'authors', 'series', 'tags', 'rating',
                         'publisher', 'pubdate', 'identifiers', 'languages',
                         'comments', 'cover'),
                 db=None):
        QWidget.__init__(self, parent)
        self.l = l = QGridLayout()
        l.setContentsMargins(0, 0, 0, 0)
        self.setLayout(l)
        revert_tooltip = revert_tooltip or _('Revert %s')
        self.current_mi = None
        self.changed_font = QFont(QApplication.font())
        self.changed_font.setBold(True)
        self.changed_font.setItalic(True)
        self.blank_as_equal = blank_as_equal

        self.widgets = OrderedDict()
        row = 0

        for field in fields:
            m = field_metadata[field]
            dt = m['datatype']
            extra = None
            if 'series' in {field, dt}:
                cls = SeriesEdit
            elif field == 'identifiers':
                cls = IdentifiersEdit
            elif field == 'languages':
                cls = LanguagesEdit
            elif 'comments' in {field, dt}:
                cls = CommentsEdit
            elif 'rating' in {field, dt}:
                cls = RatingsEdit
            elif dt == 'datetime':
                extra = datetime_fmt
                cls = DateEdit
            elif field == 'cover':
                cls = CoverView
            elif dt in {'text', 'enum'}:
                cls = LineEdit
            else:
                continue
            neww = cls(field, True, self, m, extra)
            neww.changed.connect(partial(self.changed, field))
            if isinstance(neww, EditWithComplete):
                try:
                    neww.update_items_cache(db.new_api.all_field_names(field))
                except ValueError:
                    pass  # A one-one field like title
            if isinstance(neww, SeriesEdit):
                neww.set_db(db.new_api)
            oldw = cls(field, False, self, m, extra)
            newl = QLabel('&%s:' % m['name'])
            newl.setBuddy(neww)
            button = RightClickButton(self)
            button.setIcon(QIcon(I('back.png')))
            button.clicked.connect(partial(self.revert, field))
            button.setToolTip(revert_tooltip % m['name'])
            if field == 'identifiers':
                button.m = m = QMenu(button)
                button.setMenu(m)
                button.setPopupMode(QToolButton.DelayedPopup)
                m.addAction(button.toolTip()).triggered.connect(button.click)
                m.actions()[0].setIcon(button.icon())
                m.addAction(_('Merge identifiers')).triggered.connect(
                    self.merge_identifiers)
                m.actions()[1].setIcon(QIcon(I('merge.png')))
            elif field == 'tags':
                button.m = m = QMenu(button)
                button.setMenu(m)
                button.setPopupMode(QToolButton.DelayedPopup)
                m.addAction(button.toolTip()).triggered.connect(button.click)
                m.actions()[0].setIcon(button.icon())
                m.addAction(_('Merge tags')).triggered.connect(self.merge_tags)
                m.actions()[1].setIcon(QIcon(I('merge.png')))

            self.widgets[field] = Widgets(neww, oldw, newl, button)
            for i, w in enumerate((newl, neww, button, oldw)):
                c = i if i < 2 else i + 1
                if w is oldw:
                    c += 1
                l.addWidget(w, row, c)
            row += 1

        self.sep = f = QFrame(self)
        f.setFrameShape(f.VLine)
        l.addWidget(f, 0, 2, row, 1)
        self.sep2 = f = QFrame(self)
        f.setFrameShape(f.VLine)
        l.addWidget(f, 0, 4, row, 1)
        if 'comments' in self.widgets and not gprefs.get(
                'diff_widget_show_comments_controls', True):
            self.widgets['comments'].new.hide_toolbars()
Exemple #29
0
    def __init__(self, parent=None):
        QAbstractItemModel.__init__(self, parent)
        self.categories = (
            (_("Favorites"), ()),  # {{{
            (
                _("European scripts"),
                (
                    (_("Armenian"), (0x530, 0x58F)),
                    (_("Armenian ligatures"), (0xFB13, 0xFB17)),
                    (_("Coptic"), (0x2C80, 0x2CFF)),
                    (_("Coptic in Greek block"), (0x3E2, 0x3EF)),
                    (_("Cypriot Syllabary"), (0x10800, 0x1083F)),
                    (_("Cyrillic"), (0x400, 0x4FF)),
                    (_("Cyrillic Supplement"), (0x500, 0x52F)),
                    (_("Cyrillic Extended-A"), (0x2DE0, 0x2DFF)),
                    (_("Cyrillic Extended-B"), (0xA640, 0xA69F)),
                    (_("Georgian"), (0x10A0, 0x10FF)),
                    (_("Georgian Supplement"), (0x2D00, 0x2D2F)),
                    (_("Glagolitic"), (0x2C00, 0x2C5F)),
                    (_("Gothic"), (0x10330, 0x1034F)),
                    (_("Greek and Coptic"), (0x370, 0x3FF)),
                    (_("Greek Extended"), (0x1F00, 0x1FFF)),
                    (_("Latin, Basic & Latin-1 Supplement"), (0x20, 0xFF)),
                    (_("Latin Extended-A"), (0x100, 0x17F)),
                    (_("Latin Extended-B"), (0x180, 0x24F)),
                    (_("Latin Extended-C"), (0x2C60, 0x2C7F)),
                    (_("Latin Extended-D"), (0xA720, 0xA7FF)),
                    (_("Latin Extended Additional"), (0x1E00, 0x1EFF)),
                    (_("Latin ligatures"), (0xFB00, 0xFB06)),
                    (_("Fullwidth Latin letters"), (0xFF00, 0xFF5E)),
                    (_("Linear B Syllabary"), (0x10000, 0x1007F)),
                    (_("Linear B Ideograms"), (0x10080, 0x100FF)),
                    (_("Ogham"), (0x1680, 0x169F)),
                    (_("Old Italic"), (0x10300, 0x1032F)),
                    (_("Phaistos Disc"), (0x101D0, 0x101FF)),
                    (_("Runic"), (0x16A0, 0x16FF)),
                    (_("Shavian"), (0x10450, 0x1047F)),
                ),
            ),
            (
                _("Phonetic Symbols"),
                (
                    (_("IPA Extensions"), (0x250, 0x2AF)),
                    (_("Phonetic Extensions"), (0x1D00, 0x1D7F)),
                    (_("Phonetic Extensions Supplement"), (0x1D80, 0x1DBF)),
                    (_("Modifier Tone Letters"), (0xA700, 0xA71F)),
                    (_("Spacing Modifier Letters"), (0x2B0, 0x2FF)),
                    (_("Superscripts and Subscripts"), (0x2070, 0x209F)),
                ),
            ),
            (
                _("Combining Diacritics"),
                (
                    (_("Combining Diacritical Marks"), (0x300, 0x36F)),
                    (_("Combining Diacritical Marks for Symbols"), (0x20D0, 0x20FF)),
                    (_("Combining Diacritical Marks Supplement"), (0x1DC0, 0x1DFF)),
                    (_("Combining Half Marks"), (0xFE20, 0xFE2F)),
                ),
            ),
            (
                _("African Scripts"),
                (
                    (_("Bamum"), (0xA6A0, 0xA6FF)),
                    (_("Bamum Supplement"), (0x16800, 0x16A3F)),
                    (_("Egyptian Hieroglyphs"), (0x13000, 0x1342F)),
                    (_("Ethiopic"), (0x1200, 0x137F)),
                    (_("Ethiopic Supplement"), (0x1380, 0x139F)),
                    (_("Ethiopic Extended"), (0x2D80, 0x2DDF)),
                    (_("Ethiopic Extended-A"), (0xAB00, 0xAB2F)),
                    (_("Meroitic Cursive"), (0x109A0, 0x109FF)),
                    (_("Meroitic Hieroglyphs*"), (0x10980, 0x1099F)),
                    (_("N'Ko"), (0x7C0, 0x7FF)),
                    (_("Osmanya"), (0x10480, 0x104AF)),
                    (_("Tifinagh"), (0x2D30, 0x2D7F)),
                    (_("Vai"), (0xA500, 0xA63F)),
                ),
            ),
            (
                _("Middle Eastern Scripts"),
                (
                    (_("Arabic"), (0x600, 0x6FF)),
                    (_("Arabic Supplement"), (0x750, 0x77F)),
                    (_("Arabic Extended-A"), (0x8A0, 0x8FF)),
                    (_("Arabic Presentation Forms-A"), (0xFB50, 0xFDFF)),
                    (_("Arabic Presentation Forms-B"), (0xFE70, 0xFEFF)),
                    (_("Avestan"), (0x10B00, 0x10B3F)),
                    (_("Carian"), (0x102A0, 0x102DF)),
                    (_("Cuneiform"), (0x12000, 0x123FF)),
                    (_("Cuneiform Numbers and Punctuation"), (0x12400, 0x1247F)),
                    (_("Hebrew"), (0x590, 0x5FF)),
                    (_("Hebrew Presentation Forms"), (0xFB1D, 0xFB4F)),
                    (_("Imperial Aramaic"), (0x10840, 0x1085F)),
                    (_("Inscriptional Pahlavi"), (0x10B60, 0x10B7F)),
                    (_("Inscriptional Parthian"), (0x10B40, 0x10B5F)),
                    (_("Lycian"), (0x10280, 0x1029F)),
                    (_("Lydian"), (0x10920, 0x1093F)),
                    (_("Mandaic"), (0x840, 0x85F)),
                    (_("Old Persian"), (0x103A0, 0x103DF)),
                    (_("Old South Arabian"), (0x10A60, 0x10A7F)),
                    (_("Phoenician"), (0x10900, 0x1091F)),
                    (_("Samaritan"), (0x800, 0x83F)),
                    (_("Syriac"), (0x700, 0x74F)),
                    (_("Ugaritic"), (0x10380, 0x1039F)),
                ),
            ),
            (
                _("Central Asian Scripts"),
                (
                    (_("Mongolian"), (0x1800, 0x18AF)),
                    (_("Old Turkic"), (0x10C00, 0x10C4F)),
                    (_("Phags-pa"), (0xA840, 0xA87F)),
                    (_("Tibetan"), (0xF00, 0xFFF)),
                ),
            ),
            (
                _("South Asian Scripts"),
                (
                    (_("Bengali"), (0x980, 0x9FF)),
                    (_("Brahmi"), (0x11000, 0x1107F)),
                    (_("Chakma"), (0x11100, 0x1114F)),
                    (_("Devanagari"), (0x900, 0x97F)),
                    (_("Devanagari Extended"), (0xA8E0, 0xA8FF)),
                    (_("Gujarati"), (0xA80, 0xAFF)),
                    (_("Gurmukhi"), (0xA00, 0xA7F)),
                    (_("Kaithi"), (0x11080, 0x110CF)),
                    (_("Kannada"), (0xC80, 0xCFF)),
                    (_("Kharoshthi"), (0x10A00, 0x10A5F)),
                    (_("Lepcha"), (0x1C00, 0x1C4F)),
                    (_("Limbu"), (0x1900, 0x194F)),
                    (_("Malayalam"), (0xD00, 0xD7F)),
                    (_("Meetei Mayek"), (0xABC0, 0xABFF)),
                    (_("Meetei Mayek Extensions*"), (0xAAE0, 0xAAEF)),
                    (_("Ol Chiki"), (0x1C50, 0x1C7F)),
                    (_("Oriya"), (0xB00, 0xB7F)),
                    (_("Saurashtra"), (0xA880, 0xA8DF)),
                    (_("Sinhala"), (0xD80, 0xDFF)),
                    (_("Sharada"), (0x11180, 0x111DF)),
                    (_("Sora Sompeng"), (0x110D0, 0x110FF)),
                    (_("Syloti Nagri"), (0xA800, 0xA82F)),
                    (_("Takri"), (0x11680, 0x116CF)),
                    (_("Tamil"), (0xB80, 0xBFF)),
                    (_("Telugu"), (0xC00, 0xC7F)),
                    (_("Thaana"), (0x780, 0x7BF)),
                    (_("Vedic Extensions"), (0x1CD0, 0x1CFF)),
                ),
            ),
            (
                _("Southeast Asian Scripts"),
                (
                    (_("Balinese"), (0x1B00, 0x1B7F)),
                    (_("Batak"), (0x1BC0, 0x1BFF)),
                    (_("Buginese"), (0x1A00, 0x1A1F)),
                    (_("Cham"), (0xAA00, 0xAA5F)),
                    (_("Javanese"), (0xA980, 0xA9DF)),
                    (_("Kayah Li"), (0xA900, 0xA92F)),
                    (_("Khmer"), (0x1780, 0x17FF)),
                    (_("Khmer Symbols"), (0x19E0, 0x19FF)),
                    (_("Lao"), (0xE80, 0xEFF)),
                    (_("Myanmar"), (0x1000, 0x109F)),
                    (_("Myanmar Extended-A"), (0xAA60, 0xAA7F)),
                    (_("New Tai Lue"), (0x1980, 0x19DF)),
                    (_("Rejang"), (0xA930, 0xA95F)),
                    (_("Sundanese"), (0x1B80, 0x1BBF)),
                    (_("Sundanese Supplement"), (0x1CC0, 0x1CCF)),
                    (_("Tai Le"), (0x1950, 0x197F)),
                    (_("Tai Tham"), (0x1A20, 0x1AAF)),
                    (_("Tai Viet"), (0xAA80, 0xAADF)),
                    (_("Thai"), (0xE00, 0xE7F)),
                ),
            ),
            (
                _("Philippine Scripts"),
                (
                    (_("Buhid"), (0x1740, 0x175F)),
                    (_("Hanunoo"), (0x1720, 0x173F)),
                    (_("Tagalog"), (0x1700, 0x171F)),
                    (_("Tagbanwa"), (0x1760, 0x177F)),
                ),
            ),
            (
                _("East Asian Scripts"),
                (
                    (_("Bopomofo"), (0x3100, 0x312F)),
                    (_("Bopomofo Extended"), (0x31A0, 0x31BF)),
                    (_("CJK Unified Ideographs"), (0x4E00, 0x9FFF)),
                    (_("CJK Unified Ideographs Extension-A"), (0x3400, 0x4DBF)),
                    (_("CJK Unified Ideographs Extension B"), (0x20000, 0x2A6DF)),
                    (_("CJK Unified Ideographs Extension C"), (0x2A700, 0x2B73F)),
                    (_("CJK Unified Ideographs Extension D"), (0x2B740, 0x2B81F)),
                    (_("CJK Compatibility Ideographs"), (0xF900, 0xFAFF)),
                    (_("CJK Compatibility Ideographs Supplement"), (0x2F800, 0x2FA1F)),
                    (_("Kangxi Radicals"), (0x2F00, 0x2FDF)),
                    (_("CJK Radicals Supplement"), (0x2E80, 0x2EFF)),
                    (_("CJK Strokes"), (0x31C0, 0x31EF)),
                    (_("Ideographic Description Characters"), (0x2FF0, 0x2FFF)),
                    (_("Hiragana"), (0x3040, 0x309F)),
                    (_("Katakana"), (0x30A0, 0x30FF)),
                    (_("Katakana Phonetic Extensions"), (0x31F0, 0x31FF)),
                    (_("Kana Supplement"), (0x1B000, 0x1B0FF)),
                    (_("Halfwidth Katakana"), (0xFF65, 0xFF9F)),
                    (_("Kanbun"), (0x3190, 0x319F)),
                    (_("Hangul Syllables"), (0xAC00, 0xD7AF)),
                    (_("Hangul Jamo"), (0x1100, 0x11FF)),
                    (_("Hangul Jamo Extended-A"), (0xA960, 0xA97F)),
                    (_("Hangul Jamo Extended-B"), (0xD7B0, 0xD7FF)),
                    (_("Hangul Compatibility Jamo"), (0x3130, 0x318F)),
                    (_("Halfwidth Jamo"), (0xFFA0, 0xFFDC)),
                    (_("Lisu"), (0xA4D0, 0xA4FF)),
                    (_("Miao"), (0x16F00, 0x16F9F)),
                    (_("Yi Syllables"), (0xA000, 0xA48F)),
                    (_("Yi Radicals"), (0xA490, 0xA4CF)),
                ),
            ),
            (
                _("American Scripts"),
                (
                    (_("Cherokee"), (0x13A0, 0x13FF)),
                    (_("Deseret"), (0x10400, 0x1044F)),
                    (_("Unified Canadian Aboriginal Syllabics"), (0x1400, 0x167F)),
                    (_("UCAS Extended"), (0x18B0, 0x18FF)),
                ),
            ),
            (
                _("Other"),
                (
                    (_("Alphabetic Presentation Forms"), (0xFB00, 0xFB4F)),
                    (_("Halfwidth and Fullwidth Forms"), (0xFF00, 0xFFEF)),
                ),
            ),
            (
                _("Punctuation"),
                (
                    (_("General Punctuation"), (0x2000, 0x206F)),
                    (_("ASCII Punctuation"), (0x21, 0x7F)),
                    (_("Cuneiform Numbers and Punctuation"), (0x12400, 0x1247F)),
                    (_("Latin-1 Punctuation"), (0xA1, 0xBF)),
                    (_("Small Form Variants"), (0xFE50, 0xFE6F)),
                    (_("Supplemental Punctuation"), (0x2E00, 0x2E7F)),
                    (_("CJK Symbols and Punctuation"), (0x3000, 0x303F)),
                    (_("CJK Compatibility Forms"), (0xFE30, 0xFE4F)),
                    (_("Fullwidth ASCII Punctuation"), (0xFF01, 0xFF60)),
                    (_("Vertical Forms"), (0xFE10, 0xFE1F)),
                ),
            ),
            (
                _("Alphanumeric Symbols"),
                (
                    (_("Arabic Mathematical Alphabetic Symbols"), (0x1EE00, 0x1EEFF)),
                    (_("Letterlike Symbols"), (0x2100, 0x214F)),
                    (_("Roman Symbols"), (0x10190, 0x101CF)),
                    (_("Mathematical Alphanumeric Symbols"), (0x1D400, 0x1D7FF)),
                    (_("Enclosed Alphanumerics"), (0x2460, 0x24FF)),
                    (_("Enclosed Alphanumeric Supplement"), (0x1F100, 0x1F1FF)),
                    (_("Enclosed CJK Letters and Months"), (0x3200, 0x32FF)),
                    (_("Enclosed Ideographic Supplement"), (0x1F200, 0x1F2FF)),
                    (_("CJK Compatibility"), (0x3300, 0x33FF)),
                ),
            ),
            (
                _("Technical Symbols"),
                (
                    (_("Miscellaneous Technical"), (0x2300, 0x23FF)),
                    (_("Control Pictures"), (0x2400, 0x243F)),
                    (_("Optical Character Recognition"), (0x2440, 0x245F)),
                ),
            ),
            (
                _("Numbers and Digits"),
                (
                    (_("Aegean Numbers"), (0x10100, 0x1013F)),
                    (_("Ancient Greek Numbers"), (0x10140, 0x1018F)),
                    (_("Common Indic Number Forms"), (0xA830, 0xA83F)),
                    (_("Counting Rod Numerals"), (0x1D360, 0x1D37F)),
                    (_("Cuneiform Numbers and Punctuation"), (0x12400, 0x1247F)),
                    (_("Fullwidth ASCII Digits"), (0xFF10, 0xFF19)),
                    (_("Number Forms"), (0x2150, 0x218F)),
                    (_("Rumi Numeral Symbols"), (0x10E60, 0x10E7F)),
                    (_("Superscripts and Subscripts"), (0x2070, 0x209F)),
                ),
            ),
            (
                _("Mathematical Symbols"),
                (
                    (_("Arrows"), (0x2190, 0x21FF)),
                    (_("Supplemental Arrows-A"), (0x27F0, 0x27FF)),
                    (_("Supplemental Arrows-B"), (0x2900, 0x297F)),
                    (_("Miscellaneous Symbols and Arrows"), (0x2B00, 0x2BFF)),
                    (_("Mathematical Alphanumeric Symbols"), (0x1D400, 0x1D7FF)),
                    (_("Letterlike Symbols"), (0x2100, 0x214F)),
                    (_("Mathematical Operators"), (0x2200, 0x22FF)),
                    (_("Miscellaneous Mathematical Symbols-A"), (0x27C0, 0x27EF)),
                    (_("Miscellaneous Mathematical Symbols-B"), (0x2980, 0x29FF)),
                    (_("Supplemental Mathematical Operators"), (0x2A00, 0x2AFF)),
                    (_("Ceilings and Floors"), (0x2308, 0x230B)),
                    (_("Geometric Shapes"), (0x25A0, 0x25FF)),
                    (_("Box Drawing"), (0x2500, 0x257F)),
                    (_("Block Elements"), (0x2580, 0x259F)),
                ),
            ),
            (
                _("Musical Symbols"),
                (
                    (_("Musical Symbols"), (0x1D100, 0x1D1FF)),
                    (_("More Musical Symbols"), (0x2669, 0x266F)),
                    (_("Ancient Greek Musical Notation"), (0x1D200, 0x1D24F)),
                    (_("Byzantine Musical Symbols"), (0x1D000, 0x1D0FF)),
                ),
            ),
            (
                _("Game Symbols"),
                (
                    (_("Chess"), (0x2654, 0x265F)),
                    (_("Domino Tiles"), (0x1F030, 0x1F09F)),
                    (_("Draughts"), (0x26C0, 0x26C3)),
                    (_("Japanese Chess"), (0x2616, 0x2617)),
                    (_("Mahjong Tiles"), (0x1F000, 0x1F02F)),
                    (_("Playing Cards"), (0x1F0A0, 0x1F0FF)),
                    (_("Playing Card Suits"), (0x2660, 0x2667)),
                ),
            ),
            (
                _("Other Symbols"),
                (
                    (_("Alchemical Symbols"), (0x1F700, 0x1F77F)),
                    (_("Ancient Symbols"), (0x10190, 0x101CF)),
                    (_("Braille Patterns"), (0x2800, 0x28FF)),
                    (_("Currency Symbols"), (0x20A0, 0x20CF)),
                    (_("Combining Diacritical Marks for Symbols"), (0x20D0, 0x20FF)),
                    (_("Dingbats"), (0x2700, 0x27BF)),
                    (_("Emoticons"), (0x1F600, 0x1F64F)),
                    (_("Miscellaneous Symbols"), (0x2600, 0x26FF)),
                    (_("Miscellaneous Symbols and Arrows"), (0x2B00, 0x2BFF)),
                    (_("Miscellaneous Symbols And Pictographs"), (0x1F300, 0x1F5FF)),
                    (_("Yijing Hexagram Symbols"), (0x4DC0, 0x4DFF)),
                    (_("Yijing Mono and Digrams"), (0x268A, 0x268F)),
                    (_("Yijing Trigrams"), (0x2630, 0x2637)),
                    (_("Tai Xuan Jing Symbols"), (0x1D300, 0x1D35F)),
                    (_("Transport And Map Symbols"), (0x1F680, 0x1F6FF)),
                ),
            ),
            (
                _("Other"),
                (
                    (_("Specials"), (0xFFF0, 0xFFFF)),
                    (_("Tags"), (0xE0000, 0xE007F)),
                    (_("Variation Selectors"), (0xFE00, 0xFE0F)),
                    (_("Variation Selectors Supplement"), (0xE0100, 0xE01EF)),
                ),
            ),
        )  # }}}

        self.category_map = {}
        self.starts = []
        for tlname, items in self.categories[1:]:
            for name, (start, end) in items:
                self.category_map[start] = (tlname, name)
                self.starts.append(start)
        self.starts.sort()
        self.bold_font = f = QApplication.font()
        f.setBold(True)
        self.fav_icon = QIcon(I("rating.png"))
Exemple #30
0
    def __init__(self, parent=None):
        QAbstractItemModel.__init__(self, parent)
        self.categories = ((_('Favorites'), ()),  # {{{
(_('European scripts'), (
    (_('Armenian'), (0x530, 0x58F)),
    (_('Armenian ligatures'), (0xFB13, 0xFB17)),
    (_('Coptic'), (0x2C80, 0x2CFF)),
    (_('Coptic in Greek block'), (0x3E2, 0x3EF)),
    (_('Cypriot syllabary'), (0x10800, 0x1083F)),
    (_('Cyrillic'), (0x400, 0x4FF)),
    (_('Cyrillic supplement'), (0x500, 0x52F)),
    (_('Cyrillic extended A'), (0x2DE0, 0x2DFF)),
    (_('Cyrillic extended B'), (0xA640, 0xA69F)),
    (_('Georgian'), (0x10A0, 0x10FF)),
    (_('Georgian supplement'), (0x2D00, 0x2D2F)),
    (_('Glagolitic'), (0x2C00, 0x2C5F)),
    (_('Gothic'), (0x10330, 0x1034F)),
    (_('Greek and Coptic'), (0x370, 0x3FF)),
    (_('Greek extended'), (0x1F00, 0x1FFF)),
    (_('Latin, Basic & Latin-1 supplement'), (0x20, 0xFF)),
    (_('Latin extended A'), (0x100, 0x17F)),
    (_('Latin extended B'), (0x180, 0x24F)),
    (_('Latin extended C'), (0x2C60, 0x2C7F)),
    (_('Latin extended D'), (0xA720, 0xA7FF)),
    (_('Latin extended additional'), (0x1E00, 0x1EFF)),
    (_('Latin ligatures'), (0xFB00, 0xFB06)),
    (_('Fullwidth Latin letters'), (0xFF00, 0xFF5E)),
    (_('Linear B syllabary'), (0x10000, 0x1007F)),
    (_('Linear B ideograms'), (0x10080, 0x100FF)),
    (_('Ogham'), (0x1680, 0x169F)),
    (_('Old italic'), (0x10300, 0x1032F)),
    (_('Phaistos disc'), (0x101D0, 0x101FF)),
    (_('Runic'), (0x16A0, 0x16FF)),
    (_('Shavian'), (0x10450, 0x1047F)),
)),

(_('Phonetic symbols'), (
    (_('IPA extensions'), (0x250, 0x2AF)),
    (_('Phonetic extensions'), (0x1D00, 0x1D7F)),
    (_('Phonetic extensions supplement'), (0x1D80, 0x1DBF)),
    (_('Modifier tone letters'), (0xA700, 0xA71F)),
    (_('Spacing modifier letters'), (0x2B0, 0x2FF)),
    (_('Superscripts and subscripts'), (0x2070, 0x209F)),
)),

(_('Combining diacritics'), (
    (_('Combining diacritical marks'), (0x300, 0x36F)),
    (_('Combining diacritical marks for symbols'), (0x20D0, 0x20FF)),
    (_('Combining diacritical marks supplement'), (0x1DC0, 0x1DFF)),
    (_('Combining half marks'), (0xFE20, 0xFE2F)),
)),

(_('African scripts'), (
    (_('Bamum'), (0xA6A0, 0xA6FF)),
    (_('Bamum supplement'), (0x16800, 0x16A3F)),
    (_('Egyptian hieroglyphs'), (0x13000, 0x1342F)),
    (_('Ethiopic'), (0x1200, 0x137F)),
    (_('Ethiopic supplement'), (0x1380, 0x139F)),
    (_('Ethiopic extended'), (0x2D80, 0x2DDF)),
    (_('Ethiopic extended A'), (0xAB00, 0xAB2F)),
    (_('Meroitic cursive'), (0x109A0, 0x109FF)),
    (_('Meroitic hieroglyphs'), (0x10980, 0x1099F)),
    (_('N\'Ko'), (0x7C0, 0x7FF)),
    (_('Osmanya'), (0x10480, 0x104AF)),
    (_('Tifinagh'), (0x2D30, 0x2D7F)),
    (_('Vai'), (0xA500, 0xA63F)),
)),

(_('Middle Eastern scripts'), (
    (_('Arabic'), (0x600, 0x6FF)),
    (_('Arabic supplement'), (0x750, 0x77F)),
    (_('Arabic extended A'), (0x8A0, 0x8FF)),
    (_('Arabic presentation forms A'), (0xFB50, 0xFDFF)),
    (_('Arabic presentation forms B'), (0xFE70, 0xFEFF)),
    (_('Avestan'), (0x10B00, 0x10B3F)),
    (_('Carian'), (0x102A0, 0x102DF)),
    (_('Cuneiform'), (0x12000, 0x123FF)),
    (_('Cuneiform numbers and punctuation'), (0x12400, 0x1247F)),
    (_('Hebrew'), (0x590, 0x5FF)),
    (_('Hebrew presentation forms'), (0xFB1D, 0xFB4F)),
    (_('Imperial Aramaic'), (0x10840, 0x1085F)),
    (_('Inscriptional Pahlavi'), (0x10B60, 0x10B7F)),
    (_('Inscriptional Parthian'), (0x10B40, 0x10B5F)),
    (_('Lycian'), (0x10280, 0x1029F)),
    (_('Lydian'), (0x10920, 0x1093F)),
    (_('Mandaic'), (0x840, 0x85F)),
    (_('Old Persian'), (0x103A0, 0x103DF)),
    (_('Old South Arabian'), (0x10A60, 0x10A7F)),
    (_('Phoenician'), (0x10900, 0x1091F)),
    (_('Samaritan'), (0x800, 0x83F)),
    (_('Syriac'), (0x700, 0x74F)),
    (_('Ugaritic'), (0x10380, 0x1039F)),
)),

(_('Central Asian scripts'), (
    (_('Mongolian'), (0x1800, 0x18AF)),
    (_('Old Turkic'), (0x10C00, 0x10C4F)),
    (_('Phags-pa'), (0xA840, 0xA87F)),
    (_('Tibetan'), (0xF00, 0xFFF)),
)),

(_('South Asian scripts'), (
    (_('Bengali'), (0x980, 0x9FF)),
    (_('Brahmi'), (0x11000, 0x1107F)),
    (_('Chakma'), (0x11100, 0x1114F)),
    (_('Devanagari'), (0x900, 0x97F)),
    (_('Devanagari extended'), (0xA8E0, 0xA8FF)),
    (_('Gujarati'), (0xA80, 0xAFF)),
    (_('Gurmukhi'), (0xA00, 0xA7F)),
    (_('Kaithi'), (0x11080, 0x110CF)),
    (_('Kannada'), (0xC80, 0xCFF)),
    (_('Kharoshthi'), (0x10A00, 0x10A5F)),
    (_('Lepcha'), (0x1C00, 0x1C4F)),
    (_('Limbu'), (0x1900, 0x194F)),
    (_('Malayalam'), (0xD00, 0xD7F)),
    (_('Meetei Mayek'), (0xABC0, 0xABFF)),
    (_('Meetei Mayek extensions'), (0xAAE0, 0xAAEF)),
    (_('Ol Chiki'), (0x1C50, 0x1C7F)),
    (_('Oriya'), (0xB00, 0xB7F)),
    (_('Saurashtra'), (0xA880, 0xA8DF)),
    (_('Sinhala'), (0xD80, 0xDFF)),
    (_('Sharada'), (0x11180, 0x111DF)),
    (_('Sora Sompeng'), (0x110D0, 0x110FF)),
    (_('Syloti Nagri'), (0xA800, 0xA82F)),
    (_('Takri'), (0x11680, 0x116CF)),
    (_('Tamil'), (0xB80, 0xBFF)),
    (_('Telugu'), (0xC00, 0xC7F)),
    (_('Thaana'), (0x780, 0x7BF)),
    (_('Vedic extensions'), (0x1CD0, 0x1CFF)),
)),

(_('Southeast Asian scripts'), (
    (_('Balinese'), (0x1B00, 0x1B7F)),
    (_('Batak'), (0x1BC0, 0x1BFF)),
    (_('Buginese'), (0x1A00, 0x1A1F)),
    (_('Cham'), (0xAA00, 0xAA5F)),
    (_('Javanese'), (0xA980, 0xA9DF)),
    (_('Kayah Li'), (0xA900, 0xA92F)),
    (_('Khmer'), (0x1780, 0x17FF)),
    (_('Khmer symbols'), (0x19E0, 0x19FF)),
    (_('Lao'), (0xE80, 0xEFF)),
    (_('Myanmar'), (0x1000, 0x109F)),
    (_('Myanmar extended A'), (0xAA60, 0xAA7F)),
    (_('New Tai Lue'), (0x1980, 0x19DF)),
    (_('Rejang'), (0xA930, 0xA95F)),
    (_('Sundanese'), (0x1B80, 0x1BBF)),
    (_('Sundanese supplement'), (0x1CC0, 0x1CCF)),
    (_('Tai Le'), (0x1950, 0x197F)),
    (_('Tai Tham'), (0x1A20, 0x1AAF)),
    (_('Tai Viet'), (0xAA80, 0xAADF)),
    (_('Thai'), (0xE00, 0xE7F)),
)),

(_('Philippine scripts'), (
    (_('Buhid'), (0x1740, 0x175F)),
    (_('Hanunoo'), (0x1720, 0x173F)),
    (_('Tagalog'), (0x1700, 0x171F)),
    (_('Tagbanwa'), (0x1760, 0x177F)),
)),

(_('East Asian scripts'), (
    (_('Bopomofo'), (0x3100, 0x312F)),
    (_('Bopomofo extended'), (0x31A0, 0x31BF)),
    (_('CJK Unified ideographs'), (0x4E00, 0x9FFF)),
    (_('CJK Unified ideographs extension A'), (0x3400, 0x4DBF)),
    (_('CJK Unified ideographs extension B'), (0x20000, 0x2A6DF)),
    (_('CJK Unified ideographs extension C'), (0x2A700, 0x2B73F)),
    (_('CJK Unified ideographs extension D'), (0x2B740, 0x2B81F)),
    (_('CJK compatibility ideographs'), (0xF900, 0xFAFF)),
    (_('CJK compatibility ideographs supplement'), (0x2F800, 0x2FA1F)),
    (_('Kangxi radicals'), (0x2F00, 0x2FDF)),
    (_('CJK radicals supplement'), (0x2E80, 0x2EFF)),
    (_('CJK strokes'), (0x31C0, 0x31EF)),
    (_('Ideographic description characters'), (0x2FF0, 0x2FFF)),
    (_('Hiragana'), (0x3040, 0x309F)),
    (_('Katakana'), (0x30A0, 0x30FF)),
    (_('Katakana phonetic extensions'), (0x31F0, 0x31FF)),
    (_('Kana supplement'), (0x1B000, 0x1B0FF)),
    (_('Halfwidth Katakana'), (0xFF65, 0xFF9F)),
    (_('Kanbun'), (0x3190, 0x319F)),
    (_('Hangul syllables'), (0xAC00, 0xD7AF)),
    (_('Hangul Jamo'), (0x1100, 0x11FF)),
    (_('Hangul Jamo extended A'), (0xA960, 0xA97F)),
    (_('Hangul Jamo extended B'), (0xD7B0, 0xD7FF)),
    (_('Hangul compatibility Jamo'), (0x3130, 0x318F)),
    (_('Halfwidth Jamo'), (0xFFA0, 0xFFDC)),
    (_('Lisu'), (0xA4D0, 0xA4FF)),
    (_('Miao'), (0x16F00, 0x16F9F)),
    (_('Yi syllables'), (0xA000, 0xA48F)),
    (_('Yi radicals'), (0xA490, 0xA4CF)),
)),

(_('American scripts'), (
    (_('Cherokee'), (0x13A0, 0x13FF)),
    (_('Deseret'), (0x10400, 0x1044F)),
    (_('Unified Canadian aboriginal syllabics'), (0x1400, 0x167F)),
    (_('UCAS extended'), (0x18B0, 0x18FF)),
)),

(_('Other'), (
    (_('Alphabetic presentation forms'), (0xFB00, 0xFB4F)),
    (_('Halfwidth and Fullwidth forms'), (0xFF00, 0xFFEF)),
)),

(_('Punctuation'), (
    (_('General punctuation'), (0x2000, 0x206F)),
    (_('ASCII punctuation'), (0x21, 0x7F)),
    (_('Cuneiform numbers and punctuation'), (0x12400, 0x1247F)),
    (_('Latin-1 punctuation'), (0xA1, 0xBF)),
    (_('Small form variants'), (0xFE50, 0xFE6F)),
    (_('Supplemental punctuation'), (0x2E00, 0x2E7F)),
    (_('CJK symbols and punctuation'), (0x3000, 0x303F)),
    (_('CJK compatibility forms'), (0xFE30, 0xFE4F)),
    (_('Fullwidth ASCII punctuation'), (0xFF01, 0xFF60)),
    (_('Vertical forms'), (0xFE10, 0xFE1F)),
)),

(_('Alphanumeric symbols'), (
    (_('Arabic mathematical alphabetic symbols'), (0x1EE00, 0x1EEFF)),
    (_('Letterlike symbols'), (0x2100, 0x214F)),
    (_('Roman symbols'), (0x10190, 0x101CF)),
    (_('Mathematical alphanumeric symbols'), (0x1D400, 0x1D7FF)),
    (_('Enclosed alphanumerics'), (0x2460, 0x24FF)),
    (_('Enclosed alphanumeric supplement'), (0x1F100, 0x1F1FF)),
    (_('Enclosed CJK letters and months'), (0x3200, 0x32FF)),
    (_('Enclosed ideographic supplement'), (0x1F200, 0x1F2FF)),
    (_('CJK compatibility'), (0x3300, 0x33FF)),
)),

(_('Technical symbols'), (
    (_('Miscellaneous technical'), (0x2300, 0x23FF)),
    (_('Control pictures'), (0x2400, 0x243F)),
    (_('Optical character recognition'), (0x2440, 0x245F)),
)),

(_('Numbers and digits'), (
    (_('Aegean numbers'), (0x10100, 0x1013F)),
    (_('Ancient Greek numbers'), (0x10140, 0x1018F)),
    (_('Common Indic number forms'), (0xA830, 0xA83F)),
    (_('Counting rod numerals'), (0x1D360, 0x1D37F)),
    (_('Cuneiform numbers and punctuation'), (0x12400, 0x1247F)),
    (_('Fullwidth ASCII digits'), (0xFF10, 0xFF19)),
    (_('Number forms'), (0x2150, 0x218F)),
    (_('Rumi numeral symbols'), (0x10E60, 0x10E7F)),
    (_('Superscripts and subscripts'), (0x2070, 0x209F)),
)),

(_('Mathematical symbols'), (
    (_('Arrows'), (0x2190, 0x21FF)),
    (_('Supplemental arrows A'), (0x27F0, 0x27FF)),
    (_('Supplemental arrows B'), (0x2900, 0x297F)),
    (_('Miscellaneous symbols and arrows'), (0x2B00, 0x2BFF)),
    (_('Mathematical alphanumeric symbols'), (0x1D400, 0x1D7FF)),
    (_('Letterlike symbols'), (0x2100, 0x214F)),
    (_('Mathematical operators'), (0x2200, 0x22FF)),
    (_('Miscellaneous mathematical symbols A'), (0x27C0, 0x27EF)),
    (_('Miscellaneous mathematical symbols B'), (0x2980, 0x29FF)),
    (_('Supplemental mathematical operators'), (0x2A00, 0x2AFF)),
    (_('Ceilings and floors'), (0x2308, 0x230B)),
    (_('Geometric shapes'), (0x25A0, 0x25FF)),
    (_('Box drawing'), (0x2500, 0x257F)),
    (_('Block elements'), (0x2580, 0x259F)),
)),

(_('Musical symbols'), (
    (_('Musical symbols'), (0x1D100, 0x1D1FF)),
    (_('More musical symbols'), (0x2669, 0x266F)),
    (_('Ancient Greek musical notation'), (0x1D200, 0x1D24F)),
    (_('Byzantine musical symbols'), (0x1D000, 0x1D0FF)),
)),

(_('Game symbols'), (
    (_('Chess'), (0x2654, 0x265F)),
    (_('Domino tiles'), (0x1F030, 0x1F09F)),
    (_('Draughts'), (0x26C0, 0x26C3)),
    (_('Japanese chess'), (0x2616, 0x2617)),
    (_('Mahjong tiles'), (0x1F000, 0x1F02F)),
    (_('Playing cards'), (0x1F0A0, 0x1F0FF)),
    (_('Playing card suits'), (0x2660, 0x2667)),
)),

(_('Other symbols'), (
    (_('Alchemical symbols'), (0x1F700, 0x1F77F)),
    (_('Ancient symbols'), (0x10190, 0x101CF)),
    (_('Braille patterns'), (0x2800, 0x28FF)),
    (_('Currency symbols'), (0x20A0, 0x20CF)),
    (_('Combining diacritical marks for symbols'), (0x20D0, 0x20FF)),
    (_('Dingbats'), (0x2700, 0x27BF)),
    (_('Emoticons'), (0x1F600, 0x1F64F)),
    (_('Miscellaneous symbols'), (0x2600, 0x26FF)),
    (_('Miscellaneous symbols and arrows'), (0x2B00, 0x2BFF)),
    (_('Miscellaneous symbols and pictographs'), (0x1F300, 0x1F5FF)),
    (_('Yijing hexagram symbols'), (0x4DC0, 0x4DFF)),
    (_('Yijing mono and digrams'), (0x268A, 0x268F)),
    (_('Yijing trigrams'), (0x2630, 0x2637)),
    (_('Tai Xuan Jing symbols'), (0x1D300, 0x1D35F)),
    (_('Transport and map symbols'), (0x1F680, 0x1F6FF)),
)),

(_('Other'), (
    (_('Specials'), (0xFFF0, 0xFFFF)),
    (_('Tags'), (0xE0000, 0xE007F)),
    (_('Variation selectors'), (0xFE00, 0xFE0F)),
    (_('Variation selectors supplement'), (0xE0100, 0xE01EF)),
)),
)  # }}}

        self.category_map = {}
        self.starts = []
        for tlname, items in self.categories[1:]:
            for name, (start, end) in items:
                self.category_map[start] = (tlname, name)
                self.starts.append(start)
        self.starts.sort()
        self.bold_font = f = QApplication.font()
        f.setBold(True)
        self.fav_icon = QIcon(I('rating.png'))