Ejemplo n.º 1
0
void ActionsWidget::notifyPeerUpdated(const Notify::PeerUpdate &update) {
	if (update.peer != peer()) {
		return;
	}

	auto needFullRefresh = [&update, this]() {
		if (update.flags & UpdateFlag::BotCommandsChanged) {
			if (_hasBotHelp != hasBotCommand(qsl("help")) || _hasBotSettings != hasBotCommand(qsl("settings"))) {
				return true;
			}
		}
		return false;
	};
	if (needFullRefresh()) {
		refreshButtons();
	} else {
		if (update.flags & UpdateFlag::MembersChanged) {
			refreshDeleteChannel();
		}
		if (update.flags & UpdateFlag::ChannelAmIn) {
			refreshLeaveChannel();
		}
		if (update.flags & UpdateFlag::UserIsBlocked) {
			refreshBlockUser();
		}
		refreshVisibility();
	}

	contentSizeUpdated();
}
Ejemplo n.º 2
0
void InfoWidget::refreshLabels() {
	refreshAbout();
	refreshMobileNumber();
	refreshUsername();
	refreshChannelLink();

	refreshVisibility();
}
Ejemplo n.º 3
0
InviteLinkWidget::InviteLinkWidget(QWidget *parent, PeerData *peer) : BlockWidget(parent, peer, lang(lng_profile_invite_link_section)) {
	auto observeEvents = UpdateFlag::InviteLinkChanged | UpdateFlag::UsernameChanged;
	subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) {
		notifyPeerUpdated(update);
	}));

	refreshLink();
	refreshVisibility();
}
Ejemplo n.º 4
0
void InviteLinkWidget::notifyPeerUpdated(const Notify::PeerUpdate &update) {
	if (update.peer != peer()) {
		return;
	}

	if (update.flags & (UpdateFlag::InviteLinkChanged | UpdateFlag::UsernameChanged)) {
		refreshLink();
		refreshVisibility();

		contentSizeUpdated();
	}
}
void ChannelMembersWidget::notifyPeerUpdated(const Notify::PeerUpdate &update) {
	if (update.peer != peer()) {
		return;
	}

	if (update.flags & (UpdateFlag::ChannelCanViewAdmins | UpdateFlag::AdminsChanged)) {
		refreshAdmins();
	}
	if (update.flags & (UpdateFlag::ChannelCanViewMembers | UpdateFlag::MembersChanged)) {
		refreshMembers();
	}
	refreshVisibility();

	contentSizeUpdated();
}
SharedMediaWidget::SharedMediaWidget(QWidget *parent, PeerData *peer) : BlockWidget(parent, peer, lang(lng_profile_shared_media))
, _history(App::history(peer))
, _migrated(peer->migrateFrom() ? App::history(peer->migrateFrom()) : nullptr) {
	auto observeEvents = Notify::PeerUpdate::Flag::SharedMediaChanged;
	subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) {
		notifyPeerUpdated(update);
	}));

	App::main()->preloadOverviews(peer);
	if (_migrated) {
		App::main()->preloadOverviews(_migrated->peer);
	}

	refreshButtons();
	refreshVisibility();
}
void SharedMediaWidget::notifyPeerUpdated(const Notify::PeerUpdate &update) {
	if (update.peer != peer() && (!_migrated || update.peer != _migrated->peer)) {
		return;
	}

	bool updated = false;
	for (int i = 0; i < OverviewCount; ++i) {
		if (update.mediaTypesMask & (1 << i)) {
			refreshButton(static_cast<MediaOverviewType>(i));
			updated = true;
		}
	}
	if (updated) {
		refreshVisibility();

		contentSizeUpdated();
	}
}
Ejemplo n.º 8
0
void InfoWidget::notifyPeerUpdated(const Notify::PeerUpdate &update) {
	if (update.peer != peer()) {
		return;
	}

	if (update.flags & UpdateFlag::AboutChanged) {
		refreshAbout();
	}
	if (update.flags & UpdateFlag::UsernameChanged) {
		refreshUsername();
		refreshChannelLink();
	}
	if (update.flags & (UpdateFlag::UserPhoneChanged | UpdateFlag::UserCanShareContact)) {
		refreshMobileNumber();
	}
	refreshVisibility();

	contentSizeUpdated();
}
Ejemplo n.º 9
0
void ActionsWidget::refreshButtons() {
	auto buttons = base::take(_buttons);
	for_const (auto &button, buttons) {
		delete button;
	}
	_blockUser = _leaveChannel = nullptr;

	if (auto user = peer()->asUser()) {
		if ((_hasBotHelp = hasBotCommand(qsl("help")))) {
			addButton(lang(lng_profile_bot_help), SLOT(onBotHelp()));
		}
		if ((_hasBotSettings = hasBotCommand(qsl("settings")))) {
			addButton(lang(lng_profile_bot_settings), SLOT(onBotSettings()));
		}
		addButton(lang(lng_profile_clear_history), SLOT(onClearHistory()));
		addButton(lang(lng_profile_delete_conversation), SLOT(onDeleteConversation()));
		if (user->botInfo) {
			addButton(lang(lng_profile_report), SLOT(onReport()), st::defaultLeftOutlineButton, st::profileBlockOneLineSkip);
		}
		refreshBlockUser();
	} else if (auto chat = peer()->asChat()) {
		if (chat->amCreator()) {
			addButton(lang(lng_profile_migrate_button), SLOT(onUpgradeToSupergroup()));
		}
		addButton(lang(lng_profile_clear_history), SLOT(onClearHistory()));
		addButton(lang(lng_profile_clear_and_exit), SLOT(onDeleteConversation()));
	} else if (auto channel = peer()->asChannel()) {
		if (!channel->amCreator() && (!channel->isMegagroup() || channel->isPublic())) {
			addButton(lang(lng_profile_report), SLOT(onReport()));
		}
		refreshDeleteChannel();
		refreshLeaveChannel();
	}

	refreshVisibility();
}
Ejemplo n.º 10
0
void
NodeAnim::onFrameRangeKnobChanged()
{
    refreshVisibility();
}
void ChannelMembersWidget::refreshButtons() {
	refreshAdmins();
	refreshMembers();

	refreshVisibility();
}