Exemplo n.º 1
0
void TitleWidget::updateBackButton() {
	if (!cWideMode() && App::main() && App::main()->selectingPeer()) {
		_cancel.show();
		if (!_back.isHidden()) _back.hide();
		_settings.hide();
		_contacts.hide();
		_about.hide();
	} else {
		_cancel.hide();
		bool authed = (MTP::authedId() > 0);
		if (cWideMode()) {
			if (!_back.isHidden()) _back.hide();
			_settings.show();
			if (authed) _contacts.show();
			_about.show();
		} else {
			bool need = App::wnd()->needBackButton();
			if (need && _back.isHidden()) {
				_back.show();
				_settings.hide();
				_contacts.hide();
				_about.hide();
			} else if (!need && !_back.isHidden()) {
				_back.hide();
				_settings.show();
				if (authed) _contacts.show();
				_about.show();
			}
		}
	}
	showUpdateBtn();
	update();
}
Exemplo n.º 2
0
void TitleWidget::updateWideMode() {
	updateBackButton();
	if (!cWideMode()) {
		updateCounter();
	}
	if (hider) {
		if (cWideMode()) {
			hider->show();
		} else {
			hider->hide();
		}
	}
}
Exemplo n.º 3
0
PlayerWidget::PlayerWidget(QWidget *parent) : TWidget(parent)
, _prevAvailable(false)
, _nextAvailable(false)
, _fullAvailable(false)
, _over(OverNone)
, _down(OverNone)
, _downCoord(0)
, _downFrequency(AudioVoiceMsgFrequency)
, _downProgress(0.)
, _a_state(animation(this, &PlayerWidget::step_state))
, _msgmigrated(false)
, _index(-1)
, _migrated(0)
, _history(0)
, _timeWidth(0)
, _repeat(false)
, _showPause(false)
, _position(0)
, _duration(0)
, _loaded(0)
, a_progress(0., 0.)
, a_loadProgress(0., 0.)
, _a_progress(animation(this, &PlayerWidget::step_progress))
, _sideShadow(this, st::shadowColor) {
	resize(st::wndMinWidth, st::playerHeight);
	setMouseTracking(true);
	memset(_stateHovers, 0, sizeof(_stateHovers));
	_sideShadow.setVisible(cWideMode());
}
Exemplo n.º 4
0
HitTestType TitleWidget::hitTest(const QPoint &p) {
	if (App::wnd() && App::wnd()->layerShown()) return HitTestNone;

	int x(p.x()), y(p.y()), w(width()), h(height() - st::titleShadow);
	if (cWideMode() && hider && x >= App::main()->dlgsWidth()) return HitTestNone;

	if (x >= st::titleIconPos.x() && y >= st::titleIconPos.y() && x < st::titleIconPos.x() + st::titleIconImg.pxWidth() && y < st::titleIconPos.y() + st::titleIconImg.pxHeight()) {
		return HitTestIcon;
	} else if (false
        || (_update.hitTest(p - _update.geometry().topLeft()) == HitTestSysButton && _update.isVisible())
		|| (_minimize.hitTest(p - _minimize.geometry().topLeft()) == HitTestSysButton)
		|| (_maximize.hitTest(p - _maximize.geometry().topLeft()) == HitTestSysButton)
		|| (_restore.hitTest(p - _restore.geometry().topLeft()) == HitTestSysButton)
		|| (_close.hitTest(p - _close.geometry().topLeft()) == HitTestSysButton)
	) {
		return HitTestSysButton;
	} else if (x >= 0 && x < w && y >= 0 && y < h) {
		if (false
			|| (!_back.isHidden() && _back.geometry().contains(x, y))
			|| (!_cancel.isHidden() && _cancel.geometry().contains(x, y))
			|| (!_settings.isHidden() && _settings.geometry().contains(x, y))
			|| (!_contacts.isHidden() && _contacts.geometry().contains(x, y))
			|| (!_about.isHidden() && _about.geometry().contains(x, y))
		) {
			return HitTestClient;
		}
		return HitTestCaption;
	}
	return HitTestNone;
}
Exemplo n.º 5
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();
}
Exemplo n.º 6
0
void TitleWidget::updateCounter() {
	if (cWideMode() || !MTP::authedId()) return;

	int32 counter = App::histories().unreadFull - (cIncludeMuted() ? 0 : App::histories().unreadMuted);
	bool muted = cIncludeMuted() ? (App::histories().unreadMuted >= counter) : false;

	style::color bg = muted ? st::counterMuteBG : st::counterBG;
	
	if (counter > 0) {
		int32 size = cRetina() ? -32 : -16;
		switch (cScale()) {
		case dbisOneAndQuarter: size = -20; break;
		case dbisOneAndHalf: size = -24; break;
		case dbisTwo: size = -32; break;
		}
		_counter = QPixmap::fromImage(App::wnd()->iconWithCounter(size, counter, bg, false), Qt::ColorOnly);
		_counter.setDevicePixelRatio(cRetinaFactor());
		update(QRect(st::titleIconPos, st::titleIconImg.pxSize()));
	} else {
		if (!_counter.isNull()) {
			_counter = QPixmap();
			update(QRect(st::titleIconPos, st::titleIconImg.pxSize()));
		}
	}
}
Exemplo n.º 7
0
void TitleWidget::updateBackButton() {
	if (App::passcoded()) {
		if (!_cancel.isHidden()) _cancel.hide();
		if (!_back.isHidden()) _back.hide();
		if (!_settings.isHidden()) _settings.hide();
		if (!_contacts.isHidden()) _contacts.hide();
		if (!_about.isHidden()) _about.hide();
		_lock.setSysBtnStyle(st::sysUnlock);
	} else {
		_lock.setSysBtnStyle(st::sysLock);
		if (!cWideMode() && App::main() && App::main()->selectingPeer()) {
			_cancel.show();
			if (!_back.isHidden()) _back.hide();
			if (!_settings.isHidden()) _settings.hide();
			if (!_contacts.isHidden()) _contacts.hide();
			if (!_about.isHidden()) _about.hide();
		} else {
			if (!_cancel.isHidden()) _cancel.hide();
			bool authed = (MTP::authedId() > 0);
			if (cWideMode()) {
				if (!_back.isHidden()) _back.hide();
				if (_settings.isHidden()) _settings.show();
				if (authed && _contacts.isHidden()) _contacts.show();
				if (_about.isHidden()) _about.show();
			} else {
				if (App::wnd()->needBackButton()) {
					if (_back.isHidden()) _back.show();
					if (!_settings.isHidden()) _settings.hide();
					if (!_contacts.isHidden()) _contacts.hide();
					if (!_about.isHidden()) _about.hide();
				} else {
					if (!_back.isHidden()) _back.hide();
					if (_settings.isHidden()) _settings.show();
					if (authed && _contacts.isHidden()) _contacts.show();
					if (_about.isHidden()) _about.show();
				}
			}
		}
	}
	showUpdateBtn();
	update();
}
Exemplo n.º 8
0
void Window::resizeEvent(QResizeEvent *e) {
	bool wideMode = (width() >= st::wideModeWidth);
	if (wideMode != cWideMode()) {
		cSetWideMode(wideMode);
		updateWideMode();
	}
	title->setGeometry(QRect(0, 0, width(), st::titleHeight + st::titleShadow));
	if (layerBG) layerBG->resize(width(), height());
	if (_connecting) _connecting->setGeometry(0, height() - _connecting->height(), _connecting->width(), _connecting->height());
	emit resized(QSize(width(), height() - st::titleHeight));
}
Exemplo n.º 9
0
void TitleWidget::paintEvent(QPaintEvent *e) {
	QPainter 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);
		p.drawText(st::titleMenuOffset - st::titleTextButton.width / 2, st::titleTextButton.textTop + st::titleTextButton.font->ascent, lang(lng_forward_choose));
	}
	p.drawPixmap(st::titleIconPos, App::sprite(), st::titleIconImg);
	if (!cWideMode() && !_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);
	}
}
Exemplo n.º 10
0
void PlayerWidget::resizeEvent(QResizeEvent *e) {
	int32 availh = (height() - st::playerLineHeight);
	int32 ch = st::playerPlay.pxHeight() + st::playerSkip, ct = (availh - ch) / 2;
	_playbackRect = QRect(cWideMode() ? st::dlgShadow : 0, height() - st::playerMoverSize.height(), width() - (cWideMode() ? st::dlgShadow : 0), st::playerMoverSize.height());
	_prevRect = _fullAvailable ? QRect(st::playerSkip / 2, ct, st::playerPrev.pxWidth() + st::playerSkip, ch) : QRect();
	_playRect = QRect(_fullAvailable ? (_prevRect.x() + _prevRect.width()) : (st::playerSkip / 2), ct, st::playerPlay.pxWidth() + st::playerSkip, ch);
	_nextRect = _fullAvailable ? QRect(_playRect.x() + _playRect.width(), ct, st::playerNext.pxWidth() + st::playerSkip, ch) : QRect();

	_closeRect = QRect(width() - st::playerSkip / 2 - st::playerClose.pxWidth() - st::playerSkip, ct, st::playerClose.pxWidth() + st::playerSkip, ch);
	_volumeRect = QRect(_closeRect.x() - st::playerVolume.pxWidth() - st::playerSkip, ct, st::playerVolume.pxWidth() + st::playerSkip, ch);
	_repeatRect = QRect(_volumeRect.x() - st::playerRepeat.pxWidth() - st::playerSkip, ct, st::playerRepeat.pxWidth() + st::playerSkip, ch);
	_fullRect = _fullAvailable ? QRect(_repeatRect.x() - st::playerFull.pxWidth() - st::playerSkip, ct, st::playerFull.pxWidth() + st::playerSkip, ch) : QRect();

	int32 infoLeft = (_fullAvailable ? (_nextRect.x() + _nextRect.width()) : (_playRect.x() + _playRect.width()));
	_infoRect = QRect(infoLeft + st::playerSkip / 2, 0, (_fullAvailable ? _fullRect.x() : _repeatRect.x()) - infoLeft - st::playerSkip, availh);
	update();
}
Exemplo n.º 11
0
void TitleWidget::setHideLevel(float64 level) {
	if (level != hideLevel) {
		hideLevel = level;
		if (hideLevel) {
			if (!hider) {
				hider = new TitleHider(this);
				hider->move(0, 0);
				hider->resize(size());
				if (cWideMode()) {
					hider->show();
				} else {
					hider->hide();
				}
			}
			hider->setLevel(hideLevel);
		} else {
			if (hider) hider->deleteLater();
			hider = 0;
		}
	}
}
Exemplo n.º 12
0
void PlayerWidget::updateWideMode() {
	_sideShadow.setVisible(cWideMode());
}