Welcome to mirror list, hosted at ThFree Co, Russian Federation.

fb2utils.cpp « source - github.com/lintest/fb2edit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 72eefa2fa4fdfba7532371b34050fa5a877acb88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "fb2utils.h"

#include <QApplication>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QTextStream>

static QIcon loadIcon(const QString &name)
{
    QIcon icon;
    icon.addFile(QString(":/24x24/%1.png").arg(name), QSize(24,24));
    icon.addFile(QString(":/16x16/%1.png").arg(name), QSize(16,16));
    return icon;
}

FbIcon::FbIcon(const QString &name)
    : QIcon(fromTheme(name, loadIcon(name)))
{
}

QString jScript(const QString &filename)
{

    QString filepath = ":/js/" + filename;

    // TODO: throw an exception instead of
    // returning an empty string
    QFile file( filepath );
    if (!file.open(QFile::ReadOnly)) return QString();

    QTextStream in( &file );

    // Input should be UTF-8
    in.setCodec( "UTF-8" );

    // This will automatically switch reading from
    // UTF-8 to UTF-16 if a BOM is detected
    in.setAutoDetectUnicode( true );

    return in.readAll();
}