From 1d0a799b7796136972062de6d66360a7edd97e17 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 18 Feb 2015 19:52:04 +0300 Subject: [PATCH] removed Prepare project (moved to PrepareWin.bat), fixed multimedia keys in Qt 5.4.0 --- Telegram.sln | 13 +- Telegram/Prepare.vcxproj | 126 ------------------ Telegram/Prepare.vcxproj.filters | 33 ----- Telegram/PrepareWin.bat | 32 ++++- Telegram/SourceFiles/_other/packer.cpp | 7 +- Telegram/SourceFiles/_other/prepare.cpp | 106 --------------- Telegram/SourceFiles/_other/prepare.h | 37 ----- Telegram/SourceFiles/window.cpp | 4 +- Telegram/_qt_5_4_0_patch.diff | 14 +- .../platforms/windows/qwindowskeymapper.cpp | 5 +- 10 files changed, 56 insertions(+), 321 deletions(-) delete mode 100644 Telegram/Prepare.vcxproj delete mode 100644 Telegram/Prepare.vcxproj.filters delete mode 100644 Telegram/SourceFiles/_other/prepare.cpp delete mode 100644 Telegram/SourceFiles/_other/prepare.h diff --git a/Telegram.sln b/Telegram.sln index a59887f8a..d33570a0c 100644 --- a/Telegram.sln +++ b/Telegram.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.30110.0 +VisualStudioVersion = 12.0.30501.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Telegram", "Telegram\Telegram.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" ProjectSection(ProjectDependencies) = postProject @@ -16,8 +16,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MetaEmoji", "Telegram\MetaE EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Updater", "Telegram\Updater.vcxproj", "{6B4BA3BE-7B15-4B4C-B200-81ABFDEF2C76}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Prepare", "Telegram\Prepare.vcxproj", "{88AB1138-143A-4CFB-A0E6-79B646B5E1B0}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MetaLang", "Telegram\MetaLang.vcxproj", "{E417CAA4-259B-4C99-88E3-805F1300E8EB}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2F863EAD-33C9-4014-A573-93F085BA9CB1}" @@ -71,15 +69,6 @@ Global {6B4BA3BE-7B15-4B4C-B200-81ABFDEF2C76}.Release|Win32.ActiveCfg = Release|Win32 {6B4BA3BE-7B15-4B4C-B200-81ABFDEF2C76}.Release|Win32.Build.0 = Release|Win32 {6B4BA3BE-7B15-4B4C-B200-81ABFDEF2C76}.Release|x64.ActiveCfg = Release|Win32 - {88AB1138-143A-4CFB-A0E6-79B646B5E1B0}.Debug|Win32.ActiveCfg = Debug|Win32 - {88AB1138-143A-4CFB-A0E6-79B646B5E1B0}.Debug|Win32.Build.0 = Debug|Win32 - {88AB1138-143A-4CFB-A0E6-79B646B5E1B0}.Debug|x64.ActiveCfg = Debug|Win32 - {88AB1138-143A-4CFB-A0E6-79B646B5E1B0}.Deploy|Win32.ActiveCfg = Deploy|Win32 - {88AB1138-143A-4CFB-A0E6-79B646B5E1B0}.Deploy|Win32.Build.0 = Deploy|Win32 - {88AB1138-143A-4CFB-A0E6-79B646B5E1B0}.Deploy|x64.ActiveCfg = Release|Win32 - {88AB1138-143A-4CFB-A0E6-79B646B5E1B0}.Release|Win32.ActiveCfg = Release|Win32 - {88AB1138-143A-4CFB-A0E6-79B646B5E1B0}.Release|Win32.Build.0 = Release|Win32 - {88AB1138-143A-4CFB-A0E6-79B646B5E1B0}.Release|x64.ActiveCfg = Release|Win32 {E417CAA4-259B-4C99-88E3-805F1300E8EB}.Debug|Win32.ActiveCfg = Debug|Win32 {E417CAA4-259B-4C99-88E3-805F1300E8EB}.Debug|Win32.Build.0 = Debug|Win32 {E417CAA4-259B-4C99-88E3-805F1300E8EB}.Debug|x64.ActiveCfg = Debug|Win32 diff --git a/Telegram/Prepare.vcxproj b/Telegram/Prepare.vcxproj deleted file mode 100644 index 7dc896256..000000000 --- a/Telegram/Prepare.vcxproj +++ /dev/null @@ -1,126 +0,0 @@ - - - - - Debug - Win32 - - - Deploy - Win32 - - - Release - Win32 - - - - - - - - - - {88AB1138-143A-4CFB-A0E6-79B646B5E1B0} - Qt4VSv1.0 - - - - Application - v120_xp - - - Application - v120_xp - - - Application - v120_xp - - - - - - - - - - - - - - - - <_ProjectFileVersion>11.0.61030.0 - - - $(SolutionDir)$(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)IntermediatePrepare\ - - - $(SolutionDir)$(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)IntermediatePrepare\ - - - $(SolutionDir)$(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)IntermediatePrepare\ - - - - UNICODE;WIN32;WIN64;QT_CORE_LIB;%(PreprocessorDefinitions) - Disabled - ProgramDatabase - MultiThreadedDebug - .;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;%(AdditionalIncludeDirectories) - false - - - Console - $(OutDir)\$(ProjectName).exe - $(QTDIR)\lib;%(AdditionalLibraryDirectories) - kernel32.lib;user32.lib;shell32.lib;uuid.lib;ole32.lib;advapi32.lib;ws2_32.lib;qtmaind.lib;Qt5Cored.lib;%(AdditionalDependencies) - true - - - - - UNICODE;WIN32;WIN64;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;%(PreprocessorDefinitions) - - MultiThreaded - .;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;%(AdditionalIncludeDirectories) - false - - - Console - $(OutDir)\$(ProjectName).exe - $(QTDIR)\lib;%(AdditionalLibraryDirectories) - kernel32.lib;user32.lib;shell32.lib;uuid.lib;ole32.lib;advapi32.lib;ws2_32.lib;qtmain.lib;Qt5Core.lib;%(AdditionalDependencies) - false - - - - - UNICODE;WIN32;WIN64;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;%(PreprocessorDefinitions) - - - MultiThreaded - .;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;%(AdditionalIncludeDirectories) - false - - - Console - $(OutDir)\$(ProjectName).exe - $(QTDIR)\lib;%(AdditionalLibraryDirectories) - kernel32.lib;user32.lib;shell32.lib;uuid.lib;ole32.lib;advapi32.lib;ws2_32.lib;qtmain.lib;Qt5Core.lib;%(AdditionalDependencies) - false - - - - - - - - - - - \ No newline at end of file diff --git a/Telegram/Prepare.vcxproj.filters b/Telegram/Prepare.vcxproj.filters deleted file mode 100644 index c4a106555..000000000 --- a/Telegram/Prepare.vcxproj.filters +++ /dev/null @@ -1,33 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;cxx;c;def - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h - - - {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} - qrc;* - false - - - {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} - moc;h;cpp - False - - - - - Source Files - - - - - Header Files - - - \ No newline at end of file diff --git a/Telegram/PrepareWin.bat b/Telegram/PrepareWin.bat index 8a019fba8..49248c9d8 100644 --- a/Telegram/PrepareWin.bat +++ b/Telegram/PrepareWin.bat @@ -1,5 +1,6 @@ @echo OFF +set "AppVersion=7016" set "AppVersionStrSmall=0.7.16" set "AppVersionStr=0.7.16" set "AppVersionStrFull=0.7.16.0" @@ -22,6 +23,10 @@ echo. echo Preparing version %AppVersionStr%%DevPostfix%.. echo. +if exist ..\Win32\Deploy\deploy\%AppVersionStr%\ goto error_exist1 +if exist ..\Win32\Deploy\deploy\%AppVersionStr%.dev\ goto error_exist2 +if exist ..\Win32\Deploy\tupdate%AppVersion% goto error_exist3 + set "PATH=%PATH%;C:\Program Files\7-Zip;C:\Program Files (x86)\Inno Setup 5" cd ..\Win32\Deploy @@ -37,12 +42,21 @@ if %errorlevel% neq 0 goto error1 call ..\..\..\TelegramPrivate\Sign.bat tsetup.%AppVersionStr%%DevPostfix%.exe if %errorlevel% neq 0 goto error1 -call Prepare.exe -path Telegram.exe -path Updater.exe %DevParam% +call Packer.exe -version %AppVersion% -path Telegram.exe -path Updater.exe %DevParam% if %errorlevel% neq 0 goto error1 +if not exist deploy mkdir deploy +mkdir deploy\%AppVersionStr%%DevPostfix% +mkdir deploy\%AppVersionStr%%DevPostfix%\Telegram + +move Telegram.exe deploy\%AppVersionStr%%DevPostfix%\Telegram\ +move Updater.exe deploy\%AppVersionStr%%DevPostfix%\ +move Telegram.pdb deploy\%AppVersionStr%%DevPostfix%\ +move Updater.pdb deploy\%AppVersionStr%%DevPostfix%\ +move tsetup.%AppVersionStr%%DevPostfix%.exe deploy\%AppVersionStr%%DevPostfix%\ +move tupdate%AppVersion% deploy\%AppVersionStr%%DevPostfix%\ + cd deploy\%AppVersionStr%%DevPostfix% -mkdir Telegram -move Telegram.exe Telegram\ 7z a -mx9 tportable.%AppVersionStr%%DevPostfix%.zip Telegram\ if %errorlevel% neq 0 goto error2 @@ -60,4 +74,16 @@ cd ..\..\Telegram echo ERROR occured! exit /b %errorlevel% +:error_exist1 +echo Deploy folder for version %AppVersionStr% already exists! +exit /b 1 + +:error_exist2 +echo Deploy folder for version %AppVersionStr%.dev already exists! +exit /b 1 + +:error_exist3 +echo Update file for version %AppVersion% already exists! +exit /b 1 + :eof diff --git a/Telegram/SourceFiles/_other/packer.cpp b/Telegram/SourceFiles/_other/packer.cpp index deb0ed572..bd1a7df10 100644 --- a/Telegram/SourceFiles/_other/packer.cpp +++ b/Telegram/SourceFiles/_other/packer.cpp @@ -253,7 +253,12 @@ int main(int argc, char *argv[]) size_t compressedLen = compressed.size() - hSize; size_t outPropsSize = LZMA_PROPS_SIZE; - int res = LzmaCompress((uchar*)(compressed.data() + hSize), &compressedLen, (const uchar*)(result.constData()), result.size(), (uchar*)(compressed.data() + hSigLen + hShaLen), &outPropsSize, 9, 64 * 1024 * 1024, 0, 0, 0, 0, 0); + uchar *_dest = (uchar*)(compressed.data() + hSize); + size_t *_destLen = &compressedLen; + const uchar *_src = (const uchar*)(result.constData()); + size_t _srcLen = result.size(); + uchar *_outProps = (uchar*)(compressed.data() + hSigLen + hShaLen); + int res = LzmaCompress(_dest, _destLen, _src, _srcLen, _outProps, &outPropsSize, 9, 64 * 1024 * 1024, 4, 0, 2, 273, 2); if (res != SZ_OK) { cout << "Error in compression: " << res << "\n"; return -1; diff --git a/Telegram/SourceFiles/_other/prepare.cpp b/Telegram/SourceFiles/_other/prepare.cpp deleted file mode 100644 index 4c05acb57..000000000 --- a/Telegram/SourceFiles/_other/prepare.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop version of Telegram messaging app, see https://telegram.org - -Telegram Desktop is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -It is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE -Copyright (c) 2014 John Preston, https://desktop.telegram.org -*/ -#include "prepare.h" - -bool DevChannel = false; - -int prepare(QFileInfo f, QStringList paths) { - if (paths.isEmpty()) { - cout << "No -path args were passed :(\n"; - return -1; - } - - int lastVersion = 0; - QString lastVersionStr; - QFileInfo last; - QFileInfoList l = f.absoluteDir().entryInfoList(QDir::Files); - for (QFileInfoList::iterator i = l.begin(), e = l.end(); i != e; ++i) { - QRegularExpressionMatch m = QRegularExpression("/tsetup\\.((\\d+)\\.(\\d+)\\.(\\d+))(?:\\.dev)?\\.exe$").match(i->absoluteFilePath()); - if (!m.hasMatch()) continue; - - int version = m.captured(2).toInt() * 1000000 + m.captured(3).toInt() * 1000 + m.captured(4).toInt(); - if (version > lastVersion) { - lastVersion = version; - lastVersionStr = m.captured(1); - last = *i; - } - } - - if (!lastVersion) { - cout << "No tsetup.X.Y.Z.exe or tsetup.X.Y.Z.dev.exe found :(\n"; - return -1; - } - - cout << "Last version: " << (lastVersionStr + (DevChannel ? ".dev" : "")).toUtf8().constData() << " (" << lastVersion << "), executing packer..\n"; - - QDir dir("deploy/" + lastVersionStr + (DevChannel ? ".dev" : "")); - if (dir.exists()) { - cout << "Version " << (lastVersionStr + (DevChannel ? ".dev" : "")).toUtf8().constData() << " already exists in /deploy..\n"; - return -1; - } else if (QDir("deploy/" + lastVersionStr + (DevChannel ? "" : ".dev")).exists()) { - cout << "Version " << (lastVersionStr + (DevChannel ? "" : ".dev")).toUtf8().constData() << " already exists in /deploy..\n"; - return -1; - } - - QString packer = QString("Packer.exe -version %1").arg(lastVersion); - for (QStringList::iterator i = paths.begin(), e = paths.end(); i != e; ++i) { - packer += " -path " + *i; - } - if (DevChannel) packer += " -dev"; - - int res = system(packer.toUtf8().constData()); - - if (res) return res; - - dir.mkpath("."); - - paths.push_back("Telegram.pdb"); - paths.push_back("Updater.pdb"); - paths.push_back("tsetup." + lastVersionStr + (DevChannel ? ".dev" : "") + ".exe"); - paths.push_back(QString("tupdate%1").arg(lastVersion)); - for (QStringList::iterator i = paths.begin(), e = paths.end(); i != e; ++i) { - if (!QFile::copy(*i, "deploy/" + lastVersionStr + (DevChannel ? ".dev" : "") + "/" + *i)) { - cout << "Could not copy " << i->toUtf8().constData() << " to deploy/" << (lastVersionStr + (DevChannel ? ".dev" : "")).toUtf8().constData() << "\n"; - return -1; - } - cout << "Copied " << i->toUtf8().constData() << "..\n"; - } - for (QStringList::iterator i = paths.begin(), e = paths.end(); i != e; ++i) { - QFile::remove(*i); - } - - cout << "Update created in deploy/" << (lastVersionStr + (DevChannel ? ".dev" : "")).toUtf8().constData() << "\n"; - - return 0; -} - -int main(int argc, char *argv[]) -{ - QFileInfo f(argv[0]); - - QStringList paths; - for (int i = 1; i < argc; ++i) { - if (string(argv[i]) == "-path" && i + 1 < argc) { - paths.push_back(QString(argv[i + 1])); - } else if (string(argv[i]) == "-dev") { - DevChannel = true; - } - } - int res = prepare(f, paths); - return res; -} diff --git a/Telegram/SourceFiles/_other/prepare.h b/Telegram/SourceFiles/_other/prepare.h deleted file mode 100644 index b12c1a645..000000000 --- a/Telegram/SourceFiles/_other/prepare.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop version of Telegram messaging app, see https://telegram.org - -Telegram Desktop is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -It is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE -Copyright (c) 2014 John Preston, https://desktop.telegram.org -*/ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -using std::string; -using std::wstring; -using std::cout; \ No newline at end of file diff --git a/Telegram/SourceFiles/window.cpp b/Telegram/SourceFiles/window.cpp index 622b09c6e..f9099a1f6 100644 --- a/Telegram/SourceFiles/window.cpp +++ b/Telegram/SourceFiles/window.cpp @@ -329,7 +329,7 @@ NotifyWindow::~NotifyWindow() { if (App::wnd()) App::wnd()->notifyShowNext(this); } -Window::Window(QWidget *parent) : PsMainWindow(parent), _serviceHistoryRequest(0), +Window::Window(QWidget *parent) : PsMainWindow(parent), _serviceHistoryRequest(0), title(0), intro(0), main(0), settings(0), layerBG(0), _isActive(false), _topWidget(0), _connecting(0), _clearManager(0), dragging(false), _inactivePress(false), _mediaView(0) { @@ -1034,6 +1034,8 @@ TitleWidget *Window::getTitle() { } void Window::resizeEvent(QResizeEvent *e) { + if (!title) return; + bool wideMode = (width() >= st::wideModeWidth); if (wideMode != cWideMode()) { cSetWideMode(wideMode); diff --git a/Telegram/_qt_5_4_0_patch.diff b/Telegram/_qt_5_4_0_patch.diff index 3f09d4b51..2b2a901a5 100644 --- a/Telegram/_qt_5_4_0_patch.diff +++ b/Telegram/_qt_5_4_0_patch.diff @@ -647,7 +647,7 @@ index f1f472b..97819dd 100644 { m_data.setSelectedNameFilter(f); // Dialog cannot be updated at run-time. diff --git a/qtbase/src/plugins/platforms/windows/qwindowskeymapper.cpp b/qtbase/src/plugins/platforms/windows/qwindowskeymapper.cpp -index ff9ad18..ba423b4 100644 +index ff9ad18..3fd0848 100644 --- a/qtbase/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/qtbase/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -537,17 +537,16 @@ static inline int toKeyOrUnicode(int vk, int scancode, unsigned char *kbdBuffer, @@ -678,6 +678,18 @@ index ff9ad18..ba423b4 100644 code = unicodeBuffer[0].toUpper().unicode(); // Qt::Key_*'s are not encoded below 0x20, so try again, and DEL keys (0x7f) is encoded with a +@@ -833,7 +832,10 @@ bool QWindowsKeyMapper::translateMultimediaKeyEventInternal(QWindow *window, con + + const int qtKey = CmdTbl[cmd]; + sendExtendedPressRelease(receiver, qtKey, Qt::KeyboardModifier(state), 0, 0, 0); +- return true; ++ // QTBUG-43343: Make sure to return false if Qt does not handle the key, otherwise, ++ // the keys are not passed to the active media player. ++ const QKeySequence sequence(Qt::Modifier(state) + qtKey); ++ return QGuiApplicationPrivate::instance()->shortcutMap.hasShortcutForKeySequence(sequence); + #else + Q_UNREACHABLE(); + return false; diff --git a/qtbase/src/plugins/platforms/windows/qwindowswindow.cpp b/qtbase/src/plugins/platforms/windows/qwindowswindow.cpp index 8a80729..16fda26 100644 --- a/qtbase/src/plugins/platforms/windows/qwindowswindow.cpp diff --git a/Telegram/_qt_5_4_0_patch/qtbase/src/plugins/platforms/windows/qwindowskeymapper.cpp b/Telegram/_qt_5_4_0_patch/qtbase/src/plugins/platforms/windows/qwindowskeymapper.cpp index ba423b430..3fd084829 100644 --- a/Telegram/_qt_5_4_0_patch/qtbase/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/Telegram/_qt_5_4_0_patch/qtbase/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -832,7 +832,10 @@ bool QWindowsKeyMapper::translateMultimediaKeyEventInternal(QWindow *window, con const int qtKey = CmdTbl[cmd]; sendExtendedPressRelease(receiver, qtKey, Qt::KeyboardModifier(state), 0, 0, 0); - return true; + // QTBUG-43343: Make sure to return false if Qt does not handle the key, otherwise, + // the keys are not passed to the active media player. + const QKeySequence sequence(Qt::Modifier(state) + qtKey); + return QGuiApplicationPrivate::instance()->shortcutMap.hasShortcutForKeySequence(sequence); #else Q_UNREACHABLE(); return false;