Package: telegram-desktop / 1.5.11-1

Packed-resources.patch Patch series | download
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
From: Nicholas Guriev <guriev-ns@ya.ru>
Date: Tue, 22 Aug 2017 16:15:36 +0300
Subject: [PATCH] Packed resources
Bug: https://github.com/telegramdesktop/tdesktop/pull/3817
Last-Update: 2017-08-22

--- a/Telegram/Resources/qrc/telegram.qrc
+++ b/Telegram/Resources/qrc/telegram.qrc
@@ -54,17 +54,6 @@
     <file alias="night.tdesktop-theme">../night.tdesktop-theme</file>
     <file alias="night-green.tdesktop-theme">../night-green.tdesktop-theme</file>
   </qresource>
-  <qresource prefix="/sounds">
-    <file alias="msg_incoming.mp3">../sounds/msg_incoming.mp3</file>
-    <file alias="call_incoming.mp3">../sounds/call_incoming.mp3</file>
-    <file alias="call_outgoing.mp3">../sounds/call_outgoing.mp3</file>
-    <file alias="call_busy.mp3">../sounds/call_busy.mp3</file>
-    <file alias="call_connect.mp3">../sounds/call_connect.mp3</file>
-    <file alias="call_end.mp3">../sounds/call_end.mp3</file>
-  </qresource>
-  <qresource prefix="/qt-project.org">
-    <file>qmime/freedesktop.org.xml</file>
-  </qresource>
   <qresource prefix="/misc">
     <file alias="default_shortcuts-custom.json">../default_shortcuts-custom.json</file>
   </qresource>
--- a/Telegram/SourceFiles/core/file_utilities.cpp
+++ b/Telegram/SourceFiles/core/file_utilities.cpp
@@ -344,3 +344,20 @@ bool GetDefault(
 
 } // namespace internal
 } // namespace FileDialog
+
+void Resources::LoadAllData() {
+#ifdef TDESKTOP_USE_PACKED_RESOURCES
+	// Load resources packed into a separated file
+	QStringList paths;
+#ifdef _DEBUG
+	paths += cExeDir();
+#endif
+	paths += QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
+	for (QString directory : paths) {
+		if (QResource::registerResource(directory + qsl("/tresources.rcc"))) {
+			return;  // found
+		}
+	}
+	qFatal("Packed resources not found");
+#endif
+}
--- a/Telegram/SourceFiles/core/file_utilities.h
+++ b/Telegram/SourceFiles/core/file_utilities.h
@@ -105,3 +105,9 @@ bool GetDefault(
 
 } // namespace internal
 } // namespace FileDialog
+
+namespace Resources {
+
+void LoadAllData();
+
+} // namespace Resources
--- a/Telegram/SourceFiles/core/launcher.cpp
+++ b/Telegram/SourceFiles/core/launcher.cpp
@@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesk
 #include "platform/platform_launcher.h"
 #include "platform/platform_specific.h"
 #include "core/crash_reports.h"
+#include "core/file_utilities.h"
 #include "core/main_queue_processor.h"
 #include "core/update_checker.h"
 #include "core/sandbox.h"
@@ -207,6 +208,7 @@ void Launcher::init() {
 	prepareSettings();
 
 	QApplication::setApplicationName(qsl("TelegramDesktop"));
+	Resources::LoadAllData(); // should be called after setting an application name
 
 #ifndef OS_MAC_OLD
 	QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true);
--- a/Telegram/gyp/Telegram.gyp
+++ b/Telegram/gyp/Telegram.gyp
@@ -52,6 +52,7 @@
       ],
       'build_defines%': '',
       'list_sources_command': 'python <(DEPTH)/list_sources.py --input <(DEPTH)/telegram_sources.txt --replace src_loc=<(src_loc)',
+      'use_packed_resources%': 0,
       'pch_source': '<(src_loc)/stdafx.cpp',
       'pch_header': '<(src_loc)/stdafx.h',
     },
@@ -98,7 +99,6 @@
       '/usr/include/opus',
     ],
     'sources': [
-      '<@(qrc_files)',
       '<@(style_files)',
       '<!@(<(list_sources_command) <(qt_moc_list_sources_arg))',
       'telegram_sources.txt',
@@ -112,6 +112,31 @@
       '<!@(<(list_sources_command) <(qt_moc_list_sources_arg) --exclude_for <(build_os))',
     ],
     'conditions': [
+      [ 'use_packed_resources', {
+        'actions': [
+          {
+            'action_name': 'generate_resource_pack',
+            'inputs': [
+              '<(SHARED_INTERMEDIATE_DIR)/update_dependent_qrc.timestamp',
+            ],
+            'outputs': [
+              '<(PRODUCT_DIR)/tresources.rcc',
+            ],
+            'action': [
+              '<(qt_loc)/bin/rcc<(exe_ext)', '-binary',
+              '<@(qrc_files)',
+              '-o', '<@(_outputs)',
+            ],
+          },
+        ],
+        'defines': [
+          'TDESKTOP_USE_PACKED_RESOURCES',
+        ],
+      }, {
+        'sources': [
+          '<@(qrc_files)',
+        ],
+      }],
       [ '"<(official_build_target)" != ""', {
         'defines': [
           'TDESKTOP_OFFICIAL_TARGET=<(official_build_target)',