diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 83596d4e7d..62adaec338 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -23,7 +23,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "lang.h" #include "application.h" -#include "window.h" +#include "mainwindow.h" #include "mainwidget.h" #include "apiwrap.h" diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index 6d11b479b0..c227c243b7 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -31,7 +31,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include #endif #include "localstorage.h" - +#include "apiwrap.h" #include "numbers.h" namespace { @@ -146,23 +146,29 @@ namespace App { return AppClass::app(); } - Window *wnd() { + MainWindow *wnd() { return AppClass::wnd(); } MainWidget *main() { - Window *w(wnd()); - return w ? w->mainWidget() : 0; + if (auto w = wnd()) { + return w->mainWidget(); + } + return nullptr; } SettingsWidget *settings() { - Window *w(wnd()); - return w ? w->settingsWidget() : 0; + if (auto w = wnd()) { + return w->settingsWidget(); + } + return nullptr; } bool passcoded() { - Window *w(wnd()); - return w ? w->passcodeWidget() : 0; + if (auto w = wnd()) { + return w->passcodeWidget(); + } + return false; } FileUploader *uploader() { @@ -181,7 +187,7 @@ namespace { if (audioPlayer()) { audioPlayer()->stopAndClear(); } - if (Window *w = wnd()) { + if (auto w = wnd()) { w->tempDirDelete(Local::ClearManagerAll); w->notifyClearFast(); w->setupIntro(true); @@ -196,7 +202,7 @@ namespace { globalNotifyChatsPtr = UnknownNotifySettings; if (App::uploader()) App::uploader()->clear(); clearStorageImages(); - if (Window *w = wnd()) { + if (auto w = wnd()) { w->getTitle()->updateBackButton(); w->updateTitleStatus(); w->getTitle()->resizeEvent(0); diff --git a/Telegram/SourceFiles/app.h b/Telegram/SourceFiles/app.h index 3b53eb0611..4e437b71bd 100644 --- a/Telegram/SourceFiles/app.h +++ b/Telegram/SourceFiles/app.h @@ -20,10 +20,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #pragma once -#include "basic_types.h" +#include "core/basic_types.h" class AppClass; -class Window; +class MainWindow; class MainWidget; class SettingsWidget; class ApiWrap; @@ -48,7 +48,7 @@ class LayeredWidget; namespace App { AppClass *app(); - Window *wnd(); + MainWindow *wnd(); MainWidget *main(); SettingsWidget *settings(); bool passcoded(); diff --git a/Telegram/SourceFiles/application.cpp b/Telegram/SourceFiles/application.cpp index a011db893c..a5d4a73342 100644 --- a/Telegram/SourceFiles/application.cpp +++ b/Telegram/SourceFiles/application.cpp @@ -718,7 +718,7 @@ AppClass::AppClass() : QObject() QMimeDatabase().mimeTypeForName(qsl("text/plain")); // create mime database - _window = new Window(); + _window = new MainWindow(); _window->createWinId(); _window->init(); @@ -1053,7 +1053,7 @@ void AppClass::checkMapVersion() { AppClass::~AppClass() { Shortcuts::finish(); - if (Window *w = _window) { + if (auto w = _window) { _window = 0; delete w; } @@ -1086,7 +1086,7 @@ AppClass *AppClass::app() { return AppObject; } -Window *AppClass::wnd() { +MainWindow *AppClass::wnd() { return AppObject ? AppObject->_window : 0; } diff --git a/Telegram/SourceFiles/application.h b/Telegram/SourceFiles/application.h index ae51569e8d..774ebc85b6 100644 --- a/Telegram/SourceFiles/application.h +++ b/Telegram/SourceFiles/application.h @@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #pragma once -#include "window.h" +#include "mainwindow.h" #include "pspecific.h" class UpdateChecker; @@ -153,7 +153,7 @@ public: ~AppClass(); static AppClass *app(); - static Window *wnd(); + static MainWindow *wnd(); static MainWidget *main(); FileUploader *uploader(); @@ -212,7 +212,7 @@ private: uint64 _lastActionTime; - Window *_window; + MainWindow *_window; FileUploader *_uploader; Translator *_translator; diff --git a/Telegram/SourceFiles/audio.h b/Telegram/SourceFiles/audio.h index 4eb75c88dd..17bbf8cf06 100644 --- a/Telegram/SourceFiles/audio.h +++ b/Telegram/SourceFiles/audio.h @@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #pragma once -#include "basic_types.h" +#include "core/basic_types.h" void audioInit(); bool audioWorks(); diff --git a/Telegram/SourceFiles/boxes/aboutbox.cpp b/Telegram/SourceFiles/boxes/aboutbox.cpp index da41b067e7..083d6b6503 100644 --- a/Telegram/SourceFiles/boxes/aboutbox.cpp +++ b/Telegram/SourceFiles/boxes/aboutbox.cpp @@ -23,7 +23,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "aboutbox.h" #include "mainwidget.h" -#include "window.h" +#include "mainwindow.h" #include "autoupdater.h" #include "boxes/confirmbox.h" diff --git a/Telegram/SourceFiles/boxes/abstractbox.cpp b/Telegram/SourceFiles/boxes/abstractbox.cpp index e9d1783ad5..f721c6b578 100644 --- a/Telegram/SourceFiles/boxes/abstractbox.cpp +++ b/Telegram/SourceFiles/boxes/abstractbox.cpp @@ -25,7 +25,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "abstractbox.h" #include "mainwidget.h" -#include "window.h" +#include "mainwindow.h" void BlueTitleShadow::paintEvent(QPaintEvent *e) { Painter p(this); diff --git a/Telegram/SourceFiles/boxes/addcontactbox.cpp b/Telegram/SourceFiles/boxes/addcontactbox.cpp index 7e58787bc3..444742a816 100644 --- a/Telegram/SourceFiles/boxes/addcontactbox.cpp +++ b/Telegram/SourceFiles/boxes/addcontactbox.cpp @@ -28,7 +28,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "photocropbox.h" #include "ui/filedialog.h" #include "mainwidget.h" -#include "window.h" +#include "mainwindow.h" +#include "apiwrap.h" AddContactBox::AddContactBox(QString fname, QString lname, QString phone) : AbstractBox(st::boxWidth) , _user(0) diff --git a/Telegram/SourceFiles/boxes/autolockbox.cpp b/Telegram/SourceFiles/boxes/autolockbox.cpp index 3af3b2615e..a755697ca7 100644 --- a/Telegram/SourceFiles/boxes/autolockbox.cpp +++ b/Telegram/SourceFiles/boxes/autolockbox.cpp @@ -26,7 +26,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "autolockbox.h" #include "confirmbox.h" #include "mainwidget.h" -#include "window.h" +#include "mainwindow.h" AutoLockBox::AutoLockBox() : _close(this, lang(lng_box_ok), st::defaultBoxButton) { diff --git a/Telegram/SourceFiles/boxes/backgroundbox.cpp b/Telegram/SourceFiles/boxes/backgroundbox.cpp index edb6a2bd95..ddbdf4a399 100644 --- a/Telegram/SourceFiles/boxes/backgroundbox.cpp +++ b/Telegram/SourceFiles/boxes/backgroundbox.cpp @@ -23,7 +23,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "backgroundbox.h" #include "mainwidget.h" -#include "window.h" +#include "mainwindow.h" #include "settingswidget.h" BackgroundInner::BackgroundInner() : diff --git a/Telegram/SourceFiles/boxes/confirmbox.cpp b/Telegram/SourceFiles/boxes/confirmbox.cpp index b836cbbb70..3f3f73edc6 100644 --- a/Telegram/SourceFiles/boxes/confirmbox.cpp +++ b/Telegram/SourceFiles/boxes/confirmbox.cpp @@ -23,9 +23,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "confirmbox.h" #include "mainwidget.h" -#include "window.h" - +#include "mainwindow.h" +#include "apiwrap.h" #include "application.h" +#include "core/click_handler_types.h" TextParseOptions _confirmBoxTextOptions = { TextParseLinks | TextParseMultiline | TextParseRichText, // flags diff --git a/Telegram/SourceFiles/boxes/connectionbox.cpp b/Telegram/SourceFiles/boxes/connectionbox.cpp index c9d65c3bb6..8f2fc96b05 100644 --- a/Telegram/SourceFiles/boxes/connectionbox.cpp +++ b/Telegram/SourceFiles/boxes/connectionbox.cpp @@ -25,7 +25,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "connectionbox.h" #include "mainwidget.h" -#include "window.h" +#include "mainwindow.h" ConnectionBox::ConnectionBox() : AbstractBox(st::boxWidth) , _hostInput(this, st::connectionHostInputField, lang(lng_connection_host_ph), cConnectionProxy().host) diff --git a/Telegram/SourceFiles/boxes/contactsbox.cpp b/Telegram/SourceFiles/boxes/contactsbox.cpp index da166de865..326c94befe 100644 --- a/Telegram/SourceFiles/boxes/contactsbox.cpp +++ b/Telegram/SourceFiles/boxes/contactsbox.cpp @@ -26,11 +26,12 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "boxes/addcontactbox.h" #include "boxes/contactsbox.h" #include "mainwidget.h" -#include "window.h" +#include "mainwindow.h" #include "application.h" #include "ui/filedialog.h" #include "boxes/photocropbox.h" #include "boxes/confirmbox.h" +#include "apiwrap.h" QString cantInviteError() { return lng_cant_invite_not_contact(lt_more_info, textcmdLink(qsl("https://telegram.me/spambot"), lang(lng_cant_more_info))); diff --git a/Telegram/SourceFiles/boxes/emojibox.cpp b/Telegram/SourceFiles/boxes/emojibox.cpp index 9bd637bed3..9aca04bc00 100644 --- a/Telegram/SourceFiles/boxes/emojibox.cpp +++ b/Telegram/SourceFiles/boxes/emojibox.cpp @@ -23,7 +23,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "emojibox.h" #include "mainwidget.h" -#include "window.h" +#include "mainwindow.h" namespace { // copied from genemoji.cpp diff --git a/Telegram/SourceFiles/boxes/languagebox.cpp b/Telegram/SourceFiles/boxes/languagebox.cpp index 9400077e6c..8c7fe47ede 100644 --- a/Telegram/SourceFiles/boxes/languagebox.cpp +++ b/Telegram/SourceFiles/boxes/languagebox.cpp @@ -26,7 +26,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "languagebox.h" #include "confirmbox.h" #include "mainwidget.h" -#include "window.h" +#include "mainwindow.h" #include "langloaderplain.h" diff --git a/Telegram/SourceFiles/boxes/passcodebox.cpp b/Telegram/SourceFiles/boxes/passcodebox.cpp index f444a960a9..8468e86fff 100644 --- a/Telegram/SourceFiles/boxes/passcodebox.cpp +++ b/Telegram/SourceFiles/boxes/passcodebox.cpp @@ -23,7 +23,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "passcodebox.h" #include "confirmbox.h" -#include "window.h" +#include "mainwindow.h" #include "localstorage.h" diff --git a/Telegram/SourceFiles/boxes/sessionsbox.cpp b/Telegram/SourceFiles/boxes/sessionsbox.cpp index 7bb3c4847a..06d84ced13 100644 --- a/Telegram/SourceFiles/boxes/sessionsbox.cpp +++ b/Telegram/SourceFiles/boxes/sessionsbox.cpp @@ -25,7 +25,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "sessionsbox.h" #include "mainwidget.h" -#include "window.h" +#include "mainwindow.h" #include "countries.h" #include "confirmbox.h" diff --git a/Telegram/SourceFiles/boxes/stickersetbox.cpp b/Telegram/SourceFiles/boxes/stickersetbox.cpp index 2756b15bcd..8149585219 100644 --- a/Telegram/SourceFiles/boxes/stickersetbox.cpp +++ b/Telegram/SourceFiles/boxes/stickersetbox.cpp @@ -23,10 +23,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "stickersetbox.h" #include "mainwidget.h" -#include "window.h" +#include "mainwindow.h" #include "settingswidget.h" #include "boxes/confirmbox.h" - +#include "apiwrap.h" #include "localstorage.h" StickerSetInner::StickerSetInner(const MTPInputStickerSet &set) : TWidget() diff --git a/Telegram/SourceFiles/boxes/usernamebox.cpp b/Telegram/SourceFiles/boxes/usernamebox.cpp index 57c940570e..7d7bb157f2 100644 --- a/Telegram/SourceFiles/boxes/usernamebox.cpp +++ b/Telegram/SourceFiles/boxes/usernamebox.cpp @@ -24,7 +24,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "application.h" #include "usernamebox.h" #include "mainwidget.h" -#include "window.h" +#include "mainwindow.h" UsernameBox::UsernameBox() : AbstractBox(st::boxWidth), _save(this, lang(lng_settings_save), st::defaultBoxButton), diff --git a/Telegram/SourceFiles/basic_types.cpp b/Telegram/SourceFiles/core/basic_types.cpp similarity index 100% rename from Telegram/SourceFiles/basic_types.cpp rename to Telegram/SourceFiles/core/basic_types.cpp diff --git a/Telegram/SourceFiles/basic_types.h b/Telegram/SourceFiles/core/basic_types.h similarity index 100% rename from Telegram/SourceFiles/basic_types.h rename to Telegram/SourceFiles/core/basic_types.h diff --git a/Telegram/SourceFiles/core/click_handler.cpp b/Telegram/SourceFiles/core/click_handler.cpp new file mode 100644 index 0000000000..09809de140 --- /dev/null +++ b/Telegram/SourceFiles/core/click_handler.cpp @@ -0,0 +1,63 @@ +/* +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. + +In addition, as a special exception, the copyright holders give permission +to link the code of portions of this program with the OpenSSL library. + +Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE +Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org +*/ +#include "stdafx.h" +#include "core/click_handler.h" + +ClickHandlerHost::~ClickHandlerHost() { + ClickHandler::hostDestroyed(this); +} + +NeverFreedPointer ClickHandler::_active; +NeverFreedPointer ClickHandler::_pressed; +ClickHandlerHost *ClickHandler::_activeHost = nullptr; +ClickHandlerHost *ClickHandler::_pressedHost = nullptr; + +bool ClickHandler::setActive(const ClickHandlerPtr &p, ClickHandlerHost *host) { + if ((_active && (*_active == p)) || (!_active && !p)) { + return false; + } + + // emit clickHandlerActiveChanged only when there is no + // other pressed click handler currently, if there is + // this method will be called when it is unpressed + if (_active && *_active) { + bool emitClickHandlerActiveChanged = (!_pressed || !*_pressed || *_pressed == *_active); + ClickHandlerPtr wasactive = *_active; + (*_active).clear(); + if (_activeHost) { + if (emitClickHandlerActiveChanged) { + _activeHost->clickHandlerActiveChanged(wasactive, false); + } + _activeHost = nullptr; + } + } + if (p) { + _active.makeIfNull(); + *_active = p; + if ((_activeHost = host)) { + bool emitClickHandlerActiveChanged = (!_pressed || !*_pressed || *_pressed == *_active); + if (emitClickHandlerActiveChanged) { + _activeHost->clickHandlerActiveChanged(*_active, true); + } + } + } + return true; +} diff --git a/Telegram/SourceFiles/core/click_handler.h b/Telegram/SourceFiles/core/click_handler.h new file mode 100644 index 0000000000..d03cb5d4c9 --- /dev/null +++ b/Telegram/SourceFiles/core/click_handler.h @@ -0,0 +1,157 @@ +/* +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. + +In addition, as a special exception, the copyright holders give permission +to link the code of portions of this program with the OpenSSL library. + +Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE +Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org +*/ +#pragma once + +class ClickHandler; +using ClickHandlerPtr = QSharedPointer; + +class ClickHandlerHost { +protected: + + virtual void clickHandlerActiveChanged(const ClickHandlerPtr &action, bool active) { + } + virtual void clickHandlerPressedChanged(const ClickHandlerPtr &action, bool pressed) { + } + virtual ~ClickHandlerHost() = 0; + friend class ClickHandler; + +}; + +class ClickHandler { +public: + + virtual void onClick(Qt::MouseButton) const = 0; + + virtual QString tooltip() const { + return QString(); + } + virtual void copyToClipboard() const { + } + virtual QString copyToClipboardContextItem() const { + return QString(); + } + virtual QString text() const { + return QString(); + } + virtual QString dragText() const { + return text(); + } + + virtual ~ClickHandler() { + } + + // this method should be called on mouse over a click handler + // it returns true if something was changed or false otherwise + static bool setActive(const ClickHandlerPtr &p, ClickHandlerHost *host = nullptr); + + // this method should be called when mouse leaves the host + // it returns true if something was changed or false otherwise + static bool clearActive(ClickHandlerHost *host = nullptr) { + if (host && _activeHost != host) { + return false; + } + return setActive(ClickHandlerPtr(), host); + } + + // this method should be called on mouse pressed + static void pressed() { + unpressed(); + if (!_active || !*_active) { + return; + } + _pressed.makeIfNull(); + *_pressed = *_active; + if ((_pressedHost = _activeHost)) { + _pressedHost->clickHandlerPressedChanged(*_pressed, true); + } + } + + // this method should be called on mouse released + // the activated click handler is returned + static ClickHandlerPtr unpressed() { + if (_pressed && *_pressed) { + bool activated = (_active && *_active == *_pressed); + ClickHandlerPtr waspressed = *_pressed; + (*_pressed).clear(); + if (_pressedHost) { + _pressedHost->clickHandlerPressedChanged(waspressed, false); + _pressedHost = nullptr; + } + + if (activated) { + return *_active; + } else if (_active && *_active && _activeHost) { + // emit clickHandlerActiveChanged for current active + // click handler, which we didn't emit while we has + // a pressed click handler + _activeHost->clickHandlerActiveChanged(*_active, true); + } + } + return ClickHandlerPtr(); + } + + static ClickHandlerPtr getActive() { + return _active ? *_active : ClickHandlerPtr(); + } + static ClickHandlerPtr getPressed() { + return _pressed ? *_pressed : ClickHandlerPtr(); + } + + static bool showAsActive(const ClickHandlerPtr &p) { + if (!p || !_active || p != *_active) { + return false; + } + return !_pressed || !*_pressed || (p == *_pressed); + } + static bool showAsPressed(const ClickHandlerPtr &p) { + if (!p || !_active || p != *_active) { + return false; + } + return _pressed && (p == *_pressed); + } + static void hostDestroyed(ClickHandlerHost *host) { + if (_activeHost == host) { + _activeHost = nullptr; + } else if (_pressedHost == host) { + _pressedHost = nullptr; + } + } + +private: + + static NeverFreedPointer _active; + static NeverFreedPointer _pressed; + static ClickHandlerHost *_activeHost; + static ClickHandlerHost *_pressedHost; + +}; + +class LeftButtonClickHandler : public ClickHandler { +public: + void onClick(Qt::MouseButton button) const override final { + if (button != Qt::LeftButton) return; + onClickImpl(); + } + +protected: + virtual void onClickImpl() const = 0; + +}; diff --git a/Telegram/SourceFiles/core/click_handler_types.cpp b/Telegram/SourceFiles/core/click_handler_types.cpp new file mode 100644 index 0000000000..3c317c3dd4 --- /dev/null +++ b/Telegram/SourceFiles/core/click_handler_types.cpp @@ -0,0 +1,133 @@ +/* +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. + +In addition, as a special exception, the copyright holders give permission +to link the code of portions of this program with the OpenSSL library. + +Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE +Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org +*/ +#include "stdafx.h" +#include "core/click_handler_types.h" + +#include "lang.h" +#include "pspecific.h" +#include "boxes/confirmbox.h" + +QString UrlClickHandler::copyToClipboardContextItem() const { + return lang(isEmail() ? lng_context_copy_email : lng_context_copy_link); +} + +namespace { + +QString tryConvertUrlToLocal(const QString &url) { + QRegularExpressionMatch telegramMeUser = QRegularExpression(qsl("^https?://telegram\\.me/([a-zA-Z0-9\\.\\_]+)(/?\\?|/?$|/(\\d+)/?(?:\\?|$))"), QRegularExpression::CaseInsensitiveOption).match(url); + QRegularExpressionMatch telegramMeGroup = QRegularExpression(qsl("^https?://telegram\\.me/joinchat/([a-zA-Z0-9\\.\\_\\-]+)(\\?|$)"), QRegularExpression::CaseInsensitiveOption).match(url); + QRegularExpressionMatch telegramMeStickers = QRegularExpression(qsl("^https?://telegram\\.me/addstickers/([a-zA-Z0-9\\.\\_]+)(\\?|$)"), QRegularExpression::CaseInsensitiveOption).match(url); + QRegularExpressionMatch telegramMeShareUrl = QRegularExpression(qsl("^https?://telegram\\.me/share/url\\?(.+)$"), QRegularExpression::CaseInsensitiveOption).match(url); + if (telegramMeGroup.hasMatch()) { + return qsl("tg://join?invite=") + myUrlEncode(telegramMeGroup.captured(1)); + } else if (telegramMeStickers.hasMatch()) { + return qsl("tg://addstickers?set=") + myUrlEncode(telegramMeStickers.captured(1)); + } else if (telegramMeShareUrl.hasMatch()) { + return qsl("tg://msg_url?") + telegramMeShareUrl.captured(1); + } else if (telegramMeUser.hasMatch()) { + QString params = url.mid(telegramMeUser.captured(0).size()), postParam; + if (QRegularExpression(qsl("^/\\d+/?(?:\\?|$)")).match(telegramMeUser.captured(2)).hasMatch()) { + postParam = qsl("&post=") + telegramMeUser.captured(3); + } + return qsl("tg://resolve/?domain=") + myUrlEncode(telegramMeUser.captured(1)) + postParam + (params.isEmpty() ? QString() : '&' + params); + } + return url; +} + +} // namespace + +void UrlClickHandler::doOpen(QString url) { + PopupTooltip::Hide(); + + if (isEmail(url)) { + QUrl u(qstr("mailto:") + url); + if (!QDesktopServices::openUrl(u)) { + psOpenFile(u.toString(QUrl::FullyEncoded), true); + } + return; + } + + url = tryConvertUrlToLocal(url); + + if (url.startsWith(qstr("tg://"), Qt::CaseInsensitive)) { + App::openLocalUrl(url); + } else { + QDesktopServices::openUrl(url); + } +} + +void HiddenUrlClickHandler::onClick(Qt::MouseButton button) const { + QString u = url(); + + u = tryConvertUrlToLocal(u); + + if (u.startsWith(qstr("tg://"))) { + App::openLocalUrl(u); + } else { + Ui::showLayer(new ConfirmLinkBox(u)); + } +} + +QString LocationClickHandler::copyToClipboardContextItem() const { + return lang(lng_context_copy_link); +} + +void LocationClickHandler::onClick(Qt::MouseButton button) const { + if (!psLaunchMaps(_coords)) { + QDesktopServices::openUrl(_text); + } +} + +void LocationClickHandler::setup() { + QString latlon(qsl("%1,%2").arg(_coords.lat).arg(_coords.lon)); + _text = qsl("https://maps.google.com/maps?q=") + latlon + qsl("&ll=") + latlon + qsl("&z=16"); +} + +QString MentionClickHandler::copyToClipboardContextItem() const { + return lang(lng_context_copy_mention); +} + +void MentionClickHandler::onClick(Qt::MouseButton button) const { + if (button == Qt::LeftButton || button == Qt::MiddleButton) { + App::openPeerByName(_tag.mid(1), ShowAtProfileMsgId); + } +} + +QString HashtagClickHandler::copyToClipboardContextItem() const { + return lang(lng_context_copy_hashtag); +} + +void HashtagClickHandler::onClick(Qt::MouseButton button) const { + if (button == Qt::LeftButton || button == Qt::MiddleButton) { + App::searchByHashtag(_tag, Ui::getPeerForMouseAction()); + } +} + +void BotCommandClickHandler::onClick(Qt::MouseButton button) const { + if (button == Qt::LeftButton || button == Qt::MiddleButton) { + if (PeerData *peer = Ui::getPeerForMouseAction()) { + Ui::showPeerHistory(peer, ShowAtTheEndMsgId); + App::sendBotCommand(peer, _cmd); + } else { + App::insertBotCommand(_cmd); + } + } +} diff --git a/Telegram/SourceFiles/core/click_handler_types.h b/Telegram/SourceFiles/core/click_handler_types.h new file mode 100644 index 0000000000..9ca66ad854 --- /dev/null +++ b/Telegram/SourceFiles/core/click_handler_types.h @@ -0,0 +1,181 @@ +/* +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. + +In addition, as a special exception, the copyright holders give permission +to link the code of portions of this program with the OpenSSL library. + +Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE +Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org +*/ +#pragma once + +#include "core/click_handler.h" + +class TextClickHandler : public ClickHandler { +public: + + TextClickHandler(bool fullDisplayed = true) : _fullDisplayed(fullDisplayed) { + } + + void copyToClipboard() const override { + QString u = url(); + if (!u.isEmpty()) { + QApplication::clipboard()->setText(u); + } + } + + QString tooltip() const override { + return _fullDisplayed ? QString() : readable(); + } + + void setFullDisplayed(bool full) { + _fullDisplayed = full; + } + +protected: + virtual QString url() const = 0; + virtual QString readable() const { + return url(); + } + + bool _fullDisplayed; + +}; + +class UrlClickHandler : public TextClickHandler { +public: + UrlClickHandler(const QString &url, bool fullDisplayed = true) : TextClickHandler(fullDisplayed), _url(url) { + if (isEmail()) { + _readable = _url; + } else { + QUrl u(_url), good(u.isValid() ? u.toEncoded() : QString()); + _readable = good.isValid() ? good.toDisplayString() : _url; + } + } + QString copyToClipboardContextItem() const override; + + QString text() const override { + return _url; + } + QString dragText() const override { + return url(); + } + + static void doOpen(QString url); + void onClick(Qt::MouseButton button) const override { + if (button == Qt::LeftButton || button == Qt::MiddleButton) { + doOpen(url()); + } + } + +protected: + QString url() const override { + if (isEmail()) { + return _url; + } + + QUrl u(_url), good(u.isValid() ? u.toEncoded() : QString()); + QString result(good.isValid() ? QString::fromUtf8(good.toEncoded()) : _url); + + if (!QRegularExpression(qsl("^[a-zA-Z]+:")).match(result).hasMatch()) { // no protocol + return qsl("http://") + result; + } + return result; + } + QString readable() const override { + return _readable; + } + +private: + static bool isEmail(const QString &url) { + int at = url.indexOf('@'), slash = url.indexOf('/'); + return ((at > 0) && (slash < 0 || slash > at)); + } + bool isEmail() const { + return isEmail(_url); + } + + QString _url, _readable; + +}; +typedef QSharedPointer TextClickHandlerPtr; + +class HiddenUrlClickHandler : public UrlClickHandler { +public: + HiddenUrlClickHandler(QString url) : UrlClickHandler(url, false) { + } + void onClick(Qt::MouseButton button) const override; + +}; + +class MentionClickHandler : public TextClickHandler { +public: + MentionClickHandler(const QString &tag) : _tag(tag) { + } + QString copyToClipboardContextItem() const override; + + QString text() const override { + return _tag; + } + void onClick(Qt::MouseButton button) const override; + +protected: + QString url() const override { + return _tag; + } + +private: + QString _tag; + +}; + +class HashtagClickHandler : public TextClickHandler { +public: + HashtagClickHandler(const QString &tag) : _tag(tag) { + } + QString copyToClipboardContextItem() const override; + + QString text() const override { + return _tag; + } + void onClick(Qt::MouseButton button) const override; + +protected: + QString url() const override { + return _tag; + } + +private: + QString _tag; + +}; + +class BotCommandClickHandler : public TextClickHandler { +public: + BotCommandClickHandler(const QString &cmd) : _cmd(cmd) { + } + QString text() const override { + return _cmd; + } + void onClick(Qt::MouseButton button) const override; + +protected: + QString url() const override { + return _cmd; + } + +private: + QString _cmd; + +}; diff --git a/Telegram/SourceFiles/dialogswidget.cpp b/Telegram/SourceFiles/dialogswidget.cpp index ee1dd621a9..1f0aa382f8 100644 --- a/Telegram/SourceFiles/dialogswidget.cpp +++ b/Telegram/SourceFiles/dialogswidget.cpp @@ -26,13 +26,14 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "ui/style.h" #include "lang.h" #include "application.h" -#include "window.h" +#include "mainwindow.h" #include "dialogswidget.h" #include "mainwidget.h" #include "boxes/addcontactbox.h" #include "boxes/contactsbox.h" #include "boxes/confirmbox.h" #include "localstorage.h" +#include "apiwrap.h" DialogsInner::DialogsInner(QWidget *parent, MainWidget *main) : SplittedWidget(parent) , dialogs(std_::make_unique(Dialogs::SortMode::Date)) diff --git a/Telegram/SourceFiles/dropdown.cpp b/Telegram/SourceFiles/dropdown.cpp index 8fce3e32ef..93ce0f9298 100644 --- a/Telegram/SourceFiles/dropdown.cpp +++ b/Telegram/SourceFiles/dropdown.cpp @@ -28,7 +28,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "historywidget.h" #include "localstorage.h" #include "lang.h" -#include "window.h" +#include "mainwindow.h" #include "apiwrap.h" #include "mainwidget.h" diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index fd74f4b6ad..60aa53e2e5 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -20,12 +20,11 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #include "stdafx.h" -#include "window.h" +#include "mainwindow.h" #include "mainwidget.h" #include "application.h" - +#include "core/click_handler_types.h" #include "boxes/confirmbox.h" - #include "layerwidget.h" #include "lang.h" @@ -136,13 +135,13 @@ void removeDialog(History *history) { } void showSettings() { - if (Window *w = wnd()) { + if (auto w = wnd()) { w->showSettings(); } } void activateClickHandler(ClickHandlerPtr handler, Qt::MouseButton button) { - if (Window *w = wnd()) { + if (auto w = wnd()) { qRegisterMetaType(); qRegisterMetaType(); QMetaObject::invokeMethod(w, "app_activateClickHandler", Qt::QueuedConnection, Q_ARG(ClickHandlerPtr, handler), Q_ARG(Qt::MouseButton, button)); @@ -150,7 +149,7 @@ void activateClickHandler(ClickHandlerPtr handler, Qt::MouseButton button) { } void logOutDelayed() { - if (Window *w = App::wnd()) { + if (auto w = App::wnd()) { QMetaObject::invokeMethod(w, "onLogoutSure", Qt::QueuedConnection); } } @@ -160,25 +159,25 @@ void logOutDelayed() { namespace Ui { void showMediaPreview(DocumentData *document) { - if (Window *w = App::wnd()) { + if (auto w = App::wnd()) { w->ui_showMediaPreview(document); } } void showMediaPreview(PhotoData *photo) { - if (Window *w = App::wnd()) { + if (auto w = App::wnd()) { w->ui_showMediaPreview(photo); } } void hideMediaPreview() { - if (Window *w = App::wnd()) { + if (auto w = App::wnd()) { w->ui_hideMediaPreview(); } } void showLayer(LayeredWidget *box, ShowLayerOptions options) { - if (Window *w = App::wnd()) { + if (auto w = App::wnd()) { w->ui_showLayer(box, options); } else { delete box; @@ -186,16 +185,16 @@ void showLayer(LayeredWidget *box, ShowLayerOptions options) { } void hideLayer(bool fast) { - if (Window *w = App::wnd()) w->ui_showLayer(0, ShowLayerOptions(CloseOtherLayers) | (fast ? ForceFastShowLayer : AnimatedShowLayer)); + if (auto w = App::wnd()) w->ui_showLayer(0, ShowLayerOptions(CloseOtherLayers) | (fast ? ForceFastShowLayer : AnimatedShowLayer)); } bool isLayerShown() { - if (Window *w = App::wnd()) return w->ui_isLayerShown(); + if (auto w = App::wnd()) return w->ui_isLayerShown(); return false; } bool isMediaViewShown() { - if (Window *w = App::wnd()) return w->ui_isMediaViewShown(); + if (auto w = App::wnd()) return w->ui_isMediaViewShown(); return false; } @@ -236,7 +235,7 @@ void showPeerHistoryAsync(const PeerId &peer, MsgId msgId) { } PeerData *getPeerForMouseAction() { - if (Window *w = App::wnd()) { + if (auto w = App::wnd()) { return w->ui_getPeerForMouseAction(); } return nullptr; @@ -244,7 +243,7 @@ PeerData *getPeerForMouseAction() { bool hideWindowNoQuit() { if (!App::quitting()) { - if (Window *w = App::wnd()) { + if (auto w = App::wnd()) { if (cWorkMode() == dbiwmTrayOnly || cWorkMode() == dbiwmWindowAndTray) { return w->minimizeToTray(); } else if (cPlatform() == dbipMac || cPlatform() == dbipMacOld) { diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index 4a0890cccf..4c90a95b56 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -21,18 +21,22 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "stdafx.h" #include "history.h" +#include "core/click_handler_types.h" #include "dialogs/dialogs_indexed_list.h" #include "ui/style.h" #include "lang.h" #include "mainwidget.h" #include "application.h" #include "fileuploader.h" -#include "window.h" +#include "mainwindow.h" #include "ui/filedialog.h" #include "boxes/addcontactbox.h" #include "boxes/confirmbox.h" #include "audio.h" #include "localstorage.h" +#include "apiwrap.h" +#include "window/top_bar_widget.h" +#include "playerwidget.h" namespace { diff --git a/Telegram/SourceFiles/history.h b/Telegram/SourceFiles/history.h index ce0d8aca7b..ab525f3cbf 100644 --- a/Telegram/SourceFiles/history.h +++ b/Telegram/SourceFiles/history.h @@ -2396,17 +2396,8 @@ void initImageLinkManager(); void reinitImageLinkManager(); void deinitImageLinkManager(); -struct LocationData { - LocationData(const LocationCoords &coords) : coords(coords), loading(false) { - } - - LocationCoords coords; - ImagePtr thumb; - bool loading; - - void load(); -}; - +struct LocationCoords; +struct LocationData; class LocationManager : public QObject { Q_OBJECT public: diff --git a/Telegram/SourceFiles/history/history_common.h b/Telegram/SourceFiles/history/history_common.h new file mode 100644 index 0000000000..f5e807d5bf --- /dev/null +++ b/Telegram/SourceFiles/history/history_common.h @@ -0,0 +1,28 @@ +/* +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. + +In addition, as a special exception, the copyright holders give permission +to link the code of portions of this program with the OpenSSL library. + +Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE +Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org +*/ +#pragma once + +enum DragState { + DragStateNone = 0x00, + DragStateFiles = 0x01, + DragStatePhotoFiles = 0x02, + DragStateImage = 0x03, +}; diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index bebe9f51b3..8d01e358d7 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -30,12 +30,15 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "lang.h" #include "application.h" #include "mainwidget.h" -#include "window.h" +#include "mainwindow.h" #include "passcodewidget.h" -#include "window.h" +#include "mainwindow.h" #include "fileuploader.h" #include "audio.h" #include "localstorage.h" +#include "apiwrap.h" +#include "window/top_bar_widget.h" +#include "playerwidget.h" // flick scroll taken from http://qt-project.org/doc/qt-4.8/demos-embedded-anomaly-src-flickcharm-cpp.html @@ -1489,7 +1492,7 @@ void HistoryInner::updateSize() { void HistoryInner::enterEvent(QEvent *e) { dragActionUpdate(QCursor::pos()); - return QWidget::enterEvent(e); +// return QWidget::enterEvent(e); } void HistoryInner::leaveEvent(QEvent *e) { @@ -1522,6 +1525,7 @@ void HistoryInner::adjustCurrent(int32 y) const { } void HistoryInner::adjustCurrent(int32 y, History *history) const { + t_assert(!history->isEmpty()); _curHistory = history; if (_curBlock >= history->blocks.size()) { _curBlock = history->blocks.size() - 1; @@ -5333,10 +5337,10 @@ void HistoryWidget::botCallbackDone(BotCallbackInfo info, const MTPmessages_BotC if (answerData.has_message()) { if (answerData.is_alert()) { Ui::showLayer(new InformBox(qs(answerData.vmessage))); - } else { + } else if (App::wnd()) { Ui::Toast::Config toast; toast.text = qs(answerData.vmessage); - Ui::Toast::Show(toast); + Ui::Toast::Show(App::wnd(), toast); } } } diff --git a/Telegram/SourceFiles/historywidget.h b/Telegram/SourceFiles/historywidget.h index 8e74a03572..99d07a0d97 100644 --- a/Telegram/SourceFiles/historywidget.h +++ b/Telegram/SourceFiles/historywidget.h @@ -22,15 +22,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "localimageloader.h" #include "ui/boxshadow.h" - #include "dropdown.h" - -enum DragState { - DragStateNone = 0x00, - DragStateFiles = 0x01, - DragStatePhotoFiles = 0x02, - DragStateImage = 0x03, -}; +#include "history/history_common.h" class HistoryWidget; class HistoryInner : public TWidget, public AbstractTooltipShower { diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp index 5eaf00f75d..1443e383ba 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp @@ -25,6 +25,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "localstorage.h" #include "mainwidget.h" #include "lang.h" +#include "playerwidget.h" namespace InlineBots { namespace Layout { diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp index 398bf3e532..af11f174f9 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp @@ -21,6 +21,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "stdafx.h" #include "inline_bots/inline_bot_layout_item.h" +#include "core/click_handler_types.h" #include "inline_bots/inline_bot_result.h" #include "inline_bots/inline_bot_layout_internal.h" #include "localstorage.h" diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_result.h b/Telegram/SourceFiles/inline_bots/inline_bot_result.h index 567339c1c2..cf98a37ff7 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_result.h +++ b/Telegram/SourceFiles/inline_bots/inline_bot_result.h @@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #pragma once -#include "basic_types.h" +#include "core/basic_types.h" #include "structs.h" #include "mtproto/core_types.h" diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_send_data.h b/Telegram/SourceFiles/inline_bots/inline_bot_send_data.h index 2030a01be5..031ee992e5 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_send_data.h +++ b/Telegram/SourceFiles/inline_bots/inline_bot_send_data.h @@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #pragma once -#include "basic_types.h" +#include "core/basic_types.h" #include "structs.h" #include "mtproto/core_types.h" diff --git a/Telegram/SourceFiles/intro/introwidget.cpp b/Telegram/SourceFiles/intro/introwidget.cpp index 5941b4899f..d79f80e0c0 100644 --- a/Telegram/SourceFiles/intro/introwidget.cpp +++ b/Telegram/SourceFiles/intro/introwidget.cpp @@ -31,7 +31,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "intro/introsignup.h" #include "intro/intropwdcheck.h" #include "mainwidget.h" -#include "window.h" +#include "mainwindow.h" #include "application.h" #include "ui/text.h" diff --git a/Telegram/SourceFiles/layerwidget.cpp b/Telegram/SourceFiles/layerwidget.cpp index 6f843db980..a649121556 100644 --- a/Telegram/SourceFiles/layerwidget.cpp +++ b/Telegram/SourceFiles/layerwidget.cpp @@ -23,7 +23,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "layerwidget.h" #include "application.h" -#include "window.h" +#include "mainwindow.h" #include "mainwidget.h" #include "ui/filedialog.h" diff --git a/Telegram/SourceFiles/layout.cpp b/Telegram/SourceFiles/layout.cpp index 746dbe5f83..a808b5d918 100644 --- a/Telegram/SourceFiles/layout.cpp +++ b/Telegram/SourceFiles/layout.cpp @@ -25,8 +25,9 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "mainwidget.h" #include "application.h" #include "fileuploader.h" -#include "window.h" +#include "mainwindow.h" #include "ui/filedialog.h" +#include "playerwidget.h" #include "boxes/addcontactbox.h" #include "boxes/confirmbox.h" @@ -216,1107 +217,3 @@ style::sprite documentCorner(int32 colorIndex) { RoundCorners documentCorners(int32 colorIndex) { return RoundCorners(DocBlueCorners + (colorIndex & 3)); } - -void LayoutMediaItemBase::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) { - App::hoveredLinkItem(active ? _parent : nullptr); - Ui::repaintHistoryItem(_parent); -} - -void LayoutMediaItemBase::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) { - App::pressedLinkItem(pressed ? _parent : nullptr); - Ui::repaintHistoryItem(_parent); -} - -void LayoutRadialProgressItem::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) { - if (p == _openl || p == _savel || p == _cancell) { - a_iconOver.start(active ? 1 : 0); - _a_iconOver.start(); - } - LayoutMediaItemBase::clickHandlerActiveChanged(p, active); -} - -void LayoutRadialProgressItem::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) { - LayoutMediaItemBase::clickHandlerPressedChanged(p, pressed); -} - -void LayoutRadialProgressItem::setLinks(ClickHandlerPtr &&openl, ClickHandlerPtr &&savel, ClickHandlerPtr &&cancell) { - _openl = std_::move(openl); - _savel = std_::move(savel); - _cancell = std_::move(cancell); -} - -void LayoutRadialProgressItem::step_iconOver(float64 ms, bool timer) { - float64 dt = ms / st::msgFileOverDuration; - if (dt >= 1) { - a_iconOver.finish(); - _a_iconOver.stop(); - } else if (!timer) { - a_iconOver.update(dt, anim::linear); - } - if (timer && iconAnimated()) { - Ui::repaintHistoryItem(_parent); - } -} - -void LayoutRadialProgressItem::step_radial(uint64 ms, bool timer) { - if (timer) { - Ui::repaintHistoryItem(_parent); - } else { - _radial->update(dataProgress(), dataFinished(), ms); - if (!_radial->animating()) { - checkRadialFinished(); - } - } -} - -void LayoutRadialProgressItem::ensureRadial() const { - if (!_radial) { - _radial = new RadialAnimation(animation(const_cast(this), &LayoutRadialProgressItem::step_radial)); - } -} - -void LayoutRadialProgressItem::checkRadialFinished() { - if (_radial && !_radial->animating() && dataLoaded()) { - delete _radial; - _radial = 0; - } -} - -LayoutRadialProgressItem::~LayoutRadialProgressItem() { - deleteAndMark(_radial); -} - -void LayoutAbstractFileItem::setStatusSize(int32 newSize, int32 fullSize, int32 duration, qint64 realDuration) const { - _statusSize = newSize; - if (_statusSize == FileStatusSizeReady) { - _statusText = (duration >= 0) ? formatDurationAndSizeText(duration, fullSize) : (duration < -1 ? formatGifAndSizeText(fullSize) : formatSizeText(fullSize)); - } else if (_statusSize == FileStatusSizeLoaded) { - _statusText = (duration >= 0) ? formatDurationText(duration) : (duration < -1 ? qsl("GIF") : formatSizeText(fullSize)); - } else if (_statusSize == FileStatusSizeFailed) { - _statusText = lang(lng_attach_failed); - } else if (_statusSize >= 0) { - _statusText = formatDownloadText(_statusSize, fullSize); - } else { - _statusText = formatPlayedText(-_statusSize - 1, realDuration); - } -} - -LayoutOverviewDate::LayoutOverviewDate(const QDate &date, bool month) -: _date(date) -, _text(month ? langMonthFull(date) : langDayOfMonthFull(date)) { - AddComponents(OverviewItemInfo::Bit()); -} - -void LayoutOverviewDate::initDimensions() { - _maxw = st::normalFont->width(_text); - _minh = st::linksDateMargin.top() + st::normalFont->height + st::linksDateMargin.bottom() + st::linksBorder; -} - -void LayoutOverviewDate::paint(Painter &p, const QRect &clip, uint32 selection, const PaintContextOverview *context) const { - if (clip.intersects(QRect(0, st::linksDateMargin.top(), _width, st::normalFont->height))) { - p.setPen(st::linksDateColor); - p.setFont(st::semiboldFont); - p.drawTextLeft(0, st::linksDateMargin.top(), _width, _text); - } -} - -LayoutOverviewPhoto::LayoutOverviewPhoto(PhotoData *photo, HistoryItem *parent) : LayoutMediaItemBase(parent) -, _data(photo) -, _link(new PhotoOpenClickHandler(photo)) -, _goodLoaded(false) { - -} - -void LayoutOverviewPhoto::initDimensions() { - _maxw = 2 * st::overviewPhotoMinSize; - _minh = _maxw; -} - -int32 LayoutOverviewPhoto::resizeGetHeight(int32 width) { - width = qMin(width, _maxw); - if (width != _width || width != _height) { - _width = qMin(width, _maxw); - _height = _width; - } - return _height; -} - -void LayoutOverviewPhoto::paint(Painter &p, const QRect &clip, uint32 selection, const PaintContextOverview *context) const { - bool good = _data->loaded(); - if (!good) { - _data->medium->automaticLoad(_parent); - good = _data->medium->loaded(); - } - if ((good && !_goodLoaded) || _pix.width() != _width * cIntRetinaFactor()) { - _goodLoaded = good; - - int32 size = _width * cIntRetinaFactor(); - if (_goodLoaded || _data->thumb->loaded()) { - QImage img = (_data->loaded() ? _data->full : (_data->medium->loaded() ? _data->medium : _data->thumb))->pix().toImage(); - if (!_goodLoaded) { - img = imageBlur(img); - } - if (img.width() == img.height()) { - if (img.width() != size) { - img = img.scaled(size, size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); - } - } else if (img.width() > img.height()) { - img = img.copy((img.width() - img.height()) / 2, 0, img.height(), img.height()).scaled(size, size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); - } else { - img = img.copy(0, (img.height() - img.width()) / 2, img.width(), img.width()).scaled(size, size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); - } - img.setDevicePixelRatio(cRetinaFactor()); - _data->forget(); - - _pix = QPixmap::fromImage(img, Qt::ColorOnly); - } else if (!_pix.isNull()) { - _pix = QPixmap(); - } - } - - if (_pix.isNull()) { - p.fillRect(0, 0, _width, _height, st::overviewPhotoBg); - } else { - p.drawPixmap(0, 0, _pix); - } - - if (selection == FullSelection) { - p.fillRect(QRect(0, 0, _width, _height), st::overviewPhotoSelectOverlay); - p.drawSprite(QPoint(rtl() ? 0 : (_width - st::overviewPhotoChecked.pxWidth()), _height - st::overviewPhotoChecked.pxHeight()), st::overviewPhotoChecked); - } else if (context->selecting) { - p.drawSprite(QPoint(rtl() ? 0 : (_width - st::overviewPhotoCheck.pxWidth()), _height - st::overviewPhotoCheck.pxHeight()), st::overviewPhotoCheck); - } -} - -void LayoutOverviewPhoto::getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int x, int y) const { - if (hasPoint(x, y)) { - link = _link; - } -} - -LayoutOverviewVideo::LayoutOverviewVideo(DocumentData *video, HistoryItem *parent) : LayoutAbstractFileItem(parent) -, _data(video) -, _duration(formatDurationText(_data->duration())) -, _thumbLoaded(false) { - setDocumentLinks(_data); -} - -void LayoutOverviewVideo::initDimensions() { - _maxw = 2 * st::minPhotoSize; - _minh = _maxw; -} - -int32 LayoutOverviewVideo::resizeGetHeight(int32 width) { - _width = qMin(width, _maxw); - _height = _width; - return _height; -} - -void LayoutOverviewVideo::paint(Painter &p, const QRect &clip, uint32 selection, const PaintContextOverview *context) const { - bool selected = (selection == FullSelection), thumbLoaded = _data->thumb->loaded(); - - _data->automaticLoad(_parent); - bool loaded = _data->loaded(), displayLoading = _data->displayLoading(); - if (displayLoading) { - ensureRadial(); - if (!_radial->animating()) { - _radial->start(_data->progress()); - } - } - updateStatusText(); - bool radial = isRadialAnimation(context->ms); - - if ((thumbLoaded && !_thumbLoaded) || (_pix.width() != _width * cIntRetinaFactor())) { - _thumbLoaded = thumbLoaded; - - if (_thumbLoaded && !_data->thumb->isNull()) { - int32 size = _width * cIntRetinaFactor(); - QImage img = imageBlur(_data->thumb->pix().toImage()); - if (img.width() == img.height()) { - if (img.width() != size) { - img = img.scaled(size, size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); - } - } else if (img.width() > img.height()) { - img = img.copy((img.width() - img.height()) / 2, 0, img.height(), img.height()).scaled(size, size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); - } else { - img = img.copy(0, (img.height() - img.width()) / 2, img.width(), img.width()).scaled(size, size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); - } - img.setDevicePixelRatio(cRetinaFactor()); - _data->forget(); - - _pix = QPixmap::fromImage(img, Qt::ColorOnly); - } else if (!_pix.isNull()) { - _pix = QPixmap(); - } - } - - if (_pix.isNull()) { - p.fillRect(0, 0, _width, _height, st::overviewPhotoBg); - } else { - p.drawPixmap(0, 0, _pix); - } - - if (selected) { - p.fillRect(QRect(0, 0, _width, _height), st::overviewPhotoSelectOverlay); - } - - if (!selected && !context->selecting && !loaded) { - if (clip.intersects(QRect(0, _height - st::normalFont->height, _width, st::normalFont->height))) { - int32 statusX = st::msgDateImgPadding.x(), statusY = _height - st::normalFont->height - st::msgDateImgPadding.y(); - int32 statusW = st::normalFont->width(_statusText) + 2 * st::msgDateImgPadding.x(); - int32 statusH = st::normalFont->height + 2 * st::msgDateImgPadding.y(); - statusX = _width - statusW + statusX; - p.fillRect(rtlrect(statusX - st::msgDateImgPadding.x(), statusY - st::msgDateImgPadding.y(), statusW, statusH, _width), selected ? st::msgDateImgBgSelected : st::msgDateImgBg); - p.setFont(st::normalFont); - p.setPen(st::white); - p.drawTextLeft(statusX, statusY, _width, _statusText, statusW - 2 * st::msgDateImgPadding.x()); - } - } - if (clip.intersects(QRect(0, 0, _width, st::normalFont->height))) { - int32 statusX = st::msgDateImgPadding.x(), statusY = st::msgDateImgPadding.y(); - int32 statusW = st::normalFont->width(_duration) + 2 * st::msgDateImgPadding.x(); - int32 statusH = st::normalFont->height + 2 * st::msgDateImgPadding.y(); - p.fillRect(rtlrect(statusX - st::msgDateImgPadding.x(), statusY - st::msgDateImgPadding.y(), statusW, statusH, _width), selected ? st::msgDateImgBgSelected : st::msgDateImgBg); - p.setFont(st::normalFont); - p.setPen(st::white); - p.drawTextLeft(statusX, statusY, _width, _duration, statusW - 2 * st::msgDateImgPadding.x()); - } - - QRect inner((_width - st::msgFileSize) / 2, (_height - st::msgFileSize) / 2, st::msgFileSize, st::msgFileSize); - if (clip.intersects(inner)) { - p.setPen(Qt::NoPen); - if (selected) { - p.setBrush(st::msgDateImgBgSelected); - } else if (_a_iconOver.animating()) { - _a_iconOver.step(context->ms); - float64 over = a_iconOver.current(); - p.setOpacity((st::msgDateImgBg->c.alphaF() * (1 - over)) + (st::msgDateImgBgOver->c.alphaF() * over)); - p.setBrush(st::black); - } else { - bool over = ClickHandler::showAsActive(loaded ? _openl : (_data->loading() ? _cancell : _savel)); - p.setBrush(over ? st::msgDateImgBgOver : st::msgDateImgBg); - } - - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(inner); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); - - p.setOpacity((radial && loaded) ? _radial->opacity() : 1); - style::sprite icon; - if (radial) { - icon = (selected ? st::msgFileInCancelSelected : st::msgFileInCancel); - } else if (loaded) { - icon = (selected ? st::msgFileInPlaySelected : st::msgFileInPlay); - } else { - icon = (selected ? st::msgFileInDownloadSelected : st::msgFileInDownload); - } - p.drawSpriteCenter(inner, icon); - if (radial) { - p.setOpacity(1); - QRect rinner(inner.marginsRemoved(QMargins(st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine))); - _radial->draw(p, rinner, st::msgFileRadialLine, selected ? st::msgInBgSelected : st::msgInBg); - } - } - - if (selected) { - p.drawSprite(QPoint(rtl() ? 0 : (_width - st::overviewPhotoChecked.pxWidth()), _height - st::overviewPhotoChecked.pxHeight()), st::overviewPhotoChecked); - } else if (context->selecting) { - p.drawSprite(QPoint(rtl() ? 0 : (_width - st::overviewPhotoCheck.pxWidth()), _height - st::overviewPhotoCheck.pxHeight()), st::overviewPhotoCheck); - } -} - -void LayoutOverviewVideo::getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int x, int y) const { - bool loaded = _data->loaded(); - - if (hasPoint(x, y)) { - link = loaded ? _openl : (_data->loading() ? _cancell : _savel); - } -} - -void LayoutOverviewVideo::updateStatusText() const { - bool showPause = false; - int32 statusSize = 0; - if (_data->status == FileDownloadFailed || _data->status == FileUploadFailed) { - statusSize = FileStatusSizeFailed; - } else if (_data->status == FileUploading) { - statusSize = _data->uploadOffset; - } else if (_data->loading()) { - statusSize = _data->loadOffset(); - } else if (_data->loaded()) { - statusSize = FileStatusSizeLoaded; - } else { - statusSize = FileStatusSizeReady; - } - if (statusSize != _statusSize) { - int32 status = statusSize, size = _data->size; - if (statusSize >= 0 && statusSize < 0x7F000000) { - size = status; - status = FileStatusSizeReady; - } - setStatusSize(status, size, -1, 0); - _statusSize = statusSize; - } -} - -LayoutOverviewVoice::LayoutOverviewVoice(DocumentData *voice, HistoryItem *parent) : LayoutAbstractFileItem(parent) -, _data(voice) -, _namel(new DocumentOpenClickHandler(_data)) { - AddComponents(OverviewItemInfo::Bit()); - - t_assert(_data->voice() != 0); - - setDocumentLinks(_data); - - updateName(); - QString d = textcmdLink(1, textRichPrepare(langDateTime(date(_data->date)))); - TextParseOptions opts = { TextParseRichText, 0, 0, Qt::LayoutDirectionAuto }; - _details.setText(st::normalFont, lng_date_and_duration(lt_date, d, lt_duration, formatDurationText(_data->voice()->duration)), opts); - _details.setLink(1, MakeShared(parent)); -} - -void LayoutOverviewVoice::initDimensions() { - _maxw = st::profileMaxWidth; - _minh = st::msgFilePadding.top() + st::msgFileSize + st::msgFilePadding.bottom() + st::lineWidth; -} - -void LayoutOverviewVoice::paint(Painter &p, const QRect &clip, uint32 selection, const PaintContextOverview *context) const { - bool selected = (selection == FullSelection); - - _data->automaticLoad(_parent); - bool loaded = _data->loaded(), displayLoading = _data->displayLoading(); - - if (displayLoading) { - ensureRadial(); - if (!_radial->animating()) { - _radial->start(_data->progress()); - } - } - bool showPause = updateStatusText(); - int32 nameVersion = _parent->fromOriginal()->nameVersion; - if (nameVersion > _nameVersion) { - updateName(); - } - bool radial = isRadialAnimation(context->ms); - - int32 nameleft = 0, nametop = 0, nameright = 0, statustop = 0, datetop = -1; - - nameleft = st::msgFilePadding.left() + st::msgFileSize + st::msgFilePadding.right(); - nameright = st::msgFilePadding.left(); - nametop = st::msgFileNameTop; - statustop = st::msgFileStatusTop; - - if (selected) { - p.fillRect(clip.intersected(QRect(0, 0, _width, _height)), st::msgInBgSelected); - } - - QRect inner(rtlrect(st::msgFilePadding.left(), st::msgFilePadding.top(), st::msgFileSize, st::msgFileSize, _width)); - if (clip.intersects(inner)) { - p.setPen(Qt::NoPen); - if (selected) { - p.setBrush(st::msgFileInBgSelected); - } else if (_a_iconOver.animating()) { - _a_iconOver.step(context->ms); - float64 over = a_iconOver.current(); - p.setBrush(style::interpolate(st::msgFileInBg, st::msgFileInBgOver, over)); - } else { - bool over = ClickHandler::showAsActive(loaded ? _openl : (_data->loading() ? _cancell : _openl)); - p.setBrush(over ? st::msgFileInBgOver : st::msgFileInBg); - } - - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(inner); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); - - if (radial) { - QRect rinner(inner.marginsRemoved(QMargins(st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine))); - style::color bg(selected ? st::msgInBgSelected : st::msgInBg); - _radial->draw(p, rinner, st::msgFileRadialLine, bg); - } - - style::sprite icon; - if (showPause) { - icon = selected ? st::msgFileInPauseSelected : st::msgFileInPause; - } else if (_statusSize < 0 || _statusSize == FileStatusSizeLoaded) { - icon = selected ? st::msgFileInPlaySelected : st::msgFileInPlay; - } else if (_data->loading()) { - icon = selected ? st::msgFileInCancelSelected : st::msgFileInCancel; - } else { - icon = selected ? st::msgFileInDownloadSelected : st::msgFileInDownload; - } - p.drawSpriteCenter(inner, icon); - } - - int32 namewidth = _width - nameleft - nameright; - - if (clip.intersects(rtlrect(nameleft, nametop, namewidth, st::semiboldFont->height, _width))) { - p.setPen(st::black); - _name.drawLeftElided(p, nameleft, nametop, namewidth, _width); - } - - if (clip.intersects(rtlrect(nameleft, statustop, namewidth, st::normalFont->height, _width))) { - p.setFont(st::normalFont); - p.setPen(selected ? st::mediaInFgSelected : st::mediaInFg); - int32 unreadx = nameleft; - if (_statusSize == FileStatusSizeLoaded || _statusSize == FileStatusSizeReady) { - textstyleSet(&(selected ? st::mediaInStyleSelected : st::mediaInStyle)); - _details.drawLeftElided(p, nameleft, statustop, namewidth, _width); - textstyleRestore(); - unreadx += _details.maxWidth(); - } else { - int32 statusw = st::normalFont->width(_statusText); - p.drawTextLeft(nameleft, statustop, _width, _statusText, statusw); - unreadx += statusw; - } - if (_parent->isMediaUnread() && unreadx + st::mediaUnreadSkip + st::mediaUnreadSize <= _width) { - p.setPen(Qt::NoPen); - p.setBrush(selected ? st::msgFileInBgSelected : st::msgFileInBg); - - p.setRenderHint(QPainter::HighQualityAntialiasing, true); - p.drawEllipse(rtlrect(unreadx + st::mediaUnreadSkip, statustop + st::mediaUnreadTop, st::mediaUnreadSize, st::mediaUnreadSize, _width)); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); - } - } -} - -void LayoutOverviewVoice::getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int x, int y) const { - bool loaded = _data->loaded(); - - bool showPause = updateStatusText(); - - int32 nameleft = 0, nametop = 0, nameright = 0, statustop = 0, datetop = 0; - - nameleft = st::msgFilePadding.left() + st::msgFileSize + st::msgFilePadding.right(); - nameright = st::msgFilePadding.left(); - nametop = st::msgFileNameTop; - statustop = st::msgFileStatusTop; - - QRect inner(rtlrect(st::msgFilePadding.left(), st::msgFilePadding.top(), st::msgFileSize, st::msgFileSize, _width)); - if (inner.contains(x, y)) { - link = loaded ? _openl : ((_data->loading() || _data->status == FileUploading) ? _cancell : _openl); - return; - } - if (rtlrect(nameleft, statustop, _width - nameleft - nameright, st::normalFont->height, _width).contains(x, y)) { - if (_statusSize == FileStatusSizeLoaded || _statusSize == FileStatusSizeReady) { - bool inText = false; - _details.getStateLeft(link, inText, x - nameleft, y - statustop, _width, _width); - cursor = inText ? HistoryInTextCursorState : HistoryDefaultCursorState; - } - } - if (hasPoint(x, y) && !link && !_data->loading()) { - link = _namel; - return; - } -} - -void LayoutOverviewVoice::updateName() const { - int32 version = 0; - if (const HistoryMessageForwarded *fwd = _parent->Get()) { - if (_parent->fromOriginal()->isChannel()) { - _name.setText(st::semiboldFont, lng_forwarded_channel(lt_channel, App::peerName(_parent->fromOriginal())), _textNameOptions); - } else { - _name.setText(st::semiboldFont, lng_forwarded(lt_user, App::peerName(_parent->fromOriginal())), _textNameOptions); - } - } else { - _name.setText(st::semiboldFont, App::peerName(_parent->from()), _textNameOptions); - } - version = _parent->fromOriginal()->nameVersion; - _nameVersion = version; -} - -bool LayoutOverviewVoice::updateStatusText() const { - bool showPause = false; - int32 statusSize = 0, realDuration = 0; - if (_data->status == FileDownloadFailed || _data->status == FileUploadFailed) { - statusSize = FileStatusSizeFailed; - } else if (_data->loaded()) { - AudioMsgId playing; - AudioPlayerState playingState = AudioPlayerStopped; - int64 playingPosition = 0, playingDuration = 0; - int32 playingFrequency = 0; - if (audioPlayer()) { - audioPlayer()->currentState(&playing, &playingState, &playingPosition, &playingDuration, &playingFrequency); - } - - if (playing == AudioMsgId(_data, _parent->fullId()) && !(playingState & AudioPlayerStoppedMask) && playingState != AudioPlayerFinishing) { - statusSize = -1 - (playingPosition / (playingFrequency ? playingFrequency : AudioVoiceMsgFrequency)); - realDuration = playingDuration / (playingFrequency ? playingFrequency : AudioVoiceMsgFrequency); - showPause = (playingState == AudioPlayerPlaying || playingState == AudioPlayerResuming || playingState == AudioPlayerStarting); - } else { - statusSize = FileStatusSizeLoaded; - } - } else { - statusSize = FileStatusSizeReady; - } - if (statusSize != _statusSize) { - setStatusSize(statusSize, _data->size, _data->voice()->duration, realDuration); - } - return showPause; -} - -LayoutOverviewDocument::LayoutOverviewDocument(DocumentData *document, HistoryItem *parent) : LayoutAbstractFileItem(parent) -, _data(document) -, _msgl(new GoToMessageClickHandler(parent)) -, _namel(new DocumentOpenClickHandler(_data)) -, _thumbForLoaded(false) -, _name(documentName(_data)) -, _date(langDateTime(date(_data->date))) -, _namew(st::semiboldFont->width(_name)) -, _datew(st::normalFont->width(_date)) -, _colorIndex(documentColorIndex(_data, _ext)) { - AddComponents(OverviewItemInfo::Bit()); - - setDocumentLinks(_data); - - setStatusSize(FileStatusSizeReady, _data->size, _data->song() ? _data->song()->duration : -1, 0); - - if (withThumb()) { - _data->thumb->load(); - int32 tw = convertScale(_data->thumb->width()), th = convertScale(_data->thumb->height()); - if (tw > th) { - _thumbw = (tw * st::overviewFileSize) / th; - } else { - _thumbw = st::overviewFileSize; - } - } else { - _thumbw = 0; - } - - _extw = st::overviewFileExtFont->width(_ext); - if (_extw > st::overviewFileSize - st::overviewFileExtPadding * 2) { - _ext = st::overviewFileExtFont->elided(_ext, st::overviewFileSize - st::overviewFileExtPadding * 2, Qt::ElideMiddle); - _extw = st::overviewFileExtFont->width(_ext); - } -} - -void LayoutOverviewDocument::initDimensions() { - _maxw = st::profileMaxWidth; - if (_data->song()) { - _minh = st::msgFilePadding.top() + st::msgFileSize + st::msgFilePadding.bottom(); - } else { - _minh = st::overviewFilePadding.top() + st::overviewFileSize + st::overviewFilePadding.bottom() + st::lineWidth; - } -} - -void LayoutOverviewDocument::paint(Painter &p, const QRect &clip, uint32 selection, const PaintContextOverview *context) const { - bool selected = (selection == FullSelection); - - _data->automaticLoad(_parent); - bool loaded = _data->loaded() || Local::willStickerImageLoad(_data->mediaKey()), displayLoading = _data->displayLoading(); - - if (displayLoading) { - ensureRadial(); - if (!_radial->animating()) { - _radial->start(_data->progress()); - } - } - bool showPause = updateStatusText(); - bool radial = isRadialAnimation(context->ms); - - int32 nameleft = 0, nametop = 0, nameright = 0, statustop = 0, datetop = -1; - bool wthumb = withThumb(); - - if (_data->song()) { - nameleft = st::msgFilePadding.left() + st::msgFileSize + st::msgFilePadding.right(); - nameright = st::msgFilePadding.left(); - nametop = st::msgFileNameTop; - statustop = st::msgFileStatusTop; - - if (selected) { - p.fillRect(QRect(0, 0, _width, _height), st::msgInBgSelected); - } - - QRect inner(rtlrect(st::msgFilePadding.left(), st::msgFilePadding.top(), st::msgFileSize, st::msgFileSize, _width)); - if (clip.intersects(inner)) { - p.setPen(Qt::NoPen); - if (selected) { - p.setBrush(st::msgFileInBgSelected); - } else if (_a_iconOver.animating()) { - _a_iconOver.step(context->ms); - float64 over = a_iconOver.current(); - p.setBrush(style::interpolate(st::msgFileInBg, st::msgFileInBgOver, over)); - } else { - bool over = ClickHandler::showAsActive(loaded ? _openl : (_data->loading() ? _cancell : _openl)); - p.setBrush(over ? st::msgFileInBgOver : st::msgFileInBg); - } - - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(inner); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); - - if (radial) { - QRect rinner(inner.marginsRemoved(QMargins(st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine))); - style::color bg(selected ? st::msgInBgSelected : st::msgInBg); - _radial->draw(p, rinner, st::msgFileRadialLine, bg); - } - - style::sprite icon; - if (showPause) { - icon = selected ? st::msgFileInPauseSelected : st::msgFileInPause; - } else if (loaded) { - icon = selected ? st::msgFileInPlaySelected : st::msgFileInPlay; - } else if (_data->loading()) { - icon = selected ? st::msgFileInCancelSelected : st::msgFileInCancel; - } else { - icon = selected ? st::msgFileInDownloadSelected : st::msgFileInDownload; - } - p.drawSpriteCenter(inner, icon); - } - } else { - nameleft = st::overviewFileSize + st::overviewFilePadding.right(); - nametop = st::linksBorder + st::overviewFileNameTop; - statustop = st::linksBorder + st::overviewFileStatusTop; - datetop = st::linksBorder + st::overviewFileDateTop; - - QRect border(rtlrect(nameleft, 0, _width - nameleft, st::linksBorder, _width)); - if (!context->isAfterDate && clip.intersects(border)) { - p.fillRect(clip.intersected(border), st::linksBorderFg); - } - - QRect rthumb(rtlrect(0, st::linksBorder + st::overviewFilePadding.top(), st::overviewFileSize, st::overviewFileSize, _width)); - if (clip.intersects(rthumb)) { - if (wthumb) { - if (_data->thumb->loaded()) { - if (_thumb.isNull() || loaded != _thumbForLoaded) { - _thumbForLoaded = loaded; - ImagePixOptions options = ImagePixSmooth; - if (!_thumbForLoaded) options |= ImagePixBlurred; - _thumb = _data->thumb->pixNoCache(_thumbw, 0, options, st::overviewFileSize, st::overviewFileSize); - } - p.drawPixmap(rthumb.topLeft(), _thumb); - } else { - p.fillRect(rthumb, st::black); - } - } else { - p.fillRect(rthumb, documentColor(_colorIndex)); - if (!radial && loaded && !_ext.isEmpty()) { - p.setFont(st::overviewFileExtFont); - p.setPen(st::white); - p.drawText(rthumb.left() + (rthumb.width() - _extw) / 2, rthumb.top() + st::overviewFileExtTop + st::overviewFileExtFont->ascent, _ext); - } - } - if (selected) { - p.fillRect(rthumb, textstyleCurrent()->selectOverlay); - } - - if (radial || (!loaded && !_data->loading())) { - QRect inner(rthumb.x() + (rthumb.width() - st::msgFileSize) / 2, rthumb.y() + (rthumb.height() - st::msgFileSize) / 2, st::msgFileSize, st::msgFileSize); - if (clip.intersects(inner)) { - float64 radialOpacity = (radial && loaded && !_data->uploading()) ? _radial->opacity() : 1; - p.setPen(Qt::NoPen); - if (selected) { - p.setBrush(wthumb ? st::msgDateImgBgSelected : documentSelectedColor(_colorIndex)); - } else if (_a_iconOver.animating()) { - _a_iconOver.step(context->ms); - float64 over = a_iconOver.current(); - if (wthumb) { - p.setOpacity((st::msgDateImgBg->c.alphaF() * (1 - over)) + (st::msgDateImgBgOver->c.alphaF() * over)); - p.setBrush(st::black); - } else { - p.setBrush(style::interpolate(documentDarkColor(_colorIndex), documentOverColor(_colorIndex), over)); - } - } else { - bool over = ClickHandler::showAsActive(_data->loading() ? _cancell : _savel); - p.setBrush(over ? (wthumb ? st::msgDateImgBgOver : documentOverColor(_colorIndex)) : (wthumb ? st::msgDateImgBg : documentDarkColor(_colorIndex))); - } - p.setOpacity(radialOpacity * p.opacity()); - - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(inner); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); - - p.setOpacity(radialOpacity); - style::sprite icon; - if (loaded || _data->loading()) { - icon = (selected ? st::msgFileInCancelSelected : st::msgFileInCancel); - } else { - icon = (selected ? st::msgFileInDownloadSelected : st::msgFileInDownload); - } - p.drawSpriteCenter(inner, icon); - if (radial) { - p.setOpacity(1); - - QRect rinner(inner.marginsRemoved(QMargins(st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine))); - _radial->draw(p, rinner, st::msgFileRadialLine, selected ? st::msgInBgSelected : st::msgInBg); - } - } - } - if (selected || context->selecting) { - QRect check(rthumb.topLeft() + QPoint(rtl() ? 0 : (rthumb.width() - st::defaultCheckbox.diameter), rthumb.height() - st::defaultCheckbox.diameter), QSize(st::defaultCheckbox.diameter, st::defaultCheckbox.diameter)); - p.fillRect(check, selected ? st::overviewFileChecked : st::overviewFileCheck); - p.drawSpriteCenter(check, st::defaultCheckbox.checkIcon); - } - } - } - - int32 namewidth = _width - nameleft - nameright; - - if (clip.intersects(rtlrect(nameleft, nametop, qMin(namewidth, _namew), st::semiboldFont->height, _width))) { - p.setFont(st::semiboldFont); - p.setPen(st::black); - if (namewidth < _namew) { - p.drawTextLeft(nameleft, nametop, _width, st::semiboldFont->elided(_name, namewidth)); - } else { - p.drawTextLeft(nameleft, nametop, _width, _name, _namew); - } - } - - if (clip.intersects(rtlrect(nameleft, statustop, namewidth, st::normalFont->height, _width))) { - p.setFont(st::normalFont); - p.setPen(st::mediaInFg); - p.drawTextLeft(nameleft, statustop, _width, _statusText); - } - if (datetop >= 0 && clip.intersects(rtlrect(nameleft, datetop, _datew, st::normalFont->height, _width))) { - p.setFont(ClickHandler::showAsActive(_msgl) ? st::normalFont->underline() : st::normalFont); - p.setPen(st::mediaInFg); - p.drawTextLeft(nameleft, datetop, _width, _date, _datew); - } -} - -void LayoutOverviewDocument::getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int x, int y) const { - bool loaded = _data->loaded() || Local::willStickerImageLoad(_data->mediaKey()); - - bool showPause = updateStatusText(); - - int32 nameleft = 0, nametop = 0, nameright = 0, statustop = 0, datetop = 0; - bool wthumb = withThumb(); - - if (_data->song()) { - nameleft = st::msgFilePadding.left() + st::msgFileSize + st::msgFilePadding.right(); - nameright = st::msgFilePadding.left(); - nametop = st::msgFileNameTop; - statustop = st::msgFileStatusTop; - - QRect inner(rtlrect(st::msgFilePadding.left(), st::msgFilePadding.top(), st::msgFileSize, st::msgFileSize, _width)); - if (inner.contains(x, y)) { - link = loaded ? _openl : ((_data->loading() || _data->status == FileUploading) ? _cancell : _openl); - return; - } - if (hasPoint(x, y) && !_data->loading()) { - link = _namel; - return; - } - } else { - nameleft = st::overviewFileSize + st::overviewFilePadding.right(); - nametop = st::linksBorder + st::overviewFileNameTop; - statustop = st::linksBorder + st::overviewFileStatusTop; - datetop = st::linksBorder + st::overviewFileDateTop; - - QRect rthumb(rtlrect(0, st::linksBorder + st::overviewFilePadding.top(), st::overviewFileSize, st::overviewFileSize, _width)); - - if (rthumb.contains(x, y)) { - link = loaded ? _openl : ((_data->loading() || _data->status == FileUploading) ? _cancell : _savel); - return; - } - - if (_data->status != FileUploadFailed) { - if (rtlrect(nameleft, datetop, _datew, st::normalFont->height, _width).contains(x, y)) { - link = _msgl; - return; - } - } - if (!_data->loading() && _data->isValid()) { - if (loaded && rtlrect(0, st::linksBorder, nameleft, _height - st::linksBorder, _width).contains(x, y)) { - link = _namel; - return; - } - if (rtlrect(nameleft, nametop, qMin(_width - nameleft - nameright, _namew), st::semiboldFont->height, _width).contains(x, y)) { - link = _namel; - return; - } - } - } -} - -bool LayoutOverviewDocument::updateStatusText() const { - bool showPause = false; - int32 statusSize = 0, realDuration = 0; - if (_data->status == FileDownloadFailed || _data->status == FileUploadFailed) { - statusSize = FileStatusSizeFailed; - } else if (_data->status == FileUploading) { - statusSize = _data->uploadOffset; - } else if (_data->loading()) { - statusSize = _data->loadOffset(); - } else if (_data->loaded()) { - if (_data->song()) { - SongMsgId playing; - AudioPlayerState playingState = AudioPlayerStopped; - int64 playingPosition = 0, playingDuration = 0; - int32 playingFrequency = 0; - if (audioPlayer()) { - audioPlayer()->currentState(&playing, &playingState, &playingPosition, &playingDuration, &playingFrequency); - } - - if (playing == SongMsgId(_data, _parent->fullId()) && !(playingState & AudioPlayerStoppedMask) && playingState != AudioPlayerFinishing) { - statusSize = -1 - (playingPosition / (playingFrequency ? playingFrequency : AudioVoiceMsgFrequency)); - realDuration = playingDuration / (playingFrequency ? playingFrequency : AudioVoiceMsgFrequency); - showPause = (playingState == AudioPlayerPlaying || playingState == AudioPlayerResuming || playingState == AudioPlayerStarting); - } else { - statusSize = FileStatusSizeLoaded; - } - if (!showPause && (playing == SongMsgId(_data, _parent->fullId())) && App::main() && App::main()->player()->seekingSong(playing)) { - showPause = true; - } - } else { - statusSize = FileStatusSizeLoaded; - } - } else { - statusSize = FileStatusSizeReady; - } - if (statusSize != _statusSize) { - setStatusSize(statusSize, _data->size, _data->song() ? _data->song()->duration : -1, realDuration); - } - return showPause; -} - -LayoutOverviewLink::LayoutOverviewLink(HistoryMedia *media, HistoryItem *parent) : LayoutMediaItemBase(parent) { - AddComponents(OverviewItemInfo::Bit()); - - QString text = _parent->originalText(); - EntitiesInText entities = _parent->originalEntities(); - - int32 from = 0, till = text.size(), lnk = entities.size(); - for (int32 i = 0; i < lnk; ++i) { - if (entities[i].type != EntityInTextUrl && entities[i].type != EntityInTextCustomUrl && entities[i].type != EntityInTextEmail) { - continue; - } - QString u = entities[i].text, t = text.mid(entities[i].offset, entities[i].length); - _links.push_back(Link(u.isEmpty() ? t : u, t)); - } - while (lnk > 0 && till > from) { - --lnk; - if (entities[lnk].type != EntityInTextUrl && entities[lnk].type != EntityInTextCustomUrl && entities[lnk].type != EntityInTextEmail) { - ++lnk; - break; - } - int32 afterLinkStart = entities[lnk].offset + entities[lnk].length; - if (till > afterLinkStart) { - if (!QRegularExpression(qsl("^[,.\\s_=+\\-;:`'\"\\(\\)\\[\\]\\{\\}<>*&^%\\$#@!\\\\/]+$")).match(text.mid(afterLinkStart, till - afterLinkStart)).hasMatch()) { - ++lnk; - break; - } - } - till = entities[lnk].offset; - } - if (!lnk) { - if (QRegularExpression(qsl("^[,.\\s\\-;:`'\"\\(\\)\\[\\]\\{\\}<>*&^%\\$#@!\\\\/]+$")).match(text.mid(from, till - from)).hasMatch()) { - till = from; - } - } - - _page = (media && media->type() == MediaTypeWebPage) ? static_cast(media)->webpage() : 0; - if (_page) { - if (_page->document) { - _photol.reset(new DocumentOpenClickHandler(_page->document)); - } else if (_page->photo) { - if (_page->type == WebPageProfile || _page->type == WebPageVideo) { - _photol = MakeShared(_page->url); - } else if (_page->type == WebPagePhoto || _page->siteName == qstr("Twitter") || _page->siteName == qstr("Facebook")) { - _photol.reset(new PhotoOpenClickHandler(_page->photo)); - } else { - _photol = MakeShared(_page->url); - } - } else { - _photol = MakeShared(_page->url); - } - } else if (!_links.isEmpty()) { - _photol = MakeShared(_links.front().lnk->text()); - } - if (from >= till && _page) { - text = _page->description; - from = 0; - till = text.size(); - } - if (till > from) { - TextParseOptions opts = { TextParseMultiline, int32(st::linksMaxWidth), 3 * st::normalFont->height, Qt::LayoutDirectionAuto }; - _text.setText(st::normalFont, text.mid(from, till - from), opts); - } - int32 tw = 0, th = 0; - if (_page && _page->photo) { - if (!_page->photo->loaded()) _page->photo->thumb->load(false, false); - - tw = convertScale(_page->photo->thumb->width()); - th = convertScale(_page->photo->thumb->height()); - } else if (_page && _page->document) { - if (!_page->document->thumb->loaded()) _page->document->thumb->load(false, false); - - tw = convertScale(_page->document->thumb->width()); - th = convertScale(_page->document->thumb->height()); - } - if (tw > st::dlgPhotoSize) { - if (th > tw) { - th = th * st::dlgPhotoSize / tw; - tw = st::dlgPhotoSize; - } else if (th > st::dlgPhotoSize) { - tw = tw * st::dlgPhotoSize / th; - th = st::dlgPhotoSize; - } - } - _pixw = qMax(tw, 1); - _pixh = qMax(th, 1); - - if (_page) { - _title = _page->title; - } - QString url(_page ? _page->url : (_links.isEmpty() ? QString() : _links.at(0).lnk->text())); - QVector parts = url.splitRef('/'); - if (!parts.isEmpty()) { - QStringRef domain = parts.at(0); - if (parts.size() > 2 && domain.endsWith(':') && parts.at(1).isEmpty()) { // http:// and others - domain = parts.at(2); - } - - parts = domain.split('@').back().split('.'); - if (parts.size() > 1) { - _letter = parts.at(parts.size() - 2).at(0).toUpper(); - if (_title.isEmpty()) { - _title.reserve(parts.at(parts.size() - 2).size()); - _title.append(_letter).append(parts.at(parts.size() - 2).mid(1)); - } - } - } - _titlew = st::semiboldFont->width(_title); -} - -void LayoutOverviewLink::initDimensions() { - _maxw = st::linksMaxWidth; - _minh = 0; - if (!_title.isEmpty()) { - _minh += st::semiboldFont->height; - } - if (!_text.isEmpty()) { - _minh += qMin(3 * st::normalFont->height, _text.countHeight(_maxw - st::dlgPhotoSize - st::dlgPhotoPadding)); - } - _minh += _links.size() * st::normalFont->height; - _minh = qMax(_minh, int32(st::dlgPhotoSize)) + st::linksMargin.top() + st::linksMargin.bottom() + st::linksBorder; -} - -int32 LayoutOverviewLink::resizeGetHeight(int32 width) { - _width = qMin(width, _maxw); - int32 w = _width - st::dlgPhotoSize - st::dlgPhotoPadding; - for (int32 i = 0, l = _links.size(); i < l; ++i) { - _links.at(i).lnk->setFullDisplayed(w >= _links.at(i).width); - } - - _height = 0; - if (!_title.isEmpty()) { - _height += st::semiboldFont->height; - } - if (!_text.isEmpty()) { - _height += qMin(3 * st::normalFont->height, _text.countHeight(_width - st::dlgPhotoSize - st::dlgPhotoPadding)); - } - _height += _links.size() * st::normalFont->height; - _height = qMax(_height, int32(st::dlgPhotoSize)) + st::linksMargin.top() + st::linksMargin.bottom() + st::linksBorder; - return _height; -} - -void LayoutOverviewLink::paint(Painter &p, const QRect &clip, uint32 selection, const PaintContextOverview *context) const { - int32 left = st::dlgPhotoSize + st::dlgPhotoPadding, top = st::linksMargin.top() + st::linksBorder, w = _width - left; - if (clip.intersects(rtlrect(0, top, st::dlgPhotoSize, st::dlgPhotoSize, _width))) { - if (_page && _page->photo) { - QPixmap pix; - if (_page->photo->medium->loaded()) { - pix = _page->photo->medium->pixSingle(_pixw, _pixh, st::dlgPhotoSize, st::dlgPhotoSize); - } else if (_page->photo->loaded()) { - pix = _page->photo->full->pixSingle(_pixw, _pixh, st::dlgPhotoSize, st::dlgPhotoSize); - } else { - pix = _page->photo->thumb->pixSingle(_pixw, _pixh, st::dlgPhotoSize, st::dlgPhotoSize); - } - p.drawPixmapLeft(0, top, _width, pix); - } else if (_page && _page->document && !_page->document->thumb->isNull()) { - p.drawPixmapLeft(0, top, _width, _page->document->thumb->pixSingle(_pixw, _pixh, st::dlgPhotoSize, st::dlgPhotoSize)); - } else { - int32 index = _letter.isEmpty() ? 0 : (_letter.at(0).unicode() % 4); - switch (index) { - case 0: App::roundRect(p, rtlrect(0, top, st::dlgPhotoSize, st::dlgPhotoSize, _width), st::msgFileRedColor, DocRedCorners); break; - case 1: App::roundRect(p, rtlrect(0, top, st::dlgPhotoSize, st::dlgPhotoSize, _width), st::msgFileYellowColor, DocYellowCorners); break; - case 2: App::roundRect(p, rtlrect(0, top, st::dlgPhotoSize, st::dlgPhotoSize, _width), st::msgFileGreenColor, DocGreenCorners); break; - case 3: App::roundRect(p, rtlrect(0, top, st::dlgPhotoSize, st::dlgPhotoSize, _width), st::msgFileBlueColor, DocBlueCorners); break; - } - - if (!_letter.isEmpty()) { - p.setFont(st::linksLetterFont->f); - p.setPen(st::white->p); - p.drawText(rtlrect(0, top, st::dlgPhotoSize, st::dlgPhotoSize, _width), _letter, style::al_center); - } - } - - if (selection == FullSelection) { - App::roundRect(p, rtlrect(0, top, st::dlgPhotoSize, st::dlgPhotoSize, _width), st::overviewPhotoSelectOverlay, PhotoSelectOverlayCorners); - p.drawSpriteLeft(QPoint(st::dlgPhotoSize - st::linksPhotoCheck.pxWidth(), top + st::dlgPhotoSize - st::linksPhotoCheck.pxHeight()), _width, st::linksPhotoChecked); - } else if (context->selecting) { - p.drawSpriteLeft(QPoint(st::dlgPhotoSize - st::linksPhotoCheck.pxWidth(), top + st::dlgPhotoSize - st::linksPhotoCheck.pxHeight()), _width, st::linksPhotoCheck); - } - } - - if (!_title.isEmpty() && _text.isEmpty() && _links.size() == 1) { - top += (st::dlgPhotoSize - st::semiboldFont->height - st::normalFont->height) / 2; - } else { - top = st::linksTextTop; - } - - p.setPen(st::black); - p.setFont(st::semiboldFont); - if (!_title.isEmpty()) { - if (clip.intersects(rtlrect(left, top, qMin(w, _titlew), st::semiboldFont->height, _width))) { - p.drawTextLeft(left, top, _width, (w < _titlew) ? st::semiboldFont->elided(_title, w) : _title); - } - top += st::semiboldFont->height; - } - p.setFont(st::msgFont->f); - if (!_text.isEmpty()) { - int32 h = qMin(st::normalFont->height * 3, _text.countHeight(w)); - if (clip.intersects(rtlrect(left, top, w, h, _width))) { - _text.drawLeftElided(p, left, top, w, _width, 3); - } - top += h; - } - - p.setPen(st::btnYesColor); - for (int32 i = 0, l = _links.size(); i < l; ++i) { - if (clip.intersects(rtlrect(left, top, qMin(w, _links.at(i).width), st::normalFont->height, _width))) { - p.setFont(ClickHandler::showAsActive(_links.at(i).lnk) ? st::normalFont->underline() : st::normalFont); - p.drawTextLeft(left, top, _width, (w < _links.at(i).width) ? st::normalFont->elided(_links.at(i).text, w) : _links.at(i).text); - } - top += st::normalFont->height; - } - - QRect border(rtlrect(left, 0, w, st::linksBorder, _width)); - if (!context->isAfterDate && clip.intersects(border)) { - p.fillRect(clip.intersected(border), st::linksBorderFg); - } -} - -void LayoutOverviewLink::getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int x, int y) const { - int32 left = st::dlgPhotoSize + st::dlgPhotoPadding, top = st::linksMargin.top() + st::linksBorder, w = _width - left; - if (rtlrect(0, top, st::dlgPhotoSize, st::dlgPhotoSize, _width).contains(x, y)) { - link = _photol; - return; - } - - if (!_title.isEmpty() && _text.isEmpty() && _links.size() == 1) { - top += (st::dlgPhotoSize - st::semiboldFont->height - st::normalFont->height) / 2; - } - if (!_title.isEmpty()) { - if (rtlrect(left, top, qMin(w, _titlew), st::semiboldFont->height, _width).contains(x, y)) { - link = _photol; - return; - } - top += st::webPageTitleFont->height; - } - if (!_text.isEmpty()) { - top += qMin(st::normalFont->height * 3, _text.countHeight(w)); - } - for (int32 i = 0, l = _links.size(); i < l; ++i) { - if (rtlrect(left, top, qMin(w, _links.at(i).width), st::normalFont->height, _width).contains(x, y)) { - link = _links.at(i).lnk; - return; - } - top += st::normalFont->height; - } -} - -LayoutOverviewLink::Link::Link(const QString &url, const QString &text) -: text(text) -, width(st::normalFont->width(text)) -, lnk(MakeShared(url)) { -} diff --git a/Telegram/SourceFiles/layout.h b/Telegram/SourceFiles/layout.h index 9fbcf90c80..7dee8bc15c 100644 --- a/Telegram/SourceFiles/layout.h +++ b/Telegram/SourceFiles/layout.h @@ -91,12 +91,13 @@ public: }; -class LayoutMediaItemBase; class LayoutItemBase : public Composer, public ClickHandlerHost { public: LayoutItemBase() { } - LayoutItemBase &operator=(const LayoutItemBase &) = delete; + + LayoutItemBase(const LayoutItemBase &other) = delete; + LayoutItemBase &operator=(const LayoutItemBase &other) = delete; int32 maxWidth() const { return _maxw; @@ -142,311 +143,3 @@ protected: int _minh = 0; }; - -class PaintContextOverview : public PaintContextBase { -public: - PaintContextOverview(uint64 ms, bool selecting) : PaintContextBase(ms, selecting), isAfterDate(false) { - } - bool isAfterDate; - -}; - -class LayoutOverviewItemBase : public LayoutItemBase { -public: - - virtual void paint(Painter &p, const QRect &clip, uint32 selection, const PaintContextOverview *context) const = 0; - - virtual LayoutMediaItemBase *toLayoutMediaItem() { - return nullptr; - } - virtual const LayoutMediaItemBase *toLayoutMediaItem() const { - return nullptr; - } - - virtual HistoryItem *getItem() const { - return nullptr; - } - virtual DocumentData *getDocument() const { - return nullptr; - } - MsgId msgId() const { - const HistoryItem *item = getItem(); - return item ? item->id : 0; - } - -}; - -class LayoutMediaItemBase : public LayoutOverviewItemBase { -public: - LayoutMediaItemBase(HistoryItem *parent) : _parent(parent) { - } - - LayoutMediaItemBase *toLayoutMediaItem() override { - return this; - } - const LayoutMediaItemBase *toLayoutMediaItem() const override { - return this; - } - HistoryItem *getItem() const override { - return _parent; - } - - void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override; - void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool active) override; - -protected: - HistoryItem *_parent; - -}; - -class LayoutRadialProgressItem : public LayoutMediaItemBase { -public: - LayoutRadialProgressItem(HistoryItem *parent) : LayoutMediaItemBase(parent) - , _radial(0) - , a_iconOver(0, 0) - , _a_iconOver(animation(this, &LayoutRadialProgressItem::step_iconOver)) { - } - - void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override; - void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool active) override; - - ~LayoutRadialProgressItem(); - -protected: - ClickHandlerPtr _openl, _savel, _cancell; - void setLinks(ClickHandlerPtr &&openl, ClickHandlerPtr &&savel, ClickHandlerPtr &&cancell); - void setDocumentLinks(DocumentData *document) { - ClickHandlerPtr save; - if (document->voice()) { - save.reset(new DocumentOpenClickHandler(document)); - } else { - save.reset(new DocumentSaveClickHandler(document)); - } - setLinks(MakeShared(document), std_::move(save), MakeShared(document)); - } - - void step_iconOver(float64 ms, bool timer); - void step_radial(uint64 ms, bool timer); - - void ensureRadial() const; - void checkRadialFinished(); - - bool isRadialAnimation(uint64 ms) const { - if (!_radial || !_radial->animating()) return false; - - _radial->step(ms); - return _radial && _radial->animating(); - } - - virtual float64 dataProgress() const = 0; - virtual bool dataFinished() const = 0; - virtual bool dataLoaded() const = 0; - virtual bool iconAnimated() const { - return false; - } - - mutable RadialAnimation *_radial; - anim::fvalue a_iconOver; - mutable Animation _a_iconOver; - -private: - LayoutRadialProgressItem(const LayoutRadialProgressItem &other); - -}; - -class LayoutAbstractFileItem : public LayoutRadialProgressItem { -public: - LayoutAbstractFileItem(HistoryItem *parent) : LayoutRadialProgressItem(parent) { - } - -protected: - // >= 0 will contain download / upload string, _statusSize = loaded bytes - // < 0 will contain played string, _statusSize = -(seconds + 1) played - // 0x7FFFFFF0 will contain status for not yet downloaded file - // 0x7FFFFFF1 will contain status for already downloaded file - // 0x7FFFFFF2 will contain status for failed to download / upload file - mutable int32 _statusSize; - mutable QString _statusText; - - // duration = -1 - no duration, duration = -2 - "GIF" duration - void setStatusSize(int32 newSize, int32 fullSize, int32 duration, qint64 realDuration) const; - -}; - -struct OverviewItemInfo : public BaseComponent { - int top = 0; -}; - -class LayoutOverviewDate : public LayoutOverviewItemBase { -public: - LayoutOverviewDate(const QDate &date, bool month); - - void initDimensions() override; - void paint(Painter &p, const QRect &clip, uint32 selection, const PaintContextOverview *context) const override; - -private: - QDate _date; - QString _text; - -}; - -class LayoutOverviewPhoto : public LayoutMediaItemBase { -public: - LayoutOverviewPhoto(PhotoData *photo, HistoryItem *parent); - - void initDimensions() override; - int32 resizeGetHeight(int32 width) override; - void paint(Painter &p, const QRect &clip, uint32 selection, const PaintContextOverview *context) const override; - void getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int x, int y) const override; - -private: - PhotoData *_data; - ClickHandlerPtr _link; - - mutable QPixmap _pix; - mutable bool _goodLoaded; - -}; - -class LayoutOverviewVideo : public LayoutAbstractFileItem { -public: - LayoutOverviewVideo(DocumentData *video, HistoryItem *parent); - - void initDimensions() override; - int32 resizeGetHeight(int32 width) override; - void paint(Painter &p, const QRect &clip, uint32 selection, const PaintContextOverview *context) const override; - void getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int x, int y) const override; - -protected: - float64 dataProgress() const override { - return _data->progress(); - } - bool dataFinished() const override { - return !_data->loading(); - } - bool dataLoaded() const override { - return _data->loaded(); - } - bool iconAnimated() const override { - return true; - } - -private: - DocumentData *_data; - - QString _duration; - mutable QPixmap _pix; - mutable bool _thumbLoaded; - - void updateStatusText() const; - -}; - -class LayoutOverviewVoice : public LayoutAbstractFileItem { -public: - LayoutOverviewVoice(DocumentData *voice, HistoryItem *parent); - - void initDimensions() override; - void paint(Painter &p, const QRect &clip, uint32 selection, const PaintContextOverview *context) const override; - void getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int x, int y) const override; - -protected: - float64 dataProgress() const override { - return _data->progress(); - } - bool dataFinished() const override { - return !_data->loading(); - } - bool dataLoaded() const override { - return _data->loaded(); - } - bool iconAnimated() const override { - return true; - } - -private: - DocumentData *_data; - ClickHandlerPtr _namel; - - mutable Text _name, _details; - mutable int32 _nameVersion; - - void updateName() const; - bool updateStatusText() const; - -}; - -class LayoutOverviewDocument : public LayoutAbstractFileItem { -public: - LayoutOverviewDocument(DocumentData *document, HistoryItem *parent); - - void initDimensions() override; - void paint(Painter &p, const QRect &clip, uint32 selection, const PaintContextOverview *context) const override; - void getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int x, int y) const override; - - virtual DocumentData *getDocument() const override { - return _data; - } - -protected: - float64 dataProgress() const override { - return _data->progress(); - } - bool dataFinished() const override { - return !_data->loading(); - } - bool dataLoaded() const override { - return _data->loaded(); - } - bool iconAnimated() const override { - return _data->song() || !_data->loaded() || (_radial && _radial->animating()); - } - -private: - DocumentData *_data; - ClickHandlerPtr _msgl, _namel; - - mutable bool _thumbForLoaded; - mutable QPixmap _thumb; - - QString _name, _date, _ext; - int32 _namew, _datew, _extw; - int32 _thumbw, _colorIndex; - - bool withThumb() const { - return !_data->thumb->isNull() && _data->thumb->width() && _data->thumb->height(); - } - bool updateStatusText() const; - -}; - -class LayoutOverviewLink : public LayoutMediaItemBase { -public: - LayoutOverviewLink(HistoryMedia *media, HistoryItem *parent); - - void initDimensions() override; - int32 resizeGetHeight(int32 width) override; - void paint(Painter &p, const QRect &clip, uint32 selection, const PaintContextOverview *context) const override; - void getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int x, int y) const override; - -private: - ClickHandlerPtr _photol; - - QString _title, _letter; - int _titlew = 0; - WebPageData *_page = nullptr; - int _pixw = 0; - int _pixh = 0; - Text _text = { int(st::msgMinWidth) }; - - struct Link { - Link() : width(0) { - } - Link(const QString &url, const QString &text); - QString text; - int32 width; - TextClickHandlerPtr lnk; - }; - QVector _links; - -}; diff --git a/Telegram/SourceFiles/localimageloader.cpp b/Telegram/SourceFiles/localimageloader.cpp index 33904510b5..f484ccb9bf 100644 --- a/Telegram/SourceFiles/localimageloader.cpp +++ b/Telegram/SourceFiles/localimageloader.cpp @@ -25,7 +25,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "boxes/photosendbox.h" #include "mainwidget.h" -#include "window.h" +#include "mainwindow.h" #include "lang.h" #include "boxes/confirmbox.h" diff --git a/Telegram/SourceFiles/localstorage.cpp b/Telegram/SourceFiles/localstorage.cpp index 386f307c48..dc5a34e399 100644 --- a/Telegram/SourceFiles/localstorage.cpp +++ b/Telegram/SourceFiles/localstorage.cpp @@ -25,10 +25,11 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "serialize/serialize_document.h" #include "serialize/serialize_common.h" - #include "mainwidget.h" -#include "window.h" +#include "mainwindow.h" #include "lang.h" +#include "playerwidget.h" +#include "apiwrap.h" namespace { typedef quint64 FileKey; diff --git a/Telegram/SourceFiles/localstorage.h b/Telegram/SourceFiles/localstorage.h index 4d621c6d88..10264515a9 100644 --- a/Telegram/SourceFiles/localstorage.h +++ b/Telegram/SourceFiles/localstorage.h @@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #pragma once -#include "basic_types.h" +#include "core/basic_types.h" namespace _local_inner { diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 78cd7023c8..d3d478f0b8 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -21,389 +21,35 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "stdafx.h" #include "mainwidget.h" +#include "ui/buttons/peer_avatar_button.h" #include "ui/style.h" +#include "window/top_bar_widget.h" +#include "apiwrap.h" +#include "dialogswidget.h" +#include "historywidget.h" +#include "profilewidget.h" +#include "overviewwidget.h" +#include "playerwidget.h" #include "lang.h" #include "boxes/addcontactbox.h" #include "fileuploader.h" #include "application.h" -#include "window.h" +#include "mainwindow.h" #include "settingswidget.h" #include "inline_bots/inline_bot_layout_item.h" #include "boxes/confirmbox.h" #include "boxes/stickersetbox.h" #include "boxes/contactsbox.h" #include "boxes/downloadpathbox.h" - #include "localstorage.h" - #include "shortcuts.h" - #include "audio.h" - #include "langloaderplain.h" -TopBarWidget::TopBarWidget(MainWidget *w) : TWidget(w) -, a_over(0) -, _a_appearance(animation(this, &TopBarWidget::step_appearance)) -, _selPeer(0) -, _selCount(0) -, _canDelete(false) -, _selStrLeft(-st::topBarButton.width / 2) -, _selStrWidth(0) -, _animating(false) -, _clearSelection(this, lang(lng_selected_clear), st::topBarButton) -, _forward(this, lang(lng_selected_forward), st::topBarActionButton) -, _delete(this, lang(lng_selected_delete), st::topBarActionButton) -, _selectionButtonsWidth(_clearSelection.width() + _forward.width() + _delete.width()), _forwardDeleteWidth(qMax(_forward.textWidth(), _delete.textWidth())) -, _info(this, nullptr, st::infoButton) -, _edit(this, lang(lng_profile_edit_contact), st::topBarButton) -, _leaveGroup(this, lang(lng_profile_delete_and_exit), st::topBarButton) -, _addContact(this, lang(lng_profile_add_contact), st::topBarButton) -, _deleteContact(this, lang(lng_profile_delete_contact), st::topBarButton) -, _mediaType(this, lang(lng_media_type), st::topBarButton) -, _search(this, st::topBarSearch) -, _sideShadow(this, st::shadowColor) { - - connect(&_forward, SIGNAL(clicked()), this, SLOT(onForwardSelection())); - connect(&_delete, SIGNAL(clicked()), this, SLOT(onDeleteSelection())); - connect(&_clearSelection, SIGNAL(clicked()), this, SLOT(onClearSelection())); - connect(&_info, SIGNAL(clicked()), this, SLOT(onInfoClicked())); - connect(&_addContact, SIGNAL(clicked()), this, SLOT(onAddContact())); - connect(&_deleteContact, SIGNAL(clicked()), this, SLOT(onDeleteContact())); - connect(&_edit, SIGNAL(clicked()), this, SLOT(onEdit())); - connect(&_leaveGroup, SIGNAL(clicked()), this, SLOT(onDeleteAndExit())); - connect(&_search, SIGNAL(clicked()), this, SLOT(onSearch())); - - setCursor(style::cur_pointer); - showAll(); -} - -void TopBarWidget::onForwardSelection() { - if (App::main()) App::main()->forwardSelectedItems(); -} - -void TopBarWidget::onDeleteSelection() { - if (App::main()) App::main()->deleteSelectedItems(); -} - -void TopBarWidget::onClearSelection() { - if (App::main()) App::main()->clearSelectedItems(); -} - -void TopBarWidget::onInfoClicked() { - PeerData *p = App::main() ? App::main()->historyPeer() : 0; - if (p) App::main()->showPeerProfile(p); -} - -void TopBarWidget::onAddContact() { - PeerData *p = App::main() ? App::main()->profilePeer() : 0; - UserData *u = p ? p->asUser() : 0; - if (u) Ui::showLayer(new AddContactBox(u->firstName, u->lastName, u->phone.isEmpty() ? App::phoneFromSharedContact(peerToUser(u->id)) : u->phone)); -} - -void TopBarWidget::onEdit() { - PeerData *p = App::main() ? App::main()->profilePeer() : 0; - if (p) { - if (p->isChannel()) { - Ui::showLayer(new EditChannelBox(p->asChannel())); - } else if (p->isChat()) { - Ui::showLayer(new EditNameTitleBox(p)); - } else if (p->isUser()) { - Ui::showLayer(new AddContactBox(p->asUser())); - } - } -} - -void TopBarWidget::onDeleteContact() { - PeerData *p = App::main() ? App::main()->profilePeer() : 0; - UserData *u = p ? p->asUser() : 0; - if (u) { - ConfirmBox *box = new ConfirmBox(lng_sure_delete_contact(lt_contact, p->name), lang(lng_box_delete)); - connect(box, SIGNAL(confirmed()), this, SLOT(onDeleteContactSure())); - Ui::showLayer(box); - } -} - -void TopBarWidget::onDeleteContactSure() { - PeerData *p = App::main() ? App::main()->profilePeer() : 0; - UserData *u = p ? p->asUser() : 0; - if (u) { - Ui::showChatsList(); - Ui::hideLayer(); - MTP::send(MTPcontacts_DeleteContact(u->inputUser), App::main()->rpcDone(&MainWidget::deletedContact, u)); - } -} - -void TopBarWidget::onDeleteAndExit() { - PeerData *p = App::main() ? App::main()->profilePeer() : 0; - ChatData *c = p ? p->asChat() : 0; - if (c) { - ConfirmBox *box = new ConfirmBox(lng_sure_delete_and_exit(lt_group, p->name), lang(lng_box_leave), st::attentionBoxButton); - connect(box, SIGNAL(confirmed()), this, SLOT(onDeleteAndExitSure())); - Ui::showLayer(box); - } -} - -void TopBarWidget::onDeleteAndExitSure() { - PeerData *p = App::main() ? App::main()->profilePeer() : 0; - ChatData *c = p ? p->asChat() : 0; - if (c) { - Ui::showChatsList(); - Ui::hideLayer(); - MTP::send(MTPmessages_DeleteChatUser(c->inputChat, App::self()->inputUser), App::main()->rpcDone(&MainWidget::deleteHistoryAfterLeave, p), App::main()->rpcFail(&MainWidget::leaveChatFailed, p)); - } -} - -void TopBarWidget::onSearch() { - Shortcuts::launch(qsl("search")); -} - -void TopBarWidget::enterEvent(QEvent *e) { - a_over.start(1); - _a_appearance.start(); -} - -void TopBarWidget::enterFromChildEvent(QEvent *e) { - a_over.start(1); - _a_appearance.start(); -} - -void TopBarWidget::leaveEvent(QEvent *e) { - a_over.start(0); - _a_appearance.start(); -} - -void TopBarWidget::leaveToChildEvent(QEvent *e) { - a_over.start(0); - _a_appearance.start(); -} - -void TopBarWidget::step_appearance(float64 ms, bool timer) { - float64 dt = ms / st::topBarDuration; - if (dt >= 1) { - _a_appearance.stop(); - a_over.finish(); - } else { - a_over.update(dt, anim::linear); - } - if (timer) update(); -} - -void TopBarWidget::paintEvent(QPaintEvent *e) { - QPainter p(this); - - if (e->rect().top() < st::topBarHeight) { // optimize shadow-only drawing - p.fillRect(QRect(0, 0, width(), st::topBarHeight), st::topBarBG->b); - if (_clearSelection.isHidden()) { - p.save(); - main()->paintTopBar(p, a_over.current(), _info.isHidden() ? 0 : _info.width()); - p.restore(); - } else { - p.setFont(st::linkFont->f); - p.setPen(st::btnDefLink.color->p); - p.drawText(_selStrLeft, st::topBarButton.textTop + st::linkFont->ascent, _selStr); - } - } -} - -void TopBarWidget::mousePressEvent(QMouseEvent *e) { - PeerData *p = App::main() ? App::main()->profilePeer() : 0; - if (e->button() == Qt::LeftButton && e->pos().y() < st::topBarHeight && (p || !_selCount)) { - emit clicked(); - } -} - -void TopBarWidget::resizeEvent(QResizeEvent *e) { - int32 r = width(); - if (!_forward.isHidden() || !_delete.isHidden()) { - int32 fullW = r - (_selectionButtonsWidth + (_selStrWidth - st::topBarButton.width) + st::topBarActionSkip); - int32 selectedClearWidth = st::topBarButton.width, forwardDeleteWidth = st::topBarActionButton.width - _forwardDeleteWidth, skip = st::topBarActionSkip; - while (fullW < 0) { - int fit = 0; - if (selectedClearWidth < -2 * (st::topBarMinPadding + 1)) { - fullW += 4; - selectedClearWidth += 2; - } else if (selectedClearWidth < -2 * st::topBarMinPadding) { - fullW += (-2 * st::topBarMinPadding - selectedClearWidth) * 2; - selectedClearWidth = -2 * st::topBarMinPadding; - } else { - ++fit; - } - if (fullW >= 0) break; - - if (forwardDeleteWidth > 2 * (st::topBarMinPadding + 1)) { - fullW += 4; - forwardDeleteWidth -= 2; - } else if (forwardDeleteWidth > 2 * st::topBarMinPadding) { - fullW += (forwardDeleteWidth - 2 * st::topBarMinPadding) * 2; - forwardDeleteWidth = 2 * st::topBarMinPadding; - } else { - ++fit; - } - if (fullW >= 0) break; - - if (skip > st::topBarMinPadding) { - --skip; - ++fullW; - } else { - ++fit; - } - if (fullW >= 0 || fit >= 3) break; - } - _clearSelection.setWidth(selectedClearWidth); - _forward.setWidth(_forwardDeleteWidth + forwardDeleteWidth); - _delete.setWidth(_forwardDeleteWidth + forwardDeleteWidth); - _selStrLeft = -selectedClearWidth / 2; - - int32 availX = _selStrLeft + _selStrWidth, availW = r - (_clearSelection.width() + selectedClearWidth / 2) - availX; - if (_forward.isHidden()) { - _delete.move(availX + (availW - _delete.width()) / 2, (st::topBarHeight - _forward.height()) / 2); - } else if (_delete.isHidden()) { - _forward.move(availX + (availW - _forward.width()) / 2, (st::topBarHeight - _forward.height()) / 2); - } else { - _forward.move(availX + (availW - _forward.width() - _delete.width() - skip) / 2, (st::topBarHeight - _forward.height()) / 2); - _delete.move(availX + (availW + _forward.width() - _delete.width() + skip) / 2, (st::topBarHeight - _forward.height()) / 2); - } - _clearSelection.move(r -= _clearSelection.width(), 0); - } - if (!_info.isHidden()) _info.move(r -= _info.width(), 0); - if (!_deleteContact.isHidden()) _deleteContact.move(r -= _deleteContact.width(), 0); - if (!_leaveGroup.isHidden()) _leaveGroup.move(r -= _leaveGroup.width(), 0); - if (!_edit.isHidden()) _edit.move(r -= _edit.width(), 0); - if (!_addContact.isHidden()) _addContact.move(r -= _addContact.width(), 0); - if (!_mediaType.isHidden()) _mediaType.move(r -= _mediaType.width(), 0); - _search.move(width() - (_info.isHidden() ? st::topBarForwardPadding.right() : _info.width()) - _search.width(), 0); - - _sideShadow.resize(st::lineWidth, height()); - _sideShadow.moveToLeft(0, 0); -} - -void TopBarWidget::startAnim() { - _info.hide(); - _edit.hide(); - _leaveGroup.hide(); - _addContact.hide(); - _deleteContact.hide(); - _clearSelection.hide(); - _delete.hide(); - _forward.hide(); - _mediaType.hide(); - _search.hide(); - - _animating = true; -} - -void TopBarWidget::stopAnim() { - _animating = false; - _sideShadow.setVisible(!Adaptive::OneColumn()); - showAll(); -} - -void TopBarWidget::showAll() { - if (_animating) { - resizeEvent(0); - return; - } - PeerData *p = App::main() ? App::main()->profilePeer() : 0, *h = App::main() ? App::main()->historyPeer() : 0, *o = App::main() ? App::main()->overviewPeer() : 0; - if (p && (p->isChat() || (p->isUser() && (p->asUser()->contact >= 0 || !App::phoneFromSharedContact(peerToUser(p->id)).isEmpty())))) { - if (p->isChat()) { - if (p->asChat()->canEdit()) { - _edit.show(); - } else { - _edit.hide(); - } - _leaveGroup.show(); - _addContact.hide(); - _deleteContact.hide(); - } else if (p->asUser()->contact > 0) { - _edit.show(); - _leaveGroup.hide(); - _addContact.hide(); - _deleteContact.show(); - } else { - _edit.hide(); - _leaveGroup.hide(); - _addContact.show(); - _deleteContact.hide(); - } - _clearSelection.hide(); - _info.hide(); - _delete.hide(); - _forward.hide(); - _mediaType.hide(); - _search.hide(); - } else { - if (p && p->isChannel() && (p->asChannel()->amCreator() || (p->isMegagroup() && p->asChannel()->amEditor()))) { - _edit.show(); - } else { - _edit.hide(); - } - _leaveGroup.hide(); - _addContact.hide(); - _deleteContact.hide(); - if (!p && _selCount) { - _clearSelection.show(); - if (_canDelete) { - _delete.show(); - } else { - _delete.hide(); - } - _forward.show(); - _mediaType.hide(); - } else { - _clearSelection.hide(); - _delete.hide(); - _forward.hide(); - if (App::main() && App::main()->mediaTypeSwitch()) { - _mediaType.show(); - } else { - _mediaType.hide(); - } - } - if (h && !o && !p && _clearSelection.isHidden()) { - if (Adaptive::OneColumn()) { - _info.setPeer(h); - _info.show(); - } else { - _info.hide(); - } - _search.show(); - } else { - _search.hide(); - _info.hide(); - } - } - _sideShadow.setVisible(!Adaptive::OneColumn()); - resizeEvent(0); -} - -void TopBarWidget::showSelected(uint32 selCount, bool canDelete) { - PeerData *p = App::main() ? App::main()->profilePeer() : 0; - _selPeer = App::main()->overviewPeer() ? App::main()->overviewPeer() : App::main()->peer(); - _selCount = selCount; - _canDelete = canDelete; - _selStr = (_selCount > 0) ? lng_selected_count(lt_count, _selCount) : QString(); - _selStrWidth = st::btnDefLink.font->width(_selStr); - setCursor((!p && _selCount) ? style::cur_default : style::cur_pointer); - showAll(); -} - -void TopBarWidget::updateAdaptiveLayout() { - showAll(); -} - -FlatButton *TopBarWidget::mediaTypeButton() { - return &_mediaType; -} - -MainWidget *TopBarWidget::main() { - return static_cast(parentWidget()); -} - -MainWidget::MainWidget(Window *window) : TWidget(window) +MainWidget::MainWidget(MainWindow *window) : TWidget(window) , _a_show(animation(this, &MainWidget::step_show)) -, dialogs(this) -, history(this) +, _dialogs(this) +, _history(this) , _player(this) , _topBar(this) , _mediaType(this) @@ -415,8 +61,8 @@ MainWidget::MainWidget(Window *window) : TWidget(window) updateScrollColors(); connect(App::wnd(), SIGNAL(resized(const QSize&)), this, SLOT(onParentResize(const QSize&))); - connect(&dialogs, SIGNAL(cancelled()), this, SLOT(dialogsCancelled())); - connect(&history, SIGNAL(cancelled()), &dialogs, SLOT(activate())); + connect(_dialogs, SIGNAL(cancelled()), this, SLOT(dialogsCancelled())); + connect(_history, SIGNAL(cancelled()), _dialogs, SLOT(activate())); connect(this, SIGNAL(peerPhotoChanged(PeerData*)), this, SIGNAL(dialogsUpdated())); connect(&noUpdatesTimer, SIGNAL(timeout()), this, SLOT(mtpPing())); connect(&_onlineTimer, SIGNAL(timeout()), this, SLOT(updateOnline())); @@ -426,10 +72,10 @@ MainWidget::MainWidget(Window *window) : TWidget(window) connect(&_byPtsTimer, SIGNAL(timeout()), this, SLOT(onGetDifferenceTimeByPts())); connect(&_byMinChannelTimer, SIGNAL(timeout()), this, SLOT(getDifference())); connect(&_failDifferenceTimer, SIGNAL(timeout()), this, SLOT(onGetDifferenceTimeAfterFail())); - connect(_api, SIGNAL(fullPeerUpdated(PeerData*)), this, SLOT(onFullPeerUpdated(PeerData*))); - connect(this, SIGNAL(peerUpdated(PeerData*)), &history, SLOT(peerUpdated(PeerData*))); - connect(&_topBar, SIGNAL(clicked()), this, SLOT(onTopBarClick())); - connect(&history, SIGNAL(historyShown(History*,MsgId)), this, SLOT(onHistoryShown(History*,MsgId))); + connect(_api.get(), SIGNAL(fullPeerUpdated(PeerData*)), this, SLOT(onFullPeerUpdated(PeerData*))); + connect(this, SIGNAL(peerUpdated(PeerData*)), _history, SLOT(peerUpdated(PeerData*))); + connect(_topBar, SIGNAL(clicked()), this, SLOT(onTopBarClick())); + connect(_history, SIGNAL(historyShown(History*,MsgId)), this, SLOT(onHistoryShown(History*,MsgId))); connect(&updateNotifySettingTimer, SIGNAL(timeout()), this, SLOT(onUpdateNotifySettings())); if (audioPlayer()) { connect(audioPlayer(), SIGNAL(updated(const AudioMsgId&)), this, SLOT(audioPlayProgress(const AudioMsgId&))); @@ -445,23 +91,23 @@ MainWidget::MainWidget(Window *window) : TWidget(window) connect(&_cacheBackgroundTimer, SIGNAL(timeout()), this, SLOT(onCacheBackground())); - dialogs.show(); + _dialogs->show(); if (Adaptive::OneColumn()) { - history.hide(); + _history->hide(); } else { - history.show(); + _history->show(); } App::wnd()->getTitle()->updateBackButton(); - _topBar.hide(); + _topBar->hide(); - _player.hide(); + _player->hide(); orderWidgets(); MTP::setGlobalFailHandler(rpcFail(&MainWidget::updateFail)); - _mediaType.hide(); - _topBar.mediaTypeButton()->installEventFilter(&_mediaType); + _mediaType->hide(); + _topBar->mediaTypeButton()->installEventFilter(_mediaType); show(); setFocus(); @@ -475,13 +121,13 @@ bool MainWidget::onForward(const PeerId &peer, ForwardWhatMessages what) { Ui::showLayer(new InformBox(lang(lng_forward_cant))); return false; } - history.cancelReply(); + _history->cancelReply(); _toForward.clear(); if (what == ForwardSelectedMessages) { - if (overview) { - overview->fillSelectedItems(_toForward, false); + if (_overview) { + _overview->fillSelectedItems(_toForward, false); } else { - history.fillSelectedItems(_toForward, false); + _history->fillSelectedItems(_toForward, false); } } else { HistoryItem *item = 0; @@ -498,8 +144,8 @@ bool MainWidget::onForward(const PeerId &peer, ForwardWhatMessages what) { } updateForwardingTexts(); Ui::showPeerHistory(peer, ShowAtUnreadMsgId); - history.onClearSelected(); - history.updateForwarding(); + _history->onClearSelected(); + _history->updateForwarding(); return true; } @@ -512,9 +158,9 @@ bool MainWidget::onShareUrl(const PeerId &peer, const QString &url, const QStrin History *h = App::history(peer); h->setMsgDraft(std_::make_unique(url + '\n' + text, 0, MessageCursor(url.size() + 1, url.size() + 1 + text.size(), QFIXED_MAX), false)); h->clearEditDraft(); - bool opened = history.peer() && (history.peer()->id == peer); + bool opened = _history->peer() && (_history->peer()->id == peer); if (opened) { - history.applyDraft(); + _history->applyDraft(); } else { Ui::showPeerHistory(peer, ShowAtUnreadMsgId); } @@ -530,9 +176,9 @@ bool MainWidget::onInlineSwitchChosen(const PeerId &peer, const QString &botAndQ History *h = App::history(peer); h->setMsgDraft(std_::make_unique(botAndQuery, 0, MessageCursor(botAndQuery.size(), botAndQuery.size(), QFIXED_MAX), false)); h->clearEditDraft(); - bool opened = history.peer() && (history.peer()->id == peer); + bool opened = _history->peer() && (_history->peer()->id == peer); if (opened) { - history.applyDraft(); + _history->applyDraft(); } else { Ui::showPeerHistory(peer, ShowAtUnreadMsgId); } @@ -598,7 +244,7 @@ void MainWidget::cancelForwarding() { if (_toForward.isEmpty()) return; _toForward.clear(); - history.cancelForwarding(); + _history->cancelForwarding(); } void MainWidget::finishForwarding(History *hist, bool broadcast, bool silent) { @@ -656,8 +302,8 @@ void MainWidget::finishForwarding(History *hist, bool broadcast, bool silent) { } hist->sendRequestId = MTP::send(MTPmessages_ForwardMessages(MTP_flags(sendFlags), forwardFrom->input, MTP_vector(ids), MTP_vector(randomIds), hist->peer->input), rpcDone(&MainWidget::sentUpdatesReceived), RPCFailHandlerPtr(), 0, 0, hist->sendRequestId); - if (history.peer() == hist->peer) { - history.peerMessagesUpdated(); + if (_history->peer() == hist->peer) { + _history->peerMessagesUpdated(); } cancelForwarding(); @@ -665,7 +311,7 @@ void MainWidget::finishForwarding(History *hist, bool broadcast, bool silent) { historyToDown(hist); dialogsToUp(); - history.peerMessagesUpdated(hist->peer->id); + _history->peerMessagesUpdated(hist->peer->id); } void MainWidget::webPageUpdated(WebPageData *data) { @@ -697,7 +343,7 @@ void MainWidget::updateMutedIn(int32 seconds) { } void MainWidget::updateStickers() { - history.updateStickers(); + _history->updateStickers(); } void MainWidget::onUpdateMuted() { @@ -705,11 +351,11 @@ void MainWidget::onUpdateMuted() { } void MainWidget::onShareContact(const PeerId &peer, UserData *contact) { - history.onShareContact(peer, contact); + _history->onShareContact(peer, contact); } void MainWidget::onSendPaths(const PeerId &peer) { - history.onSendPaths(peer); + _history->onSendPaths(peer); } void MainWidget::onFilesOrForwardDrop(const PeerId &peer, const QMimeData *data) { @@ -721,30 +367,30 @@ void MainWidget::onFilesOrForwardDrop(const PeerId &peer, const QMimeData *data) onForward(peer, ForwardPressedMessage); } else { Ui::showPeerHistory(peer, ShowAtTheEndMsgId); - history.onFilesDrop(data); + _history->onFilesDrop(data); } } void MainWidget::rpcClear() { - history.rpcClear(); - dialogs.rpcClear(); - if (profile) profile->rpcClear(); - if (overview) overview->rpcClear(); + _history->rpcClear(); + _dialogs->rpcClear(); + if (_profile) _profile->rpcClear(); + if (_overview) _overview->rpcClear(); if (_api) _api->rpcClear(); RPCSender::rpcClear(); } QPixmap MainWidget::grabInner() { - if (overview && !overview->isHidden()) { - return myGrab(overview); - } else if (profile && !profile->isHidden()) { - return myGrab(profile); - } else if (Adaptive::OneColumn() && history.isHidden()) { - return myGrab(&dialogs, QRect(0, st::topBarHeight, dialogs.width(), dialogs.height() - st::topBarHeight)); - } else if (history.peer()) { - return myGrab(&history); + if (_overview && !_overview->isHidden()) { + return myGrab(_overview); + } else if (_profile && !_profile->isHidden()) { + return myGrab(_profile); + } else if (Adaptive::OneColumn() && _history->isHidden()) { + return myGrab(_dialogs, QRect(0, st::topBarHeight, _dialogs->width(), _dialogs->height() - st::topBarHeight)); + } else if (_history->peer()) { + return myGrab(_history); } else { - return myGrab(&history, QRect(0, st::topBarHeight, history.width(), history.height() - st::topBarHeight)); + return myGrab(_history, QRect(0, st::topBarHeight, _history->width(), _history->height() - st::topBarHeight)); } } @@ -752,47 +398,47 @@ bool MainWidget::isItemVisible(HistoryItem *item) { if (isHidden() || _a_show.animating()) { return false; } - return history.isItemVisible(item); + return _history->isItemVisible(item); } QPixmap MainWidget::grabTopBar() { - if (!_topBar.isHidden()) { - return myGrab(&_topBar); - } else if (Adaptive::OneColumn() && history.isHidden()) { - return myGrab(&dialogs, QRect(0, 0, dialogs.width(), st::topBarHeight)); + if (!_topBar->isHidden()) { + return myGrab(_topBar); + } else if (Adaptive::OneColumn() && _history->isHidden()) { + return myGrab(_dialogs, QRect(0, 0, _dialogs->width(), st::topBarHeight)); } else { - return myGrab(&history, QRect(0, 0, history.width(), st::topBarHeight)); + return myGrab(_history, QRect(0, 0, _history->width(), st::topBarHeight)); } } void MainWidget::notify_botCommandsChanged(UserData *bot) { - history.notify_botCommandsChanged(bot); + _history->notify_botCommandsChanged(bot); } void MainWidget::notify_inlineBotRequesting(bool requesting) { - history.notify_inlineBotRequesting(requesting); + _history->notify_inlineBotRequesting(requesting); } void MainWidget::notify_replyMarkupUpdated(const HistoryItem *item) { - history.notify_replyMarkupUpdated(item); + _history->notify_replyMarkupUpdated(item); } void MainWidget::notify_inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop) { - history.notify_inlineKeyboardMoved(item, oldKeyboardTop, newKeyboardTop); + _history->notify_inlineKeyboardMoved(item, oldKeyboardTop, newKeyboardTop); } bool MainWidget::notify_switchInlineBotButtonReceived(const QString &query) { - return history.notify_switchInlineBotButtonReceived(query); + return _history->notify_switchInlineBotButtonReceived(query); } void MainWidget::notify_userIsBotChanged(UserData *bot) { - history.notify_userIsBotChanged(bot); + _history->notify_userIsBotChanged(bot); } void MainWidget::notify_userIsContactChanged(UserData *user, bool fromThisApp) { if (!user) return; - dialogs.notify_userIsContactChanged(user, fromThisApp); + _dialogs->notify_userIsContactChanged(user, fromThisApp); const SharedContactItems &items(App::sharedContactItems()); SharedContactItems::const_iterator i = items.constFind(peerToUser(user->id)); @@ -808,83 +454,83 @@ void MainWidget::notify_userIsContactChanged(UserData *user, bool fromThisApp) { } void MainWidget::notify_migrateUpdated(PeerData *peer) { - history.notify_migrateUpdated(peer); + _history->notify_migrateUpdated(peer); } void MainWidget::notify_clipStopperHidden(ClipStopperType type) { - history.notify_clipStopperHidden(type); + _history->notify_clipStopperHidden(type); } void MainWidget::ui_repaintHistoryItem(const HistoryItem *item) { - history.ui_repaintHistoryItem(item); + _history->ui_repaintHistoryItem(item); if (item->history()->lastMsg == item) { item->history()->updateChatListEntry(); } - if (overview) overview->ui_repaintHistoryItem(item); + if (_overview) _overview->ui_repaintHistoryItem(item); } void MainWidget::ui_repaintInlineItem(const InlineBots::Layout::ItemBase *layout) { - history.ui_repaintInlineItem(layout); + _history->ui_repaintInlineItem(layout); } bool MainWidget::ui_isInlineItemVisible(const InlineBots::Layout::ItemBase *layout) { - return history.ui_isInlineItemVisible(layout); + return _history->ui_isInlineItemVisible(layout); } bool MainWidget::ui_isInlineItemBeingChosen() { - return history.ui_isInlineItemBeingChosen(); + return _history->ui_isInlineItemBeingChosen(); } void MainWidget::notify_historyItemLayoutChanged(const HistoryItem *item) { - history.notify_historyItemLayoutChanged(item); - if (overview) overview->notify_historyItemLayoutChanged(item); + _history->notify_historyItemLayoutChanged(item); + if (_overview) _overview->notify_historyItemLayoutChanged(item); } void MainWidget::notify_inlineItemLayoutChanged(const InlineBots::Layout::ItemBase *layout) { - history.notify_inlineItemLayoutChanged(layout); + _history->notify_inlineItemLayoutChanged(layout); } void MainWidget::notify_historyMuteUpdated(History *history) { - dialogs.notify_historyMuteUpdated(history); + _dialogs->notify_historyMuteUpdated(history); } void MainWidget::notify_handlePendingHistoryUpdate() { - history.notify_handlePendingHistoryUpdate(); + _history->notify_handlePendingHistoryUpdate(); } void MainWidget::cmd_search() { - history.cmd_search(); + _history->cmd_search(); } void MainWidget::cmd_next_chat() { - history.cmd_next_chat(); + _history->cmd_next_chat(); } void MainWidget::cmd_previous_chat() { - history.cmd_previous_chat(); + _history->cmd_previous_chat(); } void MainWidget::noHider(HistoryHider *destroyed) { if (_hider == destroyed) { - _hider = 0; + _hider = nullptr; if (Adaptive::OneColumn()) { if (_forwardConfirm) { _forwardConfirm->startHide(); _forwardConfirm = 0; } - onHistoryShown(history.history(), history.msgId()); - if (profile || overview || (history.peer() && history.peer()->id)) { + onHistoryShown(_history->history(), _history->msgId()); + if (_profile || _overview || (_history->peer() && _history->peer()->id)) { QPixmap animCache = grabInner(), animTopBarCache = grabTopBar(); - dialogs.hide(); - if (overview) { - overview->show(); - overview->animShow(animCache, animTopBarCache); - } else if (profile) { - profile->show(); - profile->animShow(animCache, animTopBarCache); + _dialogs->hide(); + if (_overview) { + _overview->show(); + _overview->animShow(animCache, animTopBarCache); + } else if (_profile) { + _profile->show(); + _profile->animShow(animCache, animTopBarCache); } else { - history.show(); - history.animShow(animCache, animTopBarCache); + _history->show(); + _history->animShow(animCache, animTopBarCache); } } App::wnd()->getTitle()->updateBackButton(); @@ -904,7 +550,7 @@ void MainWidget::hiderLayer(HistoryHider *h) { } _hider = h; - connect(_hider, SIGNAL(forwarded()), &dialogs, SLOT(onCancelSearch())); + connect(_hider, SIGNAL(forwarded()), _dialogs, SLOT(onCancelSearch())); if (Adaptive::OneColumn()) { dialogsToUp(); @@ -912,21 +558,21 @@ void MainWidget::hiderLayer(HistoryHider *h) { QPixmap animCache = myGrab(this, QRect(0, _playerHeight, _dialogsWidth, height() - _playerHeight)); onHistoryShown(0, 0); - if (overview) { - overview->hide(); - } else if (profile) { - profile->hide(); + if (_overview) { + _overview->hide(); + } else if (_profile) { + _profile->hide(); } else { - history.hide(); + _history->hide(); } - dialogs.show(); + _dialogs->show(); resizeEvent(0); - dialogs.animShow(animCache); + _dialogs->animShow(animCache); App::wnd()->getTitle()->updateBackButton(); } else { _hider->show(); resizeEvent(0); - dialogs.activate(); + _dialogs->activate(); } } @@ -935,7 +581,7 @@ void MainWidget::forwardLayer(int32 forwardSelected) { } void MainWidget::deleteLayer(int32 selectedCount) { - if (selectedCount == -1 && !overview) { + if (selectedCount == -1 && !_overview) { if (HistoryItem *item = App::contextItem()) { if (item->suggestBanReportDeleteAll()) { Ui::showLayer(new RichDeleteMessageBox(item->history()->peer->asChannel(), item->from()->asUser(), item->id)); @@ -953,9 +599,9 @@ void MainWidget::deleteLayer(int32 selectedCount) { connect(box, SIGNAL(destroyed(QObject*)), App::uploader(), SLOT(unpause())); } } - connect(box, SIGNAL(confirmed()), overview ? overview : static_cast(&history), SLOT(onDeleteContextSure())); + connect(box, SIGNAL(confirmed()), _overview ? static_cast(_overview) : static_cast(_history), SLOT(onDeleteContextSure())); } else { - connect(box, SIGNAL(confirmed()), overview ? overview : static_cast(&history), SLOT(onDeleteSelectedSure())); + connect(box, SIGNAL(confirmed()), _overview ? static_cast(_overview) : static_cast(_history), SLOT(onDeleteSelectedSure())); } Ui::showLayer(box); } @@ -1002,11 +648,11 @@ void MainWidget::onForwardCancel(QObject *obj) { } void MainWidget::dialogsActivate() { - dialogs.activate(); + _dialogs->activate(); } DragState MainWidget::getDragState(const QMimeData *mime) { - return history.getDragState(mime); + return _history->getDragState(mime); } bool MainWidget::leaveChatFailed(PeerData *peer, const RPCError &error) { @@ -1065,7 +711,7 @@ void MainWidget::deletedContact(UserData *user, const MTPcontacts_Link &result) } void MainWidget::removeDialog(History *history) { - dialogs.removeDialog(history); + _dialogs->removeDialog(history); } void MainWidget::deleteConversation(PeerData *peer, bool deleteHistory) { @@ -1273,7 +919,7 @@ void MainWidget::checkedHistory(PeerData *peer, const MTPmessages_Messages &resu h->clear(true); h->addNewerSlice(QVector(), 0); h->asChannelHistory()->insertJoinedMessage(true); - history.peerMessagesUpdated(h->peer->id); + _history->peerMessagesUpdated(h->peer->id); } } } else { @@ -1298,7 +944,7 @@ void MainWidget::checkedHistory(PeerData *peer, const MTPmessages_Messages &resu if (peer->isChannel() && peer->asChannel()->inviter > 0 && h->lastMsgDate <= peer->asChannel()->inviteDate && peer->asChannel()->amIn()) { if (UserData *from = App::userLoaded(peer->asChannel()->inviter)) { h->asChannelHistory()->insertJoinedMessage(true); - history.peerMessagesUpdated(h->peer->id); + _history->peerMessagesUpdated(h->peer->id); } } } @@ -1346,35 +992,35 @@ void MainWidget::onCacheBackground() { } void MainWidget::forwardSelectedItems() { - if (overview) { - overview->onForwardSelected(); + if (_overview) { + _overview->onForwardSelected(); } else { - history.onForwardSelected(); + _history->onForwardSelected(); } } void MainWidget::deleteSelectedItems() { - if (overview) { - overview->onDeleteSelected(); + if (_overview) { + _overview->onDeleteSelected(); } else { - history.onDeleteSelected(); + _history->onDeleteSelected(); } } void MainWidget::clearSelectedItems() { - if (overview) { - overview->onClearSelected(); + if (_overview) { + _overview->onClearSelected(); } else { - history.onClearSelected(); + _history->onClearSelected(); } } Dialogs::IndexedList *MainWidget::contactsList() { - return dialogs.contactsList(); + return _dialogs->contactsList(); } Dialogs::IndexedList *MainWidget::dialogsList() { - return dialogs.dialogsList(); + return _dialogs->dialogsList(); } namespace { @@ -1437,9 +1083,9 @@ void executeParsedCommand(const QString &command) { void MainWidget::sendMessage(History *hist, const QString &text, MsgId replyTo, bool broadcast, bool silent, WebPageId webPageId) { readServerHistory(hist, false); - history.fastShowAtEnd(hist); + _history->fastShowAtEnd(hist); - if (!hist || !history.canSendMessages(hist->peer)) { + if (!hist || !_history->canSendMessages(hist->peer)) { return; } @@ -1450,7 +1096,7 @@ void MainWidget::sendMessage(History *hist, const QString &text, MsgId replyTo, QString command = parseCommandFromMessage(hist, text); - if (replyTo < 0) replyTo = history.replyToId(); + if (replyTo < 0) replyTo = _history->replyToId(); while (command.isEmpty() && textSplit(sendingText, sendingEntities, leftText, leftEntities, MaxMessageSize)) { FullMsgId newId(peerToChannel(hist->peer->id), clientMsgId()); uint64 randomId = rand_value(); @@ -1552,32 +1198,32 @@ void MainWidget::readServerHistory(History *hist, bool force) { } uint64 MainWidget::animActiveTimeStart(const HistoryItem *msg) const { - return history.animActiveTimeStart(msg); + return _history->animActiveTimeStart(msg); } void MainWidget::stopAnimActive() { - history.stopAnimActive(); + _history->stopAnimActive(); } void MainWidget::sendBotCommand(PeerData *peer, const QString &cmd, MsgId replyTo) { - history.sendBotCommand(peer, cmd, replyTo); + _history->sendBotCommand(peer, cmd, replyTo); } void MainWidget::app_sendBotCallback(const HistoryMessageReplyMarkup::Button *button, const HistoryItem *msg, int row, int col) { - history.app_sendBotCallback(button, msg, row, col); + _history->app_sendBotCallback(button, msg, row, col); } bool MainWidget::insertBotCommand(const QString &cmd, bool specialGif) { - return history.insertBotCommand(cmd, specialGif); + return _history->insertBotCommand(cmd, specialGif); } void MainWidget::searchMessages(const QString &query, PeerData *inPeer) { App::wnd()->hideMediaview(); - dialogs.searchMessages(query, inPeer); + _dialogs->searchMessages(query, inPeer); if (Adaptive::OneColumn()) { Ui::showChatsList(); } else { - dialogs.activate(); + _dialogs->activate(); } } @@ -1630,17 +1276,17 @@ void MainWidget::overviewPreloaded(PeerData *peer, const MTPmessages_Messages &r } void MainWidget::mediaOverviewUpdated(PeerData *peer, MediaOverviewType type) { - if (profile) profile->mediaOverviewUpdated(peer, type); - if (!_player.isHidden()) _player.mediaOverviewUpdated(peer, type); - if (overview && (overview->peer() == peer || overview->peer()->migrateFrom() == peer)) { - overview->mediaOverviewUpdated(peer, type); + if (_profile) _profile->mediaOverviewUpdated(peer, type); + if (!_player->isHidden()) _player->mediaOverviewUpdated(peer, type); + if (_overview && (_overview->peer() == peer || _overview->peer()->migrateFrom() == peer)) { + _overview->mediaOverviewUpdated(peer, type); int32 mask = 0; History *h = peer ? App::historyLoaded((peer->migrateTo() ? peer->migrateTo() : peer)->id) : 0; History *m = (peer && peer->migrateFrom()) ? App::historyLoaded(peer->migrateFrom()->id) : 0; if (h) { for (int32 i = 0; i < OverviewCount; ++i) { - if (!h->overview[i].isEmpty() || h->overviewCount(i) > 0 || i == overview->type()) { + if (!h->overview[i].isEmpty() || h->overviewCount(i) > 0 || i == _overview->type()) { mask |= (1 << i); } else if (m && (!m->overview[i].isEmpty() || m->overviewCount(i) > 0)) { mask |= (1 << i); @@ -1648,37 +1294,37 @@ void MainWidget::mediaOverviewUpdated(PeerData *peer, MediaOverviewType type) { } } if (mask != _mediaTypeMask) { - _mediaType.resetButtons(); + _mediaType->resetButtons(); for (int32 i = 0; i < OverviewCount; ++i) { if (mask & (1 << i)) { switch (i) { - case OverviewPhotos: connect(_mediaType.addButton(new IconedButton(this, st::dropdownMediaPhotos, lang(lng_media_type_photos))), SIGNAL(clicked()), this, SLOT(onPhotosSelect())); break; - case OverviewVideos: connect(_mediaType.addButton(new IconedButton(this, st::dropdownMediaVideos, lang(lng_media_type_videos))), SIGNAL(clicked()), this, SLOT(onVideosSelect())); break; - case OverviewMusicFiles: connect(_mediaType.addButton(new IconedButton(this, st::dropdownMediaSongs, lang(lng_media_type_songs))), SIGNAL(clicked()), this, SLOT(onSongsSelect())); break; - case OverviewFiles: connect(_mediaType.addButton(new IconedButton(this, st::dropdownMediaDocuments, lang(lng_media_type_files))), SIGNAL(clicked()), this, SLOT(onDocumentsSelect())); break; - case OverviewVoiceFiles: connect(_mediaType.addButton(new IconedButton(this, st::dropdownMediaAudios, lang(lng_media_type_audios))), SIGNAL(clicked()), this, SLOT(onAudiosSelect())); break; - case OverviewLinks: connect(_mediaType.addButton(new IconedButton(this, st::dropdownMediaLinks, lang(lng_media_type_links))), SIGNAL(clicked()), this, SLOT(onLinksSelect())); break; + case OverviewPhotos: connect(_mediaType->addButton(new IconedButton(this, st::dropdownMediaPhotos, lang(lng_media_type_photos))), SIGNAL(clicked()), this, SLOT(onPhotosSelect())); break; + case OverviewVideos: connect(_mediaType->addButton(new IconedButton(this, st::dropdownMediaVideos, lang(lng_media_type_videos))), SIGNAL(clicked()), this, SLOT(onVideosSelect())); break; + case OverviewMusicFiles: connect(_mediaType->addButton(new IconedButton(this, st::dropdownMediaSongs, lang(lng_media_type_songs))), SIGNAL(clicked()), this, SLOT(onSongsSelect())); break; + case OverviewFiles: connect(_mediaType->addButton(new IconedButton(this, st::dropdownMediaDocuments, lang(lng_media_type_files))), SIGNAL(clicked()), this, SLOT(onDocumentsSelect())); break; + case OverviewVoiceFiles: connect(_mediaType->addButton(new IconedButton(this, st::dropdownMediaAudios, lang(lng_media_type_audios))), SIGNAL(clicked()), this, SLOT(onAudiosSelect())); break; + case OverviewLinks: connect(_mediaType->addButton(new IconedButton(this, st::dropdownMediaLinks, lang(lng_media_type_links))), SIGNAL(clicked()), this, SLOT(onLinksSelect())); break; } } } _mediaTypeMask = mask; - _mediaType.move(width() - _mediaType.width(), st::topBarHeight); - overview->updateTopBarSelection(); + _mediaType->move(width() - _mediaType->width(), st::topBarHeight); + _overview->updateTopBarSelection(); } } } void MainWidget::changingMsgId(HistoryItem *row, MsgId newId) { - if (overview) overview->changingMsgId(row, newId); + if (_overview) _overview->changingMsgId(row, newId); } void MainWidget::itemRemoved(HistoryItem *item) { - dialogs.itemRemoved(item); - if (history.peer() == item->history()->peer || (history.peer() && history.peer() == item->history()->peer->migrateTo())) { - history.itemRemoved(item); + _dialogs->itemRemoved(item); + if (_history->peer() == item->history()->peer || (_history->peer() && _history->peer() == item->history()->peer->migrateTo())) { + _history->itemRemoved(item); } - if (overview && (overview->peer() == item->history()->peer || (overview->peer() && overview->peer() == item->history()->peer->migrateTo()))) { - overview->itemRemoved(item); + if (_overview && (_overview->peer() == item->history()->peer || (_overview->peer() && _overview->peer() == item->history()->peer->migrateTo()))) { + _overview->itemRemoved(item); } if (!_toForward.isEmpty()) { SelectedItemSet::iterator i = _toForward.find(item->id); @@ -1696,8 +1342,8 @@ void MainWidget::itemRemoved(HistoryItem *item) { } void MainWidget::itemEdited(HistoryItem *item) { - if (history.peer() == item->history()->peer || (history.peer() && history.peer() == item->history()->peer->migrateTo())) { - history.itemEdited(item); + if (_history->peer() == item->history()->peer || (_history->peer() && _history->peer() == item->history()->peer->migrateTo())) { + _history->itemEdited(item); } } @@ -1734,8 +1380,8 @@ void MainWidget::loadMediaBack(PeerData *peer, MediaOverviewType type, bool many } void MainWidget::peerUsernameChanged(PeerData *peer) { - if (profile && profile->peer() == peer) { - profile->peerUsernameChanged(); + if (_profile && _profile->peer() == peer) { + _profile->peerUsernameChanged(); } if (App::settings() && peer == App::self()) { App::settings()->usernameChanged(); @@ -1751,11 +1397,11 @@ void MainWidget::checkLastUpdate(bool afterSleep) { } void MainWidget::showAddContact() { - dialogs.onAddContact(); + _dialogs->onAddContact(); } void MainWidget::showNewGroup() { - dialogs.onNewGroup(); + _dialogs->onNewGroup(); } void MainWidget::overviewLoaded(History *history, const MTPmessages_Messages &result, mtpRequestId req) { @@ -1910,13 +1556,13 @@ void MainWidget::documentPlayProgress(const SongMsgId &songId) { } if (playing == songId) { - _player.updateState(playing, playingState, playingPosition, playingDuration, playingFrequency); + _player->updateState(playing, playingState, playingPosition, playingDuration, playingFrequency); if (!(playingState & AudioPlayerStoppedMask) && playingState != AudioPlayerFinishing && !_a_show.animating()) { - if (_player.isHidden()) { - _player.clearSelection(); - _player.show(); - _playerHeight = _contentScrollAddToY = _player.height(); + if (_player->isHidden()) { + _player->clearSelection(); + _player->show(); + _playerHeight = _contentScrollAddToY = _player->height(); resizeEvent(0); } } @@ -1933,9 +1579,9 @@ void MainWidget::documentPlayProgress(const SongMsgId &songId) { } void MainWidget::hidePlayer() { - if (!_player.isHidden()) { - _player.hide(); - _contentScrollAddToY = -_player.height(); + if (!_player->isHidden()) { + _player->hide(); + _contentScrollAddToY = -_player->height(); _playerHeight = 0; resizeEvent(0); } @@ -1965,8 +1611,8 @@ void MainWidget::documentLoadProgress(FileLoader *loader) { int64 playingPosition = 0, playingDuration = 0; int32 playingFrequency = 0; audioPlayer()->currentState(&playing, &playingState, &playingPosition, &playingDuration, &playingFrequency); - if (playing.song == document && !_player.isHidden()) { - _player.updateState(playing, playingState, playingPosition, playingDuration, playingFrequency); + if (playing.song == document && !_player->isHidden()) { + _player->updateState(playing, playingState, playingPosition, playingDuration, playingFrequency); } } } @@ -2037,27 +1683,27 @@ void MainWidget::onParentResize(const QSize &newSize) { void MainWidget::updateOnlineDisplay() { if (this != App::main()) return; - history.updateOnlineDisplay(history.x(), width() - history.x() - st::sysBtnDelta * 2 - st::sysCls.img.pxWidth() - st::sysRes.img.pxWidth() - st::sysMin.img.pxWidth()); - if (profile) profile->updateOnlineDisplay(); + _history->updateOnlineDisplay(_history->x(), width() - _history->x() - st::sysBtnDelta * 2 - st::sysCls.img.pxWidth() - st::sysRes.img.pxWidth() - st::sysMin.img.pxWidth()); + if (_profile) _profile->updateOnlineDisplay(); if (App::wnd()->settingsWidget()) App::wnd()->settingsWidget()->updateOnlineDisplay(); } void MainWidget::onSendFileConfirm(const FileLoadResultPtr &file, bool ctrlShiftEnter) { - bool lastKeyboardUsed = history.lastForceReplyReplied(FullMsgId(peerToChannel(file->to.peer), file->to.replyTo)); - history.confirmSendFile(file, ctrlShiftEnter); - history.cancelReply(lastKeyboardUsed); + bool lastKeyboardUsed = _history->lastForceReplyReplied(FullMsgId(peerToChannel(file->to.peer), file->to.replyTo)); + _history->confirmSendFile(file, ctrlShiftEnter); + _history->cancelReply(lastKeyboardUsed); } void MainWidget::onSendFileCancel(const FileLoadResultPtr &file) { - history.cancelSendFile(file); + _history->cancelSendFile(file); } void MainWidget::onShareContactConfirm(const QString &phone, const QString &fname, const QString &lname, MsgId replyTo, bool ctrlShiftEnter) { - history.confirmShareContact(phone, fname, lname, replyTo, ctrlShiftEnter); + _history->confirmShareContact(phone, fname, lname, replyTo, ctrlShiftEnter); } void MainWidget::onShareContactCancel() { - history.cancelShareContact(); + _history->cancelShareContact(); } void MainWidget::dialogsCancelled() { @@ -2065,7 +1711,7 @@ void MainWidget::dialogsCancelled() { _hider->startHide(); noHider(_hider); } - history.activate(); + _history->activate(); } void MainWidget::serviceNotification(const QString &msg, const MTPMessageMedia &media) { @@ -2078,7 +1724,7 @@ void MainWidget::serviceNotification(const QString &msg, const MTPMessageMedia & item = App::histories().addNewMessage(MTP_message(MTP_flags(flags), MTP_int(clientMsgId()), MTP_int(ServiceUserId), MTP_peerUser(MTP_int(MTP::authedId())), MTPnullFwdHeader, MTPint(), MTPint(), MTP_int(unixtime()), MTP_string(sendingText), media, MTPnullMarkup, localEntities, MTPint(), MTPint()), NewMessageUnread); } if (item) { - history.peerMessagesUpdated(item->history()->peer->id); + _history->peerMessagesUpdated(item->history()->peer->id); } } @@ -2169,12 +1815,12 @@ void MainWidget::backgroundParams(const QRect &forRect, QRect &to, QRect &from) } void MainWidget::updateScrollColors() { - history.updateScrollColors(); - if (overview) overview->updateScrollColors(); + _history->updateScrollColors(); + if (_overview) _overview->updateScrollColors(); } void MainWidget::setChatBackground(const App::WallPaper &wp) { - _background = new App::WallPaper(wp); + _background = std_::make_unique(wp); _background->full->loadEvenCancelled(); checkChatBackground(); } @@ -2193,8 +1839,7 @@ void MainWidget::checkChatBackground() { } else { App::initBackground(_background->id, _background->full->pix().toImage()); } - delete _background; - _background = 0; + _background = nullptr; QTimer::singleShot(0, this, SLOT(update())); } } @@ -2205,38 +1850,38 @@ ImagePtr MainWidget::newBackgroundThumb() { } ApiWrap *MainWidget::api() { - return _api; + return _api.get(); } void MainWidget::messageDataReceived(ChannelData *channel, MsgId msgId) { - history.messageDataReceived(channel, msgId); + _history->messageDataReceived(channel, msgId); } void MainWidget::updateBotKeyboard(History *h) { - history.updateBotKeyboard(h); + _history->updateBotKeyboard(h); } void MainWidget::pushReplyReturn(HistoryItem *item) { - history.pushReplyReturn(item); + _history->pushReplyReturn(item); } void MainWidget::setInnerFocus() { - if (_hider || !history.peer()) { + if (_hider || !_history->peer()) { if (_hider && _hider->wasOffered()) { _hider->setFocus(); - } else if (overview) { - overview->activate(); - } else if (profile) { - profile->activate(); + } else if (_overview) { + _overview->activate(); + } else if (_profile) { + _profile->activate(); } else { dialogsActivate(); } - } else if (overview) { - overview->activate(); - } else if (profile) { - profile->activate(); + } else if (_overview) { + _overview->activate(); + } else if (_profile) { + _profile->activate(); } else { - history.setInnerFocus(); + _history->setInnerFocus(); } } @@ -2315,11 +1960,11 @@ bool MainWidget::viewsIncrementFail(const RPCError &error, mtpRequestId req) { } HistoryItem *MainWidget::atTopImportantMsg(int32 &bottomUnderScrollTop) const { - return history.atTopImportantMsg(bottomUnderScrollTop); + return _history->atTopImportantMsg(bottomUnderScrollTop); } void MainWidget::createDialog(History *history) { - dialogs.createDialog(history); + _dialogs->createDialog(history); } void MainWidget::choosePeer(PeerId peerId, MsgId showAtMsgId) { @@ -2337,19 +1982,19 @@ void MainWidget::clearBotStartToken(PeerData *peer) { } void MainWidget::contactsReceived() { - history.contactsReceived(); + _history->contactsReceived(); } void MainWidget::updateAfterDrag() { - if (overview) { - overview->updateAfterDrag(); + if (_overview) { + _overview->updateAfterDrag(); } else { - history.updateAfterDrag(); + _history->updateAfterDrag(); } } void MainWidget::ctrlEnterSubmitUpdated() { - history.updateFieldSubmitSettings(); + _history->updateFieldSubmitSettings(); } void MainWidget::ui_showPeerHistory(quint64 peerId, qint32 showAtMsgId, bool back) { @@ -2375,11 +2020,11 @@ void MainWidget::ui_showPeerHistory(quint64 peerId, qint32 showAtMsgId, bool bac Ui::hideLayer(); if (_hider) { _hider->startHide(); - _hider = 0; + _hider = nullptr; } QPixmap animCache, animTopBarCache; - if (!_a_show.animating() && ((history.isHidden() && (profile || overview)) || (Adaptive::OneColumn() && (history.isHidden() || !peerId)))) { + if (!_a_show.animating() && ((_history->isHidden() && (_profile || _overview)) || (Adaptive::OneColumn() && (_history->isHidden() || !peerId)))) { if (peerId) { animCache = grabInner(); } else if (Adaptive::OneColumn()) { @@ -2390,26 +2035,26 @@ void MainWidget::ui_showPeerHistory(quint64 peerId, qint32 showAtMsgId, bool bac if (peerId || !Adaptive::OneColumn()) { animTopBarCache = grabTopBar(); } - history.show(); + _history->show(); } - if (history.peer() && history.peer()->id != peerId) clearBotStartToken(history.peer()); - history.showHistory(peerId, showAtMsgId); + if (_history->peer() && _history->peer()->id != peerId) clearBotStartToken(_history->peer()); + _history->showHistory(peerId, showAtMsgId); - bool noPeer = (!history.peer() || !history.peer()->id), onlyDialogs = noPeer && Adaptive::OneColumn(); - if (profile || overview) { - if (profile) { - profile->hide(); - profile->clear(); - profile->deleteLater(); - profile->rpcClear(); - profile = 0; + bool noPeer = (!_history->peer() || !_history->peer()->id), onlyDialogs = noPeer && Adaptive::OneColumn(); + if (_profile || _overview) { + if (_profile) { + _profile->hide(); + _profile->clear(); + _profile->deleteLater(); + _profile->rpcClear(); + _profile = nullptr; } - if (overview) { - overview->hide(); - overview->clear(); - overview->deleteLater(); - overview->rpcClear(); - overview = 0; + if (_overview) { + _overview->hide(); + _overview->clear(); + _overview->deleteLater(); + _overview->rpcClear(); + _overview = nullptr; } clearBotStartToken(_peerInStack); dlgUpdated(); @@ -2418,17 +2063,17 @@ void MainWidget::ui_showPeerHistory(quint64 peerId, qint32 showAtMsgId, bool bac _stack.clear(); } if (onlyDialogs) { - _topBar.hide(); - history.hide(); + _topBar->hide(); + _history->hide(); if (!_a_show.animating()) { - dialogs.show(); + _dialogs->show(); if (!animCache.isNull()) { - dialogs.animShow(animCache); + _dialogs->animShow(animCache); } } } else { if (noPeer) { - _topBar.hide(); + _topBar->hide(); resizeEvent(0); } else if (wasActivePeer != activePeer()) { if (activePeer()->isChannel()) { @@ -2436,11 +2081,11 @@ void MainWidget::ui_showPeerHistory(quint64 peerId, qint32 showAtMsgId, bool bac } _viewsIncremented.remove(activePeer()); } - if (Adaptive::OneColumn() && !dialogs.isHidden()) dialogs.hide(); + if (Adaptive::OneColumn() && !_dialogs->isHidden()) _dialogs->hide(); if (!_a_show.animating()) { - if (history.isHidden()) history.show(); + if (_history->isHidden()) _history->show(); if (!animCache.isNull()) { - history.animShow(animCache, animTopBarCache, back); + _history->animShow(animCache, animTopBarCache, back); } else if (App::wnd()) { QTimer::singleShot(0, App::wnd(), SLOT(setInnerFocus())); } @@ -2450,20 +2095,20 @@ void MainWidget::ui_showPeerHistory(quint64 peerId, qint32 showAtMsgId, bool bac // wasActivePeer->asChannel()->ptsWaitingForShortPoll(false); //} - if (!dialogs.isHidden()) { + if (!_dialogs->isHidden()) { if (!back) { - dialogs.scrollToPeer(peerId, showAtMsgId); + _dialogs->scrollToPeer(peerId, showAtMsgId); } - dialogs.update(); + _dialogs->update(); } App::wnd()->getTitle()->updateBackButton(); } PeerData *MainWidget::ui_getPeerForMouseAction() { - if (profile) { - return profile->ui_getPeerForMouseAction(); + if (_profile) { + return _profile->ui_getPeerForMouseAction(); } - return history.ui_getPeerForMouseAction(); + return _history->ui_getPeerForMouseAction(); } void MainWidget::peerBefore(const PeerData *inPeer, MsgId inMsg, PeerData *&outPeer, MsgId &outMsg) { @@ -2472,7 +2117,7 @@ void MainWidget::peerBefore(const PeerData *inPeer, MsgId inMsg, PeerData *&outP outMsg = 0; return; } - dialogs.peerBefore(inPeer, inMsg, outPeer, outMsg); + _dialogs->peerBefore(inPeer, inMsg, outPeer, outMsg); } void MainWidget::peerAfter(const PeerData *inPeer, MsgId inMsg, PeerData *&outPeer, MsgId &outMsg) { @@ -2481,35 +2126,35 @@ void MainWidget::peerAfter(const PeerData *inPeer, MsgId inMsg, PeerData *&outPe outMsg = 0; return; } - dialogs.peerAfter(inPeer, inMsg, outPeer, outMsg); + _dialogs->peerAfter(inPeer, inMsg, outPeer, outMsg); } PeerData *MainWidget::historyPeer() { - return history.peer(); + return _history->peer(); } PeerData *MainWidget::peer() { - return overview ? overview->peer() : history.peer(); + return _overview ? _overview->peer() : _history->peer(); } PeerData *MainWidget::activePeer() { - return history.peer() ? history.peer() : _peerInStack; + return _history->peer() ? _history->peer() : _peerInStack; } MsgId MainWidget::activeMsgId() { - return history.peer() ? history.msgId() : _msgIdInStack; + return _history->peer() ? _history->msgId() : _msgIdInStack; } PeerData *MainWidget::profilePeer() { - return profile ? profile->peer() : 0; + return _profile ? _profile->peer() : 0; } PeerData *MainWidget::overviewPeer() { - return overview ? overview->peer() : 0; + return _overview ? _overview->peer() : 0; } bool MainWidget::mediaTypeSwitch() { - if (!overview) return false; + if (!_overview) return false; for (int32 i = 0; i < OverviewCount; ++i) { if (!(_mediaTypeMask & ~(1 << i))) { @@ -2525,63 +2170,63 @@ void MainWidget::showMediaOverview(PeerData *peer, MediaOverviewType type, bool } App::wnd()->hideSettings(); - if (overview && overview->peer() == peer) { - if (overview->type() != type) { - overview->switchType(type); + if (_overview && _overview->peer() == peer) { + if (_overview->type() != type) { + _overview->switchType(type); } else if (type == OverviewMusicFiles) { // hack for player showBackFromStack(); } return; } - QRect topBarRect = QRect(_topBar.x(), _topBar.y(), _topBar.width(), st::topBarHeight); - QRect historyRect = QRect(history.x(), topBarRect.y() + topBarRect.height(), history.width(), history.y() + history.height() - topBarRect.y() - topBarRect.height()); + QRect topBarRect = QRect(_topBar->x(), _topBar->y(), _topBar->width(), st::topBarHeight); + QRect historyRect = QRect(_history->x(), topBarRect.y() + topBarRect.height(), _history->width(), _history->y() + _history->height() - topBarRect.y() - topBarRect.height()); QPixmap animCache, animTopBarCache; - if (!_a_show.animating() && (Adaptive::OneColumn() || profile || overview || history.peer())) { + if (!_a_show.animating() && (Adaptive::OneColumn() || _profile || _overview || _history->peer())) { animCache = grabInner(); animTopBarCache = grabTopBar(); } if (!back) { - if (overview) { - _stack.push_back(new StackItemOverview(overview->peer(), overview->type(), overview->lastWidth(), overview->lastScrollTop())); - } else if (profile) { - _stack.push_back(new StackItemProfile(profile->peer(), profile->lastScrollTop())); - } else if (history.peer()) { + if (_overview) { + _stack.push_back(new StackItemOverview(_overview->peer(), _overview->type(), _overview->lastWidth(), _overview->lastScrollTop())); + } else if (_profile) { + _stack.push_back(new StackItemProfile(_profile->peer(), _profile->lastScrollTop())); + } else if (_history->peer()) { dlgUpdated(); - _peerInStack = history.peer(); - _msgIdInStack = history.msgId(); + _peerInStack = _history->peer(); + _msgIdInStack = _history->msgId(); dlgUpdated(); - _stack.push_back(new StackItemHistory(_peerInStack, _msgIdInStack, history.replyReturns())); + _stack.push_back(new StackItemHistory(_peerInStack, _msgIdInStack, _history->replyReturns())); } } - if (overview) { - overview->hide(); - overview->clear(); - overview->deleteLater(); - overview->rpcClear(); + if (_overview) { + _overview->hide(); + _overview->clear(); + _overview->deleteLater(); + _overview->rpcClear(); } - if (profile) { - profile->hide(); - profile->clear(); - profile->deleteLater(); - profile->rpcClear(); - profile = 0; + if (_profile) { + _profile->hide(); + _profile->clear(); + _profile->deleteLater(); + _profile->rpcClear(); + _profile = nullptr; } - overview = new OverviewWidget(this, peer, type); + _overview = new OverviewWidget(this, peer, type); _mediaTypeMask = 0; - _topBar.show(); - resizeEvent(0); + _topBar->show(); + resizeEvent(nullptr); mediaOverviewUpdated(peer, type); if (!animCache.isNull()) { - overview->animShow(animCache, animTopBarCache, back, lastScrollTop); + _overview->animShow(animCache, animTopBarCache, back, lastScrollTop); } else { - overview->fastShow(); + _overview->fastShow(); } - history.animStop(); - if (back) clearBotStartToken(history.peer()); - history.showHistory(0, 0); - history.hide(); - if (Adaptive::OneColumn()) dialogs.hide(); + _history->animStop(); + if (back) clearBotStartToken(_history->peer()); + _history->showHistory(0, 0); + _history->hide(); + if (Adaptive::OneColumn()) _dialogs->hide(); orderWidgets(); @@ -2594,44 +2239,44 @@ void MainWidget::showPeerProfile(PeerData *peer, bool back, int32 lastScrollTop) } App::wnd()->hideSettings(); - if (profile && profile->peer() == peer) return; + if (_profile && _profile->peer() == peer) return; QPixmap animCache = grabInner(), animTopBarCache = grabTopBar(); if (!back) { - if (overview) { - _stack.push_back(new StackItemOverview(overview->peer(), overview->type(), overview->lastWidth(), overview->lastScrollTop())); - } else if (profile) { - _stack.push_back(new StackItemProfile(profile->peer(), profile->lastScrollTop())); - } else if (history.peer()) { + if (_overview) { + _stack.push_back(new StackItemOverview(_overview->peer(), _overview->type(), _overview->lastWidth(), _overview->lastScrollTop())); + } else if (_profile) { + _stack.push_back(new StackItemProfile(_profile->peer(), _profile->lastScrollTop())); + } else if (_history->peer()) { dlgUpdated(); - _peerInStack = history.peer(); - _msgIdInStack = history.msgId(); + _peerInStack = _history->peer(); + _msgIdInStack = _history->msgId(); dlgUpdated(); - _stack.push_back(new StackItemHistory(_peerInStack, _msgIdInStack, history.replyReturns())); + _stack.push_back(new StackItemHistory(_peerInStack, _msgIdInStack, _history->replyReturns())); } } - if (overview) { - overview->hide(); - overview->clear(); - overview->deleteLater(); - overview->rpcClear(); - overview = 0; + if (_overview) { + _overview->hide(); + _overview->clear(); + _overview->deleteLater(); + _overview->rpcClear(); + _overview = nullptr; } - if (profile) { - profile->hide(); - profile->clear(); - profile->deleteLater(); - profile->rpcClear(); + if (_profile) { + _profile->hide(); + _profile->clear(); + _profile->deleteLater(); + _profile->rpcClear(); } - profile = new ProfileWidget(this, peer); - _topBar.show(); + _profile = new ProfileWidget(this, peer); + _topBar->show(); resizeEvent(0); - profile->animShow(animCache, animTopBarCache, back, lastScrollTop); - history.animStop(); - if (back) clearBotStartToken(history.peer()); - history.showHistory(0, 0); - history.hide(); - if (Adaptive::OneColumn()) dialogs.hide(); + _profile->animShow(animCache, animTopBarCache, back, lastScrollTop); + _history->animStop(); + if (back) clearBotStartToken(_history->peer()); + _history->showHistory(0, 0); + _history->hide(); + if (Adaptive::OneColumn()) _dialogs->hide(); orderWidgets(); @@ -2661,7 +2306,7 @@ void MainWidget::showBackFromStack() { } StackItemHistory *histItem = static_cast(item); Ui::showPeerHistory(histItem->peer->id, App::main()->activeMsgId(), true); - history.setReplyReturns(histItem->peer->id, histItem->replyReturns); + _history->setReplyReturns(histItem->peer->id, histItem->replyReturns); } else if (item->type() == ProfileStackItem) { StackItemProfile *profItem = static_cast(item); showPeerProfile(profItem->peer, true, profItem->lastScrollTop); @@ -2673,43 +2318,43 @@ void MainWidget::showBackFromStack() { } void MainWidget::orderWidgets() { - _topBar.raise(); - _player.raise(); - dialogs.raise(); - _mediaType.raise(); + _topBar->raise(); + _player->raise(); + _dialogs->raise(); + _mediaType->raise(); if (_hider) _hider->raise(); } QRect MainWidget::historyRect() const { - QRect r(history.historyRect()); - r.moveLeft(r.left() + history.x()); - r.moveTop(r.top() + history.y()); + QRect r(_history->historyRect()); + r.moveLeft(r.left() + _history->x()); + r.moveTop(r.top() + _history->y()); return r; } void MainWidget::dlgUpdated() { if (_peerInStack) { - dialogs.dlgUpdated(App::history(_peerInStack->id), _msgIdInStack); + _dialogs->dlgUpdated(App::history(_peerInStack->id), _msgIdInStack); } } void MainWidget::dlgUpdated(Dialogs::Mode list, Dialogs::Row *row) { if (row) { - dialogs.dlgUpdated(list, row); + _dialogs->dlgUpdated(list, row); } } void MainWidget::dlgUpdated(History *row, MsgId msgId) { if (!row) return; if (msgId < 0 && -msgId < ServerMaxMsgId && row->peer->migrateFrom()) { - dialogs.dlgUpdated(App::history(row->peer->migrateFrom()->id), -msgId); + _dialogs->dlgUpdated(App::history(row->peer->migrateFrom()->id), -msgId); } else { - dialogs.dlgUpdated(row, msgId); + _dialogs->dlgUpdated(row, msgId); } } void MainWidget::windowShown() { - history.windowShown(); + _history->windowShown(); } void MainWidget::sentUpdatesReceived(uint64 randomId, const MTPUpdates &result) { @@ -2739,23 +2384,23 @@ void MainWidget::onActiveChannelUpdateFull() { } void MainWidget::historyToDown(History *hist) { - history.historyToDown(hist); + _history->historyToDown(hist); } void MainWidget::dialogsToUp() { - dialogs.dialogsToUp(); + _dialogs->dialogsToUp(); } void MainWidget::newUnreadMsg(History *hist, HistoryItem *item) { - history.newUnreadMsg(hist, item); + _history->newUnreadMsg(hist, item); } void MainWidget::historyWasRead() { - history.historyWasRead(false); + _history->historyWasRead(false); } void MainWidget::historyCleared(History *hist) { - history.historyCleared(hist); + _history->historyCleared(hist); } void MainWidget::animShow(const QPixmap &bgAnimCache, bool back) { @@ -2822,17 +2467,17 @@ void MainWidget::paintEvent(QPaintEvent *e) { } void MainWidget::hideAll() { - dialogs.hide(); - history.hide(); - if (profile) { - profile->hide(); + _dialogs->hide(); + _history->hide(); + if (_profile) { + _profile->hide(); } - if (overview) { - overview->hide(); + if (_overview) { + _overview->hide(); } - _topBar.hide(); - _mediaType.hide(); - _player.hide(); + _topBar->hide(); + _mediaType->hide(); + _player->hide(); _playerHeight = 0; } @@ -2852,25 +2497,25 @@ void MainWidget::showAll() { } } if (selectingPeer()) { - dialogs.show(); - history.hide(); - if (overview) overview->hide(); - if (profile) profile->hide(); - _topBar.hide(); - } else if (overview) { - overview->show(); - } else if (profile) { - profile->show(); - } else if (history.peer()) { - history.show(); - history.resizeEvent(0); + _dialogs->show(); + _history->hide(); + if (_overview) _overview->hide(); + if (_profile) _profile->hide(); + _topBar->hide(); + } else if (_overview) { + _overview->show(); + } else if (_profile) { + _profile->show(); + } else if (_history->peer()) { + _history->show(); + _history->resizeEvent(0); } else { - dialogs.show(); - history.hide(); + _dialogs->show(); + _history->hide(); } - if (!selectingPeer() && (profile || overview || history.peer())) { - _topBar.show(); - dialogs.hide(); + if (!selectingPeer() && (_profile || _overview || _history->peer())) { + _topBar->show(); + _dialogs->hide(); } } else { if (_hider) { @@ -2880,17 +2525,17 @@ void MainWidget::showAll() { _forwardConfirm = 0; } } - dialogs.show(); - if (overview) { - overview->show(); - } else if (profile) { - profile->show(); + _dialogs->show(); + if (_overview) { + _overview->show(); + } else if (_profile) { + _profile->show(); } else { - history.show(); - history.resizeEvent(0); + _history->show(); + _history->resizeEvent(0); } - if (profile || overview || history.peer()) { - _topBar.show(); + if (_profile || _overview || _history->peer()) { + _topBar->show(); } } if (audioPlayer()) { @@ -2900,11 +2545,11 @@ void MainWidget::showAll() { int32 playingFrequency = 0; audioPlayer()->currentState(&playing, &playingState, &playingPosition, &playingDuration, &playingFrequency); if (playing) { - _player.updateState(playing, playingState, playingPosition, playingDuration, playingFrequency); + _player->updateState(playing, playingState, playingPosition, playingDuration, playingFrequency); if (!(playingState & AudioPlayerStoppedMask) && playingState != AudioPlayerFinishing) { - _player.clearSelection(); - _player.show(); - _playerHeight = _player.height(); + _player->clearSelection(); + _player->show(); + _playerHeight = _player->height(); } } } @@ -2914,32 +2559,32 @@ void MainWidget::showAll() { } void MainWidget::resizeEvent(QResizeEvent *e) { - int32 tbh = _topBar.isHidden() ? 0 : st::topBarHeight; + int32 tbh = _topBar->isHidden() ? 0 : st::topBarHeight; if (Adaptive::OneColumn()) { _dialogsWidth = width(); - _player.setGeometry(0, 0, _dialogsWidth, _player.height()); - dialogs.setGeometry(0, _playerHeight, _dialogsWidth, height() - _playerHeight); - _topBar.setGeometry(0, _playerHeight, _dialogsWidth, st::topBarHeight); - history.setGeometry(0, _playerHeight + tbh, _dialogsWidth, height() - _playerHeight - tbh); + _player->setGeometry(0, 0, _dialogsWidth, _player->height()); + _dialogs->setGeometry(0, _playerHeight, _dialogsWidth, height() - _playerHeight); + _topBar->setGeometry(0, _playerHeight, _dialogsWidth, st::topBarHeight); + _history->setGeometry(0, _playerHeight + tbh, _dialogsWidth, height() - _playerHeight - tbh); if (_hider) _hider->setGeometry(0, 0, _dialogsWidth, height()); } else { _dialogsWidth = chatsListWidth(width()); - dialogs.resize(_dialogsWidth, height()); - dialogs.moveToLeft(0, 0); - _player.resize(width() - _dialogsWidth, _player.height()); - _player.moveToLeft(_dialogsWidth, 0); - _topBar.resize(width() - _dialogsWidth, st::topBarHeight); - _topBar.moveToLeft(_dialogsWidth, _playerHeight); - history.resize(width() - _dialogsWidth, height() - _playerHeight - tbh); - history.moveToLeft(_dialogsWidth, _playerHeight + tbh); + _dialogs->resize(_dialogsWidth, height()); + _dialogs->moveToLeft(0, 0); + _player->resize(width() - _dialogsWidth, _player->height()); + _player->moveToLeft(_dialogsWidth, 0); + _topBar->resize(width() - _dialogsWidth, st::topBarHeight); + _topBar->moveToLeft(_dialogsWidth, _playerHeight); + _history->resize(width() - _dialogsWidth, height() - _playerHeight - tbh); + _history->moveToLeft(_dialogsWidth, _playerHeight + tbh); if (_hider) { _hider->resize(width() - _dialogsWidth, height()); _hider->moveToLeft(_dialogsWidth, 0); } } - _mediaType.moveToLeft(width() - _mediaType.width(), _playerHeight + st::topBarHeight); - if (profile) profile->setGeometry(history.geometry()); - if (overview) overview->setGeometry(history.geometry()); + _mediaType->moveToLeft(width() - _mediaType->width(), _playerHeight + st::topBarHeight); + if (_profile) _profile->setGeometry(_history->geometry()); + if (_overview) _overview->setGeometry(_history->geometry()); _contentScrollAddToY = 0; } @@ -2952,96 +2597,96 @@ void MainWidget::keyPressEvent(QKeyEvent *e) { void MainWidget::updateAdaptiveLayout() { showAll(); - _topBar.updateAdaptiveLayout(); - history.updateAdaptiveLayout(); - if (overview) overview->updateAdaptiveLayout(); - if (profile) profile->updateAdaptiveLayout(); - _player.updateAdaptiveLayout(); + _topBar->updateAdaptiveLayout(); + _history->updateAdaptiveLayout(); + if (_overview) _overview->updateAdaptiveLayout(); + if (_profile) _profile->updateAdaptiveLayout(); + _player->updateAdaptiveLayout(); } bool MainWidget::needBackButton() { - return overview || profile || (history.peer() && history.peer()->id); + return _overview || _profile || (_history->peer() && _history->peer()->id); } void MainWidget::paintTopBar(QPainter &p, float64 over, int32 decreaseWidth) { - if (profile) { - profile->paintTopBar(p, over, decreaseWidth); - } else if (overview) { - overview->paintTopBar(p, over, decreaseWidth); + if (_profile) { + _profile->paintTopBar(p, over, decreaseWidth); + } else if (_overview) { + _overview->paintTopBar(p, over, decreaseWidth); } else { - history.paintTopBar(p, over, decreaseWidth); + _history->paintTopBar(p, over, decreaseWidth); } } void MainWidget::onPhotosSelect() { - if (overview) overview->switchType(OverviewPhotos); - _mediaType.hideStart(); + if (_overview) _overview->switchType(OverviewPhotos); + _mediaType->hideStart(); } void MainWidget::onVideosSelect() { - if (overview) overview->switchType(OverviewVideos); - _mediaType.hideStart(); + if (_overview) _overview->switchType(OverviewVideos); + _mediaType->hideStart(); } void MainWidget::onSongsSelect() { - if (overview) overview->switchType(OverviewMusicFiles); - _mediaType.hideStart(); + if (_overview) _overview->switchType(OverviewMusicFiles); + _mediaType->hideStart(); } void MainWidget::onDocumentsSelect() { - if (overview) overview->switchType(OverviewFiles); - _mediaType.hideStart(); + if (_overview) _overview->switchType(OverviewFiles); + _mediaType->hideStart(); } void MainWidget::onAudiosSelect() { - if (overview) overview->switchType(OverviewVoiceFiles); - _mediaType.hideStart(); + if (_overview) _overview->switchType(OverviewVoiceFiles); + _mediaType->hideStart(); } void MainWidget::onLinksSelect() { - if (overview) overview->switchType(OverviewLinks); - _mediaType.hideStart(); + if (_overview) _overview->switchType(OverviewLinks); + _mediaType->hideStart(); } -TopBarWidget *MainWidget::topBar() { - return &_topBar; +Window::TopBarWidget *MainWidget::topBar() { + return _topBar; } PlayerWidget *MainWidget::player() { - return &_player; + return _player; } void MainWidget::onTopBarClick() { - if (profile) { - profile->topBarClick(); - } else if (overview) { - overview->topBarClick(); + if (_profile) { + _profile->topBarClick(); + } else if (_overview) { + _overview->topBarClick(); } else { - history.topBarClick(); + _history->topBarClick(); } } void MainWidget::onHistoryShown(History *history, MsgId atMsgId) { - if ((!Adaptive::OneColumn() || !selectingPeer()) && (profile || overview || history)) { - _topBar.show(); + if ((!Adaptive::OneColumn() || !selectingPeer()) && (_profile || _overview || history)) { + _topBar->show(); } else { - _topBar.hide(); + _topBar->hide(); } resizeEvent(0); if (_a_show.animating()) { - _topBar.hide(); + _topBar->hide(); } dlgUpdated(history, atMsgId); } void MainWidget::searchInPeer(PeerData *peer) { - dialogs.searchInPeer(peer); + _dialogs->searchInPeer(peer); if (Adaptive::OneColumn()) { dialogsToUp(); Ui::showChatsList(); } else { - dialogs.activate(); + _dialogs->activate(); } } @@ -3147,9 +2792,9 @@ void MainWidget::gotChannelDifference(ChannelData *channel, const MTPupdates_Cha h->asChannelHistory()->unreadCountAll = d.vunread_count.v; h->inboxReadBefore = d.vread_inbox_max_id.v + 1; } - if (history.peer() == channel) { - history.updateToEndVisibility(); - history.preloadHistoryIfNeeded(); + if (_history->peer() == channel) { + _history->updateToEndVisibility(); + _history->preloadHistoryIfNeeded(); } h->asChannelHistory()->getRangeDifference(); } @@ -3177,7 +2822,7 @@ void MainWidget::gotChannelDifference(ChannelData *channel, const MTPupdates_Cha switch (msg.type()) { case mtpc_message: { const auto &d(msg.c_message()); - if (App::checkEntitiesAndViewsUpdate(d)) { // new message, index my forwarded messages to links overview, already in blocks + if (App::checkEntitiesAndViewsUpdate(d)) { // new message, index my forwarded messages to links _overview, already in blocks LOG(("Skipping message, because it is already in blocks!")); } else { msgsIds.insert((uint64(uint32(d.vid.v)) << 32) | uint64(i), i + 1); @@ -3299,7 +2944,7 @@ void MainWidget::gotState(const MTPupdates_State &state) { noUpdatesTimer.start(NoUpdatesTimeout); _ptsWaiter.setRequesting(false); - dialogs.loadDialogs(); + _dialogs->loadDialogs(); updateOnline(); App::emitPeerUpdated(); @@ -3435,7 +3080,7 @@ void MainWidget::feedDifference(const MTPVector &users, const MTPVector feedMessageIds(other); App::feedMsgs(msgs, NewMessageUnread); feedUpdateVector(other, true); - history.peerMessagesUpdated(); + _history->peerMessagesUpdated(); } bool MainWidget::failDifference(const RPCError &error) { @@ -3584,7 +3229,7 @@ void MainWidget::start(const MTPUser &user) { App::wnd()->sendServiceHistoryRequest(); Local::readStickers(); Local::readSavedGifs(); - history.start(); + _history->start(); } bool MainWidget::started() { @@ -3663,9 +3308,9 @@ void MainWidget::openPeerByName(const QString &username, MsgId msgId, const QStr } if (peer->isUser() && peer->asUser()->botInfo) { peer->asUser()->botInfo->startToken = startToken; - if (peer == history.peer()) { - history.updateControlsVisibility(); - history.resizeEvent(0); + if (peer == _history->peer()) { + _history->updateControlsVisibility(); + _history->resizeEvent(0); } } Ui::showPeerHistoryAsync(peer->id, msgId); @@ -3689,7 +3334,7 @@ void MainWidget::stickersBox(const MTPInputStickerSet &set) { void MainWidget::onStickersInstalled(uint64 setId) { emit stickersUpdated(); - history.stickersInstalled(setId); + _history->stickersInstalled(setId); } void MainWidget::onFullPeerUpdated(PeerData *peer) { @@ -3704,17 +3349,17 @@ void MainWidget::onSelfParticipantUpdated(ChannelData *channel) { checkPeerHistory(channel); } else { h->asChannelHistory()->checkJoinedMessage(true); - history.peerMessagesUpdated(channel->id); + _history->peerMessagesUpdated(channel->id); } } else if (h) { h->asChannelHistory()->checkJoinedMessage(); - history.peerMessagesUpdated(channel->id); + _history->peerMessagesUpdated(channel->id); } } bool MainWidget::contentOverlapped(const QRect &globalRect) { - return (history.contentOverlapped(globalRect) || - _mediaType.overlaps(globalRect)); + return (_history->contentOverlapped(globalRect) || + _mediaType->overlaps(globalRect)); } void MainWidget::usernameResolveDone(QPair msgIdAndStartToken, const MTPcontacts_ResolvedPeer &result) { @@ -3746,9 +3391,9 @@ void MainWidget::usernameResolveDone(QPair msgIdAndStartToken, c } if (peer->isUser() && peer->asUser()->botInfo) { peer->asUser()->botInfo->startToken = startToken; - if (peer == history.peer()) { - history.updateControlsVisibility(); - history.resizeEvent(0); + if (peer == _history->peer()) { + _history->updateControlsVisibility(); + _history->resizeEvent(0); } } Ui::showPeerHistory(peer->id, msgId); @@ -3893,12 +3538,12 @@ void MainWidget::applyNotifySetting(const MTPNotifyPeer &peer, const MTPPeerNoti } if (updatePeer) { - if (history.peer() == updatePeer) { - history.updateNotifySettings(); + if (_history->peer() == updatePeer) { + _history->updateNotifySettings(); } - dialogs.updateNotifySettings(updatePeer); - if (profile && profile->peer() == updatePeer) { - profile->updateNotifySettings(); + _dialogs->updateNotifySettings(updatePeer); + if (_profile && _profile->peer() == updatePeer) { + _profile->updateNotifySettings(); } } } @@ -3959,7 +3604,7 @@ void MainWidget::updateNotifySetting(PeerData *peer, NotifySettingStatus notify, } App::history(peer->id)->setMute(notify == NotifySettingSetMuted); } - if (history.peer() == peer) history.updateNotifySettings(); + if (_history->peer() == peer) _history->updateNotifySettings(); updateNotifySettingTimer.start(NotifySettingSaveTimeout); } @@ -4032,25 +3677,25 @@ void MainWidget::incrementSticker(DocumentData *sticker) { ++it->count; Local::writeStickers(); } - history.updateRecentStickers(); + _history->updateRecentStickers(); } void MainWidget::activate() { if (_a_show.animating()) return; - if (!profile && !overview) { + if (!_profile && !_overview) { if (_hider) { if (_hider->wasOffered()) { _hider->setFocus(); } else { - dialogs.activate(); + _dialogs->activate(); } } else if (App::wnd() && !Ui::isLayerShown()) { if (!cSendPaths().isEmpty()) { forwardLayer(-1); - } else if (history.peer()) { - history.activate(); + } else if (_history->peer()) { + _history->activate(); } else { - dialogs.activate(); + _dialogs->activate(); } } } @@ -4058,8 +3703,8 @@ void MainWidget::activate() { } void MainWidget::destroyData() { - history.destroyData(); - dialogs.destroyData(); + _history->destroyData(); + _dialogs->destroyData(); } void MainWidget::updateOnlineDisplayIn(int32 msecs) { @@ -4071,7 +3716,7 @@ bool MainWidget::isActive() const { } bool MainWidget::historyIsActive() const { - return isActive() && !profile && !overview && history.isActive(); + return isActive() && !_profile && !_overview && _history->isActive(); } bool MainWidget::lastWasOnline() const { @@ -4083,17 +3728,15 @@ uint64 MainWidget::lastSetOnline() const { } int32 MainWidget::dlgsWidth() const { - return dialogs.width(); + return _dialogs->width(); } MainWidget::~MainWidget() { - if (App::main() == this) history.showHistory(0, 0); - - delete _background; + if (App::main() == this) _history->showHistory(0, 0); delete _hider; MTP::clearGlobalHandlers(); - delete _api; + if (App::wnd()) App::wnd()->noMain(this); } @@ -4244,7 +3887,7 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) { MTPDmessage::Flags flags = mtpCastFlags(d.vflags.v) | MTPDmessage::Flag::f_from_id; HistoryItem *item = App::histories().addNewMessage(MTP_message(MTP_flags(flags), d.vid, d.is_out() ? MTP_int(MTP::authedId()) : d.vuser_id, MTP_peerUser(d.is_out() ? d.vuser_id : MTP_int(MTP::authedId())), d.vfwd_from, d.vvia_bot_id, d.vreply_to_msg_id, d.vdate, d.vmessage, MTP_messageMediaEmpty(), MTPnullMarkup, d.has_entities() ? d.ventities : MTPnullEntities, MTPint(), MTPint()), NewMessageUnread); if (item) { - history.peerMessagesUpdated(item->history()->peer->id); + _history->peerMessagesUpdated(item->history()->peer->id); } ptsApplySkippedUpdates(); @@ -4279,7 +3922,7 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) { MTPDmessage::Flags flags = mtpCastFlags(d.vflags.v) | MTPDmessage::Flag::f_from_id; HistoryItem *item = App::histories().addNewMessage(MTP_message(MTP_flags(flags), d.vid, d.vfrom_id, MTP_peerChat(d.vchat_id), d.vfwd_from, d.vvia_bot_id, d.vreply_to_msg_id, d.vdate, d.vmessage, MTP_messageMediaEmpty(), MTPnullMarkup, d.has_entities() ? d.ventities : MTPnullEntities, MTPint(), MTPint()), NewMessageUnread); if (item) { - history.peerMessagesUpdated(item->history()->peer->id); + _history->peerMessagesUpdated(item->history()->peer->id); } ptsApplySkippedUpdates(); @@ -4400,7 +4043,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { // update before applying skipped bool needToAdd = true; - if (d.vmessage.type() == mtpc_message) { // index forwarded messages to links overview + if (d.vmessage.type() == mtpc_message) { // index forwarded messages to links _overview if (App::checkEntitiesAndViewsUpdate(d.vmessage.c_message())) { // already in blocks LOG(("Skipping message, because it is already in blocks!")); needToAdd = false; @@ -4409,7 +4052,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { if (needToAdd) { HistoryItem *item = App::histories().addNewMessage(d.vmessage, NewMessageUnread); if (item) { - history.peerMessagesUpdated(item->history()->peer->id); + _history->peerMessagesUpdated(item->history()->peer->id); } } ptsApplySkippedUpdates(); @@ -4428,7 +4071,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { if (wasLast && !h->lastMsg) { checkPeerHistory(h->peer); } - history.peerMessagesUpdated(); + _history->peerMessagesUpdated(); } else { App::historyUnregItem(msgRow); if (App::wnd()) App::wnd()->changingMsgId(msgRow, d.vid.v); @@ -4492,8 +4135,8 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { // update before applying skipped PeerId id = peerFromMTP(d.vpeer); App::feedOutboxRead(id, d.vmax_id.v); - if (history.peer() && history.peer()->id == id) { - history.update(); + if (_history->peer() && _history->peer()->id == id) { + _history->update(); } if (History *h = App::historyLoaded(id)) { if (h->lastMsg && h->lastMsg->out() && h->lastMsg->id <= d.vmax_id.v) { @@ -4514,7 +4157,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { // update before applying skipped App::feedWebPage(d.vwebpage); - history.updatePreview(); + _history->updatePreview(); webPagesUpdate(); ptsApplySkippedUpdates(); @@ -4529,7 +4172,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { // update before applying skipped App::feedWereDeleted(NoChannel, d.vmessages.c_vector().v); - history.peerMessagesUpdated(); + _history->peerMessagesUpdated(); ptsApplySkippedUpdates(); } break; @@ -4773,7 +4416,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { // update before applying skipped bool needToAdd = true; - if (d.vmessage.type() == mtpc_message) { // index forwarded messages to links overview + if (d.vmessage.type() == mtpc_message) { // index forwarded messages to links _overview if (App::checkEntitiesAndViewsUpdate(d.vmessage.c_message())) { // already in blocks LOG(("Skipping message, because it is already in blocks!")); needToAdd = false; @@ -4782,7 +4425,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { if (needToAdd) { HistoryItem *item = App::histories().addNewMessage(d.vmessage, NewMessageUnread); if (item) { - history.peerMessagesUpdated(item->history()->peer->id); + _history->peerMessagesUpdated(item->history()->peer->id); } } if (channel && !_handlingChannelDifference) { @@ -4858,7 +4501,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { // update before applying skipped App::feedWereDeleted(d.vchannel_id.v, d.vmessages.c_vector().v); - history.peerMessagesUpdated(); + _history->peerMessagesUpdated(); if (channel && !_handlingChannelDifference) { channel->ptsApplySkippedUpdates(); diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index 945225f6ba..18c214d5a6 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -20,15 +20,22 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #pragma once -#include "apiwrap.h" -#include "dialogswidget.h" -#include "historywidget.h" -#include "profilewidget.h" -#include "overviewwidget.h" -#include "playerwidget.h" -#include "ui/buttons/peer_avatar_button.h" +#include "localimageloader.h" +#include "history/history_common.h" -class Window; +namespace Dialogs { +class Row; +} // namespace Dialogs + +namespace Ui { +class PeerAvatarButton; +} // namespace Ui + +namespace Window { +class TopBarWidget; +} // namespace Window + +class MainWindow; class ApiWrap; class MainWidget; class ConfirmBox; @@ -37,90 +44,8 @@ class HistoryWidget; class ProfileWidget; class OverviewWidget; class PlayerWidget; - -namespace Dialogs { -class Row; -} // namespace Dialogs - -class TopBarWidget : public TWidget { - Q_OBJECT - -public: - - TopBarWidget(MainWidget *w); - - void enterEvent(QEvent *e) override; - void enterFromChildEvent(QEvent *e) override; - void leaveEvent(QEvent *e) override; - void leaveToChildEvent(QEvent *e) override; - void paintEvent(QPaintEvent *e) override; - void mousePressEvent(QMouseEvent *e) override; - void resizeEvent(QResizeEvent *e) override; - - void step_appearance(float64 ms, bool timer); - void enableShadow(bool enable = true); - - void startAnim(); - void stopAnim(); - void showAll(); - void showSelected(uint32 selCount, bool canDelete = false); - - void updateAdaptiveLayout(); - - FlatButton *mediaTypeButton(); - - void grabStart() override { - _sideShadow.hide(); - } - void grabFinish() override { - _sideShadow.setVisible(!Adaptive::OneColumn()); - } - -public slots: - - void onForwardSelection(); - void onDeleteSelection(); - void onClearSelection(); - void onInfoClicked(); - void onAddContact(); - void onEdit(); - void onDeleteContact(); - void onDeleteContactSure(); - void onDeleteAndExit(); - void onDeleteAndExitSure(); - void onSearch(); - -signals: - - void clicked(); - -private: - - MainWidget *main(); - anim::fvalue a_over; - Animation _a_appearance; - - PeerData *_selPeer; - uint32 _selCount; - bool _canDelete; - QString _selStr; - int32 _selStrLeft, _selStrWidth; - - bool _animating; - - FlatButton _clearSelection; - FlatButton _forward, _delete; - int32 _selectionButtonsWidth, _forwardDeleteWidth; - - PeerAvatarButton _info; - FlatButton _edit, _leaveGroup, _addContact, _deleteContact; - FlatButton _mediaType; - - IconedButton _search; - - PlainShadow _sideShadow; - -}; +class HistoryHider; +class Dropdown; enum StackItemType { HistoryStackItem, @@ -220,7 +145,7 @@ class MainWidget : public TWidget, public RPCSender { public: - MainWidget(Window *window); + MainWidget(MainWindow *window); void paintEvent(QPaintEvent *e) override; void resizeEvent(QResizeEvent *e) override; @@ -230,7 +155,7 @@ public: bool needBackButton(); void paintTopBar(QPainter &p, float64 over, int32 decreaseWidth); - TopBarWidget *topBar(); + Window::TopBarWidget *topBar(); PlayerWidget *player(); int contentScrollAddToY() const; @@ -623,14 +548,14 @@ private: int _dialogsWidth = st::dlgMinWidth; - DialogsWidget dialogs; - HistoryWidget history; - ProfileWidget* profile = nullptr; - OverviewWidget* overview = nullptr; - PlayerWidget _player; - TopBarWidget _topBar; + ChildWidget _dialogs; + ChildWidget _history; + ChildWidget _profile = nullptr; + ChildWidget _overview = nullptr; + ChildWidget _player; + ChildWidget _topBar; ConfirmBox *_forwardConfirm = nullptr; // for single column layout - HistoryHider *_hider = nullptr; + ChildWidget _hider = nullptr; StackItems _stack; PeerData *_peerInStack = nullptr; MsgId _msgIdInStack = 0; @@ -638,7 +563,7 @@ private: int _playerHeight = 0; int _contentScrollAddToY = 0; - Dropdown _mediaType; + ChildWidget _mediaType; int32 _mediaTypeMask = 0; int32 updDate = 0; @@ -711,8 +636,8 @@ private: void viewsIncrementDone(QVector ids, const MTPVector &result, mtpRequestId req); bool viewsIncrementFail(const RPCError &error, mtpRequestId req); - App::WallPaper *_background = nullptr; + std_::unique_ptr _background; - ApiWrap *_api; + std_::unique_ptr _api; }; diff --git a/Telegram/SourceFiles/window.cpp b/Telegram/SourceFiles/mainwindow.cpp similarity index 94% rename from Telegram/SourceFiles/window.cpp rename to Telegram/SourceFiles/mainwindow.cpp index 1c6b252ad8..fe4e23e7a2 100644 --- a/Telegram/SourceFiles/window.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #include "stdafx.h" -#include "window.h" +#include "mainwindow.h" #include "zip.h" @@ -364,7 +364,7 @@ NotifyWindow::~NotifyWindow() { if (App::wnd()) App::wnd()->notifyShowNext(this); } -Window::Window(QWidget *parent) : PsMainWindow(parent) { +MainWindow::MainWindow(QWidget *parent) : PsMainWindow(parent) { icon16 = icon256.scaledToWidth(16, Qt::SmoothTransformation); icon32 = icon256.scaledToWidth(32, Qt::SmoothTransformation); icon64 = icon256.scaledToWidth(64, Qt::SmoothTransformation); @@ -400,7 +400,7 @@ Window::Window(QWidget *parent) : PsMainWindow(parent) { setAttribute(Qt::WA_OpaquePaintEvent); } -void Window::inactivePress(bool inactive) { +void MainWindow::inactivePress(bool inactive) { _inactivePress = inactive; if (_inactivePress) { _inactiveTimer.start(200); @@ -409,15 +409,15 @@ void Window::inactivePress(bool inactive) { } } -bool Window::inactivePress() const { +bool MainWindow::inactivePress() const { return _inactivePress; } -void Window::onInactiveTimer() { +void MainWindow::onInactiveTimer() { inactivePress(false); } -void Window::stateChanged(Qt::WindowState state) { +void MainWindow::stateChanged(Qt::WindowState state) { psUserActionDone(); updateIsActive((state == Qt::WindowMinimized) ? Global::OfflineBlurTimeout() : Global::OnlineFocusTimeout()); @@ -429,7 +429,7 @@ void Window::stateChanged(Qt::WindowState state) { psSavePosition(state); } -void Window::init() { +void MainWindow::init() { psInitFrameless(); setWindowIcon(wndIcon); @@ -446,7 +446,7 @@ void Window::init() { psInitSize(); } -void Window::firstShow() { +void MainWindow::firstShow() { #ifdef Q_OS_WIN trayIconMenu = new PopupMenu(); trayIconMenu->deleteOnHide(false); @@ -472,11 +472,11 @@ void Window::firstShow() { updateTrayMenu(); } -QWidget *Window::filedialogParent() { +QWidget *MainWindow::filedialogParent() { return (_mediaView && _mediaView->isVisible()) ? (QWidget*)_mediaView : (QWidget*)this; } -void Window::clearWidgets() { +void MainWindow::clearWidgets() { Ui::hideLayer(true); if (_passcode) { _passcode->hide(); @@ -511,7 +511,7 @@ void Window::clearWidgets() { updateGlobalMenu(); } -QPixmap Window::grabInner() { +QPixmap MainWindow::grabInner() { QPixmap result; if (settings) { result = myGrab(settings); @@ -525,7 +525,7 @@ QPixmap Window::grabInner() { return result; } -void Window::clearPasscode() { +void MainWindow::clearPasscode() { if (!_passcode) return; QPixmap bg = grabInner(); @@ -546,7 +546,7 @@ void Window::clearPasscode() { updateGlobalMenu(); } -void Window::setupPasscode(bool anim) { +void MainWindow::setupPasscode(bool anim) { QPixmap bg = grabInner(); if (_passcode) { @@ -570,7 +570,7 @@ void Window::setupPasscode(bool anim) { updateGlobalMenu(); } -void Window::checkAutoLockIn(int msec) { +void MainWindow::checkAutoLockIn(int msec) { if (_autoLockTimer.isActive()) { int remain = _autoLockTimer.remainingTime(); if (remain > 0 && remain <= msec) return; @@ -578,7 +578,7 @@ void Window::checkAutoLockIn(int msec) { _autoLockTimer.start(msec); } -void Window::checkAutoLock() { +void MainWindow::checkAutoLock() { if (!cHasPasscode() || App::passcoded()) return; App::app()->checkLocalTime(); @@ -591,7 +591,7 @@ void Window::checkAutoLock() { } } -void Window::setupIntro(bool anim) { +void MainWindow::setupIntro(bool anim) { cSetContactsReceived(false); cSetDialogsReceived(false); if (intro && !intro->isHidden() && !main) return; @@ -616,11 +616,11 @@ void Window::setupIntro(bool anim) { } } -void Window::getNotifySetting(const MTPInputNotifyPeer &peer, uint32 msWait) { +void MainWindow::getNotifySetting(const MTPInputNotifyPeer &peer, uint32 msWait) { MTP::send(MTPaccount_GetNotifySettings(peer), main->rpcDone(&MainWidget::gotNotifySetting, peer), main->rpcFail(&MainWidget::failNotifySetting, peer), 0, msWait); } -void Window::serviceNotification(const QString &msg, const MTPMessageMedia &media, bool force) { +void MainWindow::serviceNotification(const QString &msg, const MTPMessageMedia &media, bool force) { History *h = (main && App::userLoaded(ServiceUserId)) ? App::history(ServiceUserId) : 0; if (!h || (!force && h->isEmpty())) { _delayedServiceMsgs.push_back(DelayedServiceMsg(msg, media)); @@ -630,7 +630,7 @@ void Window::serviceNotification(const QString &msg, const MTPMessageMedia &medi main->serviceNotification(msg, media); } -void Window::showDelayedServiceMsgs() { +void MainWindow::showDelayedServiceMsgs() { QVector toAdd = _delayedServiceMsgs; _delayedServiceMsgs.clear(); for (QVector::const_iterator i = toAdd.cbegin(), e = toAdd.cend(); i != e; ++i) { @@ -638,7 +638,7 @@ void Window::showDelayedServiceMsgs() { } } -void Window::sendServiceHistoryRequest() { +void MainWindow::sendServiceHistoryRequest() { if (!main || !main->started() || _delayedServiceMsgs.isEmpty() || _serviceHistoryRequest) return; UserData *user = App::userLoaded(ServiceUserId); @@ -649,7 +649,7 @@ void Window::sendServiceHistoryRequest() { _serviceHistoryRequest = MTP::send(MTPmessages_GetHistory(user->input, MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(1), MTP_int(0), MTP_int(0)), main->rpcDone(&MainWidget::serviceHistoryDone), main->rpcFail(&MainWidget::serviceHistoryFail)); } -void Window::setupMain(bool anim, const MTPUser *self) { +void MainWindow::setupMain(bool anim, const MTPUser *self) { QPixmap bg = anim ? grabInner() : QPixmap(); clearWidgets(); main = new MainWidget(this); @@ -673,14 +673,14 @@ void Window::setupMain(bool anim, const MTPUser *self) { _mediaView = new MediaView(); } -void Window::updateCounter() { +void MainWindow::updateCounter() { if (!Global::started() || App::quitting()) return; psUpdateCounter(); title->updateCounter(); } -void Window::showSettings() { +void MainWindow::showSettings() { if (_passcode) return; if (isHidden()) showFromTray(); @@ -705,7 +705,7 @@ void Window::showSettings() { fixOrder(); } -void Window::hideSettings(bool fast) { +void MainWindow::hideSettings(bool fast) { if (!settings || _passcode) return; if (fast) { @@ -738,14 +738,14 @@ void Window::hideSettings(bool fast) { fixOrder(); } -void Window::mtpStateChanged(int32 dc, int32 state) { +void MainWindow::mtpStateChanged(int32 dc, int32 state) { if (dc == MTP::maindc()) { updateTitleStatus(); if (settings) settings->updateConnectionType(); } } -void Window::updateTitleStatus() { +void MainWindow::updateTitleStatus() { int32 state = MTP::dcstate(); if (state == MTP::ConnectingState || state == MTP::DisconnectedState || (state < 0 && state > -600)) { if (main || getms() > 5000 || _connecting) { @@ -759,48 +759,48 @@ void Window::updateTitleStatus() { } } -IntroWidget *Window::introWidget() { +IntroWidget *MainWindow::introWidget() { return intro; } -MainWidget *Window::mainWidget() { +MainWidget *MainWindow::mainWidget() { return main; } -SettingsWidget *Window::settingsWidget() { +SettingsWidget *MainWindow::settingsWidget() { return settings; } -PasscodeWidget *Window::passcodeWidget() { +PasscodeWidget *MainWindow::passcodeWidget() { return _passcode; } -void Window::showPhoto(const PhotoOpenClickHandler *lnk, HistoryItem *item) { +void MainWindow::showPhoto(const PhotoOpenClickHandler *lnk, HistoryItem *item) { return lnk->peer() ? showPhoto(lnk->photo(), lnk->peer()) : showPhoto(lnk->photo(), item); } -void Window::showPhoto(PhotoData *photo, HistoryItem *item) { +void MainWindow::showPhoto(PhotoData *photo, HistoryItem *item) { if (_mediaView->isHidden()) Ui::hideLayer(true); _mediaView->showPhoto(photo, item); _mediaView->activateWindow(); _mediaView->setFocus(); } -void Window::showPhoto(PhotoData *photo, PeerData *peer) { +void MainWindow::showPhoto(PhotoData *photo, PeerData *peer) { if (_mediaView->isHidden()) Ui::hideLayer(true); _mediaView->showPhoto(photo, peer); _mediaView->activateWindow(); _mediaView->setFocus(); } -void Window::showDocument(DocumentData *doc, HistoryItem *item) { +void MainWindow::showDocument(DocumentData *doc, HistoryItem *item) { if (_mediaView->isHidden()) Ui::hideLayer(true); _mediaView->showDocument(doc, item); _mediaView->activateWindow(); _mediaView->setFocus(); } -void Window::ui_showLayer(LayeredWidget *box, ShowLayerOptions options) { +void MainWindow::ui_showLayer(LayeredWidget *box, ShowLayerOptions options) { if (box) { bool fast = (options.testFlag(ForceFastShowLayer)) || Ui::isLayerShown(); if (layerBg) { @@ -837,15 +837,15 @@ void Window::ui_showLayer(LayeredWidget *box, ShowLayerOptions options) { } } -bool Window::ui_isLayerShown() { +bool MainWindow::ui_isLayerShown() { return !!layerBg; } -bool Window::ui_isMediaViewShown() { +bool MainWindow::ui_isMediaViewShown() { return _mediaView && !_mediaView->isHidden(); } -void Window::ui_showMediaPreview(DocumentData *document) { +void MainWindow::ui_showMediaPreview(DocumentData *document) { if (!document || ((!document->isAnimation() || !document->loaded()) && !document->sticker())) return; if (!_mediaPreview) { _mediaPreview = std_::make_unique(this); @@ -857,7 +857,7 @@ void Window::ui_showMediaPreview(DocumentData *document) { _mediaPreview->showPreview(document); } -void Window::ui_showMediaPreview(PhotoData *photo) { +void MainWindow::ui_showMediaPreview(PhotoData *photo) { if (!photo) return; if (!_mediaPreview) { _mediaPreview = std_::make_unique(this); @@ -869,12 +869,12 @@ void Window::ui_showMediaPreview(PhotoData *photo) { _mediaPreview->showPreview(photo); } -void Window::ui_hideMediaPreview() { +void MainWindow::ui_hideMediaPreview() { if (!_mediaPreview) return; _mediaPreview->hidePreview(); } -PeerData *Window::ui_getPeerForMouseAction() { +PeerData *MainWindow::ui_getPeerForMouseAction() { if (_mediaView && !_mediaView->isHidden()) { return _mediaView->ui_getPeerForMouseAction(); } else if (main) { @@ -883,7 +883,7 @@ PeerData *Window::ui_getPeerForMouseAction() { return nullptr; } -void Window::showConnecting(const QString &text, const QString &reconnect) { +void MainWindow::showConnecting(const QString &text, const QString &reconnect) { if (_connecting) { _connecting->set(text, reconnect); } else { @@ -895,11 +895,11 @@ void Window::showConnecting(const QString &text, const QString &reconnect) { if (settings) settings->update(); } -bool Window::connectingVisible() const { +bool MainWindow::connectingVisible() const { return _connecting && !_connecting->isHidden(); } -void Window::hideConnecting() { +void MainWindow::hideConnecting() { if (_connecting) { _connecting->deleteLater(); _connecting = 0; @@ -907,18 +907,18 @@ void Window::hideConnecting() { if (settings) settings->update(); } -bool Window::historyIsActive() const { +bool MainWindow::historyIsActive() const { return isActive(false) && main && main->historyIsActive() && (!settings || !settings->isVisible()); } -void Window::checkHistoryActivation() { +void MainWindow::checkHistoryActivation() { if (main && MTP::authedId() && historyIsActive()) { main->historyWasRead(); } QTimer::singleShot(1, this, SLOT(updateTrayMenu())); } -void Window::layerHidden() { +void MainWindow::layerHidden() { if (layerBg) { layerBg->hide(); layerBg->deleteLater(); @@ -928,7 +928,7 @@ void Window::layerHidden() { setInnerFocus(); } -void Window::hideMediaview() { +void MainWindow::hideMediaview() { if (_mediaView && !_mediaView->isHidden()) { _mediaView->hide(); #if defined Q_OS_LINUX32 || defined Q_OS_LINUX64 @@ -939,13 +939,13 @@ void Window::hideMediaview() { } } -bool Window::contentOverlapped(const QRect &globalRect) { +bool MainWindow::contentOverlapped(const QRect &globalRect) { if (main && main->contentOverlapped(globalRect)) return true; if (layerBg && layerBg->contentOverlapped(globalRect)) return true; return false; } -void Window::setInnerFocus() { +void MainWindow::setInnerFocus() { if (layerBg && layerBg->canSetFocus()) { layerBg->setInnerFocus(); } else if (_passcode) { @@ -957,11 +957,11 @@ void Window::setInnerFocus() { } } -QRect Window::clientRect() const { +QRect MainWindow::clientRect() const { return QRect(0, st::titleHeight, width(), height() - st::titleHeight); } -QRect Window::photoRect() const { +QRect MainWindow::photoRect() const { if (settings) { return settings->geometry(); } else if (main) { @@ -973,15 +973,15 @@ QRect Window::photoRect() const { return QRect(0, 0, 0, 0); } -void Window::wStartDrag(QMouseEvent *e) { +void MainWindow::wStartDrag(QMouseEvent *e) { dragStart = e->globalPos() - frameGeometry().topLeft(); dragging = true; } -void Window::paintEvent(QPaintEvent *e) { +void MainWindow::paintEvent(QPaintEvent *e) { } -HitTestType Window::hitTest(const QPoint &p) const { +HitTestType MainWindow::hitTest(const QPoint &p) const { int x(p.x()), y(p.y()), w(width()), h(height()); const int32 raw = psResizeRowWidth(); @@ -1015,11 +1015,11 @@ HitTestType Window::hitTest(const QPoint &p) const { return HitTestNone; } -QRect Window::iconRect() const { +QRect MainWindow::iconRect() const { return QRect(st::titleIconPos + title->geometry().topLeft(), st::titleIconImg.pxSize()); } -bool Window::eventFilter(QObject *obj, QEvent *e) { +bool MainWindow::eventFilter(QObject *obj, QEvent *e) { switch (e->type()) { case QEvent::MouseButtonPress: case QEvent::KeyPress: @@ -1088,7 +1088,7 @@ bool Window::eventFilter(QObject *obj, QEvent *e) { return PsMainWindow::eventFilter(obj, e); } -void Window::mouseMoveEvent(QMouseEvent *e) { +void MainWindow::mouseMoveEvent(QMouseEvent *e) { if (e->buttons() & Qt::LeftButton) { if (dragging) { if (windowState().testFlag(Qt::WindowMaximized)) { @@ -1104,11 +1104,11 @@ void Window::mouseMoveEvent(QMouseEvent *e) { } } -void Window::mouseReleaseEvent(QMouseEvent *e) { +void MainWindow::mouseReleaseEvent(QMouseEvent *e) { dragging = false; } -bool Window::minimizeToTray() { +bool MainWindow::minimizeToTray() { if (App::quitting() || !psHasTrayIcon()) return false; hide(); @@ -1123,7 +1123,7 @@ bool Window::minimizeToTray() { return true; } -void Window::updateTrayMenu(bool force) { +void MainWindow::updateTrayMenu(bool force) { if (!trayIconMenu || (cPlatform() == dbipWindows && !force)) return; bool active = isActive(false); @@ -1153,25 +1153,25 @@ void Window::updateTrayMenu(bool force) { psTrayMenuUpdated(); } -void Window::onShowAddContact() { +void MainWindow::onShowAddContact() { if (isHidden()) showFromTray(); if (main) main->showAddContact(); } -void Window::onShowNewGroup() { +void MainWindow::onShowNewGroup() { if (isHidden()) showFromTray(); if (main) Ui::showLayer(new GroupInfoBox(CreatingGroupGroup, false), KeepOtherLayers); } -void Window::onShowNewChannel() { +void MainWindow::onShowNewChannel() { if (isHidden()) showFromTray(); if (main) Ui::showLayer(new GroupInfoBox(CreatingGroupChannel, false), KeepOtherLayers); } -void Window::onLogout() { +void MainWindow::onLogout() { if (isHidden()) showFromTray(); ConfirmBox *box = new ConfirmBox(lang(lng_sure_logout), lang(lng_settings_logout), st::attentionBoxButton); @@ -1179,7 +1179,7 @@ void Window::onLogout() { Ui::showLayer(box); } -void Window::onLogoutSure() { +void MainWindow::onLogoutSure() { if (MTP::authedId()) { App::logOut(); } else { @@ -1187,17 +1187,17 @@ void Window::onLogoutSure() { } } -void Window::updateGlobalMenu() { +void MainWindow::updateGlobalMenu() { #ifdef Q_OS_MAC psMacUpdateMenu(); #endif } -void Window::quitFromTray() { +void MainWindow::quitFromTray() { App::quit(); } -void Window::activate() { +void MainWindow::activate() { bool wasHidden = !isVisible(); setWindowState(windowState() & ~Qt::WindowMinimized); setVisible(true); @@ -1211,45 +1211,45 @@ void Window::activate() { } } -void Window::noIntro(IntroWidget *was) { +void MainWindow::noIntro(IntroWidget *was) { if (was == intro) { intro = 0; } } -void Window::noSettings(SettingsWidget *was) { +void MainWindow::noSettings(SettingsWidget *was) { if (was == settings) { settings = 0; } checkHistoryActivation(); } -void Window::noMain(MainWidget *was) { +void MainWindow::noMain(MainWidget *was) { if (was == main) { main = 0; } } -void Window::noBox(BackgroundWidget *was) { +void MainWindow::noBox(BackgroundWidget *was) { if (was == layerBg) { layerBg = 0; } } -void Window::layerFinishedHide(BackgroundWidget *was) { +void MainWindow::layerFinishedHide(BackgroundWidget *was) { if (was == layerBg) { QTimer::singleShot(0, this, SLOT(layerHidden())); } } -void Window::fixOrder() { +void MainWindow::fixOrder() { title->raise(); if (layerBg) layerBg->raise(); if (_mediaPreview) _mediaPreview->raise(); if (_connecting) _connecting->raise(); } -void Window::showFromTray(QSystemTrayIcon::ActivationReason reason) { +void MainWindow::showFromTray(QSystemTrayIcon::ActivationReason reason) { if (reason != QSystemTrayIcon::Context) { QTimer::singleShot(1, this, SLOT(updateTrayMenu())); QTimer::singleShot(1, this, SLOT(updateGlobalMenu())); @@ -1258,7 +1258,7 @@ void Window::showFromTray(QSystemTrayIcon::ActivationReason reason) { } } -void Window::toggleTray(QSystemTrayIcon::ActivationReason reason) { +void MainWindow::toggleTray(QSystemTrayIcon::ActivationReason reason) { if ((cPlatform() == dbipMac || cPlatform() == dbipMacOld) && isActive(false)) return; if (reason == QSystemTrayIcon::Context) { updateTrayMenu(true); @@ -1272,7 +1272,7 @@ void Window::toggleTray(QSystemTrayIcon::ActivationReason reason) { } } -void Window::toggleDisplayNotifyFromTray() { +void MainWindow::toggleDisplayNotifyFromTray() { if (App::passcoded()) { if (!isActive()) showFromTray(); Ui::showLayer(new InformBox(lang(lng_passcode_need_unblock))); @@ -1290,7 +1290,7 @@ void Window::toggleDisplayNotifyFromTray() { } } -void Window::closeEvent(QCloseEvent *e) { +void MainWindow::closeEvent(QCloseEvent *e) { if (MTP::authedId() && !Sandbox::isSavingSession() && Ui::hideWindowNoQuit()) { e->ignore(); } else { @@ -1298,11 +1298,11 @@ void Window::closeEvent(QCloseEvent *e) { } } -TitleWidget *Window::getTitle() { +TitleWidget *MainWindow::getTitle() { return title; } -void Window::resizeEvent(QResizeEvent *e) { +void MainWindow::resizeEvent(QResizeEvent *e) { if (!title) return; Adaptive::Layout layout = Adaptive::OneColumnLayout; @@ -1322,7 +1322,7 @@ void Window::resizeEvent(QResizeEvent *e) { emit resized(QSize(width(), height() - st::titleHeight)); } -void Window::updateAdaptiveLayout() { +void MainWindow::updateAdaptiveLayout() { title->updateAdaptiveLayout(); if (main) main->updateAdaptiveLayout(); if (settings) settings->updateAdaptiveLayout(); @@ -1330,25 +1330,25 @@ void Window::updateAdaptiveLayout() { if (layerBg) layerBg->updateAdaptiveLayout(); } -bool Window::needBackButton() { +bool MainWindow::needBackButton() { return !!settings; } -Window::TempDirState Window::tempDirState() { +MainWindow::TempDirState MainWindow::tempDirState() { if (_clearManager && _clearManager->hasTask(Local::ClearManagerDownloads)) { return TempDirRemoving; } return QDir(cTempDir()).exists() ? TempDirExists : TempDirEmpty; } -Window::TempDirState Window::localStorageState() { +MainWindow::TempDirState MainWindow::localStorageState() { if (_clearManager && _clearManager->hasTask(Local::ClearManagerStorage)) { return TempDirRemoving; } return (Local::hasImages() || Local::hasStickers() || Local::hasWebFiles() || Local::hasAudios()) ? TempDirExists : TempDirEmpty; } -void Window::tempDirDelete(int task) { +void MainWindow::tempDirDelete(int task) { if (_clearManager) { if (_clearManager->addTask(task)) { return; @@ -1364,7 +1364,7 @@ void Window::tempDirDelete(int task) { _clearManager->start(); } -void Window::onClearFinished(int task, void *manager) { +void MainWindow::onClearFinished(int task, void *manager) { if (manager && manager == _clearManager) { _clearManager->deleteLater(); _clearManager = 0; @@ -1372,7 +1372,7 @@ void Window::onClearFinished(int task, void *manager) { emit tempDirCleared(task); } -void Window::onClearFailed(int task, void *manager) { +void MainWindow::onClearFailed(int task, void *manager) { if (manager && manager == _clearManager) { _clearManager->deleteLater(); _clearManager = 0; @@ -1380,7 +1380,7 @@ void Window::onClearFailed(int task, void *manager) { emit tempDirClearFailed(task); } -void Window::notifySchedule(History *history, HistoryItem *item) { +void MainWindow::notifySchedule(History *history, HistoryItem *item) { if (App::quitting() || !history->currentNotification() || !main) return; PeerData *notifyByFrom = (!history->peer->isUser() && item->mentionsMe()) ? item->from() : 0; @@ -1451,11 +1451,11 @@ void Window::notifySchedule(History *history, HistoryItem *item) { } } -void Window::notifyFire() { +void MainWindow::notifyFire() { notifyShowNext(); } -void Window::notifyClear(History *history) { +void MainWindow::notifyClear(History *history) { if (!history) { for (NotifyWindows::const_iterator i = notifyWindows.cbegin(), e = notifyWindows.cend(); i != e; ++i) { (*i)->unlinkHistory(); @@ -1480,7 +1480,7 @@ void Window::notifyClear(History *history) { notifyShowNext(); } -void Window::notifyClearFast() { +void MainWindow::notifyClearFast() { notifyWaiters.clear(); notifySettingWaiters.clear(); for (NotifyWindows::const_iterator i = notifyWindows.cbegin(), e = notifyWindows.cend(); i != e; ++i) { @@ -1492,7 +1492,7 @@ void Window::notifyClearFast() { notifyWhenAlerts.clear(); } -void Window::notifySettingGot() { +void MainWindow::notifySettingGot() { int32 t = unixtime(); for (NotifyWaiters::iterator i = notifySettingWaiters.begin(); i != notifySettingWaiters.end();) { History *history = i.key(); @@ -1534,7 +1534,7 @@ void Window::notifySettingGot() { notifyShowNext(); } -void Window::notifyShowNext(NotifyWindow *remove) { +void MainWindow::notifyShowNext(NotifyWindow *remove) { if (App::quitting()) return; int32 count = NotifyWindowsCount; @@ -1711,7 +1711,7 @@ void Window::notifyShowNext(NotifyWindow *remove) { } } -void Window::notifyItemRemoved(HistoryItem *item) { +void MainWindow::notifyItemRemoved(HistoryItem *item) { if (cCustomNotifies()) { for (NotifyWindows::const_iterator i = notifyWindows.cbegin(), e = notifyWindows.cend(); i != e; ++i) { (*i)->itemRemoved(item); @@ -1719,7 +1719,7 @@ void Window::notifyItemRemoved(HistoryItem *item) { } } -void Window::notifyStopHiding() { +void MainWindow::notifyStopHiding() { if (cCustomNotifies()) { for (NotifyWindows::const_iterator i = notifyWindows.cbegin(), e = notifyWindows.cend(); i != e; ++i) { (*i)->stopHiding(); @@ -1727,7 +1727,7 @@ void Window::notifyStopHiding() { } } -void Window::notifyStartHiding() { +void MainWindow::notifyStartHiding() { if (cCustomNotifies()) { for (NotifyWindows::const_iterator i = notifyWindows.cbegin(), e = notifyWindows.cend(); i != e; ++i) { (*i)->startHiding(); @@ -1735,7 +1735,7 @@ void Window::notifyStartHiding() { } } -void Window::notifyUpdateAllPhotos() { +void MainWindow::notifyUpdateAllPhotos() { if (cCustomNotifies()) { for (NotifyWindows::const_iterator i = notifyWindows.cbegin(), e = notifyWindows.cend(); i != e; ++i) { (*i)->updatePeerPhoto(); @@ -1744,11 +1744,11 @@ void Window::notifyUpdateAllPhotos() { if (_mediaView && !_mediaView->isHidden()) _mediaView->updateControls(); } -void Window::app_activateClickHandler(ClickHandlerPtr handler, Qt::MouseButton button) { +void MainWindow::app_activateClickHandler(ClickHandlerPtr handler, Qt::MouseButton button) { handler->onClick(button); } -void Window::notifyUpdateAll() { +void MainWindow::notifyUpdateAll() { if (cCustomNotifies()) { for (NotifyWindows::const_iterator i = notifyWindows.cbegin(), e = notifyWindows.cend(); i != e; ++i) { (*i)->updateNotifyDisplay(); @@ -1757,7 +1757,7 @@ void Window::notifyUpdateAll() { psClearNotifies(); } -void Window::notifyActivateAll() { +void MainWindow::notifyActivateAll() { if (cCustomNotifies()) { for (NotifyWindows::const_iterator i = notifyWindows.cbegin(), e = notifyWindows.cend(); i != e; ++i) { psActivateNotify(*i); @@ -1765,11 +1765,11 @@ void Window::notifyActivateAll() { } } -QImage Window::iconLarge() const { +QImage MainWindow::iconLarge() const { return iconbig256; } -void Window::placeSmallCounter(QImage &img, int size, int count, style::color bg, const QPoint &shift, style::color color) { +void MainWindow::placeSmallCounter(QImage &img, int size, int count, style::color bg, const QPoint &shift, style::color color) { QPainter p(&img); QString cnt = (count < 100) ? QString("%1").arg(count) : QString("..%1").arg(count % 10, 1, 10, QChar('0')); @@ -1807,7 +1807,7 @@ void Window::placeSmallCounter(QImage &img, int size, int count, style::color bg } -QImage Window::iconWithCounter(int size, int count, style::color bg, bool smallIcon) { +QImage MainWindow::iconWithCounter(int size, int count, style::color bg, bool smallIcon) { bool layer = false; if (size < 0) { size = -size; @@ -1874,7 +1874,7 @@ QImage Window::iconWithCounter(int size, int count, style::color bg, bool smallI return img; } -void Window::sendPaths() { +void MainWindow::sendPaths() { if (App::passcoded()) return; hideMediaview(); if (settings) { @@ -1887,35 +1887,35 @@ void Window::sendPaths() { } } -void Window::mediaOverviewUpdated(PeerData *peer, MediaOverviewType type) { +void MainWindow::mediaOverviewUpdated(PeerData *peer, MediaOverviewType type) { if (main) main->mediaOverviewUpdated(peer, type); if (!_mediaView || _mediaView->isHidden()) return; _mediaView->mediaOverviewUpdated(peer, type); } -void Window::documentUpdated(DocumentData *doc) { +void MainWindow::documentUpdated(DocumentData *doc) { if (!_mediaView || _mediaView->isHidden()) return; _mediaView->documentUpdated(doc); } -void Window::changingMsgId(HistoryItem *row, MsgId newId) { +void MainWindow::changingMsgId(HistoryItem *row, MsgId newId) { if (main) main->changingMsgId(row, newId); if (!_mediaView || _mediaView->isHidden()) return; _mediaView->changingMsgId(row, newId); } -bool Window::isActive(bool cached) const { +bool MainWindow::isActive(bool cached) const { if (cached) return _isActive; return isActiveWindow() && isVisible() && !(windowState() & Qt::WindowMinimized); } -void Window::updateIsActive(int timeout) { +void MainWindow::updateIsActive(int timeout) { if (timeout) return _isActiveTimer.start(timeout); _isActive = isActive(false); if (main) main->updateOnline(); } -Window::~Window() { +MainWindow::~MainWindow() { notifyClearFast(); delete _clearManager; delete _connecting; diff --git a/Telegram/SourceFiles/window.h b/Telegram/SourceFiles/mainwindow.h similarity index 99% rename from Telegram/SourceFiles/window.h rename to Telegram/SourceFiles/mainwindow.h index 72056e65db..e1189eb355 100644 --- a/Telegram/SourceFiles/window.h +++ b/Telegram/SourceFiles/mainwindow.h @@ -123,12 +123,12 @@ typedef QList NotifyWindows; class MediaPreviewWidget; -class Window : public PsMainWindow { +class MainWindow : public PsMainWindow { Q_OBJECT public: - Window(QWidget *parent = 0); - ~Window(); + MainWindow(QWidget *parent = 0); + ~MainWindow(); void init(); void firstShow(); diff --git a/Telegram/SourceFiles/mediaview.cpp b/Telegram/SourceFiles/mediaview.cpp index 9a1e974d30..16f4b018ae 100644 --- a/Telegram/SourceFiles/mediaview.cpp +++ b/Telegram/SourceFiles/mediaview.cpp @@ -23,7 +23,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "mediaview.h" #include "mainwidget.h" -#include "window.h" +#include "mainwindow.h" #include "application.h" #include "ui/filedialog.h" diff --git a/Telegram/SourceFiles/mtproto/core_types.h b/Telegram/SourceFiles/mtproto/core_types.h index b558576362..924b93ba29 100644 --- a/Telegram/SourceFiles/mtproto/core_types.h +++ b/Telegram/SourceFiles/mtproto/core_types.h @@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #pragma once -#include "basic_types.h" +#include "core/basic_types.h" namespace MTP { diff --git a/Telegram/SourceFiles/mtproto/file_download.cpp b/Telegram/SourceFiles/mtproto/file_download.cpp index 86033cd117..73d61b1318 100644 --- a/Telegram/SourceFiles/mtproto/file_download.cpp +++ b/Telegram/SourceFiles/mtproto/file_download.cpp @@ -23,7 +23,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "mtproto/file_download.h" #include "mainwidget.h" -#include "window.h" +#include "mainwindow.h" #include "application.h" #include "localstorage.h" diff --git a/Telegram/SourceFiles/overview/overview_layout.cpp b/Telegram/SourceFiles/overview/overview_layout.cpp new file mode 100644 index 0000000000..3a789f3c6e --- /dev/null +++ b/Telegram/SourceFiles/overview/overview_layout.cpp @@ -0,0 +1,1143 @@ +/* +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. + +In addition, as a special exception, the copyright holders give permission +to link the code of portions of this program with the OpenSSL library. + +Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE +Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org +*/ +#include "stdafx.h" +#include "overview/overview_layout.h" + +#include "lang.h" +#include "mainwidget.h" +#include "application.h" +#include "fileuploader.h" +#include "mainwindow.h" +#include "ui/filedialog.h" +#include "playerwidget.h" +#include "boxes/addcontactbox.h" +#include "boxes/confirmbox.h" +#include "audio.h" +#include "localstorage.h" + +namespace Overview { +namespace Layout { + +void ItemBase::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) { + App::hoveredLinkItem(active ? _parent : nullptr); + Ui::repaintHistoryItem(_parent); +} + +void ItemBase::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) { + App::pressedLinkItem(pressed ? _parent : nullptr); + Ui::repaintHistoryItem(_parent); +} + +void RadialProgressItem::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) { + if (p == _openl || p == _savel || p == _cancell) { + a_iconOver.start(active ? 1 : 0); + _a_iconOver.start(); + } + ItemBase::clickHandlerActiveChanged(p, active); +} + +void RadialProgressItem::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) { + ItemBase::clickHandlerPressedChanged(p, pressed); +} + +void RadialProgressItem::setLinks(ClickHandlerPtr &&openl, ClickHandlerPtr &&savel, ClickHandlerPtr &&cancell) { + _openl = std_::move(openl); + _savel = std_::move(savel); + _cancell = std_::move(cancell); +} + +void RadialProgressItem::step_iconOver(float64 ms, bool timer) { + float64 dt = ms / st::msgFileOverDuration; + if (dt >= 1) { + a_iconOver.finish(); + _a_iconOver.stop(); + } else if (!timer) { + a_iconOver.update(dt, anim::linear); + } + if (timer && iconAnimated()) { + Ui::repaintHistoryItem(_parent); + } +} + +void RadialProgressItem::step_radial(uint64 ms, bool timer) { + if (timer) { + Ui::repaintHistoryItem(_parent); + } else { + _radial->update(dataProgress(), dataFinished(), ms); + if (!_radial->animating()) { + checkRadialFinished(); + } + } +} + +void RadialProgressItem::ensureRadial() const { + if (!_radial) { + _radial = new RadialAnimation(animation(const_cast(this), &RadialProgressItem::step_radial)); + } +} + +void RadialProgressItem::checkRadialFinished() { + if (_radial && !_radial->animating() && dataLoaded()) { + delete _radial; + _radial = nullptr; + } +} + +RadialProgressItem::~RadialProgressItem() { + deleteAndMark(_radial); +} + +void FileBase::setStatusSize(int32 newSize, int32 fullSize, int32 duration, qint64 realDuration) const { + _statusSize = newSize; + if (_statusSize == FileStatusSizeReady) { + _statusText = (duration >= 0) ? formatDurationAndSizeText(duration, fullSize) : (duration < -1 ? formatGifAndSizeText(fullSize) : formatSizeText(fullSize)); + } else if (_statusSize == FileStatusSizeLoaded) { + _statusText = (duration >= 0) ? formatDurationText(duration) : (duration < -1 ? qsl("GIF") : formatSizeText(fullSize)); + } else if (_statusSize == FileStatusSizeFailed) { + _statusText = lang(lng_attach_failed); + } else if (_statusSize >= 0) { + _statusText = formatDownloadText(_statusSize, fullSize); + } else { + _statusText = formatPlayedText(-_statusSize - 1, realDuration); + } +} + +Date::Date(const QDate &date, bool month) +: _date(date) +, _text(month ? langMonthFull(date) : langDayOfMonthFull(date)) { + AddComponents(Info::Bit()); +} + +void Date::initDimensions() { + _maxw = st::normalFont->width(_text); + _minh = st::linksDateMargin.top() + st::normalFont->height + st::linksDateMargin.bottom() + st::linksBorder; +} + +void Date::paint(Painter &p, const QRect &clip, uint32 selection, const PaintContext *context) const { + if (clip.intersects(QRect(0, st::linksDateMargin.top(), _width, st::normalFont->height))) { + p.setPen(st::linksDateColor); + p.setFont(st::semiboldFont); + p.drawTextLeft(0, st::linksDateMargin.top(), _width, _text); + } +} + +Photo::Photo(PhotoData *photo, HistoryItem *parent) : ItemBase(parent) +, _data(photo) +, _link(new PhotoOpenClickHandler(photo)) +, _goodLoaded(false) { +} + +void Photo::initDimensions() { + _maxw = 2 * st::overviewPhotoMinSize; + _minh = _maxw; +} + +int32 Photo::resizeGetHeight(int32 width) { + width = qMin(width, _maxw); + if (width != _width || width != _height) { + _width = qMin(width, _maxw); + _height = _width; + } + return _height; +} + +void Photo::paint(Painter &p, const QRect &clip, uint32 selection, const PaintContext *context) const { + bool good = _data->loaded(); + if (!good) { + _data->medium->automaticLoad(_parent); + good = _data->medium->loaded(); + } + if ((good && !_goodLoaded) || _pix.width() != _width * cIntRetinaFactor()) { + _goodLoaded = good; + + int32 size = _width * cIntRetinaFactor(); + if (_goodLoaded || _data->thumb->loaded()) { + QImage img = (_data->loaded() ? _data->full : (_data->medium->loaded() ? _data->medium : _data->thumb))->pix().toImage(); + if (!_goodLoaded) { + img = imageBlur(img); + } + if (img.width() == img.height()) { + if (img.width() != size) { + img = img.scaled(size, size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); + } + } else if (img.width() > img.height()) { + img = img.copy((img.width() - img.height()) / 2, 0, img.height(), img.height()).scaled(size, size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); + } else { + img = img.copy(0, (img.height() - img.width()) / 2, img.width(), img.width()).scaled(size, size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); + } + img.setDevicePixelRatio(cRetinaFactor()); + _data->forget(); + + _pix = QPixmap::fromImage(img, Qt::ColorOnly); + } else if (!_pix.isNull()) { + _pix = QPixmap(); + } + } + + if (_pix.isNull()) { + p.fillRect(0, 0, _width, _height, st::overviewPhotoBg); + } else { + p.drawPixmap(0, 0, _pix); + } + + if (selection == FullSelection) { + p.fillRect(QRect(0, 0, _width, _height), st::overviewPhotoSelectOverlay); + p.drawSprite(QPoint(rtl() ? 0 : (_width - st::overviewPhotoChecked.pxWidth()), _height - st::overviewPhotoChecked.pxHeight()), st::overviewPhotoChecked); + } else if (context->selecting) { + p.drawSprite(QPoint(rtl() ? 0 : (_width - st::overviewPhotoCheck.pxWidth()), _height - st::overviewPhotoCheck.pxHeight()), st::overviewPhotoCheck); + } +} + +void Photo::getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int x, int y) const { + if (hasPoint(x, y)) { + link = _link; + } +} + +Video::Video(DocumentData *video, HistoryItem *parent) : FileBase(parent) +, _data(video) +, _duration(formatDurationText(_data->duration())) +, _thumbLoaded(false) { + setDocumentLinks(_data); +} + +void Video::initDimensions() { + _maxw = 2 * st::minPhotoSize; + _minh = _maxw; +} + +int32 Video::resizeGetHeight(int32 width) { + _width = qMin(width, _maxw); + _height = _width; + return _height; +} + +void Video::paint(Painter &p, const QRect &clip, uint32 selection, const PaintContext *context) const { + bool selected = (selection == FullSelection), thumbLoaded = _data->thumb->loaded(); + + _data->automaticLoad(_parent); + bool loaded = _data->loaded(), displayLoading = _data->displayLoading(); + if (displayLoading) { + ensureRadial(); + if (!_radial->animating()) { + _radial->start(_data->progress()); + } + } + updateStatusText(); + bool radial = isRadialAnimation(context->ms); + + if ((thumbLoaded && !_thumbLoaded) || (_pix.width() != _width * cIntRetinaFactor())) { + _thumbLoaded = thumbLoaded; + + if (_thumbLoaded && !_data->thumb->isNull()) { + int32 size = _width * cIntRetinaFactor(); + QImage img = imageBlur(_data->thumb->pix().toImage()); + if (img.width() == img.height()) { + if (img.width() != size) { + img = img.scaled(size, size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); + } + } else if (img.width() > img.height()) { + img = img.copy((img.width() - img.height()) / 2, 0, img.height(), img.height()).scaled(size, size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); + } else { + img = img.copy(0, (img.height() - img.width()) / 2, img.width(), img.width()).scaled(size, size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); + } + img.setDevicePixelRatio(cRetinaFactor()); + _data->forget(); + + _pix = QPixmap::fromImage(img, Qt::ColorOnly); + } else if (!_pix.isNull()) { + _pix = QPixmap(); + } + } + + if (_pix.isNull()) { + p.fillRect(0, 0, _width, _height, st::overviewPhotoBg); + } else { + p.drawPixmap(0, 0, _pix); + } + + if (selected) { + p.fillRect(QRect(0, 0, _width, _height), st::overviewPhotoSelectOverlay); + } + + if (!selected && !context->selecting && !loaded) { + if (clip.intersects(QRect(0, _height - st::normalFont->height, _width, st::normalFont->height))) { + int32 statusX = st::msgDateImgPadding.x(), statusY = _height - st::normalFont->height - st::msgDateImgPadding.y(); + int32 statusW = st::normalFont->width(_statusText) + 2 * st::msgDateImgPadding.x(); + int32 statusH = st::normalFont->height + 2 * st::msgDateImgPadding.y(); + statusX = _width - statusW + statusX; + p.fillRect(rtlrect(statusX - st::msgDateImgPadding.x(), statusY - st::msgDateImgPadding.y(), statusW, statusH, _width), selected ? st::msgDateImgBgSelected : st::msgDateImgBg); + p.setFont(st::normalFont); + p.setPen(st::white); + p.drawTextLeft(statusX, statusY, _width, _statusText, statusW - 2 * st::msgDateImgPadding.x()); + } + } + if (clip.intersects(QRect(0, 0, _width, st::normalFont->height))) { + int32 statusX = st::msgDateImgPadding.x(), statusY = st::msgDateImgPadding.y(); + int32 statusW = st::normalFont->width(_duration) + 2 * st::msgDateImgPadding.x(); + int32 statusH = st::normalFont->height + 2 * st::msgDateImgPadding.y(); + p.fillRect(rtlrect(statusX - st::msgDateImgPadding.x(), statusY - st::msgDateImgPadding.y(), statusW, statusH, _width), selected ? st::msgDateImgBgSelected : st::msgDateImgBg); + p.setFont(st::normalFont); + p.setPen(st::white); + p.drawTextLeft(statusX, statusY, _width, _duration, statusW - 2 * st::msgDateImgPadding.x()); + } + + QRect inner((_width - st::msgFileSize) / 2, (_height - st::msgFileSize) / 2, st::msgFileSize, st::msgFileSize); + if (clip.intersects(inner)) { + p.setPen(Qt::NoPen); + if (selected) { + p.setBrush(st::msgDateImgBgSelected); + } else if (_a_iconOver.animating()) { + _a_iconOver.step(context->ms); + float64 over = a_iconOver.current(); + p.setOpacity((st::msgDateImgBg->c.alphaF() * (1 - over)) + (st::msgDateImgBgOver->c.alphaF() * over)); + p.setBrush(st::black); + } else { + bool over = ClickHandler::showAsActive(loaded ? _openl : (_data->loading() ? _cancell : _savel)); + p.setBrush(over ? st::msgDateImgBgOver : st::msgDateImgBg); + } + + p.setRenderHint(QPainter::HighQualityAntialiasing); + p.drawEllipse(inner); + p.setRenderHint(QPainter::HighQualityAntialiasing, false); + + p.setOpacity((radial && loaded) ? _radial->opacity() : 1); + style::sprite icon; + if (radial) { + icon = (selected ? st::msgFileInCancelSelected : st::msgFileInCancel); + } else if (loaded) { + icon = (selected ? st::msgFileInPlaySelected : st::msgFileInPlay); + } else { + icon = (selected ? st::msgFileInDownloadSelected : st::msgFileInDownload); + } + p.drawSpriteCenter(inner, icon); + if (radial) { + p.setOpacity(1); + QRect rinner(inner.marginsRemoved(QMargins(st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine))); + _radial->draw(p, rinner, st::msgFileRadialLine, selected ? st::msgInBgSelected : st::msgInBg); + } + } + + if (selected) { + p.drawSprite(QPoint(rtl() ? 0 : (_width - st::overviewPhotoChecked.pxWidth()), _height - st::overviewPhotoChecked.pxHeight()), st::overviewPhotoChecked); + } else if (context->selecting) { + p.drawSprite(QPoint(rtl() ? 0 : (_width - st::overviewPhotoCheck.pxWidth()), _height - st::overviewPhotoCheck.pxHeight()), st::overviewPhotoCheck); + } +} + +void Video::getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int x, int y) const { + bool loaded = _data->loaded(); + + if (hasPoint(x, y)) { + link = loaded ? _openl : (_data->loading() ? _cancell : _savel); + } +} + +void Video::updateStatusText() const { + bool showPause = false; + int32 statusSize = 0; + if (_data->status == FileDownloadFailed || _data->status == FileUploadFailed) { + statusSize = FileStatusSizeFailed; + } else if (_data->status == FileUploading) { + statusSize = _data->uploadOffset; + } else if (_data->loading()) { + statusSize = _data->loadOffset(); + } else if (_data->loaded()) { + statusSize = FileStatusSizeLoaded; + } else { + statusSize = FileStatusSizeReady; + } + if (statusSize != _statusSize) { + int32 status = statusSize, size = _data->size; + if (statusSize >= 0 && statusSize < 0x7F000000) { + size = status; + status = FileStatusSizeReady; + } + setStatusSize(status, size, -1, 0); + _statusSize = statusSize; + } +} + +Voice::Voice(DocumentData *voice, HistoryItem *parent) : FileBase(parent) +, _data(voice) +, _namel(new DocumentOpenClickHandler(_data)) { + AddComponents(Info::Bit()); + + t_assert(_data->voice() != 0); + + setDocumentLinks(_data); + + updateName(); + QString d = textcmdLink(1, textRichPrepare(langDateTime(date(_data->date)))); + TextParseOptions opts = { TextParseRichText, 0, 0, Qt::LayoutDirectionAuto }; + _details.setText(st::normalFont, lng_date_and_duration(lt_date, d, lt_duration, formatDurationText(_data->voice()->duration)), opts); + _details.setLink(1, MakeShared(parent)); +} + +void Voice::initDimensions() { + _maxw = st::profileMaxWidth; + _minh = st::msgFilePadding.top() + st::msgFileSize + st::msgFilePadding.bottom() + st::lineWidth; +} + +void Voice::paint(Painter &p, const QRect &clip, uint32 selection, const PaintContext *context) const { + bool selected = (selection == FullSelection); + + _data->automaticLoad(_parent); + bool loaded = _data->loaded(), displayLoading = _data->displayLoading(); + + if (displayLoading) { + ensureRadial(); + if (!_radial->animating()) { + _radial->start(_data->progress()); + } + } + bool showPause = updateStatusText(); + int32 nameVersion = _parent->fromOriginal()->nameVersion; + if (nameVersion > _nameVersion) { + updateName(); + } + bool radial = isRadialAnimation(context->ms); + + int32 nameleft = 0, nametop = 0, nameright = 0, statustop = 0, datetop = -1; + + nameleft = st::msgFilePadding.left() + st::msgFileSize + st::msgFilePadding.right(); + nameright = st::msgFilePadding.left(); + nametop = st::msgFileNameTop; + statustop = st::msgFileStatusTop; + + if (selected) { + p.fillRect(clip.intersected(QRect(0, 0, _width, _height)), st::msgInBgSelected); + } + + QRect inner(rtlrect(st::msgFilePadding.left(), st::msgFilePadding.top(), st::msgFileSize, st::msgFileSize, _width)); + if (clip.intersects(inner)) { + p.setPen(Qt::NoPen); + if (selected) { + p.setBrush(st::msgFileInBgSelected); + } else if (_a_iconOver.animating()) { + _a_iconOver.step(context->ms); + float64 over = a_iconOver.current(); + p.setBrush(style::interpolate(st::msgFileInBg, st::msgFileInBgOver, over)); + } else { + bool over = ClickHandler::showAsActive(loaded ? _openl : (_data->loading() ? _cancell : _openl)); + p.setBrush(over ? st::msgFileInBgOver : st::msgFileInBg); + } + + p.setRenderHint(QPainter::HighQualityAntialiasing); + p.drawEllipse(inner); + p.setRenderHint(QPainter::HighQualityAntialiasing, false); + + if (radial) { + QRect rinner(inner.marginsRemoved(QMargins(st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine))); + style::color bg(selected ? st::msgInBgSelected : st::msgInBg); + _radial->draw(p, rinner, st::msgFileRadialLine, bg); + } + + style::sprite icon; + if (showPause) { + icon = selected ? st::msgFileInPauseSelected : st::msgFileInPause; + } else if (_statusSize < 0 || _statusSize == FileStatusSizeLoaded) { + icon = selected ? st::msgFileInPlaySelected : st::msgFileInPlay; + } else if (_data->loading()) { + icon = selected ? st::msgFileInCancelSelected : st::msgFileInCancel; + } else { + icon = selected ? st::msgFileInDownloadSelected : st::msgFileInDownload; + } + p.drawSpriteCenter(inner, icon); + } + + int32 namewidth = _width - nameleft - nameright; + + if (clip.intersects(rtlrect(nameleft, nametop, namewidth, st::semiboldFont->height, _width))) { + p.setPen(st::black); + _name.drawLeftElided(p, nameleft, nametop, namewidth, _width); + } + + if (clip.intersects(rtlrect(nameleft, statustop, namewidth, st::normalFont->height, _width))) { + p.setFont(st::normalFont); + p.setPen(selected ? st::mediaInFgSelected : st::mediaInFg); + int32 unreadx = nameleft; + if (_statusSize == FileStatusSizeLoaded || _statusSize == FileStatusSizeReady) { + textstyleSet(&(selected ? st::mediaInStyleSelected : st::mediaInStyle)); + _details.drawLeftElided(p, nameleft, statustop, namewidth, _width); + textstyleRestore(); + unreadx += _details.maxWidth(); + } else { + int32 statusw = st::normalFont->width(_statusText); + p.drawTextLeft(nameleft, statustop, _width, _statusText, statusw); + unreadx += statusw; + } + if (_parent->isMediaUnread() && unreadx + st::mediaUnreadSkip + st::mediaUnreadSize <= _width) { + p.setPen(Qt::NoPen); + p.setBrush(selected ? st::msgFileInBgSelected : st::msgFileInBg); + + p.setRenderHint(QPainter::HighQualityAntialiasing, true); + p.drawEllipse(rtlrect(unreadx + st::mediaUnreadSkip, statustop + st::mediaUnreadTop, st::mediaUnreadSize, st::mediaUnreadSize, _width)); + p.setRenderHint(QPainter::HighQualityAntialiasing, false); + } + } +} + +void Voice::getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int x, int y) const { + bool loaded = _data->loaded(); + + bool showPause = updateStatusText(); + + int32 nameleft = 0, nametop = 0, nameright = 0, statustop = 0, datetop = 0; + + nameleft = st::msgFilePadding.left() + st::msgFileSize + st::msgFilePadding.right(); + nameright = st::msgFilePadding.left(); + nametop = st::msgFileNameTop; + statustop = st::msgFileStatusTop; + + QRect inner(rtlrect(st::msgFilePadding.left(), st::msgFilePadding.top(), st::msgFileSize, st::msgFileSize, _width)); + if (inner.contains(x, y)) { + link = loaded ? _openl : ((_data->loading() || _data->status == FileUploading) ? _cancell : _openl); + return; + } + if (rtlrect(nameleft, statustop, _width - nameleft - nameright, st::normalFont->height, _width).contains(x, y)) { + if (_statusSize == FileStatusSizeLoaded || _statusSize == FileStatusSizeReady) { + bool inText = false; + _details.getStateLeft(link, inText, x - nameleft, y - statustop, _width, _width); + cursor = inText ? HistoryInTextCursorState : HistoryDefaultCursorState; + } + } + if (hasPoint(x, y) && !link && !_data->loading()) { + link = _namel; + return; + } +} + +void Voice::updateName() const { + int32 version = 0; + if (const HistoryMessageForwarded *fwd = _parent->Get()) { + if (_parent->fromOriginal()->isChannel()) { + _name.setText(st::semiboldFont, lng_forwarded_channel(lt_channel, App::peerName(_parent->fromOriginal())), _textNameOptions); + } else { + _name.setText(st::semiboldFont, lng_forwarded(lt_user, App::peerName(_parent->fromOriginal())), _textNameOptions); + } + } else { + _name.setText(st::semiboldFont, App::peerName(_parent->from()), _textNameOptions); + } + version = _parent->fromOriginal()->nameVersion; + _nameVersion = version; +} + +bool Voice::updateStatusText() const { + bool showPause = false; + int32 statusSize = 0, realDuration = 0; + if (_data->status == FileDownloadFailed || _data->status == FileUploadFailed) { + statusSize = FileStatusSizeFailed; + } else if (_data->loaded()) { + AudioMsgId playing; + AudioPlayerState playingState = AudioPlayerStopped; + int64 playingPosition = 0, playingDuration = 0; + int32 playingFrequency = 0; + if (audioPlayer()) { + audioPlayer()->currentState(&playing, &playingState, &playingPosition, &playingDuration, &playingFrequency); + } + + if (playing == AudioMsgId(_data, _parent->fullId()) && !(playingState & AudioPlayerStoppedMask) && playingState != AudioPlayerFinishing) { + statusSize = -1 - (playingPosition / (playingFrequency ? playingFrequency : AudioVoiceMsgFrequency)); + realDuration = playingDuration / (playingFrequency ? playingFrequency : AudioVoiceMsgFrequency); + showPause = (playingState == AudioPlayerPlaying || playingState == AudioPlayerResuming || playingState == AudioPlayerStarting); + } else { + statusSize = FileStatusSizeLoaded; + } + } else { + statusSize = FileStatusSizeReady; + } + if (statusSize != _statusSize) { + setStatusSize(statusSize, _data->size, _data->voice()->duration, realDuration); + } + return showPause; +} + +Document::Document(DocumentData *document, HistoryItem *parent) : FileBase(parent) +, _data(document) +, _msgl(new GoToMessageClickHandler(parent)) +, _namel(new DocumentOpenClickHandler(_data)) +, _thumbForLoaded(false) +, _name(documentName(_data)) +, _date(langDateTime(date(_data->date))) +, _namew(st::semiboldFont->width(_name)) +, _datew(st::normalFont->width(_date)) +, _colorIndex(documentColorIndex(_data, _ext)) { + AddComponents(Info::Bit()); + + setDocumentLinks(_data); + + setStatusSize(FileStatusSizeReady, _data->size, _data->song() ? _data->song()->duration : -1, 0); + + if (withThumb()) { + _data->thumb->load(); + int32 tw = convertScale(_data->thumb->width()), th = convertScale(_data->thumb->height()); + if (tw > th) { + _thumbw = (tw * st::overviewFileSize) / th; + } else { + _thumbw = st::overviewFileSize; + } + } else { + _thumbw = 0; + } + + _extw = st::overviewFileExtFont->width(_ext); + if (_extw > st::overviewFileSize - st::overviewFileExtPadding * 2) { + _ext = st::overviewFileExtFont->elided(_ext, st::overviewFileSize - st::overviewFileExtPadding * 2, Qt::ElideMiddle); + _extw = st::overviewFileExtFont->width(_ext); + } +} + +void Document::initDimensions() { + _maxw = st::profileMaxWidth; + if (_data->song()) { + _minh = st::msgFilePadding.top() + st::msgFileSize + st::msgFilePadding.bottom(); + } else { + _minh = st::overviewFilePadding.top() + st::overviewFileSize + st::overviewFilePadding.bottom() + st::lineWidth; + } +} + +void Document::paint(Painter &p, const QRect &clip, uint32 selection, const PaintContext *context) const { + bool selected = (selection == FullSelection); + + _data->automaticLoad(_parent); + bool loaded = _data->loaded() || Local::willStickerImageLoad(_data->mediaKey()), displayLoading = _data->displayLoading(); + + if (displayLoading) { + ensureRadial(); + if (!_radial->animating()) { + _radial->start(_data->progress()); + } + } + bool showPause = updateStatusText(); + bool radial = isRadialAnimation(context->ms); + + int32 nameleft = 0, nametop = 0, nameright = 0, statustop = 0, datetop = -1; + bool wthumb = withThumb(); + + if (_data->song()) { + nameleft = st::msgFilePadding.left() + st::msgFileSize + st::msgFilePadding.right(); + nameright = st::msgFilePadding.left(); + nametop = st::msgFileNameTop; + statustop = st::msgFileStatusTop; + + if (selected) { + p.fillRect(QRect(0, 0, _width, _height), st::msgInBgSelected); + } + + QRect inner(rtlrect(st::msgFilePadding.left(), st::msgFilePadding.top(), st::msgFileSize, st::msgFileSize, _width)); + if (clip.intersects(inner)) { + p.setPen(Qt::NoPen); + if (selected) { + p.setBrush(st::msgFileInBgSelected); + } else if (_a_iconOver.animating()) { + _a_iconOver.step(context->ms); + float64 over = a_iconOver.current(); + p.setBrush(style::interpolate(st::msgFileInBg, st::msgFileInBgOver, over)); + } else { + bool over = ClickHandler::showAsActive(loaded ? _openl : (_data->loading() ? _cancell : _openl)); + p.setBrush(over ? st::msgFileInBgOver : st::msgFileInBg); + } + + p.setRenderHint(QPainter::HighQualityAntialiasing); + p.drawEllipse(inner); + p.setRenderHint(QPainter::HighQualityAntialiasing, false); + + if (radial) { + QRect rinner(inner.marginsRemoved(QMargins(st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine))); + style::color bg(selected ? st::msgInBgSelected : st::msgInBg); + _radial->draw(p, rinner, st::msgFileRadialLine, bg); + } + + style::sprite icon; + if (showPause) { + icon = selected ? st::msgFileInPauseSelected : st::msgFileInPause; + } else if (loaded) { + icon = selected ? st::msgFileInPlaySelected : st::msgFileInPlay; + } else if (_data->loading()) { + icon = selected ? st::msgFileInCancelSelected : st::msgFileInCancel; + } else { + icon = selected ? st::msgFileInDownloadSelected : st::msgFileInDownload; + } + p.drawSpriteCenter(inner, icon); + } + } else { + nameleft = st::overviewFileSize + st::overviewFilePadding.right(); + nametop = st::linksBorder + st::overviewFileNameTop; + statustop = st::linksBorder + st::overviewFileStatusTop; + datetop = st::linksBorder + st::overviewFileDateTop; + + QRect border(rtlrect(nameleft, 0, _width - nameleft, st::linksBorder, _width)); + if (!context->isAfterDate && clip.intersects(border)) { + p.fillRect(clip.intersected(border), st::linksBorderFg); + } + + QRect rthumb(rtlrect(0, st::linksBorder + st::overviewFilePadding.top(), st::overviewFileSize, st::overviewFileSize, _width)); + if (clip.intersects(rthumb)) { + if (wthumb) { + if (_data->thumb->loaded()) { + if (_thumb.isNull() || loaded != _thumbForLoaded) { + _thumbForLoaded = loaded; + ImagePixOptions options = ImagePixSmooth; + if (!_thumbForLoaded) options |= ImagePixBlurred; + _thumb = _data->thumb->pixNoCache(_thumbw, 0, options, st::overviewFileSize, st::overviewFileSize); + } + p.drawPixmap(rthumb.topLeft(), _thumb); + } else { + p.fillRect(rthumb, st::black); + } + } else { + p.fillRect(rthumb, documentColor(_colorIndex)); + if (!radial && loaded && !_ext.isEmpty()) { + p.setFont(st::overviewFileExtFont); + p.setPen(st::white); + p.drawText(rthumb.left() + (rthumb.width() - _extw) / 2, rthumb.top() + st::overviewFileExtTop + st::overviewFileExtFont->ascent, _ext); + } + } + if (selected) { + p.fillRect(rthumb, textstyleCurrent()->selectOverlay); + } + + if (radial || (!loaded && !_data->loading())) { + QRect inner(rthumb.x() + (rthumb.width() - st::msgFileSize) / 2, rthumb.y() + (rthumb.height() - st::msgFileSize) / 2, st::msgFileSize, st::msgFileSize); + if (clip.intersects(inner)) { + float64 radialOpacity = (radial && loaded && !_data->uploading()) ? _radial->opacity() : 1; + p.setPen(Qt::NoPen); + if (selected) { + p.setBrush(wthumb ? st::msgDateImgBgSelected : documentSelectedColor(_colorIndex)); + } else if (_a_iconOver.animating()) { + _a_iconOver.step(context->ms); + float64 over = a_iconOver.current(); + if (wthumb) { + p.setOpacity((st::msgDateImgBg->c.alphaF() * (1 - over)) + (st::msgDateImgBgOver->c.alphaF() * over)); + p.setBrush(st::black); + } else { + p.setBrush(style::interpolate(documentDarkColor(_colorIndex), documentOverColor(_colorIndex), over)); + } + } else { + bool over = ClickHandler::showAsActive(_data->loading() ? _cancell : _savel); + p.setBrush(over ? (wthumb ? st::msgDateImgBgOver : documentOverColor(_colorIndex)) : (wthumb ? st::msgDateImgBg : documentDarkColor(_colorIndex))); + } + p.setOpacity(radialOpacity * p.opacity()); + + p.setRenderHint(QPainter::HighQualityAntialiasing); + p.drawEllipse(inner); + p.setRenderHint(QPainter::HighQualityAntialiasing, false); + + p.setOpacity(radialOpacity); + style::sprite icon; + if (loaded || _data->loading()) { + icon = (selected ? st::msgFileInCancelSelected : st::msgFileInCancel); + } else { + icon = (selected ? st::msgFileInDownloadSelected : st::msgFileInDownload); + } + p.drawSpriteCenter(inner, icon); + if (radial) { + p.setOpacity(1); + + QRect rinner(inner.marginsRemoved(QMargins(st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine))); + _radial->draw(p, rinner, st::msgFileRadialLine, selected ? st::msgInBgSelected : st::msgInBg); + } + } + } + if (selected || context->selecting) { + QRect check(rthumb.topLeft() + QPoint(rtl() ? 0 : (rthumb.width() - st::defaultCheckbox.diameter), rthumb.height() - st::defaultCheckbox.diameter), QSize(st::defaultCheckbox.diameter, st::defaultCheckbox.diameter)); + p.fillRect(check, selected ? st::overviewFileChecked : st::overviewFileCheck); + p.drawSpriteCenter(check, st::defaultCheckbox.checkIcon); + } + } + } + + int32 namewidth = _width - nameleft - nameright; + + if (clip.intersects(rtlrect(nameleft, nametop, qMin(namewidth, _namew), st::semiboldFont->height, _width))) { + p.setFont(st::semiboldFont); + p.setPen(st::black); + if (namewidth < _namew) { + p.drawTextLeft(nameleft, nametop, _width, st::semiboldFont->elided(_name, namewidth)); + } else { + p.drawTextLeft(nameleft, nametop, _width, _name, _namew); + } + } + + if (clip.intersects(rtlrect(nameleft, statustop, namewidth, st::normalFont->height, _width))) { + p.setFont(st::normalFont); + p.setPen(st::mediaInFg); + p.drawTextLeft(nameleft, statustop, _width, _statusText); + } + if (datetop >= 0 && clip.intersects(rtlrect(nameleft, datetop, _datew, st::normalFont->height, _width))) { + p.setFont(ClickHandler::showAsActive(_msgl) ? st::normalFont->underline() : st::normalFont); + p.setPen(st::mediaInFg); + p.drawTextLeft(nameleft, datetop, _width, _date, _datew); + } +} + +void Document::getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int x, int y) const { + bool loaded = _data->loaded() || Local::willStickerImageLoad(_data->mediaKey()); + + bool showPause = updateStatusText(); + + int32 nameleft = 0, nametop = 0, nameright = 0, statustop = 0, datetop = 0; + bool wthumb = withThumb(); + + if (_data->song()) { + nameleft = st::msgFilePadding.left() + st::msgFileSize + st::msgFilePadding.right(); + nameright = st::msgFilePadding.left(); + nametop = st::msgFileNameTop; + statustop = st::msgFileStatusTop; + + QRect inner(rtlrect(st::msgFilePadding.left(), st::msgFilePadding.top(), st::msgFileSize, st::msgFileSize, _width)); + if (inner.contains(x, y)) { + link = loaded ? _openl : ((_data->loading() || _data->status == FileUploading) ? _cancell : _openl); + return; + } + if (hasPoint(x, y) && !_data->loading()) { + link = _namel; + return; + } + } else { + nameleft = st::overviewFileSize + st::overviewFilePadding.right(); + nametop = st::linksBorder + st::overviewFileNameTop; + statustop = st::linksBorder + st::overviewFileStatusTop; + datetop = st::linksBorder + st::overviewFileDateTop; + + QRect rthumb(rtlrect(0, st::linksBorder + st::overviewFilePadding.top(), st::overviewFileSize, st::overviewFileSize, _width)); + + if (rthumb.contains(x, y)) { + link = loaded ? _openl : ((_data->loading() || _data->status == FileUploading) ? _cancell : _savel); + return; + } + + if (_data->status != FileUploadFailed) { + if (rtlrect(nameleft, datetop, _datew, st::normalFont->height, _width).contains(x, y)) { + link = _msgl; + return; + } + } + if (!_data->loading() && _data->isValid()) { + if (loaded && rtlrect(0, st::linksBorder, nameleft, _height - st::linksBorder, _width).contains(x, y)) { + link = _namel; + return; + } + if (rtlrect(nameleft, nametop, qMin(_width - nameleft - nameright, _namew), st::semiboldFont->height, _width).contains(x, y)) { + link = _namel; + return; + } + } + } +} + +bool Document::updateStatusText() const { + bool showPause = false; + int32 statusSize = 0, realDuration = 0; + if (_data->status == FileDownloadFailed || _data->status == FileUploadFailed) { + statusSize = FileStatusSizeFailed; + } else if (_data->status == FileUploading) { + statusSize = _data->uploadOffset; + } else if (_data->loading()) { + statusSize = _data->loadOffset(); + } else if (_data->loaded()) { + if (_data->song()) { + SongMsgId playing; + AudioPlayerState playingState = AudioPlayerStopped; + int64 playingPosition = 0, playingDuration = 0; + int32 playingFrequency = 0; + if (audioPlayer()) { + audioPlayer()->currentState(&playing, &playingState, &playingPosition, &playingDuration, &playingFrequency); + } + + if (playing == SongMsgId(_data, _parent->fullId()) && !(playingState & AudioPlayerStoppedMask) && playingState != AudioPlayerFinishing) { + statusSize = -1 - (playingPosition / (playingFrequency ? playingFrequency : AudioVoiceMsgFrequency)); + realDuration = playingDuration / (playingFrequency ? playingFrequency : AudioVoiceMsgFrequency); + showPause = (playingState == AudioPlayerPlaying || playingState == AudioPlayerResuming || playingState == AudioPlayerStarting); + } else { + statusSize = FileStatusSizeLoaded; + } + if (!showPause && (playing == SongMsgId(_data, _parent->fullId())) && App::main() && App::main()->player()->seekingSong(playing)) { + showPause = true; + } + } else { + statusSize = FileStatusSizeLoaded; + } + } else { + statusSize = FileStatusSizeReady; + } + if (statusSize != _statusSize) { + setStatusSize(statusSize, _data->size, _data->song() ? _data->song()->duration : -1, realDuration); + } + return showPause; +} + +Link::Link(HistoryMedia *media, HistoryItem *parent) : ItemBase(parent) { + AddComponents(Info::Bit()); + + QString text = _parent->originalText(); + EntitiesInText entities = _parent->originalEntities(); + + int32 from = 0, till = text.size(), lnk = entities.size(); + for (int32 i = 0; i < lnk; ++i) { + if (entities[i].type != EntityInTextUrl && entities[i].type != EntityInTextCustomUrl && entities[i].type != EntityInTextEmail) { + continue; + } + QString u = entities[i].text, t = text.mid(entities[i].offset, entities[i].length); + _links.push_back(LinkEntry(u.isEmpty() ? t : u, t)); + } + while (lnk > 0 && till > from) { + --lnk; + if (entities[lnk].type != EntityInTextUrl && entities[lnk].type != EntityInTextCustomUrl && entities[lnk].type != EntityInTextEmail) { + ++lnk; + break; + } + int32 afterLinkStart = entities[lnk].offset + entities[lnk].length; + if (till > afterLinkStart) { + if (!QRegularExpression(qsl("^[,.\\s_=+\\-;:`'\"\\(\\)\\[\\]\\{\\}<>*&^%\\$#@!\\\\/]+$")).match(text.mid(afterLinkStart, till - afterLinkStart)).hasMatch()) { + ++lnk; + break; + } + } + till = entities[lnk].offset; + } + if (!lnk) { + if (QRegularExpression(qsl("^[,.\\s\\-;:`'\"\\(\\)\\[\\]\\{\\}<>*&^%\\$#@!\\\\/]+$")).match(text.mid(from, till - from)).hasMatch()) { + till = from; + } + } + + _page = (media && media->type() == MediaTypeWebPage) ? static_cast(media)->webpage() : 0; + if (_page) { + if (_page->document) { + _photol.reset(new DocumentOpenClickHandler(_page->document)); + } else if (_page->photo) { + if (_page->type == WebPageProfile || _page->type == WebPageVideo) { + _photol = MakeShared(_page->url); + } else if (_page->type == WebPagePhoto || _page->siteName == qstr("Twitter") || _page->siteName == qstr("Facebook")) { + _photol.reset(new PhotoOpenClickHandler(_page->photo)); + } else { + _photol = MakeShared(_page->url); + } + } else { + _photol = MakeShared(_page->url); + } + } else if (!_links.isEmpty()) { + _photol = MakeShared(_links.front().lnk->text()); + } + if (from >= till && _page) { + text = _page->description; + from = 0; + till = text.size(); + } + if (till > from) { + TextParseOptions opts = { TextParseMultiline, int32(st::linksMaxWidth), 3 * st::normalFont->height, Qt::LayoutDirectionAuto }; + _text.setText(st::normalFont, text.mid(from, till - from), opts); + } + int32 tw = 0, th = 0; + if (_page && _page->photo) { + if (!_page->photo->loaded()) _page->photo->thumb->load(false, false); + + tw = convertScale(_page->photo->thumb->width()); + th = convertScale(_page->photo->thumb->height()); + } else if (_page && _page->document) { + if (!_page->document->thumb->loaded()) _page->document->thumb->load(false, false); + + tw = convertScale(_page->document->thumb->width()); + th = convertScale(_page->document->thumb->height()); + } + if (tw > st::dlgPhotoSize) { + if (th > tw) { + th = th * st::dlgPhotoSize / tw; + tw = st::dlgPhotoSize; + } else if (th > st::dlgPhotoSize) { + tw = tw * st::dlgPhotoSize / th; + th = st::dlgPhotoSize; + } + } + _pixw = qMax(tw, 1); + _pixh = qMax(th, 1); + + if (_page) { + _title = _page->title; + } + QString url(_page ? _page->url : (_links.isEmpty() ? QString() : _links.at(0).lnk->text())); + QVector parts = url.splitRef('/'); + if (!parts.isEmpty()) { + QStringRef domain = parts.at(0); + if (parts.size() > 2 && domain.endsWith(':') && parts.at(1).isEmpty()) { // http:// and others + domain = parts.at(2); + } + + parts = domain.split('@').back().split('.'); + if (parts.size() > 1) { + _letter = parts.at(parts.size() - 2).at(0).toUpper(); + if (_title.isEmpty()) { + _title.reserve(parts.at(parts.size() - 2).size()); + _title.append(_letter).append(parts.at(parts.size() - 2).mid(1)); + } + } + } + _titlew = st::semiboldFont->width(_title); +} + +void Link::initDimensions() { + _maxw = st::linksMaxWidth; + _minh = 0; + if (!_title.isEmpty()) { + _minh += st::semiboldFont->height; + } + if (!_text.isEmpty()) { + _minh += qMin(3 * st::normalFont->height, _text.countHeight(_maxw - st::dlgPhotoSize - st::dlgPhotoPadding)); + } + _minh += _links.size() * st::normalFont->height; + _minh = qMax(_minh, int32(st::dlgPhotoSize)) + st::linksMargin.top() + st::linksMargin.bottom() + st::linksBorder; +} + +int32 Link::resizeGetHeight(int32 width) { + _width = qMin(width, _maxw); + int32 w = _width - st::dlgPhotoSize - st::dlgPhotoPadding; + for (int32 i = 0, l = _links.size(); i < l; ++i) { + _links.at(i).lnk->setFullDisplayed(w >= _links.at(i).width); + } + + _height = 0; + if (!_title.isEmpty()) { + _height += st::semiboldFont->height; + } + if (!_text.isEmpty()) { + _height += qMin(3 * st::normalFont->height, _text.countHeight(_width - st::dlgPhotoSize - st::dlgPhotoPadding)); + } + _height += _links.size() * st::normalFont->height; + _height = qMax(_height, int32(st::dlgPhotoSize)) + st::linksMargin.top() + st::linksMargin.bottom() + st::linksBorder; + return _height; +} + +void Link::paint(Painter &p, const QRect &clip, uint32 selection, const PaintContext *context) const { + int32 left = st::dlgPhotoSize + st::dlgPhotoPadding, top = st::linksMargin.top() + st::linksBorder, w = _width - left; + if (clip.intersects(rtlrect(0, top, st::dlgPhotoSize, st::dlgPhotoSize, _width))) { + if (_page && _page->photo) { + QPixmap pix; + if (_page->photo->medium->loaded()) { + pix = _page->photo->medium->pixSingle(_pixw, _pixh, st::dlgPhotoSize, st::dlgPhotoSize); + } else if (_page->photo->loaded()) { + pix = _page->photo->full->pixSingle(_pixw, _pixh, st::dlgPhotoSize, st::dlgPhotoSize); + } else { + pix = _page->photo->thumb->pixSingle(_pixw, _pixh, st::dlgPhotoSize, st::dlgPhotoSize); + } + p.drawPixmapLeft(0, top, _width, pix); + } else if (_page && _page->document && !_page->document->thumb->isNull()) { + p.drawPixmapLeft(0, top, _width, _page->document->thumb->pixSingle(_pixw, _pixh, st::dlgPhotoSize, st::dlgPhotoSize)); + } else { + int32 index = _letter.isEmpty() ? 0 : (_letter.at(0).unicode() % 4); + switch (index) { + case 0: App::roundRect(p, rtlrect(0, top, st::dlgPhotoSize, st::dlgPhotoSize, _width), st::msgFileRedColor, DocRedCorners); break; + case 1: App::roundRect(p, rtlrect(0, top, st::dlgPhotoSize, st::dlgPhotoSize, _width), st::msgFileYellowColor, DocYellowCorners); break; + case 2: App::roundRect(p, rtlrect(0, top, st::dlgPhotoSize, st::dlgPhotoSize, _width), st::msgFileGreenColor, DocGreenCorners); break; + case 3: App::roundRect(p, rtlrect(0, top, st::dlgPhotoSize, st::dlgPhotoSize, _width), st::msgFileBlueColor, DocBlueCorners); break; + } + + if (!_letter.isEmpty()) { + p.setFont(st::linksLetterFont->f); + p.setPen(st::white->p); + p.drawText(rtlrect(0, top, st::dlgPhotoSize, st::dlgPhotoSize, _width), _letter, style::al_center); + } + } + + if (selection == FullSelection) { + App::roundRect(p, rtlrect(0, top, st::dlgPhotoSize, st::dlgPhotoSize, _width), st::overviewPhotoSelectOverlay, PhotoSelectOverlayCorners); + p.drawSpriteLeft(QPoint(st::dlgPhotoSize - st::linksPhotoCheck.pxWidth(), top + st::dlgPhotoSize - st::linksPhotoCheck.pxHeight()), _width, st::linksPhotoChecked); + } else if (context->selecting) { + p.drawSpriteLeft(QPoint(st::dlgPhotoSize - st::linksPhotoCheck.pxWidth(), top + st::dlgPhotoSize - st::linksPhotoCheck.pxHeight()), _width, st::linksPhotoCheck); + } + } + + if (!_title.isEmpty() && _text.isEmpty() && _links.size() == 1) { + top += (st::dlgPhotoSize - st::semiboldFont->height - st::normalFont->height) / 2; + } else { + top = st::linksTextTop; + } + + p.setPen(st::black); + p.setFont(st::semiboldFont); + if (!_title.isEmpty()) { + if (clip.intersects(rtlrect(left, top, qMin(w, _titlew), st::semiboldFont->height, _width))) { + p.drawTextLeft(left, top, _width, (w < _titlew) ? st::semiboldFont->elided(_title, w) : _title); + } + top += st::semiboldFont->height; + } + p.setFont(st::msgFont->f); + if (!_text.isEmpty()) { + int32 h = qMin(st::normalFont->height * 3, _text.countHeight(w)); + if (clip.intersects(rtlrect(left, top, w, h, _width))) { + _text.drawLeftElided(p, left, top, w, _width, 3); + } + top += h; + } + + p.setPen(st::btnYesColor); + for (int32 i = 0, l = _links.size(); i < l; ++i) { + if (clip.intersects(rtlrect(left, top, qMin(w, _links.at(i).width), st::normalFont->height, _width))) { + p.setFont(ClickHandler::showAsActive(_links.at(i).lnk) ? st::normalFont->underline() : st::normalFont); + p.drawTextLeft(left, top, _width, (w < _links.at(i).width) ? st::normalFont->elided(_links.at(i).text, w) : _links.at(i).text); + } + top += st::normalFont->height; + } + + QRect border(rtlrect(left, 0, w, st::linksBorder, _width)); + if (!context->isAfterDate && clip.intersects(border)) { + p.fillRect(clip.intersected(border), st::linksBorderFg); + } +} + +void Link::getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int x, int y) const { + int32 left = st::dlgPhotoSize + st::dlgPhotoPadding, top = st::linksMargin.top() + st::linksBorder, w = _width - left; + if (rtlrect(0, top, st::dlgPhotoSize, st::dlgPhotoSize, _width).contains(x, y)) { + link = _photol; + return; + } + + if (!_title.isEmpty() && _text.isEmpty() && _links.size() == 1) { + top += (st::dlgPhotoSize - st::semiboldFont->height - st::normalFont->height) / 2; + } + if (!_title.isEmpty()) { + if (rtlrect(left, top, qMin(w, _titlew), st::semiboldFont->height, _width).contains(x, y)) { + link = _photol; + return; + } + top += st::webPageTitleFont->height; + } + if (!_text.isEmpty()) { + top += qMin(st::normalFont->height * 3, _text.countHeight(w)); + } + for (int32 i = 0, l = _links.size(); i < l; ++i) { + if (rtlrect(left, top, qMin(w, _links.at(i).width), st::normalFont->height, _width).contains(x, y)) { + link = _links.at(i).lnk; + return; + } + top += st::normalFont->height; + } +} + +Link::LinkEntry::LinkEntry(const QString &url, const QString &text) +: text(text) +, width(st::normalFont->width(text)) +, lnk(MakeShared(url)) { +} + +} // namespace Layout +} // namespace Overview diff --git a/Telegram/SourceFiles/overview/overview_layout.h b/Telegram/SourceFiles/overview/overview_layout.h new file mode 100644 index 0000000000..9a155d01cb --- /dev/null +++ b/Telegram/SourceFiles/overview/overview_layout.h @@ -0,0 +1,337 @@ +/* +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. + +In addition, as a special exception, the copyright holders give permission +to link the code of portions of this program with the OpenSSL library. + +Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE +Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org +*/ +#pragma once + +#include "layout.h" +#include "core/click_handler_types.h" + +namespace Overview { +namespace Layout { + +class PaintContext : public PaintContextBase { +public: + PaintContext(uint64 ms, bool selecting) : PaintContextBase(ms, selecting), isAfterDate(false) { + } + bool isAfterDate; + +}; + +class ItemBase; +class AbstractItem : public LayoutItemBase { +public: + + virtual void paint(Painter &p, const QRect &clip, uint32 selection, const PaintContext *context) const = 0; + + virtual ItemBase *toMediaItem() { + return nullptr; + } + virtual const ItemBase *toMediaItem() const { + return nullptr; + } + + virtual HistoryItem *getItem() const { + return nullptr; + } + virtual DocumentData *getDocument() const { + return nullptr; + } + MsgId msgId() const { + const HistoryItem *item = getItem(); + return item ? item->id : 0; + } + +}; + +class ItemBase : public AbstractItem { +public: + ItemBase(HistoryItem *parent) : _parent(parent) { + } + + ItemBase *toMediaItem() override { + return this; + } + const ItemBase *toMediaItem() const override { + return this; + } + HistoryItem *getItem() const override { + return _parent; + } + + void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override; + void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool active) override; + +protected: + HistoryItem *_parent; + +}; + +class RadialProgressItem : public ItemBase { +public: + RadialProgressItem(HistoryItem *parent) : ItemBase(parent) + , _radial(0) + , a_iconOver(0, 0) + , _a_iconOver(animation(this, &RadialProgressItem::step_iconOver)) { + } + RadialProgressItem(const RadialProgressItem &other) = delete; + + void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override; + void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool active) override; + + ~RadialProgressItem(); + +protected: + ClickHandlerPtr _openl, _savel, _cancell; + void setLinks(ClickHandlerPtr &&openl, ClickHandlerPtr &&savel, ClickHandlerPtr &&cancell); + void setDocumentLinks(DocumentData *document) { + ClickHandlerPtr save; + if (document->voice()) { + save.reset(new DocumentOpenClickHandler(document)); + } else { + save.reset(new DocumentSaveClickHandler(document)); + } + setLinks(MakeShared(document), std_::move(save), MakeShared(document)); + } + + void step_iconOver(float64 ms, bool timer); + void step_radial(uint64 ms, bool timer); + + void ensureRadial() const; + void checkRadialFinished(); + + bool isRadialAnimation(uint64 ms) const { + if (!_radial || !_radial->animating()) return false; + + _radial->step(ms); + return _radial && _radial->animating(); + } + + virtual float64 dataProgress() const = 0; + virtual bool dataFinished() const = 0; + virtual bool dataLoaded() const = 0; + virtual bool iconAnimated() const { + return false; + } + + mutable RadialAnimation *_radial; + anim::fvalue a_iconOver; + mutable Animation _a_iconOver; + +}; + +class FileBase : public RadialProgressItem { +public: + FileBase(HistoryItem *parent) : RadialProgressItem(parent) { + } + +protected: + // >= 0 will contain download / upload string, _statusSize = loaded bytes + // < 0 will contain played string, _statusSize = -(seconds + 1) played + // 0x7FFFFFF0 will contain status for not yet downloaded file + // 0x7FFFFFF1 will contain status for already downloaded file + // 0x7FFFFFF2 will contain status for failed to download / upload file + mutable int32 _statusSize; + mutable QString _statusText; + + // duration = -1 - no duration, duration = -2 - "GIF" duration + void setStatusSize(int32 newSize, int32 fullSize, int32 duration, qint64 realDuration) const; + +}; + +struct Info : public BaseComponent { + int top = 0; +}; + +class Date : public AbstractItem { +public: + Date(const QDate &date, bool month); + + void initDimensions() override; + void paint(Painter &p, const QRect &clip, uint32 selection, const PaintContext *context) const override; + +private: + QDate _date; + QString _text; + +}; + +class Photo : public ItemBase { +public: + Photo(PhotoData *photo, HistoryItem *parent); + + void initDimensions() override; + int32 resizeGetHeight(int32 width) override; + void paint(Painter &p, const QRect &clip, uint32 selection, const PaintContext *context) const override; + void getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int x, int y) const override; + +private: + PhotoData *_data; + ClickHandlerPtr _link; + + mutable QPixmap _pix; + mutable bool _goodLoaded; + +}; + +class Video : public FileBase { +public: + Video(DocumentData *video, HistoryItem *parent); + + void initDimensions() override; + int32 resizeGetHeight(int32 width) override; + void paint(Painter &p, const QRect &clip, uint32 selection, const PaintContext *context) const override; + void getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int x, int y) const override; + +protected: + float64 dataProgress() const override { + return _data->progress(); + } + bool dataFinished() const override { + return !_data->loading(); + } + bool dataLoaded() const override { + return _data->loaded(); + } + bool iconAnimated() const override { + return true; + } + +private: + DocumentData *_data; + + QString _duration; + mutable QPixmap _pix; + mutable bool _thumbLoaded; + + void updateStatusText() const; + +}; + +class Voice : public FileBase { +public: + Voice(DocumentData *voice, HistoryItem *parent); + + void initDimensions() override; + void paint(Painter &p, const QRect &clip, uint32 selection, const PaintContext *context) const override; + void getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int x, int y) const override; + +protected: + float64 dataProgress() const override { + return _data->progress(); + } + bool dataFinished() const override { + return !_data->loading(); + } + bool dataLoaded() const override { + return _data->loaded(); + } + bool iconAnimated() const override { + return true; + } + +private: + DocumentData *_data; + ClickHandlerPtr _namel; + + mutable Text _name, _details; + mutable int32 _nameVersion; + + void updateName() const; + bool updateStatusText() const; + +}; + +class Document : public FileBase { +public: + Document(DocumentData *document, HistoryItem *parent); + + void initDimensions() override; + void paint(Painter &p, const QRect &clip, uint32 selection, const PaintContext *context) const override; + void getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int x, int y) const override; + + virtual DocumentData *getDocument() const override { + return _data; + } + +protected: + float64 dataProgress() const override { + return _data->progress(); + } + bool dataFinished() const override { + return !_data->loading(); + } + bool dataLoaded() const override { + return _data->loaded(); + } + bool iconAnimated() const override { + return _data->song() || !_data->loaded() || (_radial && _radial->animating()); + } + +private: + DocumentData *_data; + ClickHandlerPtr _msgl, _namel; + + mutable bool _thumbForLoaded; + mutable QPixmap _thumb; + + QString _name, _date, _ext; + int32 _namew, _datew, _extw; + int32 _thumbw, _colorIndex; + + bool withThumb() const { + return !_data->thumb->isNull() && _data->thumb->width() && _data->thumb->height(); + } + bool updateStatusText() const; + +}; + +class Link : public ItemBase { +public: + Link(HistoryMedia *media, HistoryItem *parent); + + void initDimensions() override; + int32 resizeGetHeight(int32 width) override; + void paint(Painter &p, const QRect &clip, uint32 selection, const PaintContext *context) const override; + void getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int x, int y) const override; + +private: + ClickHandlerPtr _photol; + + QString _title, _letter; + int _titlew = 0; + WebPageData *_page = nullptr; + int _pixw = 0; + int _pixh = 0; + Text _text = { int(st::msgMinWidth) }; + + struct LinkEntry { + LinkEntry() : width(0) { + } + LinkEntry(const QString &url, const QString &text); + QString text; + int32 width; + TextClickHandlerPtr lnk; + }; + QVector _links; + +}; + +} // namespace Layout +} // namespace Overview diff --git a/Telegram/SourceFiles/overviewwidget.cpp b/Telegram/SourceFiles/overviewwidget.cpp index f9237984e0..6d4a595bea 100644 --- a/Telegram/SourceFiles/overviewwidget.cpp +++ b/Telegram/SourceFiles/overviewwidget.cpp @@ -21,7 +21,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "stdafx.h" #include "lang.h" -#include "window.h" +#include "mainwindow.h" #include "mainwidget.h" #include "overviewwidget.h" #include "boxes/addcontactbox.h" @@ -29,6 +29,9 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "boxes/photocropbox.h" #include "application.h" #include "ui/filedialog.h" +#include "playerwidget.h" +#include "window/top_bar_widget.h" +#include "overview/overview_layout.h" // flick scroll taken from http://qt-project.org/doc/qt-4.8/demos-embedded-anomaly-src-flickcharm-cpp.html @@ -333,7 +336,7 @@ void OverviewInner::moveToNextItem(MsgId &msgId, int32 &index, MsgId upTo, int32 } index += delta; - while (index >= 0 && index < _items.size() && !_items.at(index)->toLayoutMediaItem()) { + while (index >= 0 && index < _items.size() && !_items.at(index)->toMediaItem()) { index += (delta > 0) ? 1 : -1; } if (index < 0 || index >= _items.size()) { @@ -354,7 +357,7 @@ void OverviewInner::repaintItem(MsgId itemId, int32 itemIndex) { int32 row = (_photosToAdd + shownAtIndex) / _photosInRow, col = (_photosToAdd + shownAtIndex) % _photosInRow; update(int32(col * w), _marginTop + int32(row * vsize), qCeil(w), vsize); } else { - int32 top = _items.at(itemIndex)->Get()->top; + int32 top = _items.at(itemIndex)->Get()->top; if (_reversed) top = _height - top; update(_rowsLeft, _marginTop + top, _rowWidth, _items.at(itemIndex)->height()); } @@ -698,7 +701,7 @@ QPoint OverviewInner::mapMouseToItem(QPoint p, MsgId itemId, int32 itemIndex) { p.setX(p.x() - int32(col * w) - st::overviewPhotoSkip); p.setY(p.y() - _marginTop - row * (_rowWidth + st::overviewPhotoSkip) - st::overviewPhotoSkip); } else { - int32 top = _items.at(itemIndex)->Get()->top; + int32 top = _items.at(itemIndex)->Get()->top; if (_reversed) top = _height - top; p.setY(p.y() - _marginTop - top); } @@ -734,7 +737,7 @@ int32 OverviewInner::itemTop(const FullMsgId &msgId) const { int32 itemIndex = -1; fixItemIndex(itemIndex, (msgId.channel == _channel) ? msgId.msg : ((_migrated && msgId.channel == _migrated->channelId()) ? -msgId.msg : 0)); if (itemIndex >= 0) { - int32 top = _items.at(itemIndex)->Get()->top; + int32 top = _items.at(itemIndex)->Get()->top; if (_reversed) top = _height - top; return _marginTop + top; } @@ -785,7 +788,7 @@ uint32 OverviewInner::itemSelectedValue(int32 index) const { selfrom = _dragSelToIndex; selto = _dragSelFromIndex; } - if (_items.at(index)->toLayoutMediaItem()) { // draw item + if (_items.at(index)->toMediaItem()) { // draw item if (index >= _dragSelToIndex && index <= _dragSelFromIndex && _dragSelToIndex >= 0) { return (_dragSelecting && _items.at(index)->msgId() > 0) ? FullSelection : 0; } else if (!_selected.isEmpty()) { @@ -809,7 +812,7 @@ void OverviewInner::paintEvent(QPaintEvent *e) { p.setClipRect(r); } uint64 ms = getms(); - PaintContextOverview context(ms, _selMode); + Overview::Layout::PaintContext context(ms, _selMode); if (_history->overview[_type].isEmpty() && (!_migrated || !_history->overviewLoaded(_type) || _migrated->overview[_type].isEmpty())) { QPoint dogPos((_width - st::msgDogImg.pxWidth()) / 2, ((height() - st::msgDogImg.pxHeight()) * 4) / 9); @@ -854,15 +857,15 @@ void OverviewInner::paintEvent(QPaintEvent *e) { int32 y = 0, w = _rowWidth; for (int32 j = 0, l = _items.size(); j < l; ++j) { int32 i = _reversed ? (l - j - 1) : j, nexti = _reversed ? (i - 1) : (i + 1); - int32 nextItemTop = (j + 1 == l) ? (_reversed ? 0 : _height) : _items.at(nexti)->Get()->top; + int32 nextItemTop = (j + 1 == l) ? (_reversed ? 0 : _height) : _items.at(nexti)->Get()->top; if (_reversed) nextItemTop = _height - nextItemTop; if (_marginTop + nextItemTop > r.top()) { - OverviewItemInfo *info = _items.at(i)->Get(); + auto info = _items.at(i)->Get(); int32 curY = info->top; if (_reversed) curY = _height - curY; if (_marginTop + curY >= r.y() + r.height()) break; - context.isAfterDate = (j > 0) ? !_items.at(j - 1)->toLayoutMediaItem() : false; + context.isAfterDate = (j > 0) ? !_items.at(j - 1)->toMediaItem() : false; p.translate(0, curY - y); _items.at(i)->paint(p, r.translated(-_rowsLeft, -_marginTop - curY), itemSelectedValue(i), &context); y = curY; @@ -908,7 +911,7 @@ void OverviewInner::onUpdateSelected() { upon = false; } if (i >= 0) { - if (LayoutMediaItemBase *media = _items.at(i)->toLayoutMediaItem()) { + if (auto media = _items.at(i)->toMediaItem()) { item = media->getItem(); index = i; if (upon) { @@ -921,23 +924,23 @@ void OverviewInner::onUpdateSelected() { for (int32 j = 0, l = _items.size(); j < l; ++j) { bool lastItem = (j + 1 == l); int32 i = _reversed ? (l - j - 1) : j, nexti = _reversed ? (i - 1) : (i + 1); - int32 nextItemTop = lastItem ? (_reversed ? 0 : _height) : _items.at(nexti)->Get()->top; + int32 nextItemTop = lastItem ? (_reversed ? 0 : _height) : _items.at(nexti)->Get()->top; if (_reversed) nextItemTop = _height - nextItemTop; if (_marginTop + nextItemTop > m.y() || lastItem) { - int32 top = _items.at(i)->Get()->top; + int32 top = _items.at(i)->Get()->top; if (_reversed) top = _height - top; - if (!_items.at(i)->toLayoutMediaItem()) { // day item + if (!_items.at(i)->toMediaItem()) { // day item int32 h = _items.at(i)->height(); bool beforeItem = (_marginTop + top + h / 2) >= m.y(); if (_reversed) beforeItem = !beforeItem; if (i > 0 && (beforeItem || i == _items.size() - 1)) { --i; - if (!_items.at(i)->toLayoutMediaItem()) break; // wtf - top = _items.at(i)->Get()->top; + if (!_items.at(i)->toMediaItem()) break; // wtf + top = _items.at(i)->Get()->top; } else if (i < _items.size() - 1 && (!beforeItem || !i)) { ++i; - if (!_items.at(i)->toLayoutMediaItem()) break; // wtf - top = _items.at(i)->Get()->top; + if (!_items.at(i)->toMediaItem()) break; // wtf + top = _items.at(i)->Get()->top; } else { break; // wtf } @@ -945,7 +948,7 @@ void OverviewInner::onUpdateSelected() { j = _reversed ? (l - i - 1) : i; } - if (LayoutMediaItemBase *media = _items.at(i)->toLayoutMediaItem()) { + if (auto media = _items.at(i)->toMediaItem()) { item = media->getItem(); index = i; media->getState(lnk, cursorState, m.x() - _rowsLeft, m.y() - _marginTop - top); @@ -1325,7 +1328,7 @@ int32 OverviewInner::resizeToWidth(int32 nwidth, int32 scrollTop, int32 minHeigh for (int32 i = 0, l = _items.size(); i < l; ++i) { int32 h = _items.at(i)->resizeGetHeight(_rowWidth); if (resize) { - _items.at(i)->Get()->top = _height + (_reversed ? h : 0); + _items.at(i)->Get()->top = _height + (_reversed ? h : 0); _height += h; } } @@ -1632,7 +1635,7 @@ void OverviewInner::mediaOverviewUpdated() { allGood = false; } HistoryItem *item = App::histItemById(itemChannel(msgid), itemMsgId(msgid)); - LayoutMediaItemBase *layout = layoutPrepare(item); + auto layout = layoutPrepare(item); if (!layout) continue; setLayoutItem(index, layout, 0); @@ -1658,17 +1661,17 @@ void OverviewInner::mediaOverviewUpdated() { if (allGood) { if (_items.size() > index && complexMsgId(_items.at(index)->getItem()) == msgid) { if (withDates) prevDate = _items.at(index)->getItem()->date.date(); - top = _items.at(index)->Get()->top; + top = _items.at(index)->Get()->top; if (!_reversed) { top += _items.at(index)->height(); } ++index; continue; } - if (_items.size() > index + 1 && !_items.at(index)->toLayoutMediaItem() && complexMsgId(_items.at(index + 1)->getItem()) == msgid) { // day item + if (_items.size() > index + 1 && !_items.at(index)->toMediaItem() && complexMsgId(_items.at(index + 1)->getItem()) == msgid) { // day item ++index; if (withDates) prevDate = _items.at(index)->getItem()->date.date(); - top = _items.at(index)->Get()->top; + top = _items.at(index)->Get()->top; if (!_reversed) { top += _items.at(index)->height(); } @@ -1678,7 +1681,7 @@ void OverviewInner::mediaOverviewUpdated() { allGood = false; } HistoryItem *item = App::histItemById(itemChannel(msgid), itemMsgId(msgid)); - LayoutMediaItemBase *layout = layoutPrepare(item); + auto layout = layoutPrepare(item); if (!layout) continue; if (withDates) { @@ -1795,7 +1798,7 @@ void OverviewInner::repaintItem(const HistoryItem *msg) { if (history == _migrated) msgid = -msgid; for (int32 i = 0, l = _items.size(); i != l; ++i) { if (complexMsgId(_items.at(i)->getItem()) == msgid) { - int32 top = _items.at(i)->Get()->top; + int32 top = _items.at(i)->Get()->top; if (_reversed) top = _height - top; update(_rowsLeft, _marginTop + top, _rowWidth, _items.at(i)->height()); break; @@ -1840,7 +1843,7 @@ void OverviewInner::recountMargins() { } } -LayoutMediaItemBase *OverviewInner::layoutPrepare(HistoryItem *item) { +Overview::Layout::ItemBase *OverviewInner::layoutPrepare(HistoryItem *item) { if (!item) return nullptr; LayoutItems::const_iterator i = _layoutItems.cend(); @@ -1848,59 +1851,59 @@ LayoutMediaItemBase *OverviewInner::layoutPrepare(HistoryItem *item) { if (_type == OverviewPhotos) { if (media && media->type() == MediaTypePhoto) { if ((i = _layoutItems.constFind(item)) == _layoutItems.cend()) { - i = _layoutItems.insert(item, new LayoutOverviewPhoto(static_cast(media)->photo(), item)); + i = _layoutItems.insert(item, new Overview::Layout::Photo(static_cast(media)->photo(), item)); i.value()->initDimensions(); } } } else if (_type == OverviewVideos) { if (media && media->type() == MediaTypeVideo) { if ((i = _layoutItems.constFind(item)) == _layoutItems.cend()) { - i = _layoutItems.insert(item, new LayoutOverviewVideo(media->getDocument(), item)); + i = _layoutItems.insert(item, new Overview::Layout::Video(media->getDocument(), item)); i.value()->initDimensions(); } } } else if (_type == OverviewVoiceFiles) { if (media && (media->type() == MediaTypeVoiceFile)) { if ((i = _layoutItems.constFind(item)) == _layoutItems.cend()) { - i = _layoutItems.insert(item, new LayoutOverviewVoice(media->getDocument(), item)); + i = _layoutItems.insert(item, new Overview::Layout::Voice(media->getDocument(), item)); i.value()->initDimensions(); } } } else if (_type == OverviewFiles || _type == OverviewMusicFiles) { if (media && (media->type() == MediaTypeFile || media->type() == MediaTypeMusicFile || media->type() == MediaTypeGif)) { if ((i = _layoutItems.constFind(item)) == _layoutItems.cend()) { - i = _layoutItems.insert(item, new LayoutOverviewDocument(media->getDocument(), item)); + i = _layoutItems.insert(item, new Overview::Layout::Document(media->getDocument(), item)); i.value()->initDimensions(); } } } else if (_type == OverviewLinks) { if ((i = _layoutItems.constFind(item)) == _layoutItems.cend()) { - i = _layoutItems.insert(item, new LayoutOverviewLink(media, item)); + i = _layoutItems.insert(item, new Overview::Layout::Link(media, item)); i.value()->initDimensions(); } } return (i == _layoutItems.cend()) ? nullptr : i.value(); } -LayoutOverviewItemBase *OverviewInner::layoutPrepare(const QDate &date, bool month) { +Overview::Layout::AbstractItem *OverviewInner::layoutPrepare(const QDate &date, bool month) { int32 key = date.year() * 100 + date.month(); if (!month) key = key * 100 + date.day(); LayoutDates::const_iterator i = _layoutDates.constFind(key); if (i == _layoutDates.cend()) { - i = _layoutDates.insert(key, new LayoutOverviewDate(date, month)); + i = _layoutDates.insert(key, new Overview::Layout::Date(date, month)); i.value()->initDimensions(); } return i.value(); } -int32 OverviewInner::setLayoutItem(int32 index, LayoutOverviewItemBase *item, int32 top) { +int32 OverviewInner::setLayoutItem(int32 index, Overview::Layout::AbstractItem *item, int32 top) { if (_items.size() > index) { _items[index] = item; } else { _items.push_back(item); } int32 h = item->resizeGetHeight(_rowWidth); - if (OverviewItemInfo *info = item->Get()) { + if (auto info = item->Get()) { info->top = top + (_reversed ? h : 0); } return h; diff --git a/Telegram/SourceFiles/overviewwidget.h b/Telegram/SourceFiles/overviewwidget.h index 0d82fecac3..e0c039726b 100644 --- a/Telegram/SourceFiles/overviewwidget.h +++ b/Telegram/SourceFiles/overviewwidget.h @@ -20,6 +20,16 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #pragma once +namespace Overview { +namespace Layout { + +class AbstractItem; +class ItemBase; +class Date; + +} // namespace Layout +} // namespace Overview + class OverviewWidget; class OverviewInner : public QWidget, public AbstractTooltipShower, public RPCSender { Q_OBJECT @@ -152,15 +162,15 @@ private: int32 _rowsLeft, _rowWidth; - typedef QVector Items; + typedef QVector Items; Items _items; - typedef QMap LayoutItems; + typedef QMap LayoutItems; LayoutItems _layoutItems; - typedef QMap LayoutDates; + typedef QMap LayoutDates; LayoutDates _layoutDates; - LayoutMediaItemBase *layoutPrepare(HistoryItem *item); - LayoutOverviewItemBase *layoutPrepare(const QDate &date, bool month); - int32 setLayoutItem(int32 index, LayoutOverviewItemBase *item, int32 top); + Overview::Layout::ItemBase *layoutPrepare(HistoryItem *item); + Overview::Layout::AbstractItem *layoutPrepare(const QDate &date, bool month); + int32 setLayoutItem(int32 index, Overview::Layout::AbstractItem *item, int32 top); FlatInput _search; IconedButton _cancelSearch; diff --git a/Telegram/SourceFiles/passcodewidget.cpp b/Telegram/SourceFiles/passcodewidget.cpp index 0d75d56129..95aa4871d1 100644 --- a/Telegram/SourceFiles/passcodewidget.cpp +++ b/Telegram/SourceFiles/passcodewidget.cpp @@ -25,7 +25,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "localstorage.h" #include "passcodewidget.h" -#include "window.h" +#include "mainwindow.h" #include "application.h" #include "ui/text.h" diff --git a/Telegram/SourceFiles/playerwidget.cpp b/Telegram/SourceFiles/playerwidget.cpp index 7644265dbe..454763a2e6 100644 --- a/Telegram/SourceFiles/playerwidget.cpp +++ b/Telegram/SourceFiles/playerwidget.cpp @@ -24,7 +24,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "boxes/addcontactbox.h" #include "application.h" -#include "window.h" +#include "mainwindow.h" #include "playerwidget.h" #include "mainwidget.h" diff --git a/Telegram/SourceFiles/profilewidget.cpp b/Telegram/SourceFiles/profilewidget.cpp index 25831b8455..ff4d809409 100644 --- a/Telegram/SourceFiles/profilewidget.cpp +++ b/Telegram/SourceFiles/profilewidget.cpp @@ -21,7 +21,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "stdafx.h" #include "lang.h" -#include "window.h" +#include "mainwindow.h" #include "mainwidget.h" #include "profilewidget.h" #include "boxes/addcontactbox.h" @@ -30,6 +30,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "application.h" #include "boxes/contactsbox.h" #include "ui/filedialog.h" +#include "apiwrap.h" +#include "window/top_bar_widget.h" ProfileInner::ProfileInner(ProfileWidget *profile, ScrollArea *scroll, PeerData *peer) : TWidget(0) , _profile(profile) diff --git a/Telegram/SourceFiles/pspecific_linux.cpp b/Telegram/SourceFiles/pspecific_linux.cpp index e3af2b9dea..368563a9f2 100644 --- a/Telegram/SourceFiles/pspecific_linux.cpp +++ b/Telegram/SourceFiles/pspecific_linux.cpp @@ -488,7 +488,7 @@ namespace { } bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) { - Window *wnd = App::wnd(); + auto wnd = App::wnd(); if (!wnd) return false; return false; diff --git a/Telegram/SourceFiles/pspecific_mac.cpp b/Telegram/SourceFiles/pspecific_mac.cpp index 531c59561e..9eb8f9f8e9 100644 --- a/Telegram/SourceFiles/pspecific_mac.cpp +++ b/Telegram/SourceFiles/pspecific_mac.cpp @@ -40,7 +40,7 @@ namespace { } bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) { - Window *wnd = AppClass::wnd(); + auto wnd = AppClass::wnd(); if (!wnd) return false; return wnd->psFilterNativeEvent(message); diff --git a/Telegram/SourceFiles/pspecific_mac_p.mm b/Telegram/SourceFiles/pspecific_mac_p.mm index 9bacdd112b..4e3c1998f7 100644 --- a/Telegram/SourceFiles/pspecific_mac_p.mm +++ b/Telegram/SourceFiles/pspecific_mac_p.mm @@ -18,7 +18,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "stdafx.h" #include "pspecific_mac_p.h" -#include "window.h" +#include "mainwindow.h" #include "mainwidget.h" #include "application.h" diff --git a/Telegram/SourceFiles/pspecific_win.cpp b/Telegram/SourceFiles/pspecific_win.cpp index 26665b0d5b..6b97fab507 100644 --- a/Telegram/SourceFiles/pspecific_win.cpp +++ b/Telegram/SourceFiles/pspecific_win.cpp @@ -802,7 +802,7 @@ namespace { } bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) { - Window *wnd = App::wnd(); + auto wnd = App::wnd(); if (!wnd) return false; MSG *msg = (MSG*)message; diff --git a/Telegram/SourceFiles/pspecific_winrt.cpp b/Telegram/SourceFiles/pspecific_winrt.cpp index ee96c9ae55..816e62d223 100644 --- a/Telegram/SourceFiles/pspecific_winrt.cpp +++ b/Telegram/SourceFiles/pspecific_winrt.cpp @@ -802,7 +802,7 @@ namespace { } bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) { - Window *wnd = App::wnd(); + auto wnd = App::wnd(); if (!wnd) return false; MSG *msg = (MSG*)message; diff --git a/Telegram/SourceFiles/settingswidget.cpp b/Telegram/SourceFiles/settingswidget.cpp index cba8bc9ed7..28c6a91f25 100644 --- a/Telegram/SourceFiles/settingswidget.cpp +++ b/Telegram/SourceFiles/settingswidget.cpp @@ -41,9 +41,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "boxes/stickersetbox.h" #include "langloaderplain.h" #include "ui/filedialog.h" - +#include "apiwrap.h" #include "autoupdater.h" - #include "localstorage.h" Slider::Slider(QWidget *parent, const style::slider &st, int32 count, int32 sel) : QWidget(parent), @@ -291,9 +290,9 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : TWidget(parent) connect(&_downloadPathEdit, SIGNAL(clicked()), this, SLOT(onDownloadPathEdit())); connect(&_downloadPathClear, SIGNAL(clicked()), this, SLOT(onDownloadPathClear())); switch (App::wnd()->tempDirState()) { - case Window::TempDirEmpty: _tempDirClearState = TempDirEmpty; break; - case Window::TempDirExists: _tempDirClearState = TempDirExists; break; - case Window::TempDirRemoving: _tempDirClearState = TempDirClearing; break; + case MainWindow::TempDirEmpty: _tempDirClearState = TempDirEmpty; break; + case MainWindow::TempDirExists: _tempDirClearState = TempDirExists; break; + case MainWindow::TempDirRemoving: _tempDirClearState = TempDirClearing; break; } connect(App::wnd(), SIGNAL(tempDirCleared(int)), this, SLOT(onTempDirCleared(int))); connect(App::wnd(), SIGNAL(tempDirClearFailed(int)), this, SLOT(onTempDirClearFailed(int))); @@ -302,9 +301,9 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : TWidget(parent) // local storage connect(&_localStorageClear, SIGNAL(clicked()), this, SLOT(onLocalStorageClear())); switch (App::wnd()->localStorageState()) { - case Window::TempDirEmpty: _storageClearState = TempDirEmpty; break; - case Window::TempDirExists: _storageClearState = TempDirExists; break; - case Window::TempDirRemoving: _storageClearState = TempDirClearing; break; + case MainWindow::TempDirEmpty: _storageClearState = TempDirEmpty; break; + case MainWindow::TempDirExists: _storageClearState = TempDirExists; break; + case MainWindow::TempDirRemoving: _storageClearState = TempDirClearing; break; } // chat background @@ -1836,7 +1835,7 @@ void SettingsInner::onPhotoUpdateDone(PeerId peer) { update(); } -SettingsWidget::SettingsWidget(Window *parent) : TWidget(parent) +SettingsWidget::SettingsWidget(MainWindow *parent) : TWidget(parent) , _a_show(animation(this, &SettingsWidget::step_show)) , _scroll(this, st::setScroll) , _inner(this) diff --git a/Telegram/SourceFiles/settingswidget.h b/Telegram/SourceFiles/settingswidget.h index d9ee03988e..4162c98446 100644 --- a/Telegram/SourceFiles/settingswidget.h +++ b/Telegram/SourceFiles/settingswidget.h @@ -26,7 +26,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include -class Window; +class MainWindow; class Settings; class Slider : public QWidget { @@ -313,7 +313,7 @@ class SettingsWidget : public TWidget { public: - SettingsWidget(Window *parent); + SettingsWidget(MainWindow *parent); void paintEvent(QPaintEvent *e); void resizeEvent(QResizeEvent *e); diff --git a/Telegram/SourceFiles/shortcuts.cpp b/Telegram/SourceFiles/shortcuts.cpp index bf5dde9cd2..2e5599ac55 100644 --- a/Telegram/SourceFiles/shortcuts.cpp +++ b/Telegram/SourceFiles/shortcuts.cpp @@ -19,18 +19,18 @@ Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #include "stdafx.h" - #include "shortcuts.h" -#include "window.h" +#include "mainwindow.h" #include "passcodewidget.h" #include "mainwidget.h" +#include "playerwidget.h" namespace ShortcutCommands { typedef void(*Handler)(); void lock_telegram() { - if (Window *w = App::wnd()) { + if (auto w = App::wnd()) { if (App::passcoded()) { w->passcodeWidget()->onSubmit(); } else if (cHasPasscode()) { @@ -40,7 +40,7 @@ namespace ShortcutCommands { } void minimize_telegram() { - if (Window *w = App::wnd()) { + if (auto w = App::wnd()) { if (cWorkMode() == dbiwmTrayOnly) { w->minimizeToTray(); } else { @@ -51,8 +51,8 @@ namespace ShortcutCommands { void close_telegram() { if (!Ui::hideWindowNoQuit()) { - if (Window *w = App::wnd()) { - App::wnd()->close(); + if (auto w = App::wnd()) { + w->close(); } } } diff --git a/Telegram/SourceFiles/stdafx.h b/Telegram/SourceFiles/stdafx.h index 8a521c56a4..db0521fb82 100644 --- a/Telegram/SourceFiles/stdafx.h +++ b/Telegram/SourceFiles/stdafx.h @@ -31,7 +31,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include #include -#include "basic_types.h" +#include "core/basic_types.h" #include "config.h" #include "mtproto/facade.h" diff --git a/Telegram/SourceFiles/structs.cpp b/Telegram/SourceFiles/structs.cpp index cc31492efb..dacd819d7c 100644 --- a/Telegram/SourceFiles/structs.cpp +++ b/Telegram/SourceFiles/structs.cpp @@ -28,11 +28,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "mainwidget.h" #include "application.h" #include "fileuploader.h" -#include "window.h" +#include "mainwindow.h" #include "ui/filedialog.h" - +#include "apiwrap.h" #include "boxes/confirmbox.h" - #include "audio.h" #include "localstorage.h" diff --git a/Telegram/SourceFiles/structs.h b/Telegram/SourceFiles/structs.h index aff75db405..fe2255bb0d 100644 --- a/Telegram/SourceFiles/structs.h +++ b/Telegram/SourceFiles/structs.h @@ -1312,3 +1312,63 @@ struct MessageCursor { inline bool operator==(const MessageCursor &a, const MessageCursor &b) { return (a.position == b.position) && (a.anchor == b.anchor) && (a.scroll == b.scroll); } + +struct LocationCoords { + LocationCoords() : lat(0), lon(0) { + } + LocationCoords(float64 lat, float64 lon) : lat(lat), lon(lon) { + } + LocationCoords(const MTPDgeoPoint &point) : lat(point.vlat.v), lon(point.vlong.v) { + } + float64 lat, lon; +}; +inline bool operator==(const LocationCoords &a, const LocationCoords &b) { + return (a.lat == b.lat) && (a.lon == b.lon); +} +inline bool operator<(const LocationCoords &a, const LocationCoords &b) { + return (a.lat < b.lat) || ((a.lat == b.lat) && (a.lon < b.lon)); +} +inline uint qHash(const LocationCoords &t, uint seed = 0) { + return qHash(QtPrivate::QHashCombine().operator()(qHash(t.lat), t.lon), seed); +} + +struct LocationData { + LocationData(const LocationCoords &coords) : coords(coords), loading(false) { + } + + LocationCoords coords; + ImagePtr thumb; + bool loading; + + void load(); +}; + +class LocationClickHandler : public ClickHandler { +public: + LocationClickHandler(const LocationCoords &coords) : _coords(coords) { + setup(); + } + QString copyToClipboardContextItem() const override; + + void copyToClipboard() const override { + if (!_text.isEmpty()) { + QApplication::clipboard()->setText(_text); + } + } + + QString tooltip() const override { + return QString(); + } + + QString text() const override { + return _text; + } + void onClick(Qt::MouseButton button) const override; + +private: + + void setup(); + LocationCoords _coords; + QString _text; + +}; diff --git a/Telegram/SourceFiles/sysbuttons.cpp b/Telegram/SourceFiles/sysbuttons.cpp index bdc31b9c63..fe2546b4e4 100644 --- a/Telegram/SourceFiles/sysbuttons.cpp +++ b/Telegram/SourceFiles/sysbuttons.cpp @@ -111,7 +111,7 @@ void SysBtn::step_color(float64 ms, bool timer) { if (timer) update(); } -MinimizeBtn::MinimizeBtn(QWidget *parent, Window *window) : SysBtn(parent, st::sysMin), wnd(window) { +MinimizeBtn::MinimizeBtn(QWidget *parent, MainWindow *window) : SysBtn(parent, st::sysMin), wnd(window) { connect(this, SIGNAL(clicked()), this, SLOT(onClick())); } @@ -119,7 +119,7 @@ void MinimizeBtn::onClick() { wnd->setWindowState(Qt::WindowMinimized); } -MaximizeBtn::MaximizeBtn(QWidget *parent, Window *window) : SysBtn(parent, st::sysMax), wnd(window) { +MaximizeBtn::MaximizeBtn(QWidget *parent, MainWindow *window) : SysBtn(parent, st::sysMax), wnd(window) { connect(this, SIGNAL(clicked()), this, SLOT(onClick())); } @@ -127,7 +127,7 @@ void MaximizeBtn::onClick() { wnd->setWindowState(Qt::WindowMaximized); } -RestoreBtn::RestoreBtn(QWidget *parent, Window *window) : SysBtn(parent, st::sysRes), wnd(window) { +RestoreBtn::RestoreBtn(QWidget *parent, MainWindow *window) : SysBtn(parent, st::sysRes), wnd(window) { connect(this, SIGNAL(clicked()), this, SLOT(onClick())); } @@ -135,7 +135,7 @@ void RestoreBtn::onClick() { wnd->setWindowState(Qt::WindowNoState); } -CloseBtn::CloseBtn(QWidget *parent, Window *window) : SysBtn(parent, st::sysCls), wnd(window) { +CloseBtn::CloseBtn(QWidget *parent, MainWindow *window) : SysBtn(parent, st::sysCls), wnd(window) { connect(this, SIGNAL(clicked()), this, SLOT(onClick())); } @@ -143,7 +143,7 @@ void CloseBtn::onClick() { wnd->close(); } -UpdateBtn::UpdateBtn(QWidget *parent, Window *window, const QString &text) : SysBtn(parent, st::sysUpd, text), wnd(window) { +UpdateBtn::UpdateBtn(QWidget *parent, MainWindow *window, const QString &text) : SysBtn(parent, st::sysUpd, text), wnd(window) { connect(this, SIGNAL(clicked()), this, SLOT(onClick())); } @@ -161,7 +161,7 @@ void UpdateBtn::onClick() { App::quit(); } -LockBtn::LockBtn(QWidget *parent, Window *window) : SysBtn(parent, st::sysLock), wnd(window) { +LockBtn::LockBtn(QWidget *parent, MainWindow *window) : SysBtn(parent, st::sysLock), wnd(window) { connect(this, SIGNAL(clicked()), this, SLOT(onClick())); } diff --git a/Telegram/SourceFiles/sysbuttons.h b/Telegram/SourceFiles/sysbuttons.h index e9c12272d3..88ff7b0a1e 100644 --- a/Telegram/SourceFiles/sysbuttons.h +++ b/Telegram/SourceFiles/sysbuttons.h @@ -23,7 +23,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "ui/animation.h" #include "ui/button.h" -class Window; +class MainWindow; class SysBtn : public Button { Q_OBJECT @@ -62,7 +62,7 @@ class MinimizeBtn : public SysBtn { public: - MinimizeBtn(QWidget *parent, Window *window); + MinimizeBtn(QWidget *parent, MainWindow *window); public slots: @@ -70,7 +70,7 @@ public slots: private: - Window *wnd; + MainWindow *wnd; }; class MaximizeBtn : public SysBtn { @@ -78,7 +78,7 @@ class MaximizeBtn : public SysBtn { public: - MaximizeBtn(QWidget *parent, Window *window); + MaximizeBtn(QWidget *parent, MainWindow *window); public slots: @@ -86,7 +86,7 @@ public slots: private: - Window *wnd; + MainWindow *wnd; }; class RestoreBtn : public SysBtn { @@ -94,7 +94,7 @@ class RestoreBtn : public SysBtn { public: - RestoreBtn(QWidget *parent, Window *window); + RestoreBtn(QWidget *parent, MainWindow *window); public slots: @@ -102,7 +102,7 @@ public slots: private: - Window *wnd; + MainWindow *wnd; }; class CloseBtn : public SysBtn { @@ -110,7 +110,7 @@ class CloseBtn : public SysBtn { public: - CloseBtn(QWidget *parent, Window *window); + CloseBtn(QWidget *parent, MainWindow *window); public slots: @@ -118,7 +118,7 @@ public slots: private: - Window *wnd; + MainWindow *wnd; }; class UpdateBtn : public SysBtn { @@ -126,7 +126,7 @@ class UpdateBtn : public SysBtn { public: - UpdateBtn(QWidget *parent, Window *window, const QString &text = QString()); + UpdateBtn(QWidget *parent, MainWindow *window, const QString &text = QString()); public slots: @@ -134,7 +134,7 @@ public slots: private: - Window *wnd; + MainWindow *wnd; }; class LockBtn : public SysBtn { @@ -142,7 +142,7 @@ class LockBtn : public SysBtn { public: - LockBtn(QWidget *parent, Window *window); + LockBtn(QWidget *parent, MainWindow *window); public slots: @@ -150,5 +150,5 @@ public slots: private: - Window *wnd; + MainWindow *wnd; }; diff --git a/Telegram/SourceFiles/title.cpp b/Telegram/SourceFiles/title.cpp index 117aa49a22..6c599915d5 100644 --- a/Telegram/SourceFiles/title.cpp +++ b/Telegram/SourceFiles/title.cpp @@ -24,7 +24,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "title.h" #include "mainwidget.h" -#include "window.h" +#include "mainwindow.h" #include "application.h" #include "boxes/contactsbox.h" #include "boxes/aboutbox.h" @@ -49,7 +49,7 @@ void TitleHider::setLevel(float64 level) { update(); } -TitleWidget::TitleWidget(Window *window) : TWidget(window) +TitleWidget::TitleWidget(MainWindow *window) : TWidget(window) , wnd(window) , hideLevel(0) , hider(0) diff --git a/Telegram/SourceFiles/title.h b/Telegram/SourceFiles/title.h index 018695890a..a0cf522269 100644 --- a/Telegram/SourceFiles/title.h +++ b/Telegram/SourceFiles/title.h @@ -23,7 +23,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include #include "sysbuttons.h" -class Window; +class MainWindow; class TitleHider : public QWidget { public: @@ -44,7 +44,7 @@ class TitleWidget : public TWidget { public: - TitleWidget(Window *parent); + TitleWidget(MainWindow *parent); void paintEvent(QPaintEvent *e); void resizeEvent(QResizeEvent *e); @@ -78,7 +78,7 @@ signals: private: - Window *wnd; + MainWindow *wnd; style::color statusColor; diff --git a/Telegram/SourceFiles/ui/animation.cpp b/Telegram/SourceFiles/ui/animation.cpp index 047a3346b3..a9ce8f9109 100644 --- a/Telegram/SourceFiles/ui/animation.cpp +++ b/Telegram/SourceFiles/ui/animation.cpp @@ -30,7 +30,7 @@ extern "C" { } #include "mainwidget.h" -#include "window.h" +#include "mainwindow.h" namespace { AnimationManager *_manager = 0; diff --git a/Telegram/SourceFiles/ui/animation.h b/Telegram/SourceFiles/ui/animation.h index 9621f793c1..68ccb92360 100644 --- a/Telegram/SourceFiles/ui/animation.h +++ b/Telegram/SourceFiles/ui/animation.h @@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #pragma once -#include "basic_types.h" +#include "core/basic_types.h" #include #include diff --git a/Telegram/SourceFiles/ui/buttons/peer_avatar_button.cpp b/Telegram/SourceFiles/ui/buttons/peer_avatar_button.cpp index 7dbadc50c1..23acb46093 100644 --- a/Telegram/SourceFiles/ui/buttons/peer_avatar_button.cpp +++ b/Telegram/SourceFiles/ui/buttons/peer_avatar_button.cpp @@ -21,6 +21,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "stdafx.h" #include "ui/buttons/peer_avatar_button.h" +#include "structs.h" + +namespace Ui { + PeerAvatarButton::PeerAvatarButton(QWidget *parent, PeerData *peer, const style::PeerAvatarButton &st) : Button(parent) , _peer(peer) , _st(st) { @@ -33,3 +37,5 @@ void PeerAvatarButton::paintEvent(QPaintEvent *e) { _peer->paintUserpic(p, _st.photoSize, (_st.size - _st.photoSize) / 2, (_st.size - _st.photoSize) / 2); } } + +} // namespace Ui diff --git a/Telegram/SourceFiles/ui/buttons/peer_avatar_button.h b/Telegram/SourceFiles/ui/buttons/peer_avatar_button.h index d0861fef9e..88e0b8464a 100644 --- a/Telegram/SourceFiles/ui/buttons/peer_avatar_button.h +++ b/Telegram/SourceFiles/ui/buttons/peer_avatar_button.h @@ -22,7 +22,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "ui/button.h" #include "ui/style.h" -#include "structs.h" + +class PeerData; + +namespace Ui { class PeerAvatarButton : public Button { public: @@ -38,3 +41,5 @@ private: const style::PeerAvatarButton &_st; }; + +} // namespace Ui diff --git a/Telegram/SourceFiles/ui/flatinput.cpp b/Telegram/SourceFiles/ui/flatinput.cpp index 5742394074..e175f043e6 100644 --- a/Telegram/SourceFiles/ui/flatinput.cpp +++ b/Telegram/SourceFiles/ui/flatinput.cpp @@ -22,7 +22,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "ui/style.h" #include "flatinput.h" -#include "window.h" +#include "mainwindow.h" #include "countryinput.h" #include "lang.h" diff --git a/Telegram/SourceFiles/ui/flattextarea.cpp b/Telegram/SourceFiles/ui/flattextarea.cpp index d547531327..9ef9551ff8 100644 --- a/Telegram/SourceFiles/ui/flattextarea.cpp +++ b/Telegram/SourceFiles/ui/flattextarea.cpp @@ -22,7 +22,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "flattextarea.h" #include "ui/style.h" -#include "window.h" +#include "mainwindow.h" FlatTextarea::FlatTextarea(QWidget *parent, const style::flatTextarea &st, const QString &pholder, const QString &v) : QTextEdit(parent) , _oldtext(v) diff --git a/Telegram/SourceFiles/ui/text.cpp b/Telegram/SourceFiles/ui/text.cpp index cea666df0f..190da42ceb 100644 --- a/Telegram/SourceFiles/ui/text.cpp +++ b/Telegram/SourceFiles/ui/text.cpp @@ -21,13 +21,13 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "stdafx.h" #include "text.h" -#include "lang.h" +#include +#include "core/click_handler_types.h" +#include "lang.h" #include "pspecific.h" #include "boxes/confirmbox.h" -#include "window.h" - -#include +#include "mainwindow.h" namespace { @@ -57,47 +57,6 @@ namespace { } } -ClickHandlerHost::~ClickHandlerHost() { - ClickHandler::hostDestroyed(this); -} - -NeverFreedPointer ClickHandler::_active; -NeverFreedPointer ClickHandler::_pressed; -ClickHandlerHost *ClickHandler::_activeHost = nullptr; -ClickHandlerHost *ClickHandler::_pressedHost = nullptr; - -bool ClickHandler::setActive(const ClickHandlerPtr &p, ClickHandlerHost *host) { - if ((_active && (*_active == p)) || (!_active && !p)) { - return false; - } - - // emit clickHandlerActiveChanged only when there is no - // other pressed click handler currently, if there is - // this method will be called when it is unpressed - if (_active && *_active) { - bool emitClickHandlerActiveChanged = (!_pressed || !*_pressed || *_pressed == *_active); - ClickHandlerPtr wasactive = *_active; - (*_active).clear(); - if (_activeHost) { - if (emitClickHandlerActiveChanged) { - _activeHost->clickHandlerActiveChanged(wasactive, false); - } - _activeHost = nullptr; - } - } - if (p) { - _active.makeIfNull(); - *_active = p; - if ((_activeHost = host)) { - bool emitClickHandlerActiveChanged = (!_pressed || !*_pressed || *_pressed == *_active); - if (emitClickHandlerActiveChanged) { - _activeHost->clickHandlerActiveChanged(*_active, true); - } - } - } - return true; -} - const QRegularExpression &reDomain() { return _reDomain; } @@ -954,113 +913,6 @@ namespace { } } -QString UrlClickHandler::copyToClipboardContextItem() const { - return lang(isEmail() ? lng_context_copy_email : lng_context_copy_link); -} - -namespace { - -QString tryConvertUrlToLocal(const QString &url) { - QRegularExpressionMatch telegramMeUser = QRegularExpression(qsl("^https?://telegram\\.me/([a-zA-Z0-9\\.\\_]+)(/?\\?|/?$|/(\\d+)/?(?:\\?|$))"), QRegularExpression::CaseInsensitiveOption).match(url); - QRegularExpressionMatch telegramMeGroup = QRegularExpression(qsl("^https?://telegram\\.me/joinchat/([a-zA-Z0-9\\.\\_\\-]+)(\\?|$)"), QRegularExpression::CaseInsensitiveOption).match(url); - QRegularExpressionMatch telegramMeStickers = QRegularExpression(qsl("^https?://telegram\\.me/addstickers/([a-zA-Z0-9\\.\\_]+)(\\?|$)"), QRegularExpression::CaseInsensitiveOption).match(url); - QRegularExpressionMatch telegramMeShareUrl = QRegularExpression(qsl("^https?://telegram\\.me/share/url\\?(.+)$"), QRegularExpression::CaseInsensitiveOption).match(url); - if (telegramMeGroup.hasMatch()) { - return qsl("tg://join?invite=") + myUrlEncode(telegramMeGroup.captured(1)); - } else if (telegramMeStickers.hasMatch()) { - return qsl("tg://addstickers?set=") + myUrlEncode(telegramMeStickers.captured(1)); - } else if (telegramMeShareUrl.hasMatch()) { - return qsl("tg://msg_url?") + telegramMeShareUrl.captured(1); - } else if (telegramMeUser.hasMatch()) { - QString params = url.mid(telegramMeUser.captured(0).size()), postParam; - if (QRegularExpression(qsl("^/\\d+/?(?:\\?|$)")).match(telegramMeUser.captured(2)).hasMatch()) { - postParam = qsl("&post=") + telegramMeUser.captured(3); - } - return qsl("tg://resolve/?domain=") + myUrlEncode(telegramMeUser.captured(1)) + postParam + (params.isEmpty() ? QString() : '&' + params); - } - return url; -} - -} // namespace - -void UrlClickHandler::doOpen(QString url) { - PopupTooltip::Hide(); - - if (isEmail(url)) { - QUrl u(qstr("mailto:") + url); - if (!QDesktopServices::openUrl(u)) { - psOpenFile(u.toString(QUrl::FullyEncoded), true); - } - return; - } - - url = tryConvertUrlToLocal(url); - - if (url.startsWith(qstr("tg://"), Qt::CaseInsensitive)) { - App::openLocalUrl(url); - } else { - QDesktopServices::openUrl(url); - } -} - -void HiddenUrlClickHandler::onClick(Qt::MouseButton button) const { - QString u = url(); - - u = tryConvertUrlToLocal(u); - - if (u.startsWith(qstr("tg://"))) { - App::openLocalUrl(u); - } else { - Ui::showLayer(new ConfirmLinkBox(u)); - } -} - -QString LocationClickHandler::copyToClipboardContextItem() const { - return lang(lng_context_copy_link); -} - -void LocationClickHandler::onClick(Qt::MouseButton button) const { - if (!psLaunchMaps(_coords)) { - QDesktopServices::openUrl(_text); - } -} - -void LocationClickHandler::setup() { - QString latlon(qsl("%1,%2").arg(_coords.lat).arg(_coords.lon)); - _text = qsl("https://maps.google.com/maps?q=") + latlon + qsl("&ll=") + latlon + qsl("&z=16"); -} - -QString MentionClickHandler::copyToClipboardContextItem() const { - return lang(lng_context_copy_mention); -} - -void MentionClickHandler::onClick(Qt::MouseButton button) const { - if (button == Qt::LeftButton || button == Qt::MiddleButton) { - App::openPeerByName(_tag.mid(1), ShowAtProfileMsgId); - } -} - -QString HashtagClickHandler::copyToClipboardContextItem() const { - return lang(lng_context_copy_hashtag); -} - -void HashtagClickHandler::onClick(Qt::MouseButton button) const { - if (button == Qt::LeftButton || button == Qt::MiddleButton) { - App::searchByHashtag(_tag, Ui::getPeerForMouseAction()); - } -} - -void BotCommandClickHandler::onClick(Qt::MouseButton button) const { - if (button == Qt::LeftButton || button == Qt::MiddleButton) { - if (PeerData *peer = Ui::getPeerForMouseAction()) { - Ui::showPeerHistory(peer, ShowAtTheEndMsgId); - App::sendBotCommand(peer, _cmd); - } else { - App::insertBotCommand(_cmd); - } - } -} - class TextPainter { public: diff --git a/Telegram/SourceFiles/ui/text.h b/Telegram/SourceFiles/ui/text.h index 74c7aa3f1e..c890745f58 100644 --- a/Telegram/SourceFiles/ui/text.h +++ b/Telegram/SourceFiles/ui/text.h @@ -20,6 +20,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #pragma once +#include "core/click_handler.h" + enum EntityInTextType { EntityInTextUrl, EntityInTextCustomUrl, @@ -34,10 +36,10 @@ enum EntityInTextType { EntityInTextPre, // block }; struct EntityInText { - EntityInText(EntityInTextType type, int32 offset, int32 length, const QString &text = QString()) : type(type), offset(offset), length(length), text(text) { + EntityInText(EntityInTextType type, int offset, int length, const QString &text = QString()) : type(type), offset(offset), length(length), text(text) { } EntityInTextType type; - int32 offset, length; + int offset, length; QString text; }; typedef QList EntitiesInText; @@ -309,344 +311,6 @@ private: friend class TextPainter; }; -class ClickHandler; -using ClickHandlerPtr = QSharedPointer; - -class ClickHandlerHost { -protected: - - virtual void clickHandlerActiveChanged(const ClickHandlerPtr &action, bool active) { - } - virtual void clickHandlerPressedChanged(const ClickHandlerPtr &action, bool pressed) { - } - virtual ~ClickHandlerHost() = 0; - friend class ClickHandler; - -}; - -class ClickHandler { -public: - - virtual void onClick(Qt::MouseButton) const = 0; - - virtual QString tooltip() const { - return QString(); - } - virtual void copyToClipboard() const { - } - virtual QString copyToClipboardContextItem() const { - return QString(); - } - virtual QString text() const { - return QString(); - } - virtual QString dragText() const { - return text(); - } - - virtual ~ClickHandler() { - } - - // this method should be called on mouse over a click handler - // it returns true if something was changed or false otherwise - static bool setActive(const ClickHandlerPtr &p, ClickHandlerHost *host = nullptr); - - // this method should be called when mouse leaves the host - // it returns true if something was changed or false otherwise - static bool clearActive(ClickHandlerHost *host = nullptr) { - if (host && _activeHost != host) { - return false; - } - return setActive(ClickHandlerPtr(), host); - } - - // this method should be called on mouse pressed - static void pressed() { - unpressed(); - if (!_active || !*_active) { - return; - } - _pressed.makeIfNull(); - *_pressed = *_active; - if ((_pressedHost = _activeHost)) { - _pressedHost->clickHandlerPressedChanged(*_pressed, true); - } - } - - // this method should be called on mouse released - // the activated click handler is returned - static ClickHandlerPtr unpressed() { - if (_pressed && *_pressed) { - bool activated = (_active && *_active == *_pressed); - ClickHandlerPtr waspressed = *_pressed; - (*_pressed).clear(); - if (_pressedHost) { - _pressedHost->clickHandlerPressedChanged(waspressed, false); - _pressedHost = nullptr; - } - - if (activated) { - return *_active; - } else if (_active && *_active && _activeHost) { - // emit clickHandlerActiveChanged for current active - // click handler, which we didn't emit while we has - // a pressed click handler - _activeHost->clickHandlerActiveChanged(*_active, true); - } - } - return ClickHandlerPtr(); - } - - static ClickHandlerPtr getActive() { - return _active ? *_active : ClickHandlerPtr(); - } - static ClickHandlerPtr getPressed() { - return _pressed ? *_pressed : ClickHandlerPtr(); - } - - static bool showAsActive(const ClickHandlerPtr &p) { - if (!p || !_active || p != *_active) { - return false; - } - return !_pressed || !*_pressed || (p == *_pressed); - } - static bool showAsPressed(const ClickHandlerPtr &p) { - if (!p || !_active || p != *_active) { - return false; - } - return _pressed && (p == *_pressed); - } - static void hostDestroyed(ClickHandlerHost *host) { - if (_activeHost == host) { - _activeHost = nullptr; - } else if (_pressedHost == host) { - _pressedHost = nullptr; - } - } - -private: - - static NeverFreedPointer _active; - static NeverFreedPointer _pressed; - static ClickHandlerHost *_activeHost; - static ClickHandlerHost *_pressedHost; - -}; - -class LeftButtonClickHandler : public ClickHandler { -public: - void onClick(Qt::MouseButton button) const override final { - if (button != Qt::LeftButton) return; - onClickImpl(); - } - -protected: - virtual void onClickImpl() const = 0; - -}; - -class TextClickHandler : public ClickHandler { -public: - - TextClickHandler(bool fullDisplayed = true) : _fullDisplayed(fullDisplayed) { - } - - void copyToClipboard() const override { - QString u = url(); - if (!u.isEmpty()) { - QApplication::clipboard()->setText(u); - } - } - - QString tooltip() const override { - return _fullDisplayed ? QString() : readable(); - } - - void setFullDisplayed(bool full) { - _fullDisplayed = full; - } - -protected: - virtual QString url() const = 0; - virtual QString readable() const { - return url(); - } - - bool _fullDisplayed; - -}; - -class UrlClickHandler : public TextClickHandler { -public: - UrlClickHandler(const QString &url, bool fullDisplayed = true) : TextClickHandler(fullDisplayed), _url(url) { - if (isEmail()) { - _readable = _url; - } else { - QUrl u(_url), good(u.isValid() ? u.toEncoded() : QString()); - _readable = good.isValid() ? good.toDisplayString() : _url; - } - } - QString copyToClipboardContextItem() const override; - - QString text() const override { - return _url; - } - QString dragText() const override { - return url(); - } - - static void doOpen(QString url); - void onClick(Qt::MouseButton button) const override { - if (button == Qt::LeftButton || button == Qt::MiddleButton) { - doOpen(url()); - } - } - -protected: - QString url() const override { - if (isEmail()) { - return _url; - } - - QUrl u(_url), good(u.isValid() ? u.toEncoded() : QString()); - QString result(good.isValid() ? QString::fromUtf8(good.toEncoded()) : _url); - - if (!QRegularExpression(qsl("^[a-zA-Z]+:")).match(result).hasMatch()) { // no protocol - return qsl("http://") + result; - } - return result; - } - QString readable() const override { - return _readable; - } - -private: - static bool isEmail(const QString &url) { - int at = url.indexOf('@'), slash = url.indexOf('/'); - return ((at > 0) && (slash < 0 || slash > at)); - } - bool isEmail() const { - return isEmail(_url); - } - - QString _url, _readable; - -}; -typedef QSharedPointer TextClickHandlerPtr; - -class HiddenUrlClickHandler : public UrlClickHandler { -public: - HiddenUrlClickHandler(QString url) : UrlClickHandler(url, false) { - } - void onClick(Qt::MouseButton button) const override; - -}; - -struct LocationCoords { - LocationCoords() : lat(0), lon(0) { - } - LocationCoords(float64 lat, float64 lon) : lat(lat), lon(lon) { - } - LocationCoords(const MTPDgeoPoint &point) : lat(point.vlat.v), lon(point.vlong.v) { - } - float64 lat, lon; -}; -inline bool operator==(const LocationCoords &a, const LocationCoords &b) { - return (a.lat == b.lat) && (a.lon == b.lon); -} -inline bool operator<(const LocationCoords &a, const LocationCoords &b) { - return (a.lat < b.lat) || ((a.lat == b.lat) && (a.lon < b.lon)); -} -inline uint qHash(const LocationCoords &t, uint seed = 0) { - return qHash(QtPrivate::QHashCombine().operator()(qHash(t.lat), t.lon), seed); -} - -class LocationClickHandler : public TextClickHandler { -public: - LocationClickHandler(const LocationCoords &coords) : _coords(coords) { - setup(); - } - QString copyToClipboardContextItem() const override; - - QString text() const override { - return _text; - } - void onClick(Qt::MouseButton button) const override; - -protected: - QString url() const override { - return _text; - } - -private: - - void setup(); - LocationCoords _coords; - QString _text; - -}; - -class MentionClickHandler : public TextClickHandler { -public: - MentionClickHandler(const QString &tag) : _tag(tag) { - } - QString copyToClipboardContextItem() const override; - - QString text() const override { - return _tag; - } - void onClick(Qt::MouseButton button) const override; - -protected: - QString url() const override { - return _tag; - } - -private: - QString _tag; - -}; - -class HashtagClickHandler : public TextClickHandler { -public: - HashtagClickHandler(const QString &tag) : _tag(tag) { - } - QString copyToClipboardContextItem() const override; - - QString text() const override { - return _tag; - } - void onClick(Qt::MouseButton button) const override; - -protected: - QString url() const override { - return _tag; - } - -private: - QString _tag; - -}; - -class BotCommandClickHandler : public TextClickHandler { -public: - BotCommandClickHandler(const QString &cmd) : _cmd(cmd) { - } - QString text() const override { - return _cmd; - } - void onClick(Qt::MouseButton button) const override; - -protected: - QString url() const override { - return _cmd; - } - -private: - QString _cmd; - -}; - static const QChar TextCommand(0x0010); enum TextCommands { TextCommandBold = 0x01, diff --git a/Telegram/SourceFiles/ui/toast/toast.cpp b/Telegram/SourceFiles/ui/toast/toast.cpp index 341d427cd9..02d67e92a9 100644 --- a/Telegram/SourceFiles/ui/toast/toast.cpp +++ b/Telegram/SourceFiles/ui/toast/toast.cpp @@ -23,7 +23,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "ui/toast/toast_manager.h" #include "ui/toast/toast_widget.h" -#include "window.h" namespace Ui { namespace Toast { @@ -35,12 +34,10 @@ Instance::Instance(const Config &config, QWidget *widgetParent, const Private &) _a_fade.start(); } -void Show(const Config &config) { - if (internal::Manager *manager = internal::Manager::instance()) { - if (Window *window = App::wnd()) { - auto toast = std_::make_unique(config, window, Instance::Private()); - manager->addToast(std_::move(toast)); - } +void Show(QWidget *parent, const Config &config) { + if (auto manager = internal::Manager::instance(parent)) { + auto toast = std_::make_unique(config, parent, Instance::Private()); + manager->addToast(std_::move(toast)); } } diff --git a/Telegram/SourceFiles/ui/toast/toast.h b/Telegram/SourceFiles/ui/toast/toast.h index be634dfdb4..d4a15b3a02 100644 --- a/Telegram/SourceFiles/ui/toast/toast.h +++ b/Telegram/SourceFiles/ui/toast/toast.h @@ -33,7 +33,7 @@ struct Config { QString text; int durationMs = DefaultDuration; }; -void Show(const Config &config); +void Show(QWidget *parent, const Config &config); class Instance { struct Private { @@ -57,7 +57,7 @@ private: // ToastManager should reset _widget pointer if _widget is destroyed. friend class internal::Manager; - friend void Show(const Config &config); + friend void Show(QWidget *parent, const Config &config); std_::unique_ptr _widget; }; diff --git a/Telegram/SourceFiles/ui/toast/toast_manager.cpp b/Telegram/SourceFiles/ui/toast/toast_manager.cpp index 29479c9a9b..39c63f1c39 100644 --- a/Telegram/SourceFiles/ui/toast/toast_manager.cpp +++ b/Telegram/SourceFiles/ui/toast/toast_manager.cpp @@ -21,30 +21,31 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "stdafx.h" #include "ui/toast/toast_manager.h" +#include "application.h" #include "ui/toast/toast_widget.h" -#include "window.h" namespace Ui { namespace Toast { namespace internal { -Manager *Manager::_instance = nullptr; +namespace { -Manager::Manager(QObject *parent) : QObject(parent) { - t_assert(_instance == nullptr); - _instance = this; +NeverFreedPointer> _managers; +} // namespace + +Manager::Manager(QWidget *parent) : QObject(parent) { connect(&_hideTimer, SIGNAL(timeout()), this, SLOT(onHideTimeout())); connect(parent, SIGNAL(resized()), this, SLOT(onParentResized())); } -Manager *Manager::instance() { - if (!_instance) { - if (Window *w = App::wnd()) { - _instance = new Manager(w); - } +Manager *Manager::instance(QWidget *parent) { + _managers.makeIfNull(); + auto i = _managers->constFind(parent); + if (i == _managers->cend()) { + i = _managers->insert(parent, new Manager(parent)); } - return _instance; + return i.value(); } void Manager::addToast(std_::unique_ptr &&toast) { @@ -115,7 +116,7 @@ void Manager::startNextHideTimer() { } Manager::~Manager() { - _instance = nullptr; + _managers->remove(parent()); } } // namespace internal diff --git a/Telegram/SourceFiles/ui/toast/toast_manager.h b/Telegram/SourceFiles/ui/toast/toast_manager.h index f2b514a9ed..28419cf720 100644 --- a/Telegram/SourceFiles/ui/toast/toast_manager.h +++ b/Telegram/SourceFiles/ui/toast/toast_manager.h @@ -34,7 +34,7 @@ public: Manager(const Manager &other) = delete; Manager &operator=(const Manager &other) = delete; - static Manager *instance(); + static Manager *instance(QWidget *parent); void addToast(std_::unique_ptr &&toast); @@ -46,7 +46,7 @@ private slots: void onToastWidgetParentResized(); private: - Manager(QObject *parent); + Manager(QWidget *parent); void startNextHideTimer(); SingleTimer _hideTimer; @@ -56,8 +56,6 @@ private: QMap _toastByWidget; QList _toasts; - static Manager *_instance; - }; } // namespace internal diff --git a/Telegram/SourceFiles/ui/twidget.cpp b/Telegram/SourceFiles/ui/twidget.cpp index eced0da475..cb3ea81b78 100644 --- a/Telegram/SourceFiles/ui/twidget.cpp +++ b/Telegram/SourceFiles/ui/twidget.cpp @@ -21,7 +21,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "stdafx.h" #include "application.h" -#include "window.h" +#include "mainwindow.h" namespace Fonts { diff --git a/Telegram/SourceFiles/ui/twidget.h b/Telegram/SourceFiles/ui/twidget.h index 4667e43a9e..9d4b5468f0 100644 --- a/Telegram/SourceFiles/ui/twidget.h +++ b/Telegram/SourceFiles/ui/twidget.h @@ -156,12 +156,12 @@ void rtlupdate(int x, int y, int w, int h) { \ update(myrtlrect(x, y, w, h)); \ } \ protected: \ -void enterEvent(QEvent *e) { \ +void enterEvent(QEvent *e) override { \ TWidget *p(tparent()); \ if (p) p->leaveToChildEvent(e); \ return QWidget::enterEvent(e); \ } \ -void leaveEvent(QEvent *e) { \ +void leaveEvent(QEvent *e) override { \ TWidget *p(tparent()); \ if (p) p->enterFromChildEvent(e); \ return QWidget::leaveEvent(e); \ @@ -172,8 +172,7 @@ class TWidget : public QWidget { T_WIDGET public: - - TWidget(QWidget *parent = 0) : QWidget(parent) { + TWidget(QWidget *parent = nullptr) : QWidget(parent) { } bool event(QEvent *e) { return QWidget::event(e); @@ -185,8 +184,6 @@ public: bool inFocusChain() const; -private: - }; void myEnsureResized(QWidget *target); @@ -229,3 +226,44 @@ private: const char *_member; }; + +// A simple wrap around T* to explicitly state ownership +template +class ChildWidget { +public: + ChildWidget(std::nullptr_t) : _widget(nullptr) { + } + // No default constructor, but constructors with at least + // one argument are simply make functions. + template + ChildWidget(Parent &&parent, Args&&... args) : _widget(new T(std_::forward(parent), std_::forward(args)...)) { + } + + ChildWidget(const ChildWidget &other) = delete; + ChildWidget &operator=(const ChildWidget &other) = delete; + + ChildWidget &operator=(std::nullptr_t) { + _widget = nullptr; + return *this; + } + ChildWidget &operator=(T *widget) { + _widget = widget; + return *this; + } + + T *operator->() const { + return _widget; + } + T &operator*() const { + return *_widget; + } + + // So we can pass this pointer to methods like connect(). + operator T*() const { + return _widget; + } + +private: + T *_widget; + +}; diff --git a/Telegram/SourceFiles/window/top_bar_widget.cpp b/Telegram/SourceFiles/window/top_bar_widget.cpp new file mode 100644 index 0000000000..b6b1ace0de --- /dev/null +++ b/Telegram/SourceFiles/window/top_bar_widget.cpp @@ -0,0 +1,393 @@ +/* +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. + +In addition, as a special exception, the copyright holders give permission +to link the code of portions of this program with the OpenSSL library. + +Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE +Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org +*/ +#include "stdafx.h" +#include "window/top_bar_widget.h" + +#include "boxes/addcontactbox.h" +#include "boxes/confirmbox.h" +#include "mainwidget.h" +#include "shortcuts.h" +#include "lang.h" +#include "ui/buttons/peer_avatar_button.h" +#include "ui/flatbutton.h" + +namespace Window { + +TopBarWidget::TopBarWidget(MainWidget *w) : TWidget(w) +, a_over(0) +, _a_appearance(animation(this, &TopBarWidget::step_appearance)) +, _selPeer(0) +, _selCount(0) +, _canDelete(false) +, _selStrLeft(-st::topBarButton.width / 2) +, _selStrWidth(0) +, _animating(false) +, _clearSelection(this, lang(lng_selected_clear), st::topBarButton) +, _forward(this, lang(lng_selected_forward), st::topBarActionButton) +, _delete(this, lang(lng_selected_delete), st::topBarActionButton) +, _selectionButtonsWidth(_clearSelection->width() + _forward->width() + _delete->width()) +, _forwardDeleteWidth(qMax(_forward->textWidth(), _delete->textWidth())) +, _info(this, nullptr, st::infoButton) +, _edit(this, lang(lng_profile_edit_contact), st::topBarButton) +, _leaveGroup(this, lang(lng_profile_delete_and_exit), st::topBarButton) +, _addContact(this, lang(lng_profile_add_contact), st::topBarButton) +, _deleteContact(this, lang(lng_profile_delete_contact), st::topBarButton) +, _mediaType(this, lang(lng_media_type), st::topBarButton) +, _search(this, st::topBarSearch) +, _sideShadow(this, st::shadowColor) { + + connect(_forward, SIGNAL(clicked()), this, SLOT(onForwardSelection())); + connect(_delete, SIGNAL(clicked()), this, SLOT(onDeleteSelection())); + connect(_clearSelection, SIGNAL(clicked()), this, SLOT(onClearSelection())); + connect(_info, SIGNAL(clicked()), this, SLOT(onInfoClicked())); + connect(_addContact, SIGNAL(clicked()), this, SLOT(onAddContact())); + connect(_deleteContact, SIGNAL(clicked()), this, SLOT(onDeleteContact())); + connect(_edit, SIGNAL(clicked()), this, SLOT(onEdit())); + connect(_leaveGroup, SIGNAL(clicked()), this, SLOT(onDeleteAndExit())); + connect(_search, SIGNAL(clicked()), this, SLOT(onSearch())); + + setCursor(style::cur_pointer); + showAll(); +} + +void TopBarWidget::onForwardSelection() { + if (App::main()) App::main()->forwardSelectedItems(); +} + +void TopBarWidget::onDeleteSelection() { + if (App::main()) App::main()->deleteSelectedItems(); +} + +void TopBarWidget::onClearSelection() { + if (App::main()) App::main()->clearSelectedItems(); +} + +void TopBarWidget::onInfoClicked() { + PeerData *p = App::main() ? App::main()->historyPeer() : 0; + if (p) App::main()->showPeerProfile(p); +} + +void TopBarWidget::onAddContact() { + PeerData *p = App::main() ? App::main()->profilePeer() : 0; + UserData *u = p ? p->asUser() : 0; + if (u) Ui::showLayer(new AddContactBox(u->firstName, u->lastName, u->phone.isEmpty() ? App::phoneFromSharedContact(peerToUser(u->id)) : u->phone)); +} + +void TopBarWidget::onEdit() { + PeerData *p = App::main() ? App::main()->profilePeer() : 0; + if (p) { + if (p->isChannel()) { + Ui::showLayer(new EditChannelBox(p->asChannel())); + } else if (p->isChat()) { + Ui::showLayer(new EditNameTitleBox(p)); + } else if (p->isUser()) { + Ui::showLayer(new AddContactBox(p->asUser())); + } + } +} + +void TopBarWidget::onDeleteContact() { + PeerData *p = App::main() ? App::main()->profilePeer() : 0; + UserData *u = p ? p->asUser() : 0; + if (u) { + ConfirmBox *box = new ConfirmBox(lng_sure_delete_contact(lt_contact, p->name), lang(lng_box_delete)); + connect(box, SIGNAL(confirmed()), this, SLOT(onDeleteContactSure())); + Ui::showLayer(box); + } +} + +void TopBarWidget::onDeleteContactSure() { + PeerData *p = App::main() ? App::main()->profilePeer() : 0; + UserData *u = p ? p->asUser() : 0; + if (u) { + Ui::showChatsList(); + Ui::hideLayer(); + MTP::send(MTPcontacts_DeleteContact(u->inputUser), App::main()->rpcDone(&MainWidget::deletedContact, u)); + } +} + +void TopBarWidget::onDeleteAndExit() { + PeerData *p = App::main() ? App::main()->profilePeer() : 0; + ChatData *c = p ? p->asChat() : 0; + if (c) { + ConfirmBox *box = new ConfirmBox(lng_sure_delete_and_exit(lt_group, p->name), lang(lng_box_leave), st::attentionBoxButton); + connect(box, SIGNAL(confirmed()), this, SLOT(onDeleteAndExitSure())); + Ui::showLayer(box); + } +} + +void TopBarWidget::onDeleteAndExitSure() { + PeerData *p = App::main() ? App::main()->profilePeer() : 0; + ChatData *c = p ? p->asChat() : 0; + if (c) { + Ui::showChatsList(); + Ui::hideLayer(); + MTP::send(MTPmessages_DeleteChatUser(c->inputChat, App::self()->inputUser), App::main()->rpcDone(&MainWidget::deleteHistoryAfterLeave, p), App::main()->rpcFail(&MainWidget::leaveChatFailed, p)); + } +} + +void TopBarWidget::onSearch() { + Shortcuts::launch(qsl("search")); +} + +void TopBarWidget::enterEvent(QEvent *e) { + a_over.start(1); + _a_appearance.start(); +} + +void TopBarWidget::enterFromChildEvent(QEvent *e) { + a_over.start(1); + _a_appearance.start(); +} + +void TopBarWidget::leaveEvent(QEvent *e) { + a_over.start(0); + _a_appearance.start(); +} + +void TopBarWidget::leaveToChildEvent(QEvent *e) { + a_over.start(0); + _a_appearance.start(); +} + +void TopBarWidget::step_appearance(float64 ms, bool timer) { + float64 dt = ms / st::topBarDuration; + if (dt >= 1) { + _a_appearance.stop(); + a_over.finish(); + } else { + a_over.update(dt, anim::linear); + } + if (timer) update(); +} + +void TopBarWidget::paintEvent(QPaintEvent *e) { + QPainter p(this); + + if (e->rect().top() < st::topBarHeight) { // optimize shadow-only drawing + p.fillRect(QRect(0, 0, width(), st::topBarHeight), st::topBarBG->b); + if (_clearSelection->isHidden()) { + p.save(); + main()->paintTopBar(p, a_over.current(), _info->isHidden() ? 0 : _info->width()); + p.restore(); + } else { + p.setFont(st::linkFont->f); + p.setPen(st::btnDefLink.color->p); + p.drawText(_selStrLeft, st::topBarButton.textTop + st::linkFont->ascent, _selStr); + } + } +} + +void TopBarWidget::mousePressEvent(QMouseEvent *e) { + PeerData *p = App::main() ? App::main()->profilePeer() : 0; + if (e->button() == Qt::LeftButton && e->pos().y() < st::topBarHeight && (p || !_selCount)) { + emit clicked(); + } +} + +void TopBarWidget::resizeEvent(QResizeEvent *e) { + int32 r = width(); + if (!_forward->isHidden() || !_delete->isHidden()) { + int32 fullW = r - (_selectionButtonsWidth + (_selStrWidth - st::topBarButton.width) + st::topBarActionSkip); + int32 selectedClearWidth = st::topBarButton.width, forwardDeleteWidth = st::topBarActionButton.width - _forwardDeleteWidth, skip = st::topBarActionSkip; + while (fullW < 0) { + int fit = 0; + if (selectedClearWidth < -2 * (st::topBarMinPadding + 1)) { + fullW += 4; + selectedClearWidth += 2; + } else if (selectedClearWidth < -2 * st::topBarMinPadding) { + fullW += (-2 * st::topBarMinPadding - selectedClearWidth) * 2; + selectedClearWidth = -2 * st::topBarMinPadding; + } else { + ++fit; + } + if (fullW >= 0) break; + + if (forwardDeleteWidth > 2 * (st::topBarMinPadding + 1)) { + fullW += 4; + forwardDeleteWidth -= 2; + } else if (forwardDeleteWidth > 2 * st::topBarMinPadding) { + fullW += (forwardDeleteWidth - 2 * st::topBarMinPadding) * 2; + forwardDeleteWidth = 2 * st::topBarMinPadding; + } else { + ++fit; + } + if (fullW >= 0) break; + + if (skip > st::topBarMinPadding) { + --skip; + ++fullW; + } else { + ++fit; + } + if (fullW >= 0 || fit >= 3) break; + } + _clearSelection->setWidth(selectedClearWidth); + _forward->setWidth(_forwardDeleteWidth + forwardDeleteWidth); + _delete->setWidth(_forwardDeleteWidth + forwardDeleteWidth); + _selStrLeft = -selectedClearWidth / 2; + + int32 availX = _selStrLeft + _selStrWidth, availW = r - (_clearSelection->width() + selectedClearWidth / 2) - availX; + if (_forward->isHidden()) { + _delete->move(availX + (availW - _delete->width()) / 2, (st::topBarHeight - _forward->height()) / 2); + } else if (_delete->isHidden()) { + _forward->move(availX + (availW - _forward->width()) / 2, (st::topBarHeight - _forward->height()) / 2); + } else { + _forward->move(availX + (availW - _forward->width() - _delete->width() - skip) / 2, (st::topBarHeight - _forward->height()) / 2); + _delete->move(availX + (availW + _forward->width() - _delete->width() + skip) / 2, (st::topBarHeight - _forward->height()) / 2); + } + _clearSelection->move(r -= _clearSelection->width(), 0); + } + if (!_info->isHidden()) _info->move(r -= _info->width(), 0); + if (!_deleteContact->isHidden()) _deleteContact->move(r -= _deleteContact->width(), 0); + if (!_leaveGroup->isHidden()) _leaveGroup->move(r -= _leaveGroup->width(), 0); + if (!_edit->isHidden()) _edit->move(r -= _edit->width(), 0); + if (!_addContact->isHidden()) _addContact->move(r -= _addContact->width(), 0); + if (!_mediaType->isHidden()) _mediaType->move(r -= _mediaType->width(), 0); + _search->move(width() - (_info->isHidden() ? st::topBarForwardPadding.right() : _info->width()) - _search->width(), 0); + + _sideShadow->resize(st::lineWidth, height()); + _sideShadow->moveToLeft(0, 0); +} + +void TopBarWidget::startAnim() { + _info->hide(); + _edit->hide(); + _leaveGroup->hide(); + _addContact->hide(); + _deleteContact->hide(); + _clearSelection->hide(); + _delete->hide(); + _forward->hide(); + _mediaType->hide(); + _search->hide(); + + _animating = true; +} + +void TopBarWidget::stopAnim() { + _animating = false; + _sideShadow->setVisible(!Adaptive::OneColumn()); + showAll(); +} + +void TopBarWidget::showAll() { + if (_animating) { + resizeEvent(0); + return; + } + PeerData *p = App::main() ? App::main()->profilePeer() : 0, *h = App::main() ? App::main()->historyPeer() : 0, *o = App::main() ? App::main()->overviewPeer() : 0; + if (p && (p->isChat() || (p->isUser() && (p->asUser()->contact >= 0 || !App::phoneFromSharedContact(peerToUser(p->id)).isEmpty())))) { + if (p->isChat()) { + if (p->asChat()->canEdit()) { + _edit->show(); + } else { + _edit->hide(); + } + _leaveGroup->show(); + _addContact->hide(); + _deleteContact->hide(); + } else if (p->asUser()->contact > 0) { + _edit->show(); + _leaveGroup->hide(); + _addContact->hide(); + _deleteContact->show(); + } else { + _edit->hide(); + _leaveGroup->hide(); + _addContact->show(); + _deleteContact->hide(); + } + _clearSelection->hide(); + _info->hide(); + _delete->hide(); + _forward->hide(); + _mediaType->hide(); + _search->hide(); + } else { + if (p && p->isChannel() && (p->asChannel()->amCreator() || (p->isMegagroup() && p->asChannel()->amEditor()))) { + _edit->show(); + } else { + _edit->hide(); + } + _leaveGroup->hide(); + _addContact->hide(); + _deleteContact->hide(); + if (!p && _selCount) { + _clearSelection->show(); + if (_canDelete) { + _delete->show(); + } else { + _delete->hide(); + } + _forward->show(); + _mediaType->hide(); + } else { + _clearSelection->hide(); + _delete->hide(); + _forward->hide(); + if (App::main() && App::main()->mediaTypeSwitch()) { + _mediaType->show(); + } else { + _mediaType->hide(); + } + } + if (h && !o && !p && _clearSelection->isHidden()) { + if (Adaptive::OneColumn()) { + _info->setPeer(h); + _info->show(); + } else { + _info->hide(); + } + _search->show(); + } else { + _search->hide(); + _info->hide(); + } + } + _sideShadow->setVisible(!Adaptive::OneColumn()); + resizeEvent(nullptr); +} + +void TopBarWidget::showSelected(uint32 selCount, bool canDelete) { + PeerData *p = App::main() ? App::main()->profilePeer() : 0; + _selPeer = App::main()->overviewPeer() ? App::main()->overviewPeer() : App::main()->peer(); + _selCount = selCount; + _canDelete = canDelete; + _selStr = (_selCount > 0) ? lng_selected_count(lt_count, _selCount) : QString(); + _selStrWidth = st::btnDefLink.font->width(_selStr); + setCursor((!p && _selCount) ? style::cur_default : style::cur_pointer); + showAll(); +} + +void TopBarWidget::updateAdaptiveLayout() { + showAll(); +} + +FlatButton *TopBarWidget::mediaTypeButton() { + return _mediaType; +} + +MainWidget *TopBarWidget::main() { + return static_cast(parentWidget()); +} + +} // namespace Window diff --git a/Telegram/SourceFiles/window/top_bar_widget.h b/Telegram/SourceFiles/window/top_bar_widget.h new file mode 100644 index 0000000000..3c94114e6a --- /dev/null +++ b/Telegram/SourceFiles/window/top_bar_widget.h @@ -0,0 +1,114 @@ +/* +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. + +In addition, as a special exception, the copyright holders give permission +to link the code of portions of this program with the OpenSSL library. + +Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE +Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org +*/ +#pragma once + +#include "ui/twidget.h" + +namespace Ui { +class PeerAvatarButton; +} // namespace Ui +class FlatButton; +class IconedButton; +class PlainShadow; + +namespace Window { + +class TopBarWidget : public TWidget { + Q_OBJECT + +public: + + TopBarWidget(MainWidget *w); + + void enterEvent(QEvent *e) override; + void enterFromChildEvent(QEvent *e) override; + void leaveEvent(QEvent *e) override; + void leaveToChildEvent(QEvent *e) override; + void paintEvent(QPaintEvent *e) override; + void mousePressEvent(QMouseEvent *e) override; + void resizeEvent(QResizeEvent *e) override; + + void step_appearance(float64 ms, bool timer); + void enableShadow(bool enable = true); + + void startAnim(); + void stopAnim(); + void showAll(); + void showSelected(uint32 selCount, bool canDelete = false); + + void updateAdaptiveLayout(); + + FlatButton *mediaTypeButton(); + + void grabStart() override { + _sideShadow->hide(); + } + void grabFinish() override { + _sideShadow->setVisible(!Adaptive::OneColumn()); + } + + public slots: + + void onForwardSelection(); + void onDeleteSelection(); + void onClearSelection(); + void onInfoClicked(); + void onAddContact(); + void onEdit(); + void onDeleteContact(); + void onDeleteContactSure(); + void onDeleteAndExit(); + void onDeleteAndExitSure(); + void onSearch(); + +signals: + + void clicked(); + +private: + + MainWidget *main(); + anim::fvalue a_over; + Animation _a_appearance; + + PeerData *_selPeer = nullptr; + uint32 _selCount; + bool _canDelete; + QString _selStr; + int32 _selStrLeft, _selStrWidth; + + bool _animating; + + ChildWidget _clearSelection; + ChildWidget _forward, _delete; + int _selectionButtonsWidth, _forwardDeleteWidth; + + ChildWidget _info; + ChildWidget _edit, _leaveGroup, _addContact, _deleteContact; + ChildWidget _mediaType; + + ChildWidget _search; + + ChildWidget _sideShadow; + +}; + +} // namespace Window diff --git a/Telegram/Telegram.vcxproj b/Telegram/Telegram.vcxproj index c651652de3..1fb2d8faf4 100644 --- a/Telegram/Telegram.vcxproj +++ b/Telegram/Telegram.vcxproj @@ -348,6 +348,10 @@ true true + + true + true + true true @@ -435,6 +439,10 @@ true true + + true + true + true true @@ -443,10 +451,6 @@ true true - - true - true - true true @@ -631,6 +635,10 @@ true true + + true + true + true true @@ -718,6 +726,10 @@ true true + + true + true + true true @@ -726,10 +738,6 @@ true true - - true - true - @@ -940,6 +948,10 @@ true true + + true + true + true true @@ -1027,6 +1039,10 @@ true true + + true + true + true true @@ -1035,17 +1051,12 @@ true true - - true - true - - @@ -1063,6 +1074,9 @@ + + + @@ -1107,6 +1121,7 @@ + @@ -1160,7 +1175,8 @@ - + + NotUsing NotUsing @@ -1213,25 +1229,28 @@ .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/mtproto/connection_tcp.h" -DAL_LIBTYPE_STATIC -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -DQT_NO_DEBUG -DNDEBUG -D_SCL_SECURE_NO_WARNINGS "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\openssl\Release\include" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\SourceFiles" "-I.\GeneratedFiles" "-I.\..\..\Libraries\breakpad\src" "-I.\ThirdParty\minizip" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\..\Libraries\QtStatic\qtbase\include\QtCore\5.5.1\QtCore" "-I.\..\..\Libraries\QtStatic\qtbase\include\QtGui\5.5.1\QtGui" - + $(QTDIR)\bin\moc.exe;%(FullPath) Moc%27ing basic_types.h... .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp - "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/basic_types.h" -DAL_LIBTYPE_STATIC -DCUSTOM_API_ID -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -DQT_NO_DEBUG -DNDEBUG -D_SCL_SECURE_NO_WARNINGS "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\openssl\Release\include" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\SourceFiles" "-I.\GeneratedFiles" "-I.\..\..\Libraries\breakpad\src" "-I.\ThirdParty\minizip" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\..\Libraries\QtStatic\qtbase\include\QtCore\5.5.1\QtCore" "-I.\..\..\Libraries\QtStatic\qtbase\include\QtGui\5.5.1\QtGui" + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/core/basic_types.h" -DAL_LIBTYPE_STATIC -DCUSTOM_API_ID -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -DQT_NO_DEBUG -DNDEBUG -D_SCL_SECURE_NO_WARNINGS "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\openssl\Release\include" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\SourceFiles" "-I.\GeneratedFiles" "-I.\..\..\Libraries\breakpad\src" "-I.\ThirdParty\minizip" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\..\Libraries\QtStatic\qtbase\include\QtCore\5.5.1\QtCore" "-I.\..\..\Libraries\QtStatic\qtbase\include\QtGui\5.5.1\QtGui" $(QTDIR)\bin\moc.exe;%(FullPath) Moc%27ing basic_types.h... .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp - "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/basic_types.h" -DAL_LIBTYPE_STATIC -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -D_SCL_SECURE_NO_WARNINGS "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\openssl_debug\Debug\include" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\..\..\Libraries\breakpad\src" "-I.\ThirdParty\minizip" "-I.\SourceFiles" "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\..\Libraries\QtStatic\qtbase\include\QtCore\5.5.1\QtCore" "-I.\..\..\Libraries\QtStatic\qtbase\include\QtGui\5.5.1\QtGui" + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/core/basic_types.h" -DAL_LIBTYPE_STATIC -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -D_SCL_SECURE_NO_WARNINGS "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\openssl_debug\Debug\include" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\..\..\Libraries\breakpad\src" "-I.\ThirdParty\minizip" "-I.\SourceFiles" "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\..\Libraries\QtStatic\qtbase\include\QtCore\5.5.1\QtCore" "-I.\..\..\Libraries\QtStatic\qtbase\include\QtGui\5.5.1\QtGui" $(QTDIR)\bin\moc.exe;%(FullPath) Moc%27ing basic_types.h... .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp - "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/basic_types.h" -DAL_LIBTYPE_STATIC -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -DQT_NO_DEBUG -DNDEBUG -D_SCL_SECURE_NO_WARNINGS "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\openssl\Release\include" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\SourceFiles" "-I.\GeneratedFiles" "-I.\..\..\Libraries\breakpad\src" "-I.\ThirdParty\minizip" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\..\Libraries\QtStatic\qtbase\include\QtCore\5.5.1\QtCore" "-I.\..\..\Libraries\QtStatic\qtbase\include\QtGui\5.5.1\QtGui" + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/core/basic_types.h" -DAL_LIBTYPE_STATIC -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -DQT_NO_DEBUG -DNDEBUG -D_SCL_SECURE_NO_WARNINGS "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\openssl\Release\include" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\SourceFiles" "-I.\GeneratedFiles" "-I.\..\..\Libraries\breakpad\src" "-I.\ThirdParty\minizip" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\..\Libraries\QtStatic\qtbase\include\QtCore\5.5.1\QtCore" "-I.\..\..\Libraries\QtStatic\qtbase\include\QtGui\5.5.1\QtGui" + + + @@ -1339,6 +1358,7 @@ .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/mtproto/session.h" -DAL_LIBTYPE_STATIC -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -DQT_NO_DEBUG -DNDEBUG -D_SCL_SECURE_NO_WARNINGS "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\openssl\Release\include" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\SourceFiles" "-I.\GeneratedFiles" "-I.\..\..\Libraries\breakpad\src" "-I.\ThirdParty\minizip" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\..\Libraries\QtStatic\qtbase\include\QtCore\5.5.1\QtCore" "-I.\..\..\Libraries\QtStatic\qtbase\include\QtGui\5.5.1\QtGui" + @@ -1520,22 +1540,36 @@ "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/ui/toast/toast_manager.h" -DAL_LIBTYPE_STATIC -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -DQT_NO_DEBUG -DNDEBUG -D_SCL_SECURE_NO_WARNINGS "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\openssl\Release\include" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\SourceFiles" "-I.\GeneratedFiles" "-I.\..\..\Libraries\breakpad\src" "-I.\ThirdParty\minizip" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\..\Libraries\QtStatic\qtbase\include\QtCore\5.5.1\QtCore" "-I.\..\..\Libraries\QtStatic\qtbase\include\QtGui\5.5.1\QtGui" + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing top_bar_widget.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/window/top_bar_widget.h" -DAL_LIBTYPE_STATIC -DCUSTOM_API_ID -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -DQT_NO_DEBUG -DNDEBUG -D_SCL_SECURE_NO_WARNINGS "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\openssl\Release\include" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\SourceFiles" "-I.\GeneratedFiles" "-I.\..\..\Libraries\breakpad\src" "-I.\ThirdParty\minizip" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\..\Libraries\QtStatic\qtbase\include\QtCore\5.5.1\QtCore" "-I.\..\..\Libraries\QtStatic\qtbase\include\QtGui\5.5.1\QtGui" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing top_bar_widget.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/window/top_bar_widget.h" -DAL_LIBTYPE_STATIC -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -D_SCL_SECURE_NO_WARNINGS "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\openssl_debug\Debug\include" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\..\..\Libraries\breakpad\src" "-I.\ThirdParty\minizip" "-I.\SourceFiles" "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\..\Libraries\QtStatic\qtbase\include\QtCore\5.5.1\QtCore" "-I.\..\..\Libraries\QtStatic\qtbase\include\QtGui\5.5.1\QtGui" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing top_bar_widget.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/window/top_bar_widget.h" -DAL_LIBTYPE_STATIC -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -DQT_NO_DEBUG -DNDEBUG -D_SCL_SECURE_NO_WARNINGS "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\openssl\Release\include" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\SourceFiles" "-I.\GeneratedFiles" "-I.\..\..\Libraries\breakpad\src" "-I.\ThirdParty\minizip" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\..\Libraries\QtStatic\qtbase\include\QtCore\5.5.1\QtCore" "-I.\..\..\Libraries\QtStatic\qtbase\include\QtGui\5.5.1\QtGui" + - - Moc%27ing window.h... + + Moc%27ing mainwindow.h... .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp - "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DAL_LIBTYPE_STATIC -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -D_SCL_SECURE_NO_WARNINGS "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\openssl_debug\Debug\include" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\..\..\Libraries\breakpad\src" "-I.\ThirdParty\minizip" "-I.\SourceFiles" "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\..\Libraries\QtStatic\qtbase\include\QtCore\5.5.1\QtCore" "-I.\..\..\Libraries\QtStatic\qtbase\include\QtGui\5.5.1\QtGui" "-fstdafx.h" "-f../../SourceFiles/window.h" - Moc%27ing window.h... - Moc%27ing window.h... + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/mainwindow.h" -DAL_LIBTYPE_STATIC -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -D_SCL_SECURE_NO_WARNINGS "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\openssl_debug\Debug\include" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\..\..\Libraries\breakpad\src" "-I.\ThirdParty\minizip" "-I.\SourceFiles" "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\..\Libraries\QtStatic\qtbase\include\QtCore\5.5.1\QtCore" "-I.\..\..\Libraries\QtStatic\qtbase\include\QtGui\5.5.1\QtGui" + Moc%27ing mainwindow.h... + Moc%27ing mainwindow.h... .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp - "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DAL_LIBTYPE_STATIC -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -DQT_NO_DEBUG -DNDEBUG -D_SCL_SECURE_NO_WARNINGS "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\openssl\Release\include" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\SourceFiles" "-I.\GeneratedFiles" "-I.\..\..\Libraries\breakpad\src" "-I.\ThirdParty\minizip" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\..\Libraries\QtStatic\qtbase\include\QtCore\5.5.1\QtCore" "-I.\..\..\Libraries\QtStatic\qtbase\include\QtGui\5.5.1\QtGui" "-fstdafx.h" "-f../../SourceFiles/window.h" - "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DAL_LIBTYPE_STATIC -DCUSTOM_API_ID -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -DQT_NO_DEBUG -DNDEBUG -D_SCL_SECURE_NO_WARNINGS "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\openssl\Release\include" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\SourceFiles" "-I.\GeneratedFiles" "-I.\..\..\Libraries\breakpad\src" "-I.\ThirdParty\minizip" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\..\Libraries\QtStatic\qtbase\include\QtCore\5.5.1\QtCore" "-I.\..\..\Libraries\QtStatic\qtbase\include\QtGui\5.5.1\QtGui" "-fstdafx.h" "-f../../SourceFiles/window.h" - $(QTDIR)\bin\moc.exe;%(FullPath) - $(QTDIR)\bin\moc.exe;%(FullPath) - $(QTDIR)\bin\moc.exe;%(FullPath) + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/mainwindow.h" -DAL_LIBTYPE_STATIC -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -DQT_NO_DEBUG -DNDEBUG -D_SCL_SECURE_NO_WARNINGS "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\openssl\Release\include" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\SourceFiles" "-I.\GeneratedFiles" "-I.\..\..\Libraries\breakpad\src" "-I.\ThirdParty\minizip" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\..\Libraries\QtStatic\qtbase\include\QtCore\5.5.1\QtCore" "-I.\..\..\Libraries\QtStatic\qtbase\include\QtGui\5.5.1\QtGui" + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" "-fstdafx.h" "-f../../SourceFiles/mainwindow.h" -DAL_LIBTYPE_STATIC -DCUSTOM_API_ID -DUNICODE -DWIN32 -DWIN64 -DHAVE_STDINT_H -DZLIB_WINAPI -DQT_NO_DEBUG -DNDEBUG -D_SCL_SECURE_NO_WARNINGS "-I.\..\..\Libraries\lzma\C" "-I.\..\..\Libraries\libexif-0.6.20" "-I.\..\..\Libraries\zlib-1.2.8" "-I.\..\..\Libraries\openssl\Release\include" "-I.\..\..\Libraries\ffmpeg" "-I.\..\..\Libraries\openal-soft\include" "-I.\SourceFiles" "-I.\GeneratedFiles" "-I.\..\..\Libraries\breakpad\src" "-I.\ThirdParty\minizip" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\..\Libraries\QtStatic\qtbase\include\QtCore\5.5.1\QtCore" "-I.\..\..\Libraries\QtStatic\qtbase\include\QtGui\5.5.1\QtGui" + $(QTDIR)\bin\moc.exe;%(FullPath);$(QTDIR)\bin\moc.exe;%(FullPath) + $(QTDIR)\bin\moc.exe;%(FullPath);$(QTDIR)\bin\moc.exe;%(FullPath) + $(QTDIR)\bin\moc.exe;%(FullPath);$(QTDIR)\bin\moc.exe;%(FullPath) .\GeneratedFiles\style_classes.h diff --git a/Telegram/Telegram.vcxproj.filters b/Telegram/Telegram.vcxproj.filters index 2c6bfa628b..86772f8db2 100644 --- a/Telegram/Telegram.vcxproj.filters +++ b/Telegram/Telegram.vcxproj.filters @@ -67,6 +67,18 @@ {24292a88-6707-4070-b2d2-8b53acd5cdd0} + + {162feb92-08a4-4abf-9936-79c389d4fcb9} + + + {39b5a449-928d-4add-9610-95c03878d52f} + + + {0192d4a5-ecf0-4076-937a-d3a08443e543} + + + {ddcc5634-90e7-4815-ba86-a3db539f4774} + @@ -99,9 +111,6 @@ Source Files - - Source Files - Source Files @@ -177,15 +186,6 @@ Source Files - - Generated Files\Deploy - - - Generated Files\Debug - - - Generated Files\Release - Generated Files\Deploy @@ -825,18 +825,6 @@ Generated Files\Release - - Source Files - - - Generated Files\Deploy - - - Generated Files\Debug - - - Generated Files\Release - inline_bots @@ -1035,6 +1023,51 @@ ui\buttons + + window + + + Generated Files\Deploy + + + Generated Files\Deploy + + + Generated Files\Debug + + + Generated Files\Release + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + core + + + core + + + Generated Files\Deploy + + + Generated Files\Debug + + + Generated Files\Release + + + core + + + overview + @@ -1175,6 +1208,18 @@ ui\buttons + + history + + + core + + + core + + + overview + @@ -1183,9 +1228,6 @@ Source Files - - Source Files - Source Files @@ -1378,9 +1420,6 @@ Source Files - - Source Files - ui @@ -1417,6 +1456,15 @@ ui\toast + + window + + + Source Files + + + core + diff --git a/Telegram/Telegram.xcodeproj/project.pbxproj b/Telegram/Telegram.xcodeproj/project.pbxproj index 68dd8e9238..fe744af85d 100644 --- a/Telegram/Telegram.xcodeproj/project.pbxproj +++ b/Telegram/Telegram.xcodeproj/project.pbxproj @@ -162,7 +162,7 @@ 5FC914F652D1B16FDA8F0634 /* moc_contactsbox.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 26083D8E535AFF927591E1A5 /* moc_contactsbox.cpp */; settings = {ATTRIBUTES = (); }; }; 60CB4898955209B665E7B07D /* moc_twidget.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 55A654A2EE8554FF062742B8 /* moc_twidget.cpp */; settings = {ATTRIBUTES = (); }; }; 668DDDA0C55405E7FCFD6CA5 /* CoreServices.framework in Link Binary With Libraries */ = {isa = PBXBuildFile; fileRef = 9742F24EE18EA44D52824F1E /* CoreServices.framework */; }; - 68FFEB7CA30BF0149161B809 /* window.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = CA56ACFB53D87637192CC9B2 /* window.cpp */; settings = {ATTRIBUTES = (); }; }; + 68FFEB7CA30BF0149161B809 /* mainwindow.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = CA56ACFB53D87637192CC9B2 /* mainwindow.cpp */; settings = {ATTRIBUTES = (); }; }; 6A8BC88AB464B92706EFE6FF /* moc_countryinput.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 9D9F4744B2F9FF22569D4535 /* moc_countryinput.cpp */; settings = {ATTRIBUTES = (); }; }; 6C79FBC5CFA36AC3EA6ABBD4 /* moc_dropdown.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = AC9B5F6FB4B984C8D76F7AE2 /* moc_dropdown.cpp */; settings = {ATTRIBUTES = (); }; }; 6E4DB0CBEF415196AFD4149F /* fileuploader.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 9B36BB8C5B8CA7B07F3F35F0 /* fileuploader.cpp */; settings = {ATTRIBUTES = (); }; }; @@ -194,7 +194,7 @@ 9809A3AF1946D51ACB41D716 /* moc_photocropbox.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = AF61D864B8C444ADD4E1B391 /* moc_photocropbox.cpp */; settings = {ATTRIBUTES = (); }; }; 98E4F55DB5D8E64AB9F08C83 /* moc_localimageloader.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 1D7899ACAA9F973CADFA34C1 /* moc_localimageloader.cpp */; settings = {ATTRIBUTES = (); }; }; 99F0A9B2AFE5ABDCBFC04510 /* rpc_sender.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 89F92B278CA31C393E245056 /* rpc_sender.cpp */; settings = {ATTRIBUTES = (); }; }; - 9A0D5DDC7816FC2538EB6A96 /* moc_window.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 6B46A0EE3C3B9D3B5A24946E /* moc_window.cpp */; settings = {ATTRIBUTES = (); }; }; + 9A0D5DDC7816FC2538EB6A96 /* moc_mainwindow.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 6B46A0EE3C3B9D3B5A24946E /* moc_mainwindow.cpp */; settings = {ATTRIBUTES = (); }; }; 9A523F51135FD4E2464673A6 /* moc_session.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 63AF8520023B4EA40306CB03 /* moc_session.cpp */; settings = {ATTRIBUTES = (); }; }; 9D294F23E02CFDF22C288382 /* moc_emojibox.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 0C0DC15EB416789673526AA5 /* moc_emojibox.cpp */; settings = {ATTRIBUTES = (); }; }; 9F33AC0693BC81B27D8F518D /* Qt5Gui in Link Binary With Libraries */ = {isa = PBXBuildFile; fileRef = 04391BE7A8B9D811E255100A /* Qt5Gui */; }; @@ -467,7 +467,7 @@ 1A4C47331E186344291B8178 /* dropdown.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = dropdown.h; path = SourceFiles/dropdown.h; sourceTree = ""; }; 1B4A65B84270FF2FED008EB6 /* moc_introphone.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = moc_introphone.cpp; path = GeneratedFiles/Debug/moc_introphone.cpp; sourceTree = ""; }; 1D7899ACAA9F973CADFA34C1 /* moc_localimageloader.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = moc_localimageloader.cpp; path = GeneratedFiles/Debug/moc_localimageloader.cpp; sourceTree = ""; }; - 1DC02F674A7192FF8BE391A7 /* basic_types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = basic_types.h; path = SourceFiles/basic_types.h; sourceTree = ""; }; + 1DC02F674A7192FF8BE391A7 /* basic_types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = basic_types.h; path = SourceFiles/core/basic_types.h; sourceTree = ""; }; 1DEFC0760BB9340529F582F7 /* confirmbox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = confirmbox.h; path = SourceFiles/boxes/confirmbox.h; sourceTree = ""; }; 1E5EEB5782B6357057356F9E /* moc_flatinput.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = moc_flatinput.cpp; path = GeneratedFiles/Debug/moc_flatinput.cpp; sourceTree = ""; }; 1FAE75C970AA73F2DEDDB508 /* /usr/local/Qt-5.5.1/mkspecs/modules/qt_plugin_qavfcamera.pri */ = {isa = PBXFileReference; lastKnownFileType = text; path = "/usr/local/Qt-5.5.1/mkspecs/modules/qt_plugin_qavfcamera.pri"; sourceTree = ""; }; @@ -494,7 +494,7 @@ 2E48BB382B895A5ACD79AF9F /* /usr/local/Qt-5.5.1/mkspecs/modules/qt_lib_bluetooth_private.pri */ = {isa = PBXFileReference; lastKnownFileType = text; path = "/usr/local/Qt-5.5.1/mkspecs/modules/qt_lib_bluetooth_private.pri"; sourceTree = ""; }; 2E6D9B1D2743D24E31B0B284 /* /usr/local/Qt-5.5.1/mkspecs/modules/qt_lib_xmlpatterns.pri */ = {isa = PBXFileReference; lastKnownFileType = text; path = "/usr/local/Qt-5.5.1/mkspecs/modules/qt_lib_xmlpatterns.pri"; sourceTree = ""; }; 2EA58EF6CDF368B0132BAEB9 /* settings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = settings.h; path = SourceFiles/settings.h; sourceTree = ""; }; - 301BB513F2F5D447B3BF22DF /* window.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = window.h; path = SourceFiles/window.h; sourceTree = ""; }; + 301BB513F2F5D447B3BF22DF /* mainwindow.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = mainwindow.h; path = SourceFiles/mainwindow.h; sourceTree = ""; }; 311004331A04F3D69C98643C /* /usr/local/Qt-5.5.1/mkspecs/modules/qt_lib_serialport_private.pri */ = {isa = PBXFileReference; lastKnownFileType = text; path = "/usr/local/Qt-5.5.1/mkspecs/modules/qt_lib_serialport_private.pri"; sourceTree = ""; }; 31120EDB269DFF13E1D49847 /* qicns */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = qicns; path = "/usr/local/Qt-5.5.1/plugins/imageformats/libqicns$(QT_LIBRARY_SUFFIX).a"; sourceTree = ""; }; 315C7FACB4A9E18AA95486CA /* dcenter.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = dcenter.cpp; path = SourceFiles/mtproto/dcenter.cpp; sourceTree = ""; }; @@ -563,7 +563,7 @@ 6868ADA9E9A9801B2BA92B97 /* countryinput.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = countryinput.h; path = SourceFiles/ui/countryinput.h; sourceTree = ""; }; 69347C39E4D922E94D0860BF /* /usr/local/Qt-5.5.1/mkspecs/modules/qt_lib_designercomponents_private.pri */ = {isa = PBXFileReference; lastKnownFileType = text; path = "/usr/local/Qt-5.5.1/mkspecs/modules/qt_lib_designercomponents_private.pri"; sourceTree = ""; }; 6A510365F9F6367ECB0DB065 /* images.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = images.cpp; path = SourceFiles/ui/images.cpp; sourceTree = ""; }; - 6B46A0EE3C3B9D3B5A24946E /* moc_window.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = moc_window.cpp; path = GeneratedFiles/Debug/moc_window.cpp; sourceTree = ""; }; + 6B46A0EE3C3B9D3B5A24946E /* moc_mainwindow.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = moc_mainwindow.cpp; path = GeneratedFiles/Debug/moc_mainwindow.cpp; sourceTree = ""; }; 6B90F69947805586A6FAE80E /* sysbuttons.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = sysbuttons.cpp; path = SourceFiles/sysbuttons.cpp; sourceTree = ""; }; 6C08BFC27C4C303A3A5181DB /* /usr/local/Qt-5.5.1/mkspecs/modules/qt_lib_printsupport.pri */ = {isa = PBXFileReference; lastKnownFileType = text; path = "/usr/local/Qt-5.5.1/mkspecs/modules/qt_lib_printsupport.pri"; sourceTree = ""; }; 6C86B6E6AB1857B735B720D6 /* layerwidget.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = layerwidget.h; path = SourceFiles/layerwidget.h; sourceTree = ""; }; @@ -583,7 +583,7 @@ 7C2F42B222EE88E26A6FED62 /* /usr/local/Qt-5.5.1/mkspecs/modules/qt_lib_designer_private.pri */ = {isa = PBXFileReference; lastKnownFileType = text; path = "/usr/local/Qt-5.5.1/mkspecs/modules/qt_lib_designer_private.pri"; sourceTree = ""; }; 7CA6945B22800A0F30B75DA5 /* addcontactbox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = addcontactbox.cpp; path = SourceFiles/boxes/addcontactbox.cpp; sourceTree = ""; }; 7CDE9D7CB2C729BC3612372B /* addcontactbox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = addcontactbox.h; path = SourceFiles/boxes/addcontactbox.h; sourceTree = ""; }; - 7D075A915E8739C1B6BC5F43 /* basic_types.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = basic_types.cpp; path = SourceFiles/basic_types.cpp; sourceTree = ""; }; + 7D075A915E8739C1B6BC5F43 /* basic_types.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = basic_types.cpp; path = SourceFiles/core/basic_types.cpp; sourceTree = ""; }; 7D28E9003CE64D8A7F2E292E /* /usr/local/Qt-5.5.1/mkspecs/modules/qt_lib_concurrent_private.pri */ = {isa = PBXFileReference; lastKnownFileType = text; path = "/usr/local/Qt-5.5.1/mkspecs/modules/qt_lib_concurrent_private.pri"; sourceTree = ""; }; 7DBFC0B5EAF874BA10E3D603 /* scheme_auto.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = scheme_auto.h; path = SourceFiles/mtproto/scheme_auto.h; sourceTree = ""; }; 7DE30A90667C03C4F91A2A91 /* /usr/local/Qt-5.5.1/mkspecs/modules/qt_lib_sql.pri */ = {isa = PBXFileReference; lastKnownFileType = text; path = "/usr/local/Qt-5.5.1/mkspecs/modules/qt_lib_sql.pri"; sourceTree = ""; }; @@ -703,7 +703,7 @@ C84546C18DCBB04166195DCF /* /usr/local/Qt-5.5.1/mkspecs/modules/qt_plugin_qtposition_positionpoll.pri */ = {isa = PBXFileReference; lastKnownFileType = text; path = "/usr/local/Qt-5.5.1/mkspecs/modules/qt_plugin_qtposition_positionpoll.pri"; sourceTree = ""; }; C913E6A1001E07EE7C13CE93 /* style.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = style.h; path = SourceFiles/ui/style.h; sourceTree = ""; }; C9FFCCE4FCB845744636795F /* moc_flatbutton.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = moc_flatbutton.cpp; path = GeneratedFiles/Debug/moc_flatbutton.cpp; sourceTree = ""; }; - CA56ACFB53D87637192CC9B2 /* window.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = window.cpp; path = SourceFiles/window.cpp; sourceTree = ""; }; + CA56ACFB53D87637192CC9B2 /* mainwindow.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mainwindow.cpp; path = SourceFiles/mainwindow.cpp; sourceTree = ""; }; CCF75CFFB857487FB18F99F9 /* /usr/local/Qt-5.5.1/mkspecs/modules/qt_plugin_qoffscreen.pri */ = {isa = PBXFileReference; lastKnownFileType = text; path = "/usr/local/Qt-5.5.1/mkspecs/modules/qt_plugin_qoffscreen.pri"; sourceTree = ""; }; CE0D5EFE401BF9815FACE579 /* pspecific_mac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = pspecific_mac.h; path = SourceFiles/pspecific_mac.h; sourceTree = ""; }; CE7FFE194127BD789A2C877A /* moc_confirmbox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = moc_confirmbox.cpp; path = GeneratedFiles/Debug/moc_confirmbox.cpp; sourceTree = ""; }; @@ -1148,8 +1148,8 @@ 3BE70E2A82DC2BF402165ED5 /* sysbuttons.h */, 2BB2A1BB8DB0993F78F4E3C7 /* title.cpp */, 4D504A849F15EB58E53A4E5F /* title.h */, - CA56ACFB53D87637192CC9B2 /* window.cpp */, - 301BB513F2F5D447B3BF22DF /* window.h */, + CA56ACFB53D87637192CC9B2 /* mainwindow.cpp */, + 301BB513F2F5D447B3BF22DF /* mainwindow.h */, 24F7D3E789E91B10E422C116 /* config.h */, C913E6A1001E07EE7C13CE93 /* style.h */, ); @@ -1327,7 +1327,7 @@ 93AFE74928551FC3D7E8390B /* moc_settingswidget.cpp */, B88236FC554B694F618D848C /* moc_sysbuttons.cpp */, 1080B6D395843B8F76A2E45E /* moc_title.cpp */, - 6B46A0EE3C3B9D3B5A24946E /* moc_window.cpp */, + 6B46A0EE3C3B9D3B5A24946E /* moc_mainwindow.cpp */, 924D4939FD169BB4B8AEB1C9 /* moc_facade.cpp */, B714EA71A09A832FAA846A0A /* moc_connection.cpp */, 2C540BAEABD7F9B5FA11008E /* moc_dcenter.cpp */, @@ -1707,7 +1707,7 @@ 5CE57D44510AB2A11886AB52 /* title.cpp in Compile Sources */, 077A4AF81CA41C38002188D2 /* connection_auto.cpp in Compile Sources */, 4078D5D614EB3ECF7F1848C7 /* basic_types.cpp in Compile Sources */, - 68FFEB7CA30BF0149161B809 /* window.cpp in Compile Sources */, + 68FFEB7CA30BF0149161B809 /* mainwindow.cpp in Compile Sources */, 0CB7DE9A54CC9BF86FB7B5CA /* facade.cpp in Compile Sources */, DF259E9677CC63AF8754032B /* connection.cpp in Compile Sources */, 074FCB9119D36E60004C6EB2 /* moc_popupmenu.cpp in Compile Sources */, @@ -1793,7 +1793,7 @@ FD2FE0C564A7389A2E609EC7 /* moc_sysbuttons.cpp in Compile Sources */, E97B3CFAB59B49BACFFC5F7C /* moc_title.cpp in Compile Sources */, 07D8510819F8340A00623D75 /* moc_usernamebox.cpp in Compile Sources */, - 9A0D5DDC7816FC2538EB6A96 /* moc_window.cpp in Compile Sources */, + 9A0D5DDC7816FC2538EB6A96 /* moc_mainwindow.cpp in Compile Sources */, 06EABCC49D2EEE4076322BE7 /* moc_facade.cpp in Compile Sources */, 0755AEDE1AD12A80004D738A /* moc_intropwdcheck.cpp in Compile Sources */, 07DE92AA1AA4928200A18F6F /* moc_autolockbox.cpp in Compile Sources */, diff --git a/Telegram/Telegram.xcodeproj/qt_preprocess.mak b/Telegram/Telegram.xcodeproj/qt_preprocess.mak index 727c563f48..4e0c0fabcf 100644 --- a/Telegram/Telegram.xcodeproj/qt_preprocess.mak +++ b/Telegram/Telegram.xcodeproj/qt_preprocess.mak @@ -56,7 +56,7 @@ compilers: GeneratedFiles/qrc_telegram.cpp\ GeneratedFiles/Debug/moc_sysbuttons.cpp\ GeneratedFiles/Debug/moc_title.cpp\ GeneratedFiles/Debug/moc_basic_types.cpp\ - GeneratedFiles/Debug/moc_window.cpp\ + GeneratedFiles/Debug/moc_mainwindow.cpp\ GeneratedFiles/Debug/moc_facade.cpp\ GeneratedFiles/Debug/moc_connection.cpp\ GeneratedFiles/Debug/moc_connection_abstract.cpp\ @@ -181,7 +181,7 @@ compiler_moc_header_make_all: GeneratedFiles/Debug/moc_apiwrap.cpp\ GeneratedFiles/Debug/moc_sysbuttons.cpp\ GeneratedFiles/Debug/moc_title.cpp\ GeneratedFiles/Debug/moc_basic_types.cpp\ - GeneratedFiles/Debug/moc_window.cpp\ + GeneratedFiles/Debug/moc_mainwindow.cpp\ GeneratedFiles/Debug/moc_facade.cpp\ GeneratedFiles/Debug/moc_connection.cpp\ GeneratedFiles/Debug/moc_connection_abstract.cpp\ @@ -249,7 +249,7 @@ compiler_moc_header_clean: GeneratedFiles/Debug/moc_sysbuttons.cpp\ GeneratedFiles/Debug/moc_title.cpp\ GeneratedFiles/Debug/moc_basic_types.cpp\ - GeneratedFiles/Debug/moc_window.cpp\ + GeneratedFiles/Debug/moc_mainwindow.cpp\ GeneratedFiles/Debug/moc_facade.cpp\ GeneratedFiles/Debug/moc_connection.cpp\ GeneratedFiles/Debug/moc_connection_abstract.cpp\ @@ -294,7 +294,7 @@ compiler_moc_header_clean: GeneratedFiles/Debug/moc_intropwdcheck.cpp\ GeneratedFiles/Debug/moc_introsignup.cpp\ GeneratedFiles/Debug/moc_pspecific_mac.cpp -GeneratedFiles/Debug/moc_apiwrap.cpp: SourceFiles/basic_types.h \ +GeneratedFiles/Debug/moc_apiwrap.cpp: SourceFiles/core/basic_types.h \ SourceFiles/logs.h \ SourceFiles/apiwrap.h /usr/local/Qt-5.5.1/bin/moc $(DEFINES) -D__APPLE__ -D__GNUC__=4 -I/usr/local/Qt-5.5.1/mkspecs/macx-clang -I. -I/usr/local/Qt-5.5.1/include/QtGui/5.5.1/QtGui -I/usr/local/Qt-5.5.1/include/QtCore/5.5.1/QtCore -I/usr/local/Qt-5.5.1/include -I./SourceFiles -I./GeneratedFiles -I../../Libraries/lzma/C -I../../Libraries/libexif-0.6.20 -I/usr/local/Qt-5.5.1/include -I/usr/local/Qt-5.5.1/include/QtMultimedia -I/usr/local/Qt-5.5.1/include/QtWidgets -I/usr/local/Qt-5.5.1/include/QtNetwork -I/usr/local/Qt-5.5.1/include/QtGui -I/usr/local/Qt-5.5.1/include/QtCore -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/backward -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/5.1/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include SourceFiles/apiwrap.h -o GeneratedFiles/Debug/moc_apiwrap.cpp @@ -302,12 +302,12 @@ GeneratedFiles/Debug/moc_apiwrap.cpp: SourceFiles/basic_types.h \ GeneratedFiles/Debug/moc_application.cpp: ../../Libraries/QtStatic/qtbase/include/QtNetwork/QLocalSocket \ ../../Libraries/QtStatic/qtbase/include/QtNetwork/QLocalServer \ ../../Libraries/QtStatic/qtbase/include/QtNetwork/QNetworkReply \ - SourceFiles/window.h \ + SourceFiles/mainwindow.h \ SourceFiles/title.h \ ../../Libraries/QtStatic/qtbase/include/QtWidgets/QWidget \ SourceFiles/sysbuttons.h \ SourceFiles/ui/animation.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QTimer \ @@ -323,7 +323,7 @@ GeneratedFiles/Debug/moc_application.cpp: ../../Libraries/QtStatic/qtbase/includ SourceFiles/application.h /usr/local/Qt-5.5.1/bin/moc $(DEFINES) -D__APPLE__ -D__GNUC__=4 -I/usr/local/Qt-5.5.1/mkspecs/macx-clang -I. -I/usr/local/Qt-5.5.1/include/QtGui/5.5.1/QtGui -I/usr/local/Qt-5.5.1/include/QtCore/5.5.1/QtCore -I/usr/local/Qt-5.5.1/include -I./SourceFiles -I./GeneratedFiles -I../../Libraries/lzma/C -I../../Libraries/libexif-0.6.20 -I/usr/local/Qt-5.5.1/include -I/usr/local/Qt-5.5.1/include/QtMultimedia -I/usr/local/Qt-5.5.1/include/QtWidgets -I/usr/local/Qt-5.5.1/include/QtNetwork -I/usr/local/Qt-5.5.1/include/QtGui -I/usr/local/Qt-5.5.1/include/QtCore -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/backward -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/5.1/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include SourceFiles/application.h -o GeneratedFiles/Debug/moc_application.cpp -GeneratedFiles/Debug/moc_audio.cpp: SourceFiles/basic_types.h \ +GeneratedFiles/Debug/moc_audio.cpp: SourceFiles/core/basic_types.h \ SourceFiles/audio.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ @@ -331,7 +331,7 @@ GeneratedFiles/Debug/moc_audio.cpp: SourceFiles/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtGui/QColor /usr/local/Qt-5.5.1/bin/moc $(DEFINES) -D__APPLE__ -D__GNUC__=4 -I/usr/local/Qt-5.5.1/mkspecs/macx-clang -I. -I/usr/local/Qt-5.5.1/include/QtGui/5.5.1/QtGui -I/usr/local/Qt-5.5.1/include/QtCore/5.5.1/QtCore -I/usr/local/Qt-5.5.1/include -I./SourceFiles -I./GeneratedFiles -I../../Libraries/lzma/C -I../../Libraries/libexif-0.6.20 -I/usr/local/Qt-5.5.1/include -I/usr/local/Qt-5.5.1/include/QtMultimedia -I/usr/local/Qt-5.5.1/include/QtWidgets -I/usr/local/Qt-5.5.1/include/QtNetwork -I/usr/local/Qt-5.5.1/include/QtGui -I/usr/local/Qt-5.5.1/include/QtCore -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/backward -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/5.1/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include SourceFiles/audio.h -o GeneratedFiles/Debug/moc_audio.cpp -GeneratedFiles/Debug/moc_autoupdater.cpp: SourceFiles/basic_types.h \ +GeneratedFiles/Debug/moc_autoupdater.cpp: SourceFiles/core/basic_types.h \ SourceFiles/autoupdater.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ @@ -393,7 +393,7 @@ GeneratedFiles/Debug/moc_mainwidget.cpp: ../../Libraries/QtStatic/qtbase/include SourceFiles/ui/twidget.h \ SourceFiles/ui/flatcheckbox.h \ SourceFiles/ui/animation.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QTimer \ @@ -417,7 +417,7 @@ GeneratedFiles/Debug/moc_settingswidget.cpp: SourceFiles/ui/flatbutton.h \ SourceFiles/ui/twidget.h \ SourceFiles/ui/flatcheckbox.h \ SourceFiles/ui/animation.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QTimer \ @@ -431,7 +431,7 @@ GeneratedFiles/Debug/moc_settingswidget.cpp: SourceFiles/ui/flatbutton.h \ GeneratedFiles/Debug/moc_sysbuttons.cpp: ../../Libraries/QtStatic/qtbase/include/QtWidgets/QWidget \ SourceFiles/ui/animation.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QTimer \ @@ -445,7 +445,7 @@ GeneratedFiles/Debug/moc_sysbuttons.cpp: ../../Libraries/QtStatic/qtbase/include GeneratedFiles/Debug/moc_title.cpp: ../../Libraries/QtStatic/qtbase/include/QtWidgets/QWidget \ SourceFiles/sysbuttons.h \ SourceFiles/ui/animation.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QTimer \ @@ -455,18 +455,18 @@ GeneratedFiles/Debug/moc_title.cpp: ../../Libraries/QtStatic/qtbase/include/QtWi SourceFiles/title.h /usr/local/Qt-5.5.1/bin/moc $(DEFINES) -D__APPLE__ -D__GNUC__=4 -I/usr/local/Qt-5.5.1/mkspecs/macx-clang -I. -I/usr/local/Qt-5.5.1/include/QtGui/5.5.1/QtGui -I/usr/local/Qt-5.5.1/include/QtCore/5.5.1/QtCore -I/usr/local/Qt-5.5.1/include -I./SourceFiles -I./GeneratedFiles -I../../Libraries/lzma/C -I../../Libraries/libexif-0.6.20 -I/usr/local/Qt-5.5.1/include -I/usr/local/Qt-5.5.1/include/QtMultimedia -I/usr/local/Qt-5.5.1/include/QtWidgets -I/usr/local/Qt-5.5.1/include/QtNetwork -I/usr/local/Qt-5.5.1/include/QtGui -I/usr/local/Qt-5.5.1/include/QtCore -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/backward -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/5.1/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include SourceFiles/title.h -o GeneratedFiles/Debug/moc_title.cpp -GeneratedFiles/Debug/moc_basic_types.cpp: SourceFiles/basic_types.h \ +GeneratedFiles/Debug/moc_basic_types.cpp: SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtWidgets/QWidget \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QTimer - /usr/local/Qt-5.5.1/bin/moc $(DEFINES) -D__APPLE__ -D__GNUC__=4 -I/usr/local/Qt-5.5.1/mkspecs/macx-clang -I. -I/usr/local/Qt-5.5.1/include/QtGui/5.5.1/QtGui -I/usr/local/Qt-5.5.1/include/QtCore/5.5.1/QtCore -I/usr/local/Qt-5.5.1/include -I./SourceFiles -I./GeneratedFiles -I../../Libraries/lzma/C -I../../Libraries/libexif-0.6.20 -I/usr/local/Qt-5.5.1/include -I/usr/local/Qt-5.5.1/include/QtMultimedia -I/usr/local/Qt-5.5.1/include/QtWidgets -I/usr/local/Qt-5.5.1/include/QtNetwork -I/usr/local/Qt-5.5.1/include/QtGui -I/usr/local/Qt-5.5.1/include/QtCore -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/backward -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/5.1/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include SourceFiles/basic_types.h -o GeneratedFiles/Debug/moc_basic_types.cpp + /usr/local/Qt-5.5.1/bin/moc $(DEFINES) -D__APPLE__ -D__GNUC__=4 -I/usr/local/Qt-5.5.1/mkspecs/macx-clang -I. -I/usr/local/Qt-5.5.1/include/QtGui/5.5.1/QtGui -I/usr/local/Qt-5.5.1/include/QtCore/5.5.1/QtCore -I/usr/local/Qt-5.5.1/include -I./SourceFiles -I./GeneratedFiles -I../../Libraries/lzma/C -I../../Libraries/libexif-0.6.20 -I/usr/local/Qt-5.5.1/include -I/usr/local/Qt-5.5.1/include/QtMultimedia -I/usr/local/Qt-5.5.1/include/QtWidgets -I/usr/local/Qt-5.5.1/include/QtNetwork -I/usr/local/Qt-5.5.1/include/QtGui -I/usr/local/Qt-5.5.1/include/QtCore -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/backward -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/5.1/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include SourceFiles/core/basic_types.h -o GeneratedFiles/Debug/moc_basic_types.cpp -GeneratedFiles/Debug/moc_window.cpp: SourceFiles/title.h \ +GeneratedFiles/Debug/moc_mainwindow.cpp: SourceFiles/title.h \ ../../Libraries/QtStatic/qtbase/include/QtWidgets/QWidget \ SourceFiles/sysbuttons.h \ SourceFiles/ui/animation.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QTimer \ @@ -481,8 +481,8 @@ GeneratedFiles/Debug/moc_window.cpp: SourceFiles/title.h \ SourceFiles/pspecific_winrt.h \ SourceFiles/passcodewidget.h \ SourceFiles/ui/boxshadow.h \ - SourceFiles/window.h - /usr/local/Qt-5.5.1/bin/moc $(DEFINES) -D__APPLE__ -D__GNUC__=4 -I/usr/local/Qt-5.5.1/mkspecs/macx-clang -I. -I/usr/local/Qt-5.5.1/include/QtGui/5.5.1/QtGui -I/usr/local/Qt-5.5.1/include/QtCore/5.5.1/QtCore -I/usr/local/Qt-5.5.1/include -I./SourceFiles -I./GeneratedFiles -I../../Libraries/lzma/C -I../../Libraries/libexif-0.6.20 -I/usr/local/Qt-5.5.1/include -I/usr/local/Qt-5.5.1/include/QtMultimedia -I/usr/local/Qt-5.5.1/include/QtWidgets -I/usr/local/Qt-5.5.1/include/QtNetwork -I/usr/local/Qt-5.5.1/include/QtGui -I/usr/local/Qt-5.5.1/include/QtCore -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/backward -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/5.1/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include SourceFiles/window.h -o GeneratedFiles/Debug/moc_window.cpp + SourceFiles/mainwindow.h + /usr/local/Qt-5.5.1/bin/moc $(DEFINES) -D__APPLE__ -D__GNUC__=4 -I/usr/local/Qt-5.5.1/mkspecs/macx-clang -I. -I/usr/local/Qt-5.5.1/include/QtGui/5.5.1/QtGui -I/usr/local/Qt-5.5.1/include/QtCore/5.5.1/QtCore -I/usr/local/Qt-5.5.1/include -I./SourceFiles -I./GeneratedFiles -I../../Libraries/lzma/C -I../../Libraries/libexif-0.6.20 -I/usr/local/Qt-5.5.1/include -I/usr/local/Qt-5.5.1/include/QtMultimedia -I/usr/local/Qt-5.5.1/include/QtWidgets -I/usr/local/Qt-5.5.1/include/QtNetwork -I/usr/local/Qt-5.5.1/include/QtGui -I/usr/local/Qt-5.5.1/include/QtCore -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/backward -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/5.1/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include SourceFiles/mainwindow.h -o GeneratedFiles/Debug/moc_mainwindow.cpp GeneratedFiles/Debug/moc_facade.cpp: SourceFiles/mtproto/session.h \ SourceFiles/mtproto/connection.h \ @@ -491,7 +491,7 @@ GeneratedFiles/Debug/moc_facade.cpp: SourceFiles/mtproto/session.h \ SourceFiles/mtproto/connection_http.h \ SourceFiles/mtproto/connection_tcp.h \ SourceFiles/mtproto/core_types.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ SourceFiles/mtproto/scheme_auto.h \ @@ -504,7 +504,7 @@ GeneratedFiles/Debug/moc_facade.cpp: SourceFiles/mtproto/session.h \ /usr/local/Qt-5.5.1/bin/moc $(DEFINES) -D__APPLE__ -D__GNUC__=4 -I/usr/local/Qt-5.5.1/mkspecs/macx-clang -I. -I/usr/local/Qt-5.5.1/include/QtGui/5.5.1/QtGui -I/usr/local/Qt-5.5.1/include/QtCore/5.5.1/QtCore -I/usr/local/Qt-5.5.1/include -I./SourceFiles -I./GeneratedFiles -I../../Libraries/lzma/C -I../../Libraries/libexif-0.6.20 -I/usr/local/Qt-5.5.1/include -I/usr/local/Qt-5.5.1/include/QtMultimedia -I/usr/local/Qt-5.5.1/include/QtWidgets -I/usr/local/Qt-5.5.1/include/QtNetwork -I/usr/local/Qt-5.5.1/include/QtGui -I/usr/local/Qt-5.5.1/include/QtCore -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/backward -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/5.1/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include SourceFiles/mtproto/facade.h -o GeneratedFiles/Debug/moc_facade.cpp GeneratedFiles/Debug/moc_connection.cpp: SourceFiles/mtproto/core_types.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ SourceFiles/mtproto/scheme_auto.h \ @@ -514,7 +514,7 @@ GeneratedFiles/Debug/moc_connection.cpp: SourceFiles/mtproto/core_types.h \ /usr/local/Qt-5.5.1/bin/moc $(DEFINES) -D__APPLE__ -D__GNUC__=4 -I/usr/local/Qt-5.5.1/mkspecs/macx-clang -I. -I/usr/local/Qt-5.5.1/include/QtGui/5.5.1/QtGui -I/usr/local/Qt-5.5.1/include/QtCore/5.5.1/QtCore -I/usr/local/Qt-5.5.1/include -I./SourceFiles -I./GeneratedFiles -I../../Libraries/lzma/C -I../../Libraries/libexif-0.6.20 -I/usr/local/Qt-5.5.1/include -I/usr/local/Qt-5.5.1/include/QtMultimedia -I/usr/local/Qt-5.5.1/include/QtWidgets -I/usr/local/Qt-5.5.1/include/QtNetwork -I/usr/local/Qt-5.5.1/include/QtGui -I/usr/local/Qt-5.5.1/include/QtCore -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/backward -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/5.1/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include SourceFiles/mtproto/connection.h -o GeneratedFiles/Debug/moc_connection.cpp GeneratedFiles/Debug/moc_connection_abstract.cpp: SourceFiles/mtproto/core_types.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ SourceFiles/mtproto/scheme_auto.h \ @@ -524,7 +524,7 @@ GeneratedFiles/Debug/moc_connection_abstract.cpp: SourceFiles/mtproto/core_types /usr/local/Qt-5.5.1/bin/moc $(DEFINES) -D__APPLE__ -D__GNUC__=4 -I/usr/local/Qt-5.5.1/mkspecs/macx-clang -I. -I/usr/local/Qt-5.5.1/include/QtGui/5.5.1/QtGui -I/usr/local/Qt-5.5.1/include/QtCore/5.5.1/QtCore -I/usr/local/Qt-5.5.1/include -I./SourceFiles -I./GeneratedFiles -I../../Libraries/lzma/C -I../../Libraries/libexif-0.6.20 -I/usr/local/Qt-5.5.1/include -I/usr/local/Qt-5.5.1/include/QtMultimedia -I/usr/local/Qt-5.5.1/include/QtWidgets -I/usr/local/Qt-5.5.1/include/QtNetwork -I/usr/local/Qt-5.5.1/include/QtGui -I/usr/local/Qt-5.5.1/include/QtCore -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/backward -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/5.1/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include SourceFiles/mtproto/connection_abstract.h -o GeneratedFiles/Debug/moc_connection_abstract.cpp GeneratedFiles/Debug/moc_connection_auto.cpp: SourceFiles/mtproto/core_types.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ SourceFiles/mtproto/scheme_auto.h \ @@ -534,7 +534,7 @@ GeneratedFiles/Debug/moc_connection_auto.cpp: SourceFiles/mtproto/core_types.h \ /usr/local/Qt-5.5.1/bin/moc $(DEFINES) -D__APPLE__ -D__GNUC__=4 -I/usr/local/Qt-5.5.1/mkspecs/macx-clang -I. -I/usr/local/Qt-5.5.1/include/QtGui/5.5.1/QtGui -I/usr/local/Qt-5.5.1/include/QtCore/5.5.1/QtCore -I/usr/local/Qt-5.5.1/include -I./SourceFiles -I./GeneratedFiles -I../../Libraries/lzma/C -I../../Libraries/libexif-0.6.20 -I/usr/local/Qt-5.5.1/include -I/usr/local/Qt-5.5.1/include/QtMultimedia -I/usr/local/Qt-5.5.1/include/QtWidgets -I/usr/local/Qt-5.5.1/include/QtNetwork -I/usr/local/Qt-5.5.1/include/QtGui -I/usr/local/Qt-5.5.1/include/QtCore -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/backward -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/5.1/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include SourceFiles/mtproto/connection_auto.h -o GeneratedFiles/Debug/moc_connection_auto.cpp GeneratedFiles/Debug/moc_connection_http.cpp: SourceFiles/mtproto/core_types.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ SourceFiles/mtproto/scheme_auto.h \ @@ -544,7 +544,7 @@ GeneratedFiles/Debug/moc_connection_http.cpp: SourceFiles/mtproto/core_types.h \ /usr/local/Qt-5.5.1/bin/moc $(DEFINES) -D__APPLE__ -D__GNUC__=4 -I/usr/local/Qt-5.5.1/mkspecs/macx-clang -I. -I/usr/local/Qt-5.5.1/include/QtGui/5.5.1/QtGui -I/usr/local/Qt-5.5.1/include/QtCore/5.5.1/QtCore -I/usr/local/Qt-5.5.1/include -I./SourceFiles -I./GeneratedFiles -I../../Libraries/lzma/C -I../../Libraries/libexif-0.6.20 -I/usr/local/Qt-5.5.1/include -I/usr/local/Qt-5.5.1/include/QtMultimedia -I/usr/local/Qt-5.5.1/include/QtWidgets -I/usr/local/Qt-5.5.1/include/QtNetwork -I/usr/local/Qt-5.5.1/include/QtGui -I/usr/local/Qt-5.5.1/include/QtCore -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/backward -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/5.1/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include SourceFiles/mtproto/connection_http.h -o GeneratedFiles/Debug/moc_connection_http.cpp GeneratedFiles/Debug/moc_connection_tcp.cpp: SourceFiles/mtproto/core_types.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ SourceFiles/mtproto/scheme_auto.h \ @@ -565,7 +565,7 @@ GeneratedFiles/Debug/moc_session.cpp: SourceFiles/mtproto/connection.h \ SourceFiles/mtproto/connection_http.h \ SourceFiles/mtproto/connection_tcp.h \ SourceFiles/mtproto/core_types.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ SourceFiles/mtproto/scheme_auto.h \ @@ -576,7 +576,7 @@ GeneratedFiles/Debug/moc_session.cpp: SourceFiles/mtproto/connection.h \ SourceFiles/mtproto/session.h /usr/local/Qt-5.5.1/bin/moc $(DEFINES) -D__APPLE__ -D__GNUC__=4 -I/usr/local/Qt-5.5.1/mkspecs/macx-clang -I. -I/usr/local/Qt-5.5.1/include/QtGui/5.5.1/QtGui -I/usr/local/Qt-5.5.1/include/QtCore/5.5.1/QtCore -I/usr/local/Qt-5.5.1/include -I./SourceFiles -I./GeneratedFiles -I../../Libraries/lzma/C -I../../Libraries/libexif-0.6.20 -I/usr/local/Qt-5.5.1/include -I/usr/local/Qt-5.5.1/include/QtMultimedia -I/usr/local/Qt-5.5.1/include/QtWidgets -I/usr/local/Qt-5.5.1/include/QtNetwork -I/usr/local/Qt-5.5.1/include/QtGui -I/usr/local/Qt-5.5.1/include/QtCore -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1/backward -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/5.1/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include SourceFiles/mtproto/session.h -o GeneratedFiles/Debug/moc_session.cpp -GeneratedFiles/Debug/moc_animation.cpp: SourceFiles/basic_types.h \ +GeneratedFiles/Debug/moc_animation.cpp: SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QTimer \ @@ -604,7 +604,7 @@ GeneratedFiles/Debug/moc_countryinput.cpp: ../../Libraries/QtStatic/qtbase/inclu SourceFiles/ui/flatinput.h \ ../../Libraries/QtStatic/qtbase/include/QtWidgets/QLineEdit \ SourceFiles/ui/animation.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QTimer \ @@ -624,7 +624,7 @@ GeneratedFiles/Debug/moc_flatbutton.cpp: SourceFiles/ui/button.h \ SourceFiles/ui/twidget.h \ SourceFiles/ui/flatcheckbox.h \ SourceFiles/ui/animation.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QTimer \ @@ -646,7 +646,7 @@ GeneratedFiles/Debug/moc_flatinput.cpp: ../../Libraries/QtStatic/qtbase/include/ GeneratedFiles/style_classes.h \ GeneratedFiles/style_auto.h \ SourceFiles/ui/animation.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QTimer \ @@ -665,7 +665,7 @@ GeneratedFiles/Debug/moc_flattextarea.cpp: ../../Libraries/QtStatic/qtbase/inclu GeneratedFiles/style_classes.h \ GeneratedFiles/style_auto.h \ SourceFiles/ui/animation.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QTimer \ @@ -721,7 +721,7 @@ GeneratedFiles/Debug/moc_connectionbox.cpp: SourceFiles/boxes/abstractbox.h \ GeneratedFiles/style_classes.h \ GeneratedFiles/style_auto.h \ SourceFiles/ui/animation.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QTimer \ @@ -742,7 +742,7 @@ GeneratedFiles/Debug/moc_downloadpathbox.cpp: SourceFiles/boxes/abstractbox.h \ GeneratedFiles/style_classes.h \ GeneratedFiles/style_auto.h \ SourceFiles/ui/animation.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QTimer \ @@ -799,7 +799,7 @@ GeneratedFiles/Debug/moc_introwidget.cpp: ../../Libraries/QtStatic/qtbase/includ SourceFiles/ui/twidget.h \ SourceFiles/ui/flatcheckbox.h \ SourceFiles/ui/animation.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QTimer \ @@ -816,7 +816,7 @@ GeneratedFiles/Debug/moc_introcode.cpp: ../../Libraries/QtStatic/qtbase/include/ SourceFiles/ui/twidget.h \ SourceFiles/ui/flatcheckbox.h \ SourceFiles/ui/animation.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QTimer \ @@ -836,7 +836,7 @@ GeneratedFiles/Debug/moc_introphone.cpp: ../../Libraries/QtStatic/qtbase/include SourceFiles/ui/twidget.h \ SourceFiles/ui/flatcheckbox.h \ SourceFiles/ui/animation.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QTimer \ @@ -860,7 +860,7 @@ GeneratedFiles/Debug/moc_intropwdcheck.cpp: ../../Libraries/QtStatic/qtbase/incl SourceFiles/ui/twidget.h \ SourceFiles/ui/flatcheckbox.h \ SourceFiles/ui/animation.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QTimer \ @@ -884,7 +884,7 @@ GeneratedFiles/Debug/moc_introsignup.cpp: ../../Libraries/QtStatic/qtbase/includ SourceFiles/ui/twidget.h \ SourceFiles/ui/flatcheckbox.h \ SourceFiles/ui/animation.h \ - SourceFiles/basic_types.h \ + SourceFiles/core/basic_types.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QReadWriteLock \ SourceFiles/logs.h \ ../../Libraries/QtStatic/qtbase/include/QtCore/QTimer \