summaryrefslogtreecommitdiffstats
path: root/weatherapp.pro
blob: 7ca3dbf99ffd5b8945d3b7650777515077750e2d (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
cache()

TEMPLATE = app
QT += qml quick gui network xmlpatterns
TARGET = QuickForecast

include(src/src.pri)

APP_FILES = \
    $$PWD/qml/main.qml \
    $$PWD/qml/pages/BasicPage.qml \
    $$PWD/qml/pages/CitiesPage.qml \
    $$PWD/qml/pages/OneDayPage.qml \
    $$PWD/qml/pages/LongTermPage.qml \
    $$PWD/qml/pages/LongTermDayItem.qml \
    $$PWD/qml/pages/OneDayZoomItem.qml \
    $$PWD/qml/pages/OneDaySliderItem.qml \
    $$PWD/qml/pages/Separator.qml \
    $$PWD/qml/models/WeatherModel.qml \
    $$PWD/qml/js/utils.js

# Touch Styled Controls
APP_FILES += \
    $$PWD/qml/touch/TouchLabel.qml \
    $$PWD/qml/touch/TouchScrollView.qml \
    $$PWD/qml/touch/TouchSlider.qml \
    $$PWD/qml/touch/TouchTextField.qml \
    $$PWD/qml/touch/ListViewDelegate.qml \
    $$PWD/qml/touch/images/BackArrow.png \
    $$PWD/qml/touch/images/Pointer.png \
    $$PWD/qml/touch/images/Pointer_pressed.png \
    $$PWD/qml/touch/images/Circle.png \
    $$PWD/qml/touch/images/darkclose.png \
    $$PWD/qml/touch/images/magnifier.png \
    $$PWD/qml/touch/images/Clear.png

# Fonts
APP_FILES += \
    $$PWD/fonts/OpenSans-Bold.ttf \
    $$PWD/fonts/OpenSans-Semibold.ttf \
    $$PWD/fonts/OpenSans-Regular.ttf

OTHER_FILES += $$APP_FILES $$PWD/translations/README

# var, prepend, append
defineReplace(prependAll) {
    for(a,$$1):result += $$2$${a}$$3
    return($$result)
}

# Supported languages
LANGUAGES = bn da de es fi fr hi hu it nb nl pl ro ru zh

# Available translations
TRANSLATIONS = $$prependAll(LANGUAGES, $$PWD/translations/QuickForecast_, .ts)

# Used to embed the qm files in resources
TRANSLATIONS_FILES =

# run LRELEASE to generate the qm files
qtPrepareTool(LRELEASE, lrelease)
for(tsfile, TRANSLATIONS) {
    qmfile = $$shadowed($$tsfile)
    qmfile ~= s,\\.ts$,.qm,
    qmdir = $$dirname(qmfile)
    !exists($$qmdir) {
        mkpath($$qmdir)|error("Aborting.")
    }
    command = $$LRELEASE -removeidentical $$tsfile -qm  $$qmfile
    system($$command)|error("Failed to run: $$command")
    TRANSLATIONS_FILES += $$qmfile
}

# Create the resource file
GENERATED_RESOURCE_FILE = $$OUT_PWD/weatherapp.qrc

RESOURCE_CONTENT = \
    "<RCC>" \
    "<qresource>"

for(resourcefile, APP_FILES) {
    resourcefileabsolutepath = $$absolute_path($$resourcefile)
    relativepath_in = $$relative_path($$resourcefileabsolutepath, $$_PRO_FILE_PWD_)
    relativepath_out = $$relative_path($$resourcefileabsolutepath, $$OUT_PWD)
    RESOURCE_CONTENT += "<file alias=\"weatherapp/$$relativepath_in\">$$relativepath_out</file>"
}

for(translationfile, TRANSLATIONS_FILES) {
    relativepath_out = $$relative_path($$translationfile, $$OUT_PWD)
    RESOURCE_CONTENT += "<file alias=\"$$relativepath_out\">$$relativepath_out</file>"
}

RESOURCE_CONTENT += \
    "</qresource>" \
    "</RCC>"

write_file($$GENERATED_RESOURCE_FILE, RESOURCE_CONTENT)|error("Aborting.")

RESOURCES += $$GENERATED_RESOURCE_FILE

ios {
    FONTS.files = $$PWD/fonts/OpenSans-Bold.ttf $$PWD/fonts/OpenSans-Semibold.ttf $$PWD/fonts/OpenSans-Regular.ttf
    FONTS.path = fonts
    QMAKE_BUNDLE_DATA += FONTS
    QMAKE_INFO_PLIST = ios/iosInfo.plist
}

android: ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android

winrt {
    WINRT_MANIFEST.logo_large = app-icons/AppIcon_150x150.png
    WINRT_MANIFEST.logo_small = app-icons/AppIcon_30x30.png
    WINRT_MANIFEST.logo_store = app-icons/AppIcon_50x50.png
    WINRT_MANIFEST.logo_splash = app-icons/AppIcon_620x300.png
    WINRT_MANIFEST.background = $${LITERAL_HASH}00a2ff
    WINRT_MANIFEST.publisher = "Digia Plc"
    winphone:equals(WINSDK_VER, 8.0) {
        WINRT_MANIFEST.capabilities += ID_CAP_NETWORKING
        WINRT_MANIFEST.logo_medium = app-icons/AppIcon_100x100.png
        WINRT_MANIFEST.tile_iconic_small = app-icons/AppIcon_71x110.png
        WINRT_MANIFEST.tile_iconic_medium = app-icons/AppIcon_134x202.png
        build_pass:FONTS = $$PWD/fonts/OpenSans-Bold.ttf $$PWD/fonts/OpenSans-Semibold.ttf $$PWD/fonts/OpenSans-Regular.ttf
    } else {
        WINRT_MANIFEST.capabilities += internetClient
    }
    CONFIG += windeployqt
    WINDEPLOYQT_OPTIONS = -no-svg -qmldir $$shell_quote($$system_path($$_PRO_FILE_PWD_))
}

# TRANSLATIONS - Create extra targets for convenience

wd = $$replace(PWD, /, $$QMAKE_DIR_SEP)

# LUPDATE - Make new targets for each and all languages
qtPrepareTool(LUPDATE, lupdate)
LUPDATE += -locations relative -no-ui-lines
TSFILES = $$files($$PWD/translations/QuickForecast_*.ts) $$PWD/translations/QuickForecast_untranslated.ts
for(file, TSFILES) {
    lang = $$replace(file, .*_([^/]*)\\.ts, \\1)
    v = ts-$${lang}.commands
    $$v = cd $$wd && $$LUPDATE $$SOURCES $$APP_FILES -ts $$file
    QMAKE_EXTRA_TARGETS += ts-$$lang
}
ts-all.commands = cd $$PWD && $$LUPDATE $$SOURCES $$APP_FILES -ts $$TSFILES
QMAKE_EXTRA_TARGETS += ts-all

# COMMIT - Make a new target for lconvert and committing the ts files
# lconvert is used to remove the strings location in the ts files
# and thus save space.
qtPrepareTool(LCONVERT, lconvert)
LCONVERT += -locations none
isEqual(QMAKE_DIR_SEP, /) {
    commit-ts.commands = \
        cd $$wd; \
        git add -N translations/*_??.ts && \
        for f in `git diff-files --name-only translations/*_??.ts`; do \
            $$LCONVERT -i \$\$f -o \$\$f; \
        done; \
        git add translations/*_??.ts && git commit
} else {
    commit-ts.commands = \
        cd $$wd && \
        git add -N translations/*_??.ts && \
        for /f usebackq %%f in (`git diff-files --name-only -- translations/*_??.ts`) do \
            $$LCONVERT -i %%f -o %%f $$escape_expand(\\n\\t) \
        cd $$wd && git add translations/*_??.ts && git commit
}
QMAKE_EXTRA_TARGETS += commit-ts