예제 #1
0
void SearchLineEdit::contextMenuEvent(QContextMenuEvent *event)
{
    QMenu *menu = createStandardContextMenu();

    menu->addSeparator();
    QAction *action = menu->addAction(tr("Clear Search History"));
    connect(action, SIGNAL(triggered()), this, SLOT(onClearHistory()));

    menu->exec(event->globalPos());
    delete menu;
}
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();
}
예제 #3
0
ProfileInner::ProfileInner(ProfileWidget *profile, ScrollArea *scroll, const PeerData *peer) : TWidget(0),
	_profile(profile), _scroll(scroll), _peer(App::peer(peer->id)),
	_peerUser(_peer->chat ? 0 : _peer->asUser()), _peerChat(_peer->chat ? _peer->asChat() : 0), _hist(App::history(peer->id)),
	_chatAdmin(_peerChat ? (_peerChat->admin == MTP::authedId()) : false),

	// profile
	_nameCache(peer->name),
	_uploadPhoto(this, lang(lng_profile_set_group_photo), st::btnShareContact),
	_addParticipant(this, lang(lng_profile_add_participant), st::btnShareContact),
	_sendMessage(this, lang(lng_profile_send_message), st::btnShareContact),
	_shareContact(this, lang(lng_profile_share_contact), st::btnShareContact),
	_cancelPhoto(this, lang(lng_cancel)),

	a_photo(0),
	_photoOver(false),

	// settings
	_enableNotifications(this, lang(lng_profile_enable_notifications)),
	_clearHistory(this, lang(lng_profile_clear_history)),

	// shared media
	_allMediaTypes(false),
	_mediaShowAll(this, lang(lng_profile_show_all_types)),
	_mediaPhotos(this, QString()),
	_mediaVideos(this, QString()),
	_mediaDocuments(this, QString()),
	_mediaAudios(this, QString()),

	// participants
	_pHeight(st::profileListPhotoSize + st::profileListPadding.height() * 2),
	_kickWidth(st::linkFont->m.width(lang(lng_profile_kick))),
	_selectedRow(-1), _lastPreload(0), _contactId(0),
	_kickOver(0), _kickDown(0), _kickConfirm(0),
	
	_loadingId(0), _menu(0) {

	if (_peerUser) {
		_phoneText = _peerUser->phone.isEmpty() ? QString() : App::formatPhone(_peerUser->phone);
		_loadingId = MTP::send(MTPusers_GetFullUser(_peerUser->inputUser), rpcDone(&ProfileInner::gotFullUser));
	} else if (_peerChat->photoId) {
		PhotoData *ph = App::photo(_peerChat->photoId);
		if (ph->date) {
			_photoLink = TextLinkPtr(new PhotoLink(ph, _peer));
		}
	} else {
		_loadingId = MTP::send(MTPmessages_GetFullChat(App::peerToMTP(_peerChat->id).c_peerChat().vchat_id), rpcDone(&ProfileInner::gotFullChat));
	}

	// profile
	_nameText.setText(st::profileNameFont, _nameCache, _textNameOptions);

	connect(&_uploadPhoto, SIGNAL(clicked()), this, SLOT(onUpdatePhoto()));
	connect(&_addParticipant, SIGNAL(clicked()), this, SLOT(onAddParticipant()));
	connect(&_sendMessage, SIGNAL(clicked()), this, SLOT(onSendMessage()));
	connect(&_shareContact, SIGNAL(clicked()), this, SLOT(onShareContact()));
	connect(&_cancelPhoto, SIGNAL(clicked()), this, SLOT(onUpdatePhotoCancel()));

	connect(App::app(), SIGNAL(peerPhotoDone(PeerId)), this, SLOT(onPhotoUpdateDone(PeerId)));
	connect(App::app(), SIGNAL(peerPhotoFail(PeerId)), this, SLOT(onPhotoUpdateFail(PeerId)));

	connect(App::main(), SIGNAL(peerPhotoChanged(PeerData *)), this, SLOT(peerUpdated(PeerData *)));
	connect(App::main(), SIGNAL(peerUpdated(PeerData *)), this, SLOT(peerUpdated(PeerData *)));
	connect(App::main(), SIGNAL(peerNameChanged(PeerData *, const PeerData::Names &, const PeerData::NameFirstChars &)), this, SLOT(peerUpdated(PeerData *)));

	// settings
	connect(&_enableNotifications, SIGNAL(clicked()), this, SLOT(onEnableNotifications()));
	connect(&_clearHistory, SIGNAL(clicked()), this, SLOT(onClearHistory()));

	// shared media
	connect(&_mediaShowAll, SIGNAL(clicked()), this, SLOT(onMediaShowAll()));
	connect(&_mediaPhotos, SIGNAL(clicked()), this, SLOT(onMediaPhotos()));
	connect(&_mediaVideos, SIGNAL(clicked()), this, SLOT(onMediaVideos()));
	connect(&_mediaDocuments, SIGNAL(clicked()), this, SLOT(onMediaDocuments()));
	connect(&_mediaAudios, SIGNAL(clicked()), this, SLOT(onMediaAudios()));
	_mediaLinks[OverviewPhotos] = &_mediaPhotos;
	_mediaLinks[OverviewVideos] = &_mediaVideos;
	_mediaLinks[OverviewDocuments] = &_mediaDocuments;
	_mediaLinks[OverviewAudios] = &_mediaAudios;
	App::main()->preloadOverviews(_peer);

	App::contextItem(0);

	resizeEvent(0);
	showAll();
}
예제 #4
0
Controller::Controller() :
    _deviceNeedResolve(0),
    _lastTimeFocused(0),
    _service(&_udpDiscovery, this),
    _udpDiscoveryTimer(this)
{
    _service.moveToThread(&_serviceThread);
    _serviceThread.start();

    _view = new View(&_model);
    _bonjourBrowser = new BonjourServiceBrowser(this);

    connect(&_udpDiscovery, SIGNAL(devicesFound(const QList<Device *> &)), this, SLOT(updateDevices(const QList<Device *> &)));
    connect(&_udpDiscovery, SIGNAL(pongReceived(const QString&)), this, SLOT(onPong(const QString &)));

    connect(_bonjourBrowser, SIGNAL(currentBonjourRecordsChanged(const QList<BonjourRecord> &)),
            this, SLOT(updateRecords(const QList<BonjourRecord> &)));
    connect(_bonjourBrowser, SIGNAL(error(DNSServiceErrorType)),
            this, SLOT(error(DNSServiceErrorType)));

    connect(_view, SIGNAL(sendFile(const QString&, const QList<QUrl>&, DataType)),
            this, SLOT(onSendFile(const QString&, const QList<QUrl>&, DataType)));
    connect(_view, SIGNAL(sendText(const QString&, const QString&, DataType)),
            this, SLOT(onSendText(const QString&, const QString&, DataType)));
    connect(_view, SIGNAL(cancelTransfert(const QString&)),
            this, SLOT(onCancelTransfert(const QString&)));
    connect(_view, SIGNAL(focused()), this, SLOT(onWindowFocused()));
    connect(_view, SIGNAL(forceRefresh()), this, SLOT(onForceRefresh()));

    connect(_view, SIGNAL(registerService()),
            &_service, SLOT(serviceRegister()));
    connect(_view, SIGNAL(unregisterService()),
            &_service, SLOT(serviceUnregister()));
    connect(_view, SIGNAL(deleteFromHistory(int)),
            &_service, SLOT(onDeleteFromHistory(int)));
    connect(_view, SIGNAL(clearHistoryTriggered()),
            &_service, SLOT(onClearHistory()));
    connect(_view, SIGNAL(serviceNameChanged()),
            &_service, SLOT(onTimerOut()));
    connect(_view, SIGNAL(cancelIncomingTransfert()),
            &_service, SLOT(deleteFileReset()));

    connect(&_service, SIGNAL(historyChanged(const QList<HistoryElement>&)),
            _view, SLOT(onHistoryChanged(const QList<HistoryElement>&)));
    connect(&_service, SIGNAL(historyElementProgressUpdated(unsigned)),
            _view, SLOT(historyElementProgressUpdated(unsigned)));

    connect(&_service, SIGNAL(serviceError(ServiceErrorState,bool)),
            _view, SLOT(onServiceError(ServiceErrorState,bool)));
    connect(&_service, SIGNAL(receivingFile(const QString&,int)),
             _view, SLOT(onReceivingFile(const QString&,int)));
    connect(&_service, SIGNAL(receivingFolder(const QString&,int)),
            _view, SLOT(onReceivingFolder(const QString&,int)));
    connect(&_service, SIGNAL(receivingText(const QString&)),
            _view, SLOT(onReceivingText(const QString&)));
    connect(&_service, SIGNAL(receivingUrl(const QString&)),
            _view, SLOT(onReceivingUrl(const QString&)));

    connect(&_model, SIGNAL(newDeviceCreated(Device*)),
            this, SLOT(onNewDeviceCreated(Device*)));
    connect(&_model, SIGNAL(deviceRemoved()),
            _view, SLOT(updateDevices()));

    connect(&_updater, SIGNAL(updateNeeded(const QString&,const QString&)),
            _view, SLOT(onUpdateNeeded(const QString&,const QString&)));

    checkForBonjourState();
    _view->updateDevices();
    _view->onHistoryChanged(_service.getHistory());

    _bonjourBrowser->browseForServiceType(QLatin1String("_fdnd._tcp."));

    connect(&_udpDiscoveryTimer, SIGNAL(timeout()), &_udpDiscovery, SLOT(startDiscovery()));
    _udpDiscoveryTimer.start(UDP_DISCOVERY_INTERVAL);
    _udpDiscovery.startDiscovery();

    createSendTo();
}