void ScaleWidget::setScale(DBIScale newScale) {
	if (_inSetScale) return;
	_inSetScale = true;
	auto guard = base::scope_guard([this] { _inSetScale = false; });

	if (newScale == cScreenScale()) newScale = dbisAuto;
	if (newScale == dbisAuto && !_auto->checked()) {
		_auto->setChecked(true);
	} else if (newScale != dbisAuto && _auto->checked()) {
		_auto->setChecked(false);
	}
	_newScale = newScale;
	if (newScale == dbisAuto) newScale = cScreenScale();
	if (_scale->activeSection() != newScale - 1) {
		_scale->setActiveSection(newScale - 1);
	}

	if (cEvalScale(newScale) != cEvalScale(cRealScale())) {
		Ui::show(Box<ConfirmBox>(lang(lng_settings_need_restart), lang(lng_settings_restart_now), base::lambda_guarded(this, [this] {
			cSetConfigScale(_newScale);
			Local::writeSettings();
			App::restart();
		}), base::lambda_guarded(this, [this] {
			App::CallDelayed(st::boxDuration, this, [this] {
				setScale(cRealScale());
			});
		})));
	} else {
		cSetConfigScale(newScale);
		Local::writeSettings();
	}
}
Пример #2
0
void TitleWidget::showUpdateBtn() {
	if (!cWideMode() && App::main() && App::main()->selectingPeer()) {
		_cancel.show();
		_update.hide();
		_minimize.hide();
		_restore.hide();
		_maximize.hide();
		_close.hide();
		return;
	}
	bool updateReady = App::app()->updatingState() == Application::UpdatingReady;
	if (updateReady || cEvalScale(cConfigScale()) != cEvalScale(cRealScale())) {
		_update.setText(lang(updateReady ? lng_menu_update : lng_menu_restart));
		_update.show();
		resizeEvent(0);
		_minimize.hide();
		_restore.hide();
		_maximize.hide();
		_close.hide();
		anim::start(this);
	} else {
		_update.hide();
		if (cPlatform() == dbipWindows) {
			_minimize.show();
			maximizedChanged(wnd->windowState().testFlag(Qt::WindowMaximized), true);
			_close.show();
		}
		anim::stop(this);
	}
	resizeEvent(0);
	update();
}
Пример #3
0
void TitleWidget::updateRestartButtonVisibility() {
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
	bool updateReady = (Sandbox::updatingState() == Application::UpdatingReady);
#else // !TDESKTOP_DISABLE_AUTOUPDATE
	bool updateReady = false;
#endif // else for !TDESKTOP_DISABLE_AUTOUPDATE
	auto scaleRestarting = cEvalScale(cConfigScale()) != cEvalScale(cRealScale());

	auto updateVisible = _cancel.isHidden() && (updateReady || scaleRestarting);
	if (updateVisible) {
		_update.setText(lang(updateReady ? lng_menu_update : lng_menu_restart));
		_update.show();
		_a_update.start();
	} else {
		_update.hide();
		_a_update.stop();
	}
}
Пример #4
0
void TitleWidget::showUpdateBtn() {
	if (Adaptive::OneColumn() && App::main() && App::main()->selectingPeer()) {
		_cancel.show();
		_lock.hide();
		_update.hide();
		_minimize.hide();
		_restore.hide();
		_maximize.hide();
		_close.hide();
		return;
	}
	if (cHasPasscode()) {
		_lock.show();
	} else {
		_lock.hide();
	}
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
	bool updateReady = (Sandbox::updatingState() == Application::UpdatingReady);
#else
	bool updateReady = false;
#endif
	if (updateReady || cEvalScale(cConfigScale()) != cEvalScale(cRealScale())) {
		_update.setText(lang(updateReady ? lng_menu_update : lng_menu_restart));
		_update.show();
		resizeEvent(0);
		_minimize.hide();
		_restore.hide();
		_maximize.hide();
		_close.hide();
		_a_update.start();
	} else {
		_update.hide();
		if (cPlatform() == dbipWindows) {
			_minimize.show();
			maximizedChanged(lastMaximized, true);
			_close.show();
		}
		_a_update.stop();
	}
	resizeEvent(0);
	update();
}
Пример #5
0
void SettingsInner::setScale(DBIScale newScale) {
	if (cConfigScale() == newScale) return;

	cSetConfigScale(newScale);
	App::writeConfig();
	App::wnd()->getTitle()->showUpdateBtn();
	if (newScale == dbisAuto && !_dpiAutoScale.checked()) {
		_dpiAutoScale.setChecked(true);
	} else if (newScale != dbisAuto && _dpiAutoScale.checked()) {
		_dpiAutoScale.setChecked(false);
	}
	if (newScale == dbisAuto) newScale = cScreenScale();
	if (_dpiSlider.selected() != newScale - 1) {
		_dpiSlider.setSelected(newScale - 1);
	}
	if (cEvalScale(cConfigScale()) != cEvalScale(cRealScale())) {
		ConfirmBox *box = new ConfirmBox(lang(lng_settings_need_restart), lang(lng_settings_restart_now), lang(lng_settings_restart_later));
		connect(box, SIGNAL(confirmed()), this, SLOT(onRestartNow()));
		App::wnd()->showLayer(box);
	}
}
Пример #6
0
bool scaleIs(DBIScale scale) {
	return cRealScale() == scale || (cRealScale() == dbisAuto && cScreenScale() == scale);
}