From d73cfacde920d5612778f08d5f46985d7729afe8 Mon Sep 17 00:00:00 2001
From: Stanislav Ershov <digital.stream.of.mind@gmail.com>
Date: Fri, 22 Dec 2017 02:00:01 +0300
Subject: [PATCH] [skip ci] remove unused code from original tdesktop app

---
 Telegram/Patches/breakpad.diff                |  481 ------
 Telegram/Patches/build_ffmpeg_win.sh          |   18 -
 Telegram/Patches/gyp.diff                     |   80 -
 Telegram/Patches/macold/crashpad.diff         |   20 -
 Telegram/Patches/macold/mini_chromium.diff    |   26 -
 Telegram/Patches/macold/qtbase_5_3_2.diff     |  784 ---------
 .../Patches/macold/qtimageformats_5_3_2.diff  |   47 -
 Telegram/Patches/qtbase_5_6_2.diff            | 1451 -----------------
 Telegram/Resources/langs/download.sh          |   34 -
 Telegram/Resources/langs/upload.sh            |   29 -
 Telegram/Resources/winrc/Updater.rc           |   72 -
 Telegram/Resources/winrc/resource1.h          |   14 -
 Telegram/build/build.bat                      |  317 ----
 Telegram/build/build.sh                       |  360 ----
 Telegram/build/deploy.sh                      |  226 ---
 Telegram/build/release.py                     |  256 ---
 Telegram/build/release.sh                     |   44 -
 Telegram/build/replace.vbs                    |   35 -
 Telegram/build/set_version.bat                |  166 --
 Telegram/build/set_version.sh                 |  145 --
 Telegram/build/setup.iss                      |  119 --
 Telegram/build/test_package.bat               |   81 -
 Telegram/build/version                        |    6 -
 Telegram/create.bat                           |  147 --
 24 files changed, 4958 deletions(-)
 delete mode 100644 Telegram/Patches/breakpad.diff
 delete mode 100644 Telegram/Patches/build_ffmpeg_win.sh
 delete mode 100644 Telegram/Patches/gyp.diff
 delete mode 100644 Telegram/Patches/macold/crashpad.diff
 delete mode 100644 Telegram/Patches/macold/mini_chromium.diff
 delete mode 100644 Telegram/Patches/macold/qtbase_5_3_2.diff
 delete mode 100644 Telegram/Patches/macold/qtimageformats_5_3_2.diff
 delete mode 100644 Telegram/Patches/qtbase_5_6_2.diff
 delete mode 100755 Telegram/Resources/langs/download.sh
 delete mode 100755 Telegram/Resources/langs/upload.sh
 delete mode 100644 Telegram/Resources/winrc/Updater.rc
 delete mode 100644 Telegram/Resources/winrc/resource1.h
 delete mode 100644 Telegram/build/build.bat
 delete mode 100755 Telegram/build/build.sh
 delete mode 100755 Telegram/build/deploy.sh
 delete mode 100644 Telegram/build/release.py
 delete mode 100755 Telegram/build/release.sh
 delete mode 100644 Telegram/build/replace.vbs
 delete mode 100644 Telegram/build/set_version.bat
 delete mode 100755 Telegram/build/set_version.sh
 delete mode 100644 Telegram/build/setup.iss
 delete mode 100644 Telegram/build/test_package.bat
 delete mode 100644 Telegram/build/version
 delete mode 100644 Telegram/create.bat

diff --git a/Telegram/Patches/breakpad.diff b/Telegram/Patches/breakpad.diff
deleted file mode 100644
index bde669862..000000000
--- a/Telegram/Patches/breakpad.diff
+++ /dev/null
@@ -1,481 +0,0 @@
-diff --git a/src/build/common.gypi b/src/build/common.gypi
-index b9466a3..9fb31aa 100644
---- a/src/build/common.gypi
-+++ b/src/build/common.gypi
-@@ -330,6 +330,7 @@
-           'VCCLCompilerTool': {
-             'WarnAsError': 'true',
-             'Detect64BitPortabilityProblems': 'false',
-+            'TreatWChar_tAsBuiltInType': 'false',
-           },
-         },
-       }],
-diff --git a/src/client/mac/Breakpad.xcodeproj/project.pbxproj b/src/client/mac/Breakpad.xcodeproj/project.pbxproj
-index 1a93ce6..1c1d643 100644
---- a/src/client/mac/Breakpad.xcodeproj/project.pbxproj
-+++ b/src/client/mac/Breakpad.xcodeproj/project.pbxproj
-@@ -35,6 +35,19 @@
- /* End PBXAggregateTarget section */
- 
- /* Begin PBXBuildFile section */
-+		0748C0431C63C409004489BF /* MachIPC.mm in Sources */ = {isa = PBXBuildFile; fileRef = F92C53790ECCE635009BE4BA /* MachIPC.mm */; };
-+		0748C0441C63C43C004489BF /* minidump_generator.cc in Sources */ = {isa = PBXBuildFile; fileRef = F92C536F0ECCE3FD009BE4BA /* minidump_generator.cc */; };
-+		0748C0451C63C46C004489BF /* string_utilities.cc in Sources */ = {isa = PBXBuildFile; fileRef = F92C53820ECCE635009BE4BA /* string_utilities.cc */; };
-+		0748C0461C63C484004489BF /* minidump_file_writer.cc in Sources */ = {isa = PBXBuildFile; fileRef = F92C538F0ECCE70A009BE4BA /* minidump_file_writer.cc */; };
-+		0748C0471C63C4A1004489BF /* dynamic_images.cc in Sources */ = {isa = PBXBuildFile; fileRef = F92C536B0ECCE3FD009BE4BA /* dynamic_images.cc */; };
-+		0748C0491C63C4CF004489BF /* macho_id.cc in Sources */ = {isa = PBXBuildFile; fileRef = F92C537A0ECCE635009BE4BA /* macho_id.cc */; };
-+		0748C04A1C63C4D4004489BF /* string_conversion.cc in Sources */ = {isa = PBXBuildFile; fileRef = F92C53850ECCE6AD009BE4BA /* string_conversion.cc */; };
-+		0748C04B1C63C4DB004489BF /* convert_UTF.c in Sources */ = {isa = PBXBuildFile; fileRef = F92C53870ECCE6C0009BE4BA /* convert_UTF.c */; };
-+		0748C04C1C63C4EA004489BF /* macho_utilities.cc in Sources */ = {isa = PBXBuildFile; fileRef = F92C537C0ECCE635009BE4BA /* macho_utilities.cc */; };
-+		0748C04D1C63C50F004489BF /* file_id.cc in Sources */ = {isa = PBXBuildFile; fileRef = F92C53740ECCE635009BE4BA /* file_id.cc */; };
-+		0748C04E1C63C51C004489BF /* md5.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D72CA0D13DFAD5C006CABE3 /* md5.cc */; };
-+		0748C04F1C63C523004489BF /* macho_walker.cc in Sources */ = {isa = PBXBuildFile; fileRef = F92C537E0ECCE635009BE4BA /* macho_walker.cc */; };
-+		0748C0501C63C52D004489BF /* bootstrap_compat.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D61A25D14F43CFC002D5862 /* bootstrap_compat.cc */; };
- 		162F64F2161C577500CD68D5 /* arch_utilities.cc in Sources */ = {isa = PBXBuildFile; fileRef = 162F64F0161C577500CD68D5 /* arch_utilities.cc */; };
- 		162F64F3161C577500CD68D5 /* arch_utilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 162F64F1161C577500CD68D5 /* arch_utilities.h */; };
- 		162F64F4161C579B00CD68D5 /* arch_utilities.cc in Sources */ = {isa = PBXBuildFile; fileRef = 162F64F0161C577500CD68D5 /* arch_utilities.cc */; };
-@@ -170,11 +183,8 @@
- 		F92C564A0ECD10CA009BE4BA /* string_conversion.cc in Sources */ = {isa = PBXBuildFile; fileRef = F92C53850ECCE6AD009BE4BA /* string_conversion.cc */; };
- 		F92C564C0ECD10DD009BE4BA /* breakpadUtilities.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F92C563C0ECD10B3009BE4BA /* breakpadUtilities.dylib */; };
- 		F92C56570ECD113E009BE4BA /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F92C554A0ECCF530009BE4BA /* Carbon.framework */; };
--		F92C565C0ECD1158009BE4BA /* breakpadUtilities.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F92C563C0ECD10B3009BE4BA /* breakpadUtilities.dylib */; };
- 		F92C565F0ECD116B009BE4BA /* protected_memory_allocator.cc in Sources */ = {isa = PBXBuildFile; fileRef = F92C53720ECCE3FD009BE4BA /* protected_memory_allocator.cc */; };
- 		F92C56630ECD1179009BE4BA /* exception_handler.cc in Sources */ = {isa = PBXBuildFile; fileRef = F92C536D0ECCE3FD009BE4BA /* exception_handler.cc */; };
--		F92C56650ECD1185009BE4BA /* breakpadUtilities.dylib in Resources */ = {isa = PBXBuildFile; fileRef = F92C563C0ECD10B3009BE4BA /* breakpadUtilities.dylib */; };
--		F92C568A0ECD15F9009BE4BA /* Inspector in Resources */ = {isa = PBXBuildFile; fileRef = F92C53540ECCE349009BE4BA /* Inspector */; };
- 		F92C56A90ECE04C5009BE4BA /* crash_report_sender.m in Sources */ = {isa = PBXBuildFile; fileRef = F92C56A80ECE04C5009BE4BA /* crash_report_sender.m */; };
- 		F93803CD0F8083B7004D428B /* dynamic_images.cc in Sources */ = {isa = PBXBuildFile; fileRef = F92C536B0ECCE3FD009BE4BA /* dynamic_images.cc */; };
- 		F93803CE0F8083B7004D428B /* exception_handler.cc in Sources */ = {isa = PBXBuildFile; fileRef = F92C536D0ECCE3FD009BE4BA /* exception_handler.cc */; };
-@@ -213,7 +223,6 @@
- 		F9C44DBD0EF072A0003AEBAA /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F9C44DBA0EF072A0003AEBAA /* MainMenu.xib */; };
- 		F9C44E000EF077CD003AEBAA /* Breakpad.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Breakpad.framework */; };
- 		F9C44E3C0EF08B12003AEBAA /* Breakpad.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Breakpad.framework */; };
--		F9C44E980EF09F56003AEBAA /* crash_report_sender.app in Resources */ = {isa = PBXBuildFile; fileRef = F92C56A00ECE04A7009BE4BA /* crash_report_sender.app */; };
- 		F9C44EA20EF09F93003AEBAA /* HTTPMultipartUpload.m in Sources */ = {isa = PBXBuildFile; fileRef = F92C53770ECCE635009BE4BA /* HTTPMultipartUpload.m */; };
- 		F9C44EE50EF0A006003AEBAA /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F9C44EE40EF0A006003AEBAA /* SystemConfiguration.framework */; };
- 		F9C44EE90EF0A3C1003AEBAA /* GTMLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = F9C44EE80EF0A3C1003AEBAA /* GTMLogger.m */; };
-@@ -410,20 +419,6 @@
- 			remoteGlobalIDString = F92C563B0ECD10B3009BE4BA;
- 			remoteInfo = breakpadUtilities;
- 		};
--		F92C56850ECD15EF009BE4BA /* PBXContainerItemProxy */ = {
--			isa = PBXContainerItemProxy;
--			containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
--			proxyType = 1;
--			remoteGlobalIDString = F92C563B0ECD10B3009BE4BA;
--			remoteInfo = breakpadUtilities;
--		};
--		F92C56870ECD15F1009BE4BA /* PBXContainerItemProxy */ = {
--			isa = PBXContainerItemProxy;
--			containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
--			proxyType = 1;
--			remoteGlobalIDString = F92C53530ECCE349009BE4BA;
--			remoteInfo = Inspector;
--		};
- 		F93DE2FB0F82C3C600608B94 /* PBXContainerItemProxy */ = {
- 			isa = PBXContainerItemProxy;
- 			containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
-@@ -536,13 +531,6 @@
- 			remoteGlobalIDString = 8DC2EF4F0486A6940098B216;
- 			remoteInfo = Breakpad;
- 		};
--		F9C44E960EF09F4B003AEBAA /* PBXContainerItemProxy */ = {
--			isa = PBXContainerItemProxy;
--			containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
--			proxyType = 1;
--			remoteGlobalIDString = F92C569F0ECE04A7009BE4BA;
--			remoteInfo = crash_report_sender;
--		};
- /* End PBXContainerItemProxy section */
- 
- /* Begin PBXCopyFilesBuildPhase section */
-@@ -714,7 +702,6 @@
- 			isa = PBXFrameworksBuildPhase;
- 			buildActionMask = 2147483647;
- 			files = (
--				F92C565C0ECD1158009BE4BA /* breakpadUtilities.dylib in Frameworks */,
- 				8DC2EF570486A6940098B216 /* Cocoa.framework in Frameworks */,
- 			);
- 			runOnlyForDeploymentPostprocessing = 0;
-@@ -1181,18 +1168,13 @@
- 			isa = PBXNativeTarget;
- 			buildConfigurationList = 1DEB91AD08733DA50010E9CD /* Build configuration list for PBXNativeTarget "Breakpad" */;
- 			buildPhases = (
--				F97A0E850ED4EC15008784D3 /* Change install name of breakpadUtilities */,
- 				8DC2EF500486A6940098B216 /* Headers */,
--				8DC2EF520486A6940098B216 /* Resources */,
- 				8DC2EF540486A6940098B216 /* Sources */,
- 				8DC2EF560486A6940098B216 /* Frameworks */,
- 			);
- 			buildRules = (
- 			);
- 			dependencies = (
--				F92C56860ECD15EF009BE4BA /* PBXTargetDependency */,
--				F92C56880ECD15F1009BE4BA /* PBXTargetDependency */,
--				F9C44E970EF09F4B003AEBAA /* PBXTargetDependency */,
- 			);
- 			name = Breakpad;
- 			productInstallPath = "$(HOME)/Library/Frameworks";
-@@ -1399,6 +1381,8 @@
- /* Begin PBXProject section */
- 		0867D690FE84028FC02AAC07 /* Project object */ = {
- 			isa = PBXProject;
-+			attributes = {
-+			};
- 			buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "Breakpad" */;
- 			compatibilityVersion = "Xcode 3.1";
- 			developmentRegion = English;
-@@ -1583,16 +1567,6 @@
- /* End PBXReferenceProxy section */
- 
- /* Begin PBXResourcesBuildPhase section */
--		8DC2EF520486A6940098B216 /* Resources */ = {
--			isa = PBXResourcesBuildPhase;
--			buildActionMask = 2147483647;
--			files = (
--				F9C44E980EF09F56003AEBAA /* crash_report_sender.app in Resources */,
--				F92C568A0ECD15F9009BE4BA /* Inspector in Resources */,
--				F92C56650ECD1185009BE4BA /* breakpadUtilities.dylib in Resources */,
--			);
--			runOnlyForDeploymentPostprocessing = 0;
--		};
- 		F92C569C0ECE04A7009BE4BA /* Resources */ = {
- 			isa = PBXResourcesBuildPhase;
- 			buildActionMask = 2147483647;
-@@ -1640,20 +1614,6 @@
- 			shellPath = /bin/sh;
- 			shellScript = "install_name_tool -id \"@executable_path/../Resources/breakpadUtilities.dylib\" \"${BUILT_PRODUCTS_DIR}/breakpadUtilities.dylib\"\n";
- 		};
--		F97A0E850ED4EC15008784D3 /* Change install name of breakpadUtilities */ = {
--			isa = PBXShellScriptBuildPhase;
--			buildActionMask = 2147483647;
--			files = (
--			);
--			inputPaths = (
--			);
--			name = "Change install name of breakpadUtilities";
--			outputPaths = (
--			);
--			runOnlyForDeploymentPostprocessing = 0;
--			shellPath = /bin/sh;
--			shellScript = "#!/bin/bash\ninstall_name_tool -id \"@executable_path/../Frameworks/Breakpad.framework/Resources/breakpadUtilities.dylib\" \"${BUILT_PRODUCTS_DIR}/breakpadUtilities.dylib\"\n";
--		};
- 		F9C77DD80F7DD5CF0045F7DB /* ShellScript */ = {
- 			isa = PBXShellScriptBuildPhase;
- 			buildActionMask = 2147483647;
-@@ -1674,6 +1634,19 @@
- 			isa = PBXSourcesBuildPhase;
- 			buildActionMask = 2147483647;
- 			files = (
-+				0748C0501C63C52D004489BF /* bootstrap_compat.cc in Sources */,
-+				0748C04F1C63C523004489BF /* macho_walker.cc in Sources */,
-+				0748C04E1C63C51C004489BF /* md5.cc in Sources */,
-+				0748C04D1C63C50F004489BF /* file_id.cc in Sources */,
-+				0748C04C1C63C4EA004489BF /* macho_utilities.cc in Sources */,
-+				0748C04B1C63C4DB004489BF /* convert_UTF.c in Sources */,
-+				0748C04A1C63C4D4004489BF /* string_conversion.cc in Sources */,
-+				0748C0491C63C4CF004489BF /* macho_id.cc in Sources */,
-+				0748C0471C63C4A1004489BF /* dynamic_images.cc in Sources */,
-+				0748C0461C63C484004489BF /* minidump_file_writer.cc in Sources */,
-+				0748C0451C63C46C004489BF /* string_utilities.cc in Sources */,
-+				0748C0441C63C43C004489BF /* minidump_generator.cc in Sources */,
-+				0748C0431C63C409004489BF /* MachIPC.mm in Sources */,
- 				F92C565F0ECD116B009BE4BA /* protected_memory_allocator.cc in Sources */,
- 				F92C56630ECD1179009BE4BA /* exception_handler.cc in Sources */,
- 				F92C55D10ECD0064009BE4BA /* Breakpad.mm in Sources */,
-@@ -1955,16 +1928,6 @@
- 			target = F92C563B0ECD10B3009BE4BA /* breakpadUtilities */;
- 			targetProxy = F92C564D0ECD10E5009BE4BA /* PBXContainerItemProxy */;
- 		};
--		F92C56860ECD15EF009BE4BA /* PBXTargetDependency */ = {
--			isa = PBXTargetDependency;
--			target = F92C563B0ECD10B3009BE4BA /* breakpadUtilities */;
--			targetProxy = F92C56850ECD15EF009BE4BA /* PBXContainerItemProxy */;
--		};
--		F92C56880ECD15F1009BE4BA /* PBXTargetDependency */ = {
--			isa = PBXTargetDependency;
--			target = F92C53530ECCE349009BE4BA /* Inspector */;
--			targetProxy = F92C56870ECD15F1009BE4BA /* PBXContainerItemProxy */;
--		};
- 		F93DE2FC0F82C3C600608B94 /* PBXTargetDependency */ = {
- 			isa = PBXTargetDependency;
- 			target = F93803BD0F80820F004D428B /* generator_test */;
-@@ -2025,11 +1988,6 @@
- 			target = 8DC2EF4F0486A6940098B216 /* Breakpad */;
- 			targetProxy = F9C44E190EF0790F003AEBAA /* PBXContainerItemProxy */;
- 		};
--		F9C44E970EF09F4B003AEBAA /* PBXTargetDependency */ = {
--			isa = PBXTargetDependency;
--			target = F92C569F0ECE04A7009BE4BA /* crash_report_sender */;
--			targetProxy = F9C44E960EF09F4B003AEBAA /* PBXContainerItemProxy */;
--		};
- /* End PBXTargetDependency section */
- 
- /* Begin PBXVariantGroup section */
-@@ -2126,8 +2084,12 @@
- 			isa = XCBuildConfiguration;
- 			baseConfigurationReference = 8B31027711F0D3AF00FCF3E4 /* BreakpadDebug.xcconfig */;
- 			buildSettings = {
-+				CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
-+				CLANG_CXX_LIBRARY = "libc++";
- 				GCC_TREAT_WARNINGS_AS_ERRORS = NO;
--				SDKROOT = macosx10.5;
-+				GCC_VERSION = "";
-+				MACOSX_DEPLOYMENT_TARGET = 10.8;
-+				SDKROOT = macosx;
- 			};
- 			name = Debug;
- 		};
-@@ -2135,7 +2097,12 @@
- 			isa = XCBuildConfiguration;
- 			baseConfigurationReference = 8B31027811F0D3AF00FCF3E4 /* BreakpadRelease.xcconfig */;
- 			buildSettings = {
-+				CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
-+				CLANG_CXX_LIBRARY = "libc++";
- 				GCC_TREAT_WARNINGS_AS_ERRORS = NO;
-+				GCC_VERSION = "";
-+				MACOSX_DEPLOYMENT_TARGET = 10.8;
-+				SDKROOT = macosx;
- 			};
- 			name = Release;
- 		};
-@@ -2454,7 +2421,12 @@
- 			isa = XCBuildConfiguration;
- 			baseConfigurationReference = 8B31027711F0D3AF00FCF3E4 /* BreakpadDebug.xcconfig */;
- 			buildSettings = {
-+				CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
-+				CLANG_CXX_LIBRARY = "libc++";
- 				GCC_TREAT_WARNINGS_AS_ERRORS = NO;
-+				GCC_VERSION = "";
-+				MACOSX_DEPLOYMENT_TARGET = 10.8;
-+				SDKROOT = macosx;
- 			};
- 			name = "Debug With Code Coverage";
- 		};
-diff --git a/src/client/mac/Framework/Breakpad.mm b/src/client/mac/Framework/Breakpad.mm
-index 1d2e519..943310f 100644
---- a/src/client/mac/Framework/Breakpad.mm
-+++ b/src/client/mac/Framework/Breakpad.mm
-@@ -355,10 +355,10 @@ bool Breakpad::Initialize(NSDictionary *parameters) {
-     return false;
-   }
- 
--  if ([[parameters objectForKey:@BREAKPAD_IN_PROCESS] boolValue])
-+//  if ([[parameters objectForKey:@BREAKPAD_IN_PROCESS] boolValue])
-     return InitializeInProcess(parameters);
--  else
--    return InitializeOutOfProcess(parameters);
-+//  else
-+//    return InitializeOutOfProcess(parameters);
- }
- 
- //=============================================================================
-@@ -373,52 +373,52 @@ bool Breakpad::InitializeInProcess(NSDictionary* parameters) {
- }
- 
- //=============================================================================
--bool Breakpad::InitializeOutOfProcess(NSDictionary* parameters) {
--  // Get path to Inspector executable.
--  NSString *inspectorPathString = KeyValue(@BREAKPAD_INSPECTOR_LOCATION);
--
--  // Standardize path (resolve symlinkes, etc.)  and escape spaces
--  inspectorPathString = [inspectorPathString stringByStandardizingPath];
--  inspectorPathString = [[inspectorPathString componentsSeparatedByString:@" "]
--                                              componentsJoinedByString:@"\\ "];
--
--  // Create an on-demand server object representing the Inspector.
--  // In case of a crash, we simply need to call the LaunchOnDemand()
--  // method on it, then send a mach message to its service port.
--  // It will then launch and perform a process inspection of our crashed state.
--  // See the HandleException() method for the details.
--#define RECEIVE_PORT_NAME "com.Breakpad.Inspector"
--
--  name_t portName;
--  snprintf(portName, sizeof(name_t),  "%s%d", RECEIVE_PORT_NAME, getpid());
--
--  // Save the location of the Inspector
--  strlcpy(inspector_path_, [inspectorPathString fileSystemRepresentation],
--          sizeof(inspector_path_));
--
--  // Append a single command-line argument to the Inspector path
--  // representing the bootstrap name of the launch-on-demand receive port.
--  // When the Inspector is launched, it can use this to lookup the port
--  // by calling bootstrap_check_in().
--  strlcat(inspector_path_, " ", sizeof(inspector_path_));
--  strlcat(inspector_path_, portName, sizeof(inspector_path_));
--
--  kern_return_t kr = inspector_.Initialize(inspector_path_,
--                                           portName,
--                                           true);        // shutdown on exit
--
--  if (kr != KERN_SUCCESS) {
--    return false;
--  }
--
--  // Create the handler (allocating it in our special protected pool)
--  handler_ =
--      new (gBreakpadAllocator->Allocate(
--          sizeof(google_breakpad::ExceptionHandler)))
--          google_breakpad::ExceptionHandler(
--              Breakpad::ExceptionHandlerDirectCallback, this, true);
--  return true;
--}
-+//bool Breakpad::InitializeOutOfProcess(NSDictionary* parameters) {
-+//  // Get path to Inspector executable.
-+//  NSString *inspectorPathString = KeyValue(@BREAKPAD_INSPECTOR_LOCATION);
-+//
-+//  // Standardize path (resolve symlinkes, etc.)  and escape spaces
-+//  inspectorPathString = [inspectorPathString stringByStandardizingPath];
-+//  inspectorPathString = [[inspectorPathString componentsSeparatedByString:@" "]
-+//                                              componentsJoinedByString:@"\\ "];
-+//
-+//  // Create an on-demand server object representing the Inspector.
-+//  // In case of a crash, we simply need to call the LaunchOnDemand()
-+//  // method on it, then send a mach message to its service port.
-+//  // It will then launch and perform a process inspection of our crashed state.
-+//  // See the HandleException() method for the details.
-+//#define RECEIVE_PORT_NAME "com.Breakpad.Inspector"
-+//
-+//  name_t portName;
-+//  snprintf(portName, sizeof(name_t),  "%s%d", RECEIVE_PORT_NAME, getpid());
-+//
-+//  // Save the location of the Inspector
-+//  strlcpy(inspector_path_, [inspectorPathString fileSystemRepresentation],
-+//          sizeof(inspector_path_));
-+//
-+//  // Append a single command-line argument to the Inspector path
-+//  // representing the bootstrap name of the launch-on-demand receive port.
-+//  // When the Inspector is launched, it can use this to lookup the port
-+//  // by calling bootstrap_check_in().
-+//  strlcat(inspector_path_, " ", sizeof(inspector_path_));
-+//  strlcat(inspector_path_, portName, sizeof(inspector_path_));
-+//
-+//  kern_return_t kr = inspector_.Initialize(inspector_path_,
-+//                                           portName,
-+//                                           true);        // shutdown on exit
-+//
-+//  if (kr != KERN_SUCCESS) {
-+//    return false;
-+//  }
-+//
-+//  // Create the handler (allocating it in our special protected pool)
-+//  handler_ =
-+//      new (gBreakpadAllocator->Allocate(
-+//          sizeof(google_breakpad::ExceptionHandler)))
-+//          google_breakpad::ExceptionHandler(
-+//              Breakpad::ExceptionHandlerDirectCallback, this, true);
-+//  return true;
-+//}
- 
- //=============================================================================
- Breakpad::~Breakpad() {
-@@ -445,10 +445,10 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) {
-   NSString *version = [parameters objectForKey:@BREAKPAD_VERSION];
-   NSString *urlStr = [parameters objectForKey:@BREAKPAD_URL];
-   NSString *interval = [parameters objectForKey:@BREAKPAD_REPORT_INTERVAL];
--  NSString *inspectorPathString =
--      [parameters objectForKey:@BREAKPAD_INSPECTOR_LOCATION];
--  NSString *reporterPathString =
--      [parameters objectForKey:@BREAKPAD_REPORTER_EXE_LOCATION];
-+//  NSString *inspectorPathString =
-+//      [parameters objectForKey:@BREAKPAD_INSPECTOR_LOCATION];
-+//  NSString *reporterPathString =
-+//      [parameters objectForKey:@BREAKPAD_REPORTER_EXE_LOCATION];
-   NSString *timeout = [parameters objectForKey:@BREAKPAD_CONFIRM_TIMEOUT];
-   NSArray  *logFilePaths = [parameters objectForKey:@BREAKPAD_LOGFILES];
-   NSString *logFileTailSize =
-@@ -536,39 +536,39 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) {
-   }
- 
-   // Find the helper applications if not specified in user config.
--  NSString *resourcePath = nil;
--  if (!inspectorPathString || !reporterPathString) {
--    resourcePath = GetResourcePath();
--    if (!resourcePath) {
--      return false;
--    }
--  }
-+//  NSString *resourcePath = nil;
-+//  if (!inspectorPathString || !reporterPathString) {
-+//    resourcePath = GetResourcePath();
-+//    if (!resourcePath) {
-+//      return false;
-+//    }
-+//  }
- 
-   // Find Inspector.
--  if (!inspectorPathString) {
--    inspectorPathString =
--        [resourcePath stringByAppendingPathComponent:@"Inspector"];
--  }
--
--  // Verify that there is an Inspector tool.
--  if (![[NSFileManager defaultManager] fileExistsAtPath:inspectorPathString]) {
--    return false;
--  }
-+//  if (!inspectorPathString) {
-+//    inspectorPathString =
-+//        [resourcePath stringByAppendingPathComponent:@"Inspector"];
-+//  }
-+//
-+//  // Verify that there is an Inspector tool.
-+//  if (![[NSFileManager defaultManager] fileExistsAtPath:inspectorPathString]) {
-+//    return false;
-+//  }
- 
-   // Find Reporter.
--  if (!reporterPathString) {
--    reporterPathString =
--        [resourcePath
--         stringByAppendingPathComponent:@"crash_report_sender.app"];
--    reporterPathString =
--        [[NSBundle bundleWithPath:reporterPathString] executablePath];
--  }
-+//  if (!reporterPathString) {
-+//    reporterPathString =
-+//        [resourcePath
-+//         stringByAppendingPathComponent:@"crash_report_sender.app"];
-+//    reporterPathString =
-+//        [[NSBundle bundleWithPath:reporterPathString] executablePath];
-+//  }
- 
-   // Verify that there is a Reporter application.
--  if (![[NSFileManager defaultManager]
--             fileExistsAtPath:reporterPathString]) {
--    return false;
--  }
-+//  if (![[NSFileManager defaultManager]
-+//             fileExistsAtPath:reporterPathString]) {
-+//    return false;
-+//  }
- 
-   if (!dumpSubdirectory) {
-     dumpSubdirectory = @"";
-@@ -601,10 +601,10 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) {
-   dictionary.SetKeyValue(BREAKPAD_REPORT_INTERVAL, [interval UTF8String]);
-   dictionary.SetKeyValue(BREAKPAD_SKIP_CONFIRM,    [skipConfirm UTF8String]);
-   dictionary.SetKeyValue(BREAKPAD_CONFIRM_TIMEOUT, [timeout UTF8String]);
--  dictionary.SetKeyValue(BREAKPAD_INSPECTOR_LOCATION,
--                         [inspectorPathString fileSystemRepresentation]);
--  dictionary.SetKeyValue(BREAKPAD_REPORTER_EXE_LOCATION,
--                         [reporterPathString fileSystemRepresentation]);
-+//  dictionary.SetKeyValue(BREAKPAD_INSPECTOR_LOCATION,
-+//                         [inspectorPathString fileSystemRepresentation]);
-+//  dictionary.SetKeyValue(BREAKPAD_REPORTER_EXE_LOCATION,
-+//                         [reporterPathString fileSystemRepresentation]);
-   dictionary.SetKeyValue(BREAKPAD_LOGFILE_UPLOAD_SIZE,
-                          [logFileTailSize UTF8String]);
-   dictionary.SetKeyValue(BREAKPAD_REQUEST_COMMENTS,
-@@ -762,9 +762,9 @@ bool Breakpad::HandleException(int exception_type,
- bool Breakpad::HandleMinidump(const char *dump_dir, const char *minidump_id) {
-   google_breakpad::ConfigFile config_file;
-   config_file.WriteFile(dump_dir, config_params_, dump_dir, minidump_id);
--  google_breakpad::LaunchReporter(
--      config_params_->GetValueForKey(BREAKPAD_REPORTER_EXE_LOCATION),
--      config_file.GetFilePath());
-+//  google_breakpad::LaunchReporter(
-+//      config_params_->GetValueForKey(BREAKPAD_REPORTER_EXE_LOCATION),
-+//      config_file.GetFilePath());
-   return true;
- }
- 
diff --git a/Telegram/Patches/build_ffmpeg_win.sh b/Telegram/Patches/build_ffmpeg_win.sh
deleted file mode 100644
index 412034fef..000000000
--- a/Telegram/Patches/build_ffmpeg_win.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-set -e
-FullExecPath=$PWD
-pushd `dirname $0` > /dev/null
-FullScriptPath=`pwd`
-popd > /dev/null
-
-pacman --noconfirm -Sy
-pacman --noconfirm -S msys/make
-pacman --noconfirm -S mingw64/mingw-w64-x86_64-opus
-pacman --noconfirm -S diffutils
-pacman --noconfirm -S pkg-config
-
-PKG_CONFIG_PATH="/mingw64/lib/pkgconfig:$PKG_CONFIG_PATH"
-
-./configure --toolchain=msvc --disable-programs --disable-doc --disable-everything --enable-protocol=file --enable-libopus --enable-decoder=aac --enable-decoder=aac_latm --enable-decoder=aasc --enable-decoder=flac --enable-decoder=gif --enable-decoder=h264 --enable-decoder=mp1 --enable-decoder=mp1float --enable-decoder=mp2 --enable-decoder=mp2float --enable-decoder=mp3 --enable-decoder=mp3adu --enable-decoder=mp3adufloat --enable-decoder=mp3float --enable-decoder=mp3on4 --enable-decoder=mp3on4float --enable-decoder=mpeg4 --enable-decoder=msmpeg4v2 --enable-decoder=msmpeg4v3 --enable-decoder=wavpack --enable-decoder=opus --enable-decoder=pcm_alaw --enable-decoder=pcm_alaw_at --enable-decoder=pcm_f32be --enable-decoder=pcm_f32le --enable-decoder=pcm_f64be --enable-decoder=pcm_f64le --enable-decoder=pcm_lxf --enable-decoder=pcm_mulaw --enable-decoder=pcm_mulaw_at --enable-decoder=pcm_s16be --enable-decoder=pcm_s16be_planar --enable-decoder=pcm_s16le --enable-decoder=pcm_s16le_planar --enable-decoder=pcm_s24be --enable-decoder=pcm_s24daud --enable-decoder=pcm_s24le --enable-decoder=pcm_s24le_planar --enable-decoder=pcm_s32be --enable-decoder=pcm_s32le --enable-decoder=pcm_s32le_planar --enable-decoder=pcm_s64be --enable-decoder=pcm_s64le --enable-decoder=pcm_s8 --enable-decoder=pcm_s8_planar --enable-decoder=pcm_u16be --enable-decoder=pcm_u16le --enable-decoder=pcm_u24be --enable-decoder=pcm_u24le --enable-decoder=pcm_u32be --enable-decoder=pcm_u32le --enable-decoder=pcm_u8 --enable-decoder=pcm_zork --enable-decoder=vorbis --enable-decoder=wmalossless --enable-decoder=wmapro --enable-decoder=wmav1 --enable-decoder=wmav2 --enable-decoder=wmavoice --enable-encoder=libopus --enable-hwaccel=h264_d3d11va --enable-hwaccel=h264_dxva2 --enable-parser=aac --enable-parser=aac_latm --enable-parser=flac --enable-parser=h264 --enable-parser=mpeg4video --enable-parser=mpegaudio --enable-parser=opus --enable-parser=vorbis --enable-demuxer=aac --enable-demuxer=flac --enable-demuxer=gif --enable-demuxer=h264 --enable-demuxer=mov --enable-demuxer=mp3 --enable-demuxer=ogg --enable-demuxer=wav --enable-muxer=ogg --enable-muxer=opus --extra-ldflags="-libpath:$FullExecPath/../opus/win32/VS2015/Win32/Release"
-
-make -j4
-make -j4 install
diff --git a/Telegram/Patches/gyp.diff b/Telegram/Patches/gyp.diff
deleted file mode 100644
index e0b55c1c5..000000000
--- a/Telegram/Patches/gyp.diff
+++ /dev/null
@@ -1,80 +0,0 @@
-diff --git a/pylib/gyp/generator/cmake.py b/pylib/gyp/generator/cmake.py
-index a2b9629..68d7020 100644
---- a/pylib/gyp/generator/cmake.py
-+++ b/pylib/gyp/generator/cmake.py
-@@ -1070,6 +1070,23 @@ def WriteTarget(namer, qualified_target, target_dicts, build_dir, config_to_use,
- 
-       output.write(')\n')
- 
-+  # Precompile header
-+  precompiled_header = config.get('cmake_precompiled_header', '')
-+  if precompiled_header:
-+    precompiled_header_script = config.get('cmake_precompiled_header_script', '')
-+    if not precompiled_header_script:
-+      print ('ERROR: cmake_precompiled_header requires cmake_precompiled_header_script')
-+    cmake_precompiled_header = NormjoinPath(path_from_cmakelists_to_gyp, precompiled_header)
-+    cmake_precompiled_header_script = NormjoinPathForceCMakeSource(path_from_cmakelists_to_gyp, precompiled_header_script)
-+    output.write('include(')
-+    output.write(cmake_precompiled_header_script)
-+    output.write(')\n')
-+    output.write('add_precompiled_header(')
-+    output.write(cmake_target_name)
-+    output.write(' ')
-+    output.write(cmake_precompiled_header)
-+    output.write(')\n')
-+
-   UnsetVariable(output, 'TOOLSET')
-   UnsetVariable(output, 'TARGET')
- 
-diff --git a/pylib/gyp/generator/xcode.py b/pylib/gyp/generator/xcode.py
-index db99d6a..8d56baf 100644
---- a/pylib/gyp/generator/xcode.py
-+++ b/pylib/gyp/generator/xcode.py
-@@ -72,6 +72,10 @@ generator_additional_non_configuration_keys = [
-   'ios_app_extension',
-   'ios_watch_app',
-   'ios_watchkit_extension',
-+
-+  'mac_sandbox', # sandbox support
-+  'mac_sandbox_development_team',
-+
-   'mac_bundle',
-   'mac_bundle_resources',
-   'mac_framework_headers',
-@@ -772,6 +776,26 @@ def GenerateOutput(target_list, target_dicts, data, params):
-     xcode_targets[qualified_target] = xct
-     xcode_target_to_target_dict[xct] = spec
- 
-+    # sandbox support
-+    is_sandbox = int(spec.get('mac_sandbox', 0))
-+    if is_sandbox:
-+      dev_team = spec.get('mac_sandbox_development_team', '%%ERROR%%')
-+      assert dev_team != '%%ERROR%%', (
-+          'mac_sandbox must be accompanied by mac_sandbox_development_team (target "%s")' %
-+          target_name)
-+      try:
-+        tmp =  pbxp._properties['attributes']['TargetAttributes']
-+      except KeyError:
-+        pbxp._properties['attributes']['TargetAttributes'] = {}
-+      pbxp._properties['attributes']['TargetAttributes'][xct] = {
-+        'DevelopmentTeam': dev_team,
-+        'SystemCapabilities': {
-+          'com.apple.Sandbox': {
-+            'enabled': 1,
-+          },
-+        },
-+      }
-+
-     spec_actions = spec.get('actions', [])
-     spec_rules = spec.get('rules', [])
- 
-@@ -1141,7 +1165,8 @@ exit 1
-         groups = [x for x in groups if not x.endswith('_excluded')]
-       for group in groups:
-         for item in rule.get(group, []):
--          pbxp.AddOrGetFileInRootGroup(item)
-+          concrete_item = ExpandXcodeVariables(item, rule_input_dict)
-+          pbxp.AddOrGetFileInRootGroup(concrete_item)
- 
-     # Add "sources".
-     for source in spec.get('sources', []):
diff --git a/Telegram/Patches/macold/crashpad.diff b/Telegram/Patches/macold/crashpad.diff
deleted file mode 100644
index 7aa23102b..000000000
--- a/Telegram/Patches/macold/crashpad.diff
+++ /dev/null
@@ -1,20 +0,0 @@
-diff --git a/build/crashpad.gypi b/build/crashpad.gypi
-index 027c7b6..4bfdfb5 100644
---- a/build/crashpad.gypi
-+++ b/build/crashpad.gypi
-@@ -25,5 +25,15 @@
-       4201,  # nonstandard extension used : nameless struct/union.
-       4324,  # structure was padded due to __declspec(align()).
-     ],
-+    'xcode_settings': {
-+      'OTHER_CPLUSPLUSFLAGS': [ '-nostdinc++' ],
-+      'OTHER_LDFLAGS': [
-+        '/usr/local/macold/lib/libc++.a',
-+        '/usr/local/macold/lib/libc++abi.a',
-+      ],
-+    },
-+    'include_dirs': [
-+      '/usr/local/macold/include/c++/v1',
-+    ],
-   },
- }
diff --git a/Telegram/Patches/macold/mini_chromium.diff b/Telegram/Patches/macold/mini_chromium.diff
deleted file mode 100644
index 50aa1dc3e..000000000
--- a/Telegram/Patches/macold/mini_chromium.diff
+++ /dev/null
@@ -1,26 +0,0 @@
-diff --git a/build/common.gypi b/build/common.gypi
-index 1affc70..c0d2f6a 100644
---- a/build/common.gypi
-+++ b/build/common.gypi
-@@ -66,6 +66,11 @@
-           'conditions': [
-             ['clang!=0', {
-               'CLANG_CXX_LANGUAGE_STANDARD': 'c++11',  # -std=c++11
-+              'OTHER_CPLUSPLUSFLAGS': [ '-nostdinc++' ],
-+              'OTHER_LDFLAGS': [
-+                '/usr/local/macold/lib/libc++.a',
-+                '/usr/local/macold/lib/libc++abi.a',
-+              ],
- 
-               # Don't link in libarclite_macosx.a, see http://crbug.com/156530.
-               'CLANG_LINK_OBJC_RUNTIME': 'NO',      # -fno-objc-link-runtime
-@@ -116,6 +121,9 @@
-           ],
- 
-         },
-+        'include_dirs': [
-+          '/usr/local/macold/include/c++/v1',
-+        ],
-       }],
- 
-       ['OS=="linux"', {
diff --git a/Telegram/Patches/macold/qtbase_5_3_2.diff b/Telegram/Patches/macold/qtbase_5_3_2.diff
deleted file mode 100644
index 552623148..000000000
--- a/Telegram/Patches/macold/qtbase_5_3_2.diff
+++ /dev/null
@@ -1,784 +0,0 @@
-diff --git a/configure b/configure
-index cb8d78f..cadb3f0 100755
---- a/configure
-+++ b/configure
-@@ -511,7 +511,8 @@ if [ "$BUILD_ON_MAC" = "yes" ]; then
-         exit 2
-     fi
- 
--    if ! /usr/bin/xcrun -find xcrun >/dev/null 2>&1; then
-+    # Patch: Fix Qt for working with Xcode 8.
-+    if ! /usr/bin/xcrun -find xcodebuild >/dev/null 2>&1; then
-         echo >&2
-         echo "   Xcode not set up properly. You may need to confirm the license" >&2
-         echo "   agreement by running /usr/bin/xcodebuild without arguments." >&2
-diff --git a/mkspecs/common/g++-macx.conf b/mkspecs/common/g++-macx.conf
-index 086510d..c485967 100644
---- a/mkspecs/common/g++-macx.conf
-+++ b/mkspecs/common/g++-macx.conf
-@@ -14,7 +14,13 @@ QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -gdwarf-2
- QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO += -gdwarf-2
- QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO += -g -gdwarf-2
- 
--QMAKE_LFLAGS_STATIC_LIB += -all_load
-+# Patch: Don't remember :(
-+#QMAKE_LFLAGS_STATIC_LIB += -all_load
-+
-+# Patch: Use C++14 with custom libc++ build.
-+QMAKE_CXXFLAGS_CXX11 = -std=c++1y
-+QMAKE_CXXFLAGS += -nostdinc++ -I/usr/local/macold/include/c++/v1
-+QMAKE_LFLAGS += /usr/local/macold/lib/libc++.a /usr/local/macold/lib/libc++abi.a
- 
- QMAKE_XCODE_GCC_VERSION = com.apple.compilers.llvmgcc42
- 
-diff --git a/mkspecs/features/mac/default_pre.prf b/mkspecs/features/mac/default_pre.prf
-index 0cc8cd6..ca9725b 100644
---- a/mkspecs/features/mac/default_pre.prf
-+++ b/mkspecs/features/mac/default_pre.prf
-@@ -12,7 +12,9 @@ isEmpty(QMAKE_XCODE_DEVELOPER_PATH) {
-         error("Xcode is not installed in $${QMAKE_XCODE_DEVELOPER_PATH}. Please use xcode-select to choose Xcode installation path.")
- 
-     # Make sure Xcode is set up properly
--    isEmpty($$list($$system("/usr/bin/xcrun -find xcrun 2>/dev/null"))): \
-+
-+    # Patch: Fix Qt for working with Xcode 8.
-+    isEmpty($$list($$system("/usr/bin/xcrun -find xcodebuild 2>/dev/null"))): \
-         error("Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild.")
- }
- 
-diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp
-index bb79a13..5d595bc 100644
---- a/src/gui/image/qbmphandler.cpp
-+++ b/src/gui/image/qbmphandler.cpp
-@@ -220,6 +220,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int
-     int blue_scale = 0;
-     int alpha_scale = 0;
- 
-+    // Patch: Backport a fix for bmp reader.
-+    if (!d->isSequential())
-+        d->seek(startpos + BMP_FILEHDR_SIZE + (bi.biSize >= BMP_WIN4? BMP_WIN : bi.biSize)); // goto start of colormap
-+
-     if (bi.biSize >= BMP_WIN4 || (comp == BMP_BITFIELDS && (nbits == 16 || nbits == 32))) {
-         if (d->read((char *)&red_mask, sizeof(red_mask)) != sizeof(red_mask))
-             return false;
-@@ -307,8 +311,9 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int
-     image.setDotsPerMeterX(bi.biXPelsPerMeter);
-     image.setDotsPerMeterY(bi.biYPelsPerMeter);
- 
--    if (!d->isSequential())
--        d->seek(startpos + BMP_FILEHDR_SIZE + (bi.biSize >= BMP_WIN4? BMP_WIN : bi.biSize)); // goto start of colormap
-+    // Patch: Backport a fix for bmp reader.
-+    //if (!d->isSequential())
-+    //    d->seek(startpos + BMP_FILEHDR_SIZE + (bi.biSize >= BMP_WIN4? BMP_WIN : bi.biSize)); // goto start of colormap
- 
-     if (ncols > 0) {                                // read color table
-         uchar rgb[4];
-diff --git a/src/gui/painting/qpaintengine_p.h b/src/gui/painting/qpaintengine_p.h
-index ebff950..4300ca4 100644
---- a/src/gui/painting/qpaintengine_p.h
-+++ b/src/gui/painting/qpaintengine_p.h
-@@ -87,8 +87,18 @@ public:
-         if (hasSystemTransform) {
-             if (systemTransform.type() <= QTransform::TxTranslate)
-                 systemClip.translate(qRound(systemTransform.dx()), qRound(systemTransform.dy()));
--            else
-+            // Patch: Transform the system clip region back from device pixels to device-independent pixels before
-+            // applying systemTransform, which already has transform from device-independent pixels to device pixels.
-+            else {
-+#ifdef Q_OS_MAC
-+                QTransform scaleTransform;
-+                const qreal invDevicePixelRatio = 1. / pdev->devicePixelRatio();
-+                scaleTransform.scale(invDevicePixelRatio, invDevicePixelRatio);
-+                systemClip = systemTransform.map(scaleTransform.map(systemClip));
-+#else
-                 systemClip = systemTransform.map(systemClip);
-+#endif
-+            }
-         }
- 
-         // Make sure we're inside the viewport.
-diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
-index 4879ae5..56cdcba 100644
---- a/src/gui/text/qtextlayout.cpp
-+++ b/src/gui/text/qtextlayout.cpp
-@@ -654,6 +654,9 @@ int QTextLayout::nextCursorPosition(int oldPos, CursorMode mode) const
-         while (oldPos < len && !attributes[oldPos].graphemeBoundary)
-             oldPos++;
-     } else {
-+        // Patch: Skip to the end of the current word, not to the start of the next one.
-+        while (oldPos < len && attributes[oldPos].whiteSpace)
-+            oldPos++;
-         if (oldPos < len && d->atWordSeparator(oldPos)) {
-             oldPos++;
-             while (oldPos < len && d->atWordSeparator(oldPos))
-@@ -662,8 +665,9 @@ int QTextLayout::nextCursorPosition(int oldPos, CursorMode mode) const
-             while (oldPos < len && !d->atSpace(oldPos) && !d->atWordSeparator(oldPos))
-                 oldPos++;
-         }
--        while (oldPos < len && d->atSpace(oldPos))
--            oldPos++;
-+        // Patch: Skip to the end of the current word, not to the start of the next one.
-+        //while (oldPos < len && d->atSpace(oldPos))
-+        //    oldPos++;
-     }
- 
-     return oldPos;
-@@ -1602,6 +1606,9 @@ namespace {
-         int currentPosition;
-         glyph_t previousGlyph;
- 
-+        // Patch: Backport a crash fix.
-+        QFontEngine *previousGlyphFontEngine;
-+
-         QFixed minw;
-         QFixed softHyphenWidth;
-         QFixed rightBearing;
-@@ -1634,13 +1641,19 @@ namespace {
-             if (currentPosition > 0 &&
-                 logClusters[currentPosition - 1] < glyphs.numGlyphs) {
-                 previousGlyph = currentGlyph(); // needed to calculate right bearing later
-+
-+                // Patch: Backport a crash fix.
-+                previousGlyphFontEngine = fontEngine;
-             }
-         }
- 
--        inline void adjustRightBearing(glyph_t glyph)
-+        // Patch: Backport a crash fix.
-+        inline void adjustRightBearing(QFontEngine *engine, glyph_t glyph)
-         {
-             qreal rb;
--            fontEngine->getGlyphBearings(glyph, 0, &rb);
-+
-+            // Patch: Backport a crash fix.
-+            engine->getGlyphBearings(glyph, 0, &rb);
-             rightBearing = qMin(QFixed(), QFixed::fromReal(rb));
-         }
- 
-@@ -1648,13 +1661,16 @@ namespace {
-         {
-             if (currentPosition <= 0)
-                 return;
--            adjustRightBearing(currentGlyph());
-+
-+            // Patch: Backport a crash fix.
-+            adjustRightBearing(fontEngine, currentGlyph());
-         }
- 
-         inline void adjustPreviousRightBearing()
-         {
-             if (previousGlyph > 0)
--                adjustRightBearing(previousGlyph);
-+                // Patch: Backport a crash fix.
-+                adjustRightBearing(previousGlyphFontEngine, previousGlyph);
-         }
- 
-         inline void resetRightBearing()
-diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h
-index cbe42c3..b273db7 100644
---- a/src/gui/text/qtextlayout.h
-+++ b/src/gui/text/qtextlayout.h
-@@ -194,6 +194,9 @@ private:
-                                QRectF *brect, int tabstops, int* tabarray, int tabarraylen,
-                                QPainter *painter);
-     QTextEngine *d;
-+
-+    // Patch: Give access to the internal api.
-+    friend class TextBlock;
- };
- 
- 
-diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
-index ca7afb7..25ae500 100644
---- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
-+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
-@@ -256,6 +256,13 @@ static void getFontDescription(CTFontDescriptorRef font, FontDescription *fd)
- 
-     fd->foundryName = QStringLiteral("CoreText");
-     fd->familyName = (CFStringRef) CTFontDescriptorCopyAttribute(font, kCTFontFamilyNameAttribute);
-+
-+    // Patch: Fix open sans semibold loading.
-+    QCFString _displayName = (CFStringRef) CTFontDescriptorCopyAttribute(font, kCTFontDisplayNameAttribute);
-+    if (_displayName == QStringLiteral("Open Sans Semibold")) {
-+        fd->familyName = _displayName;
-+    }
-+
-     fd->styleName = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontStyleNameAttribute);
-     fd->weight = QFont::Normal;
-     fd->style = QFont::StyleNormal;
-diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
-index 92358ec..694fee7 100644
---- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
-+++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
-@@ -213,7 +213,8 @@ static void cleanupCocoaApplicationDelegate()
-     if (reflectionDelegate) {
-         if ([reflectionDelegate respondsToSelector:@selector(applicationShouldTerminate:)])
-             return [reflectionDelegate applicationShouldTerminate:sender];
--        return NSTerminateNow;
-+        // Patch: Don't terminate if reflectionDelegate does not respond to that selector, just use the default.
-+        //return NSTerminateNow;
-     }
- 
-     if ([self canQuit]) {
-@@ -289,6 +290,11 @@ static void cleanupCocoaApplicationDelegate()
- 
- - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
- {
-+    // Patch: We need to receive this notification in the delegate as well.
-+    if (reflectionDelegate
-+        && [reflectionDelegate respondsToSelector:@selector(applicationDidFinishLaunching:)])
-+        [reflectionDelegate applicationDidFinishLaunching:aNotification];
-+
-     Q_UNUSED(aNotification);
-     inLaunch = false;
-     // qt_release_apple_event_handler();
-@@ -411,7 +417,9 @@ static void cleanupCocoaApplicationDelegate()
- {
-     Q_UNUSED(replyEvent);
-     NSString *urlString = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
--    QWindowSystemInterface::handleFileOpenEvent(QUrl(QCFString::toQString(urlString)));
-+
-+    // Patch: Fix opening of an external url by a protocol handler.
-+    QWindowSystemInterface::handleFileOpenEvent(QUrl::fromNSURL([NSURL URLWithString:urlString]));
- }
- 
- - (void)appleEventQuit:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
-diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm
-index b81b9a0..4e59e83 100644
---- a/src/plugins/platforms/cocoa/qcocoacursor.mm
-+++ b/src/plugins/platforms/cocoa/qcocoacursor.mm
-@@ -81,7 +81,7 @@ void QCocoaCursor::setPos(const QPoint &position)
-     pos.x = position.x();
-     pos.y = position.y();
- 
--    CGEventRef e = CGEventCreateMouseEvent(0, kCGEventMouseMoved, pos, 0);
-+    CGEventRef e = CGEventCreateMouseEvent(0, kCGEventMouseMoved, pos, kCGMouseButtonLeft);
-     CGEventPost(kCGHIDEventTap, e);
-     CFRelease(e);
- }
-diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
-index 9fd05a6..dea6072 100644
---- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
-+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
-@@ -402,14 +402,24 @@ void QCocoaIntegration::updateScreens()
-         }
-         siblings << screen;
-     }
-+
-+    // Patch: Backport crash fix from Qt 5.6.1.
-+    // Set virtual siblings list. All screens in mScreens are siblings, because we ignored the
-+    // mirrors. Note that some of the screens we update the siblings list for here may be deleted
-+    // below, but update anyway to keep the to-be-deleted screens out of the siblings list.
-+    foreach (QCocoaScreen* screen, mScreens)
-+        screen->setVirtualSiblings(siblings);
-+
-     // Now the leftovers in remainingScreens are no longer current, so we can delete them.
-     foreach (QCocoaScreen* screen, remainingScreens) {
-         mScreens.removeOne(screen);
-         delete screen;
-     }
-+
-+    // Patch: Backport crash fix from Qt 5.6.1.
-     // All screens in mScreens are siblings, because we ignored the mirrors.
--    foreach (QCocoaScreen* screen, mScreens)
--        screen->setVirtualSiblings(siblings);
-+    //foreach (QCocoaScreen* screen, mScreens)
-+    //    screen->setVirtualSiblings(siblings);
- }
- 
- QCocoaScreen *QCocoaIntegration::screenAtIndex(int index)
-diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.mm b/src/plugins/platforms/cocoa/qcocoakeymapper.mm
-index e46eaff..c62db53 100644
---- a/src/plugins/platforms/cocoa/qcocoakeymapper.mm
-+++ b/src/plugins/platforms/cocoa/qcocoakeymapper.mm
-@@ -382,6 +382,12 @@ bool QCocoaKeyMapper::updateKeyboard()
-         keyboardInputLocale = QLocale::c();
-         keyboardInputDirection = Qt::LeftToRight;
-     }
-+
-+    // Patch: Backport a fix for layout-independent keyboard shortcuts.
-+    const auto newMode = keyboard_mode;
-+    deleteLayouts();
-+    keyboard_mode = newMode;
-+
-     return true;
- }
- 
-@@ -464,7 +470,8 @@ QList<int> QCocoaKeyMapper::possibleKeys(const QKeyEvent *event) const
-         Qt::KeyboardModifiers neededMods = ModsTbl[i];
-         int key = kbItem->qtKey[i];
-         if (key && key != baseKey && ((keyMods & neededMods) == neededMods)) {
--            ret << int(key + (keyMods & ~neededMods));
-+            // Patch: Backport a fix for layout-independent keyboard shortcuts.
-+            ret << int(key + neededMods);
-         }
-     }
-     return ret;
-diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
-index 83c960d..03ae969 100755
---- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
-+++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
-@@ -102,7 +102,10 @@ QT_USE_NAMESPACE
-     QCocoaSystemTrayIcon *systray;
-     NSStatusItem *item;
-     QCocoaMenu *menu;
--    bool menuVisible;
-+
-+    // Patch: Nice macOS tray icon support.
-+    bool menuVisible, iconSelected;
-+
-     QIcon icon;
-     QT_MANGLE_NAMESPACE(QNSImageView) *imageCell;
- }
-@@ -124,6 +127,10 @@ QT_USE_NAMESPACE
-     QT_MANGLE_NAMESPACE(QNSStatusItem) *parent;
- }
- -(id)initWithParent:(QT_MANGLE_NAMESPACE(QNSStatusItem)*)myParent;
-+
-+// Patch: Nice macOS tray icon support.
-+-(void)updateIconSelection;
-+
- -(void)menuTrackingDone:(NSNotification*)notification;
- -(void)mousePressed:(NSEvent *)mouseEvent button:(Qt::MouseButton)mouseButton;
- @end
-@@ -187,6 +194,19 @@ void QCocoaSystemTrayIcon::cleanup()
-     m_sys = 0;
- }
- 
-+// Patch: Nice macOS tray icon support.
-+namespace {
-+
-+qreal getDevicePixelRatio() {
-+    qreal result = 1.0;
-+    foreach (QScreen *screen, QGuiApplication::screens()) {
-+        result = qMax(result, screen->devicePixelRatio());
-+    }
-+    return result;
-+}
-+
-+} // namespace
-+
- void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon)
- {
-     if (!m_sys)
-@@ -194,13 +214,18 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon)
- 
-     m_sys->item->icon = icon;
- 
--    const bool menuVisible = m_sys->item->menu && m_sys->item->menuVisible;
-+    // Patch: Nice macOS tray icon support.
-+    //const bool menuVisible = m_sys->item->menu && m_sys->item->menuVisible;
- 
--    CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
--    const short scale = hgt - 4;
-+    const int padding = 0;
-+    const int menuHeight = [[NSStatusBar systemStatusBar] thickness];
-+    const int maxImageHeight = menuHeight - padding;
-+
-+    const short scale = maxImageHeight * getDevicePixelRatio();
- 
-     QPixmap pm = m_sys->item->icon.pixmap(QSize(scale, scale),
--                                          menuVisible ? QIcon::Selected : QIcon::Normal);
-+                                          // Patch: Nice macOS tray icon support.
-+                                          m_sys->item->iconSelected ? QIcon::Selected : QIcon::Normal);
-     if (pm.isNull()) {
-         pm = QPixmap(scale, scale);
-         pm.fill(Qt::transparent);
-@@ -322,15 +347,16 @@ QT_END_NAMESPACE
-     return self;
- }
- 
---(void)menuTrackingDone:(NSNotification*)notification
-+// Patch: Nice macOS tray icon support.
-+-(void)updateIconSelection
- {
--    Q_UNUSED(notification);
--    down = NO;
-+    const int padding = 0;
-+    const int menuHeight = [[NSStatusBar systemStatusBar] thickness];
-+    const int maxImageHeight = menuHeight - padding;
- 
--    CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
--    const short scale = hgt - 4;
--
--    QPixmap pm = parent->icon.pixmap(QSize(scale, scale), QIcon::Normal);
-+    const short scale = maxImageHeight * getDevicePixelRatio();
-+    QPixmap pm = parent->icon.pixmap(QSize(scale, scale),
-+    parent->iconSelected ? QIcon::Selected : QIcon::Normal);
-     if (pm.isNull()) {
-         pm = QPixmap(scale, scale);
-         pm.fill(Qt::transparent);
-@@ -338,9 +364,19 @@ QT_END_NAMESPACE
-     NSImage *nsaltimage = static_cast<NSImage *>(qt_mac_create_nsimage(pm));
-     [self setImage: nsaltimage];
-     [nsaltimage release];
-+}
-+
-+-(void)menuTrackingDone:(NSNotification*)notification
-+{
-+    Q_UNUSED(notification);
-+    down = NO;
- 
-     parent->menuVisible = false;
- 
-+    // Patch: Nice macOS tray icon support.
-+    parent->iconSelected = false;
-+    [self updateIconSelection];
-+
-     [self setNeedsDisplay:YES];
- }
- 
-@@ -350,18 +386,9 @@ QT_END_NAMESPACE
-     int clickCount = [mouseEvent clickCount];
-     [self setNeedsDisplay:YES];
- 
--    CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
--    const short scale = hgt - 4;
--
--    QPixmap pm = parent->icon.pixmap(QSize(scale, scale),
--                                     parent->menuVisible ? QIcon::Selected : QIcon::Normal);
--    if (pm.isNull()) {
--        pm = QPixmap(scale, scale);
--        pm.fill(Qt::transparent);
--    }
--    NSImage *nsaltimage = static_cast<NSImage *>(qt_mac_create_nsimage(pm));
--    [self setImage: nsaltimage];
--    [nsaltimage release];
-+    // Patch: Nice macOS tray icon support.
-+    parent->iconSelected = (clickCount != 2) && parent->menu;
-+    [self updateIconSelection];
- 
-     if (clickCount == 2) {
-         [self menuTrackingDone:nil];
-@@ -380,6 +407,10 @@ QT_END_NAMESPACE
- {
-     Q_UNUSED(mouseEvent);
-     [self menuTrackingDone:nil];
-+
-+    // Patch: Nice macOS tray icon support.
-+    parent->iconSelected = false;
-+    [self updateIconSelection];
- }
- 
- - (void)rightMouseDown:(NSEvent *)mouseEvent
-@@ -391,6 +422,10 @@ QT_END_NAMESPACE
- {
-     Q_UNUSED(mouseEvent);
-     [self menuTrackingDone:nil];
-+
-+    // Patch: Nice macOS tray icon support.
-+    parent->iconSelected = false;
-+    [self updateIconSelection];
- }
- 
- - (void)otherMouseDown:(NSEvent *)mouseEvent
-@@ -405,7 +440,8 @@ QT_END_NAMESPACE
- }
- 
- -(void)drawRect:(NSRect)rect {
--    [[parent item] drawStatusBarBackgroundInRect:rect withHighlight:down];
-+    // Patch: Nice macOS tray icon support.
-+    [[parent item] drawStatusBarBackgroundInRect:rect withHighlight:parent->menu ? down : NO];
-     [super drawRect:rect];
- }
- @end
-diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
-index 4d0458a..3357a5e 100644
---- a/src/plugins/platforms/cocoa/qcocoawindow.mm
-+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
-@@ -167,7 +167,8 @@ static bool isMouseEvent(NSEvent *ev)
-     if (!self.window.delegate)
-         return; // Already detached, pending NSAppKitDefined event
- 
--    if (pw && pw->frameStrutEventsEnabled() && isMouseEvent(theEvent)) {
-+    // Patch: Fix events loss if the window was minimized or hidden.
-+    if (pw && pw->frameStrutEventsEnabled() && pw->m_synchedWindowState != Qt::WindowMinimized && pw->m_isExposed && isMouseEvent(theEvent)) {
-         NSPoint loc = [theEvent locationInWindow];
-         NSRect windowFrame = [self.window legacyConvertRectFromScreen:[self.window frame]];
-         NSRect contentFrame = [[self.window contentView] frame];
-@@ -795,6 +796,16 @@ NSUInteger QCocoaWindow::windowStyleMask(Qt::WindowFlags flags)
- {
-     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
-     NSInteger styleMask = NSBorderlessWindowMask;
-+
-+    // Patch: allow creating panels floating on all spaces in macOS.
-+    // If you call "setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary" before
-+    // setting the "NSNonactivatingPanelMask" bit in the style mask it won't work after that.
-+    // So we need a way to set that bit before Qt sets collection behavior the way it does.
-+    QVariant nonactivatingPanelMask = window()->property("_td_macNonactivatingPanelMask");
-+    if (nonactivatingPanelMask.isValid() && nonactivatingPanelMask.toBool()) {
-+        styleMask |= NSNonactivatingPanelMask;
-+    }
-+
-     if (flags & Qt::FramelessWindowHint)
-         return styleMask;
-     if ((type & Qt::Popup) == Qt::Popup) {
-@@ -914,6 +925,19 @@ void QCocoaWindow::setWindowFilePath(const QString &filePath)
-     [m_nsWindow setRepresentedFilename: fi.exists() ? QCFString::toNSString(filePath) : @""];
- }
- 
-+// Patch: Nice macOS window icon.
-+namespace {
-+
-+qreal getDevicePixelRatio() {
-+	qreal result = 1.0;
-+	foreach (QScreen *screen, QGuiApplication::screens()) {
-+		result = qMax(result, screen->devicePixelRatio());
-+	}
-+	return result;
-+}
-+
-+} // namespace
-+
- void QCocoaWindow::setWindowIcon(const QIcon &icon)
- {
-     QCocoaAutoReleasePool pool;
-@@ -929,7 +953,10 @@ void QCocoaWindow::setWindowIcon(const QIcon &icon)
-     if (icon.isNull()) {
-         [iconButton setImage:nil];
-     } else {
--        QPixmap pixmap = icon.pixmap(QSize(22, 22));
-+        // Patch: Nice macOS window icon.
-+        CGFloat hgt = 16. * getDevicePixelRatio();
-+        QPixmap pixmap = icon.pixmap(QSize(hgt, hgt));
-+
-         NSImage *image = static_cast<NSImage *>(qt_mac_create_nsimage(pixmap));
-         [iconButton setImage:image];
-         [image release];
-diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
-index a18ee7f..1f91feb 100644
---- a/src/plugins/platforms/cocoa/qnsview.mm
-+++ b/src/plugins/platforms/cocoa/qnsview.mm
-@@ -393,7 +393,9 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
-         [self notifyWindowStateChanged:newState];
-         // NSWindowDidOrderOnScreenAndFinishAnimatingNotification is private API, and not
-         // emitted in 10.6, so we bring back the old behavior for that case alone.
--        if (newState == Qt::WindowNoState && QSysInfo::QSysInfo::MacintoshVersion == QSysInfo::MV_10_6)
-+
-+        // Patch: Fix macOS window show after window was hidden.
-+        if (newState == Qt::WindowNoState/* && QSysInfo::QSysInfo::MacintoshVersion == QSysInfo::MV_10_6*/)
-             m_platformWindow->exposeWindow();
-     } else if ([notificationName isEqualToString: @"NSWindowDidOrderOffScreenNotification"]) {
-         m_platformWindow->obscureWindow();
-@@ -1300,7 +1302,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
- #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
-         if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
-             // On 10.8 and above, MayBegin is likely to happen.  We treat it the same as an actual begin.
--            if (phase == NSEventPhaseMayBegin)
-+
-+            // Patch: Actual begin should be treated as begin as well.
-+            if (phase == NSEventPhaseMayBegin || phase == NSEventPhaseBegan)
-                 ph = Qt::ScrollBegin;
-         } else
- #endif
-@@ -1366,14 +1370,22 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
-     quint32 nativeVirtualKey = [nsevent keyCode];
- 
-     QChar ch = QChar::ReplacementCharacter;
--    int keyCode = Qt::Key_unknown;
--    if ([characters length] != 0) {
--        if (((modifiers & Qt::MetaModifier) || (modifiers & Qt::AltModifier)) && ([charactersIgnoringModifiers length] != 0))
--            ch = QChar([charactersIgnoringModifiers characterAtIndex:0]);
--        else
--            ch = QChar([characters characterAtIndex:0]);
--        keyCode = [self convertKeyCode:ch];
--    }
-+
-+    // Patch: Backport a fix for layout-independent shortcuts.
-+    if ([characters length] != 0) // https://bugreports.qt.io/browse/QTBUG-42584
-+        ch = QChar([characters characterAtIndex:0]);
-+    else if ([charactersIgnoringModifiers length] != 0 && ((modifiers & Qt::MetaModifier) || (modifiers & Qt::AltModifier)))
-+        ch = QChar([charactersIgnoringModifiers characterAtIndex:0]);
-+
-+    int keyCode = [self convertKeyCode:ch];
-+    //int keyCode = Qt::Key_unknown;
-+    //if ([characters length] != 0) {
-+    //    if (((modifiers & Qt::MetaModifier) || (modifiers & Qt::AltModifier)) && ([charactersIgnoringModifiers length] != 0))
-+    //        ch = QChar([charactersIgnoringModifiers characterAtIndex:0]);
-+    //    else
-+    //        ch = QChar([characters characterAtIndex:0]);
-+    //    keyCode = [self convertKeyCode:ch];
-+    //}
- 
-     // we will send a key event unless the input method sets m_sendKeyEvent to false
-     m_sendKeyEvent = true;
-@@ -1437,6 +1449,11 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
-                 && qtKey == Qt::Key_Period) {
-             [self handleKeyEvent:nsevent eventType:int(QEvent::KeyPress)];
-             return YES;
-+
-+        // Patch: Allow us to handle Ctrl+Tab and Ctrl+Backtab in the app.
-+        } else if ([nsevent modifierFlags] & NSControlKeyMask && (qtKey == Qt::Key_Tab || qtKey == Qt::Key_Backtab)) {
-+            [self handleKeyEvent:nsevent eventType:int(QEvent::KeyPress)];
-+            return YES;
-         }
-     }
-     return [super performKeyEquivalent:nsevent];
-diff --git a/src/tools/qlalr/lalr.cpp b/src/tools/qlalr/lalr.cpp
-index c680764..e2a7aaf 100644
---- a/src/tools/qlalr/lalr.cpp
-+++ b/src/tools/qlalr/lalr.cpp
-@@ -246,11 +246,13 @@ void Grammar::buildExtendedGrammar ()
-   non_terminals.insert (accept_symbol);
- }
- 
--struct _Nullable: public std::unary_function<Name, bool>
-+// Patch: Fix building with the new SDK.
-+struct __Nullable: public std::unary_function<Name, bool>
- {
-   Automaton *_M_automaton;
- 
--  _Nullable (Automaton *aut):
-+  // Patch: Fix building with the new SDK.
-+  __Nullable (Automaton *aut):
-     _M_automaton (aut) {}
- 
-   bool operator () (Name name) const
-@@ -308,7 +310,8 @@ void Automaton::buildNullables ()
- 
-       for (RulePointer rule = _M_grammar->rules.begin (); rule != _M_grammar->rules.end (); ++rule)
-         {
--          NameList::iterator nn = std::find_if (rule->rhs.begin (), rule->rhs.end (), std::not1 (_Nullable (this)));
-+          // Patch: Fix building with the new SDK.
-+          NameList::iterator nn = std::find_if (rule->rhs.begin (), rule->rhs.end (), std::not1 (__Nullable (this)));
- 
-           if (nn == rule->rhs.end ())
-             changed |= nullables.insert (rule->lhs).second;
-@@ -643,7 +646,8 @@ void Automaton::buildIncludesDigraph ()
-                   if (! _M_grammar->isNonTerminal (*A))
-                     continue;
- 
--                  NameList::iterator first_not_nullable = std::find_if (dot, rule->rhs.end (), std::not1 (_Nullable (this)));
-+                  // Patch: Fix building with the new SDK.
-+                  NameList::iterator first_not_nullable = std::find_if (dot, rule->rhs.end (), std::not1 (__Nullable (this)));
-                   if (first_not_nullable != rule->rhs.end ())
-                     continue;
- 
-diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
-index 7396808..7178aec 100644
---- a/src/widgets/kernel/qwidget.cpp
-+++ b/src/widgets/kernel/qwidget.cpp
-@@ -4722,6 +4722,17 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset,
-         return; // Fully transparent.
- 
-     Q_D(QWidget);
-+
-+    // Patch: save and restore dirtyOpaqueChildren field.
-+    //
-+    // Just like in QWidget::grab() this field should be restored
-+    // after the d->render() call, because it will be set to 1 and
-+    // opaqueChildren field will be filled with empty region in
-+    // case the widget is hidden (because all the opaque children
-+    // will be skipped in isVisible() check).
-+    //
-+    const bool oldDirtyOpaqueChildren = d->dirtyOpaqueChildren;
-+
-     const bool inRenderWithPainter = d->extra && d->extra->inRenderWithPainter;
-     const QRegion toBePainted = !inRenderWithPainter ? d->prepareToRender(sourceRegion, renderFlags)
-                                                      : sourceRegion;
-@@ -4743,6 +4754,10 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset,
-     if (!inRenderWithPainter && (opacity < 1.0 || (target->devType() == QInternal::Printer))) {
-         d->render_helper(painter, targetOffset, toBePainted, renderFlags);
-         d->extra->inRenderWithPainter = inRenderWithPainter;
-+
-+        // Patch: save and restore dirtyOpaqueChildren field.
-+        d->dirtyOpaqueChildren = oldDirtyOpaqueChildren;
-+
-         return;
-     }
- 
-@@ -4774,6 +4789,9 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset,
-     d->setSharedPainter(oldPainter);
- 
-     d->extra->inRenderWithPainter = inRenderWithPainter;
-+
-+    // Patch: save and restore dirtyOpaqueChildren field.
-+    d->dirtyOpaqueChildren = oldDirtyOpaqueChildren;
- }
- 
- static void sendResizeEvents(QWidget *target)
-@@ -7983,7 +8001,8 @@ bool QWidget::event(QEvent *event)
-     case QEvent::KeyPress: {
-         QKeyEvent *k = (QKeyEvent *)event;
-         bool res = false;
--        if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) {  //### Add MetaModifier?
-+        // Patch: Allow us to handle Ctrl+Tab and Ctrl+Backtab in the app.
-+        if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier))) {  //### Add MetaModifier?
-             if (k->key() == Qt::Key_Backtab
-                 || (k->key() == Qt::Key_Tab && (k->modifiers() & Qt::ShiftModifier)))
-                 res = focusNextPrevChild(false);
-diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
-index 0845a5e..5735cb6 100644
---- a/src/widgets/styles/qmacstyle_mac.mm
-+++ b/src/widgets/styles/qmacstyle_mac.mm
-@@ -3667,9 +3667,11 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
- 
-                 NSBezierPath *pushButtonFocusRingPath;
-                 if (bdi.kind == kThemeBevelButton)
--                    pushButtonFocusRingPath = [NSBezierPath bezierPathWithRect:focusRect];
-+                    // Patch: Fix building with the new SDK.
-+                    pushButtonFocusRingPath = [NSBezierPath bezierPathWithRect:NSRectFromCGRect(focusRect)];
-                 else
--                    pushButtonFocusRingPath = [NSBezierPath bezierPathWithRoundedRect:focusRect xRadius:4 yRadius:4];
-+                    // Patch: Fix building with the new SDK.
-+                    pushButtonFocusRingPath = [NSBezierPath bezierPathWithRoundedRect:NSRectFromCGRect(focusRect) xRadius:4 yRadius:4];
-                 qt_drawFocusRingOnPath(cg, pushButtonFocusRingPath);
-             }
- 
-diff --git a/src/widgets/util/qsystemtrayicon_qpa.cpp b/src/widgets/util/qsystemtrayicon_qpa.cpp
-index f98aeaf..00c0734 100644
---- a/src/widgets/util/qsystemtrayicon_qpa.cpp
-+++ b/src/widgets/util/qsystemtrayicon_qpa.cpp
-@@ -99,13 +99,18 @@ void QSystemTrayIconPrivate::updateIcon_sys()
- 
- void QSystemTrayIconPrivate::updateMenu_sys()
- {
--    if (qpa_sys && menu) {
--        if (!menu->platformMenu()) {
--            QPlatformMenu *platformMenu = qpa_sys->createMenu();
--            if (platformMenu)
--                menu->setPlatformMenu(platformMenu);
-+    // Patch: Nice macOS tray icon support.
-+    if (qpa_sys) {
-+        if (menu) {
-+            if (!menu->platformMenu()) {
-+                QPlatformMenu *platformMenu = qpa_sys->createMenu();
-+                if (platformMenu)
-+                    menu->setPlatformMenu(platformMenu);
-+            }
-+            qpa_sys->updateMenu(menu->platformMenu());
-+        } else {
-+            qpa_sys->updateMenu(0);
-         }
--        qpa_sys->updateMenu(menu->platformMenu());
-     }
- }
- 
-diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
-index 75f3059..980f2be 100644
---- a/src/widgets/widgets/qwidgetlinecontrol.cpp
-+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
-@@ -1867,7 +1867,8 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
- 
-     if (unknown && !isReadOnly()) {
-         QString t = event->text();
--        if (!t.isEmpty() && t.at(0).isPrint()) {
-+        // Patch: Enable ZWJ and ZWNJ characters to be in text input.
-+        if (!t.isEmpty() && (t.at(0).isPrint() || t.at(0).unicode() == 0x200C || t.at(0).unicode() == 0x200D)) {
-             insert(t);
- #ifndef QT_NO_COMPLETER
-             complete(event->key());
-diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
-index 96438a0..b0b7206 100644
---- a/src/widgets/widgets/qwidgettextcontrol.cpp
-+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
-@@ -1342,7 +1342,8 @@ void QWidgetTextControlPrivate::keyPressEvent(QKeyEvent *e)
- process:
-     {
-         QString text = e->text();
--        if (!text.isEmpty() && (text.at(0).isPrint() || text.at(0) == QLatin1Char('\t'))) {
-+        // Patch: Enable ZWJ and ZWNJ characters to be in text input.
-+        if (!text.isEmpty() && (text.at(0).isPrint() || text.at(0) == QLatin1Char('\t') || text.at(0).unicode() == 0x200C || text.at(0).unicode() == 0x200D)) {
-             if (overwriteMode
-                 // no need to call deleteChar() if we have a selection, insertText
-                 // does it already
diff --git a/Telegram/Patches/macold/qtimageformats_5_3_2.diff b/Telegram/Patches/macold/qtimageformats_5_3_2.diff
deleted file mode 100644
index b1f04103b..000000000
--- a/Telegram/Patches/macold/qtimageformats_5_3_2.diff
+++ /dev/null
@@ -1,47 +0,0 @@
-diff --git a/src/3rdparty/libwebp/src/dec/vp8l.c b/src/3rdparty/libwebp/src/dec/vp8l.c
-index ea0254d..953ff01 100644
---- a/src/3rdparty/libwebp/src/dec/vp8l.c
-+++ b/src/3rdparty/libwebp/src/dec/vp8l.c
-@@ -12,7 +12,7 @@
- // Authors: Vikas Arora (vikaas.arora@gmail.com)
- //          Jyrki Alakuijala (jyrki@google.com)
- 
--#include <stdio.h>
-+// Patch: Backport of a crash fix.
- #include <stdlib.h>
- #include "./alphai.h"
- #include "./vp8li.h"
-@@ -740,6 +740,10 @@ static int DecodeAlphaData(VP8LDecoder* const dec, uint8_t* const data,
-   const int len_code_limit = NUM_LITERAL_CODES + NUM_LENGTH_CODES;
-   const int mask = hdr->huffman_mask_;
-   assert(htree_group != NULL);
-+
-+  // Patch: Backport of a crash fix.
-+  assert(pos < end);
-+
-   assert(last_row <= height);
-   assert(Is8bOptimizable(hdr));
- 
-@@ -830,6 +834,10 @@ static int DecodeImageData(VP8LDecoder* const dec, uint32_t* const data,
-       (hdr->color_cache_size_ > 0) ? &hdr->color_cache_ : NULL;
-   const int mask = hdr->huffman_mask_;
-   assert(htree_group != NULL);
-+
-+  // Patch: Backport of a crash fix.
-+  assert(src < src_end);
-+
-   assert(src_last <= src_end);
- 
-   while (!br->eos_ && src < src_last) {
-@@ -1294,6 +1302,11 @@ int VP8LDecodeAlphaImageStream(ALPHDecoder* const alph_dec, int last_row) {
-   assert(dec->action_ == READ_DATA);
-   assert(last_row <= dec->height_);
- 
-+  // Patch: Backport of a crash fix.
-+  if (dec->last_pixel_ == dec->width_ * dec->height_) {
-+    return 1; // done
-+  }
-+
-   // Decode (with special row processing).
-   return alph_dec->use_8b_decode ?
-       DecodeAlphaData(dec, (uint8_t*)dec->pixels_, dec->width_, dec->height_,
diff --git a/Telegram/Patches/qtbase_5_6_2.diff b/Telegram/Patches/qtbase_5_6_2.diff
deleted file mode 100644
index 85fddbd27..000000000
--- a/Telegram/Patches/qtbase_5_6_2.diff
+++ /dev/null
@@ -1,1451 +0,0 @@
-diff --git a/mkspecs/common/msvc-desktop.conf b/mkspecs/common/msvc-desktop.conf
-index eec9e1f..7ae53c7 100644
---- a/mkspecs/common/msvc-desktop.conf
-+++ b/mkspecs/common/msvc-desktop.conf
-@@ -30,9 +30,10 @@ QMAKE_YACCFLAGS         = -d
- QMAKE_CFLAGS            = -nologo -Zc:wchar_t
- QMAKE_CFLAGS_WARN_ON    = -W3
- QMAKE_CFLAGS_WARN_OFF   = -W0
--QMAKE_CFLAGS_RELEASE    = -O2 -MD
--QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MD -Zi
--QMAKE_CFLAGS_DEBUG      = -Zi -MDd
-+# Patch: Make this build use static runtime library.
-+QMAKE_CFLAGS_RELEASE    = -O2 -MT
-+QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi
-+QMAKE_CFLAGS_DEBUG      = -Zi -MTd
- QMAKE_CFLAGS_YACC       =
- QMAKE_CFLAGS_LTCG       = -GL
- QMAKE_CFLAGS_SSE2       = -arch:SSE2
-diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
-index 391fbcc..d07802b 100644
---- a/src/corelib/io/qfsfileengine_win.cpp
-+++ b/src/corelib/io/qfsfileengine_win.cpp
-@@ -427,11 +427,12 @@ qint64 QFSFileEnginePrivate::nativeWrite(const char *data, qint64 len)
- 
-     // Writing on Windows fails with ERROR_NO_SYSTEM_RESOURCES when
-     // the chunks are too large, so we limit the block size to 32MB.
--    const DWORD blockSize = DWORD(qMin(bytesToWrite, qint64(32 * 1024 * 1024)));
-     qint64 totalWritten = 0;
-     do {
-+        // Patch: backport critical bugfix from '683c9bc4a8' commit.
-+        const DWORD currentBlockSize = DWORD(qMin(bytesToWrite, qint64(32 * 1024 * 1024)));
-         DWORD bytesWritten;
--        if (!WriteFile(fileHandle, data + totalWritten, blockSize, &bytesWritten, NULL)) {
-+        if (!WriteFile(fileHandle, data + totalWritten, currentBlockSize, &bytesWritten, NULL)) {
-             if (totalWritten == 0) {
-                 // Note: Only return error if the first WriteFile failed.
-                 q->setError(QFile::WriteError, qt_error_string());
-diff --git a/src/corelib/tools/qunicodetables.cpp b/src/corelib/tools/qunicodetables.cpp
-index 14e4fd1..0619a17 100644
---- a/src/corelib/tools/qunicodetables.cpp
-+++ b/src/corelib/tools/qunicodetables.cpp
-@@ -6227,7 +6227,8 @@ static const Properties uc_properties[] = {
-     { 1, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 7, 4, 4, 21, 11 },
-     { 0, 17, 230, 5, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 4, 4, 4, 21, 11 },
-     { 18, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 85, 0, 8, 8, 12, 11 },
--    { 25, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 12, 17, 2 },
-+    // Patch: Some bad characters appeared in ui in case 2 was here instead of 11.
-+    { 25, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 12, 17, 11 },
-     { 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 14, 9, 11, 11 },
-     { 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 14, 9, 11, 11 },
-     { 3, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 14, 9, 11, 11 },
-diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp
-index 2d00b9d..eeba86e 100644
---- a/src/gui/kernel/qhighdpiscaling.cpp
-+++ b/src/gui/kernel/qhighdpiscaling.cpp
-@@ -51,6 +51,9 @@ static const char screenFactorsEnvVar[] = "QT_SCREEN_SCALE_FACTORS";
- 
- static inline qreal initialGlobalScaleFactor()
- {
-+    // Patch: Disable environment variable dpi scaling changing.
-+    // It is not supported by Telegram Desktop :(
-+    return 1.;
- 
-     qreal result = 1;
-     if (qEnvironmentVariableIsSet(scaleFactorEnvVar)) {
-diff --git a/src/gui/kernel/qplatformdialoghelper.h b/src/gui/kernel/qplatformdialoghelper.h
-index 5b2f4ec..790db46 100644
---- a/src/gui/kernel/qplatformdialoghelper.h
-+++ b/src/gui/kernel/qplatformdialoghelper.h
-@@ -386,6 +386,10 @@ public:
-     virtual QUrl directory() const = 0;
-     virtual void selectFile(const QUrl &filename) = 0;
-     virtual QList<QUrl> selectedFiles() const = 0;
-+
-+    // Patch: Adding select-by-url for Windows file dialog.
-+    virtual QByteArray selectedRemoteContent() const { return QByteArray(); }
-+
-     virtual void setFilter() = 0;
-     virtual void selectNameFilter(const QString &filter) = 0;
-     virtual QString selectedNameFilter() const = 0;
-diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
-index bcd29b6..bcb0672 100644
---- a/src/gui/kernel/qwindow.cpp
-+++ b/src/gui/kernel/qwindow.cpp
-@@ -2525,7 +2525,8 @@ void QWindowPrivate::setCursor(const QCursor *newCursor)
- void QWindowPrivate::applyCursor()
- {
-     Q_Q(QWindow);
--    if (platformWindow) {
-+    // Patch: Fixing possible crash (crashdumps point on this code line).
-+    if (platformWindow && q->screen() && q->screen()->handle()) {
-         if (QPlatformCursor *platformCursor = q->screen()->handle()->cursor()) {
-             QCursor *c = QGuiApplication::overrideCursor();
-             if (!c && hasCursor)
-diff --git a/src/gui/painting/qpaintengine_p.h b/src/gui/painting/qpaintengine_p.h
-index 918c989..4158259 100644
---- a/src/gui/painting/qpaintengine_p.h
-+++ b/src/gui/painting/qpaintengine_p.h
-@@ -80,8 +80,18 @@ public:
-         if (hasSystemTransform) {
-             if (systemTransform.type() <= QTransform::TxTranslate)
-                 systemClip.translate(qRound(systemTransform.dx()), qRound(systemTransform.dy()));
--            else
-+            // Patch: Transform the system clip region back from device pixels to device-independent pixels before
-+            // applying systemTransform, which already has transform from device-independent pixels to device pixels.
-+            else {
-+#ifdef Q_OS_MAC
-+                QTransform scaleTransform;
-+                const qreal invDevicePixelRatio = 1. / pdev->devicePixelRatio();
-+                scaleTransform.scale(invDevicePixelRatio, invDevicePixelRatio);
-+                systemClip = systemTransform.map(scaleTransform.map(systemClip));
-+#else
-                 systemClip = systemTransform.map(systemClip);
-+#endif
-+            }
-         }
- 
-         // Make sure we're inside the viewport.
-diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
-index 7e507bb..936e7a9 100644
---- a/src/gui/text/qtextengine_p.h
-+++ b/src/gui/text/qtextengine_p.h
-@@ -283,7 +283,8 @@ private:
- 
- struct QScriptItem;
- /// Internal QTextItem
--class QTextItemInt : public QTextItem
-+// Patch: Enable access to QTextItemInt in .dll for WinRT build.
-+class Q_GUI_EXPORT QTextItemInt : public QTextItem
- {
- public:
-     inline QTextItemInt()
-diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
-index aca475a..5fa0be2 100644
---- a/src/gui/text/qtextlayout.cpp
-+++ b/src/gui/text/qtextlayout.cpp
-@@ -694,6 +694,9 @@ int QTextLayout::nextCursorPosition(int oldPos, CursorMode mode) const
-         while (oldPos < len && !attributes[oldPos].graphemeBoundary)
-             oldPos++;
-     } else {
-+        // Patch: Skip to the end of the current word, not to the start of the next one.
-+        while (oldPos < len && attributes[oldPos].whiteSpace)
-+            oldPos++;
-         if (oldPos < len && d->atWordSeparator(oldPos)) {
-             oldPos++;
-             while (oldPos < len && d->atWordSeparator(oldPos))
-@@ -702,8 +705,9 @@ int QTextLayout::nextCursorPosition(int oldPos, CursorMode mode) const
-             while (oldPos < len && !attributes[oldPos].whiteSpace && !d->atWordSeparator(oldPos))
-                 oldPos++;
-         }
--        while (oldPos < len && attributes[oldPos].whiteSpace)
--            oldPos++;
-+        // Patch: Skip to the end of the current word, not to the start of the next one.
-+        //while (oldPos < len && attributes[oldPos].whiteSpace)
-+        //    oldPos++;
-     }
- 
-     return oldPos;
-@@ -1645,6 +1649,9 @@ namespace {
-         int currentPosition;
-         glyph_t previousGlyph;
- 
-+        // Patch: Fix a crash in right bearing calculation.
-+        QFontEngine *previousGlyphFontEngine;
-+
-         QFixed minw;
-         QFixed softHyphenWidth;
-         QFixed rightBearing;
-@@ -1677,13 +1684,19 @@ namespace {
-             if (currentPosition > 0 &&
-                 logClusters[currentPosition - 1] < glyphs.numGlyphs) {
-                 previousGlyph = currentGlyph(); // needed to calculate right bearing later
-+
-+                // Patch: Fix a crash in right bearing calculation.
-+                previousGlyphFontEngine = fontEngine;
-             }
-         }
- 
--        inline void calculateRightBearing(glyph_t glyph)
-+        // Patch: Fix a crash in right bearing calculation.
-+        inline void calculateRightBearing(QFontEngine *engine, glyph_t glyph)
-         {
-             qreal rb;
--            fontEngine->getGlyphBearings(glyph, 0, &rb);
-+
-+            // Patch: Fix a crash in right bearing calculation.
-+            engine->getGlyphBearings(glyph, 0, &rb);
- 
-             // We only care about negative right bearings, so we limit the range
-             // of the bearing here so that we can assume it's negative in the rest
-@@ -1696,13 +1709,16 @@ namespace {
-         {
-             if (currentPosition <= 0)
-                 return;
--            calculateRightBearing(currentGlyph());
-+
-+            // Patch: Fix a crash in right bearing calculation.
-+            calculateRightBearing(fontEngine, currentGlyph());
-         }
- 
-         inline void calculateRightBearingForPreviousGlyph()
-         {
-             if (previousGlyph > 0)
--                calculateRightBearing(previousGlyph);
-+                // Patch: Fix a crash in right bearing calculation.
-+                calculateRightBearing(previousGlyphFontEngine, previousGlyph);
-         }
- 
-         static const QFixed RightBearingNotCalculated;
-diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h
-index f74d4d4..8ad672c 100644
---- a/src/gui/text/qtextlayout.h
-+++ b/src/gui/text/qtextlayout.h
-@@ -196,6 +196,9 @@ private:
-                                QRectF *brect, int tabstops, int* tabarray, int tabarraylen,
-                                QPainter *painter);
-     QTextEngine *d;
-+
-+    // Patch: Allow access to private constructor.
-+    friend class TextBlock;
- };
- 
- 
-diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp
-index 41834b2..8cdf4ab 100644
---- a/src/network/socket/qnativesocketengine_win.cpp
-+++ b/src/network/socket/qnativesocketengine_win.cpp
-@@ -675,6 +675,13 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &address, quin
-                             errorDetected = true;
-                             break;
-                         }
-+                        // Patch: Handle network unreachable the same as host unreachable.
-+                        if (value == WSAENETUNREACH) {
-+                            setError(QAbstractSocket::NetworkError, NetworkUnreachableErrorString);
-+                            socketState = QAbstractSocket::UnconnectedState;
-+                            errorDetected = true;
-+                            break;
-+                        }
-                         if (value == WSAEADDRNOTAVAIL) {
-                             setError(QAbstractSocket::NetworkError, AddressNotAvailableErrorString);
-                             socketState = QAbstractSocket::UnconnectedState;
-diff --git a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp
-index 728b166..1dc6459 100644
---- a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp
-+++ b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp
-@@ -172,6 +172,79 @@ void QBasicFontDatabase::releaseHandle(void *handle)
- 
- extern FT_Library qt_getFreetype();
- 
-+// Patch: Enable Open Sans Semibold font family reading.
-+// Copied from freetype with some modifications.
-+
-+#ifndef FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY
-+#define FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY FT_MAKE_TAG('i', 'g', 'p', 'f')
-+#endif
-+
-+#ifndef FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY
-+#define FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY FT_MAKE_TAG('i', 'g', 'p', 's')
-+#endif
-+
-+/* there's a Mac-specific extended implementation of FT_New_Face() */
-+/* in src/base/ftmac.c                                             */
-+
-+#if !defined( FT_MACINTOSH ) || defined( DARWIN_NO_CARBON )
-+
-+/* documentation is in freetype.h */
-+
-+FT_Error __ft_New_Face(FT_Library library, const char* pathname, FT_Long face_index, FT_Face *aface) {
-+    FT_Open_Args args;
-+
-+    /* test for valid `library' and `aface' delayed to FT_Open_Face() */
-+    if (!pathname)
-+        return FT_Err_Invalid_Argument;
-+
-+    FT_Parameter params[2];
-+    params[0].tag = FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY;
-+    params[0].data = 0;
-+    params[1].tag = FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY;
-+    params[1].data = 0;
-+    args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS;
-+    args.pathname = (char*)pathname;
-+    args.stream = NULL;
-+    args.num_params = 2;
-+    args.params = params;
-+
-+    return FT_Open_Face(library, &args, face_index, aface);
-+}
-+
-+#else
-+
-+FT_Error __ft_New_Face(FT_Library library, const char* pathname, FT_Long face_index, FT_Face *aface) {
-+    return FT_New_Face(library, pathname, face_index, aface);
-+}
-+
-+#endif  /* defined( FT_MACINTOSH ) && !defined( DARWIN_NO_CARBON ) */
-+
-+/* documentation is in freetype.h */
-+
-+FT_Error __ft_New_Memory_Face(FT_Library library, const FT_Byte* file_base, FT_Long file_size, FT_Long face_index, FT_Face *aface) {
-+    FT_Open_Args  args;
-+
-+    /* test for valid `library' and `face' delayed to FT_Open_Face() */
-+    if (!file_base)
-+        return FT_Err_Invalid_Argument;
-+
-+    FT_Parameter params[2];
-+    params[0].tag = FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY;
-+    params[0].data = 0;
-+    params[1].tag = FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY;
-+    params[1].data = 0;
-+    args.flags = FT_OPEN_MEMORY | FT_OPEN_PARAMS;
-+    args.memory_base = file_base;
-+    args.memory_size = file_size;
-+    args.stream = NULL;
-+    args.num_params = 2;
-+    args.params = params;
-+
-+    return FT_Open_Face(library, &args, face_index, aface);
-+}
-+
-+// end
-+
- QStringList QBasicFontDatabase::addTTFile(const QByteArray &fontData, const QByteArray &file)
- {
-     FT_Library library = qt_getFreetype();
-@@ -183,9 +256,11 @@ QStringList QBasicFontDatabase::addTTFile(const QByteArray &fontData, const QByt
-         FT_Face face;
-         FT_Error error;
-         if (!fontData.isEmpty()) {
--            error = FT_New_Memory_Face(library, (const FT_Byte *)fontData.constData(), fontData.size(), index, &face);
-+            // Patch: Enable Open Sans Semibold font family reading.
-+            error = __ft_New_Memory_Face(library, (const FT_Byte *)fontData.constData(), fontData.size(), index, &face);
-         } else {
--            error = FT_New_Face(library, file.constData(), index, &face);
-+            // Patch: Enable Open Sans Semibold font family reading.
-+            error = __ft_New_Face(library, file.constData(), index, &face);
-         }
-         if (error != FT_Err_Ok) {
-             qDebug() << "FT_New_Face failed with index" << index << ':' << hex << error;
-diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
-index 8ebabf3..7bb8abd 100644
---- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
-+++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
-@@ -375,6 +375,17 @@ static void populateFromPattern(FcPattern *pattern)
- 
-     familyName = QString::fromUtf8((const char *)value);
- 
-+    // Patch: Enable Open Sans Semibold font family reading.
-+    if (familyName == QLatin1String("Open Sans")) {
-+        FcChar8 *styl = 0;
-+        if (FcPatternGetString(pattern, FC_STYLE, 0, &styl) == FcResultMatch) {
-+            QString style = QString::fromUtf8(reinterpret_cast<const char *>(styl));
-+            if (style == QLatin1String("Semibold")) {
-+                familyName.append(QChar(QChar::Space)).append(style);
-+            }
-+        }
-+    }
-+
-     slant_value = FC_SLANT_ROMAN;
-     weight_value = FC_WEIGHT_REGULAR;
-     spacing_value = FC_PROPORTIONAL;
-@@ -718,7 +729,19 @@ QStringList QFontconfigDatabase::fallbacksForFamily(const QString &family, QFont
-             if (FcPatternGetString(fontSet->fonts[i], FC_FAMILY, 0, &value) != FcResultMatch)
-                 continue;
-             //         capitalize(value);
--            const QString familyName = QString::fromUtf8((const char *)value);
-+
-+            // Patch: Enable Open Sans Semibold font family reading.
-+            QString familyName = QString::fromUtf8((const char *)value);
-+            if (familyName == QLatin1String("Open Sans")) {
-+                FcChar8 *styl = 0;
-+                if (FcPatternGetString(fontSet->fonts[i], FC_STYLE, 0, &styl) == FcResultMatch) {
-+                    QString style = QString::fromUtf8(reinterpret_cast<const char *>(styl));
-+                    if (style == QLatin1String("Semibold")) {
-+                        familyName.append(QChar(QChar::Space)).append(style);
-+                    }
-+                }
-+            }
-+
-             const QString familyNameCF = familyName.toCaseFolded();
-             if (!duplicates.contains(familyNameCF)) {
-                 fallbackFamilies << familyName;
-@@ -784,6 +807,18 @@ QStringList QFontconfigDatabase::addApplicationFont(const QByteArray &fontData,
-         FcChar8 *fam = 0;
-         if (FcPatternGetString(pattern, FC_FAMILY, 0, &fam) == FcResultMatch) {
-             QString family = QString::fromUtf8(reinterpret_cast<const char *>(fam));
-+
-+            // Patch: Enable Open Sans Semibold font family reading.
-+            if (family == QLatin1String("Open Sans")) {
-+                FcChar8 *styl = 0;
-+                if (FcPatternGetString(pattern, FC_STYLE, 0, &styl) == FcResultMatch) {
-+                    QString style = QString::fromUtf8(reinterpret_cast<const char *>(styl));
-+                    if (style == QLatin1String("Semibold")) {
-+                        family.append(QChar(QChar::Space)).append(style);
-+                    }
-+                }
-+            }
-+
-             families << family;
-         }
-         populateFromPattern(pattern);
-diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
-index 566abf2..5b9c714 100644
---- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
-+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
-@@ -265,6 +265,13 @@ static void getFontDescription(CTFontDescriptorRef font, FontDescription *fd)
- 
-     fd->foundryName = QStringLiteral("CoreText");
-     fd->familyName = (CFStringRef) CTFontDescriptorCopyAttribute(font, kCTFontFamilyNameAttribute);
-+
-+    // Patch: Enable Open Sans Semibold font family reading.
-+    QCFString _displayName = (CFStringRef) CTFontDescriptorCopyAttribute(font, kCTFontDisplayNameAttribute);
-+    if (_displayName == QStringLiteral("Open Sans Semibold")) {
-+        fd->familyName = _displayName;
-+    }
-+
-     fd->styleName = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontStyleNameAttribute);
-     fd->weight = QFont::Normal;
-     fd->style = QFont::StyleNormal;
-diff --git a/src/plugins/platforminputcontexts/compose/compose.pro b/src/plugins/platforminputcontexts/compose/compose.pro
-index 86bdd47..9b9c8de 100644
---- a/src/plugins/platforminputcontexts/compose/compose.pro
-+++ b/src/plugins/platforminputcontexts/compose/compose.pro
-@@ -15,7 +15,8 @@ HEADERS += $$PWD/qcomposeplatforminputcontext.h \
- contains(QT_CONFIG, xkbcommon-qt): {
-     # dont't need x11 dependency for compose key plugin
-     QT_CONFIG -= use-xkbcommon-x11support
--    include(../../../3rdparty/xkbcommon.pri)
-+    # Patch: Adding fcitx input context plugin to our static build.
-+    #include(../../../3rdparty/xkbcommon.pri)
- } else {
-     LIBS += $$QMAKE_LIBS_XKBCOMMON
-     QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XKBCOMMON
-diff --git a/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp b/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp
-index d1bea9a..36a15a6 100644
---- a/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp
-+++ b/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp
-@@ -232,6 +232,12 @@ bool QComposeInputContext::checkComposeTable()
- 
- void QComposeInputContext::commitText(uint character) const
- {
-+    // Patch: Crash fix when not focused widget still receives input events.
-+    if (!m_focusObject) {
-+        qWarning("QComposeInputContext::commitText: m_focusObject == nullptr, cannot commit text");
-+        return;
-+    }
-+
-     QInputMethodEvent event;
-     event.setCommitString(QChar(character));
-     QCoreApplication::sendEvent(m_focusObject, &event);
-diff --git a/src/plugins/platforminputcontexts/platforminputcontexts.pro b/src/plugins/platforminputcontexts/platforminputcontexts.pro
-index faea54b..0f96509 100644
---- a/src/plugins/platforminputcontexts/platforminputcontexts.pro
-+++ b/src/plugins/platforminputcontexts/platforminputcontexts.pro
-@@ -1,7 +1,8 @@
- TEMPLATE = subdirs
- 
- qtHaveModule(dbus) {
--!mac:!win32:SUBDIRS += ibus
-+# Patch: Adding fcitx/hime input context plugin to our static build.
-+!mac:!win32:SUBDIRS += ibus fcitx hime
- }
- 
- contains(QT_CONFIG, xcb-plugin): SUBDIRS += compose
-diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
-index caa8884..9dc3bc1 100644
---- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
-+++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
-@@ -210,7 +210,8 @@ QT_END_NAMESPACE
-     if (reflectionDelegate) {
-         if ([reflectionDelegate respondsToSelector:@selector(applicationShouldTerminate:)])
-             return [reflectionDelegate applicationShouldTerminate:sender];
--        return NSTerminateNow;
-+        // Patch: Don't terminate if reflectionDelegate does not respond to that selector, just use the default.
-+        //return NSTerminateNow;
-     }
- 
-     if ([self canQuit]) {
-@@ -287,11 +288,15 @@ QT_END_NAMESPACE
- 
- - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
- {
-+    // Patch: We need to catch that notification in delegate.
-+    if (reflectionDelegate
-+        && [reflectionDelegate respondsToSelector:@selector(applicationDidFinishLaunching:)])
-+        [reflectionDelegate applicationDidFinishLaunching:aNotification];
-+
-     Q_UNUSED(aNotification);
-     inLaunch = false;
-     // qt_release_apple_event_handler();
- 
--
-     // Insert code here to initialize your application
- }
- 
-diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.h b/src/plugins/platforms/cocoa/qcocoabackingstore.h
-index 934f68a..3ece698 100644
---- a/src/plugins/platforms/cocoa/qcocoabackingstore.h
-+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.h
-@@ -64,6 +64,9 @@ public:
- private:
-     QImage m_qImage;
-     QSize m_requestedSize;
-+
-+    // Patch: Optimize redraw - don't clear image if it will be fully redrawn.
-+    bool m_qImageNeedsClear;
- };
- 
- QT_END_NAMESPACE
-diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
-index ca92103..f27ea15 100644
---- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm
-+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
-@@ -38,7 +38,8 @@
- QT_BEGIN_NAMESPACE
- 
- QCocoaBackingStore::QCocoaBackingStore(QWindow *window)
--    : QPlatformBackingStore(window)
-+    // Patch: Optimize redraw - don't clear image if it will be fully redrawn.
-+    : QPlatformBackingStore(window), m_qImageNeedsClear(false)
- {
- }
- 
-@@ -59,9 +60,12 @@ QPaintDevice *QCocoaBackingStore::paintDevice()
-     if (m_qImage.size() != effectiveBufferSize) {
-         QImage::Format format = (window()->format().hasAlpha() || cocoaWindow->m_drawContentBorderGradient)
-                 ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
-+
-+        // Patch: Optimize redraw - don't clear image if it will be fully redrawn.
-+        m_qImageNeedsClear = window()->requestedFormat().hasAlpha() || cocoaWindow->m_drawContentBorderGradient;
-         m_qImage = QImage(effectiveBufferSize, format);
-         m_qImage.setDevicePixelRatio(windowDevicePixelRatio);
--        if (format == QImage::Format_ARGB32_Premultiplied)
-+        if (m_qImageNeedsClear)
-             m_qImage.fill(Qt::transparent);
-     }
-     return &m_qImage;
-@@ -100,7 +104,8 @@ bool QCocoaBackingStore::scroll(const QRegion &area, int dx, int dy)
- 
- void QCocoaBackingStore::beginPaint(const QRegion &region)
- {
--    if (m_qImage.hasAlphaChannel()) {
-+    // Patch: Optimize redraw - don't clear image if it will be fully redrawn.
-+    if (m_qImageNeedsClear && m_qImage.hasAlphaChannel()) {
-         QPainter p(&m_qImage);
-         p.setCompositionMode(QPainter::CompositionMode_Source);
-         const QVector<QRect> rects = region.rects();
-diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.mm b/src/plugins/platforms/cocoa/qcocoakeymapper.mm
-index c2d206f..9b97398 100644
---- a/src/plugins/platforms/cocoa/qcocoakeymapper.mm
-+++ b/src/plugins/platforms/cocoa/qcocoakeymapper.mm
-@@ -384,6 +384,12 @@ bool QCocoaKeyMapper::updateKeyboard()
-         keyboardInputLocale = QLocale::c();
-         keyboardInputDirection = Qt::LeftToRight;
-     }
-+
-+    // Patch: Fix layout-independent global shortcuts.
-+    const auto newMode = keyboard_mode;
-+    deleteLayouts();
-+    keyboard_mode = newMode;
-+
-     return true;
- }
- 
-@@ -466,7 +472,8 @@ QList<int> QCocoaKeyMapper::possibleKeys(const QKeyEvent *event) const
-         Qt::KeyboardModifiers neededMods = ModsTbl[i];
-         int key = kbItem->qtKey[i];
-         if (key && key != baseKey && ((keyMods & neededMods) == neededMods)) {
--            ret << int(key + (keyMods & ~neededMods));
-+            // Patch: Fix layout-independent global shortcuts.
-+            ret << int(key + neededMods);
-         }
-     }
-     return ret;
-diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
-index 8152c57..5ddd7b3 100644
---- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
-+++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
-@@ -94,6 +94,8 @@ QT_USE_NAMESPACE
-     QCocoaSystemTrayIcon *systray;
-     NSStatusItem *item;
-     QCocoaMenu *menu;
-+    // Patch: Create a rich os x tray icon (pixel-perfect, theme switching).
-+    bool menuVisible, iconSelected;
-     QIcon icon;
-     QT_MANGLE_NAMESPACE(QNSImageView) *imageCell;
- }
-@@ -197,7 +199,9 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon)
-     // (device independent pixels). The menu height on past and
-     // current OS X versions is 22 points. Provide some future-proofing
-     // by deriving the icon height from the menu height.
--    const int padding = 4;
-+
-+    // Patch: Create a rich os x tray icon (pixel-perfect, theme switching).
-+    const int padding = 0;
-     const int menuHeight = [[NSStatusBar systemStatusBar] thickness];
-     const int maxImageHeight = menuHeight - padding;
- 
-@@ -207,8 +211,11 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon)
-     // devicePixelRatio for the "best" screen on the system.
-     qreal devicePixelRatio = qApp->devicePixelRatio();
-     const int maxPixmapHeight = maxImageHeight * devicePixelRatio;
-+
-+    // Patch: Create a rich os x tray icon (pixel-perfect, theme switching).
-+    const QIcon::Mode mode = m_sys->item->iconSelected ? QIcon::Selected : QIcon::Normal;
-     QSize selectedSize;
--    Q_FOREACH (const QSize& size, sortByHeight(icon.availableSizes())) {
-+    Q_FOREACH (const QSize& size, sortByHeight(icon.availableSizes(mode))) {
-         // Select a pixmap based on the height. We want the largest pixmap
-         // with a height smaller or equal to maxPixmapHeight. The pixmap
-         // may rectangular; assume it has a reasonable size. If there is
-@@ -224,9 +231,9 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon)
- 
-     // Handle SVG icons, which do not return anything for availableSizes().
-     if (!selectedSize.isValid())
--        selectedSize = icon.actualSize(QSize(maxPixmapHeight, maxPixmapHeight));
-+        selectedSize = icon.actualSize(QSize(maxPixmapHeight, maxPixmapHeight), mode);
- 
--    QPixmap pixmap = icon.pixmap(selectedSize);
-+    QPixmap pixmap = icon.pixmap(selectedSize, mode);
- 
-     // Draw a low-resolution icon if there is not enough pixels for a retina
-     // icon. This prevents showing a small icon on retina displays.
-@@ -374,6 +381,11 @@ QT_END_NAMESPACE
-     Q_UNUSED(notification);
-     down = NO;
- 
-+    // Patch: Create a rich os x tray icon (pixel-perfect, theme switching).
-+    parent->iconSelected = false;
-+    parent->systray->updateIcon(parent->icon);
-+    parent->menuVisible = false;
-+
-     [self setNeedsDisplay:YES];
- }
- 
-@@ -383,6 +395,10 @@ QT_END_NAMESPACE
-     int clickCount = [mouseEvent clickCount];
-     [self setNeedsDisplay:YES];
- 
-+    // Patch: Create a rich os x tray icon (pixel-perfect, theme switching).
-+    parent->iconSelected = (clickCount != 2) && parent->menu;
-+    parent->systray->updateIcon(parent->icon);
-+
-     if (clickCount == 2) {
-         [self menuTrackingDone:nil];
-         [parent doubleClickSelector:self];
-@@ -399,6 +415,11 @@ QT_END_NAMESPACE
- -(void)mouseUp:(NSEvent *)mouseEvent
- {
-     Q_UNUSED(mouseEvent);
-+
-+    // Patch: Create a rich os x tray icon (pixel-perfect, theme switching).
-+    parent->iconSelected = false;
-+    parent->systray->updateIcon(parent->icon);
-+
-     [self menuTrackingDone:nil];
- }
- 
-@@ -410,6 +431,11 @@ QT_END_NAMESPACE
- -(void)rightMouseUp:(NSEvent *)mouseEvent
- {
-     Q_UNUSED(mouseEvent);
-+
-+    // Patch: Create a rich os x tray icon (pixel-perfect, theme switching).
-+    parent->iconSelected = false;
-+    parent->systray->updateIcon(parent->icon);
-+
-     [self menuTrackingDone:nil];
- }
- 
-@@ -425,7 +451,8 @@ QT_END_NAMESPACE
- }
- 
- -(void)drawRect:(NSRect)rect {
--    [[parent item] drawStatusBarBackgroundInRect:rect withHighlight:down];
-+    // Patch: Create a rich os x tray icon (pixel-perfect, theme switching).
-+    [[parent item] drawStatusBarBackgroundInRect:rect withHighlight:parent->menu ? down : NO];
-     [super drawRect:rect];
- }
- @end
-@@ -438,6 +465,10 @@ QT_END_NAMESPACE
-     if (self) {
-         item = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain];
-         menu = 0;
-+
-+        // Patch: Create a rich os x tray icon (pixel-perfect, theme switching).
-+        menuVisible = false;
-+
-         systray = sys;
-         imageCell = [[QNSImageView alloc] initWithParent:self];
-         [item setView: imageCell];
-@@ -482,6 +513,10 @@ QT_END_NAMESPACE
-          selector:@selector(menuTrackingDone:)
-              name:NSMenuDidEndTrackingNotification
-                  object:m];
-+
-+        // Patch: Create a rich os x tray icon (pixel-perfect, theme switching).
-+        menuVisible = true;
-+
-         [item popUpStatusItemMenu: m];
-     }
- }
-diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
-index c0d5904..f3c2047 100644
---- a/src/plugins/platforms/cocoa/qcocoawindow.mm
-+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
-@@ -141,7 +141,8 @@ static bool isMouseEvent(NSEvent *ev)
-     if (!self.window.delegate)
-         return; // Already detached, pending NSAppKitDefined event
- 
--    if (pw && pw->frameStrutEventsEnabled() && isMouseEvent(theEvent)) {
-+    // Patch: Fix restore after minimize or close by window buttons.
-+    if (pw && pw->frameStrutEventsEnabled() && pw->m_synchedWindowState != Qt::WindowMinimized && pw->m_isExposed && isMouseEvent(theEvent)) {
-         NSPoint loc = [theEvent locationInWindow];
-         NSRect windowFrame = [self.window convertRectFromScreen:[self.window frame]];
-         NSRect contentFrame = [[self.window contentView] frame];
-@@ -811,6 +812,16 @@ NSUInteger QCocoaWindow::windowStyleMask(Qt::WindowFlags flags)
- {
-     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
-     NSInteger styleMask = NSBorderlessWindowMask;
-+
-+    // Patch: allow creating panels floating on all spaces in macOS.
-+    // If you call "setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary" before
-+    // setting the "NSNonactivatingPanelMask" bit in the style mask it won't work after that.
-+    // So we need a way to set that bit before Qt sets collection behavior the way it does.
-+    QVariant nonactivatingPanelMask = window()->property("_td_macNonactivatingPanelMask");
-+    if (nonactivatingPanelMask.isValid() && nonactivatingPanelMask.toBool()) {
-+        styleMask |= NSNonactivatingPanelMask;
-+    }
-+
-     if (flags & Qt::FramelessWindowHint)
-         return styleMask;
-     if ((type & Qt::Popup) == Qt::Popup) {
-@@ -943,6 +954,19 @@ void QCocoaWindow::setWindowFilePath(const QString &filePath)
-     [m_nsWindow setRepresentedFilename: fi.exists() ? QCFString::toNSString(filePath) : @""];
- }
- 
-+// Patch: Create a good os x window icon (pixel-perfect).
-+namespace {
-+
-+qreal getDevicePixelRatio() {
-+    qreal result = 1.0;
-+    foreach (QScreen *screen, QGuiApplication::screens()) {
-+        result = qMax(result, screen->devicePixelRatio());
-+    }
-+    return result;
-+}
-+
-+} // namespace
-+
- void QCocoaWindow::setWindowIcon(const QIcon &icon)
- {
-     QMacAutoReleasePool pool;
-@@ -958,7 +982,9 @@ void QCocoaWindow::setWindowIcon(const QIcon &icon)
-     if (icon.isNull()) {
-         [iconButton setImage:nil];
-     } else {
--        QPixmap pixmap = icon.pixmap(QSize(22, 22));
-+        // Patch: Create a good os x window icon (pixel-perfect).
-+        CGFloat hgt = 16. * getDevicePixelRatio();
-+        QPixmap pixmap = icon.pixmap(QSize(hgt, hgt));
-         NSImage *image = static_cast<NSImage *>(qt_mac_create_nsimage(pixmap));
-         [iconButton setImage:image];
-         [image release];
-diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
-index c67bcfd..4498a17 100644
---- a/src/plugins/platforms/cocoa/qnsview.mm
-+++ b/src/plugins/platforms/cocoa/qnsview.mm
-@@ -1431,7 +1431,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
- #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
-     if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
-         // On 10.8 and above, MayBegin is likely to happen.  We treat it the same as an actual begin.
--        if (phase == NSEventPhaseMayBegin) {
-+
-+        // Patch: Fix actual begin handle of swipe on trackpad.
-+        if (phase == NSEventPhaseMayBegin || phase == NSEventPhaseBegan) {
-             m_scrolling = true;
-             ph = Qt::ScrollBegin;
-         }
-@@ -1496,14 +1498,14 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
-     quint32 nativeVirtualKey = [nsevent keyCode];
- 
-     QChar ch = QChar::ReplacementCharacter;
--    int keyCode = Qt::Key_unknown;
--    if ([characters length] != 0) {
--        if (((modifiers & Qt::MetaModifier) || (modifiers & Qt::AltModifier)) && ([charactersIgnoringModifiers length] != 0))
--            ch = QChar([charactersIgnoringModifiers characterAtIndex:0]);
--        else
--            ch = QChar([characters characterAtIndex:0]);
--        keyCode = [self convertKeyCode:ch];
--    }
-+
-+    // Patch: Fix Alt+.. shortcuts in OS X. See https://bugreports.qt.io/browse/QTBUG-42584 at the end.
-+    if ([characters length] != 0)
-+        ch = QChar([characters characterAtIndex:0]);
-+    else if ([charactersIgnoringModifiers length] != 0 && ((modifiers & Qt::MetaModifier) || (modifiers & Qt::AltModifier)))
-+        ch = QChar([charactersIgnoringModifiers characterAtIndex:0]);
-+
-+    int keyCode = [self convertKeyCode:ch];
- 
-     // we will send a key event unless the input method sets m_sendKeyEvent to false
-     m_sendKeyEvent = true;
-@@ -1569,6 +1571,23 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
-     [self handleKeyEvent:nsevent eventType:int(QEvent::KeyRelease)];
- }
- 
-+// Patch: Enable Ctrl+Tab and Ctrl+Shift+Tab / Ctrl+Backtab handle in-app.
-+- (BOOL)performKeyEquivalent:(NSEvent *)nsevent
-+{
-+    NSString *chars = [nsevent charactersIgnoringModifiers];
-+
-+    if ([nsevent type] == NSKeyDown && [chars length] > 0) {
-+        QChar ch = [chars characterAtIndex:0];
-+        Qt::Key qtKey = qt_mac_cocoaKey2QtKey(ch);
-+        if ([nsevent modifierFlags] & NSControlKeyMask
-+                && (qtKey == Qt::Key_Tab || qtKey == Qt::Key_Backtab)) {
-+            [self handleKeyEvent:nsevent eventType:int(QEvent::KeyPress)];
-+            return YES;
-+        }
-+    }
-+    return [super performKeyEquivalent:nsevent];
-+}
-+
- - (void)cancelOperation:(id)sender
- {
-     Q_UNUSED(sender);
-diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
-index 94bb71e..16ab51e 100644
---- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
-+++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
-@@ -716,12 +716,20 @@ public:
-     void setSelectedFiles(const QList<QUrl> &);
-     QString selectedFile() const;
- 
-+    // Patch: Adding select-by-url for Windows file dialog.
-+    void setSelectedRemoteContent(const QByteArray &);
-+    QByteArray selectedRemoteContent() const;
-+
- private:
-     class Data : public QSharedData {
-     public:
-         QUrl directory;
-         QString selectedNameFilter;
-         QList<QUrl> selectedFiles;
-+
-+        // Patch: Adding select-by-url for Windows file dialog.
-+        QByteArray selectedRemoteContent;
-+
-         QMutex mutex;
-     };
-     QExplicitlySharedDataPointer<Data> m_data;
-@@ -775,6 +783,21 @@ inline void QWindowsFileDialogSharedData::setSelectedFiles(const QList<QUrl> &ur
-     m_data->selectedFiles = urls;
- }
- 
-+// Patch: Adding select-by-url for Windows file dialog.
-+inline QByteArray QWindowsFileDialogSharedData::selectedRemoteContent() const
-+{
-+    m_data->mutex.lock();
-+    const QByteArray result = m_data->selectedRemoteContent;
-+    m_data->mutex.unlock();
-+    return result;
-+}
-+
-+inline void QWindowsFileDialogSharedData::setSelectedRemoteContent(const QByteArray &c)
-+{
-+    QMutexLocker(&m_data->mutex);
-+    m_data->selectedRemoteContent = c;
-+}
-+
- inline void QWindowsFileDialogSharedData::fromOptions(const QSharedPointer<QFileDialogOptions> &o)
- {
-     QMutexLocker locker(&m_data->mutex);
-@@ -899,6 +922,9 @@ public:
-     // example by appended default suffixes, etc.
-     virtual QList<QUrl> dialogResult() const = 0;
- 
-+    // Patch: Adding select-by-url for Windows file dialog.
-+    virtual QByteArray dialogRemoteContent() const { return QByteArray(); }
-+
-     inline void onFolderChange(IShellItem *);
-     inline void onSelectionChange();
-     inline void onTypeChange();
-@@ -1338,7 +1364,14 @@ void QWindowsNativeFileDialogBase::selectFile(const QString &fileName) const
-     // Hack to prevent CLSIDs from being set as file name due to
-     // QFileDialogPrivate::initialSelection() being QString-based.
-     if (!isClsid(fileName))
--        m_fileDialog->SetFileName((wchar_t*)fileName.utf16());
-+    // Patch: Fix handle of full fileName.
-+    {
-+        QString file = QDir::toNativeSeparators(fileName);
-+        int lastBackSlash = file.lastIndexOf(QChar::fromLatin1('\\'));
-+        if (lastBackSlash >= 0)
-+            file = file.mid(lastBackSlash + 1);
-+        m_fileDialog->SetFileName((wchar_t*)file.utf16());;
-+    }
- }
- 
- // Return the index of the selected filter, accounting for QFileDialog
-@@ -1408,6 +1441,10 @@ bool QWindowsNativeFileDialogBase::onFileOk()
- {
-     // Store selected files as GetResults() returns invalid data after the dialog closes.
-     m_data.setSelectedFiles(dialogResult());
-+
-+    // Patch: Adding select-by-url for Windows file dialog.
-+    m_data.setSelectedRemoteContent(dialogRemoteContent());
-+
-     return true;
- }
- 
-@@ -1542,6 +1579,9 @@ public:
-     QList<QUrl> selectedFiles() const Q_DECL_OVERRIDE;
-     QList<QUrl> dialogResult() const Q_DECL_OVERRIDE;
- 
-+    // Patch: Adding select-by-url for Windows file dialog.
-+    QByteArray dialogRemoteContent() const Q_DECL_OVERRIDE;
-+
- private:
-     inline IFileOpenDialog *openFileDialog() const
-         { return static_cast<IFileOpenDialog *>(fileDialog()); }
-@@ -1556,6 +1596,62 @@ QList<QUrl> QWindowsNativeOpenFileDialog::dialogResult() const
-     return result;
- }
- 
-+// Patch: Adding select-by-url for Windows file dialog.
-+QByteArray QWindowsNativeOpenFileDialog::dialogRemoteContent() const
-+{
-+    QByteArray result;
-+    IShellItemArray *items = 0;
-+    if (FAILED(openFileDialog()->GetResults(&items)) || !items)
-+        return result;
-+    DWORD itemCount = 0;
-+    if (FAILED(items->GetCount(&itemCount)) || !itemCount)
-+        return result;
-+    for (DWORD i = 0; i < itemCount; ++i)
-+    {
-+        IShellItem *item = 0;
-+        if (SUCCEEDED(items->GetItemAt(i, &item))) {
-+            SFGAOF attributes = 0;
-+            // Check whether it has a file system representation?
-+            if (FAILED(item->GetAttributes(SFGAO_FILESYSTEM, &attributes)) || (attributes & SFGAO_FILESYSTEM))
-+            {
-+                LPWSTR name = 0;
-+                if (SUCCEEDED(item->GetDisplayName(SIGDN_FILESYSPATH, &name)))
-+                {
-+                    CoTaskMemFree(name);
-+                    continue;
-+                }
-+            }
-+            if (FAILED(item->GetAttributes(SFGAO_STREAM, &attributes)) || !(attributes & SFGAO_STREAM))
-+                continue;
-+
-+            IBindCtx *bind = 0;
-+            if (FAILED(CreateBindCtx(0, &bind)))
-+                continue;
-+
-+            IStream *stream = 0;
-+            if (FAILED(item->BindToHandler(bind, BHID_Stream, IID_IStream, reinterpret_cast<void **>(&stream))))
-+                continue;
-+
-+            STATSTG stat = { 0 };
-+            if (FAILED(stream->Stat(&stat, STATFLAG_NONAME)) || !stat.cbSize.QuadPart)
-+                continue;
-+
-+            quint64 fullSize = stat.cbSize.QuadPart;
-+            if (fullSize <= 64 * 1024 * 1024)
-+            {
-+                result.resize(fullSize);
-+                ULONG read = 0;
-+                HRESULT r = stream->Read(result.data(), fullSize, &read);
-+                if (r == S_FALSE || r == S_OK)
-+                    return result;
-+
-+                result.clear();
-+            }
-+        }
-+    }
-+    return result;
-+}
-+
- QList<QUrl> QWindowsNativeOpenFileDialog::selectedFiles() const
- {
-     QList<QUrl> result;
-@@ -1614,6 +1710,10 @@ public:
-     virtual QUrl directory() const Q_DECL_OVERRIDE;
-     virtual void selectFile(const QUrl &filename) Q_DECL_OVERRIDE;
-     virtual QList<QUrl> selectedFiles() const Q_DECL_OVERRIDE;
-+
-+    // Patch: Adding select-by-url for Windows file dialog.
-+    virtual QByteArray selectedRemoteContent() const Q_DECL_OVERRIDE;
-+
-     virtual void setFilter() Q_DECL_OVERRIDE;
-     virtual void selectNameFilter(const QString &filter) Q_DECL_OVERRIDE;
-     virtual QString selectedNameFilter() const Q_DECL_OVERRIDE;
-@@ -1707,6 +1807,12 @@ QList<QUrl> QWindowsFileDialogHelper::selectedFiles() const
-     return m_data.selectedFiles();
- }
- 
-+// Patch: Adding select-by-url for Windows file dialog.
-+QByteArray QWindowsFileDialogHelper::selectedRemoteContent() const
-+{
-+    return m_data.selectedRemoteContent();
-+}
-+
- void QWindowsFileDialogHelper::setFilter()
- {
-     qCDebug(lcQpaDialogs) << __FUNCTION__;
-@@ -1996,6 +2102,10 @@ public:
-     QUrl directory() const Q_DECL_OVERRIDE;
-     void selectFile(const QUrl &url) Q_DECL_OVERRIDE;
-     QList<QUrl> selectedFiles() const Q_DECL_OVERRIDE;
-+
-+    // Patch: Adding select-by-url for Windows file dialog.
-+    QByteArray selectedRemoteContent() const Q_DECL_OVERRIDE;
-+
-     void setFilter() Q_DECL_OVERRIDE {}
-     void selectNameFilter(const QString &) Q_DECL_OVERRIDE;
-     QString selectedNameFilter() const Q_DECL_OVERRIDE;
-@@ -2039,6 +2149,12 @@ QList<QUrl> QWindowsXpFileDialogHelper::selectedFiles() const
-     return m_data.selectedFiles();
- }
- 
-+// Patch: Adding select-by-url for Windows file dialog.
-+QByteArray QWindowsXpFileDialogHelper::selectedRemoteContent() const
-+{
-+    return m_data.selectedRemoteContent();
-+}
-+
- void QWindowsXpFileDialogHelper::selectNameFilter(const QString &f)
- {
-     m_data.setSelectedNameFilter(f); // Dialog cannot be updated at run-time.
-diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp
-index 1e58b9b..1741c21 100644
---- a/src/plugins/platforms/windows/qwindowskeymapper.cpp
-+++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp
-@@ -1268,6 +1268,10 @@ QList<int> QWindowsKeyMapper::possibleKeys(const QKeyEvent *e) const
-     if (nativeVirtualKey > 255)
-         return result;
- 
-+    // Patch: This must not happen, but there are crash reports on the next line.
-+    if (e->nativeVirtualKey() > 0xFF)
-+        return result;
-+
-     const KeyboardLayoutItem &kbItem = keyLayout[nativeVirtualKey];
-     if (!kbItem.exists)
-         return result;
-diff --git a/src/plugins/platforms/windows/qwindowsservices.cpp b/src/plugins/platforms/windows/qwindowsservices.cpp
-index 1d23a9d..640cd42 100644
---- a/src/plugins/platforms/windows/qwindowsservices.cpp
-+++ b/src/plugins/platforms/windows/qwindowsservices.cpp
-@@ -127,6 +127,10 @@ static inline bool launchMail(const QUrl &url)
-             command.prepend(doubleQuote);
-         }
-     }
-+
-+    // Patch: Fix mail launch if no param is expected in this command.
-+    if (command.indexOf(QStringLiteral("%1")) < 0) return false;
-+
-     // Pass the url as the parameter. Should use QProcess::startDetached(),
-     // but that cannot handle a Windows command line [yet].
-     command.replace(QStringLiteral("%1"), url.toString(QUrl::FullyEncoded));
-diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
-index b38d7c2..34f19c4 100644
---- a/src/plugins/platforms/windows/qwindowswindow.cpp
-+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
-@@ -1020,7 +1020,8 @@ void QWindowsWindow::destroyWindow()
-         // Clear any transient child relationships as Windows will otherwise destroy them (QTBUG-35499, QTBUG-36666)
-         if (QWindow *transientChild = findTransientChild(window()))
-             if (QWindowsWindow *tw = QWindowsWindow::baseWindowOf(transientChild))
--                tw->updateTransientParent();
-+                // Patch: Fix possibility of add / remove taskbar icon of the window.
-+                tw->clearTransientParent();
-         QWindowsContext *context = QWindowsContext::instance();
-         if (context->windowUnderMouse() == window())
-             context->clearWindowUnderMouse();
-@@ -1235,6 +1236,21 @@ void QWindowsWindow::updateTransientParent() const
-         if (const QWindowsWindow *tw = QWindowsWindow::baseWindowOf(tp))
-             if (!tw->testFlag(WithinDestroy)) // Prevent destruction by parent window (QTBUG-35499, QTBUG-36666)
-                 newTransientParent = tw->handle();
-+    // Patch: Fix possibility of add / remove taskbar icon of the window.
-+    if (newTransientParent && newTransientParent != oldTransientParent)
-+        SetWindowLongPtr(m_data.hwnd, GWL_HWNDPARENT, (LONG_PTR)newTransientParent);
-+#endif // !Q_OS_WINCE
-+}
-+
-+// Patch: Fix possibility of add / remove taskbar icon of the window.
-+void QWindowsWindow::clearTransientParent() const
-+{
-+#ifndef Q_OS_WINCE
-+    if (window()->type() == Qt::Popup)
-+        return; // QTBUG-34503, // a popup stays on top, no parent, see also WindowCreationData::fromWindow().
-+    // Update transient parent.
-+    const HWND oldTransientParent = transientParentHwnd(m_data.hwnd);
-+    HWND newTransientParent = 0;
-     if (newTransientParent != oldTransientParent)
-         SetWindowLongPtr(m_data.hwnd, GWL_HWNDPARENT, (LONG_PTR)newTransientParent);
- #endif // !Q_OS_WINCE
-@@ -1448,10 +1464,14 @@ void QWindowsWindow::handleResized(int wParam)
-         handleGeometryChange();
-         break;
-     case SIZE_RESTORED:
--        if (isFullScreen_sys())
--            handleWindowStateChange(Qt::WindowFullScreen);
--        else if (m_windowState != Qt::WindowNoState && !testFlag(MaximizeToFullScreen))
-+        // Patch: When resolution is changed for a frameless fullscreen widget
-+        // handleWindowStateChange call prevents correct geometry get in handleGeometryChange().
-+        if (isFullScreen_sys()) {
-+            if (m_windowState != Qt::WindowFullScreen)
-+                handleWindowStateChange(Qt::WindowFullScreen);
-+        } else if (m_windowState != Qt::WindowNoState && !testFlag(MaximizeToFullScreen)) {
-             handleWindowStateChange(Qt::WindowNoState);
-+        }
-         handleGeometryChange();
-         break;
-     }
-diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h
-index 6fffa1e..cb1c9c1 100644
---- a/src/plugins/platforms/windows/qwindowswindow.h
-+++ b/src/plugins/platforms/windows/qwindowswindow.h
-@@ -265,6 +265,10 @@ private:
-     inline void setWindowState_sys(Qt::WindowState newState);
-     inline void setParent_sys(const QPlatformWindow *parent);
-     inline void updateTransientParent() const;
-+
-+    // Patch: Fix possibility of add / remove taskbar icon of the window.
-+    inline void clearTransientParent() const;
-+
-     void destroyWindow();
-     inline bool isDropSiteEnabled() const { return m_dropTarget != 0; }
-     void setDropSiteEnabled(bool enabled);
-diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
-index 09e7ecf..c0f15a4 100644
---- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
-+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
-@@ -79,7 +79,10 @@ static int resourceType(const QByteArray &key)
-         QByteArrayLiteral("rootwindow"),
-         QByteArrayLiteral("subpixeltype"), QByteArrayLiteral("antialiasingenabled"),
-         QByteArrayLiteral("nofonthinting"),
--        QByteArrayLiteral("atspibus")
-+        QByteArrayLiteral("atspibus"),
-+
-+        // Patch: Backport compositing manager check from Qt 5.7
-+        QByteArrayLiteral("compositingenabled")
-     };
-     const QByteArray *end = names + sizeof(names) / sizeof(names[0]);
-     const QByteArray *result = std::find(names, end, key);
-@@ -252,6 +255,13 @@ void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resourceStr
-     case RootWindow:
-         result = reinterpret_cast<void *>(xcbScreen->root());
-         break;
-+
-+    // Patch: Backport compositing manager check from Qt 5.7
-+    case CompositingEnabled:
-+        if (QXcbVirtualDesktop *vd = xcbScreen->virtualDesktop())
-+            result = vd->compositingActive() ? this : Q_NULLPTR;
-+        break;
-+
-     default:
-         break;
-     }
-diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h
-index f88b710..6f818a5 100644
---- a/src/plugins/platforms/xcb/qxcbnativeinterface.h
-+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h
-@@ -68,7 +68,10 @@ public:
-         ScreenSubpixelType,
-         ScreenAntialiasingEnabled,
-         NoFontHinting,
--        AtspiBus
-+        AtspiBus,
-+
-+        // Patch: Backport compositing manager check from Qt 5.7
-+        CompositingEnabled
-     };
- 
-     QXcbNativeInterface();
-diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
-index bc2de89..aa8f8df 100644
---- a/src/widgets/dialogs/qfiledialog.cpp
-+++ b/src/widgets/dialogs/qfiledialog.cpp
-@@ -1200,6 +1200,15 @@ QList<QUrl> QFileDialogPrivate::userSelectedFiles() const
-     return files;
- }
- 
-+// Patch: Adding select-by-url for Windows file dialog.
-+QByteArray QFileDialogPrivate::userSelectedRemoteContent() const
-+{
-+    if (nativeDialogInUse)
-+        return selectedRemoteContent_sys();
-+
-+    return QByteArray();
-+}
-+
- QStringList QFileDialogPrivate::addDefaultSuffixToFiles(const QStringList &filesToFix) const
- {
-     QStringList files;
-@@ -1267,6 +1276,14 @@ QStringList QFileDialog::selectedFiles() const
-     return files;
- }
- 
-+// Patch: Adding select-by-url for Windows file dialog.
-+QByteArray QFileDialog::selectedRemoteContent() const
-+{
-+    Q_D(const QFileDialog);
-+
-+    return d->userSelectedRemoteContent();
-+}
-+
- /*!
-     Returns a list of urls containing the selected files in the dialog.
-     If no files are selected, or the mode is not ExistingFiles or
-diff --git a/src/widgets/dialogs/qfiledialog.h b/src/widgets/dialogs/qfiledialog.h
-index ffe49a2..42dc563 100644
---- a/src/widgets/dialogs/qfiledialog.h
-+++ b/src/widgets/dialogs/qfiledialog.h
-@@ -108,6 +108,9 @@ public:
-     void selectFile(const QString &filename);
-     QStringList selectedFiles() const;
- 
-+    // Patch: Adding select-by-url for Windows file dialog.
-+    QByteArray selectedRemoteContent() const;
-+
-     void selectUrl(const QUrl &url);
-     QList<QUrl> selectedUrls() const;
- 
-diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h
-index f610e46..547a646 100644
---- a/src/widgets/dialogs/qfiledialog_p.h
-+++ b/src/widgets/dialogs/qfiledialog_p.h
-@@ -123,6 +123,10 @@ public:
-     static QString initialSelection(const QUrl &path);
-     QStringList typedFiles() const;
-     QList<QUrl> userSelectedFiles() const;
-+
-+    // Patch: Adding select-by-url for Windows file dialog.
-+    QByteArray userSelectedRemoteContent() const;
-+
-     QStringList addDefaultSuffixToFiles(const QStringList &filesToFix) const;
-     QList<QUrl> addDefaultSuffixToUrls(const QList<QUrl> &urlsToFix) const;
-     bool removeDirectory(const QString &path);
-@@ -256,6 +260,10 @@ public:
-     QUrl directory_sys() const;
-     void selectFile_sys(const QUrl &filename);
-     QList<QUrl> selectedFiles_sys() const;
-+
-+    // Patch: Adding select-by-url for Windows file dialog.
-+    QByteArray selectedRemoteContent_sys() const;
-+
-     void setFilter_sys();
-     void selectNameFilter_sys(const QString &filter);
-     QString selectedNameFilter_sys() const;
-@@ -393,6 +401,14 @@ inline QList<QUrl> QFileDialogPrivate::selectedFiles_sys() const
-     return QList<QUrl>();
- }
- 
-+// Patch: Adding select-by-url for Windows file dialog.
-+inline QByteArray QFileDialogPrivate::selectedRemoteContent_sys() const
-+{
-+    if (QPlatformFileDialogHelper *helper = platformFileDialogHelper())
-+        return helper->selectedRemoteContent();
-+    return QByteArray();
-+}
-+
- inline void QFileDialogPrivate::setFilter_sys()
- {
-     if (QPlatformFileDialogHelper *helper = platformFileDialogHelper())
-diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
-index b1d80d7..42e32fd 100644
---- a/src/widgets/kernel/qwidget.cpp
-+++ b/src/widgets/kernel/qwidget.cpp
-@@ -5138,6 +5138,17 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset,
-         return; // Fully transparent.
- 
-     Q_D(QWidget);
-+
-+    // Patch: save and restore dirtyOpaqueChildren field.
-+    //
-+    // Just like in QWidget::grab() this field should be restored
-+    // after the d->render() call, because it will be set to 1 and
-+    // opaqueChildren field will be filled with empty region in
-+    // case the widget is hidden (because all the opaque children
-+    // will be skipped in isVisible() check).
-+    //
-+    const bool oldDirtyOpaqueChildren = d->dirtyOpaqueChildren;
-+
-     const bool inRenderWithPainter = d->extra && d->extra->inRenderWithPainter;
-     const QRegion toBePainted = !inRenderWithPainter ? d->prepareToRender(sourceRegion, renderFlags)
-                                                      : sourceRegion;
-@@ -5159,6 +5170,10 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset,
-     if (!inRenderWithPainter && (opacity < 1.0 || (target->devType() == QInternal::Printer))) {
-         d->render_helper(painter, targetOffset, toBePainted, renderFlags);
-         d->extra->inRenderWithPainter = inRenderWithPainter;
-+
-+        // Patch: save and restore dirtyOpaqueChildren field.
-+        d->dirtyOpaqueChildren = oldDirtyOpaqueChildren;
-+
-         return;
-     }
- 
-@@ -5190,6 +5205,9 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset,
-     d->setSharedPainter(oldPainter);
- 
-     d->extra->inRenderWithPainter = inRenderWithPainter;
-+
-+    // Patch: save and restore dirtyOpaqueChildren field.
-+    d->dirtyOpaqueChildren = oldDirtyOpaqueChildren;
- }
- 
- static void sendResizeEvents(QWidget *target)
-@@ -8769,7 +8787,8 @@ bool QWidget::event(QEvent *event)
-     case QEvent::KeyPress: {
-         QKeyEvent *k = (QKeyEvent *)event;
-         bool res = false;
--        if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) {  //### Add MetaModifier?
-+        // Patch: Enable Ctrl+Tab and Ctrl+Shift+Tab / Ctrl+Backtab handle in-app.
-+        if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier))) {  //### Add MetaModifier?
-             if (k->key() == Qt::Key_Backtab
-                 || (k->key() == Qt::Key_Tab && (k->modifiers() & Qt::ShiftModifier)))
-                 res = focusNextPrevChild(false);
-diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp
-index 704142f..7c4340e 100644
---- a/src/widgets/util/qsystemtrayicon.cpp
-+++ b/src/widgets/util/qsystemtrayicon.cpp
-@@ -709,6 +709,10 @@ void QSystemTrayIconPrivate::updateMenu_sys_qpa()
-     if (menu) {
-         addPlatformMenu(menu);
-         qpa_sys->updateMenu(menu->platformMenu());
-+
-+    // Patch: Create a rich os x tray icon (pixel-perfect, theme switching).
-+    } else {
-+        qpa_sys->updateMenu(nullptr);
-     }
- }
- 
-diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp
-index 2e2a042..472e377 100644
---- a/src/widgets/widgets/qabstractscrollarea.cpp
-+++ b/src/widgets/widgets/qabstractscrollarea.cpp
-@@ -640,15 +640,22 @@ scrolling range.
- QSize QAbstractScrollArea::maximumViewportSize() const
- {
-     Q_D(const QAbstractScrollArea);
--    int hsbExt = d->hbar->sizeHint().height();
--    int vsbExt = d->vbar->sizeHint().width();
-+    // Patch: Count the sizeHint of the bar only if it is displayed.
-+    //int hsbExt = d->hbar->sizeHint().height();
-+    //int vsbExt = d->vbar->sizeHint().width();
- 
-     int f = 2 * d->frameWidth;
-     QSize max = size() - QSize(f + d->left + d->right, f + d->top + d->bottom);
--    if (d->vbarpolicy == Qt::ScrollBarAlwaysOn)
-+
-+    // Patch: Count the sizeHint of the bar only if it is displayed.
-+    if (d->vbarpolicy == Qt::ScrollBarAlwaysOn) {
-+        int vsbExt = d->vbar->sizeHint().width();
-         max.rwidth() -= vsbExt;
--    if (d->hbarpolicy == Qt::ScrollBarAlwaysOn)
-+    }
-+    if (d->hbarpolicy == Qt::ScrollBarAlwaysOn) {
-+        int hsbExt = d->hbar->sizeHint().height();
-         max.rheight() -= hsbExt;
-+    }
-     return max;
- }
- 
-diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
-index daf9f00..57499dc 100644
---- a/src/widgets/widgets/qwidgetlinecontrol.cpp
-+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
-@@ -40,6 +40,11 @@
- #include <private/qguiapplication_p.h>
- #include <qpa/qplatformtheme.h>
- #include <qstylehints.h>
-+
-+// Patch: Enable Ctrl+key and Ctrl+Shift+key in all locales except German.
-+// See https://github.com/telegramdesktop/tdesktop/pull/1185.
-+#include <QtCore/QLocale>
-+
- #ifndef QT_NO_ACCESSIBILITY
- #include "qaccessible.h"
- #endif
-@@ -1882,11 +1887,21 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
-     }
- 
-     // QTBUG-35734: ignore Ctrl/Ctrl+Shift; accept only AltGr (Alt+Ctrl) on German keyboards
--    if (unknown && !isReadOnly()
--        && event->modifiers() != Qt::ControlModifier
--        && event->modifiers() != (Qt::ControlModifier | Qt::ShiftModifier)) {
-+
-+    // Patch: Enable Ctrl+key and Ctrl+Shift+key in all locales except German.
-+    // See https://github.com/telegramdesktop/tdesktop/pull/1185.
-+    bool skipCtrlAndCtrlShift = false;
-+    if (QGuiApplication::inputMethod()->locale().language() == QLocale::German) {
-+        if (event->modifiers() == Qt::ControlModifier
-+            || event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) {
-+            skipCtrlAndCtrlShift = true;
-+        }
-+    }
-+    if (unknown && !isReadOnly() && !skipCtrlAndCtrlShift) {
-         QString t = event->text();
--        if (!t.isEmpty() && t.at(0).isPrint()) {
-+
-+        // Patch: Enable ZWJ and ZWNJ characters to be in text input.
-+        if (!t.isEmpty() && (t.at(0).isPrint() || t.at(0).unicode() == 0x200C || t.at(0).unicode() == 0x200D)) {
-             insert(t);
- #ifndef QT_NO_COMPLETER
-             complete(event->key());
-diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
-index deca002..8a2023f 100644
---- a/src/widgets/widgets/qwidgettextcontrol.cpp
-+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
-@@ -71,6 +71,11 @@
- #include <qinputmethod.h>
- #include <qtooltip.h>
- #include <qstyleoption.h>
-+
-+// Patch: Enable Ctrl+key and Ctrl+Shift+key in all locales except German.
-+// See https://github.com/telegramdesktop/tdesktop/pull/1185.
-+#include <QtCore/QLocale>
-+
- #include <QtWidgets/qlineedit.h>
- #include <QtGui/qaccessible.h>
- #include <QtCore/qmetaobject.h>
-@@ -1343,13 +1348,24 @@ void QWidgetTextControlPrivate::keyPressEvent(QKeyEvent *e)
- process:
-     {
-         // QTBUG-35734: ignore Ctrl/Ctrl+Shift; accept only AltGr (Alt+Ctrl) on German keyboards
--        if (e->modifiers() == Qt::ControlModifier
--            || e->modifiers() == (Qt::ShiftModifier | Qt::ControlModifier)) {
-+
-+        // Patch: Enable Ctrl+key and Ctrl+Shift+key in all locales except German.
-+        // See https://github.com/telegramdesktop/tdesktop/pull/1185.
-+        bool skipCtrlAndCtrlShift = false;
-+        if (QGuiApplication::inputMethod()->locale().language() == QLocale::German) {
-+            if (e->modifiers() == Qt::ControlModifier
-+                || e->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) {
-+                skipCtrlAndCtrlShift = true;
-+            }
-+        }
-+        if (skipCtrlAndCtrlShift) {
-             e->ignore();
-             return;
-         }
-         QString text = e->text();
--        if (!text.isEmpty() && (text.at(0).isPrint() || text.at(0) == QLatin1Char('\t'))) {
-+
-+        // Patch: Enable ZWJ and ZWNJ characters to be in text input.
-+        if (!text.isEmpty() && (text.at(0).isPrint() || text.at(0) == QLatin1Char('\t') || text.at(0).unicode() == 0x200C || text.at(0).unicode() == 0x200D)) {
-             if (overwriteMode
-                 // no need to call deleteChar() if we have a selection, insertText
-                 // does it already
diff --git a/Telegram/Resources/langs/download.sh b/Telegram/Resources/langs/download.sh
deleted file mode 100755
index 92f1ef1db..000000000
--- a/Telegram/Resources/langs/download.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/env bash
-set -e
-FullExecPath=$PWD
-pushd `dirname $0` > /dev/null
-FullScriptPath=`pwd`
-popd > /dev/null
-
-if [ ! -d "$FullScriptPath/../../../../TelegramPrivate" ]; then
-  echo ""
-  echo "This script is for building the production version of Telegram Desktop."
-  echo ""
-  echo "For building custom versions please visit the build instructions page at:"
-  echo "https://github.com/telegramdesktop/tdesktop/#build-instructions"
-  exit
-fi
-
-Error () {
-  cd $FullExecPath
-  echo "$1"
-  exit 1
-}
-
-cd $FullScriptPath/../../../../
-while IFS='' read -r line || [[ -n "$line" ]]; do
-  tx pull -f -l $line --minimum-perc=100
-done < tdesktop/Telegram/Resources/langs/list
-cd translations/telegram-desktop.langstrings/
-for file in *.strings; do
-  iconv -f "UTF-16LE" -t "UTF-8" "$file" > "../../tdesktop/Telegram/Resources/langs/lang_$file.tmp"
-  awk '{ if (NR==1) sub(/^\xef\xbb\xbf/,""); sub(/
/,""); print }' "../../tdesktop/Telegram/Resources/langs/lang_$file.tmp" > "../../tdesktop/Telegram/Resources/langs/lang_$file"
-  rm "../../tdesktop/Telegram/Resources/langs/lang_$file.tmp"
-done
-
-cd $FullExecPath
diff --git a/Telegram/Resources/langs/upload.sh b/Telegram/Resources/langs/upload.sh
deleted file mode 100755
index e20706990..000000000
--- a/Telegram/Resources/langs/upload.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env bash
-set -e
-FullExecPath=$PWD
-pushd `dirname $0` > /dev/null
-FullScriptPath=`pwd`
-popd > /dev/null
-
-if [ ! -d "$FullScriptPath/../../../../TelegramPrivate" ]; then
-  echo ""
-  echo "This script is for building the production version of Telegram Desktop."
-  echo ""
-  echo "For building custom versions please visit the build instructions page at:"
-  echo "https://github.com/telegramdesktop/tdesktop/#build-instructions"
-  exit
-fi
-
-Error () {
-  cd $FullExecPath
-  echo "$1"
-  exit 1
-}
-
-cd $FullScriptPath/../../../../
-while IFS='' read -r line || [[ -n "$line" ]]; do
-  tx pull -f -l $line
-done < tdesktop/Telegram/Resources/langs/list
-tx push -s
-
-cd $FullExecPath
diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc
deleted file mode 100644
index ad5bce869..000000000
--- a/Telegram/Resources/winrc/Updater.rc
+++ /dev/null
@@ -1,72 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource1.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "winres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,1,23,0
- PRODUCTVERSION 1,1,23,0
- FILEFLAGSMASK 0x3fL
-#ifdef _DEBUG
- FILEFLAGS 0x1L
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS 0x40004L
- FILETYPE 0x0L
- FILESUBTYPE 0x0L
-BEGIN
-    BLOCK "StringFileInfo"
-    BEGIN
-        BLOCK "040904b0"
-        BEGIN
-            VALUE "CompanyName", "Telegram Messenger LLP"
-            VALUE "FileDescription", "Telegram Desktop Updater"
-            VALUE "FileVersion", "1.1.23.0"
-            VALUE "LegalCopyright", "Copyright (C) 2014-2017"
-            VALUE "ProductName", "Telegram Desktop"
-            VALUE "ProductVersion", "1.1.23.0"
-        END
-    END
-    BLOCK "VarFileInfo"
-    BEGIN
-        VALUE "Translation", 0x409, 1200
-    END
-END
-
-#endif    // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif    // not APSTUDIO_INVOKED
-
diff --git a/Telegram/Resources/winrc/resource1.h b/Telegram/Resources/winrc/resource1.h
deleted file mode 100644
index fa4d7c2ea..000000000
--- a/Telegram/Resources/winrc/resource1.h
+++ /dev/null
@@ -1,14 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by Updater.rc
-
-// Next default values for new objects
-// 
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE        101
-#define _APS_NEXT_COMMAND_VALUE         40001
-#define _APS_NEXT_CONTROL_VALUE         1001
-#define _APS_NEXT_SYMED_VALUE           101
-#endif
-#endif
diff --git a/Telegram/build/build.bat b/Telegram/build/build.bat
deleted file mode 100644
index 3bf255b87..000000000
--- a/Telegram/build/build.bat
+++ /dev/null
@@ -1,317 +0,0 @@
-@echo OFF
-setlocal enabledelayedexpansion
-set "FullScriptPath=%~dp0"
-set "FullExecPath=%cd%"
-
-if not exist "%FullScriptPath%..\..\..\TelegramPrivate" (
-  echo.
-  echo This script is for building the production version of Telegram Desktop.
-  echo.
-  echo For building custom versions please visit the build instructions page at:
-  echo https://github.com/telegramdesktop/tdesktop/#build-instructions
-  exit /b
-)
-
-FOR /F "tokens=1* delims= " %%i in (%FullScriptPath%target) do set "BuildTarget=%%i"
-
-if "%BuildTarget%" equ "uwp" (
-  set "BuildUWP=1"
-) else (
-  set "BuildUWP=0"
-)
-
-FOR /F "tokens=1,2* delims= " %%i in (%FullScriptPath%version) do set "%%i=%%j"
-
-set "VersionForPacker=%AppVersion%"
-if %BetaVersion% neq 0 (
-  set "AppVersion=%BetaVersion%"
-  set "AppVersionStrFull=%AppVersionStr%_%BetaVersion%"
-  set "AlphaBetaParam=-beta %BetaVersion%"
-  set "BetaKeyFile=tbeta_%BetaVersion%_key"
-) else (
-  if %AlphaChannel% neq 0 (
-    set "AlphaBetaParam=-alpha"
-    set "AppVersionStrFull=%AppVersionStr%.alpha"
-  ) else (
-    set "AlphaBetaParam="
-    set "AppVersionStrFull=%AppVersionStr%"
-  )
-)
-
-echo.
-if %BuildUWP% neq 0 (
-  echo Building version %AppVersionStrFull% for UWP..
-) else (
-  echo Building version %AppVersionStrFull% for Windows..
-)
-echo.
-
-set "HomePath=%FullScriptPath%.."
-set "ResourcesPath=%HomePath%\Resources"
-set "SolutionPath=%HomePath%\.."
-set "UpdateFile=tupdate%AppVersion%"
-set "SetupFile=tsetup.%AppVersionStrFull%.exe"
-set "PortableFile=tportable.%AppVersionStrFull%.zip"
-set "ReleasePath=%HomePath%\..\out\Release"
-set "DeployPath=%ReleasePath%\deploy\%AppVersionStrMajor%\%AppVersionStrFull%"
-set "SignPath=%HomePath%\..\..\TelegramPrivate\Sign.bat"
-set "SignAppxPath=%HomePath%\..\..\TelegramPrivate\AppxSign.bat"
-set "BinaryName=Telegram"
-set "DropboxSymbolsPath=X:\Telegram\symbols"
-set "FinalReleasePath=Y:\TBuild\tother\tsetup"
-
-if not exist %DropboxSymbolsPath% (
-  echo Dropbox path %DropboxSymbolsPath% not found!
-  exit /b 1
-)
-
-if not exist %FinalReleasePath% (
-  echo Release path %FinalReleasePath% not found!
-  exit /b 1
-)
-
-if %BuildUWP% neq 0 (
-  if exist %ReleasePath%\AppX\ (
-    echo Result folder out\Release\AppX already exists!
-    exit /b 1
-  )
-)
-if %BetaVersion% neq 0 (
-  if exist %DeployPath%\ (
-    echo Deploy folder for version %AppVersionStr% already exists!
-    exit /b 1
-  )
-  if exist %ReleasePath%\%BetaKeyFile% (
-    echo Beta version key file for version %AppVersion% already exists!
-    exit /b 1
-  )
-) else (
-  if exist %ReleasePath%\deploy\%AppVersionStrMajor%\%AppVersionStr%.alpha\ (
-    echo Deploy folder for version %AppVersionStr%.alpha already exists!
-    exit /b 1
-  )
-  if exist %ReleasePath%\deploy\%AppVersionStrMajor%\%AppVersionStr%.dev\ (
-    echo Deploy folder for version %AppVersionStr%.dev already exists!
-    exit /b 1
-  )
-  if exist %ReleasePath%\deploy\%AppVersionStrMajor%\%AppVersionStr%\ (
-    echo Deploy folder for version %AppVersionStr% already exists!
-    exit /b 1
-  )
-  if exist %ReleasePath%\tupdate%AppVersion% (
-    echo Update file for version %AppVersion% already exists!
-    exit /b 1
-  )
-)
-
-cd "%HomePath%"
-
-call gyp\refresh.bat
-if %errorlevel% neq 0 goto error
-
-cd "%SolutionPath%"
-call ninja -C out/Release Telegram
-if %errorlevel% neq 0 goto error
-
-echo.
-echo Version %AppVersionStrFull% build successfull. Preparing..
-echo.
-
-echo Dumping debug symbols..
-xcopy "%ReleasePath%\%BinaryName%.exe" "%ReleasePath%\%BinaryName%.exe.exe*"
-call "%SolutionPath%\..\Libraries\breakpad\src\tools\windows\dump_syms\Release\dump_syms.exe" "%ReleasePath%\%BinaryName%.exe.pdb" > "%ReleasePath%\%BinaryName%.exe.sym"
-del "%ReleasePath%\%BinaryName%.exe.exe"
-echo Done!
-
-set "PATH=%PATH%;C:\Program Files\7-Zip;C:\Program Files (x86)\Inno Setup 5"
-
-cd "%ReleasePath%"
-call "%SignPath%" "%BinaryName%.exe"
-if %errorlevel% neq 0 goto error
-
-if %BuildUWP% equ 0 (
-  call "%SignPath%" "Updater.exe"
-  if %errorlevel% neq 0 goto error
-
-  if %BetaVersion% equ 0 (
-    iscc /dMyAppVersion=%AppVersionStrSmall% /dMyAppVersionZero=%AppVersionStr% /dMyAppVersionFull=%AppVersionStrFull% "/dReleasePath=%ReleasePath%" "%FullScriptPath%setup.iss"
-    if %errorlevel% neq 0 goto error
-    if not exist "tsetup.%AppVersionStrFull%.exe" goto error
-
-    call "%SignPath%" "tsetup.%AppVersionStrFull%.exe"
-    if %errorlevel% neq 0 goto error
-  )
-
-  call Packer.exe -version %VersionForPacker% -path %BinaryName%.exe -path Updater.exe %AlphaBetaParam%
-  if %errorlevel% neq 0 goto error
-
-  if %BetaVersion% neq 0 (
-    if not exist "%ReleasePath%\%BetaKeyFile%" (
-      echo Beta version key file not found!
-      exit /b 1
-    )
-
-    FOR /F "tokens=1* delims= " %%i in (%ReleasePath%\%BetaKeyFile%) do set "BetaSignature=%%i"
-  )
-  if %errorlevel% neq 0 goto error
-
-  if %BetaVersion% neq 0 (
-    set "UpdateFile=!UpdateFile!_!BetaSignature!"
-    set "PortableFile=tbeta!BetaVersion!_!BetaSignature!.zip"
-  )
-)
-
-for /f ^"usebackq^ eol^=^
-
-^ delims^=^" %%a in (%ReleasePath%\%BinaryName%.exe.sym) do (
-   set "SymbolsHashLine=%%a"
-   goto symbolslinedone
- )
- :symbolslinedone
-FOR /F "tokens=1,2,3,4* delims= " %%i in ("%SymbolsHashLine%") do set "SymbolsHash=%%l"
-
-echo Copying %BinaryName%.exe.sym to %DropboxSymbolsPath%\%BinaryName%.exe.pdb\%SymbolsHash%
-if not exist %DropboxSymbolsPath%\%BinaryName%.exe.pdb mkdir %DropboxSymbolsPath%\%BinaryName%.exe.pdb
-if not exist %DropboxSymbolsPath%\%BinaryName%.exe.pdb\%SymbolsHash% mkdir %DropboxSymbolsPath%\%BinaryName%.exe.pdb\%SymbolsHash%
-move "%ReleasePath%\%BinaryName%.exe.sym" %DropboxSymbolsPath%\%BinaryName%.exe.pdb\%SymbolsHash%\
-echo Done!
-
-if %BuildUWP% neq 0 (
-  cd "%HomePath%"
-
-  mkdir "%ReleasePath%\AppX_x86"
-  xcopy "Resources\uwp\AppX\*" "%ReleasePath%\AppX_x86\" /E
-  set "ResourcePath=%ReleasePath%\AppX_x86\AppxManifest.xml"
-  call :repl "Argument= (ProcessorArchitecture=)&quot;ARCHITECTURE&quot;/ $1&quot;x86&quot;" "Filename=!ResourcePath!" || goto error
-
-  makepri new /pr Resources\uwp\AppX\ /cf Resources\uwp\priconfig.xml /mn %ReleasePath%\AppX_x86\AppxManifest.xml /of %ReleasePath%\AppX_x86\resources.pri
-  if %errorlevel% neq 0 goto error
-
-  xcopy "%ReleasePath%\%BinaryName%.exe" "%ReleasePath%\AppX_x86\"
-
-  MakeAppx.exe pack /d "%ReleasePath%\AppX_x86" /l /p ..\out\Release\%BinaryName%.x86.appx
-  if %errorlevel% neq 0 goto error
-
-  mkdir "%ReleasePath%\AppX_x64"
-  xcopy "Resources\uwp\AppX\*" "%ReleasePath%\AppX_x64\" /E
-  set "ResourcePath=%ReleasePath%\AppX_x64\AppxManifest.xml"
-  call :repl "Argument= (ProcessorArchitecture=)&quot;ARCHITECTURE&quot;/ $1&quot;x64&quot;" "Filename=!ResourcePath!" || goto error
-
-  makepri new /pr Resources\uwp\AppX\ /cf Resources\uwp\priconfig.xml /mn %ReleasePath%\AppX_x64\AppxManifest.xml /of %ReleasePath%\AppX_x64\resources.pri
-  if %errorlevel% neq 0 goto error
-
-  xcopy "%ReleasePath%\%BinaryName%.exe" "%ReleasePath%\AppX_x64\"
-
-  MakeAppx.exe pack /d "%ReleasePath%\AppX_x64" /l /p ..\out\Release\%BinaryName%.x64.appx
-  if %errorlevel% neq 0 goto error
-
-  if not exist "%ReleasePath%\deploy" mkdir "%ReleasePath%\deploy"
-  if not exist "%ReleasePath%\deploy\%AppVersionStrMajor%" mkdir "%ReleasePath%\deploy\%AppVersionStrMajor%"
-  mkdir "%DeployPath%"
-
-  xcopy "%ReleasePath%\%BinaryName%.pdb" "%DeployPath%\"
-  move "%ReleasePath%\%BinaryName%.exe.pdb" "%DeployPath%\"
-  move "%ReleasePath%\%BinaryName%.x86.appx" "%DeployPath%\"
-  move "%ReleasePath%\%BinaryName%.x64.appx" "%DeployPath%\"
-  move "%ReleasePath%\%BinaryName%.exe" "%DeployPath%\"
-
-  if "%AlphaBetaParam%" equ "" (
-    move "%ReleasePath%\AppX_x86" "%DeployPath%\AppX_x86"
-    move "%ReleasePath%\AppX_x64" "%DeployPath%\AppX_x64"
-  ) else (
-    echo Leaving result in out\Release\AppX_arch for now..
-  )
-) else (
-  if not exist "%ReleasePath%\deploy" mkdir "%ReleasePath%\deploy"
-  if not exist "%ReleasePath%\deploy\%AppVersionStrMajor%" mkdir "%ReleasePath%\deploy\%AppVersionStrMajor%"
-  mkdir "%DeployPath%"
-  mkdir "%DeployPath%\%BinaryName%"
-  if %errorlevel% neq 0 goto error
-
-  move "%ReleasePath%\%BinaryName%.exe" "%DeployPath%\%BinaryName%\"
-  move "%ReleasePath%\Updater.exe" "%DeployPath%\"
-  xcopy "%ReleasePath%\%BinaryName%.pdb" "%DeployPath%\"
-  xcopy "%ReleasePath%\Updater.pdb" "%DeployPath%\"
-  move "%ReleasePath%\%BinaryName%.exe.pdb" "%DeployPath%\"
-  move "%ReleasePath%\Updater.exe.pdb" "%DeployPath%\"
-  if %BetaVersion% equ 0 (
-    move "%ReleasePath%\%SetupFile%" "%DeployPath%\"
-  ) else (
-    move "%ReleasePath%\%BetaKeyFile%" "%DeployPath%\"
-  )
-  move "%ReleasePath%\%UpdateFile%" "%DeployPath%\"
-  if %errorlevel% neq 0 goto error
-
-  cd "%DeployPath%"
-  7z a -mx9 %PortableFile% %BinaryName%\
-  if %errorlevel% neq 0 goto error
-)
-
-set "FinalDeployPath=%FinalReleasePath%\%AppVersionStrMajor%\%AppVersionStrFull%"
-
-if %BuildUWP% equ 0 (
-  echo.
-  echo Version %AppVersionStrFull% is ready for deploy!
-  echo.
-
-  if not exist "%DeployPath%\%UpdateFile%" goto error
-  if not exist "%DeployPath%\%PortableFile%" goto error
-  if %BetaVersion% equ 0 (
-    if not exist "%DeployPath%\%SetupFile%" goto error
-  )
-  if not exist "%DeployPath%\%BinaryName%.pdb" goto error
-  if not exist "%DeployPath%\%BinaryName%.exe.pdb" goto error
-  if not exist "%DeployPath%\Updater.exe" goto error
-  if not exist "%DeployPath%\Updater.pdb" goto error
-  if not exist "%DeployPath%\Updater.exe.pdb" goto error
-  if not exist "%FinalReleasePath%\%AppVersionStrMajor%" mkdir "%FinalReleasePath%\%AppVersionStrMajor%"
-  if not exist "%FinalDeployPath%" mkdir "%FinalDeployPath%"
-
-  xcopy "%DeployPath%\%UpdateFile%" "%FinalDeployPath%\" /Y
-  xcopy "%DeployPath%\%PortableFile%" "%FinalDeployPath%\" /Y
-  if %BetaVersion% equ 0 (
-    xcopy "%DeployPath%\%SetupFile%" "%FinalDeployPath%\" /Y
-  ) else (
-    xcopy "%DeployPath%\%BetaKeyFile%" "%FinalDeployPath%\" /Y
-  )
-)
-
-echo Version %AppVersionStrFull% is ready!
-
-cd "%FullExecPath%"
-exit /b
-
-:error
-(
-  set ErrorCode=%errorlevel%
-  if !ErrorCode! neq 0 (
-    echo Error !ErrorCode!
-  ) else (
-    echo Error 666
-    set ErrorCode=666
-  )
-  cd "%FullExecPath%"
-  exit /b !ErrorCode!
-)
-
-:repl
-(
-  set %1
-  set %2
-  set "TempFilename=!Filename!__tmp__"
-  cscript //Nologo "%FullScriptPath%replace.vbs" "Replace" "!Argument!" < "!Filename!" > "!TempFilename!" || goto :repl_finish
-  xcopy /Y !TempFilename! !Filename! >NUL || goto :repl_finish
-  goto :repl_finish
-)
-
-:repl_finish
-(
-  set ErrorCode=%errorlevel%
-  if !ErrorCode! neq 0 (
-    echo Replace error !ErrorCode!
-    echo While replacing "%Replace%"
-    echo In file "%Filename%"
-  )
-  del %TempFilename%
-  exit /b !ErrorCode!
-)
diff --git a/Telegram/build/build.sh b/Telegram/build/build.sh
deleted file mode 100755
index bcd367df4..000000000
--- a/Telegram/build/build.sh
+++ /dev/null
@@ -1,360 +0,0 @@
-set -e
-FullExecPath=$PWD
-pushd `dirname $0` > /dev/null
-FullScriptPath=`pwd`
-popd > /dev/null
-
-if [ ! -d "$FullScriptPath/../../../TelegramPrivate" ]; then
-  echo ""
-  echo "This script is for building the production version of Telegram Desktop."
-  echo ""
-  echo "For building custom versions please visit the build instructions page at:"
-  echo "https://github.com/telegramdesktop/tdesktop/#build-instructions"
-  exit
-fi
-
-Error () {
-  cd $FullExecPath
-  echo "$1"
-  exit 1
-}
-
-if [ ! -f "$FullScriptPath/target" ]; then
-  Error "Build target not found!"
-fi
-
-while IFS='' read -r line || [[ -n "$line" ]]; do
-  BuildTarget="$line"
-done < "$FullScriptPath/target"
-
-while IFS='' read -r line || [[ -n "$line" ]]; do
-  set $line
-  eval $1="$2"
-done < "$FullScriptPath/version"
-
-VersionForPacker="$AppVersion"
-if [ "$BetaVersion" != "0" ]; then
-  AppVersion="$BetaVersion"
-  AppVersionStrFull="${AppVersionStr}_${BetaVersion}"
-  AlphaBetaParam="-beta $BetaVersion"
-  BetaKeyFile="tbeta_${AppVersion}_key"
-elif [ "$AlphaChannel" == "0" ]; then
-  AppVersionStrFull="$AppVersionStr"
-  AlphaBetaParam=''
-else
-  AppVersionStrFull="$AppVersionStr.alpha"
-  AlphaBetaParam='-alpha'
-fi
-
-echo ""
-HomePath="$FullScriptPath/.."
-if [ "$BuildTarget" == "linux" ]; then
-  echo "Building version $AppVersionStrFull for Linux 64bit.."
-  UpdateFile="tlinuxupd$AppVersion"
-  SetupFile="tsetup.$AppVersionStrFull.tar.xz"
-  ReleasePath="$HomePath/../out/Release"
-  BinaryName="Telegram"
-elif [ "$BuildTarget" == "linux32" ]; then
-  echo "Building version $AppVersionStrFull for Linux 32bit.."
-  UpdateFile="tlinux32upd$AppVersion"
-  SetupFile="tsetup32.$AppVersionStrFull.tar.xz"
-  ReleasePath="$HomePath/../out/Release"
-  BinaryName="Telegram"
-elif [ "$BuildTarget" == "mac" ]; then
-  echo "Building version $AppVersionStrFull for OS X 10.8+.."
-  UpdateFile="tmacupd$AppVersion"
-  SetupFile="tsetup.$AppVersionStrFull.dmg"
-  ReleasePath="$HomePath/../out/Release"
-  BinaryName="Telegram"
-elif [ "$BuildTarget" == "mac32" ]; then
-  echo "Building version $AppVersionStrFull for OS X 10.6 and 10.7.."
-  UpdateFile="tmac32upd$AppVersion"
-  SetupFile="tsetup32.$AppVersionStrFull.dmg"
-  ReleasePath="$HomePath/../out/Release"
-  BinaryName="Telegram"
-elif [ "$BuildTarget" == "macstore" ]; then
-  if [ "$BetaVersion" != "0" ]; then
-    Error "Can't build macstore beta version!"
-  fi
-
-  echo "Building version $AppVersionStrFull for Mac App Store.."
-  ReleasePath="$HomePath/../out/Release"
-  BinaryName="Telegram Desktop"
-else
-  Error "Invalid target!"
-fi
-
-#if [ "$BuildTarget" == "linux" ] || [ "$BuildTarget" == "linux32" ] || [ "$BuildTarget" == "mac" ] || [ "$BuildTarget" == "mac32" ] || [ "$BuildTarget" == "macstore" ]; then
-  if [ "$BetaVersion" != "0" ]; then
-    if [ -f "$ReleasePath/$BetaKeyFile" ]; then
-      Error "Beta version key file for version $AppVersion already exists!"
-    fi
-
-    if [ -d "$ReleasePath/deploy/$AppVersionStrMajor/$AppVersionStrFull" ]; then
-      Error "Deploy folder for version $AppVersionStrFull already exists!"
-    fi
-  else
-    if [ -d "$ReleasePath/deploy/$AppVersionStrMajor/$AppVersionStr.alpha" ]; then
-      Error "Deploy folder for version $AppVersionStr.alpha already exists!"
-    fi
-
-    if [ -d "$ReleasePath/deploy/$AppVersionStrMajor/$AppVersionStr.dev" ]; then
-      Error "Deploy folder for version $AppVersionStr.dev already exists!"
-    fi
-
-    if [ -d "$ReleasePath/deploy/$AppVersionStrMajor/$AppVersionStr" ]; then
-      Error "Deploy folder for version $AppVersionStr already exists!"
-    fi
-
-    if [ -f "$ReleasePath/$UpdateFile" ]; then
-      Error "Update file for version $AppVersion already exists!"
-    fi
-  fi
-
-  DeployPath="$ReleasePath/deploy/$AppVersionStrMajor/$AppVersionStrFull"
-#fi
-
-if [ "$BuildTarget" == "linux" ] || [ "$BuildTarget" == "linux32" ]; then
-
-  DropboxSymbolsPath="/media/psf/Dropbox/Telegram/symbols"
-  if [ ! -d "$DropboxSymbolsPath" ]; then
-    Error "Dropbox path not found!"
-  fi
-
-  gyp/refresh.sh
-
-  cd $ReleasePath
-  make -j4
-  echo "$BinaryName build complete!"
-
-  if [ ! -f "$ReleasePath/$BinaryName" ]; then
-    Error "$BinaryName not found!"
-  fi
-
-  if [ ! -f "$ReleasePath/Updater" ]; then
-    Error "Updater not found!"
-  fi
-
-  echo "Dumping debug symbols.."
-  "$HomePath/../../Libraries/breakpad/src/tools/linux/dump_syms/dump_syms" "$ReleasePath/$BinaryName" > "$ReleasePath/$BinaryName.sym"
-  echo "Done!"
-
-  echo "Stripping the executable.."
-  strip -s "$ReleasePath/$BinaryName"
-  echo "Done!"
-
-  echo "Preparing version $AppVersionStrFull, executing Packer.."
-  cd "$ReleasePath"
-  "./Packer" -path "$BinaryName" -path Updater -version $VersionForPacker $AlphaBetaParam
-  echo "Packer done!"
-
-  if [ "$BetaVersion" != "0" ]; then
-    if [ ! -f "$ReleasePath/$BetaKeyFile" ]; then
-      Error "Beta version key file not found!"
-    fi
-
-    while IFS='' read -r line || [[ -n "$line" ]]; do
-      BetaSignature="$line"
-    done < "$ReleasePath/$BetaKeyFile"
-
-    UpdateFile="${UpdateFile}_${BetaSignature}"
-    SetupFile="tbeta${BetaVersion}_${BetaSignature}.tar.xz"
-  fi
-
-  SymbolsHash=`head -n 1 "$ReleasePath/$BinaryName.sym" | awk -F " " 'END {print $4}'`
-  echo "Copying $BinaryName.sym to $DropboxSymbolsPath/$BinaryName/$SymbolsHash"
-  mkdir -p "$DropboxSymbolsPath/$BinaryName/$SymbolsHash"
-  cp "$ReleasePath/$BinaryName.sym" "$DropboxSymbolsPath/$BinaryName/$SymbolsHash/"
-  echo "Done!"
-
-  if [ ! -d "$ReleasePath/deploy" ]; then
-    mkdir "$ReleasePath/deploy"
-  fi
-
-  if [ ! -d "$ReleasePath/deploy/$AppVersionStrMajor" ]; then
-    mkdir "$ReleasePath/deploy/$AppVersionStrMajor"
-  fi
-
-  echo "Copying $BinaryName, Updater and $UpdateFile to deploy/$AppVersionStrMajor/$AppVersionStrFull..";
-  mkdir "$DeployPath"
-  mkdir "$DeployPath/$BinaryName"
-  mv "$ReleasePath/$BinaryName" "$DeployPath/$BinaryName/"
-  mv "$ReleasePath/Updater" "$DeployPath/$BinaryName/"
-  mv "$ReleasePath/$UpdateFile" "$DeployPath/"
-  if [ "$BetaVersion" != "0" ]; then
-    mv "$ReleasePath/$BetaKeyFile" "$DeployPath/"
-  fi
-  cd "$DeployPath"
-  tar -cJvf "$SetupFile" "$BinaryName/"
-fi
-
-if [ "$BuildTarget" == "mac" ] || [ "$BuildTarget" == "mac32" ] || [ "$BuildTarget" == "macstore" ]; then
-
-  DropboxSymbolsPath="/Volumes/Storage/Dropbox/Telegram/symbols"
-  if [ ! -d "$DropboxSymbolsPath" ]; then
-    Error "Dropbox path not found!"
-  fi
-
-  gyp/refresh.sh
-  xcodebuild -project Telegram.xcodeproj -alltargets -configuration Release build
-
-  if [ ! -d "$ReleasePath/$BinaryName.app" ]; then
-    Error "$BinaryName.app not found!"
-  fi
-
-  if [ ! -d "$ReleasePath/$BinaryName.app.dSYM" ]; then
-    Error "$BinaryName.app.dSYM not found!"
-  fi
-
-  if [ "$BuildTarget" == "mac" ] || [ "$BuildTarget" == "mac32" ]; then
-    if [ ! -f "$ReleasePath/$BinaryName.app/Contents/Frameworks/Updater" ]; then
-      Error "Updater not found!"
-    fi
-    if [ ! -f "$ReleasePath/$BinaryName.app/Contents/Helpers/crashpad_handler" ]; then
-      Error "crashpad_handler not found!"
-    fi
-  fi
-  if [ "$BuildTarget" == "macstore" ]; then
-    if [ ! -d "$ReleasePath/$BinaryName.app/Contents/Frameworks/Breakpad.framework" ]; then
-      Error "Breakpad.framework not found!"
-    fi
-  fi
-
-  echo "Dumping debug symbols.."
-  "$HomePath/../../Libraries/breakpad/src/tools/mac/dump_syms/build/Release/dump_syms" "$ReleasePath/$BinaryName.app.dSYM" > "$ReleasePath/$BinaryName.sym" 2>/dev/null
-  echo "Done!"
-
-  echo "Stripping the executable.."
-  strip "$ReleasePath/$BinaryName.app/Contents/MacOS/$BinaryName"
-  echo "Done!"
-
-  echo "Signing the application.."
-  if [ "$BuildTarget" == "mac" ] || [ "$BuildTarget" == "mac32" ]; then
-    codesign --force --deep --sign "Developer ID Application: John Preston" "$ReleasePath/$BinaryName.app"
-  elif [ "$BuildTarget" == "macstore" ]; then
-    codesign --force --deep --sign "3rd Party Mac Developer Application: TELEGRAM MESSENGER LLP (6N38VWS5BX)" "$ReleasePath/$BinaryName.app" --entitlements "$HomePath/Telegram/Telegram Desktop.entitlements"
-    echo "Making an installer.."
-    productbuild --sign "3rd Party Mac Developer Installer: TELEGRAM MESSENGER LLP (6N38VWS5BX)" --component "$ReleasePath/$BinaryName.app" /Applications "$ReleasePath/$BinaryName.pkg"
-  fi
-  echo "Done!"
-
-  AppUUID=`dwarfdump -u "$ReleasePath/$BinaryName.app/Contents/MacOS/$BinaryName" | awk -F " " '{print $2}'`
-  DsymUUID=`dwarfdump -u "$ReleasePath/$BinaryName.app.dSYM" | awk -F " " '{print $2}'`
-  if [ "$AppUUID" != "$DsymUUID" ]; then
-    Error "UUID of binary '$AppUUID' and dSYM '$DsymUUID' differ!"
-  fi
-
-  if [ ! -f "$ReleasePath/$BinaryName.app/Contents/Resources/Icon.icns" ]; then
-    Error "Icon.icns not found in Resources!"
-  fi
-
-  if [ ! -f "$ReleasePath/$BinaryName.app/Contents/MacOS/$BinaryName" ]; then
-    Error "$BinaryName not found in MacOS!"
-  fi
-
-  if [ ! -d "$ReleasePath/$BinaryName.app/Contents/_CodeSignature" ]; then
-    Error "$BinaryName signature not found!"
-  fi
-
-  if [ "$BuildTarget" == "mac" ] || [ "$BuildTarget" == "mac32" ]; then
-    if [ ! -f "$ReleasePath/$BinaryName.app/Contents/Frameworks/Updater" ]; then
-      Error "Updater not found in Frameworks!"
-    fi
-  elif [ "$BuildTarget" == "macstore" ]; then
-    if [ ! -f "$ReleasePath/$BinaryName.pkg" ]; then
-      Error "$BinaryName.pkg not found!"
-    fi
-  fi
-
-  SymbolsHash=`head -n 1 "$ReleasePath/$BinaryName.sym" | awk -F " " 'END {print $4}'`
-  echo "Copying $BinaryName.sym to $DropboxSymbolsPath/$BinaryName/$SymbolsHash"
-  mkdir -p "$DropboxSymbolsPath/$BinaryName/$SymbolsHash"
-  cp "$ReleasePath/$BinaryName.sym" "$DropboxSymbolsPath/$BinaryName/$SymbolsHash/"
-  echo "Done!"
-
-  if [ "$BuildTarget" == "mac" ] || [ "$BuildTarget" == "mac32" ]; then
-    if [ "$BetaVersion" == "0" ]; then
-      cd "$ReleasePath"
-      cp -f tsetup_template.dmg tsetup.temp.dmg
-      TempDiskPath=`hdiutil attach -nobrowse -noautoopenrw -readwrite tsetup.temp.dmg | awk -F "\t" 'END {print $3}'`
-      cp -R "./$BinaryName.app" "$TempDiskPath/"
-      bless --folder "$TempDiskPath/" --openfolder "$TempDiskPath/"
-      hdiutil detach "$TempDiskPath"
-      hdiutil convert tsetup.temp.dmg -format UDZO -imagekey zlib-level=9 -ov -o "$SetupFile"
-      rm tsetup.temp.dmg
-    fi
-    cd "$ReleasePath"
-    "./Packer" -path "$BinaryName.app" -target "$BuildTarget" -version $VersionForPacker $AlphaBetaParam
-    echo "Packer done!"
-
-    if [ "$BetaVersion" != "0" ]; then
-      if [ ! -f "$ReleasePath/$BetaKeyFile" ]; then
-        Error "Beta version key file not found!"
-      fi
-
-      while IFS='' read -r line || [[ -n "$line" ]]; do
-        BetaSignature="$line"
-      done < "$ReleasePath/$BetaKeyFile"
-
-      UpdateFile="${UpdateFile}_${BetaSignature}"
-      SetupFile="tbeta${BetaVersion}_${BetaSignature}.zip"
-    fi
-  fi
-
-  if [ ! -d "$ReleasePath/deploy" ]; then
-    mkdir "$ReleasePath/deploy"
-  fi
-
-  if [ ! -d "$ReleasePath/deploy/$AppVersionStrMajor" ]; then
-    mkdir "$ReleasePath/deploy/$AppVersionStrMajor"
-  fi
-
-  if [ "$BuildTarget" == "mac" ] || [ "$BuildTarget" == "mac32" ]; then
-    echo "Copying $BinaryName.app and $UpdateFile to deploy/$AppVersionStrMajor/$AppVersionStr..";
-    mkdir "$DeployPath"
-    mkdir "$DeployPath/$BinaryName"
-    cp -r "$ReleasePath/$BinaryName.app" "$DeployPath/$BinaryName/"
-    if [ "$BetaVersion" != "0" ]; then
-      cd "$DeployPath"
-      zip -r "$SetupFile" "$BinaryName"
-      mv "$SetupFile" "$ReleasePath/"
-      mv "$ReleasePath/$BetaKeyFile" "$DeployPath/"
-    fi
-    mv "$ReleasePath/$BinaryName.app.dSYM" "$DeployPath/"
-    rm "$ReleasePath/$BinaryName.app/Contents/MacOS/$BinaryName"
-    rm "$ReleasePath/$BinaryName.app/Contents/Frameworks/Updater"
-    rm "$ReleasePath/$BinaryName.app/Contents/Info.plist"
-    rm -rf "$ReleasePath/$BinaryName.app/Contents/_CodeSignature"
-    mv "$ReleasePath/$UpdateFile" "$DeployPath/"
-    mv "$ReleasePath/$SetupFile" "$DeployPath/"
-
-    if [ "$BuildTarget" == "mac32" ]; then
-      ReleaseToPath="$HomePath/../../tother/tmac32"
-      DeployToPath="$ReleaseToPath/$AppVersionStrMajor/$AppVersionStrFull"
-      if [ ! -d "$ReleaseToPath/$AppVersionStrMajor" ]; then
-        mkdir "$ReleaseToPath/$AppVersionStrMajor"
-      fi
-
-      if [ ! -d "$DeployToPath" ]; then
-        mkdir "$DeployToPath"
-      fi
-
-      cp -v "$DeployPath/$UpdateFile" "$DeployToPath/"
-      cp -v "$DeployPath/$SetupFile" "$DeployToPath/"
-      if [ "$BetaVersion" != "0" ]; then
-        cp -v "$DeployPath/$BetaKeyFile" "$DeployToPath/"
-      fi
-    fi
-  elif [ "$BuildTarget" == "macstore" ]; then
-    echo "Copying $BinaryName.app to deploy/$AppVersionStrMajor/$AppVersionStr..";
-    mkdir "$DeployPath"
-    cp -r "$ReleasePath/$BinaryName.app" "$DeployPath/"
-    mv "$ReleasePath/$BinaryName.pkg" "$DeployPath/"
-    mv "$ReleasePath/$BinaryName.app.dSYM" "$DeployPath/"
-    rm "$ReleasePath/$BinaryName.app/Contents/MacOS/$BinaryName"
-    rm "$ReleasePath/$BinaryName.app/Contents/Info.plist"
-    rm -rf "$ReleasePath/$BinaryName.app/Contents/_CodeSignature"
-  fi
-fi
-
-echo "Version $AppVersionStrFull is ready!";
diff --git a/Telegram/build/deploy.sh b/Telegram/build/deploy.sh
deleted file mode 100755
index 4aac2d49e..000000000
--- a/Telegram/build/deploy.sh
+++ /dev/null
@@ -1,226 +0,0 @@
-set -e
-FullExecPath=$PWD
-pushd `dirname $0` > /dev/null
-FullScriptPath=`pwd`
-popd > /dev/null
-
-if [ ! -d "$FullScriptPath/../../../TelegramPrivate" ]; then
-  echo ""
-  echo "This script is for building the production version of Telegram Desktop."
-  echo ""
-  echo "For building custom versions please visit the build instructions page at:"
-  echo "https://github.com/telegramdesktop/tdesktop/#build-instructions"
-  exit
-fi
-
-Error () {
-  cd $FullExecPath
-  echo "$1"
-  exit 1
-}
-
-DeployTarget="$1"
-
-if [ ! -f "$FullScriptPath/target" ]; then
-  Error "Build target not found!"
-fi
-
-while IFS='' read -r line || [[ -n "$line" ]]; do
-  BuildTarget="$line"
-done < "$FullScriptPath/target"
-
-while IFS='' read -r line || [[ -n "$line" ]]; do
-  set $line
-  eval $1="$2"
-done < "$FullScriptPath/version"
-
-if [ "$BetaVersion" != "0" ]; then
-  AppVersion="$BetaVersion"
-  AppVersionStrFull="${AppVersionStr}_${BetaVersion}"
-  BetaKeyFile="tbeta_${AppVersion}_key"
-elif [ "$AlphaChannel" == "0" ]; then
-  AppVersionStrFull="$AppVersionStr"
-else
-  AppVersionStrFull="$AppVersionStr.alpha"
-fi
-
-echo ""
-HomePath="$FullScriptPath/.."
-if [ "$BuildTarget" == "linux" ]; then
-  echo "Deploying version $AppVersionStrFull for Linux 64bit.."
-  UpdateFile="tlinuxupd$AppVersion"
-  SetupFile="tsetup.$AppVersionStrFull.tar.xz"
-  ReleasePath="$HomePath/../out/Release"
-  RemoteFolder="tlinux"
-elif [ "$BuildTarget" == "linux32" ]; then
-  echo "Deploying version $AppVersionStrFull for Linux 32bit.."
-  UpdateFile="tlinux32upd$AppVersion"
-  SetupFile="tsetup32.$AppVersionStrFull.tar.xz"
-  ReleasePath="$HomePath/../out/Release"
-  RemoteFolder="tlinux32"
-elif [ "$BuildTarget" == "mac" ]; then
-  DeployMac="0"
-  DeployMac32="0"
-  DeployWin="0"
-  if [ "$DeployTarget" == "mac" ]; then
-    DeployMac="1"
-    echo "Deploying version $AppVersionStrFull for OS X 10.8+.."
-  elif [ "$DeployTarget" == "mac32" ]; then
-    DeployMac32="1"
-    echo "Deploying version $AppVersionStrFull for OS X 10.6 and 10.7.."
-  elif [ "$DeployTarget" == "win" ]; then
-    DeployWin="1"
-    echo "Deploying version $AppVersionStrFull for Windows.."
-  else
-    DeployMac="1"
-    if [ "$BetaVersion" != "0" ]; then
-      DeployMac32="0"
-    else
-      DeployMac32="1"
-    fi
-    DeployWin="1"
-    echo "Deploying three versions of $AppVersionStrFull: for Windows, OS X 10.6 and 10.7 and OS X 10.8+.."
-  fi
-  UpdateFile="tmacupd$AppVersion"
-  SetupFile="tsetup.$AppVersionStrFull.dmg"
-  ReleasePath="$HomePath/../out/Release"
-  RemoteFolder="tmac"
-  Mac32DeployPath="$HomePath/../../tother/tmac32/$AppVersionStrMajor/$AppVersionStrFull"
-  Mac32UpdateFile="tmac32upd$AppVersion"
-  Mac32SetupFile="tsetup32.$AppVersionStrFull.dmg"
-  Mac32RemoteFolder="tmac32"
-  WinDeployPath="$HomePath/../../tother/tsetup/$AppVersionStrMajor/$AppVersionStrFull"
-  WinUpdateFile="tupdate$AppVersion"
-  WinSetupFile="tsetup.$AppVersionStrFull.exe"
-  WinPortableFile="tportable.$AppVersionStrFull.zip"
-  WinRemoteFolder="tsetup"
-  BackupPath="/Volumes/Storage/backup/$AppVersionStrMajor/$AppVersionStrFull"
-elif [ "$BuildTarget" == "mac32" ] || [ "$BuildTarget" = "macstore" ]; then
-  Error "No need to deploy this target."
-else
-  Error "Invalid target!"
-fi
-
-DeployPath="$ReleasePath/deploy/$AppVersionStrMajor/$AppVersionStrFull"
-
-if [ "$BetaVersion" != "0" ]; then
-  if [ "$DeployTarget" == "win" ]; then
-    BetaFilePath="$WinDeployPath/$BetaKeyFile"
-  elif [ "$DeployTarget" == "mac32" ]; then
-    BetaFilePath="$Mac32DeployPath/$BetaKeyFile"
-  else
-    BetaFilePath="$DeployPath/$BetaKeyFile"
-  fi
-  if [ ! -f "$BetaFilePath" ]; then
-    Error "Beta key file for $AppVersionStrFull not found :("
-  fi
-
-  while IFS='' read -r line || [[ -n "$line" ]]; do
-    BetaSignature="$line"
-  done < "$BetaFilePath"
-
-  UpdateFile="${UpdateFile}_${BetaSignature}"
-  if [ "$BuildTarget" == "linux" ] || [ "$BuildTarget" == "linux32" ]; then
-    SetupFile="tbeta${BetaVersion}_${BetaSignature}.tar.xz"
-  elif [ "$BuildTarget" == "mac" ]; then
-    SetupFile="tbeta${BetaVersion}_${BetaSignature}.zip"
-    Mac32UpdateFile="${Mac32UpdateFile}_${BetaSignature}"
-    Mac32SetupFile="tbeta${BetaVersion}_${BetaSignature}.zip"
-    WinUpdateFile="${WinUpdateFile}_${BetaSignature}"
-    WinPortableFile="tbeta${BetaVersion}_${BetaSignature}.zip"
-  fi
-elif [ "$BuildTarget" == "linux" ] || [ "$BuildTarget" == "linux32" ]; then
-  BackupPath="/media/psf/backup/$AppVersionStrMajor/$AppVersionStrFull/t$BuildTarget"
-  if [ ! -d "/media/psf/backup" ]; then
-    Error "Backup folder not found!"
-  fi
-fi
-
-#if [ "$BuildTarget" == "linux" ] || [ "$BuildTarget" == "linux32" ] || [ "$BuildTarget" == "mac" ] || [ "$BuildTarget" == "mac32" ] || [ "$BuildTarget" == "macstore" ]; then
-
-  if [ "$BuildTarget" != "mac" ] || [ "$DeployMac" == "1" ]; then
-    if [ ! -f "$DeployPath/$UpdateFile" ]; then
-      Error "$UpdateFile not found!";
-    fi
-
-    if [ ! -f "$DeployPath/$SetupFile" ]; then
-      Error "$SetupFile not found!"
-    fi
-  fi
-
-  if [ "$BuildTarget" == "mac" ]; then
-    if [ "$DeployMac32" == "1" ]; then
-      if [ ! -f "$Mac32DeployPath/$Mac32UpdateFile" ]; then
-        Error "$Mac32UpdateFile not found!"
-      fi
-
-      if [ ! -f "$Mac32DeployPath/$Mac32SetupFile" ]; then
-        Error "$Mac32SetupFile not found!"
-      fi
-    fi
-
-    if [ "$DeployWin" == "1" ]; then
-      if [ ! -f "$WinDeployPath/$WinUpdateFile" ]; then
-        Error "$WinUpdateFile not found!"
-      fi
-
-      if [ "$BetaVersion" == "0" ]; then
-        if [ ! -f "$WinDeployPath/$WinSetupFile" ]; then
-          Error "$WinSetupFile not found!"
-        fi
-      fi
-
-      if [ ! -f "$WinDeployPath/$WinPortableFile" ]; then
-        Error "$WinPortableFile not found!"
-      fi
-    fi
-  fi
-#fi
-
-if [ "$BuildTarget" == "linux" ] || [ "$BuildTarget" == "linux32" ] || [ "$BuildTarget" == "mac" ]; then
-  if [ "$BuildTarget" != "mac" ] || [ "$DeployMac" == "1" ]; then
-    rsync -av --progress "$DeployPath/$UpdateFile" "$DeployPath/$SetupFile" "tmaster:tdesktop/www/$RemoteFolder/"
-  fi
-  if [ "$BuildTarget" == "linux" ] || [ "$BuildTarget" == "linux32" ]; then
-    if [ "$BetaVersion" == "0" ]; then
-      mkdir -p "$BackupPath"
-      cp "$DeployPath/$SetupFile" "$BackupPath"
-    fi
-  fi
-  if [ "$BuildTarget" == "mac" ]; then
-    if [ "$DeployMac32" == "1" ]; then
-      rsync -av --progress "$Mac32DeployPath/$Mac32UpdateFile" "$Mac32DeployPath/$Mac32SetupFile" "tmaster:tdesktop/www/$Mac32RemoteFolder/"
-    fi
-    if [ "$DeployWin" == "1" ]; then
-      if [ "$BetaVersion" == "0" ]; then
-        rsync -av --progress "$WinDeployPath/$WinUpdateFile" "$WinDeployPath/$WinSetupFile" "$WinDeployPath/$WinPortableFile" "tmaster:tdesktop/www/$WinRemoteFolder/"
-      else
-        rsync -av --progress "$WinDeployPath/$WinUpdateFile" "$WinDeployPath/$WinPortableFile" "tmaster:tdesktop/www/$WinRemoteFolder/"
-      fi
-    fi
-
-    if [ "$DeployMac" == "1" ]; then
-      if [ "$BetaVersion" == "0" ]; then
-        mkdir -p "$BackupPath/tmac"
-        mv -v "$DeployPath/$SetupFile" "$BackupPath/tmac/"
-      fi
-    fi
-    if [ "$DeployMac32" == "1" ]; then
-      if [ "$BetaVersion" == "0" ]; then
-        mkdir -p "$BackupPath/tmac32"
-        mv -v "$Mac32DeployPath/$Mac32SetupFile" "$BackupPath/tmac32/"
-      fi
-    fi
-    if [ "$DeployWin" == "1" ]; then
-      if [ "$BetaVersion" == "0" ]; then
-        mkdir -p "$BackupPath/tsetup"
-        mv -v "$WinDeployPath/$WinSetupFile" "$BackupPath/tsetup/"
-        mv -v "$WinDeployPath/$WinPortableFile" "$BackupPath/tsetup/"
-      fi
-    fi
-  fi
-fi
-
-echo "Version $AppVersionStrFull was deployed!"
-cd $FullExecPath
-
diff --git a/Telegram/build/release.py b/Telegram/build/release.py
deleted file mode 100644
index eaa37ab99..000000000
--- a/Telegram/build/release.py
+++ /dev/null
@@ -1,256 +0,0 @@
-import os, sys, requests, pprint, re, json
-from uritemplate import URITemplate, expand
-from subprocess import call
-
-changelog_file = '../../changelog.txt'
-token_file = '../../../TelegramPrivate/github-releases-token.txt'
-
-version = ''
-commit = ''
-for arg in sys.argv:
-  if re.match(r'\d+\.\d+', arg):
-    version = arg
-  elif re.match(r'^[a-f0-9]{40}$', arg):
-    commit = arg
-
-# thanks http://stackoverflow.com/questions/13909900/progress-of-python-requests-post
-class upload_in_chunks(object):
-  def __init__(self, filename, chunksize=1 << 13):
-    self.filename = filename
-    self.chunksize = chunksize
-    self.totalsize = os.path.getsize(filename)
-    self.readsofar = 0
-
-  def __iter__(self):
-    with open(self.filename, 'rb') as file:
-      while True:
-        data = file.read(self.chunksize)
-        if not data:
-          sys.stderr.write("\n")
-          break
-        self.readsofar += len(data)
-        percent = self.readsofar * 1e2 / self.totalsize
-        sys.stderr.write("\r{percent:3.0f}%".format(percent=percent))
-        yield data
-
-  def __len__(self):
-    return self.totalsize
-
-class IterableToFileAdapter(object):
-  def __init__(self, iterable):
-    self.iterator = iter(iterable)
-    self.length = len(iterable)
-
-  def read(self, size=-1): # TBD: add buffer for `len(data) > size` case
-    return next(self.iterator, b'')
-
-  def __len__(self):
-    return self.length
-
-def checkResponseCode(result, right_code):
-  if (result.status_code != right_code):
-    print('Wrong result code: ' + str(result.status_code) + ', should be ' + str(right_code))
-    sys.exit(1)
-
-pp = pprint.PrettyPrinter(indent=2)
-url = 'https://api.github.com/'
-
-version_parts = version.split('.')
-
-stable = 1
-alpha = 0
-dev = 0
-
-if len(version_parts) < 2:
-  print('Error: expected at least major version ' + version)
-  sys.exit(1)
-if len(version_parts) > 4:
-  print('Error: bad version passed ' + version)
-  sys.exit(1)
-version_major = version_parts[0] + '.' + version_parts[1]
-if len(version_parts) == 2:
-  version = version_major + '.0'
-  version_full = version
-else:
-  version = version_major + '.' + version_parts[2]
-  version_full = version
-  if len(version_parts) == 4:
-    if version_parts[3] == 'dev':
-      dev = 1
-      stable = 0
-      version_full = version + '.dev'
-    elif version_parts[3] == 'alpha':
-      alpha = 1
-      stable = 0
-      version_full = version + '.alpha'
-    else:
-      print('Error: unexpected version part ' + version_parts[3])
-      sys.exit(1)
-
-access_token = ''
-if os.path.isfile(token_file):
-  with open(token_file) as f:
-    for line in f:
-      access_token = line.replace('\n', '')
-
-if access_token == '':
-  print('Access token not found!')
-  sys.exit(1)
-
-print('Version: ' + version_full);
-local_folder = '/Volumes/Storage/backup/' + version_major + '/' + version_full
-
-if stable == 1:
-  if os.path.isdir(local_folder + '.dev'):
-    dev = 1
-    stable = 0
-    version_full = version + '.dev'
-    local_folder = local_folder + '.dev'
-  elif os.path.isdir(local_folder + '.alpha'):
-    alpha = 1
-    stable = 0
-    version_full = version + '.alpha'
-    local_folder = local_folder + '.alpha'
-
-if not os.path.isdir(local_folder):
-  print('Storage path not found!')
-  sys.exit(1)
-
-local_folder = local_folder + '/'
-
-files = []
-files.append({
-  'local': 'tsetup.' + version_full + '.exe',
-  'remote': 'tsetup.' + version_full + '.exe',
-  'backup_folder': 'tsetup',
-  'mime': 'application/octet-stream',
-  'label': 'Windows: Installer',
-})
-files.append({
-  'local': 'tportable.' + version_full + '.zip',
-  'remote': 'tportable.' + version_full + '.zip',
-  'backup_folder': 'tsetup',
-  'mime': 'application/zip',
-  'label': 'Windows: Portable',
-})
-files.append({
-  'local': 'tsetup.' + version_full + '.dmg',
-  'remote': 'tsetup.' + version_full + '.dmg',
-  'backup_folder': 'tmac',
-  'mime': 'application/octet-stream',
-  'label': 'macOS and OS X 10.8+: Installer',
-})
-files.append({
-  'local': 'tsetup32.' + version_full + '.dmg',
-  'remote': 'tsetup32.' + version_full + '.dmg',
-  'backup_folder': 'tmac32',
-  'mime': 'application/octet-stream',
-  'label': 'OS X 10.6 and 10.7: Installer',
-})
-files.append({
-  'local': 'tsetup.' + version_full + '.tar.xz',
-  'remote': 'tsetup.' + version_full + '.tar.xz',
-  'backup_folder': 'tlinux',
-  'mime': 'application/octet-stream',
-  'label': 'Linux 64 bit: Binary',
-})
-files.append({
-  'local': 'tsetup32.' + version_full + '.tar.xz',
-  'remote': 'tsetup32.' + version_full + '.tar.xz',
-  'backup_folder': 'tlinux32',
-  'mime': 'application/octet-stream',
-  'label': 'Linux 32 bit: Binary',
-})
-
-r = requests.get(url + 'repos/telegramdesktop/tdesktop/releases/tags/v' + version)
-if r.status_code == 404:
-  print('Release not found, creating.')
-  if commit == '':
-    print('Error: specify the commit.')
-    sys.exit(1)
-  if not os.path.isfile(changelog_file):
-    print('Error: Changelog file not found.')
-    sys.exit(1)
-  changelog = ''
-  started = 0
-  with open(changelog_file) as f:
-    for line in f:
-      if started == 1:
-        if re.match(r'^\d+\.\d+', line):
-          break;
-        if re.match(r'^\s+$', line):
-          continue
-        changelog += line
-      else:
-        if re.match(r'^\d+\.\d+', line):
-          if line[0:len(version) + 1] == version + ' ':
-            started = 1
-          elif line[0:len(version_major) + 1] == version_major + ' ':
-            if version_major + '.0' == version:
-              started = 1
-  if started != 1:
-    print('Error: Changelog not found.')
-    sys.exit(1)
-
-  changelog = changelog.strip()
-  print('Changelog: ');
-  print(changelog);
-
-  r = requests.post(url + 'repos/telegramdesktop/tdesktop/releases', headers={'Authorization': 'token ' + access_token}, data=json.dumps({
-    'tag_name': 'v' + version,
-    'target_commitish': commit,
-    'name': 'v ' + version,
-    'body': changelog,
-    'prerelease': (dev == 1 or alpha == 1),
-  }))
-  checkResponseCode(r, 201)
-
-r = requests.get(url + 'repos/telegramdesktop/tdesktop/releases/tags/v' + version)
-checkResponseCode(r, 200);
-
-release_data = r.json()
-#pp.pprint(release_data)
-
-release_id = release_data['id']
-print('Release ID: ' + str(release_id))
-
-r = requests.get(url + 'repos/telegramdesktop/tdesktop/releases/' + str(release_id) + '/assets');
-checkResponseCode(r, 200);
-
-assets = release_data['assets']
-for asset in assets:
-  name = asset['name']
-  found = 0
-  for file in files:
-    if file['remote'] == name:
-      print('Already uploaded: ' + name)
-      file['already'] = 1
-      found = 1
-      break
-  if found == 0:
-    print('Warning: strange asset: ' + name)
-
-for file in files:
-  if 'already' in file:
-    continue
-  file_path = local_folder + file['backup_folder'] + '/' + file['local']
-  if not os.path.isfile(file_path):
-    print('Warning: file not found ' + file['local'])
-    continue
-
-  upload_url = expand(release_data['upload_url'], {'name': file['remote'], 'label': file['label']}) + '&access_token=' + access_token;
-
-  content = upload_in_chunks(file_path, 10)
-
-  print('Uploading: ' + file['remote'] + ' (' + str(round(len(content) / 10000) / 100.) + ' MB)')
-  r = requests.post(upload_url, headers={"Content-Type": file['mime']}, data=IterableToFileAdapter(content))
-
-  checkResponseCode(r, 201)
-
-  print('Success! Removing.')
-  return_code = call(["rm", file_path])
-  if return_code != 0:
-    print('Bad rm code: ' + str(return_code))
-    sys.exit(1)
-
-sys.exit()
diff --git a/Telegram/build/release.sh b/Telegram/build/release.sh
deleted file mode 100755
index abbacfb90..000000000
--- a/Telegram/build/release.sh
+++ /dev/null
@@ -1,44 +0,0 @@
-set -e
-FullExecPath=$PWD
-pushd `dirname $0` > /dev/null
-FullScriptPath=`pwd`
-popd > /dev/null
-
-Param1="$1"
-Param2="$2"
-Param3="$3"
-Param4="$4"
-
-if [ ! -d "$FullScriptPath/../../../TelegramPrivate" ]; then
-  echo ""
-  echo "This script is for building the production version of Telegram Desktop."
-  echo ""
-  echo "For building custom versions please visit the build instructions page at:"
-  echo "https://github.com/telegramdesktop/tdesktop/#build-instructions"
-  exit
-fi
-
-Error () {
-  cd $FullExecPath
-  echo "$1"
-  exit 1
-}
-
-while IFS='' read -r line || [[ -n "$line" ]]; do
-  set $line
-  eval $1="$2"
-done < "$FullScriptPath/version"
-
-VersionForPacker="$AppVersion"
-if [ "$BetaVersion" != "0" ]; then
-  Error "No releases for closed beta versions"
-elif [ "$AlphaChannel" == "0" ]; then
-  AppVersionStrFull="$AppVersionStr"
-  AlphaBetaParam=''
-else
-  AppVersionStrFull="$AppVersionStr.alpha"
-  AlphaBetaParam='-alpha'
-fi
-
-cd "$FullScriptPath"
-python release.py $AppVersionStr $Param1 $Param2 $Param3 $Param4
diff --git a/Telegram/build/replace.vbs b/Telegram/build/replace.vbs
deleted file mode 100644
index 5b23ab8ee..000000000
--- a/Telegram/build/replace.vbs
+++ /dev/null
@@ -1,35 +0,0 @@
-Dim action, pat, patparts, rxp, inp, matchCount
-action = WScript.Arguments(0)
-pat = WScript.Arguments(1)
-pat = Replace(pat, "&quot;", chr(34))
-pat = Replace(pat, "&hat;", "^")
-pat = Replace(pat, "&amp;", "&")
-
-Set rxp = new RegExp
-rxp.Global = True
-rxp.Multiline = False
-If action = "Replace" Then
-  patparts = Split(pat, "/")
-  rxp.Pattern = patparts(0)
-Else
-  rxp.Pattern = pat
-End If
-
-matchCount = 0
-Do While Not WScript.StdIn.AtEndOfStream
-  inp = WScript.StdIn.ReadLine()
-  If rxp.Test(inp) Then
-    matchCount = matchCount + 1
-  End If
-  If action = "Replace" Then
-    WScript.Echo rxp.Replace(inp, patparts(1))
-  End If
-Loop
-
-If action = "Replace" Then
-  If matchCount = 0 Then
-    WScript.Quit(2)
-  End If
-Else
-  WScript.Echo matchCount
-End If
diff --git a/Telegram/build/set_version.bat b/Telegram/build/set_version.bat
deleted file mode 100644
index 4b448ebce..000000000
--- a/Telegram/build/set_version.bat
+++ /dev/null
@@ -1,166 +0,0 @@
-@echo OFF
-setlocal enabledelayedexpansion
-set "FullScriptPath=%~dp0"
-
-set "InputVersion=%1"
-
-for /F "tokens=1,2,3,4 delims=. " %%a in ("%InputVersion%") do (
-  set "VersionMajor=%%a"
-  set "VersionMinor=%%b"
-  set "VersionPatch=%%c"
-  if "%%d" == "" (
-    set "VersionBeta=0"
-    set "VersionAlpha=0"
-  ) else if "%%d" == "alpha" (
-    set "VersionBeta=0"
-    set "VersionAlpha=1"
-  ) else (
-    set "VersionBeta=%%d"
-    set "VersionAlpha=0"
-  )
-)
-
-set /a "VersionMajorCleared=%VersionMajor% %% 1000"
-if "%VersionMajorCleared%" neq "%VersionMajor%" (
-  echo Bad major version!
-  exit /b 1
-)
-set /a "VersionMinorCleared=%VersionMinor% %% 1000"
-if "%VersionMinorCleared%" neq "%VersionMinor%" (
-  echo Bad minor version!
-  exit /b 1
-)
-set /a "VersionPatchCleared=%VersionPatch% %% 1000"
-if "%VersionPatchCleared%" neq "%VersionPatch%" (
-  echo Bad patch version!
-  exit /b 1
-)
-if "%VersionAlpha%" neq "0" (
-  if "%VersionAlpha%" neq "1" (
-    echo Bad alpha version!
-    exit /b 1
-  )
-  set "VersionAlphaBool=true"
-) else (
-  set "VersionAlphaBool=false"
-)
-
-set /a "VersionFull=%VersionMajor% * 1000000 + %VersionMinor% * 1000 + %VersionPatch%"
-if "%VersionBeta%" neq "0" (
-  set /a "VersionBetaCleared=%VersionBeta% %% 1000"
-  if "!VersionBetaCleared!" neq "%VersionBeta%" (
-    echo Bad beta version!
-    exit /b 1
-  )
-  set /a "VersionBetaMul=1000 + %VersionBeta%"
-  set "VersionFullBeta=%VersionFull%!VersionBetaMul:~1!"
-) else (
-  set "VersionFullBeta=0"
-)
-
-set "VersionStr=%VersionMajor%.%VersionMinor%.%VersionPatch%"
-if "%VersionPatch%" neq "0" (
-  set "VersionStrSmall=%VersionStr%"
-) else (
-  set "VersionStrSmall=%VersionMajor%.%VersionMinor%"
-)
-
-if "%VersionAlpha%" neq "0" (
-  echo Setting version: %VersionStr% alpha
-) else if "%VersionBeta%" neq "0" (
-  echo Setting version: %VersionStr%.%VersionBeta% closed beta
-) else (
-  echo Setting version: %VersionStr% stable
-)
-
-echo Checking changelog...
-set "ChangelogFile=%FullScriptPath%..\..\changelog.txt"
-call :count "Argument=^%VersionStr% " "Filename=%ChangelogFile%"
-if "%FoundCount%" equ "0" (
-  call :count "Argument=^%VersionStrSmall% " "Filename=%ChangelogFile%"
-  if "!FoundCount!" equ "0" (
-    echo Changelog entry not found!
-    exit /b 1
-  ) else if "!FoundCount!" neq "1" (
-    echo Wrong changelog entries count found: %FoundCount%
-    exit /b 1
-  )
-) else if "%FoundCount%" neq "1" (
-  echo Wrong changelog entries count found: %FoundCount%
-  exit /b 1
-)
-
-echo Patching build/version...
-set "VersionFilePath=%FullScriptPath%version"
-call :repl "Argument=(AppVersion) (\s*)\d+/$1$2 %VersionFull%" "Filename=%VersionFilePath%" || goto :error
-call :repl "Argument=(AppVersionStrMajor) (\s*)[\d\.]+/$1$2 %VersionMajor%.%VersionMinor%" "Filename=%VersionFilePath%" || goto :error
-call :repl "Argument=(AppVersionStrSmall) (\s*)[\d\.]+/$1$2 %VersionStrSmall%" "Filename=%VersionFilePath%" || goto :error
-call :repl "Argument=(AppVersionStr) (\s*)[\d\.]+/$1$2 %VersionStr%" "Filename=%VersionFilePath%" || goto :error
-call :repl "Argument=(AlphaChannel) (\s*)[\d\.]+/$1$2 %VersionAlpha%" "Filename=%VersionFilePath%" || goto :error
-call :repl "Argument=(BetaVersion) (\s*)\d+/$1$2 %VersionFullBeta%" "Filename=%VersionFilePath%" || goto :error
-
-echo Patching core/version.h...
-set "VersionHeaderPath=%FullScriptPath%..\SourceFiles\core\version.h"
-call :repl "Argument=(BETA_VERSION_MACRO\s+)\(\d+ULL\)/$1(%VersionFullBeta%ULL)" "Filename=%VersionHeaderPath%" || goto :error
-call :repl "Argument=(AppVersion\s+=) (\s*)\d+/$1$2 %VersionFull%" "Filename=%VersionHeaderPath%" || goto :error
-call :repl "Argument=(AppVersionStr\s+=) (\s*)[&hat;;]+/$1$2 &quot;%VersionStrSmall%&quot;" "Filename=%VersionHeaderPath%" || goto :error
-call :repl "Argument=(AppAlphaVersion\s+=) (\s*)[a-z]+/$1$2 %VersionAlphaBool%" "Filename=%VersionHeaderPath%" || goto :error
-
-echo Patching Telegram.rc...
-set "ResourcePath=%FullScriptPath%..\Resources\winrc\Telegram.rc"
-call :repl "Argument=(FILEVERSION) (\s*)\d+,\d+,\d+,\d+/$1$2 %VersionMajor%,%VersionMinor%,%VersionPatch%,%VersionBeta%" "Filename=%ResourcePath%" || goto :error
-call :repl "Argument=(PRODUCTVERSION) (\s*)\d+,\d+,\d+,\d+/$1$2 %VersionMajor%,%VersionMinor%,%VersionPatch%,%VersionBeta%" "Filename=%ResourcePath%" || goto :error
-call :repl "Argument=(&quot;FileVersion&quot;,) (\s*)&quot;\d+.\d+.\d+.\d+&quot;/$1$2 &quot;%VersionMajor%.%VersionMinor%.%VersionPatch%.%VersionBeta%&quot;" "Filename=%ResourcePath%" || goto :error
-call :repl "Argument=(&quot;ProductVersion&quot;,) (\s*)&quot;\d+.\d+.\d+.\d+&quot;/$1$2 &quot;%VersionMajor%.%VersionMinor%.%VersionPatch%.%VersionBeta%&quot;" "Filename=%ResourcePath%" || goto :error
-
-echo Patching Updater.rc...
-set "ResourcePath=%FullScriptPath%..\Resources\winrc\Updater.rc"
-call :repl "Argument=(FILEVERSION) (\s*)\d+,\d+,\d+,\d+/$1$2 %VersionMajor%,%VersionMinor%,%VersionPatch%,%VersionBeta%" "Filename=%ResourcePath%" || goto :error
-call :repl "Argument=(PRODUCTVERSION) (\s*)\d+,\d+,\d+,\d+/$1$2 %VersionMajor%,%VersionMinor%,%VersionPatch%,%VersionBeta%" "Filename=%ResourcePath%" || goto :error
-call :repl "Argument=(&quot;FileVersion&quot;,) (\s*)&quot;\d+.\d+.\d+.\d+&quot;/$1$2 &quot;%VersionMajor%.%VersionMinor%.%VersionPatch%.%VersionBeta%&quot;" "Filename=%ResourcePath%" || goto :error
-call :repl "Argument=(&quot;ProductVersion&quot;,) (\s*)&quot;\d+.\d+.\d+.\d+&quot;/$1$2 &quot;%VersionMajor%.%VersionMinor%.%VersionPatch%.%VersionBeta%&quot;" "Filename=%ResourcePath%" || goto :error
-
-echo Patching appxmanifest.xml...
-set "ResourcePath=%FullScriptPath%..\Resources\uwp\AppX\AppxManifest.xml"
-call :repl "Argument= (Version=)&quot;\d+.\d+.\d+.\d+&quot;/ $1&quot;%VersionMajor%.%VersionMinor%.%VersionPatch%.%VersionBeta%&quot;" "Filename=%ResourcePath%" || goto :error
-
-exit /b
-
-:error
-(
-  set ErrorCode=%errorlevel%
-  echo Error !ErrorCode!
-  exit /b !ErrorCode!
-)
-
-:repl
-(
-  set %1
-  set %2
-  set "TempFilename=!Filename!__tmp__"
-  cscript //Nologo "%FullScriptPath%replace.vbs" "Replace" "!Argument!" < "!Filename!" > "!TempFilename!" || goto :repl_finish
-  xcopy /Y !TempFilename! !Filename! >NUL || goto :repl_finish
-  goto :repl_finish
-)
-
-:count
-(
-  set %1
-  set %2
-  set "TempFilename=!Filename!__tmp__"
-  cscript //Nologo "%FullScriptPath%replace.vbs" "Count" "!Argument!" < "!Filename!" > "!TempFilename!" || goto :repl_finish
-  FOR /F "tokens=1,2* delims= " %%i in (!TempFilename!) do set "FoundCount=%%i"
-  goto :repl_finish
-)
-
-:repl_finish
-(
-  set ErrorCode=%errorlevel%
-  if !ErrorCode! neq 0 (
-    echo Replace error !ErrorCode!
-    echo While replacing "%Replace%"
-    echo In file "%Filename%"
-  )
-  del %TempFilename%
-  exit /b !ErrorCode!
-)
diff --git a/Telegram/build/set_version.sh b/Telegram/build/set_version.sh
deleted file mode 100755
index f251764cc..000000000
--- a/Telegram/build/set_version.sh
+++ /dev/null
@@ -1,145 +0,0 @@
-set -e
-pushd `dirname $0` > /dev/null
-FullScriptPath=`pwd`
-popd > /dev/null
-
-Error () {
-  echo "$1"
-  exit 1
-}
-
-InputVersion="$1"
-
-IFS='.' read -ra VersionParts <<< "$InputVersion"
-VersionMajor="${VersionParts[0]}"
-VersionMinor="${VersionParts[1]}"
-VersionPatch="${VersionParts[2]}"
-if [ "${VersionParts[3]}" == "" ]; then
-  VersionBeta=0
-  VersionAlpha=0
-elif [ "${VersionParts[3]}" == "alpha" ]; then
-  VersionBeta=0
-  VersionAlpha=1
-else
-  VersionBeta="${VersionParts[3]}"
-  VersionAlpha=0
-fi
-
-VersionMajorCleared=`echo "$VersionMajor % 1000" | bc`
-if [ "$VersionMajorCleared" != "$VersionMajor" ]; then
-  Error "Bad major version!"
-fi
-VersionMinorCleared=`echo "$VersionMinor % 1000" | bc`
-if [ "$VersionMinorCleared" != "$VersionMinor" ]; then
-  Error "Bad minor version!"
-fi
-VersionPatchCleared=`echo "$VersionPatch % 1000" | bc`
-if [ "$VersionPatchCleared" != "$VersionPatch" ]; then
-  Error "Bad patch version!"
-fi
-if [ "$VersionAlpha" != "0" ]; then
-  if [ "$VersionAlpha" != "1" ]; then
-    Error "Bad alpha version!"
-  fi
-  VersionAlphaBool=true
-else
-  VersionAlphaBool=false
-fi
-
-VersionFull=`echo "$VersionMajor * 1000000 + $VersionMinor * 1000 + $VersionPatch" | bc`
-if [ "$VersionBeta" != "0" ]; then
-  VersionBetaCleared=`echo "$VersionBeta % 1000" | bc`
-  if [ "$VersionBetaCleared" != "$VersionBeta" ]; then
-    Error "Bad beta version!"
-  fi
-  VersionBetaMul=`echo "$VersionBeta + 1000" | bc`
-  VersionFullBeta="$VersionFull${VersionBetaMul:1}"
-else
-  VersionFullBeta=0
-fi
-
-VersionStr="$VersionMajor.$VersionMinor.$VersionPatch"
-if [ "$VersionPatch" != "0" ]; then
-  VersionStrSmall="$VersionStr"
-else
-  VersionStrSmall="$VersionMajor.$VersionMinor"
-fi
-
-if [ "$VersionAlpha" != "0" ]; then
-  echo "Setting version: $VersionStr alpha"
-elif [ "$VersionBeta" != "0" ]; then
-  echo "Setting version: $VersionStr.$VersionBeta closed beta"
-else
-  echo "Setting version: $VersionStr stable"
-fi
-
-repl () {
-  Pattern="$1"
-  Replacement="$2"
-  File="$3"
-  CheckCommand="grep -sc '$Pattern' $File"
-  set +e
-  CheckCount=`eval $CheckCommand`
-  set -e
-  if [ "$CheckCount" -gt 0 ]; then
-    ReplaceCommand="sed -i'.~' 's/$Pattern/$Replacement/g' $File"
-    eval $ReplaceCommand
-  else
-    echo "Not found $Pattern"
-    Error "While processing $File"
-  fi
-}
-
-echo "Checking changelog..."
-ChangelogFile="$FullScriptPath/../../changelog.txt"
-ChangelogCommand="grep -sc '^$VersionStr ' $ChangelogFile"
-set +e
-FoundCount=`eval $ChangelogCommand`
-set -e
-if [ "$FoundCount" == "0" ]; then
-  ChangelogCommand="grep -sc '^$VersionStrSmall ' $ChangelogFile"
-  set +e
-  FoundCount=`eval $ChangelogCommand`
-  set -e
-  if [ "$FoundCount" == "0" ]; then
-    Error "Changelog entry not found!"
-  elif [ "$FoundCount" != "1" ]; then
-    Error "Wrong changelog entries count found: $FoundCount"
-  fi
-elif [ "$FoundCount" != "1" ]; then
-  Error "Wrong changelog entries count found: $FoundCount"
-fi
-
-echo "Patching build/version..."
-VersionFilePath="$FullScriptPath/version"
-repl "\(AppVersion\) \([ ]*\)[0-9][0-9]*" "\1\2 $VersionFull" "$VersionFilePath"
-repl "\(AppVersionStrMajor\) \([ ]*\)[0-9][0-9\.]*" "\1\2 $VersionMajor.$VersionMinor" "$VersionFilePath"
-repl "\(AppVersionStrSmall\) \([ ]*\)[0-9][0-9\.]*" "\1\2 $VersionStrSmall" "$VersionFilePath"
-repl "\(AppVersionStr\) \([ ]*\)[0-9][0-9\.]*" "\1\2 $VersionStr" "$VersionFilePath"
-repl "\(AlphaChannel\) \([ ]*\)[0-9][0-9]*" "\1\2 $VersionAlpha" "$VersionFilePath"
-repl "\(BetaVersion\) \([ ]*\)[0-9][0-9]*" "\1\2 $VersionFullBeta" "$VersionFilePath"
-
-echo "Patching core/version.h..."
-VersionHeaderPath="$FullScriptPath/../SourceFiles/core/version.h"
-repl "\(BETA_VERSION_MACRO [ ]*\)([0-9][0-9]*ULL)" "\1(${VersionFullBeta}ULL)" "$VersionHeaderPath"
-repl "\(AppVersion [ ]*=\) \([ ]*\)[0-9][0-9]*" "\1\2 $VersionFull" "$VersionHeaderPath"
-repl "\(AppVersionStr [ ]*=\) \([ ]*\)[^;][^;]*" "\1\2 \"$VersionStrSmall\"" "$VersionHeaderPath"
-repl "\(AppAlphaVersion [ ]*=\) \([ ]*\)[a-z][a-z]*" "\1\2 $VersionAlphaBool" "$VersionHeaderPath"
-
-echo "Patching Telegram.rc..."
-ResourcePath="$FullScriptPath/../Resources/winrc/Telegram.rc"
-repl "\(FILEVERSION\) \([ ]*\)[0-9][0-9]*,[0-9][0-9]*,[0-9][0-9]*,[0-9][0-9]*" "\1\2 $VersionMajor,$VersionMinor,$VersionPatch,$VersionBeta" "$ResourcePath"
-repl "\(PRODUCTVERSION\) \([ ]*\)[0-9][0-9]*,[0-9][0-9]*,[0-9][0-9]*,[0-9][0-9]*" "\1\2 $VersionMajor,$VersionMinor,$VersionPatch,$VersionBeta" "$ResourcePath"
-repl "\(\"FileVersion\",\) \([ ]*\)\"[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\"" "\1\2 \"$VersionMajor.$VersionMinor.$VersionPatch.$VersionBeta\"" "$ResourcePath"
-repl "\(\"ProductVersion\",\) \([ ]*\)\"[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\"" "\1\2 \"$VersionMajor.$VersionMinor.$VersionPatch.$VersionBeta\"" "$ResourcePath"
-
-echo "Patching Updater.rc..."
-ResourcePath="$FullScriptPath/../Resources/winrc/Updater.rc"
-repl "\(FILEVERSION\) \([ ]*\)[0-9][0-9]*,[0-9][0-9]*,[0-9][0-9]*,[0-9][0-9]*" "\1\2 $VersionMajor,$VersionMinor,$VersionPatch,$VersionBeta" "$ResourcePath"
-repl "\(PRODUCTVERSION\) \([ ]*\)[0-9][0-9]*,[0-9][0-9]*,[0-9][0-9]*,[0-9][0-9]*" "\1\2 $VersionMajor,$VersionMinor,$VersionPatch,$VersionBeta" "$ResourcePath"
-repl "\(\"FileVersion\",\) \([ ]*\)\"[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\"" "\1\2 \"$VersionMajor.$VersionMinor.$VersionPatch.$VersionBeta\"" "$ResourcePath"
-repl "\(\"ProductVersion\",\) \([ ]*\)\"[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\"" "\1\2 \"$VersionMajor.$VersionMinor.$VersionPatch.$VersionBeta\"" "$ResourcePath"
-
-echo "Patching appxmanifest.xml..."
-ResourcePath="$FullScriptPath/../Resources/uwp/AppX/AppxManifest.xml"
-repl " \(Version=\)\"[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*\"" " \1\"$VersionMajor.$VersionMinor.$VersionPatch.$VersionBeta\"" "$ResourcePath"
diff --git a/Telegram/build/setup.iss b/Telegram/build/setup.iss
deleted file mode 100644
index 78faee5a4..000000000
--- a/Telegram/build/setup.iss
+++ /dev/null
@@ -1,119 +0,0 @@
-#define MyAppShortName "Telegram"
-#define MyAppName "Telegram Desktop"
-#define MyAppPublisher "Telegram Messenger LLP"
-#define MyAppURL "https://tdesktop.com"
-#define MyAppExeName "Telegram.exe"
-#define MyAppId "53F49750-6209-4FBF-9CA8-7A333C87D1ED"
-
-[Setup]
-; NOTE: The value of AppId uniquely identifies this application.
-; Do not use the same AppId value in installers for other applications.
-; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
-AppId={{{#MyAppId}}
-AppName={#MyAppName}
-AppVersion={#MyAppVersion}
-AppPublisher={#MyAppPublisher}
-AppPublisherURL={#MyAppURL}
-AppSupportURL={#MyAppURL}
-AppUpdatesURL={#MyAppURL}
-DefaultDirName={userappdata}\{#MyAppName}
-DefaultGroupName={#MyAppName}
-AllowNoIcons=yes
-OutputDir={#ReleasePath}
-OutputBaseFilename=tsetup.{#MyAppVersionFull}
-SetupIconFile={#SourcePath}..\Resources\art\icon256.ico
-UninstallDisplayIcon={app}\Telegram.exe
-Compression=lzma
-SolidCompression=yes
-DisableStartupPrompt=yes
-PrivilegesRequired=lowest
-VersionInfoVersion={#MyAppVersion}.0
-CloseApplications=force
-DisableDirPage=no
-DisableProgramGroupPage=no
-
-[Languages]
-Name: "english"; MessagesFile: "compiler:Default.isl"
-Name: "it"; MessagesFile: "compiler:Languages\Italian.isl"
-Name: "es"; MessagesFile: "compiler:Languages\Spanish.isl"
-Name: "de"; MessagesFile: "compiler:Languages\German.isl"
-Name: "nl"; MessagesFile: "compiler:Languages\Dutch.isl"
-Name: "pt_BR"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl"
-
-[Tasks]
-Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"
-Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; OnlyBelowVersion: 0,6.1
-
-[Files]
-Source: "{#ReleasePath}\Telegram.exe"; DestDir: "{app}"; Flags: ignoreversion
-Source: "{#ReleasePath}\Updater.exe"; DestDir: "{app}"; Flags: ignoreversion
-; NOTE: Don't use "Flags: ignoreversion" on any shared system files
-
-[Icons]
-Name: "{group}\{#MyAppShortName}"; Filename: "{app}\{#MyAppExeName}"
-Name: "{group}\{cm:UninstallProgram,{#MyAppShortName}}"; Filename: "{uninstallexe}"
-Name: "{userdesktop}\{#MyAppShortName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
-Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppShortName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
-
-[Run]
-Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppShortName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
-
-[UninstallDelete]
-Type: files; Name: "{app}\data"
-Type: files; Name: "{app}\data_config"
-Type: files; Name: "{app}\log.txt"
-Type: filesandordirs; Name: "{app}\DebugLogs"
-Type: filesandordirs; Name: "{app}\tupdates"
-Type: filesandordirs; Name: "{app}\tdata"
-Type: filesandordirs; Name: "{app}\tcache"
-Type: filesandordirs; Name: "{app}\tdumps"
-Type: dirifempty; Name: "{app}"
-Type: files; Name: "{userappdata}\{#MyAppName}\data"
-Type: files; Name: "{userappdata}\{#MyAppName}\data_config"
-Type: files; Name: "{userappdata}\{#MyAppName}\log.txt"
-Type: filesandordirs; Name: "{userappdata}\{#MyAppName}\DebugLogs"
-Type: filesandordirs; Name: "{userappdata}\{#MyAppName}\tupdates"
-Type: filesandordirs; Name: "{userappdata}\{#MyAppName}\tdata"
-Type: filesandordirs; Name: "{userappdata}\{#MyAppName}\tcache"
-Type: filesandordirs; Name: "{userappdata}\{#MyAppName}\tdumps"
-Type: dirifempty; Name: "{userappdata}\{#MyAppName}"
-
-[Code]
-procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
-var ResultCode: Integer;
-begin
-  if CurUninstallStep = usUninstall then
-  begin
-    ShellExec('', ExpandConstant('{app}\{#MyAppExeName}'), '-cleanup', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
-  end;
-end;
-
-const CSIDL_DESKTOPDIRECTORY = $0010;
-      CSIDL_COMMON_DESKTOPDIRECTORY = $0019;
-
-procedure CurStepChanged(CurStep: TSetupStep);
-var ResultCode: Integer;
-    HasOldKey: Boolean;
-    HasNewKey: Boolean;
-    HasOldLnk: Boolean;
-    HasNewLnk: Boolean;
-    UserDesktopLnk: String;
-    CommonDesktopLnk: String;
-begin
-  if CurStep = ssPostInstall then
-  begin
-    HasNewKey := RegKeyExists(HKEY_CURRENT_USER, 'Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{#MyAppId}}_is1') or RegKeyExists(HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\{{#MyAppId}}_is1');
-    HasOldKey := RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{#MyAppId}}_is1') or RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{#MyAppId}}_is1');
-    UserDesktopLnk := ExpandFileName(GetShellFolderByCSIDL(CSIDL_DESKTOPDIRECTORY, False) + '\{#MyAppShortName}.lnk');
-    CommonDesktopLnk := ExpandFileName(GetShellFolderByCSIDL(CSIDL_COMMON_DESKTOPDIRECTORY, False) + '\{#MyAppShortName}.lnk');
-    HasNewLnk := FileExists(UserDesktopLnk);
-    HasOldLnk := FileExists(CommonDesktopLnk) and (UserDesktopLnk <> CommonDesktopLnk);
-    if (HasOldKey and HasNewKey) or (HasOldLnk and HasNewLnk) then
-    begin
-      if (GetWindowsVersion >= $06000000) then // Vista or later
-        ShellExec('runas', ExpandConstant('{app}\{#MyAppExeName}'), '-fixprevious', '', SW_SHOW, ewWaitUntilTerminated, ResultCode)
-      else
-        ShellExec('', ExpandConstant('{app}\{#MyAppExeName}'), '-fixprevious', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
-    end;
-  end;
-end;
diff --git a/Telegram/build/test_package.bat b/Telegram/build/test_package.bat
deleted file mode 100644
index 223ba3b33..000000000
--- a/Telegram/build/test_package.bat
+++ /dev/null
@@ -1,81 +0,0 @@
-@echo OFF
-setlocal enabledelayedexpansion
-set "FullScriptPath=%~dp0"
-set "FullExecPath=%cd%"
-
-if not exist "%FullScriptPath%..\..\..\TelegramPrivate" (
-  echo.
-  echo This script is for building the production version of Telegram Desktop.
-  echo.
-  echo For building custom versions please visit the build instructions page at:
-  echo https://github.com/telegramdesktop/tdesktop/#build-instructions
-  exit /b
-)
-
-set "HomePath=%FullScriptPath%.."
-set "SignAppxPath=%HomePath%\..\..\TelegramPrivate\AppxSign.bat"
-set "ResourcesPath=%HomePath%\Resources"
-set "SolutionPath=%HomePath%\.."
-set "ReleasePath=%HomePath%\..\out\Debug"
-set "BinaryName=Telegram"
-
-if exist %ReleasePath%\AppX\ (
-  echo Result folder out\Debug\AppX already exists!
-  exit /b 1
-)
-
-cd "%HomePath%"
-
-call gyp\refresh.bat
-if %errorlevel% neq 0 goto error
-
-cd "%SolutionPath%"
-call ninja -C out/Debug Telegram
-if %errorlevel% neq 0 goto error
-
-cd "%HomePath%"
-
-mkdir "%ReleasePath%\AppX"
-xcopy "Resources\uwp\AppX\*" "%ReleasePath%\AppX\" /E
-
-set "ResourcePath=%ReleasePath%\AppX\AppxManifest.xml"
-call :repl "Argument= (Publisher=)&quot;CN=536BC709-8EE1-4478-AF22-F0F0F26FF64A&quot;/ $1&quot;CN=Telegram Messenger LLP, O=Telegram Messenger LLP, L=London, C=GB&quot;" "Filename=%ResourcePath%" || goto :error
-call :repl "Argument= (ProcessorArchitecture=)&quot;ARCHITECTURE&quot;/ $1&quot;x64&quot;" "Filename=%ResourcePath%" || goto :error
-
-makepri new /pr Resources\uwp\AppX\ /cf Resources\uwp\priconfig.xml /mn %ReleasePath%\AppX\AppxManifest.xml /of %ReleasePath%\AppX\resources.pri
-if %errorlevel% neq 0 goto error
-
-xcopy "%ReleasePath%\%BinaryName%.exe" "%ReleasePath%\AppX\"
-
-MakeAppx.exe pack /d "%ReleasePath%\AppX" /l /p ..\out\Debug\%BinaryName%.appx
-if %errorlevel% neq 0 goto error
-
-call "%SignAppxPath%" "..\out\Debug\%BinaryName%.appx"
-
-move "%ReleasePath%\%BinaryName%.appx" "%ReleasePath%\AppX\"
-
-echo Done.
-
-exit /b
-
-:repl
-(
-  set %1
-  set %2
-  set "TempFilename=!Filename!__tmp__"
-  cscript //Nologo "%FullScriptPath%replace.vbs" "Replace" "!Argument!" < "!Filename!" > "!TempFilename!" || goto :repl_finish
-  xcopy /Y !TempFilename! !Filename! >NUL || goto :repl_finish
-  goto :repl_finish
-)
-
-:repl_finish
-(
-  set ErrorCode=%errorlevel%
-  if !ErrorCode! neq 0 (
-    echo Replace error !ErrorCode!
-    echo While replacing "%Replace%"
-    echo In file "%Filename%"
-  )
-  del %TempFilename%
-  exit /b !ErrorCode!
-)
diff --git a/Telegram/build/version b/Telegram/build/version
deleted file mode 100644
index 354b10f04..000000000
--- a/Telegram/build/version
+++ /dev/null
@@ -1,6 +0,0 @@
-AppVersion         1001023
-AppVersionStrMajor 1.1
-AppVersionStrSmall 1.1.23
-AppVersionStr      1.1.23
-AlphaChannel       0
-BetaVersion        0
diff --git a/Telegram/create.bat b/Telegram/create.bat
deleted file mode 100644
index 570e75f2b..000000000
--- a/Telegram/create.bat
+++ /dev/null
@@ -1,147 +0,0 @@
-@echo off
-setlocal enabledelayedexpansion
-set "FullScriptPath=%~dp0"
-set "FullExecPath=%cd%"
-
-set "Command=%1"
-if "%Command%" == "test" (
-  call :write_test %2
-  exit /b %errorlevel%
-) else if "%Command%" == "header" (
-  call :write_header %2
-  exit /b %errorlevel%
-) else if "%Command%" == "source" (
-  call :write_source %2
-  exit /b %errorlevel%
-) else if "%Command%" == "" (
-  echo This is an utility for fast blank module creation.
-  echo Please provide module path.
-  exit /b
-)
-
-call :write_module %Command%
-exit /b %errorlevel%
-
-:write_module
-(
-  set "CommandPath=%1"
-  set "CommandPathUnix=!CommandPath:\=/!"
-  if "!CommandPathUnix!" == "" (
-    echo Provide module path.
-    exit /b 1
-  )
-  echo Generating module !CommandPathUnix!..
-  call create.bat header !CommandPathUnix!
-  call create.bat source !CommandPathUnix!
-  exit /b
-)
-
-:write_header
-(
-  set "CommandPath=%1"
-  set "CommandPathUnix=!CommandPath:\=/!"
-  set "CommandPathWin=!CommandPath:/=\!"
-
-  if "!CommandPathUnix!" == "" (
-    echo Provide header path.
-    exit /b 1
-  ) else if exist "SourceFiles\!CommandPathWin!.h" (
-    echo This header already exists.
-    exit /b 1
-  )
-  echo Generating header !CommandPathUnix!.h..
-  mkdir "SourceFiles\!CommandPathWin!.h"
-  rmdir "SourceFiles\!CommandPathWin!.h"
-
-  call :write_comment !CommandPathWin!.h
-  set "header1=#pragma once"
-  (
-    echo !header1!
-    echo.
-  )>> "SourceFiles\!CommandPathWin!.h"
-  exit /b
-)
-
-:write_source
-(
-  set "CommandPath=%1"
-  set "CommandPathUnix=!CommandPath:\=/!"
-  set "CommandPathWin=!CommandPath:/=\!"
-
-  if "!CommandPathUnix!" == "" (
-    echo Provide source path.
-    exit /b 1
-  ) else if exist "SourceFiles\!CommandPathWin!.cpp" (
-    echo This source already exists.
-    exit /b 1
-  )
-  echo Generating source !CommandPathUnix!.cpp..
-  mkdir "SourceFiles\!CommandPathWin!.cpp"
-  rmdir "SourceFiles\!CommandPathWin!.cpp"
-
-  call :write_comment !CommandPathWin!.cpp
-  set "quote="""
-  set "quote=!quote:~0,1!"
-  set "source1=#include !quote!!CommandPathUnix!.h!quote!"
-  (
-    echo !source1!
-    echo.
-  )>> "SourceFiles\!CommandPathWin!.cpp"
-  exit /b
-)
-
-:write_test
-(
-  set "CommandPath=%1"
-  set "CommandPathUnix=!CommandPath:\=/!"
-  set "CommandPathWin=!CommandPath:/=\!"
-
-  if "!CommandPathUnix!" == "" (
-    echo Provide source path.
-    exit /b 1
-  ) else if exist "SourceFiles\!CommandPathWin!.cpp" (
-    echo This source already exists.
-    exit /b 1
-  )
-  echo Generating test !CommandPathUnix!.cpp..
-  mkdir "SourceFiles\!CommandPathWin!.cpp"
-  rmdir "SourceFiles\!CommandPathWin!.cpp"
-
-  call :write_comment !CommandPathWin!.cpp
-  set "quote="""
-  set "quote=!quote:~0,1!"
-  set "source1=#include !quote!catch.hpp!quote!"
-  (
-    echo !source1!
-    echo.
-  )>> "SourceFiles\!CommandPathWin!.cpp"
-  exit /b
-)
-
-:write_comment
-(
-  set "Path=%1"
-  (
-    echo /*
-    echo This file is part of Telegram Desktop,
-    echo the official desktop version of Telegram messaging app, see https://telegram.org
-    echo.
-    echo Telegram Desktop is free software: you can redistribute it and/or modify
-    echo it under the terms of the GNU General Public License as published by
-    echo the Free Software Foundation, either version 3 of the License, or
-    echo ^(at your option^) any later version.
-    echo.
-    echo It is distributed in the hope that it will be useful,
-    echo but WITHOUT ANY WARRANTY; without even the implied warranty of
-    echo MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-    echo GNU General Public License for more details.
-    echo.
-    echo In addition, as a special exception, the copyright holders give permission
-    echo to link the code of portions of this program with the OpenSSL library.
-    echo.
-    echo Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
-    echo Copyright ^(c^) 2014-2017 John Preston, https://desktop.telegram.org
-    echo */
-  )> "SourceFiles\!Path!"
-  exit /b
-)