예제 #1
0
파일: utils.py 프로젝트: kovidgoyal/vise
def pixmap_to_data(pixmap, format='PNG'):
    '''
    Return the QPixmap pixmap as a string saved in the specified format.
    '''
    ba = QByteArray()
    buf = QBuffer(ba)
    buf.open(QIODeviceBase.OpenModeFlag.WriteOnly)
    pixmap.save(buf, format)
    return bytes(ba.data())
예제 #2
0
파일: welcome.py 프로젝트: kovidgoyal/vise
def get_welcome_html():
    if not hasattr(get_welcome_html, 'html'):
        d = get_data('welcome.html').decode('utf-8')
        ic = get_data('images/vise.svg')
        d = d.replace('VISE_ICON', 'data:image/svg+xml;base64,' + base64.standard_b64encode(ic).decode('ascii'))
        get_welcome_html.html = QByteArray(d.encode('utf-8'))
    return get_welcome_html.html
예제 #3
0
def serialize(obj: _QtSerializable) -> QByteArray:
    """Serialize an object into a QByteArray."""
    data = QByteArray()
    stream = QDataStream(data, QIODevice.OpenModeFlag.WriteOnly)
    check_dstream(stream)
    stream << obj  # type: ignore[operator]
    check_dstream(stream)
    return data
    def getInitialSettings(self):
        """Get initial settings of the application using QSettings upon startup."""
        position = self.settings.value("position", QPoint(200, 0))
        size = self.settings.value("size", QSize(800, 500))
        self.is_delete_checked = self.settings.value("delete_images", type=bool) 
        # restoreState() is used here to restore the image_preview_dock widget
        self.restoreState(self.settings.value("window_state", bytes(QByteArray())))

        self.resize(size)
        self.move(position)
        return self.is_delete_checked
예제 #5
0
def filename_icon_data(encoded_file_name):
    return QByteArray(icon_data_for_filename(unhexlify(encoded_file_name).decode('utf-8'), size=64) or get_data('images/blank.png'))
예제 #6
0
def get_downloads_html():
    if not hasattr(get_downloads_html, 'html'):
        get_downloads_html.html = QByteArray(get_data('downloads.html').decode('utf-8').replace('_TITLE_', _('Downloads')).encode('utf-8'))
    return get_downloads_html.html