예제 #1
0
/*!	\brief Actually draws the close button

	Unless a subclass has a particularly large button, it is probably
	unnecessary to check the update rectangle.

	\param tab The \a tab to update.
	\param direct Draw without double buffering.
	\param rect The area of the button to update.
*/
void
WinDecorator::_DrawClose(Decorator::Tab* tab, bool direct, BRect rect)
{
	STRACE(("_DrawClose(%f, %f, %f, %f)\n", rect.left, rect.top, rect.right,
		rect.bottom));

	// Just like DrawZoom, but for a close button
	_DrawBeveledRect(rect, tab->closePressed);

	// Draw the X

	BRect closeBox(rect);
	closeBox.InsetBy(4, 4);
	closeBox.right--;
	closeBox.top--;

	if (true)
		closeBox.OffsetBy(1, 1);

	fDrawingEngine->SetHighColor(RGBColor(0, 0, 0));
	fDrawingEngine->StrokeLine(closeBox.LeftTop(), closeBox.RightBottom());
	fDrawingEngine->StrokeLine(closeBox.RightTop(), closeBox.LeftBottom());
	closeBox.OffsetBy(1, 0);
	fDrawingEngine->StrokeLine(closeBox.LeftTop(), closeBox.RightBottom());
	fDrawingEngine->StrokeLine(closeBox.RightTop(), closeBox.LeftBottom());
}
예제 #2
0
void AboutBox::keyPressEvent(QKeyEvent *e) {
	if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) {
		closeBox();
	} else {
		BoxContent::keyPressEvent(e);
	}
}
예제 #3
0
void AbstractBox::keyPressEvent(QKeyEvent *e) {
	if (e->key() == Qt::Key_Escape) {
		closeBox();
	} else {
		LayerWidget::keyPressEvent(e);
	}
}
예제 #4
0
void ConfirmPhoneBox::prepare() {

	_about.create(this, st::confirmPhoneAboutLabel);
	TextWithEntities aboutText;
	auto formattedPhone = App::formatPhone(_phone);
	aboutText.text = lng_confirm_phone_about(lt_phone, formattedPhone);
	auto phonePosition = aboutText.text.indexOf(formattedPhone);
	if (phonePosition >= 0) {
		aboutText.entities.push_back(EntityInText(EntityInTextBold, phonePosition, formattedPhone.size()));
	}
	_about->setMarkedText(aboutText);

	_code.create(this, st::confirmPhoneCodeField, lang(lng_code_ph));

	setTitle(lang(lng_confirm_phone_title));

	addButton(lang(lng_confirm_phone_send), [this] { onSendCode(); });
	addButton(lang(lng_cancel), [this] { closeBox(); });

	setDimensions(st::boxWidth, st::usernamePadding.top() + _code->height() + st::usernameSkip + _about->height() + st::usernameSkip);

	connect(_code, SIGNAL(changed()), this, SLOT(onCodeChanged()));
	connect(_code, SIGNAL(submitted(bool)), this, SLOT(onSendCode()));

	connect(_callTimer, SIGNAL(timeout()), this, SLOT(onCallStatusTimer()));

	showChildren();
}
예제 #5
0
bool UsernameBox::onUpdateFail(const RPCError &error) {
	if (MTP::isDefaultHandledError(error)) return false;

	_saveRequestId = 0;
	QString err(error.type());
	if (err == qstr("USERNAME_NOT_MODIFIED") || _sentUsername == App::self()->username) {
		App::self()->setName(TextUtilities::SingleLine(App::self()->firstName), TextUtilities::SingleLine(App::self()->lastName), TextUtilities::SingleLine(App::self()->nameOrPhone), TextUtilities::SingleLine(_sentUsername));
		closeBox();
		return true;
	} else if (err == qstr("USERNAME_INVALID")) {
		_username->setFocus();
		_username->showError();
		_errorText = lang(lng_username_invalid);
		update();
		return true;
	} else if (err == qstr("USERNAME_OCCUPIED") || err == qstr("USERNAMES_UNAVAILABLE")) {
		_username->setFocus();
		_username->showError();
		_errorText = lang(lng_username_occupied);
		update();
		return true;
	}
	_username->setFocus();
	return true;
}
예제 #6
0
void ChangePhoneBox::EnterCode::prepare() {
	setTitle(langFactory(lng_change_phone_title));

	auto descriptionText = lng_change_phone_code_description(lt_phone, textcmdStartSemibold() + App::formatPhone(_phone) + textcmdStopSemibold());
	auto description = object_ptr<Ui::FlatLabel>(this, descriptionText, Ui::FlatLabel::InitType::Rich, st::changePhoneLabel);
	description->moveToLeft(st::boxPadding.left(), 0);

	auto phoneValue = QString();
	_code.create(this, st::defaultInputField, langFactory(lng_change_phone_code_title), phoneValue);
	_code->setAutoSubmit(_codeLength, [=] { submit(); });
	_code->setChangedCallback([=] { hideError(); });

	_code->resize(st::boxWidth - 2 * st::boxPadding.left(), _code->height());
	_code->moveToLeft(st::boxPadding.left(), description->bottomNoMargins());
	connect(_code, &Ui::InputField::submitted, [=] { submit(); });

	setDimensions(st::boxWidth, countHeight());

	if (_callTimeout > 0) {
		_call.setStatus({ SentCodeCall::State::Waiting, _callTimeout });
		updateCall();
	}

	addButton(langFactory(lng_change_phone_new_submit), [=] { submit(); });
	addButton(langFactory(lng_cancel), [=] { closeBox(); });
}
예제 #7
0
void ManagePeerBox::prepare() {
	_channel->updateFull();

	setTitle(ManagePeerTitle(_channel));
	addButton(langFactory(lng_cancel), [this] { closeBox(); });

	setupContent();
}
예제 #8
0
void AddContactBox::updateButtons() {
	clearButtons();
	if (_retrying) {
		addButton(lang(lng_try_other_contact), [this] { onRetry(); });
	} else {
		addButton(lang(_user ? lng_settings_save : lng_add_contact), [this] { onSave(); });
		addButton(lang(lng_cancel), [this] { closeBox(); });
	}
}
예제 #9
0
void AboutBox::prepare() {
	setTitle(qsl("Telegram Desktop"));

	addButton(lang(lng_close), [this] { closeBox(); });

	_text3->setRichText(lng_about_text_3(lt_faq_open, qsl("[a href=\"%1\"]").arg(telegramFaqLink()), lt_faq_close, qsl("[/a]")));

	_version->setClickedCallback([this] { showVersionHistory(); });

	setDimensions(st::aboutWidth, st::aboutTextTop + _text1->height() + st::aboutSkip + _text2->height() + st::aboutSkip + _text3->height());
}
예제 #10
0
파일: box.c 프로젝트: Clay-Birkett/monetdb
str
BOXclose(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
	str name;

	(void) cntxt;
	(void) mb;		/*fool compiler */
	name = *(str *) getArgReference(stk, pci, 1);
	if (closeBox(name, FALSE) == 0)
		return MAL_SUCCEED;
	throw(MAL, "box.close", BOX_CLOSED);
}
예제 #11
0
void ReportBox::prepare() {
	setTitle(lang(_peer->isUser() ? lng_report_bot_title : (_peer->isMegagroup() ? lng_report_group_title : lng_report_title)));

	addButton(lang(lng_report_button), [this] { onReport(); });
	addButton(lang(lng_cancel), [this] { closeBox(); });

	connect(_reasonSpam, SIGNAL(changed()), this, SLOT(onChange()));
	connect(_reasonViolence, SIGNAL(changed()), this, SLOT(onChange()));
	connect(_reasonPornography, SIGNAL(changed()), this, SLOT(onChange()));
	connect(_reasonOther, SIGNAL(changed()), this, SLOT(onChange()));

	updateMaxHeight();
}
예제 #12
0
void AutoLockBox::onChange() {
	if (!isBoxShown()) return;

	for (int32 i = 0, l = _options.size(); i < l; ++i) {
		int32 v = _options[i]->val();
		if (_options[i]->checked()) {
			Global::SetAutoLock(v);
			Local::writeUserSettings();
			Global::RefLocalPasscodeChanged().notify();
		}
	}
	App::wnd()->checkAutoLock();
	closeBox();
}
예제 #13
0
void StickersBox::prepare() {
	if (_section == Section::Installed) {
		Local::readArchivedStickers();
	} else if (_section == Section::Archived) {
		requestArchivedSets();
	} else if (_section == Section::ArchivedPart) {
		setTitle(lang(lng_stickers_archived));
	}
	if (Global::ArchivedStickerSetsOrder().isEmpty()) {
		preloadArchivedSets();
	}
	if (_tabs) {
		setNoContentMargin(true);
		_tabs->setSectionActivatedCallback([this] {
			switchTab();
		});
		refreshTabs();
	}
	if (_installed.widget() && _section != Section::Installed) _installed.widget()->hide();
	if (_featured.widget() && _section != Section::Featured) _featured.widget()->hide();
	if (_section != Section::Archived && _section != Section::ArchivedPart) _archived.widget()->hide();

	if (_featured.widget()) {
		_featured.widget()->setInstallSetCallback([this](uint64 setId) { installSet(setId); });
	}
	_archived.widget()->setInstallSetCallback([this](uint64 setId) { installSet(setId); });
	_archived.widget()->setLoadMoreCallback([this] { loadMoreArchived(); });

	addButton(lang(lng_about_done), [this] { closeBox(); });

	if (_section == Section::Installed) {
		_tab = &_installed;
	} else if (_section == Section::ArchivedPart) {
		_aboutHeight = st::stickersReorderPadding.top() + _about.countHeight(_aboutWidth) + st::stickersReorderPadding.bottom();
		_titleShadow.create(this);
		_tab = &_archived;
	} else if (_section == Section::Archived) {
		_tab = &_archived;
	} else { // _section == Section::Featured
		_tab = &_featured;
	}
	setInnerWidget(_tab->takeWidget(), getTopSkip());
	setDimensions(st::boxWideWidth, (_section == Section::ArchivedPart) ? st::sessionsHeight : st::boxMaxListHeight);

	connect(App::main(), SIGNAL(stickersUpdated()), this, SLOT(onStickersUpdated()));
	App::main()->updateStickers();

	if (_installed.widget()) {
		connect(_installed.widget(), SIGNAL(draggingScrollDelta(int)), this, SLOT(onDraggingScrollDelta(int)));
	}
예제 #14
0
void ChangePhoneBox::prepare() {
	setTitle(langFactory(lng_change_phone_title));
	addButton(langFactory(lng_change_phone_button), [] {
		Ui::show(Box<ConfirmBox>(lang(lng_change_phone_warning), [] {
			Ui::show(Box<EnterPhone>());
		}));
	});
	addButton(langFactory(lng_cancel), [this] {
		closeBox();
	});

	auto label = object_ptr<Ui::FlatLabel>(this, lang(lng_change_phone_description), Ui::FlatLabel::InitType::Rich, st::changePhoneDescription);
	label->moveToLeft((st::boxWideWidth - label->width()) / 2, st::changePhoneDescriptionTop);

	setDimensions(st::boxWideWidth, label->bottomNoMargins() + st::boxLittleSkip);
}
예제 #15
0
void MembersBox::prepare() {
	setTitle(lang(_filter == MembersFilter::Recent ? lng_channel_members : lng_channel_admins));

	_inner = setInnerWidget(object_ptr<Inner>(this, _channel, _filter), st::boxLayerScroll);

	setDimensions(st::boxWideWidth, st::boxMaxListHeight);
	addButton(lang(lng_close), [this] { closeBox(); });
	if (_channel->amCreator() && (_channel->membersCount() < (_channel->isMegagroup() ? Global::MegagroupSizeMax() : Global::ChatSizeMax()) || (!_channel->isMegagroup() && !_channel->isPublic()) || _filter == MembersFilter::Admins)) {
		addLeftButton(lang((_filter == MembersFilter::Admins) ? lng_channel_add_admin : lng_channel_add_members), [this] { onAdd(); });
	}

	connect(_inner, SIGNAL(mustScrollTo(int, int)), this, SLOT(onScrollToY(int, int)));

	_loadTimer.create(this);
	connect(_loadTimer, SIGNAL(timeout()), _inner, SLOT(load()));
}
예제 #16
0
void LocalStorageBox::prepare() {
	setTitle(langFactory(lng_local_storage_title));

	addButton(langFactory(lng_box_ok), [this] { closeBox(); });

	_clear->setClickedCallback([this] { clearStorage(); });

	connect(App::wnd(), SIGNAL(tempDirCleared(int)), this, SLOT(onTempDirCleared(int)));
	connect(App::wnd(), SIGNAL(tempDirClearFailed(int)), this, SLOT(onTempDirClearFailed(int)));

	subscribe(Auth().downloaderTaskFinished(), [this] { update(); });

	updateControls();

	checkLocalStoredCounts();
}
예제 #17
0
void AutoLockBox::prepare() {
	setTitle(lang(lng_passcode_autolock));

	addButton(lang(lng_box_ok), [this] { closeBox(); });

	int opts[] = { 60, 300, 3600, 18000 }, cnt = sizeof(opts) / sizeof(opts[0]);
	auto y = st::boxOptionListPadding.top();
	_options.reserve(cnt);
	for (auto i = 0; i != cnt; ++i) {
		auto v = opts[i];
		_options.push_back(new Ui::Radiobutton(this, qsl("autolock"), v, (v % 3600) ? lng_passcode_autolock_minutes(lt_count, v / 60) : lng_passcode_autolock_hours(lt_count, v / 3600), (Global::AutoLock() == v), st::langsButton));
		_options.back()->move(st::boxPadding.left() + st::boxOptionListPadding.left(), y);
		y += _options.back()->heightNoMargins() + st::boxOptionListSkip;
		connect(_options.back(), SIGNAL(changed()), this, SLOT(onChange()));
	}

	setDimensions(st::langsWidth, st::boxOptionListPadding.top() + cnt * st::langsButton.height + (cnt - 1) * st::boxOptionListSkip + st::boxOptionListPadding.bottom() + st::boxPadding.bottom());
}
예제 #18
0
bool AddContactBox::onSaveUserFail(const RPCError &error) {
	if (MTP::isDefaultHandledError(error)) return false;

	_addRequest = 0;
	QString err(error.type());
	QString firstName = _first->getLastText().trimmed(), lastName = _last->getLastText().trimmed();
	if (err == "CHAT_TITLE_NOT_MODIFIED") {
		_user->setName(firstName, lastName, _user->nameOrPhone, _user->username);
		closeBox();
		return true;
	} else if (err == "NO_CHAT_TITLE") {
		_first->setFocus();
		_first->showError();
		return true;
	}
	_first->setFocus();
	return true;
}
예제 #19
0
bool ChangePhoneBox::EnterCode::sendCodeFail(const RPCError &error) {
	auto errorText = Lang::Hard::ServerError();
	if (MTP::isFloodError(error)) {
		errorText = lang(lng_flood_error);
	} else if (MTP::isDefaultHandledError(error)) {
		return false;
	} else if (error.type() == qstr("PHONE_CODE_EMPTY") || error.type() == qstr("PHONE_CODE_INVALID")) {
		errorText = lang(lng_bad_code);
	} else if (error.type() == qstr("PHONE_CODE_EXPIRED")) {
		closeBox(); // Go back to phone input.
		_requestId = 0;
		return true;
	} else if (error.type() == qstr("PHONE_NUMBER_INVALID")) {
		errorText = lang(lng_bad_phone);
	}
	_requestId = 0;
	showError(errorText);
	return true;
}
예제 #20
0
void ChangePhoneBox::EnterPhone::prepare() {
	setTitle(langFactory(lng_change_phone_title));

	auto phoneValue = QString();
	_phone.create(this, st::defaultInputField, langFactory(lng_change_phone_new_title), phoneValue);

	_phone->resize(st::boxWidth - 2 * st::boxPadding.left(), _phone->height());
	_phone->moveToLeft(st::boxPadding.left(), st::boxLittleSkip);
	connect(_phone, &Ui::PhoneInput::submitted, [=] { submit(); });

	auto description = object_ptr<Ui::FlatLabel>(this, lang(lng_change_phone_new_description), Ui::FlatLabel::InitType::Simple, st::changePhoneLabel);
	auto errorSkip = st::boxLittleSkip + st::changePhoneError.style.font->height;
	description->moveToLeft(st::boxPadding.left(), _phone->y() + _phone->height() + errorSkip + st::boxLittleSkip);

	setDimensions(st::boxWidth, description->bottomNoMargins() + st::boxLittleSkip);

	addButton(langFactory(lng_change_phone_new_submit), [this] { submit(); });
	addButton(langFactory(lng_cancel), [this] { closeBox(); });
}
예제 #21
0
void UsernameBox::prepare() {
	_goodText = App::self()->username.isEmpty() ? QString() : lang(lng_username_available);

	setTitle(langFactory(lng_username_title));

	addButton(langFactory(lng_settings_save), [this] { onSave(); });
	addButton(langFactory(lng_cancel), [this] { closeBox(); });

	connect(_username, SIGNAL(changed()), this, SLOT(onChanged()));
	connect(_username, SIGNAL(submitted(bool)), this, SLOT(onSave()));
	connect(_link, SIGNAL(clicked()), this, SLOT(onLinkClick()));

	_about.setRichText(st::usernameTextStyle, lang(lng_username_about));
	setDimensions(st::boxWidth, st::usernamePadding.top() + _username->height() + st::usernameSkip + _about.countHeight(st::boxWidth - st::usernamePadding.left()) + 3 * st::usernameTextStyle.lineHeight + st::usernamePadding.bottom());

	_checkTimer->setSingleShot(true);
	connect(_checkTimer, SIGNAL(timeout()), this, SLOT(onCheck()));

	updateLinkText();
}
예제 #22
0
void SessionsBox::prepare() {
	setTitle(langFactory(lng_sessions_other_header));

	addButton(langFactory(lng_close), [this] { closeBox(); });

	setDimensions(st::boxWideWidth, st::sessionsHeight);

	connect(_inner, SIGNAL(oneTerminated()), this, SLOT(onOneTerminated()));
	connect(_inner, SIGNAL(allTerminated()), this, SLOT(onAllTerminated()));
	connect(_inner, SIGNAL(terminateAll()), this, SLOT(onTerminateAll()));
	connect(App::wnd(), SIGNAL(checkNewAuthorization()), this, SLOT(onCheckNewAuthorization()));
	connect(_shortPollTimer, SIGNAL(timeout()), this, SLOT(onShortPollAuthorizations()));

	_inner = setInnerWidget(object_ptr<Inner>(this, &_list, &_current), st::sessionsScroll);
	_inner->resize(width(), st::noContactsHeight);

	setLoading(true);

	MTP::send(MTPaccount_GetAuthorizations(), rpcDone(&SessionsBox::gotAuthorizations));
}
void UsernameBox::prepare() {
	_goodText = App::self()->username.isEmpty() ? QString() : lang(lng_username_available);

	setTitle(langFactory(lng_username_title));

	addButton(langFactory(lng_settings_save), [=] { save(); });
	addButton(langFactory(lng_cancel), [=] { closeBox(); });

	connect(_username, &Ui::MaskedInputField::changed, [=] { changed(); });
	connect(_username, &Ui::MaskedInputField::submitted, [=] { save(); });
	_link->addClickHandler([=] { linkClick(); });

	_about.setRichText(st::usernameTextStyle, lang(lng_username_about));
	setDimensions(st::boxWidth, st::usernamePadding.top() + _username->height() + st::usernameSkip + _about.countHeight(st::boxWidth - st::usernamePadding.left()) + 3 * st::usernameTextStyle.lineHeight + st::usernamePadding.bottom());

	_checkTimer->setSingleShot(true);
	connect(_checkTimer, &QTimer::timeout, [=] { check(); });

	updateLinkText();
}
void CalendarBox::prepare() {
	_previous->setClickedCallback([this] {
		if (isPreviousEnabled()) {
			_context->skipMonth(-1);
		}
	});
	_next->setClickedCallback([this] {
		if (isNextEnabled()) {
			_context->skipMonth(1);
		}
	});

//	_inner = setInnerWidget(object_ptr<Inner>(this, _context.get()), st::calendarScroll, st::calendarTitleHeight);
	_inner->setDateChosenCallback(std::move(_callback));

	addButton(langFactory(lng_close), [this] { closeBox(); });

	subscribe(_context->month(), [this](QDate month) { monthChanged(month); });

	_context->start();
}
void AboutBox::prepare() {
	setTitle([] { return qsl("Telegram Desktop"); });

	addButton(langFactory(lng_close), [this] { closeBox(); });

	const auto linkFilter = [](const ClickHandlerPtr &link, auto button) {
		if (const auto url = dynamic_cast<UrlClickHandler*>(link.get())) {
			url->UrlClickHandler::onClick({ button });
			return false;
		}
		return true;
	};

	_text3->setRichText(lng_about_text_3(lt_faq_open, qsl("[a href=\"%1\"]").arg(telegramFaqLink()), lt_faq_close, qsl("[/a]")));
	_text1->setClickHandlerFilter(linkFilter);
	_text2->setClickHandlerFilter(linkFilter);
	_text3->setClickHandlerFilter(linkFilter);

	_version->setClickedCallback([this] { showVersionHistory(); });

	setDimensions(st::aboutWidth, st::aboutTextTop + _text1->height() + st::aboutSkip + _text2->height() + st::aboutSkip + _text3->height());
}
예제 #26
0
	_title->setMaxLength(MaxGroupChannelTitle);

	if (_creating == CreatingGroupChannel) {
		_description.create(this, st::newGroupDescription, lang(lng_create_group_description));
		_description->show();
		_description->setMaxLength(MaxChannelDescription);

		connect(_description, SIGNAL(resized()), this, SLOT(onDescriptionResized()));
		connect(_description, SIGNAL(submitted(bool)), this, SLOT(onNext()));
		connect(_description, SIGNAL(cancelled()), this, SLOT(onClose()));
	}

	connect(_title, SIGNAL(submitted(bool)), this, SLOT(onNameSubmit()));

	addButton(lang(_creating == CreatingGroupChannel ? lng_create_group_create : lng_create_group_next), [this] { onNext(); });
	addButton(lang(_fromTypeChoose ? lng_create_group_back : lng_cancel), [this] { closeBox(); });

	_photo->setClickedCallback(App::LambdaDelayed(st::defaultActiveButton.ripple.hideDuration, this, [this] {
		auto imgExtensions = cImgExtensions();
		auto filter = qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;") + filedialogAllFilesFilter();
		_setPhotoFileQueryId = FileDialog::queryReadFile(lang(lng_choose_image), filter);
	}));
	subscribe(FileDialog::QueryDone(), [this](const FileDialog::QueryUpdate &update) {
		notifyFileQueryUpdated(update);
	});

	updateMaxHeight();
}

void GroupInfoBox::setInnerFocus() {
	_title->setFocusFast();
예제 #27
0
void AddContactBox::onSaveUserDone(const MTPcontacts_ImportedContacts &res) {
	auto &d = res.c_contacts_importedContacts();
	App::feedUsers(d.vusers);
	closeBox();
}
void DeleteDocumentBox::prepare() {
	addButton(langFactory(lng_box_delete), _submit);
	addButton(langFactory(lng_cancel), [=] { closeBox(); });

	setDimensions(st::boxWidth, _height);
}
예제 #29
0
void UsernameBox::onUpdateDone(const MTPUser &user) {
	App::feedUsers(MTP_vector<MTPUser>(1, user));
	closeBox();
}