diff --git a/Telegram/SourceFiles/application.cpp b/Telegram/SourceFiles/application.cpp index f40305811..4ecbe5845 100644 --- a/Telegram/SourceFiles/application.cpp +++ b/Telegram/SourceFiles/application.cpp @@ -696,8 +696,8 @@ void Application::checkMapVersion() { if (Local::oldMapVersion() < AppVersion) { if (Local::oldMapVersion()) { QString versionFeatures; - if (cDevVersion() && Local::oldMapVersion() < 9007) { - versionFeatures = QString::fromUtf8("\xe2\x80\x94 Tilde symbol fixed in message input field\n\xe2\x80\x94 Add a caption to any photo you send\n\xe2\x80\x94 Bad sound quality bug fixed\n\xe2\x80\x94 Some bugfixes and improvements");// .replace('@', qsl("@") + QChar(0x200D)); + if (cDevVersion() && Local::oldMapVersion() < 9009) { + versionFeatures = QString::fromUtf8("\xe2\x80\x94 New popup menus in text input fields\n\xe2\x80\x94 Error is displayed when trying to paste or drop a folder instead of a file\n\xe2\x80\x94 Some bugfixes and improvements");// .replace('@', qsl("@") + QChar(0x200D)); } else if (Local::oldMapVersion() < 9005) { versionFeatures = lang(lng_new_version_text).trimmed(); } else { diff --git a/Telegram/SourceFiles/config.h b/Telegram/SourceFiles/config.h index 58b7905d0..4cd25c880 100644 --- a/Telegram/SourceFiles/config.h +++ b/Telegram/SourceFiles/config.h @@ -20,8 +20,8 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org */ #pragma once -static const int32 AppVersion = 9008; -static const wchar_t *AppVersionStr = L"0.9.8"; +static const int32 AppVersion = 9009; +static const wchar_t *AppVersionStr = L"0.9.9"; static const bool DevVersion = true; static const wchar_t *AppNameOld = L"Telegram Win (Unofficial)"; @@ -351,7 +351,7 @@ enum { }; inline const QRegularExpression &cWordSplit() { - static QRegularExpression regexp(qsl("[\\@\\s\\-\\+\\)\\(\\,\\.\\:\\!\\_\\;\\\"\\'\\x0]")); + static QRegularExpression regexp(qsl("[\\@\\s\\-\\+\\(\\)\\[\\]\\{\\}\\<\\>\\,\\.\\:\\!\\_\\;\\\"\\'\\x0]")); return regexp; } diff --git a/Telegram/SourceFiles/gui/flatinput.cpp b/Telegram/SourceFiles/gui/flatinput.cpp index 887ea2599..8d5e5731c 100644 --- a/Telegram/SourceFiles/gui/flatinput.cpp +++ b/Telegram/SourceFiles/gui/flatinput.cpp @@ -917,7 +917,7 @@ QVariant InputArea::InputAreaInner::loadResource(int type, const QUrl &name) { } void InputArea::processDocumentContentsChange(int position, int charsAdded) { - int32 emojiPosition = 0, emojiLen = 0; + int32 emojiPosition = -1, emojiLen = 0; const EmojiData *emoji = 0; static QString regular = qsl("Open Sans"), semibold = qsl("Open Sans Semibold"); @@ -982,11 +982,11 @@ void InputArea::processDocumentContentsChange(int position, int charsAdded) { ++fp; } } - if (emojiPosition) break; + if (emojiPosition >= 0) break; } - if (emojiPosition) break; + if (emojiPosition >= 0) break; } - if (emojiPosition) { + if (emojiPosition >= 0) { if (emoji) { if (!_inner.document()->pageSize().isNull()) { _inner.document()->setPageSize(QSizeF(0, 0)); @@ -999,7 +999,7 @@ void InputArea::processDocumentContentsChange(int position, int charsAdded) { position = emojiPosition + 1; emoji = 0; - emojiPosition = 0; + emojiPosition = -1; } else { break; } @@ -1611,7 +1611,7 @@ QVariant InputField::InputFieldInner::loadResource(int type, const QUrl &name) { } void InputField::processDocumentContentsChange(int position, int charsAdded) { - int32 emojiPosition = 0, emojiLen = 0; + int32 emojiPosition = -1, emojiLen = 0; const EmojiData *emoji = 0; static QString regular = qsl("Open Sans"), semibold = qsl("Open Sans Semibold"), space(' '); @@ -1689,9 +1689,9 @@ void InputField::processDocumentContentsChange(int position, int charsAdded) { ++fp; } } - if (emojiPosition) break; + if (emojiPosition >= 0) break; } - if (emojiPosition) break; + if (emojiPosition >= 0) break; if (b.next() != doc->end()) { emojiPosition = b.next().position() - 1; @@ -1702,7 +1702,7 @@ void InputField::processDocumentContentsChange(int position, int charsAdded) { break; } } - if (emojiPosition) { + if (emojiPosition >= 0) { if (emoji) { if (!_inner.document()->pageSize().isNull()) { _inner.document()->setPageSize(QSizeF(0, 0)); @@ -1715,7 +1715,7 @@ void InputField::processDocumentContentsChange(int position, int charsAdded) { position = emojiPosition + 1; emoji = 0; - emojiPosition = 0; + emojiPosition = -1; } else { break; } diff --git a/Telegram/SourceFiles/gui/flattextarea.cpp b/Telegram/SourceFiles/gui/flattextarea.cpp index d49a21948..8cb8103b6 100644 --- a/Telegram/SourceFiles/gui/flattextarea.cpp +++ b/Telegram/SourceFiles/gui/flattextarea.cpp @@ -619,7 +619,7 @@ void FlatTextarea::checkContentHeight() { } void FlatTextarea::processDocumentContentsChange(int position, int charsAdded) { - int32 emojiPosition = 0, emojiLen = 0; + int32 emojiPosition = -1, emojiLen = 0; const EmojiData *emoji = 0; static QString regular = qsl("Open Sans"), semibold = qsl("Open Sans Semibold"); @@ -681,11 +681,11 @@ void FlatTextarea::processDocumentContentsChange(int position, int charsAdded) { ++fp; } } - if (emojiPosition) break; + if (emojiPosition >= 0) break; } - if (emojiPosition) break; + if (emojiPosition >= 0) break; } - if (emojiPosition) { + if (emojiPosition >= 0) { if (emoji) { if (!document()->pageSize().isNull()) { document()->setPageSize(QSizeF(0, 0)); @@ -698,7 +698,7 @@ void FlatTextarea::processDocumentContentsChange(int position, int charsAdded) { position = emojiPosition + 1; emoji = 0; - emojiPosition = 0; + emojiPosition = -1; } else { break; } diff --git a/Telegram/SourceFiles/gui/popupmenu.cpp b/Telegram/SourceFiles/gui/popupmenu.cpp index 052422e69..17f96535b 100644 --- a/Telegram/SourceFiles/gui/popupmenu.cpp +++ b/Telegram/SourceFiles/gui/popupmenu.cpp @@ -37,7 +37,9 @@ PopupMenu::PopupMenu(const style::PopupMenu &st) : TWidget(0) , _childMenuIndex(-1) , a_opacity(1) , _a_hide(animFunc(this, &PopupMenu::animStep_hide)) -, _deleteOnHide(true) { +, _deleteOnHide(true) +, _triggering(false) +, _deleteLater(false) { init(); } @@ -50,9 +52,12 @@ PopupMenu::PopupMenu(QMenu *menu, const style::PopupMenu &st) : TWidget(0) , _mouseSelection(false) , _shadow(_st.shadow) , _selected(-1) +, _childMenuIndex(-1) , a_opacity(1) , _a_hide(animFunc(this, &PopupMenu::animStep_hide)) -, _deleteOnHide(true) { +, _deleteOnHide(true) +, _triggering(false) +, _deleteLater(false) { init(); QList actions(menu->actions()); for (int32 i = 0, l = actions.size(); i < l; ++i) { @@ -236,7 +241,13 @@ void PopupMenu::itemPressed(PressSource source) { } } else { hideMenu(); + _triggering = true; emit _actions[_selected]->trigger(); + _triggering = false; + if (_deleteLater) { + _deleteLater = false; + deleteLater(); + } } } } @@ -260,6 +271,7 @@ void PopupMenu::keyPressEvent(QKeyEvent *e) { if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) { itemPressed(PressSourceKeyboard); + return; } else if (e->key() == Qt::Key_Escape) { hideMenu(_parent ? true : false); return; @@ -267,6 +279,7 @@ void PopupMenu::keyPressEvent(QKeyEvent *e) { if (e->key() == (rtl() ? Qt::Key_Left : Qt::Key_Right)) { if (_selected >= 0 && _menus.at(_selected)) { itemPressed(PressSourceKeyboard); + return; } else if (_selected < 0 && _parent && !_actions.isEmpty()) { _mouseSelection = false; setSelected(0); @@ -300,11 +313,7 @@ void PopupMenu::keyPressEvent(QKeyEvent *e) { void PopupMenu::enterEvent(QEvent *e) { QPoint mouse = QCursor::pos(); - if (_inner.marginsRemoved(QMargins(0, _st.skip, 0, _st.skip)).contains(mapFromGlobal(mouse))) { - _mouseSelection = true; - _mouse = mouse; - updateSelected(); - } else { + if (!_inner.marginsRemoved(QMargins(0, _st.skip, 0, _st.skip)).contains(mapFromGlobal(mouse))) { if (_mouseSelection && _childMenuIndex < 0) { _mouseSelection = false; setSelected(-1); @@ -370,13 +379,14 @@ void PopupMenu::mouseMoveEvent(QMouseEvent *e) { void PopupMenu::mousePressEvent(QMouseEvent *e) { mouseMoveEvent(e); - itemPressed(PressSourceMouse); - if (!_inner.contains(mapFromGlobal(e->globalPos()))) { - if (_parent) { - _parent->mousePressEvent(e); - } else { - hideMenu(); - } + if (_inner.contains(mapFromGlobal(e->globalPos()))) { + itemPressed(PressSourceMouse); + return; + } + if (_parent) { + _parent->mousePressEvent(e); + } else { + hideMenu(); } } @@ -384,6 +394,16 @@ void PopupMenu::focusOutEvent(QFocusEvent *e) { hideMenu(); } +void PopupMenu::hideEvent(QHideEvent *e) { + if (_deleteOnHide) { + if (_triggering) { + _deleteLater = true; + } else { + deleteLater(); + } + } +} + void PopupMenu::hideMenu(bool fast) { if (isHidden()) return; if (_parent && !_a_hide.animating()) { @@ -418,9 +438,6 @@ void PopupMenu::childHiding(PopupMenu *child) { void PopupMenu::hideFinish() { hide(); - if (_deleteOnHide) { - deleteLater(); - } } bool PopupMenu::animStep_hide(float64 ms) { @@ -481,6 +498,7 @@ void PopupMenu::showMenu(const QPoint &p, PopupMenu *parent, PressSource source) } move(w); + _mouseSelection = (source == PressSourceMouse); setSelected((source == PressSourceMouse || _actions.isEmpty()) ? -1 : 0); psUpdateOverlayed(this); show(); diff --git a/Telegram/SourceFiles/gui/popupmenu.h b/Telegram/SourceFiles/gui/popupmenu.h index 8aa2a8085..887f15bd6 100644 --- a/Telegram/SourceFiles/gui/popupmenu.h +++ b/Telegram/SourceFiles/gui/popupmenu.h @@ -47,6 +47,7 @@ protected: void leaveEvent(QEvent *e); void enterEvent(QEvent *e); void focusOutEvent(QFocusEvent *e); + void hideEvent(QHideEvent *e); public slots: @@ -101,6 +102,6 @@ private: anim::fvalue a_opacity; Animation _a_hide; - bool _deleteOnHide; + bool _deleteOnHide, _triggering, _deleteLater; }; diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index f1845b76c..4d70baf85 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -4544,7 +4544,7 @@ void HistoryWidget::onFilesDrop(const QMimeData *data) { if (files.size() == 1 && !QFileInfo(files.at(0)).isDir()) { uploadFile(files.at(0), PrepareAuto); } -// uploadFiles(files, PrepareAuto); // multiple confirm with "compressed" checkbox +// uploadFiles(files, PrepareAuto); // multiple confirm with "compressed" checkbox } void HistoryWidget::onKbToggle(bool manual) { diff --git a/Telegram/SourceFiles/localimageloader.cpp b/Telegram/SourceFiles/localimageloader.cpp index ba9e7a0d0..f82fdb396 100644 --- a/Telegram/SourceFiles/localimageloader.cpp +++ b/Telegram/SourceFiles/localimageloader.cpp @@ -216,6 +216,10 @@ void FileLoadTask::process() { if (!_filepath.isEmpty()) { QFileInfo info(_filepath); + if (info.isDir()) { + _result->filesize = -1; + return; + } filesize = info.size(); filemime = mimeTypeForFile(info).name(); filename = info.fileName(); @@ -399,6 +403,11 @@ void FileLoadTask::finish() { App::wnd()->replaceLayer(new InformBox(lang(lng_send_image_empty))); return; } + if (_result->filesize == -1) { // dir + App::main()->onSendFileCancel(_result); + App::wnd()->replaceLayer(new InformBox(lng_send_folder(lt_name, QFileInfo(_filepath).dir().dirName()))); + return; + } if (_result->filesize > MaxUploadDocumentSize) { App::main()->onSendFileCancel(_result); App::wnd()->replaceLayer(new InformBox(lang(lng_send_image_too_large))); diff --git a/Telegram/SourceFiles/mediaview.cpp b/Telegram/SourceFiles/mediaview.cpp index c4e127302..394b59324 100644 --- a/Telegram/SourceFiles/mediaview.cpp +++ b/Telegram/SourceFiles/mediaview.cpp @@ -1946,7 +1946,7 @@ void MediaView::updateHeader() { _headerText = _doc->name.isEmpty() ? lang(lng_mediaview_doc_image) : _doc->name; } else if (_user) { _headerText = lang(lng_mediaview_profile_photo); - } else if (_channel && !_history->isMegagroup()) { + } else if ((_channel && !_history->isMegagroup()) || (_peer && _peer->isChannel() && !_peer->isMegagroup())) { _headerText = lang(lng_mediaview_channel_photo); } else if (_peer) { _headerText = lang(lng_mediaview_group_photo); diff --git a/Telegram/Telegram.plist b/Telegram/Telegram.plist index ce9f208f6..217a1bf81 100644 --- a/Telegram/Telegram.plist +++ b/Telegram/Telegram.plist @@ -11,7 +11,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.9.8 + 0.9.9 CFBundleSignature ???? CFBundleURLTypes diff --git a/Telegram/Telegram.rc b/Telegram/Telegram.rc index 7479f851a..d575f5cc7 100644 Binary files a/Telegram/Telegram.rc and b/Telegram/Telegram.rc differ diff --git a/Telegram/Telegram.xcodeproj/project.pbxproj b/Telegram/Telegram.xcodeproj/project.pbxproj index a5fa2c962..06775ca77 100644 --- a/Telegram/Telegram.xcodeproj/project.pbxproj +++ b/Telegram/Telegram.xcodeproj/project.pbxproj @@ -1687,7 +1687,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 0.9.8; + CURRENT_PROJECT_VERSION = 0.9.9; DEBUG_INFORMATION_FORMAT = dwarf; GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_OPTIMIZATION_LEVEL = 0; @@ -1706,7 +1706,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 0.9.8; + CURRENT_PROJECT_VERSION = 0.9.9; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_OPTIMIZATION_LEVEL = fast; GCC_PREFIX_HEADER = ./SourceFiles/stdafx.h; @@ -1733,10 +1733,10 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = ""; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 0.9.8; + CURRENT_PROJECT_VERSION = 0.9.9; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 0.9; - DYLIB_CURRENT_VERSION = 0.9.8; + DYLIB_CURRENT_VERSION = 0.9.9; ENABLE_STRICT_OBJC_MSGSEND = YES; FRAMEWORK_SEARCH_PATHS = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = YES; @@ -1867,10 +1867,10 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = ""; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 0.9.8; + CURRENT_PROJECT_VERSION = 0.9.9; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 0.9; - DYLIB_CURRENT_VERSION = 0.9.8; + DYLIB_CURRENT_VERSION = 0.9.9; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; FRAMEWORK_SEARCH_PATHS = ""; diff --git a/Telegram/Version b/Telegram/Version index fd79ecf60..56cc933dd 100644 --- a/Telegram/Version +++ b/Telegram/Version @@ -1,5 +1,5 @@ -AppVersion 9008 +AppVersion 9009 AppVersionStrMajor 0.9 -AppVersionStrSmall 0.9.8 -AppVersionStr 0.9.8 +AppVersionStrSmall 0.9.9 +AppVersionStr 0.9.9 DevChannel 1