From 7d272919aa9ae371683efcba689c71ee15a61353 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 20 Apr 2016 15:56:59 +0300 Subject: [PATCH] Version 0.9.44 copy text context menu item added to some messages. --- Telegram/SourceFiles/config.h | 8 ++++---- Telegram/SourceFiles/history.h | 21 +++++++++++++++++++++ Telegram/SourceFiles/historywidget.cpp | 7 ++++--- Telegram/Telegram.plist | 2 +- Telegram/Telegram.rc | 8 ++++---- Telegram/Telegram.xcodeproj/project.pbxproj | 12 ++++++------ Telegram/Version | 8 ++++---- 7 files changed, 44 insertions(+), 22 deletions(-) diff --git a/Telegram/SourceFiles/config.h b/Telegram/SourceFiles/config.h index db8d48770..359dda896 100644 --- a/Telegram/SourceFiles/config.h +++ b/Telegram/SourceFiles/config.h @@ -20,10 +20,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #pragma once -static const int32 AppVersion = 9043; -static const wchar_t *AppVersionStr = L"0.9.43"; -static const bool DevVersion = true; -//#define BETA_VERSION (9040128ULL) // just comment this line to build public version +static const int32 AppVersion = 9044; +static const wchar_t *AppVersionStr = L"0.9.44"; +static const bool DevVersion = false; +//#define BETA_VERSION (9044000ULL) // just comment this line to build public version static const wchar_t *AppNameOld = L"Telegram Win (Unofficial)"; static const wchar_t *AppName = L"Telegram Desktop"; diff --git a/Telegram/SourceFiles/history.h b/Telegram/SourceFiles/history.h index 81314ee64..cec615af9 100644 --- a/Telegram/SourceFiles/history.h +++ b/Telegram/SourceFiles/history.h @@ -1658,6 +1658,9 @@ public: virtual bool isDisplayed() const { return true; } + virtual bool hasTextForCopy() const { + return false; + } virtual void initDimensions() = 0; virtual int resizeGetHeight(int width) { _width = qMin(width, _maxw); @@ -1878,6 +1881,9 @@ public: TextSelection adjustSelection(TextSelection selection, TextSelectType type) const override { return _caption.adjustSelection(selection, type); } + bool hasTextForCopy() const override { + return !_caption.isEmpty(); + } QString inDialogsText() const override; QString selectedText(TextSelection selection) const override; @@ -1955,6 +1961,9 @@ public: TextSelection adjustSelection(TextSelection selection, TextSelectType type) const override { return _caption.adjustSelection(selection, type); } + bool hasTextForCopy() const override { + return !_caption.isEmpty(); + } QString inDialogsText() const override; QString selectedText(TextSelection selection) const override; @@ -2075,6 +2084,9 @@ public: } return selection; } + bool hasTextForCopy() const override { + return Has(); + } QString inDialogsText() const override; QString selectedText(TextSelection selection) const override; @@ -2159,6 +2171,9 @@ public: TextSelection adjustSelection(TextSelection selection, TextSelectType type) const override { return _caption.adjustSelection(selection, type); } + bool hasTextForCopy() const override { + return !_caption.isEmpty(); + } QString inDialogsText() const override; QString selectedText(TextSelection selection) const override; @@ -2384,6 +2399,9 @@ public: HistoryTextState getState(int x, int y, HistoryStateRequest request) const override; TextSelection adjustSelection(TextSelection selection, TextSelectType type) const override; + bool hasTextForCopy() const override { + return false; // we do not add _title and _description in FullSelection text copy. + } bool toggleSelectionByHandlerClick(const ClickHandlerPtr &p) const override { return _attach && _attach->toggleSelectionByHandlerClick(p); @@ -2515,6 +2533,9 @@ public: HistoryTextState getState(int x, int y, HistoryStateRequest request) const override; TextSelection adjustSelection(TextSelection selection, TextSelectType type) const override; + bool hasTextForCopy() const override { + return !_title.isEmpty() || !_description.isEmpty(); + } bool toggleSelectionByHandlerClick(const ClickHandlerPtr &p) const override { return p == _link; diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index 59c6ae8ec..181b72cd2 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -1037,7 +1037,9 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { } } if (item && !isUponSelected) { - if (HistoryMedia *media = (msg ? msg->getMedia() : 0)) { + bool mediaHasTextForCopy = false; + if (HistoryMedia *media = (msg ? msg->getMedia() : nullptr)) { + mediaHasTextForCopy = media->hasTextForCopy(); if (media->type() == MediaTypeWebPage && static_cast(media)->attach()) { media = static_cast(media)->attach(); } @@ -1065,8 +1067,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { } } } - QString contextMenuText = item->selectedText(FullSelection); - if (!contextMenuText.isEmpty() && msg && !msg->getMedia()) { + if (msg && (!msg->emptyText() || mediaHasTextForCopy)) { _menu->addAction(lang(lng_context_copy_text), this, SLOT(copyContextText()))->setEnabled(true); } } diff --git a/Telegram/Telegram.plist b/Telegram/Telegram.plist index f2a400335..79f3fa3bd 100644 --- a/Telegram/Telegram.plist +++ b/Telegram/Telegram.plist @@ -11,7 +11,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.9.43 + 0.9.44 CFBundleSignature ???? CFBundleURLTypes diff --git a/Telegram/Telegram.rc b/Telegram/Telegram.rc index d5dcb3d74..0b4ce89d7 100644 --- a/Telegram/Telegram.rc +++ b/Telegram/Telegram.rc @@ -34,8 +34,8 @@ IDI_ICON1 ICON "Resources\\art\\icon256.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,9,43,0 - PRODUCTVERSION 0,9,43,0 + FILEVERSION 0,9,44,0 + PRODUCTVERSION 0,9,44,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -51,10 +51,10 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "Telegram Messenger LLP" - VALUE "FileVersion", "0.9.43.0" + VALUE "FileVersion", "0.9.44.0" VALUE "LegalCopyright", "Copyright (C) 2014-2016" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "0.9.43.0" + VALUE "ProductVersion", "0.9.44.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/Telegram.xcodeproj/project.pbxproj b/Telegram/Telegram.xcodeproj/project.pbxproj index 679670ac5..b494ab5da 100644 --- a/Telegram/Telegram.xcodeproj/project.pbxproj +++ b/Telegram/Telegram.xcodeproj/project.pbxproj @@ -1712,7 +1712,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 0.9.43; + CURRENT_PROJECT_VERSION = 0.9.44; DEBUG_INFORMATION_FORMAT = dwarf; GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_OPTIMIZATION_LEVEL = 0; @@ -1731,7 +1731,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 0.9.43; + CURRENT_PROJECT_VERSION = 0.9.44; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_OPTIMIZATION_LEVEL = fast; GCC_PREFIX_HEADER = ./SourceFiles/stdafx.h; @@ -1760,10 +1760,10 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = ""; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 0.9.43; + CURRENT_PROJECT_VERSION = 0.9.44; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 0.9; - DYLIB_CURRENT_VERSION = 0.9.43; + DYLIB_CURRENT_VERSION = 0.9.44; ENABLE_STRICT_OBJC_MSGSEND = YES; FRAMEWORK_SEARCH_PATHS = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = YES; @@ -1901,10 +1901,10 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = ""; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 0.9.43; + CURRENT_PROJECT_VERSION = 0.9.44; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 0.9; - DYLIB_CURRENT_VERSION = 0.9.43; + DYLIB_CURRENT_VERSION = 0.9.44; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; FRAMEWORK_SEARCH_PATHS = ""; diff --git a/Telegram/Version b/Telegram/Version index 07086bb01..589e72d56 100644 --- a/Telegram/Version +++ b/Telegram/Version @@ -1,6 +1,6 @@ -AppVersion 9043 +AppVersion 9044 AppVersionStrMajor 0.9 -AppVersionStrSmall 0.9.43 -AppVersionStr 0.9.43 -DevChannel 1 +AppVersionStrSmall 0.9.44 +AppVersionStr 0.9.44 +DevChannel 0 BetaVersion 0