Exemple #1
0
void Window::setupTrayIcon() {
	if (!trayIcon) {
		if (trayIconMenu) trayIconMenu->deleteLater();
		trayIconMenu = new QMenu(this);
		trayIconMenu->setFont(QFont("Tahoma"));
		QAction *a;
		a = trayIconMenu->addAction(lang(lng_open_from_tray), this, SLOT(showFromTray()));
		a->setEnabled(true);
		a = trayIconMenu->addAction(lang(lng_quit_from_tray), this, SLOT(quitFromTray()));
		a->setEnabled(true);

		if (trayIcon) trayIcon->deleteLater();
		trayIcon = new QSystemTrayIcon(this);
		trayIcon->setIcon(this->windowIcon());
		trayIcon->setContextMenu(trayIconMenu);
		trayIcon->setToolTip(QString::fromStdWString(AppName));

		connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleTray(QSystemTrayIcon::ActivationReason)));
		connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(showFromTray()));
	}
	psUpdateCounter();
	trayIcon->show();
}	
UpdateStateRow::UpdateStateRow(QWidget *parent) : TWidget(parent)
, _check(this, lang(lng_settings_check_now))
, _restart(this, lang(lng_settings_update_now)) {
	connect(_check, SIGNAL(clicked()), this, SLOT(onCheck()));
	connect(_restart, SIGNAL(clicked()), this, SIGNAL(restart()));

	Sandbox::connect(SIGNAL(updateChecking()), this, SLOT(onChecking()));
	Sandbox::connect(SIGNAL(updateLatest()), this, SLOT(onLatest()));
	Sandbox::connect(SIGNAL(updateProgress(qint64, qint64)), this, SLOT(onDownloading(qint64, qint64)));
	Sandbox::connect(SIGNAL(updateFailed()), this, SLOT(onFailed()));
	Sandbox::connect(SIGNAL(updateReady()), this, SLOT(onReady()));

	_versionText = lng_settings_current_version_label(lt_version, currentVersionText());

	switch (Sandbox::updatingState()) {
	case Application::UpdatingDownload:
		setState(State::Download, true);
		setDownloadProgress(Sandbox::updatingReady(), Sandbox::updatingSize());
	break;
	case Application::UpdatingReady: setState(State::Ready, true); break;
	default: setState(State::None, true); break;
	}
}
Exemple #3
0
DownloadPathBox::DownloadPathBox() : AbstractBox()
, _path(cDownloadPath())
, _pathBookmark(cDownloadPathBookmark())
, _default(this, qsl("dir_type"), 0, lang(lng_download_path_default_radio), _path.isEmpty())
, _temp(this, qsl("dir_type"), 1, lang(lng_download_path_temp_radio), _path == qsl("tmp"))
, _dir(this, qsl("dir_type"), 2, lang(lng_download_path_dir_radio), !_path.isEmpty() && _path != qsl("tmp"))
, _pathLink(this, QString(), st::defaultBoxLinkButton)
, _save(this, lang(lng_connection_save), st::defaultBoxButton)
, _cancel(this, lang(lng_cancel), st::cancelBoxButton) {

	connect(&_save, SIGNAL(clicked()), this, SLOT(onSave()));
	connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose()));

	connect(&_default, SIGNAL(changed()), this, SLOT(onChange()));
	connect(&_temp, SIGNAL(changed()), this, SLOT(onChange()));
	connect(&_dir, SIGNAL(changed()), this, SLOT(onChange()));

	connect(&_pathLink, SIGNAL(clicked()), this, SLOT(onEditPath()));
	if (!_path.isEmpty() && _path != qsl("tmp")) {
		setPathText(QDir::toNativeSeparators(_path));
	}
	prepare();
}
bool Script::CreateAnonymousFunction(VARIANT* result) {
  LOG(TRACE) << "Entering Script::CreateAnonymousFunction";

  CComBSTR function_eval_script(L"window.document.__webdriver_script_fn = ");
  HRESULT hr = function_eval_script.Append(this->source_code_.c_str());
  CComBSTR code(function_eval_script);
  CComBSTR lang(L"JScript");
  CComVariant exec_script_result;

  CComPtr<IHTMLWindow2> window;
  hr = this->script_engine_host_->get_parentWindow(&window);
  if (FAILED(hr)) {
    LOGHR(WARN, hr) << "Unable to get parent window, call to IHTMLDocument2::get_parentWindow failed";
    return false;
  }

  hr = window->execScript(code, lang, &exec_script_result);
  if (FAILED(hr)) {
    LOGHR(WARN, hr) << "Unable to execute code, call to IHTMLWindow2::execScript failed";
    return false;
  }

  OLECHAR FAR* function_object_name = L"__webdriver_script_fn";
  DISPID dispid_function_object;
  hr = this->script_engine_host_->GetIDsOfNames(IID_NULL,
                                                &function_object_name,
                                                1,
                                                LOCALE_USER_DEFAULT,
                                                &dispid_function_object);
  if (FAILED(hr)) {
    LOGHR(WARN, hr) << "Unable to get id of name __webdriver_script_fn";
    return false;
  }

  // get the value of eval result
  DISPPARAMS no_args_dispatch_parameters = { NULL, NULL, 0, 0 };
  hr = this->script_engine_host_->Invoke(dispid_function_object,
                                         IID_NULL,
                                         LOCALE_USER_DEFAULT,
                                         DISPATCH_PROPERTYGET,
                                         &no_args_dispatch_parameters,
                                         result,
                                         NULL,
                                         NULL);
  if (FAILED(hr)) {
    LOGHR(WARN, hr) << "Unable to get value of eval result";
    return false;
  }
  return true;
}
Exemple #5
0
ConnectionBox::ConnectionBox() :
    _saveButton(this, lang(lng_connection_save), st::btnSelectDone),
    _cancelButton(this, lang(lng_cancel), st::btnSelectCancel),
    _hostInput(this, st::inpConnectionHost, lang(lng_connection_host_ph), cConnectionProxy().host),
    _portInput(this, st::inpConnectionPort, lang(lng_connection_port_ph), QString::number(cConnectionProxy().port)),
    _userInput(this, st::inpConnectionUser, lang(lng_connection_user_ph), cConnectionProxy().user),
	_passwordInput(this, st::inpConnectionPassword, lang(lng_connection_password_ph), cConnectionProxy().password),
	_autoRadio(this, qsl("conn_type"), dbictAuto, lang(lng_connection_auto_rb), (cConnectionType() == dbictAuto)),
	_httpProxyRadio(this, qsl("conn_type"), dbictHttpProxy, lang(lng_connection_http_proxy_rb), (cConnectionType() == dbictHttpProxy)),
	_tcpProxyRadio(this, qsl("conn_type"), dbictTcpProxy, lang(lng_connection_tcp_proxy_rb), (cConnectionType() == dbictTcpProxy)),
	_tryIPv6(this, lang(lng_connection_try_ipv6), cTryIPv6()) {

	connect(&_saveButton, SIGNAL(clicked()), this, SLOT(onSave()));
	connect(&_cancelButton, SIGNAL(clicked()), this, SLOT(onClose()));

	connect(&_autoRadio, SIGNAL(changed()), this, SLOT(onChange()));
	connect(&_httpProxyRadio, SIGNAL(changed()), this, SLOT(onChange()));
	connect(&_tcpProxyRadio, SIGNAL(changed()), this, SLOT(onChange()));

	_passwordInput.setEchoMode(QLineEdit::Password);

	prepare();
}
Exemple #6
0
bool Window::minimizeToTray() {
	if (App::quiting() || !trayIcon) return false;

	hide();
	if (cPlatform() != dbipMac && !cSeenTrayTooltip()) {
		trayIcon->showMessage(QString::fromStdWString(AppName), lang(lng_tray_icon_text), QSystemTrayIcon::Information, 10000);
		cSetSeenTrayTooltip(true);
		App::writeConfig();
	}
	if (App::main()) App::main()->setOnline(windowState());
	updateTrayMenu();
	updateGlobalMenu();
	return true;
}
Exemple #7
0
void Window::updateTrayMenu(bool force) {
    if (!trayIconMenu || (cPlatform() == dbipWindows && !force) || cPlatform() == dbipLinux32 || cPlatform() == dbipLinux64) return;

	bool active = psIsActive();
	QAction *first = trayIconMenu->actions().at(0);
	first->setText(lang(active ? lng_minimize_to_tray : lng_open_from_tray));
	disconnect(first, SIGNAL(triggered(bool)), 0, 0);
	connect(first, SIGNAL(triggered(bool)), this, active ? SLOT(minimizeToTray()) : SLOT(showFromTray()));
#ifndef Q_OS_WIN
	if (trayIcon) {
		trayIcon->setContextMenu((active || cPlatform() != dbipMac) ? trayIconMenu : 0);
	}
#endif
}
Exemple #8
0
bool UsernameBox::onUpdateFail(const RPCError &error) {
	if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false;

	_saveRequest = 0;
	QString err(error.type()), name = getName();
	if (err == "USERNAME_NOT_MODIFIED" || _sentUsername == App::self()->username) {
		App::self()->setName(textOneLine(App::self()->firstName), textOneLine(App::self()->lastName), textOneLine(App::self()->nameOrPhone), textOneLine(name));
		emit closed();
		return true;
	} else if (err == "USERNAME_INVALID") {
		_usernameInput.setFocus();
		_usernameInput.notaBene();
		_errorText = lang(lng_username_invalid);
		return true;
	} else if (err == "USERNAME_OCCUPIED" || err == "USERNAMES_UNAVAILABLE") {
		_usernameInput.setFocus();
		_usernameInput.notaBene();
		_errorText = lang(lng_username_occupied);
		return true;
	}
	_usernameInput.setFocus();
	return true;
}
void GeneralWidget::onStartMinimized() {
	auto checked = _startMinimized->entity()->checked();
	if (Global::LocalPasscode()) {
		if (checked) {
			_startMinimized->entity()->setChecked(false);
			Ui::show(Box<InformBox>(lang(lng_error_start_minimized_passcoded)));
		}
		return;
	}
	if (cStartMinimized() != checked) {
		cSetStartMinimized(checked);
		Local::writeSettings();
	}
}
Exemple #10
0
bool Window::minimizeToTray() {
    if (App::quiting() || !psHasTrayIcon()) return false;

	hide();
    if (cPlatform() == dbipWindows && trayIcon && !cSeenTrayTooltip()) {
		trayIcon->showMessage(QString::fromStdWString(AppName), lang(lng_tray_icon_text), QSystemTrayIcon::Information, 10000);
		cSetSeenTrayTooltip(true);
		Local::writeSettings();
	}
	updateIsActive(cOfflineBlurTimeout());
	updateTrayMenu();
	updateGlobalMenu();
	return true;
}
TopBarWidget::TopBarWidget(MainWidget *w) : TWidget(w)
, _a_appearance(animation(this, &TopBarWidget::step_appearance))
, _clearSelection(this, lang(lng_selected_clear), st::topBarClearButton)
, _forward(this, lang(lng_selected_forward), st::defaultActiveButton)
, _delete(this, lang(lng_selected_delete), st::defaultActiveButton)
, _info(this, nullptr, st::infoButton)
, _mediaType(this, lang(lng_media_type), st::topBarButton)
, _search(this, st::topBarSearch) {
	_clearSelection->setTextTransform(Ui::RoundButton::TextTransform::ToUpper);
	_forward->setTextTransform(Ui::RoundButton::TextTransform::ToUpper);
	_delete->setTextTransform(Ui::RoundButton::TextTransform::ToUpper);

	connect(_forward, SIGNAL(clicked()), this, SLOT(onForwardSelection()));
	connect(_delete, SIGNAL(clicked()), this, SLOT(onDeleteSelection()));
	connect(_clearSelection, SIGNAL(clicked()), this, SLOT(onClearSelection()));
	connect(_info, SIGNAL(clicked()), this, SLOT(onInfoClicked()));
	connect(_search, SIGNAL(clicked()), this, SLOT(onSearch()));

	subscribe(Adaptive::Changed(), [this]() { updateAdaptiveLayout(); });

	setCursor(style::cur_pointer);
	showAll();
}
Exemple #12
0
int Main(StrLen lang_name,StrLen file_name,StrLen CCORE_Root)
 {
  Lang::Builder builder(lang_name);
  
  LangInput::Builder input(file_name);
  
  input.extract(builder);
  
  Lang lang(builder);
  
  Run run(lang);
  
  return run.run(CCORE_Root);
 }
Exemple #13
0
void GroupInfoBox::prepare() {
	setMouseTracking(true);

	_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()));
	}
Exemple #14
0
void UsernameBox::onChanged() {
	updateLinkText();
	QString name = getName();
	if (name.isEmpty()) {
		if (!_errorText.isEmpty() || !_goodText.isEmpty()) {
			_errorText = _goodText = QString();
			update();
		}
		_checkTimer->stop();
	} else {
		int32 len = name.size();
		for (int32 i = 0; i < len; ++i) {
			QChar ch = name.at(i);
			if ((ch < 'A' || ch > 'Z') && (ch < 'a' || ch > 'z') && (ch < '0' || ch > '9') && ch != '_' && (ch != '@' || i > 0)) {
				if (_errorText != lang(lng_username_bad_symbols)) {
					_errorText = lang(lng_username_bad_symbols);
					update();
				}
				_checkTimer->stop();
				return;
			}
		}
		if (name.size() < MinUsernameLength) {
			if (_errorText != lang(lng_username_too_short)) {
				_errorText = lang(lng_username_too_short);
				update();
			}
			_checkTimer->stop();
		} else {
			if (!_errorText.isEmpty() || !_goodText.isEmpty()) {
				_errorText = _goodText = QString();
				update();
			}
			_checkTimer->start(UsernameCheckTimeout);
		}
	}
}
Exemple #15
0
bool IntroPwdCheck::codeSubmitFail(const RPCError &error) {
	if (MTP::isFloodError(error)) {
		showError(lang(lng_flood_error));
		_codeField.notaBene();
		return true;
	}
	if (MTP::isDefaultHandledError(error)) return false;

	sentRequest = 0;
	stopCheck();
	_pwdField.setDisabled(false);
	_codeField.setDisabled(false);
	const QString &err = error.type();
	if (err == qstr("PASSWORD_EMPTY")) {
		intro()->onBack();
		return true;
	} else if (err == qstr("PASSWORD_RECOVERY_NA")) {
		recoverStartFail(error);
		return true;
	} else if (err == qstr("PASSWORD_RECOVERY_EXPIRED")) {
		_emailPattern = QString();
		onToPassword();
		return true;
	} else if (err == qstr("CODE_INVALID")) {
		showError(lang(lng_signin_wrong_code));
		_codeField.selectAll();
		_codeField.notaBene();
		return true;
	}
	if (cDebug()) { // internal server error
		showError(err + ": " + error.description());
	} else {
		showError(lang(lng_server_error));
	}
	_codeField.setFocus();
	return false;
}
Exemple #16
0
void
NLang::BuildLangMenu(BMenu* menu, const char* current)
{
	BMenuItem* mi;
	
	menu->SetRadioMode(true);
	
	BMessage *defmsg = new BMessage(CMD_LANG_LOAD);
	defmsg->AddString("filename", ".");
	menu->AddItem( mi = new BMenuItem( Translate("Default"), defmsg));
	if (current && (current[0]=='.' || current[0]==0)) {
		mi->SetMarked(true);
	}	
	
	menu->AddSeparatorItem();
		
	BDirectory dir(mPath.String());
	if (dir.InitCheck() != B_OK) {
		printf("%s : Directory %s is wrong ?\n",__func__,mPath.String());
		return;
	}
	BEntry entry;
	int files=0;
	while (dir.GetNextEntry(&entry) == B_OK) {
		BPath path(&entry);
		BString name(path.Leaf());
		BString lang(path.Leaf());
		
		//printf("\tFound: %s\n", name.String());
		files++;		
		
		int l = name.FindLast('.');
		name.Remove(l, name.Length()-l);
		lang.Remove(0, l+1);
		
		BMessage *msg = new BMessage(CMD_LANG_LOAD);
		msg->AddString("filename", path.Path());
		mi = new BMenuItem(name.String(), msg );
		menu->AddItem( mi );
		if (current) {
			//printf("\t%s =?= %s , %d\n", lang.String(), current, l);
			if (lang.Compare(current)==0) {
				mi->SetMarked(true);
			}
		}
	}
	
	//printf("\t%d files\n", files);
}
void BotGameUrlClickHandler::onClick(Qt::MouseButton button) const {
	auto urlText = tryConvertUrlToLocal(url());

	if (urlText.startsWith(qstr("tg://"))) {
		App::openLocalUrl(urlText);
	} else if (!_bot || _bot->isVerified() || Local::isBotTrusted(_bot)) {
		doOpen(urlText);
	} else {
		Ui::show(Box<ConfirmBox>(lng_allow_bot_pass(lt_bot_name, _bot->name), lang(lng_allow_bot), [bot = _bot, urlText] {
			Ui::hideLayer();
			Local::makeBotTrusted(bot);
			UrlClickHandler::doOpen(urlText);
		}));
	}
}
void SettingsWidget::onInviteLink() {
	auto getInviteLink = [this]() {
		if (auto chat = peer()->asChat()) {
			return chat->inviteLink();
		} else if (auto channel = peer()->asChannel()) {
			return channel->inviteLink();
		}
		return QString();
	};
	auto link = getInviteLink();

	ConfirmBox *box = new ConfirmBox(lang(link.isEmpty() ? lng_group_invite_about : lng_group_invite_about_new));
	connect(box, SIGNAL(confirmed()), this, SLOT(onInviteLinkSure()));
	Ui::showLayer(box);
}
Exemple #19
0
bool langFirstNameGoesSecond() {
	auto fullname = lang(lng_full_name__tagged);
	for (auto begin = fullname.constData(), ch = begin, end = ch + fullname.size(); ch != end; ++ch) {
		if (*ch == TextCommand) {
			if (ch + 3 < end && (ch + 1)->unicode() == TextCommandLangTag && *(ch + 3) == TextCommand) {
				if ((ch + 2)->unicode() == 0x0020 + lt_last_name) {
					return true;
				} else if ((ch + 2)->unicode() == 0x0020 + lt_first_name) {
					break;
				}
			}
		}
	}
	return false;
}
Exemple #20
0
bool PhoneWidget::phoneSubmitFail(const RPCError &error) {
	if (MTP::isFloodError(error)) {
		stopCheck();
		_sentRequest = 0;
		showPhoneError(langFactory(lng_flood_error));
		return true;
	}
	if (MTP::isDefaultHandledError(error)) return false;

	stopCheck();
	_sentRequest = 0;
	auto &err = error.type();
	if (err == qstr("PHONE_NUMBER_FLOOD")) {
		Ui::show(Box<InformBox>(lang(lng_error_phone_flood)));
		return true;
	} else if (err == qstr("PHONE_NUMBER_INVALID")) { // show error
		showPhoneError(langFactory(lng_bad_phone));
		return true;
	} else if (err == qstr("PHONE_NUMBER_BANNED")) {
		const auto phone = _sentPhone;
		Ui::show(Box<ConfirmBox>(
			lang(lng_signin_banned_text),
			lang(lng_box_ok),
			lang(lng_signin_banned_help),
			[] { Ui::hideLayer(); },
			[phone] { SendToBannedHelp(phone); Ui::hideLayer(); }));
		return true;
	}
	if (Logs::DebugEnabled()) { // internal server error
		auto text = err + ": " + error.description();
		showPhoneError([text] { return text; });
	} else {
		showPhoneError(&Lang::Hard::ServerError);
	}
	return false;
}
void DownloadPathBox::onEditPath() {
	_dirInput.clearFocus();

	filedialogInit();
	QString path, lastPath = cDialogLastPath();
	if (!cDownloadPath().isEmpty()) cSetDialogLastPath(cDownloadPath());
	if (filedialogGetDir(path, lang(lng_download_path_choose))) {
		if (!path.isEmpty()) {
			_path = path + '/';
			_dirInput.setText(QDir::toNativeSeparators(_path));
			_dirInput.setCursorPosition(0);
		}
	}
	cSetDialogLastPath(lastPath);
}
DownloadPathBox::DownloadPathBox() : _hiding(false),
	_path(cDownloadPath()),
	_tempRadio(this, qsl("dir_type"), 0, lang(lng_download_path_temp_radio), _path.isEmpty()),
	_dirRadio(this, qsl("dir_type"), 1, lang(lng_download_path_dir_radio), !_path.isEmpty()),
	_dirInput(this, st::inpDownloadDir, QString(), QDir::toNativeSeparators(_path)),
	_saveButton(this, lang(lng_connection_save), st::btnSelectDone),
	_cancelButton(this, lang(lng_cancel), st::btnSelectCancel),
	a_opacity(0, 1) {

	_width = st::addContactWidth;

	connect(&_saveButton, SIGNAL(clicked()), this, SLOT(onSave()));
	connect(&_cancelButton, SIGNAL(clicked()), this, SLOT(onCancel()));

	connect(&_tempRadio, SIGNAL(changed()), this, SLOT(onChange()));
	connect(&_dirRadio, SIGNAL(changed()), this, SLOT(onChange()));

	connect(&_dirInput, SIGNAL(focused()), this, SLOT(onEditPath()));
	_dirInput.setCursorPosition(0);

	showAll();
	_cache = grab(rect());
	hideAll();
}
Exemple #23
0
void TitleWidget::paintEvent(QPaintEvent *e) {
	Painter p(this);
	p.fillRect(QRect(0, 0, width(), st::titleHeight), st::titleBG->b);
	if (!_cancel.isHidden()) {
		p.setPen(st::titleTextButton.color->p);
		p.setFont(st::titleTextButton.font->f);
		bool inlineSwitchChoose = (App::main() && App::main()->selectingPeerForInlineSwitch());
		auto chooseText = lang(inlineSwitchChoose ? lng_inline_switch_choose : lng_forward_choose);
		p.drawText(st::titleMenuOffset - st::titleTextButton.width / 2, st::titleTextButton.textTop + st::titleTextButton.font->ascent, chooseText);
	}
	p.drawSprite(st::titleIconPos, st::titleIconImg);
	if (Adaptive::OneColumn() && !_counter.isNull() && App::main()) {
		p.drawPixmap(st::titleIconPos.x() + st::titleIconImg.pxWidth() - (_counter.width() / cIntRetinaFactor()), st::titleIconPos.y() + st::titleIconImg.pxHeight() - (_counter.height() / cIntRetinaFactor()), _counter);
	}
}
Exemple #24
0
void IntroPwdCheck::pwdSubmitDone(bool recover, const MTPauth_Authorization &result) {
	sentRequest = 0;
	stopCheck();
	if (recover) {
		cSetPasswordRecovered(true);
	}
	_pwdField.setDisabled(false);
	_codeField.setDisabled(false);
	const MTPDauth_authorization &d(result.c_auth_authorization());
	if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf?
		showError(lang(lng_server_error));
		return;
	}
	intro()->finish(d.vuser);
}
void LocalStorageBox::paintEvent(QPaintEvent *e) {
	Painter p(this);
	if (paint(p)) return;

	paintTitle(p, lang(lng_local_storage_title));

	p.setFont(st::boxTextFont);
	p.setPen(st::windowTextFg);
	checkLocalStoredCounts();
	int top = st::boxTitleHeight + st::localStorageBoxSkip;
	if (_imagesCount > 0) {
		auto text = lng_settings_images_cached(lt_count, _imagesCount, lt_size, formatSizeText(Local::storageImagesSize() + Local::storageStickersSize() + Local::storageWebFilesSize()));
		p.drawTextLeft(st::boxPadding.left(), top, width(), text);
		top += st::boxTextFont->height + st::localStorageBoxSkip;
	}
	if (_audiosCount > 0) {
		auto text = lng_settings_audios_cached(lt_count, _audiosCount, lt_size, formatSizeText(Local::storageAudiosSize()));
		p.drawTextLeft(st::boxPadding.left(), top, width(), text);
		top += st::boxTextFont->height + st::localStorageBoxSkip;
	} else if (_imagesCount <= 0) {
		p.drawTextLeft(st::boxPadding.left(), top, width(), lang(lng_settings_no_data_cached));
		top += st::boxTextFont->height + st::localStorageBoxSkip;
	}
	auto text = ([this]() -> QString {
		switch (_state) {
		case State::Clearing: return lang(lng_local_storage_clearing);
		case State::Cleared: return lang(lng_local_storage_cleared);
		case State::ClearFailed: return lang(lng_local_storage_clear_failed);
		}
		return QString();
	})();
	if (!text.isEmpty()) {
		p.drawTextLeft(st::boxPadding.left(), top, width(), text);
		top += st::boxTextFont->height + st::localStorageBoxSkip;
	}
}
Exemple #26
0
void TitleWidget::paintEvent(QPaintEvent *e) {
	Painter p(this);
	p.fillRect(rect(), st::titleBg);
	if (!_cancel.isHidden()) {
		p.setPen(st::titleTextButton.color);
		p.setFont(st::titleTextButton.font);
		bool inlineSwitchChoose = (App::main() && App::main()->selectingPeerForInlineSwitch());
		auto chooseText = lang(inlineSwitchChoose ? lng_inline_switch_choose : lng_forward_choose);
		p.drawText(st::titleMenuOffset - st::titleTextButton.width / 2, st::titleTextButton.textTop + st::titleTextButton.font->ascent, chooseText);
	}
	st::titleIcon.paint(p, st::titleIconPosition, width());
	if (Adaptive::OneColumn() && !_counter.isNull() && App::main()) {
		p.drawPixmap(st::titleCounterPosition, _counter);
	}
}
Exemple #27
0
void ConnectionBox::paintEvent(QPaintEvent *e) {
	Painter p(this);
	if (paint(p)) return;

	paintTitle(p, lang(lng_connection_header), true);

	// paint separator
	p.fillRect(st::boxPadding.left(), _tryIPv6.y() - st::connectionSkip - st::lineWidth, width() - st::boxPadding.left() - st::boxPadding.right(), st::lineWidth, st::scrollDef.shColor->b);

	// paint shadow
	p.fillRect(0, height() - st::btnSelectCancel.height - st::scrollDef.bottomsh, width(), st::scrollDef.bottomsh, st::scrollDef.shColor->b);

	// paint button sep
	p.fillRect(st::btnSelectCancel.width, height() - st::btnSelectCancel.height, st::lineWidth, st::btnSelectCancel.height, st::btnSelectSep->b);
}
Exemple #28
0
void DownloadPathBox::onEditPath() {
	filedialogInit();
	QString path, lastPath = cDialogLastPath();
	if (!cDownloadPath().isEmpty() && cDownloadPath() != qstr("tmp")) {
		cSetDialogLastPath(cDownloadPath().left(cDownloadPath().size() - (cDownloadPath().endsWith('/') ? 1 : 0)));
	}
	if (filedialogGetDir(path, lang(lng_download_path_choose))) {
		if (!path.isEmpty()) {
			_path = path + '/';
			_pathBookmark = psDownloadPathBookmark(_path);
			setPathText(QDir::toNativeSeparators(_path));
		}
	}
	cSetDialogLastPath(lastPath);
}
Exemple #29
0
void ProfileInner::contextMenuEvent(QContextMenuEvent *e) {
	if (_menu) {
		_menu->deleteLater();
		_menu = 0;
	}
	if (!_phoneText.isEmpty()) {
		QRect info(_left + st::profilePhotoSize + st::profilePhoneLeft, st::profilePadding.top(), _width - st::profilePhotoSize - st::profilePhoneLeft, st::profilePhotoSize);
		if (info.contains(mapFromGlobal(e->globalPos()))) {
			_menu = new ContextMenu(this);
			_menu->addAction(lang(lng_profile_copy_phone), this, SLOT(onCopyPhone()))->setEnabled(true);
			_menu->deleteOnHide();
			connect(_menu, SIGNAL(destroyed(QObject*)), this, SLOT(onMenuDestroy(QObject*)));
			_menu->popup(e->globalPos());
			e->accept();
		}
Exemple #30
0
MaxInviteBox::MaxInviteBox(const QString &link) : AbstractBox(st::boxWidth),
_close(this, lang(lng_box_ok), st::defaultBoxButton),
_text(st::boxTextFont, lng_participant_invite_sorry(lt_count, cMaxGroupCount()), _confirmBoxTextOptions, st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right()),
_link(link), _linkOver(false),
a_goodOpacity(0, 0), a_good(animFunc(this, &MaxInviteBox::goodAnimStep)) {
	setMouseTracking(true);

	_textWidth = st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right();
	_textHeight = qMin(_text.countHeight(_textWidth), 16 * int(st::boxTextStyle.lineHeight));
	setMaxHeight(st::boxPadding.top() + _textHeight + st::boxTextFont->height + st::boxTextFont->height * 2 + st::newGroupLinkPadding.bottom() + st::boxButtonPadding.top() + _close.height() + st::boxButtonPadding.bottom());

	connect(&_close, SIGNAL(clicked()), this, SLOT(onClose()));

	prepare();
}