~ubuntu-docviewer-dev/ubuntu-docviewer-app/lo-viewer

« back to all changes in this revision

Viewing changes to src/app/qml/common/utils.js

Update framework to 'ubuntu-sdk-14.10'. Fixes: https://bugs.launchpad.net/bugs/1401718.

Approved by Nekhelesh Ramananthan, Ubuntu Phone Apps Jenkins Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2013-2015 Canonical, Ltd.
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or modify
5
 
 * it under the terms of the GNU General Public License as published by
6
 
 * the Free Software Foundation; version 3.
7
 
 *
8
 
 * This program is distributed in the hope that it will be useful,
9
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
 * GNU General Public License for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU General Public License
14
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 
 */
16
 
 
17
 
.pragma library
18
 
 
19
 
function printSize(i18n, size) {
20
 
    if (size >= 1073741824)
21
 
        // TRANSLATORS: %1 is the size of a file, expressed in GB
22
 
        return i18n.tr("%1 GB").arg((size / 1073741824).toFixed(2));
23
 
 
24
 
    if (size >= 1048576)
25
 
        // TRANSLATORS: %1 is the size of a file, expressed in MB
26
 
        return i18n.tr("%1 MB").arg((size / 1048576).toFixed(2));
27
 
 
28
 
    if (size >= 1024)
29
 
        // TRANSLATORS: %1 is the size of a file, expressed in kB
30
 
        return i18n.tr("%1 kB").arg(parseInt(size / 1024));
31
 
 
32
 
    // TRANSLATORS: %1 is the size of a file, expressed in byte
33
 
    return i18n.tr("%1 byte").arg(size);
34
 
}
35
 
 
36
 
function getIconNameFromMimetype(mimetype) {
37
 
    if (mimetype.substring(0, 5) === "text/")
38
 
        return "text-x-generic-symbolic"
39
 
 
40
 
    if (mimetype.substring(0, 5) === "image")
41
 
        return "image-x-generic-symbolic"
42
 
 
43
 
    if (mimetype === "application/pdf")
44
 
        return "application-pdf-symbolic"
45
 
 
46
 
    if (mimetype === "application/vnd.oasis.opendocument.text"
47
 
            || mimetype === "application/msword"
48
 
            || mimetype === "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
49
 
        return "x-office-document-symbolic"
50
 
 
51
 
    if (mimetype === "application/vnd.oasis.opendocument.spreadsheet"
52
 
            || mimetype === "application/vnd.ms-excel"
53
 
            || mimetype === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
54
 
        return "x-office-spreadsheet-symbolic"
55
 
 
56
 
    if (mimetype === "application/vnd.oasis.opendocument.presentation"
57
 
            || mimetype === "application/vnd.ms-powerpoint"
58
 
            || mimetype === "application/vnd.openxmlformats-officedocument.presentationml.presentation")
59
 
        return "x-office-presentation-symbolic"
60
 
 
61
 
    return "package-x-generic-symbolic"
62
 
}