diff --git a/Telegram/SourceFiles/application.cpp b/Telegram/SourceFiles/application.cpp index d9df42f09c..f57ab30dfb 100644 --- a/Telegram/SourceFiles/application.cpp +++ b/Telegram/SourceFiles/application.cpp @@ -445,7 +445,7 @@ void Application::onSwitchDebugMode() { f.write("1"); f.close(); } - App::wnd()->hideLayer(); + Ui::hideLayer(); } } diff --git a/Telegram/SourceFiles/boxes/aboutbox.cpp b/Telegram/SourceFiles/boxes/aboutbox.cpp index ee2db425d9..a6bad679e4 100644 --- a/Telegram/SourceFiles/boxes/aboutbox.cpp +++ b/Telegram/SourceFiles/boxes/aboutbox.cpp @@ -84,7 +84,7 @@ void AboutBox::onVersion() { App::app()->clipboard()->setText(url); - App::showLayer(new InformBox("The link to the current private beta version of Telegram Desktop was copied to the clipboard.")); + Ui::showLayer(new InformBox("The link to the current private beta version of Telegram Desktop was copied to the clipboard.")); } else { QDesktopServices::openUrl(qsl("https://desktop.telegram.org/?_hash=changelog")); } diff --git a/Telegram/SourceFiles/boxes/addcontactbox.cpp b/Telegram/SourceFiles/boxes/addcontactbox.cpp index 05fe432e51..732997d75a 100644 --- a/Telegram/SourceFiles/boxes/addcontactbox.cpp +++ b/Telegram/SourceFiles/boxes/addcontactbox.cpp @@ -236,7 +236,7 @@ void AddContactBox::onImportDone(const MTPcontacts_ImportedContacts &res) { } if (uid) { App::main()->addNewContact(uid); - App::wnd()->hideLayer(); + Ui::hideLayer(); } else { _save.hide(); _first.hide(); @@ -336,7 +336,7 @@ void NewGroupBox::resizeEvent(QResizeEvent *e) { } void NewGroupBox::onNext() { - App::wnd()->replaceLayer(new GroupInfoBox(_group.checked() ? CreatingGroupGroup : CreatingGroupChannel, true)); + Ui::showLayer(new GroupInfoBox(_group.checked() ? CreatingGroupGroup : CreatingGroupChannel, true), KeepOtherLayers); } GroupInfoBox::GroupInfoBox(CreatingGroupType creating, bool fromTypeChoose) : AbstractBox(), @@ -498,7 +498,7 @@ void GroupInfoBox::onNext() { return; } if (_creating == CreatingGroupGroup) { - App::wnd()->replaceLayer(new ContactsBox(title, _photoBig)); + Ui::showLayer(new ContactsBox(title, _photoBig), KeepOtherLayers); } else { bool mega = false; int32 flags = mega ? MTPchannels_CreateChannel::flag_megagroup : MTPchannels_CreateChannel::flag_broadcast; @@ -551,7 +551,7 @@ void GroupInfoBox::exportDone(const MTPExportedChatInvite &result) { if (result.type() == mtpc_chatInviteExported) { _createdChannel->invitationUrl = qs(result.c_chatInviteExported().vlink); } - App::wnd()->showLayer(new SetupChannelBox(_createdChannel)); + Ui::showLayer(new SetupChannelBox(_createdChannel)); } void GroupInfoBox::onDescriptionResized() { @@ -595,7 +595,7 @@ void GroupInfoBox::onPhoto() { } PhotoCropBox *box = new PhotoCropBox(img, (_creating == CreatingGroupChannel) ? peerFromChannel(0) : peerFromChat(0)); connect(box, SIGNAL(ready(const QImage&)), this, SLOT(onPhotoReady(const QImage&))); - App::wnd()->replaceLayer(box); + Ui::showLayer(box, KeepOtherLayers); } void GroupInfoBox::onPhotoReady(const QImage &img) { @@ -787,7 +787,7 @@ bool SetupChannelBox::animStep_goodFade(float64 ms) { void SetupChannelBox::closePressed() { if (!_existing) { - App::wnd()->showLayer(new ContactsBox(_channel)); + Ui::showLayer(new ContactsBox(_channel)); } } @@ -872,7 +872,7 @@ void SetupChannelBox::onPrivacyChange() { if (_public.checked()) { if (_tooMuchUsernames) { _private.setChecked(true); - App::wnd()->replaceLayer(new InformBox(lang(lng_channels_too_much_public))); + Ui::showLayer(new InformBox(lang(lng_channels_too_much_public)), KeepOtherLayers); return; } _link.show(); @@ -933,7 +933,7 @@ bool SetupChannelBox::onCheckFail(const RPCError &error) { QString err(error.type()); if (err == "CHANNELS_ADMIN_PUBLIC_TOO_MUCH") { if (_existing) { - App::wnd()->showLayer(new InformBox(lang(lng_channels_too_much_public_existing))); + Ui::showLayer(new InformBox(lang(lng_channels_too_much_public_existing))); } else { _tooMuchUsernames = true; _private.setChecked(true); @@ -961,7 +961,7 @@ bool SetupChannelBox::onFirstCheckFail(const RPCError &error) { QString err(error.type()); if (err == "CHANNELS_ADMIN_PUBLIC_TOO_MUCH") { if (_existing) { - App::wnd()->showLayer(new InformBox(lang(lng_channels_too_much_public_existing))); + Ui::showLayer(new InformBox(lang(lng_channels_too_much_public_existing))); } else { _tooMuchUsernames = true; _private.setChecked(true); @@ -1269,7 +1269,7 @@ void EditChannelBox::onSave() { } void EditChannelBox::onPublicLink() { - App::wnd()->replaceLayer(new SetupChannelBox(_channel, true)); + Ui::showLayer(new SetupChannelBox(_channel, true), KeepOtherLayers); } void EditChannelBox::saveDescription() { diff --git a/Telegram/SourceFiles/boxes/confirmbox.cpp b/Telegram/SourceFiles/boxes/confirmbox.cpp index 69fbe86b08..8fad31da68 100644 --- a/Telegram/SourceFiles/boxes/confirmbox.cpp +++ b/Telegram/SourceFiles/boxes/confirmbox.cpp @@ -94,7 +94,7 @@ void ConfirmBox::mouseReleaseEvent(QMouseEvent *e) { _lastMousePos = e->globalPos(); updateHover(); if (textlnkOver() && textlnkOver() == textlnkDown()) { - App::wnd()->hideLayer(); + Ui::hideLayer(); textlnkOver()->onClick(e->button()); } textlnkDown(TextLinkPtr()); @@ -184,7 +184,7 @@ void ConfirmLinkBox::onOpenLink() { } else { TextLink(_url).onClick(Qt::LeftButton); } - App::wnd()->hideLayer(); + Ui::hideLayer(); } MaxInviteBox::MaxInviteBox(const QString &link) : AbstractBox(st::boxWidth), diff --git a/Telegram/SourceFiles/boxes/contactsbox.cpp b/Telegram/SourceFiles/boxes/contactsbox.cpp index a7827d193b..8a7c16c530 100644 --- a/Telegram/SourceFiles/boxes/contactsbox.cpp +++ b/Telegram/SourceFiles/boxes/contactsbox.cpp @@ -228,7 +228,7 @@ void ContactsInner::onAddBot() { } else { App::main()->addParticipants(_addToPeer, QVector(1, _bot)); } - App::wnd()->hideLayer(); + Ui::hideLayer(); App::main()->showPeerHistory(_addToPeer->id, ShowAtUnreadMsgId); } @@ -269,9 +269,9 @@ bool ContactsInner::addAdminFail(const RPCError &error, mtpRequestId req) { _addAdminRequestId = 0; if (_addAdminBox) _addAdminBox->onClose(); if (error.type() == "USERS_TOO_MUCH") { - App::wnd()->replaceLayer(new MaxInviteBox(_channel->invitationUrl)); + Ui::showLayer(new MaxInviteBox(_channel->invitationUrl), KeepOtherLayers); } else if (error.type() == "ADMINS_TOO_MUCH") { - App::wnd()->replaceLayer(new InformBox(lang(lng_channel_admins_too_much))); + Ui::showLayer(new InformBox(lang(lng_channel_admins_too_much)), KeepOtherLayers); } else { emit adminAdded(); } @@ -292,7 +292,7 @@ void ContactsInner::peerUpdated(PeerData *peer) { inited = true; } if (!_chat->canEdit()) { - App::wnd()->hideLayer(); + Ui::hideLayer(); } else if (!_chat->participants.isEmpty()) { for (ContactsData::iterator i = _contactsData.begin(), e = _contactsData.end(); i != e; ++i) { delete i.value(); @@ -741,16 +741,16 @@ void ContactsInner::chooseParticipant() { _addAdminBox = new ConfirmBox(lng_channel_admin_sure(lt_user, _addAdmin->firstName)); connect(_addAdminBox, SIGNAL(confirmed()), this, SLOT(onAddAdmin())); connect(_addAdminBox, SIGNAL(destroyed(QObject*)), this, SLOT(onNoAddAdminBox(QObject*))); - App::wnd()->replaceLayer(_addAdminBox); + Ui::showLayer(_addAdminBox, KeepOtherLayers); } else if (bot() && (peer->isChat() || peer->isMegagroup())) { _addToPeer = peer; ConfirmBox *box = new ConfirmBox(lng_bot_sure_invite(lt_group, peer->name)); connect(box, SIGNAL(confirmed()), this, SLOT(onAddBot())); - App::wnd()->replaceLayer(box); + Ui::showLayer(box, KeepOtherLayers); } else { App::wnd()->hideSettings(true); App::main()->choosePeer(peer->id, ShowAtUnreadMsgId); - App::wnd()->hideLayer(); + Ui::hideLayer(); } } } @@ -1590,7 +1590,7 @@ void ContactsBox::onInvite() { App::main()->addParticipants(_inner.chat() ? (PeerData*)_inner.chat() : _inner.channel(), users); if (_inner.chat()) { - App::wnd()->hideLayer(); + Ui::hideLayer(); App::main()->showPeerHistory(_inner.chat()->id, ShowAtTheEndMsgId); } else { onClose(); @@ -1713,7 +1713,7 @@ void ContactsBox::onScroll() { } void ContactsBox::creationDone(const MTPUpdates &updates) { - App::wnd()->hideLayer(); + Ui::hideLayer(); App::main()->sentUpdatesReceived(updates); const QVector *v = 0; @@ -1749,7 +1749,7 @@ bool ContactsBox::creationFail(const RPCError &error) { _filter.showError(); return true; } else if (error.type() == "PEER_FLOOD") { - App::wnd()->replaceLayer(new InformBox(lng_cant_invite_not_contact(lt_more_info, textcmdLink(qsl("https://telegram.org/faq?_hash=can-39t-send-messages-to-non-contacts"), lang(lng_cant_more_info))))); + Ui::showLayer(new InformBox(lng_cant_invite_not_contact(lt_more_info, textcmdLink(qsl("https://telegram.org/faq?_hash=can-39t-send-messages-to-non-contacts"), lang(lng_cant_more_info)))), KeepOtherLayers); return true; } return false; @@ -1872,7 +1872,7 @@ void MembersInner::mouseReleaseEvent(QMouseEvent *e) { _kickBox = new ConfirmBox((_filter == MembersFilterRecent ? (_channel->isMegagroup() ? lng_profile_sure_kick : lng_profile_sure_kick_channel) : lng_profile_sure_kick_admin)(lt_user, _kickConfirm->firstName)); connect(_kickBox, SIGNAL(confirmed()), this, SLOT(onKickConfirm())); connect(_kickBox, SIGNAL(destroyed(QObject*)), this, SLOT(onKickBoxDestroyed(QObject*))); - App::wnd()->replaceLayer(_kickBox); + Ui::showLayer(_kickBox, KeepOtherLayers); } _kickDown = -1; } @@ -1993,7 +1993,7 @@ void MembersInner::chooseParticipant() { } if (_sel < 0 || _sel >= _rows.size()) return; if (PeerData *peer = _rows[_sel]) { - App::wnd()->hideLayer(); + Ui::hideLayer(); App::main()->showPeerProfile(peer, ShowAtUnreadMsgId); } } @@ -2199,7 +2199,7 @@ void MembersInner::membersReceived(const MTPchannels_ChannelParticipants &result bool MembersInner::membersFailed(const RPCError &error, mtpRequestId req) { if (mtpIsFlood(error)) return false; - App::wnd()->hideLayer(); + Ui::hideLayer(); return true; } @@ -2298,16 +2298,16 @@ void MembersBox::onScroll() { void MembersBox::onAdd() { if (_inner.filter() == MembersFilterRecent && _inner.channel()->count >= (_inner.channel()->isMegagroup() ? cMaxMegaGroupCount() : cMaxGroupCount())) { - App::wnd()->replaceLayer(new MaxInviteBox(_inner.channel()->invitationUrl)); + Ui::showLayer(new MaxInviteBox(_inner.channel()->invitationUrl), KeepOtherLayers); return; } ContactsBox *box = new ContactsBox(_inner.channel(), _inner.filter(), _inner.already()); if (_inner.filter() == MembersFilterRecent) { - App::wnd()->showLayer(box); + Ui::showLayer(box); } else { _addBox = box; connect(_addBox, SIGNAL(adminAdded()), this, SLOT(onAdminAdded())); - App::wnd()->replaceLayer(_addBox); + Ui::showLayer(_addBox, KeepOtherLayers); } } diff --git a/Telegram/SourceFiles/boxes/languagebox.cpp b/Telegram/SourceFiles/boxes/languagebox.cpp index c1aae95e6f..3ec7ea7eac 100644 --- a/Telegram/SourceFiles/boxes/languagebox.cpp +++ b/Telegram/SourceFiles/boxes/languagebox.cpp @@ -84,16 +84,16 @@ void LanguageBox::mousePressEvent(QMouseEvent *e) { for (int32 i = 1; i < languageCount; ++i) { LangLoaderPlain loader(qsl(":/langs/lang_") + LanguageCodes[i] + qsl(".strings"), LangLoaderRequest(lngkeys_cnt)); if (!loader.errors().isEmpty()) { - App::wnd()->showLayer(new InformBox(qsl("Lang \"") + LanguageCodes[i] + qsl("\" error :(\n\nError: ") + loader.errors())); + Ui::showLayer(new InformBox(qsl("Lang \"") + LanguageCodes[i] + qsl("\" error :(\n\nError: ") + loader.errors())); return; } else if (!loader.warnings().isEmpty()) { QString warn = loader.warnings(); if (warn.size() > 256) warn = warn.mid(0, 254) + qsl(".."); - App::wnd()->showLayer(new InformBox(qsl("Lang \"") + LanguageCodes[i] + qsl("\" warnings :(\n\nWarnings: ") + warn)); + Ui::showLayer(new InformBox(qsl("Lang \"") + LanguageCodes[i] + qsl("\" warnings :(\n\nWarnings: ") + warn)); return; } } - App::wnd()->showLayer(new InformBox(qsl("Everything seems great in all %1 languages!").arg(languageCount - 1))); + Ui::showLayer(new InformBox(qsl("Everything seems great in all %1 languages!").arg(languageCount - 1))); } } @@ -124,7 +124,7 @@ void LanguageBox::onChange() { ConfirmBox *box = new ConfirmBox(text, save, st::defaultBoxButton, cancel); connect(box, SIGNAL(confirmed()), this, SLOT(onSave())); connect(box, SIGNAL(closed()), this, SLOT(onRestore())); - App::wnd()->replaceLayer(box); + Ui::showLayer(box, KeepOtherLayers); } } } diff --git a/Telegram/SourceFiles/boxes/passcodebox.cpp b/Telegram/SourceFiles/boxes/passcodebox.cpp index b98f8957d1..45055b2cf4 100644 --- a/Telegram/SourceFiles/boxes/passcodebox.cpp +++ b/Telegram/SourceFiles/boxes/passcodebox.cpp @@ -280,7 +280,7 @@ void PasscodeBox::setPasswordDone(const MTPBool &result) { _setRequest = 0; emit reloadPassword(); ConfirmBox *box = new InformBox(lang(_reenterPasscode.isHidden() ? lng_cloud_password_removed : (_oldPasscode.isHidden() ? lng_cloud_password_was_set : lng_cloud_password_updated))); - App::wnd()->showLayer(box); + Ui::showLayer(box); } bool PasscodeBox::setPasswordFail(const RPCError &error) { @@ -308,7 +308,7 @@ bool PasscodeBox::setPasswordFail(const RPCError &error) { _recoverEmail.showError(); update(); } else if (err == "EMAIL_UNCONFIRMED") { - App::wnd()->showLayer(new InformBox(lang(lng_cloud_password_almost))); + Ui::showLayer(new InformBox(lang(lng_cloud_password_almost))); emit reloadPassword(); } else if (mtpIsFlood(error)) { if (_oldPasscode.isHidden()) return false; @@ -385,7 +385,7 @@ void PasscodeBox::onSave(bool force) { _replacedBy = new ConfirmBox(lang(lng_cloud_password_about_recover), lang(lng_cloud_password_skip_email), st::attentionBoxButton); connect(_replacedBy, SIGNAL(confirmed()), this, SLOT(onForceNoMail())); connect(_replacedBy, SIGNAL(destroyed(QObject*)), this, SLOT(onBoxDestroyed(QObject*))); - App::wnd()->replaceLayer(_replacedBy); + Ui::showLayer(_replacedBy, KeepOtherLayers); } else { QByteArray newPasswordData = pwd.isEmpty() ? QByteArray() : (_newSalt + pwd.toUtf8() + _newSalt); QByteArray newPasswordHash = pwd.isEmpty() ? QByteArray() : QByteArray(32, Qt::Uninitialized); @@ -481,7 +481,7 @@ void PasscodeBox::recover() { connect(_replacedBy, SIGNAL(reloadPassword()), this, SIGNAL(reloadPassword())); connect(_replacedBy, SIGNAL(recoveryExpired()), this, SLOT(onRecoverExpired())); connect(_replacedBy, SIGNAL(destroyed(QObject*)), this, SLOT(onBoxDestroyed(QObject*))); - App::wnd()->replaceLayer(_replacedBy); + Ui::showLayer(_replacedBy, KeepOtherLayers); } void PasscodeBox::recoverStarted(const MTPauth_PasswordRecovery &result) { @@ -583,7 +583,7 @@ void RecoverBox::codeSubmitDone(bool recover, const MTPauth_Authorization &resul _submitRequest = 0; emit reloadPassword(); - App::wnd()->showLayer(new InformBox(lang(lng_cloud_password_removed))); + Ui::showLayer(new InformBox(lang(lng_cloud_password_removed))); } bool RecoverBox::codeSubmitFail(const RPCError &error) { @@ -592,7 +592,7 @@ bool RecoverBox::codeSubmitFail(const RPCError &error) { const QString &err = error.type(); if (err == "PASSWORD_EMPTY") { emit reloadPassword(); - App::wnd()->showLayer(new InformBox(lang(lng_cloud_password_removed))); + Ui::showLayer(new InformBox(lang(lng_cloud_password_removed))); return true; } else if (err == "PASSWORD_RECOVERY_NA") { onClose(); diff --git a/Telegram/SourceFiles/boxes/sessionsbox.cpp b/Telegram/SourceFiles/boxes/sessionsbox.cpp index 8d58681ff5..6cc62071db 100644 --- a/Telegram/SourceFiles/boxes/sessionsbox.cpp +++ b/Telegram/SourceFiles/boxes/sessionsbox.cpp @@ -115,7 +115,7 @@ void SessionsInner::onTerminate() { _terminateBox = new ConfirmBox(lang(lng_settings_reset_one_sure), lang(lng_settings_reset_button), st::attentionBoxButton); connect(_terminateBox, SIGNAL(confirmed()), this, SLOT(onTerminateSure())); connect(_terminateBox, SIGNAL(destroyed(QObject*)), this, SLOT(onNoTerminateBox(QObject*))); - App::wnd()->replaceLayer(_terminateBox); + Ui::showLayer(_terminateBox, KeepOtherLayers); } } } @@ -138,7 +138,7 @@ void SessionsInner::onTerminateAll() { _terminateBox = new ConfirmBox(lang(lng_settings_reset_sure), lang(lng_settings_reset_button), st::attentionBoxButton); connect(_terminateBox, SIGNAL(confirmed()), this, SLOT(onTerminateAllSure())); connect(_terminateBox, SIGNAL(destroyed(QObject*)), this, SLOT(onNoTerminateBox(QObject*))); - App::wnd()->replaceLayer(_terminateBox); + Ui::showLayer(_terminateBox, KeepOtherLayers); } void SessionsInner::onTerminateAllSure() { diff --git a/Telegram/SourceFiles/boxes/stickersetbox.cpp b/Telegram/SourceFiles/boxes/stickersetbox.cpp index cfa0790d31..f4954e2583 100644 --- a/Telegram/SourceFiles/boxes/stickersetbox.cpp +++ b/Telegram/SourceFiles/boxes/stickersetbox.cpp @@ -67,7 +67,7 @@ void StickerSetInner::gotSet(const MTPmessages_StickerSet &set) { } if (_pack.isEmpty()) { - App::wnd()->showLayer(new InformBox(lang(lng_stickers_not_found))); + Ui::showLayer(new InformBox(lang(lng_stickers_not_found))); } else { int32 rows = _pack.size() / StickerPanPerRow + ((_pack.size() % StickerPanPerRow) ? 1 : 0); resize(st::stickersPadding.left() + StickerPanPerRow * st::stickersSize.width(), st::stickersPadding.top() + rows * st::stickersSize.height() + st::stickersPadding.bottom()); @@ -82,7 +82,7 @@ bool StickerSetInner::failedSet(const RPCError &error) { _loaded = true; - App::wnd()->showLayer(new InformBox(lang(lng_stickers_not_found))); + Ui::showLayer(new InformBox(lang(lng_stickers_not_found))); return true; } @@ -115,13 +115,13 @@ void StickerSetInner::installDone(const MTPBool &result) { cSetStickersHash(stickersCountHash()); Local::writeStickers(); emit installed(_setId); - App::wnd()->hideLayer(); + Ui::hideLayer(); } bool StickerSetInner::installFailed(const RPCError &error) { if (mtpIsFlood(error)) return false; - App::wnd()->showLayer(new InformBox(lang(lng_stickers_not_found))); + Ui::showLayer(new InformBox(lang(lng_stickers_not_found))); return true; } @@ -252,7 +252,7 @@ void StickerSetBox::onAddStickers() { void StickerSetBox::onShareStickers() { QString url = qsl("https://telegram.me/addstickers/") + _inner.shortName(); QApplication::clipboard()->setText(url); - App::wnd()->showLayer(new InformBox(lang(lng_stickers_copied))); + Ui::showLayer(new InformBox(lang(lng_stickers_copied))); } void StickerSetBox::onUpdateButtons() { diff --git a/Telegram/SourceFiles/dialogswidget.cpp b/Telegram/SourceFiles/dialogswidget.cpp index 56d96241d1..15531628eb 100644 --- a/Telegram/SourceFiles/dialogswidget.cpp +++ b/Telegram/SourceFiles/dialogswidget.cpp @@ -675,12 +675,12 @@ void DialogsInner::onContextClearHistory() { _menuActionPeer = _menuPeer; ConfirmBox *box = new ConfirmBox(_menuPeer->isUser() ? lng_sure_delete_history(lt_contact, _menuPeer->name) : lng_sure_delete_group_history(lt_group, _menuPeer->name), lang(lng_box_delete), st::attentionBoxButton); connect(box, SIGNAL(confirmed()), this, SLOT(onContextClearHistorySure())); - App::showLayer(box); + Ui::showLayer(box); } void DialogsInner::onContextClearHistorySure() { if (!_menuActionPeer || _menuActionPeer->isChannel()) return; - App::wnd()->hideLayer(); + Ui::hideLayer(); App::main()->clearHistory(_menuActionPeer); } @@ -690,13 +690,13 @@ void DialogsInner::onContextDeleteAndLeave() { _menuActionPeer = _menuPeer; ConfirmBox *box = new ConfirmBox(_menuPeer->isUser() ? lng_sure_delete_history(lt_contact, _menuPeer->name) : (_menuPeer->isChat() ? lng_sure_delete_and_exit(lt_group, _menuPeer->name) : lang(_menuPeer->isMegagroup() ? lng_sure_leave_group : lng_sure_leave_channel)), lang(_menuPeer->isUser() ? lng_box_delete : lng_box_leave), _menuPeer->isChannel() ? st::defaultBoxButton : st::attentionBoxButton); connect(box, SIGNAL(confirmed()), this, SLOT(onContextDeleteAndLeaveSure())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void DialogsInner::onContextDeleteAndLeaveSure() { if (!_menuActionPeer) return; - App::wnd()->hideLayer(); + Ui::hideLayer(); App::main()->showDialogs(); if (_menuActionPeer->isUser()) { App::main()->deleteConversation(_menuActionPeer); @@ -2556,11 +2556,11 @@ DialogsIndexed &DialogsWidget::dialogsList() { } void DialogsWidget::onAddContact() { - App::wnd()->replaceLayer(new AddContactBox()); + Ui::showLayer(new AddContactBox(), KeepOtherLayers); } void DialogsWidget::onNewGroup() { - App::wnd()->showLayer(new NewGroupBox()); + Ui::showLayer(new NewGroupBox()); } bool DialogsWidget::onCancelSearch() { diff --git a/Telegram/SourceFiles/dropdown.cpp b/Telegram/SourceFiles/dropdown.cpp index 20071440c3..2ff3833324 100644 --- a/Telegram/SourceFiles/dropdown.cpp +++ b/Telegram/SourceFiles/dropdown.cpp @@ -1737,7 +1737,7 @@ void StickerPanInner::updateSelected() { } void StickerPanInner::onSettings() { - App::showLayer(new StickersBox()); + Ui::showLayer(new StickersBox()); } void StickerPanInner::onPreview() { @@ -2147,7 +2147,7 @@ void EmojiPan::mousePressEvent(QMouseEvent *e) { updateSelected(); if (_iconOver == _icons.size()) { - App::showLayer(new StickersBox()); + Ui::showLayer(new StickersBox()); } else { _iconDown = _iconOver; _iconsMouseDown = _iconsMousePos; @@ -2672,12 +2672,12 @@ void EmojiPan::onRemoveSet(quint64 setId) { ConfirmBox *box = new ConfirmBox(lng_stickers_remove_pack(lt_sticker_pack, it->title), lang(lng_box_remove)); connect(box, SIGNAL(confirmed()), this, SLOT(onRemoveSetSure())); connect(box, SIGNAL(destroyed(QObject*)), this, SLOT(onDelayedHide())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } } void EmojiPan::onRemoveSetSure() { - App::wnd()->hideLayer(); + Ui::hideLayer(); StickerSets::iterator it = cRefStickerSets().find(_removingSetId); if (it != cRefStickerSets().cend() && !(it->flags & MTPDstickerSet::flag_official)) { if (it->id && it->access) { diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index caa7fb9de1..afd723eea7 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -66,18 +66,6 @@ namespace App { if (Window *win = wnd()) win->showSettings(); } - void showLayer(LayeredWidget *widget, bool forceFast) { - if (Window *w = wnd()) w->showLayer(widget, forceFast); - } - - void replaceLayer(LayeredWidget *widget) { - if (Window *w = wnd()) w->replaceLayer(widget); - } - - void showLayerLast(LayeredWidget *widget) { - if (Window *w = wnd()) w->showLayerLast(widget); - } - } namespace Ui { @@ -90,6 +78,19 @@ namespace Ui { if (MainWidget *m = App::main()) m->ui_hideStickerPreview(); } + void showLayer(LayeredWidget *box, ShowLayerOptions options) { + if (Window *w = App::wnd()) w->ui_showLayer(box, options); + } + + void hideLayer(bool fast) { + if (Window *w = App::wnd()) w->ui_showLayer(0, ShowLayerOptions(CloseOtherLayers) | (fast ? ForceFastShowLayer : AnimatedShowLayer)); + } + + bool isLayerShown() { + if (Window *w = App::wnd()) return w->ui_isLayerShown(); + return false; + } + } namespace Notify { diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index afbbb8e079..cc6cdb6060 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -34,9 +34,6 @@ namespace App { bool forward(const PeerId &peer, ForwardWhatMessages what); void removeDialog(History *history); void showSettings(); - void showLayer(LayeredWidget *w, bool forceFast = false); - void replaceLayer(LayeredWidget *w); - void showLayerLast(LayeredWidget *w); }; @@ -45,6 +42,10 @@ namespace Ui { // it doesn't allow me to use UI :( void showStickerPreview(DocumentData *sticker); void hideStickerPreview(); + void showLayer(LayeredWidget *box, ShowLayerOptions options = CloseOtherLayers); + void hideLayer(bool fast = false); + bool isLayerShown(); + }; namespace Notify { diff --git a/Telegram/SourceFiles/gui/countryinput.cpp b/Telegram/SourceFiles/gui/countryinput.cpp index 53719fa5c9..5405737503 100644 --- a/Telegram/SourceFiles/gui/countryinput.cpp +++ b/Telegram/SourceFiles/gui/countryinput.cpp @@ -137,7 +137,7 @@ void CountryInput::mousePressEvent(QMouseEvent *e) { if (_active) { CountrySelectBox *box = new CountrySelectBox(); connect(box, SIGNAL(countryChosen(const QString&)), this, SLOT(onChooseCountry(const QString&))); - App::wnd()->showLayer(box); + Ui::showLayer(box); } } @@ -152,7 +152,7 @@ void CountryInput::leaveEvent(QEvent *e) { } void CountryInput::onChooseCode(const QString &code) { - App::wnd()->hideLayer(); + Ui::hideLayer(); if (code.length()) { CountriesByCode::const_iterator i = _countriesByCode.constFind(code); if (i != _countriesByCode.cend()) { @@ -169,7 +169,7 @@ void CountryInput::onChooseCode(const QString &code) { } bool CountryInput::onChooseCountry(const QString &iso) { - App::wnd()->hideLayer(); + Ui::hideLayer(); CountriesByISO2::const_iterator i = _countriesByISO2.constFind(iso); const CountryInfo *info = (i == _countriesByISO2.cend()) ? 0 : (*i); diff --git a/Telegram/SourceFiles/gui/text.cpp b/Telegram/SourceFiles/gui/text.cpp index 5621122078..cddee2412e 100644 --- a/Telegram/SourceFiles/gui/text.cpp +++ b/Telegram/SourceFiles/gui/text.cpp @@ -916,7 +916,7 @@ void EmailLink::onClick(Qt::MouseButton button) const { } void CustomTextLink::onClick(Qt::MouseButton button) const { - App::wnd()->showLayer(new ConfirmLinkBox(text())); + Ui::showLayer(new ConfirmLinkBox(text())); } void MentionLink::onClick(Qt::MouseButton button) const { diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index dddec35fd9..702314ced4 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -3772,7 +3772,7 @@ bool HistoryWidget::messagesFailed(const RPCError &error, mtpRequestId requestId if (error.type() == qstr("CHANNEL_PRIVATE")) { PeerData *was = _peer; App::main()->showDialogs(); - App::wnd()->showLayer(new InformBox(lang((was && was->isMegagroup()) ? lng_group_not_accessible : lng_channel_not_accessible))); + Ui::showLayer(new InformBox(lang((was && was->isMegagroup()) ? lng_group_not_accessible : lng_channel_not_accessible))); return true; } @@ -4289,7 +4289,7 @@ bool HistoryWidget::joinFail(const RPCError &error, mtpRequestId req) { if (_unblockRequest == req) _unblockRequest = 0; if (error.type() == qstr("CHANNEL_PRIVATE")) { - App::wnd()->showLayer(new InformBox(lang((_peer && _peer->isMegagroup()) ? lng_group_not_accessible : lng_channel_not_accessible))); + Ui::showLayer(new InformBox(lang((_peer && _peer->isMegagroup()) ? lng_group_not_accessible : lng_channel_not_accessible))); return true; } return false; @@ -5223,7 +5223,7 @@ void HistoryWidget::shareContactWithConfirm(const QString &phone, const QString App::wnd()->activateWindow(); _confirmWithTextId = 0xFFFFFFFFFFFFFFFFL; - App::wnd()->showLayer(new PhotoSendBox(phone, fname, lname, replyTo)); + Ui::showLayer(new PhotoSendBox(phone, fname, lname, replyTo)); } void HistoryWidget::confirmSendFile(const FileLoadResultPtr &file, bool ctrlShiftEnter) { @@ -5498,14 +5498,14 @@ void HistoryWidget::onAudioFailed(const FullMsgId &newId) { void HistoryWidget::onReportSpamClicked() { ConfirmBox *box = new ConfirmBox(lang(_peer->isUser() ? lng_report_spam_sure : ((_peer->isChat() || _peer->isMegagroup()) ? lng_report_spam_sure_group : lng_report_spam_sure_channel)), lang(lng_report_spam_ok), st::attentionBoxButton); connect(box, SIGNAL(confirmed()), this, SLOT(onReportSpamSure())); - App::wnd()->showLayer(box); + Ui::showLayer(box); _clearPeer = _peer; } void HistoryWidget::onReportSpamSure() { if (_reportSpamRequest) return; - App::wnd()->hideLayer(); + Ui::hideLayer(); if (_clearPeer->isUser()) MTP::send(MTPcontacts_Block(_clearPeer->asUser()->inputUser), rpcDone(&HistoryWidget::blockDone, _clearPeer), RPCFailHandlerPtr(), 0, 5); _reportSpamRequest = MTP::send(MTPmessages_ReportSpam(_clearPeer->input), rpcDone(&HistoryWidget::reportSpamDone, _clearPeer), rpcFail(&HistoryWidget::reportSpamFail)); } @@ -6144,7 +6144,7 @@ void HistoryWidget::onReplyToMessage() { box = new ConfirmBox(lang(lng_reply_cant_forward), lang(lng_selected_forward)); connect(box, SIGNAL(confirmed()), this, SLOT(onForwardHere())); } - App::showLayer(box); + Ui::showLayer(box); } return; } @@ -6457,7 +6457,7 @@ void HistoryWidget::onDeleteSelectedSure() { if (App::main() && App::main()->peer() == peer()) { App::main()->itemResized(0); } - App::wnd()->hideLayer(); + Ui::hideLayer(); for (QMap >::const_iterator i = ids.cbegin(), e = ids.cend(); i != e; ++i) { App::main()->deleteMessages(i.key(), i.value()); @@ -6481,7 +6481,7 @@ void HistoryWidget::onDeleteContextSure() { if (App::main() && (App::main()->peer() == h->peer || (App::main()->peer() && h->peer->migrateTo() == App::main()->peer()))) { App::main()->itemResized(0); } - App::wnd()->hideLayer(); + Ui::hideLayer(); if (wasOnServer) { App::main()->deleteMessages(h->peer, toDelete); @@ -6544,7 +6544,7 @@ void HistoryWidget::updateTopBarSelection() { App::main()->topBar()->showSelected(_selCount > 0 ? _selCount : 0, (selectedForDelete == selectedForForward)); updateControlsVisibility(); updateListSize(); - if (!App::wnd()->layerShown() && !App::passcoded()) { + if (!Ui::isLayerShown() && !App::passcoded()) { if (_selCount || (_list && _list->wasSelectedText()) || _recording || isBotStart() || isBlocked() || !_canSendMessages) { _list->setFocus(); } else { diff --git a/Telegram/SourceFiles/intro/intropwdcheck.cpp b/Telegram/SourceFiles/intro/intropwdcheck.cpp index 211beffd46..95a670539b 100644 --- a/Telegram/SourceFiles/intro/intropwdcheck.cpp +++ b/Telegram/SourceFiles/intro/intropwdcheck.cpp @@ -289,14 +289,14 @@ void IntroPwdCheck::onToRecover() { update(); } else { ConfirmBox *box = new InformBox(lang(lng_signin_no_email_forgot)); - App::wnd()->showLayer(box); + Ui::showLayer(box); connect(box, SIGNAL(destroyed(QObject*)), this, SLOT(onToReset())); } } void IntroPwdCheck::onToPassword() { ConfirmBox *box = new InformBox(lang(lng_signin_cant_email_forgot)); - App::wnd()->showLayer(box); + Ui::showLayer(box); connect(box, SIGNAL(destroyed(QObject*)), this, SLOT(onToReset())); } @@ -319,7 +319,7 @@ void IntroPwdCheck::onReset() { if (sentRequest) return; ConfirmBox *box = new ConfirmBox(lang(lng_signin_sure_reset), lang(lng_signin_reset), st::attentionBoxButton); connect(box, SIGNAL(confirmed()), this, SLOT(onResetSure())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void IntroPwdCheck::onResetSure() { @@ -335,7 +335,7 @@ bool IntroPwdCheck::deleteFail(const RPCError &error) { } void IntroPwdCheck::deleteDone(const MTPBool &v) { - App::wnd()->hideLayer(); + Ui::hideLayer(); intro()->onIntroNext(); } diff --git a/Telegram/SourceFiles/intro/introsignup.cpp b/Telegram/SourceFiles/intro/introsignup.cpp index fbb19cd452..3a67d6118f 100644 --- a/Telegram/SourceFiles/intro/introsignup.cpp +++ b/Telegram/SourceFiles/intro/introsignup.cpp @@ -90,7 +90,7 @@ void IntroSignup::mousePressEvent(QMouseEvent *e) { } PhotoCropBox *box = new PhotoCropBox(img, PeerId(0)); connect(box, SIGNAL(ready(const QImage &)), this, SLOT(onPhotoReady(const QImage &))); - App::wnd()->showLayer(box); + Ui::showLayer(box); } } diff --git a/Telegram/SourceFiles/localimageloader.cpp b/Telegram/SourceFiles/localimageloader.cpp index 95f0b87797..e81e1ea346 100644 --- a/Telegram/SourceFiles/localimageloader.cpp +++ b/Telegram/SourceFiles/localimageloader.cpp @@ -409,23 +409,23 @@ void FileLoadTask::process() { void FileLoadTask::finish() { if (!_result || !_result->filesize) { if (_result) App::main()->onSendFileCancel(_result); - App::wnd()->replaceLayer(new InformBox(lang(lng_send_image_empty))); + Ui::showLayer(new InformBox(lang(lng_send_image_empty)), KeepOtherLayers); return; } if (_result->filesize == -1) { // dir App::main()->onSendFileCancel(_result); - App::wnd()->replaceLayer(new InformBox(lng_send_folder(lt_name, QFileInfo(_filepath).dir().dirName()))); + Ui::showLayer(new InformBox(lng_send_folder(lt_name, QFileInfo(_filepath).dir().dirName())), KeepOtherLayers); return; } if (_result->filesize > MaxUploadDocumentSize) { App::main()->onSendFileCancel(_result); - App::wnd()->replaceLayer(new InformBox(lang(lng_send_image_too_large))); + Ui::showLayer(new InformBox(lang(lng_send_image_too_large)), KeepOtherLayers); return; } if (App::main()) { bool confirm = (_confirm == FileLoadAlwaysConfirm) || (_result->photo.type() != mtpc_photoEmpty && _confirm != FileLoadNeverConfirm); if (confirm) { - App::wnd()->showLayerLast(new PhotoSendBox(_result)); + Ui::showLayer(new PhotoSendBox(_result), ShowAfterOtherLayers); } else { if (_result->type == PrepareAuto) { _result->type = (_result->photo.type() != mtpc_photoEmpty) ? PreparePhoto : PrepareDocument; diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index b5dd08893b..2d5d59a84b 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -89,18 +89,18 @@ void TopBarWidget::onInfoClicked() { void TopBarWidget::onAddContact() { PeerData *p = App::main() ? App::main()->profilePeer() : 0; UserData *u = p ? p->asUser() : 0; - if (u) App::wnd()->showLayer(new AddContactBox(u->firstName, u->lastName, u->phone.isEmpty() ? App::phoneFromSharedContact(peerToUser(u->id)) : u->phone)); + 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()) { - App::wnd()->showLayer(new EditChannelBox(p->asChannel())); + Ui::showLayer(new EditChannelBox(p->asChannel())); } else if (p->isChat()) { - App::wnd()->showLayer(new EditNameTitleBox(p)); + Ui::showLayer(new EditNameTitleBox(p)); } else if (p->isUser()) { - App::wnd()->showLayer(new AddContactBox(p->asUser())); + Ui::showLayer(new AddContactBox(p->asUser())); } } } @@ -111,7 +111,7 @@ void TopBarWidget::onDeleteContact() { 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())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } } @@ -120,7 +120,7 @@ void TopBarWidget::onDeleteContactSure() { UserData *u = p ? p->asUser() : 0; if (u) { App::main()->showDialogs(); - App::wnd()->hideLayer(); + Ui::hideLayer(); MTP::send(MTPcontacts_DeleteContact(u->inputUser), App::main()->rpcDone(&MainWidget::deletedContact, u)); } } @@ -131,7 +131,7 @@ void TopBarWidget::onDeleteAndExit() { 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())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } } @@ -140,7 +140,7 @@ void TopBarWidget::onDeleteAndExitSure() { ChatData *c = p ? p->asChat() : 0; if (c) { App::main()->showDialogs(); - App::wnd()->hideLayer(); + Ui::hideLayer(); MTP::send(MTPmessages_DeleteChatUser(c->inputChat, App::self()->inputUser), App::main()->rpcDone(&MainWidget::deleteHistoryAfterLeave, p), App::main()->rpcFail(&MainWidget::leaveChatFailed, p)); } } @@ -480,7 +480,7 @@ MainWidget::MainWidget(Window *window) : TWidget(window) bool MainWidget::onForward(const PeerId &peer, ForwardWhatMessages what) { PeerData *p = App::peer(peer); if (!peer || (p->isChannel() && !p->asChannel()->canPublish() && p->asChannel()->isBroadcast()) || (p->isChat() && !p->asChat()->canWrite()) || (p->isUser() && p->asUser()->access == UserNoAccess)) { - App::wnd()->showLayer(new InformBox(lang(lng_forward_cant))); + Ui::showLayer(new InformBox(lang(lng_forward_cant))); return false; } history.cancelReply(); @@ -514,7 +514,7 @@ bool MainWidget::onForward(const PeerId &peer, ForwardWhatMessages what) { bool MainWidget::onShareUrl(const PeerId &peer, const QString &url, const QString &text) { PeerData *p = App::peer(peer); if (!peer || (p->isChannel() && !p->asChannel()->canPublish() && p->asChannel()->isBroadcast()) || (p->isChat() && !p->asChat()->canWrite()) || (p->isUser() && p->asUser()->access == UserNoAccess)) { - App::wnd()->showLayer(new InformBox(lang(lng_share_cant))); + Ui::showLayer(new InformBox(lang(lng_share_cant))); return false; } History *h = App::history(peer); @@ -837,7 +837,7 @@ void MainWidget::deleteLayer(int32 selectedCount) { } else { connect(box, SIGNAL(confirmed()), overview ? overview : static_cast(&history), SLOT(onDeleteSelectedSure())); } - App::wnd()->showLayer(box); + Ui::showLayer(box); } void MainWidget::shareContactLayer(UserData *contact) { @@ -853,13 +853,13 @@ bool MainWidget::selectingPeer(bool withConfirm) { } void MainWidget::offerPeer(PeerId peer) { - App::wnd()->hideLayer(); + Ui::hideLayer(); if (_hider->offerPeer(peer) && !cWideMode()) { _forwardConfirm = new ConfirmBox(_hider->offeredText(), lang(lng_forward_send)); connect(_forwardConfirm, SIGNAL(confirmed()), _hider, SLOT(forward())); connect(_forwardConfirm, SIGNAL(cancelled()), this, SLOT(onForwardCancel())); connect(_forwardConfirm, SIGNAL(destroyed(QObject*)), this, SLOT(onForwardCancel(QObject*))); - App::wnd()->showLayer(_forwardConfirm); + Ui::showLayer(_forwardConfirm); } } @@ -1012,7 +1012,7 @@ bool MainWidget::addParticipantFail(UserData *user, const RPCError &error) { } else if (error.type() == "PEER_FLOOD") { text = lng_cant_invite_not_contact(lt_more_info, textcmdLink(qsl("https://telegram.org/faq?_hash=can-39t-send-messages-to-non-contacts"), lang(lng_cant_more_info))); } - App::wnd()->showLayer(new InformBox(text)); + Ui::showLayer(new InformBox(text)); return false; } @@ -1026,13 +1026,13 @@ bool MainWidget::addParticipantsFail(ChannelData *channel, const RPCError &error } else if (error.type() == "PEER_FLOOD") { text = lng_cant_invite_not_contact(lt_more_info, textcmdLink(qsl("https://telegram.org/faq?_hash=can-39t-send-messages-to-non-contacts"), lang(lng_cant_more_info))); } - App::wnd()->showLayer(new InformBox(text)); + Ui::showLayer(new InformBox(text)); return false; } void MainWidget::kickParticipant(ChatData *chat, UserData *user) { MTP::send(MTPmessages_DeleteChatUser(chat->inputChat, user->inputUser), rpcDone(&MainWidget::sentUpdatesReceived), rpcFail(&MainWidget::kickParticipantFail, chat)); - App::wnd()->hideLayer(); + Ui::hideLayer(); showPeerHistory(chat->id, ShowAtTheEndMsgId); } @@ -1131,7 +1131,7 @@ bool MainWidget::sendMessageFail(const RPCError &error) { if (mtpIsFlood(error)) return false; if (error.type() == qsl("PEER_FLOOD")) { - App::wnd()->showLayer(new InformBox(lng_cant_send_to_not_contact(lt_more_info, textcmdLink(qsl("https://telegram.org/faq?_hash=can-39t-send-messages-to-non-contacts"), lang(lng_cant_more_info))))); + Ui::showLayer(new InformBox(lng_cant_send_to_not_contact(lt_more_info, textcmdLink(qsl("https://telegram.org/faq?_hash=can-39t-send-messages-to-non-contacts"), lang(lng_cant_more_info))))); return true; } return false; @@ -1639,7 +1639,7 @@ void MainWidget::loadFailed(mtpFileLoader *loader, bool started, const char *ret } else { connect(box, SIGNAL(confirmed()), this, SLOT(onDownloadPathSettings())); } - App::wnd()->showLayer(box); + Ui::showLayer(box); } void MainWidget::onDownloadPathSettings() { @@ -1649,7 +1649,7 @@ void MainWidget::onDownloadPathSettings() { if (App::wnd() && App::wnd()->settingsWidget()) { connect(box, SIGNAL(closed()), App::wnd()->settingsWidget(), SLOT(onDownloadPathEdited())); } - App::wnd()->showLayer(box); + Ui::showLayer(box); } void MainWidget::videoLoadFailed(mtpFileLoader *loader, bool started) { @@ -1659,7 +1659,7 @@ void MainWidget::videoLoadFailed(mtpFileLoader *loader, bool started) { } void MainWidget::videoLoadRetry() { - App::wnd()->hideLayer(); + Ui::hideLayer(); VideoData *video = App::video(failedObjId); if (video) video->save(failedFileName); } @@ -1818,7 +1818,7 @@ void MainWidget::audioLoadFailed(mtpFileLoader *loader, bool started) { } void MainWidget::audioLoadRetry() { - App::wnd()->hideLayer(); + Ui::hideLayer(); AudioData *audio = App::audio(failedObjId); if (audio) audio->save(failedFileName); } @@ -1913,7 +1913,7 @@ void MainWidget::documentLoadFailed(mtpFileLoader *loader, bool started) { } void MainWidget::documentLoadRetry() { - App::wnd()->hideLayer(); + Ui::hideLayer(); DocumentData *document = App::document(failedObjId); if (document) document->save(failedFileName); } @@ -2282,7 +2282,7 @@ void MainWidget::showPeerHistory(quint64 peerId, qint32 showAtMsgId, bool back) PeerData *wasActivePeer = activePeer(); - App::wnd()->hideLayer(); + Ui::hideLayer(); if (_hider) { _hider->startHide(); _hider = 0; @@ -2741,13 +2741,13 @@ void MainWidget::hideAll() { void MainWidget::showAll() { if (cPasswordRecovered()) { cSetPasswordRecovered(false); - App::wnd()->showLayer(new InformBox(lang(lng_signin_password_removed))); + Ui::showLayer(new InformBox(lang(lng_signin_password_removed))); } if (cWideMode()) { if (_hider) { _hider->show(); if (_forwardConfirm) { - App::wnd()->hideLayer(true); + Ui::hideLayer(true); _forwardConfirm = 0; } } @@ -2770,7 +2770,7 @@ void MainWidget::showAll() { _forwardConfirm = new ConfirmBox(_hider->offeredText(), lang(lng_forward_send)); connect(_forwardConfirm, SIGNAL(confirmed()), _hider, SLOT(forward())); connect(_forwardConfirm, SIGNAL(cancelled()), this, SLOT(onForwardCancel())); - App::wnd()->showLayer(_forwardConfirm, true); + Ui::showLayer(_forwardConfirm, ForceFastShowLayer); } } if (selectingPeer()) { @@ -3541,7 +3541,7 @@ void MainWidget::openPeerByName(const QString &username, bool toProfile, const Q if (toProfile) { if (peer->isUser() && peer->asUser()->botInfo && !peer->asUser()->botInfo->cantJoinGroups && !startToken.isEmpty()) { peer->asUser()->botInfo->startGroupToken = startToken; - App::wnd()->showLayer(new ContactsBox(peer->asUser())); + Ui::showLayer(new ContactsBox(peer->asUser())); } else if (peer->isChannel()) { showPeerHistory(peer->id, ShowAtUnreadMsgId); } else { @@ -3571,7 +3571,7 @@ void MainWidget::stickersBox(const MTPInputStickerSet &set) { App::wnd()->hideMediaview(); StickerSetBox *box = new StickerSetBox(set); connect(box, SIGNAL(installed(uint64)), this, SLOT(onStickersInstalled(uint64))); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void MainWidget::onStickersInstalled(uint64 setId) { @@ -3605,7 +3605,7 @@ bool MainWidget::contentOverlapped(const QRect &globalRect) { } void MainWidget::usernameResolveDone(QPair toProfileStartToken, const MTPcontacts_ResolvedPeer &result) { - App::wnd()->hideLayer(); + Ui::hideLayer(); if (result.type() != mtpc_contacts_resolvedPeer) return; const MTPDcontacts_resolvedPeer &d(result.c_contacts_resolvedPeer()); @@ -3618,7 +3618,7 @@ void MainWidget::usernameResolveDone(QPair toProfileStartToken, c if (toProfileStartToken.first) { if (peer->isUser() && peer->asUser()->botInfo && !peer->asUser()->botInfo->cantJoinGroups && !toProfileStartToken.second.isEmpty()) { peer->asUser()->botInfo->startGroupToken = toProfileStartToken.second; - App::wnd()->showLayer(new ContactsBox(peer->asUser())); + Ui::showLayer(new ContactsBox(peer->asUser())); } else if (peer->isChannel()) { showPeerHistory(peer->id, ShowAtUnreadMsgId); } else { @@ -3640,7 +3640,7 @@ bool MainWidget::usernameResolveFail(QString name, const RPCError &error) { if (mtpIsFlood(error)) return false; if (error.code() == 400) { - App::wnd()->showLayer(new InformBox(lng_username_not_found(lt_user, name))); + Ui::showLayer(new InformBox(lng_username_not_found(lt_user, name))); } return true; } @@ -3652,7 +3652,7 @@ void MainWidget::inviteCheckDone(QString hash, const MTPChatInvite &invite) { ConfirmBox *box = new ConfirmBox(((d.is_channel() && !d.is_megagroup()) ? lng_group_invite_want_join_channel : lng_group_invite_want_join)(lt_title, qs(d.vtitle)), lang(lng_group_invite_join)); _inviteHash = hash; connect(box, SIGNAL(confirmed()), this, SLOT(onInviteImport())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } break; case mtpc_chatInviteAlready: { @@ -3669,7 +3669,7 @@ bool MainWidget::inviteCheckFail(const RPCError &error) { if (mtpIsFlood(error)) return false; if (error.code() == 400) { - App::wnd()->showLayer(new InformBox(lang(lng_group_invite_bad_link))); + Ui::showLayer(new InformBox(lang(lng_group_invite_bad_link))); } return true; } @@ -3682,7 +3682,7 @@ void MainWidget::onInviteImport() { void MainWidget::inviteImportDone(const MTPUpdates &updates) { App::main()->sentUpdatesReceived(updates); - App::wnd()->hideLayer(); + Ui::hideLayer(); const QVector *v = 0; switch (updates.type()) { case mtpc_updates: v = &updates.c_updates().vchats.c_vector().v; break; @@ -3702,7 +3702,7 @@ bool MainWidget::inviteImportFail(const RPCError &error) { if (mtpIsFlood(error)) return false; if (error.code() == 400) { - App::wnd()->showLayer(new InformBox(lang(error.type() == qsl("USERS_TOO_MUCH") ? lng_group_invite_no_room : lng_group_invite_bad_link))); + Ui::showLayer(new InformBox(lang(error.type() == qsl("USERS_TOO_MUCH") ? lng_group_invite_no_room : lng_group_invite_bad_link))); } return true; } @@ -3915,7 +3915,7 @@ void MainWidget::activate() { } else { dialogs.activate(); } - } else if (App::wnd() && !App::wnd()->layerShown()) { + } else if (App::wnd() && !Ui::isLayerShown()) { if (!cSendPaths().isEmpty()) { forwardLayer(-1); } else if (history.peer()) { @@ -4519,7 +4519,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { case mtpc_updateServiceNotification: { const MTPDupdateServiceNotification &d(update.c_updateServiceNotification()); if (mtpIsTrue(d.vpopup)) { - App::wnd()->showLayer(new InformBox(qs(d.vmessage))); + Ui::showLayer(new InformBox(qs(d.vmessage))); } else { App::wnd()->serviceNotification(qs(d.vmessage), d.vmedia); } diff --git a/Telegram/SourceFiles/mediaview.cpp b/Telegram/SourceFiles/mediaview.cpp index e26a3bd399..2963e2411b 100644 --- a/Telegram/SourceFiles/mediaview.cpp +++ b/Telegram/SourceFiles/mediaview.cpp @@ -486,7 +486,7 @@ void MediaView::showSaveMsgFile() { void MediaView::close() { if (_menu) _menu->hideMenu(true); if (App::wnd()) { - App::wnd()->hideLayer(true); + Ui::hideLayer(true); } } diff --git a/Telegram/SourceFiles/overviewwidget.cpp b/Telegram/SourceFiles/overviewwidget.cpp index 78c6af5ebc..b1c6ea31a1 100644 --- a/Telegram/SourceFiles/overviewwidget.cpp +++ b/Telegram/SourceFiles/overviewwidget.cpp @@ -2875,7 +2875,7 @@ void OverviewWidget::updateTopBarSelection() { App::main()->topBar()->showSelected(_selCount > 0 ? _selCount : 0, (selectedForDelete == selectedForForward)); App::main()->topBar()->update(); } - if (App::wnd() && !App::wnd()->layerShown()) { + if (App::wnd() && !Ui::isLayerShown()) { _inner.activate(); } update(); @@ -3127,7 +3127,7 @@ void OverviewWidget::onDeleteSelectedSure() { if (App::main() && App::main()->peer() == peer()) { App::main()->itemResized(0); } - App::wnd()->hideLayer(); + Ui::hideLayer(); for (QMap >::const_iterator i = ids.cbegin(), e = ids.cend(); i != e; ++i) { App::main()->deleteMessages(i.key(), i.value()); @@ -3151,7 +3151,7 @@ void OverviewWidget::onDeleteContextSure() { if (App::main() && (App::main()->peer() == h->peer || (App::main()->peer() && App::main()->peer() == h->peer->migrateTo()))) { App::main()->itemResized(0); } - App::wnd()->hideLayer(); + Ui::hideLayer(); if (wasOnServer) { App::main()->deleteMessages(h->peer, toDelete); diff --git a/Telegram/SourceFiles/profilewidget.cpp b/Telegram/SourceFiles/profilewidget.cpp index 79022abac8..3beede857b 100644 --- a/Telegram/SourceFiles/profilewidget.cpp +++ b/Telegram/SourceFiles/profilewidget.cpp @@ -232,7 +232,7 @@ void ProfileInner::onShareContact() { } void ProfileInner::onInviteToGroup() { - App::wnd()->showLayer(new ContactsBox(_peerUser)); + Ui::showLayer(new ContactsBox(_peerUser)); } void ProfileInner::onSendMessage() { @@ -302,36 +302,35 @@ void ProfileInner::onUpdatePhoto() { } PhotoCropBox *box = new PhotoCropBox(img, _peer); connect(box, SIGNAL(closed()), this, SLOT(onPhotoUpdateStart())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void ProfileInner::onClearHistory() { if (_peerChannel) return; ConfirmBox *box = new ConfirmBox(_peer->isUser() ? lng_sure_delete_history(lt_contact, _peer->name) : lng_sure_delete_group_history(lt_group, _peer->name), lang(lng_box_delete), st::attentionBoxButton); connect(box, SIGNAL(confirmed()), this, SLOT(onClearHistorySure())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void ProfileInner::onClearHistorySure() { - App::wnd()->hideLayer(); + Ui::hideLayer(); App::main()->clearHistory(_peer); } void ProfileInner::onDeleteConversation() { ConfirmBox *box = new ConfirmBox(_peer->isUser() ? lng_sure_delete_history(lt_contact, _peer->name) : (_peer->isChat() ? lng_sure_delete_and_exit(lt_group, _peer->name) : lang(_peer->isMegagroup() ? lng_sure_leave_group : lng_sure_leave_channel)), lang(_peer->isUser() ? lng_box_delete : lng_box_leave), _peer->isChannel() ? st::defaultBoxButton : st::attentionBoxButton); connect(box, SIGNAL(confirmed()), this, SLOT(onDeleteConversationSure())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void ProfileInner::onDeleteConversationSure() { + Ui::hideLayer(); if (_peerUser) { App::main()->deleteConversation(_peer); } else if (_peerChat) { - App::wnd()->hideLayer(); App::main()->showDialogs(); MTP::send(MTPmessages_DeleteChatUser(_peerChat->inputChat, App::self()->inputUser), App::main()->rpcDone(&MainWidget::deleteHistoryAfterLeave, _peer), App::main()->rpcFail(&MainWidget::leaveChatFailed, _peer)); } else if (_peerChannel) { - App::wnd()->hideLayer(); App::main()->showDialogs(); if (_peerChannel->migrateFrom()) { App::main()->deleteConversation(_peerChannel->migrateFrom()); @@ -344,12 +343,12 @@ void ProfileInner::onDeleteChannel() { if (!_peerChannel) return; ConfirmBox *box = new ConfirmBox(lang(_peer->isMegagroup() ? lng_sure_delete_group : lng_sure_delete_channel), lang(lng_box_delete), st::attentionBoxButton); connect(box, SIGNAL(confirmed()), this, SLOT(onDeleteChannelSure())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void ProfileInner::onDeleteChannelSure() { if (_peerChannel) { - App::wnd()->hideLayer(); + Ui::hideLayer(); App::main()->showDialogs(); if (_peerChannel->migrateFrom()) { App::main()->deleteConversation(_peerChannel->migrateFrom()); @@ -382,13 +381,13 @@ bool ProfileInner::blockFail(const RPCError &error) { void ProfileInner::onAddParticipant() { if (_peerChat) { - App::wnd()->showLayer(new ContactsBox(_peerChat, MembersFilterRecent)); + Ui::showLayer(new ContactsBox(_peerChat, MembersFilterRecent)); } else if (_peerChannel && _peerChannel->mgInfo) { MembersAlreadyIn already; for (MegagroupInfo::LastParticipants::const_iterator i = _peerChannel->mgInfo->lastParticipants.cbegin(), e = _peerChannel->mgInfo->lastParticipants.cend(); i != e; ++i) { already.insert(*i, true); } - App::wnd()->showLayer(new ContactsBox(_peerChannel, MembersFilterRecent, already)); + Ui::showLayer(new ContactsBox(_peerChannel, MembersFilterRecent, already)); } } @@ -397,7 +396,7 @@ void ProfileInner::onMigrate() { ConfirmBox *box = new ConfirmBox(lang(lng_profile_migrate_sure)); connect(box, SIGNAL(confirmed()), this, SLOT(onMigrateSure())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void ProfileInner::onMigrateSure() { @@ -459,7 +458,7 @@ void ProfileInner::onInvitationLink() { if (!_peerChat && !_peerChannel) return; QApplication::clipboard()->setText(_peerChat ? _peerChat->invitationUrl : (_peerChannel ? _peerChannel->invitationUrl : QString())); - App::wnd()->showLayer(new InformBox(lang(lng_group_invite_copied))); + Ui::showLayer(new InformBox(lang(lng_group_invite_copied))); } void ProfileInner::onPublicLink() { @@ -467,22 +466,22 @@ void ProfileInner::onPublicLink() { if (_peerChannel->isPublic()) { QApplication::clipboard()->setText(qsl("https://telegram.me/") + _peerChannel->username); - App::wnd()->showLayer(new InformBox(lang(lng_channel_public_link_copied))); + Ui::showLayer(new InformBox(lang(lng_channel_public_link_copied))); } else { - App::wnd()->showLayer(new SetupChannelBox(_peerChannel, true)); + Ui::showLayer(new SetupChannelBox(_peerChannel, true)); } } void ProfileInner::onMembers() { if (!_peerChannel) return; - App::wnd()->showLayer(new MembersBox(_peerChannel, MembersFilterRecent)); + Ui::showLayer(new MembersBox(_peerChannel, MembersFilterRecent)); } void ProfileInner::onAdmins() { if (_peerChannel) { - App::wnd()->showLayer(new MembersBox(_peerChannel, MembersFilterAdmins)); + Ui::showLayer(new MembersBox(_peerChannel, MembersFilterAdmins)); } else if (_peerChat) { - App::wnd()->showLayer(new ContactsBox(_peerChat, MembersFilterAdmins)); + Ui::showLayer(new ContactsBox(_peerChat, MembersFilterAdmins)); } } @@ -491,7 +490,7 @@ void ProfileInner::onCreateInvitationLink() { ConfirmBox *box = new ConfirmBox(lang(((_peerChat && _peerChat->invitationUrl.isEmpty()) || (_peerChannel && _peerChannel->invitationUrl.isEmpty())) ? lng_group_invite_about : lng_group_invite_about_new)); connect(box, SIGNAL(confirmed()), this, SLOT(onCreateInvitationLinkSure())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void ProfileInner::onCreateInvitationLinkSure() { @@ -514,7 +513,7 @@ void ProfileInner::chatInviteDone(const MTPExportedChatInvite &result) { updateInvitationLink(); showAll(); resizeEvent(0); - App::wnd()->hideLayer(); + Ui::hideLayer(); } void ProfileInner::onFullPeerUpdated(PeerData *peer) { @@ -1075,7 +1074,7 @@ void ProfileInner::mouseReleaseEvent(QMouseEvent *e) { _kickConfirm = _kickOver; ConfirmBox *box = new ConfirmBox(lng_profile_sure_kick(lt_user, _kickOver->firstName), lang(lng_box_remove)); connect(box, SIGNAL(confirmed()), this, SLOT(onKickConfirm())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } if (textlnkDown()) { TextLinkPtr lnk = textlnkDown(); @@ -1104,7 +1103,7 @@ void ProfileInner::onKickConfirm() { if (_peerChat) { App::main()->kickParticipant(_peerChat, _kickConfirm); } else if (_peerChannel) { - App::wnd()->hideLayer(); + Ui::hideLayer(); App::api()->kickParticipant(_peerChannel, _kickConfirm); } } @@ -1236,7 +1235,7 @@ bool ProfileInner::updateMediaLinks(int32 *addToScroll) { } void ProfileInner::migrateDone(const MTPUpdates &updates) { - App::wnd()->hideLayer(); + Ui::hideLayer(); App::main()->sentUpdatesReceived(updates); const QVector *v = 0; switch (updates.type()) { @@ -1262,7 +1261,7 @@ void ProfileInner::migrateDone(const MTPUpdates &updates) { bool ProfileInner::migrateFail(const RPCError &error) { if (mtpIsFlood(error)) return false; - App::wnd()->hideLayer(); + Ui::hideLayer(); return true; } diff --git a/Telegram/SourceFiles/settingswidget.cpp b/Telegram/SourceFiles/settingswidget.cpp index 3cd1c4945d..dd678769f3 100644 --- a/Telegram/SourceFiles/settingswidget.cpp +++ b/Telegram/SourceFiles/settingswidget.cpp @@ -783,14 +783,14 @@ void SettingsInner::keyPressEvent(QKeyEvent *e) { QString text = cDebug() ? qsl("Do you want to disable DEBUG logs?") : qsl("Do you want to enable DEBUG logs?\n\nAll network events will be logged."); ConfirmBox *box = new ConfirmBox(text); connect(box, SIGNAL(confirmed()), App::app(), SLOT(onSwitchDebugMode())); - App::wnd()->showLayer(box); + Ui::showLayer(box); from = size; break; } else if (str == qstr("testmode")) { QString text = cTestMode() ? qsl("Do you want to disable TEST mode?") : qsl("Do you want to enable TEST mode?\n\nYou will be switched to test cloud."); ConfirmBox *box = new ConfirmBox(text); connect(box, SIGNAL(confirmed()), App::app(), SLOT(onSwitchTestMode())); - App::wnd()->showLayer(box); + Ui::showLayer(box); from = size; break; } else if (str == qstr("loadlang")) { @@ -831,7 +831,7 @@ void SettingsInner::mousePressEvent(QMouseEvent *e) { return; } if (QRect(_uploadPhoto.x() + st::setNameLeft, st::setTop + st::setNameTop, qMin(_uploadPhoto.width() - int(st::setNameLeft), _nameText.maxWidth()), st::setNameFont->height).contains(e->pos())) { - App::wnd()->showLayer(new EditNameTitleBox(self())); + Ui::showLayer(new EditNameTitleBox(self())); } else if (QRect(_left, st::setTop, st::setPhotoSize, st::setPhotoSize).contains(e->pos())) { if (_photoLink) { App::photo(self()->photoId)->full->load(); @@ -1178,12 +1178,12 @@ void SettingsInner::onUpdatePhoto() { } PhotoCropBox *box = new PhotoCropBox(img, self()); connect(box, SIGNAL(closed()), this, SLOT(onPhotoUpdateStart())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void SettingsInner::onShowSessions() { SessionsBox *box = new SessionsBox(); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void SettingsInner::onAskQuestion() { @@ -1192,7 +1192,7 @@ void SettingsInner::onAskQuestion() { ConfirmBox *box = new ConfirmBox(lang(lng_settings_ask_sure), lang(lng_settings_ask_ok), st::defaultBoxButton, lang(lng_settings_faq_button)); connect(box, SIGNAL(confirmed()), this, SLOT(onAskQuestionSure())); connect(box, SIGNAL(cancelPressed()), this, SLOT(onTelegramFAQ())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void SettingsInner::onAskQuestionSure() { @@ -1217,9 +1217,9 @@ void SettingsInner::chooseCustomLang() { cancel = result.value(lng_cancel, langOriginal(lng_cancel)); ConfirmBox *box = new ConfirmBox(text, save, st::defaultBoxButton, cancel); connect(box, SIGNAL(confirmed()), this, SLOT(onSaveTestLang())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } else { - App::wnd()->showLayer(new InformBox("Custom lang failed :(\n\nError: " + loader.errors())); + Ui::showLayer(new InformBox("Custom lang failed :(\n\nError: " + loader.errors())); } } } @@ -1228,7 +1228,7 @@ void SettingsInner::onChangeLanguage() { if ((_changeLanguage.clickModifiers() & Qt::ShiftModifier) && (_changeLanguage.clickModifiers() & Qt::AltModifier)) { chooseCustomLang(); } else { - App::wnd()->showLayer(new LanguageBox()); + Ui::showLayer(new LanguageBox()); } } @@ -1293,19 +1293,19 @@ void SettingsInner::onRestartNow() { void SettingsInner::onPasscode() { PasscodeBox *box = new PasscodeBox(); connect(box, SIGNAL(closed()), this, SLOT(passcodeChanged())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void SettingsInner::onPasscodeOff() { PasscodeBox *box = new PasscodeBox(true); connect(box, SIGNAL(closed()), this, SLOT(passcodeChanged())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void SettingsInner::onPassword() { PasscodeBox *box = new PasscodeBox(_newPasswordSalt, _curPasswordSalt, _hasPasswordRecovery, _curPasswordHint); connect(box, SIGNAL(reloadPassword()), this, SLOT(onReloadPassword())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void SettingsInner::onPasswordOff() { @@ -1319,7 +1319,7 @@ void SettingsInner::onPasswordOff() { } else { PasscodeBox *box = new PasscodeBox(_newPasswordSalt, _curPasswordSalt, _hasPasswordRecovery, _curPasswordHint, true); connect(box, SIGNAL(reloadPassword()), this, SLOT(onReloadPassword())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } } @@ -1332,19 +1332,19 @@ void SettingsInner::onReloadPassword(Qt::ApplicationState state) { void SettingsInner::onAutoLock() { AutoLockBox *box = new AutoLockBox(); connect(box, SIGNAL(closed()), this, SLOT(passcodeChanged())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void SettingsInner::onConnectionType() { ConnectionBox *box = new ConnectionBox(); connect(box, SIGNAL(closed()), this, SLOT(updateConnectionType()), Qt::QueuedConnection); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void SettingsInner::onUsername() { UsernameBox *box = new UsernameBox(); connect(box, SIGNAL(closed()), this, SLOT(usernameChanged())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void SettingsInner::onWorkmodeTray() { @@ -1445,7 +1445,7 @@ void SettingsInner::setScale(DBIScale newScale) { if (cEvalScale(cConfigScale()) != cEvalScale(cRealScale())) { ConfirmBox *box = new ConfirmBox(lang(lng_settings_need_restart), lang(lng_settings_restart_now), st::defaultBoxButton, lang(lng_settings_restart_later)); connect(box, SIGNAL(confirmed()), this, SLOT(onRestartNow())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } } @@ -1528,11 +1528,11 @@ void SettingsInner::onReplaceEmojis() { } void SettingsInner::onViewEmojis() { - App::showLayer(new EmojiBox()); + Ui::showLayer(new EmojiBox()); } void SettingsInner::onStickers() { - App::showLayer(new StickersBox()); + Ui::showLayer(new StickersBox()); } void SettingsInner::onEnterSend() { @@ -1553,7 +1553,7 @@ void SettingsInner::onCtrlEnterSend() { void SettingsInner::onBackFromGallery() { BackgroundBox *box = new BackgroundBox(); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void SettingsInner::onBackFromFile() { @@ -1631,7 +1631,7 @@ void SettingsInner::onDontAskDownloadPath() { void SettingsInner::onDownloadPathEdit() { DownloadPathBox *box = new DownloadPathBox(); connect(box, SIGNAL(closed()), this, SLOT(onDownloadPathEdited())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void SettingsInner::onDownloadPathEdited() { @@ -1650,11 +1650,11 @@ void SettingsInner::onDownloadPathEdited() { void SettingsInner::onDownloadPathClear() { ConfirmBox *box = new ConfirmBox(lang(lng_sure_clear_downloads)); connect(box, SIGNAL(confirmed()), this, SLOT(onDownloadPathClearSure())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void SettingsInner::onDownloadPathClearSure() { - App::wnd()->hideLayer(); + Ui::hideLayer(); App::wnd()->tempDirDelete(Local::ClearManagerDownloads); _tempDirClearState = TempDirClearing; showAll(); diff --git a/Telegram/SourceFiles/structs.cpp b/Telegram/SourceFiles/structs.cpp index b7c3bfed0a..93f24d3685 100644 --- a/Telegram/SourceFiles/structs.cpp +++ b/Telegram/SourceFiles/structs.cpp @@ -1042,7 +1042,7 @@ void PeerLink::onClick(Qt::MouseButton button) const { if (button == Qt::LeftButton && App::main()) { if (peer() && peer()->isChannel() && App::main()->historyPeer() != peer()) { if (!peer()->asChannel()->isPublic() && !peer()->asChannel()->amIn()) { - App::wnd()->showLayer(new InformBox(lang((peer()->isMegagroup()) ? lng_group_not_accessible : lng_channel_not_accessible))); + Ui::showLayer(new InformBox(lang((peer()->isMegagroup()) ? lng_group_not_accessible : lng_channel_not_accessible))); } else { App::main()->showPeerHistory(peer()->id, ShowAtUnreadMsgId); } diff --git a/Telegram/SourceFiles/title.cpp b/Telegram/SourceFiles/title.cpp index 364d233417..36c72feb61 100644 --- a/Telegram/SourceFiles/title.cpp +++ b/Telegram/SourceFiles/title.cpp @@ -143,12 +143,12 @@ void TitleWidget::onContacts() { if (App::wnd() && App::wnd()->isHidden()) App::wnd()->showFromTray(); if (!App::self()) return; - App::wnd()->showLayer(new ContactsBox()); + Ui::showLayer(new ContactsBox()); } void TitleWidget::onAbout() { if (App::wnd() && App::wnd()->isHidden()) App::wnd()->showFromTray(); - App::wnd()->showLayer(new AboutBox()); + Ui::showLayer(new AboutBox()); } TitleWidget::~TitleWidget() { @@ -365,7 +365,7 @@ void TitleWidget::maximizedChanged(bool maximized, bool force) { } HitTestType TitleWidget::hitTest(const QPoint &p) { - if (App::wnd() && App::wnd()->layerShown()) return HitTestNone; + if (App::wnd() && Ui::isLayerShown()) return HitTestNone; int x(p.x()), y(p.y()), w(width()), h(height()); if (cWideMode() && hider && x >= App::main()->dlgsWidth()) return HitTestNone; diff --git a/Telegram/SourceFiles/types.h b/Telegram/SourceFiles/types.h index dae1346f91..3a998622f3 100644 --- a/Telegram/SourceFiles/types.h +++ b/Telegram/SourceFiles/types.h @@ -443,3 +443,13 @@ enum ForwardWhatMessages { ForwardPressedMessage, ForwardPressedLinkMessage }; + +enum ShowLayerOption { + CloseOtherLayers = 0x00, + KeepOtherLayers = 0x01, + ShowAfterOtherLayers = 0x03, + + AnimatedShowLayer = 0x00, + ForceFastShowLayer = 0x04, +}; +typedef QFlags ShowLayerOptions; diff --git a/Telegram/SourceFiles/window.cpp b/Telegram/SourceFiles/window.cpp index ada34c9e4e..aa47b1f776 100644 --- a/Telegram/SourceFiles/window.cpp +++ b/Telegram/SourceFiles/window.cpp @@ -474,7 +474,7 @@ QWidget *Window::filedialogParent() { } void Window::clearWidgets() { - hideLayer(true); + Ui::hideLayer(true); if (_passcode) { _passcode->hide(); _passcode->deleteLater(); @@ -679,7 +679,7 @@ void Window::showSettings() { if (isHidden()) showFromTray(); - App::wnd()->hideLayer(); + Ui::hideLayer(); if (settings) { return hideSettings(); } @@ -774,49 +774,65 @@ void Window::showPhoto(const PhotoLink *lnk, HistoryItem *item) { } void Window::showPhoto(PhotoData *photo, HistoryItem *item) { - hideLayer(true); + Ui::hideLayer(true); _mediaView->showPhoto(photo, item); _mediaView->activateWindow(); _mediaView->setFocus(); } void Window::showPhoto(PhotoData *photo, PeerData *peer) { - hideLayer(true); + Ui::hideLayer(true); _mediaView->showPhoto(photo, peer); _mediaView->activateWindow(); _mediaView->setFocus(); } void Window::showDocument(DocumentData *doc, HistoryItem *item) { - hideLayer(true); + Ui::hideLayer(true); _mediaView->showDocument(doc, item); _mediaView->activateWindow(); _mediaView->setFocus(); } -void Window::showLayer(LayeredWidget *w, bool forceFast) { - bool fast = forceFast || layerShown(); - hideLayer(true); - layerBg = new BackgroundWidget(this, w); - if (fast) { - layerBg->showFast(); +void Window::ui_showLayer(LayeredWidget *box, ShowLayerOptions options) { + if (box) { + bool fast = (options.testFlag(ForceFastShowLayer)) || Ui::isLayerShown(); + if (layerBg) { + if (options.testFlag(KeepOtherLayers)) { + if (options.testFlag(ShowAfterOtherLayers)) { + layerBg->showLayerLast(box); + return; + } else { + layerBg->replaceInner(box); + return; + } + } else { + layerBg->onClose(); + layerBg->hide(); + layerBg->deleteLater(); + layerBg = 0; + } + } + + layerBg = new BackgroundWidget(this, box); + if (fast) { + layerBg->showFast(); + } + } else { + if (layerBg) { + layerBg->onClose(); + if (options.testFlag(ForceFastShowLayer)) { + layerBg->hide(); + layerBg->deleteLater(); + layerBg = 0; + } + } + hideMediaview(); } } -void Window::replaceLayer(LayeredWidget *w) { - if (layerBg) { - layerBg->replaceInner(w); - } else { - layerBg = new BackgroundWidget(this, w); - } -} - -void Window::showLayerLast(LayeredWidget *w) { - if (layerBg) { - layerBg->showLayerLast(w); - } else { - layerBg = new BackgroundWidget(this, w); - } +bool Window::ui_isLayerShown() { + return !!layerBg; } void Window::showConnecting(const QString &text, const QString &reconnect) { @@ -843,29 +859,6 @@ void Window::hideConnecting() { if (settings) settings->update(); } -void Window::hideLayer(bool fast) { - if (layerBg) { - layerBg->onClose(); - if (fast) { - layerBg->hide(); - layerBg->deleteLater(); - layerBg = 0; - } - } - hideMediaview(); -} - -bool Window::hideInnerLayer() { - if (layerBg) { - return layerBg->onInnerClose(); - } - return true; -} - -bool Window::layerShown() { - return !!layerBg; -} - bool Window::historyIsActive() const { return isActive(false) && main && main->historyIsActive() && (!settings || !settings->isVisible()); } @@ -1090,13 +1083,13 @@ void Window::onShowAddContact() { void Window::onShowNewGroup() { if (isHidden()) showFromTray(); - if (main) replaceLayer(new GroupInfoBox(CreatingGroupGroup, false)); + if (main) Ui::showLayer(new GroupInfoBox(CreatingGroupGroup, false), KeepOtherLayers); } void Window::onShowNewChannel() { if (isHidden()) showFromTray(); - if (main) replaceLayer(new GroupInfoBox(CreatingGroupChannel, false)); + if (main) Ui::showLayer(new GroupInfoBox(CreatingGroupChannel, false), KeepOtherLayers); } void Window::onLogout() { @@ -1104,7 +1097,7 @@ void Window::onLogout() { ConfirmBox *box = new ConfirmBox(lang(lng_sure_logout), lang(lng_settings_logout), st::attentionBoxButton); connect(box, SIGNAL(confirmed()), this, SLOT(onLogoutSure())); - App::wnd()->showLayer(box); + Ui::showLayer(box); } void Window::onLogoutSure() { @@ -1198,7 +1191,7 @@ void Window::toggleTray(QSystemTrayIcon::ActivationReason reason) { void Window::toggleDisplayNotifyFromTray() { if (App::passcoded()) { if (!isActive()) showFromTray(); - showLayer(new InformBox(lang(lng_passcode_need_unblock))); + Ui::showLayer(new InformBox(lang(lng_passcode_need_unblock))); return; } cSetDesktopNotify(!cDesktopNotify()); @@ -1781,9 +1774,7 @@ void Window::sendPaths() { if (settings) { hideSettings(); } else { - if (layerShown()) { - hideLayer(); - } + Ui::hideLayer(); if (main) { main->activate(); } diff --git a/Telegram/SourceFiles/window.h b/Telegram/SourceFiles/window.h index ba8b818252..2fed69a3b4 100644 --- a/Telegram/SourceFiles/window.h +++ b/Telegram/SourceFiles/window.h @@ -182,14 +182,8 @@ public: void showPhoto(PhotoData *photo, PeerData *item); void showDocument(DocumentData *doc, HistoryItem *item); - void showLayer(LayeredWidget *w, bool forceFast = false); - void replaceLayer(LayeredWidget *w); - void showLayerLast(LayeredWidget *w); - - void hideLayer(bool fast = false); - bool hideInnerLayer(); - - bool layerShown(); + void ui_showLayer(LayeredWidget *box, ShowLayerOptions options); + bool ui_isLayerShown(); bool historyIsActive() const; diff --git a/Telegram/Telegram.pro b/Telegram/Telegram.pro index 8c851b7b25..4ff133b83a 100644 --- a/Telegram/Telegram.pro +++ b/Telegram/Telegram.pro @@ -89,6 +89,7 @@ SOURCES += \ ./SourceFiles/autoupdater.cpp \ ./SourceFiles/dialogswidget.cpp \ ./SourceFiles/dropdown.cpp \ + ./SourceFiles/facades.cpp \ ./SourceFiles/fileuploader.cpp \ ./SourceFiles/history.cpp \ ./SourceFiles/historywidget.cpp \ @@ -112,6 +113,7 @@ SOURCES += \ ./SourceFiles/types.cpp \ ./SourceFiles/window.cpp \ ./SourceFiles/mtproto/mtp.cpp \ + ./SourceFiles/mtproto/mtpAuthKey.cpp \ ./SourceFiles/mtproto/mtpConnection.cpp \ ./SourceFiles/mtproto/mtpCoreTypes.cpp \ ./SourceFiles/mtproto/mtpDC.cpp \ @@ -175,6 +177,7 @@ HEADERS += \ ./SourceFiles/countries.h \ ./SourceFiles/dialogswidget.h \ ./SourceFiles/dropdown.h \ + ./SourceFiles/facades.h \ ./SourceFiles/fileuploader.h \ ./SourceFiles/history.h \ ./SourceFiles/historywidget.h \