2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2014-12-01 10:47:38 +00:00
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2015-10-03 13:16:42 +00:00
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2016-02-08 10:56:18 +00:00
|
|
|
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "lang.h"
|
|
|
|
#include "style.h"
|
|
|
|
|
|
|
|
#include "title.h"
|
|
|
|
#include "mainwidget.h"
|
|
|
|
#include "window.h"
|
|
|
|
#include "application.h"
|
|
|
|
#include "boxes/contactsbox.h"
|
|
|
|
#include "boxes/aboutbox.h"
|
|
|
|
|
|
|
|
TitleHider::TitleHider(QWidget *parent) : QWidget(parent), _level(0) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void TitleHider::paintEvent(QPaintEvent *e) {
|
|
|
|
QPainter p(this);
|
|
|
|
p.setOpacity(_level * st::layerAlpha);
|
2015-10-17 08:31:48 +00:00
|
|
|
p.fillRect(App::main()->dlgsWidth(), 0, width() - App::main()->dlgsWidth(), height(), st::layerBg->b);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TitleHider::mousePressEvent(QMouseEvent *e) {
|
|
|
|
if (e->button() == Qt::LeftButton) {
|
|
|
|
emit static_cast<TitleWidget*>(parentWidget())->hiderClicked();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TitleHider::setLevel(float64 level) {
|
|
|
|
_level = level;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
TitleWidget::TitleWidget(Window *window) : TWidget(window)
|
|
|
|
, wnd(window)
|
|
|
|
, hideLevel(0)
|
|
|
|
, hider(0)
|
|
|
|
, _back(this, st::titleBackButton, lang(lng_menu_back))
|
|
|
|
, _cancel(this, lang(lng_cancel), st::titleTextButton)
|
|
|
|
, _settings(this, lang(lng_menu_settings), st::titleTextButton)
|
|
|
|
, _contacts(this, lang(lng_menu_contacts), st::titleTextButton)
|
|
|
|
, _about(this, lang(lng_menu_about), st::titleTextButton)
|
|
|
|
, _lock(this, window)
|
|
|
|
, _update(this, window, lang(lng_menu_update))
|
|
|
|
, _minimize(this, window)
|
|
|
|
, _maximize(this, window)
|
|
|
|
, _restore(this, window)
|
|
|
|
, _close(this, window)
|
|
|
|
, _a_update(animation(this, &TitleWidget::step_update))
|
|
|
|
, lastMaximized(!(window->windowState() & Qt::WindowMaximized))
|
2014-06-16 09:31:10 +00:00
|
|
|
{
|
2014-05-30 08:53:19 +00:00
|
|
|
setGeometry(0, 0, wnd->width(), st::titleHeight);
|
2015-10-01 14:05:05 +00:00
|
|
|
setAttribute(Qt::WA_OpaquePaintEvent);
|
2015-03-02 12:34:16 +00:00
|
|
|
_lock.hide();
|
2014-11-18 12:41:33 +00:00
|
|
|
_update.hide();
|
2014-12-16 17:05:18 +00:00
|
|
|
_cancel.hide();
|
|
|
|
_back.hide();
|
2016-01-30 16:31:10 +00:00
|
|
|
if (
|
|
|
|
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
|
2016-02-08 14:54:55 +00:00
|
|
|
Sandbox::updatingState() == Application::UpdatingReady ||
|
2016-01-30 16:31:10 +00:00
|
|
|
#endif
|
|
|
|
cHasPasscode()
|
|
|
|
) {
|
2014-11-18 12:41:33 +00:00
|
|
|
showUpdateBtn();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2014-11-18 15:22:05 +00:00
|
|
|
stateChanged();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-12-15 15:55:45 +00:00
|
|
|
connect(&_back, SIGNAL(clicked()), window, SLOT(hideSettings()));
|
2014-12-12 16:27:03 +00:00
|
|
|
connect(&_cancel, SIGNAL(clicked()), this, SIGNAL(hiderClicked()));
|
2014-05-30 08:53:19 +00:00
|
|
|
connect(&_settings, SIGNAL(clicked()), window, SLOT(showSettings()));
|
|
|
|
connect(&_contacts, SIGNAL(clicked()), this, SLOT(onContacts()));
|
|
|
|
connect(&_about, SIGNAL(clicked()), this, SLOT(onAbout()));
|
|
|
|
connect(wnd->windowHandle(), SIGNAL(windowStateChanged(Qt::WindowState)), this, SLOT(stateChanged(Qt::WindowState)));
|
2016-01-30 18:24:18 +00:00
|
|
|
|
|
|
|
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
|
2016-02-08 14:54:55 +00:00
|
|
|
Sandbox::connect(SIGNAL(updateReady()), this, SLOT(showUpdateBtn()));
|
2016-01-30 18:24:18 +00:00
|
|
|
#endif
|
2016-01-11 15:43:29 +00:00
|
|
|
|
2014-07-08 10:24:21 +00:00
|
|
|
if (cPlatform() != dbipWindows) {
|
2014-06-15 12:31:03 +00:00
|
|
|
_minimize.hide();
|
|
|
|
_maximize.hide();
|
|
|
|
_restore.hide();
|
|
|
|
_close.hide();
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TitleWidget::paintEvent(QPaintEvent *e) {
|
|
|
|
QPainter p(this);
|
|
|
|
p.fillRect(QRect(0, 0, width(), st::titleHeight), st::titleBG->b);
|
2014-12-12 16:27:03 +00:00
|
|
|
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));
|
|
|
|
}
|
2014-12-15 15:55:45 +00:00
|
|
|
p.drawPixmap(st::titleIconPos, App::sprite(), st::titleIconImg);
|
2016-02-08 14:54:55 +00:00
|
|
|
if (Adaptive::OneColumn() && !_counter.isNull() && App::main()) {
|
2014-12-15 15:55:45 +00:00
|
|
|
p.drawPixmap(st::titleIconPos.x() + st::titleIconImg.pxWidth() - (_counter.width() / cIntRetinaFactor()), st::titleIconPos.y() + st::titleIconImg.pxHeight() - (_counter.height() / cIntRetinaFactor()), _counter);
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
void TitleWidget::step_update(float64 ms, bool timer) {
|
2014-11-18 12:41:33 +00:00
|
|
|
float64 phase = sin(M_PI_2 * (ms / st::updateBlinkDuration));
|
|
|
|
if (phase < 0) phase = -phase;
|
|
|
|
_update.setOverLevel(phase);
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
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());
|
2016-02-08 14:54:55 +00:00
|
|
|
if (Adaptive::OneColumn()) {
|
2014-12-12 16:27:03 +00:00
|
|
|
hider->hide();
|
2016-02-08 14:54:55 +00:00
|
|
|
} else {
|
|
|
|
hider->show();
|
2014-12-12 16:27:03 +00:00
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
hider->setLevel(hideLevel);
|
|
|
|
} else {
|
|
|
|
if (hider) hider->deleteLater();
|
|
|
|
hider = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TitleWidget::onContacts() {
|
2014-11-18 12:40:43 +00:00
|
|
|
if (App::wnd() && App::wnd()->isHidden()) App::wnd()->showFromTray();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
if (!App::self()) return;
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(new ContactsBox());
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TitleWidget::onAbout() {
|
2014-11-18 12:40:43 +00:00
|
|
|
if (App::wnd() && App::wnd()->isHidden()) App::wnd()->showFromTray();
|
2015-12-07 18:09:05 +00:00
|
|
|
Ui::showLayer(new AboutBox());
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TitleWidget::~TitleWidget() {
|
|
|
|
delete hider;
|
|
|
|
hider = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TitleWidget::resizeEvent(QResizeEvent *e) {
|
2014-06-15 12:31:03 +00:00
|
|
|
QPoint p(width() - ((cPlatform() == dbipWindows && lastMaximized) ? 0 : st::sysBtnDelta), 0);
|
2014-11-18 12:41:33 +00:00
|
|
|
|
|
|
|
if (!_update.isHidden()) {
|
|
|
|
p.setX(p.x() - _update.width());
|
|
|
|
_update.move(p);
|
2015-03-02 12:34:16 +00:00
|
|
|
if (!_lock.isHidden()) {
|
|
|
|
p.setX(p.x() - _lock.width());
|
|
|
|
_lock.move(p);
|
|
|
|
p.setX(p.x() + _lock.width());
|
|
|
|
}
|
2014-11-18 12:41:33 +00:00
|
|
|
p.setX(p.x() + _update.width());
|
|
|
|
}
|
2014-12-12 16:27:03 +00:00
|
|
|
_cancel.move(p.x() - _cancel.width(), 0);
|
2014-11-18 12:41:33 +00:00
|
|
|
|
2014-07-08 10:24:21 +00:00
|
|
|
if (cPlatform() == dbipWindows) {
|
2014-06-15 12:31:03 +00:00
|
|
|
p.setX(p.x() - _close.width());
|
|
|
|
_close.move(p);
|
2016-01-11 15:43:29 +00:00
|
|
|
|
2014-06-15 12:31:03 +00:00
|
|
|
p.setX(p.x() - _maximize.width());
|
|
|
|
_restore.move(p); _maximize.move(p);
|
2016-01-11 15:43:29 +00:00
|
|
|
|
2014-06-15 12:31:03 +00:00
|
|
|
p.setX(p.x() - _minimize.width());
|
|
|
|
_minimize.move(p);
|
|
|
|
}
|
2015-03-02 12:34:16 +00:00
|
|
|
if (_update.isHidden() && !_lock.isHidden()) {
|
|
|
|
p.setX(p.x() - _lock.width());
|
|
|
|
_lock.move(p);
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
_settings.move(st::titleMenuOffset, 0);
|
2014-12-12 16:27:03 +00:00
|
|
|
_back.move(st::titleMenuOffset, 0);
|
2014-12-15 15:55:45 +00:00
|
|
|
_back.resize((_minimize.isHidden() ? (_update.isHidden() ? width() : _update.x()) : _minimize.x()) - st::titleMenuOffset, _back.height());
|
2015-03-02 12:34:16 +00:00
|
|
|
if (MTP::authedId() && _back.isHidden() && _cancel.isHidden() && !App::passcoded()) {
|
|
|
|
if (_contacts.isHidden()) _contacts.show();
|
2014-05-30 08:53:19 +00:00
|
|
|
_contacts.move(_settings.x() + _settings.width(), 0);
|
|
|
|
_about.move(_contacts.x() + _contacts.width(), 0);
|
|
|
|
} else {
|
2015-03-02 12:34:16 +00:00
|
|
|
if (!_contacts.isHidden()) _contacts.hide();
|
2014-12-12 16:27:03 +00:00
|
|
|
if (!MTP::authedId()) _about.move(_settings.x() + _settings.width(), 0);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hider) hider->resize(size());
|
|
|
|
}
|
|
|
|
|
2014-12-15 15:55:45 +00:00
|
|
|
void TitleWidget::updateBackButton() {
|
2015-03-02 12:34:16 +00:00
|
|
|
if (App::passcoded()) {
|
|
|
|
if (!_cancel.isHidden()) _cancel.hide();
|
2014-12-12 16:27:03 +00:00
|
|
|
if (!_back.isHidden()) _back.hide();
|
2014-12-16 19:19:09 +00:00
|
|
|
if (!_settings.isHidden()) _settings.hide();
|
|
|
|
if (!_contacts.isHidden()) _contacts.hide();
|
|
|
|
if (!_about.isHidden()) _about.hide();
|
2015-03-02 12:34:16 +00:00
|
|
|
_lock.setSysBtnStyle(st::sysUnlock);
|
2014-12-12 16:27:03 +00:00
|
|
|
} else {
|
2015-03-02 12:34:16 +00:00
|
|
|
_lock.setSysBtnStyle(st::sysLock);
|
2016-02-08 14:54:55 +00:00
|
|
|
if (Adaptive::OneColumn() && App::main() && App::main()->selectingPeer()) {
|
2015-03-02 12:34:16 +00:00
|
|
|
_cancel.show();
|
2014-12-12 16:27:03 +00:00
|
|
|
if (!_back.isHidden()) _back.hide();
|
2015-03-02 12:34:16 +00:00
|
|
|
if (!_settings.isHidden()) _settings.hide();
|
|
|
|
if (!_contacts.isHidden()) _contacts.hide();
|
|
|
|
if (!_about.isHidden()) _about.hide();
|
2014-12-12 16:27:03 +00:00
|
|
|
} else {
|
2015-03-02 12:34:16 +00:00
|
|
|
if (!_cancel.isHidden()) _cancel.hide();
|
|
|
|
bool authed = (MTP::authedId() > 0);
|
2016-02-08 14:54:55 +00:00
|
|
|
if (Adaptive::OneColumn()) {
|
2015-03-02 12:34:16 +00:00
|
|
|
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();
|
|
|
|
}
|
2016-02-08 14:54:55 +00:00
|
|
|
} else {
|
|
|
|
if (!_back.isHidden()) _back.hide();
|
|
|
|
if (_settings.isHidden()) _settings.show();
|
|
|
|
if (authed && _contacts.isHidden()) _contacts.show();
|
|
|
|
if (_about.isHidden()) _about.show();
|
2014-12-12 16:27:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
showUpdateBtn();
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2016-02-08 14:54:55 +00:00
|
|
|
void TitleWidget::updateAdaptiveLayout() {
|
2014-12-12 16:27:03 +00:00
|
|
|
updateBackButton();
|
2016-02-08 14:54:55 +00:00
|
|
|
if (Adaptive::OneColumn()) {
|
2014-12-15 15:55:45 +00:00
|
|
|
updateCounter();
|
|
|
|
}
|
2014-12-12 16:27:03 +00:00
|
|
|
if (hider) {
|
2016-02-08 14:54:55 +00:00
|
|
|
if (Adaptive::OneColumn()) {
|
2014-12-12 16:27:03 +00:00
|
|
|
hider->hide();
|
2016-02-08 14:54:55 +00:00
|
|
|
} else {
|
|
|
|
hider->show();
|
2014-12-12 16:27:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-15 15:55:45 +00:00
|
|
|
void TitleWidget::updateCounter() {
|
2016-02-08 14:54:55 +00:00
|
|
|
if (!Adaptive::OneColumn() || !MTP::authedId()) return;
|
2014-12-15 15:55:45 +00:00
|
|
|
|
2015-08-28 15:15:56 +00:00
|
|
|
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;
|
2016-01-11 15:43:29 +00:00
|
|
|
|
2014-12-15 15:55:45 +00:00
|
|
|
if (counter > 0) {
|
2014-12-15 20:40:43 +00:00
|
|
|
int32 size = cRetina() ? -32 : -16;
|
2014-12-15 15:55:45 +00:00
|
|
|
switch (cScale()) {
|
|
|
|
case dbisOneAndQuarter: size = -20; break;
|
|
|
|
case dbisOneAndHalf: size = -24; break;
|
|
|
|
case dbisTwo: size = -32; break;
|
|
|
|
}
|
2014-12-22 23:11:37 +00:00
|
|
|
_counter = QPixmap::fromImage(App::wnd()->iconWithCounter(size, counter, bg, false), Qt::ColorOnly);
|
2014-12-15 15:55:45 +00:00
|
|
|
_counter.setDevicePixelRatio(cRetinaFactor());
|
|
|
|
update(QRect(st::titleIconPos, st::titleIconImg.pxSize()));
|
|
|
|
} else {
|
|
|
|
if (!_counter.isNull()) {
|
|
|
|
_counter = QPixmap();
|
|
|
|
update(QRect(st::titleIconPos, st::titleIconImg.pxSize()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void TitleWidget::mousePressEvent(QMouseEvent *e) {
|
|
|
|
if (wnd->psHandleTitle()) return;
|
|
|
|
if (e->buttons() & Qt::LeftButton) {
|
|
|
|
wnd->wStartDrag(e);
|
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TitleWidget::mouseDoubleClickEvent(QMouseEvent *e) {
|
|
|
|
if (wnd->psHandleTitle()) return;
|
|
|
|
Qt::WindowStates s(wnd->windowState());
|
|
|
|
if (s.testFlag(Qt::WindowMaximized)) {
|
|
|
|
wnd->setWindowState(s & ~Qt::WindowMaximized);
|
|
|
|
} else {
|
|
|
|
wnd->setWindowState(s | Qt::WindowMaximized);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TitleWidget::stateChanged(Qt::WindowState state) {
|
|
|
|
if (state == Qt::WindowMinimized) return;
|
|
|
|
maximizedChanged(state == Qt::WindowMaximized);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TitleWidget::showUpdateBtn() {
|
2016-02-08 14:54:55 +00:00
|
|
|
if (Adaptive::OneColumn() && App::main() && App::main()->selectingPeer()) {
|
2014-12-12 16:27:03 +00:00
|
|
|
_cancel.show();
|
2015-03-02 12:34:16 +00:00
|
|
|
_lock.hide();
|
2014-12-12 16:27:03 +00:00
|
|
|
_update.hide();
|
|
|
|
_minimize.hide();
|
|
|
|
_restore.hide();
|
|
|
|
_maximize.hide();
|
|
|
|
_close.hide();
|
|
|
|
return;
|
|
|
|
}
|
2015-03-02 12:34:16 +00:00
|
|
|
if (cHasPasscode()) {
|
|
|
|
_lock.show();
|
|
|
|
} else {
|
|
|
|
_lock.hide();
|
|
|
|
}
|
2016-01-30 16:31:10 +00:00
|
|
|
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
|
2016-02-08 14:54:55 +00:00
|
|
|
bool updateReady = (Sandbox::updatingState() == Application::UpdatingReady);
|
2016-01-30 16:31:10 +00:00
|
|
|
#else
|
|
|
|
bool updateReady = false;
|
|
|
|
#endif
|
2014-12-01 10:47:38 +00:00
|
|
|
if (updateReady || cEvalScale(cConfigScale()) != cEvalScale(cRealScale())) {
|
|
|
|
_update.setText(lang(updateReady ? lng_menu_update : lng_menu_restart));
|
2014-05-30 08:53:19 +00:00
|
|
|
_update.show();
|
2014-12-01 10:47:38 +00:00
|
|
|
resizeEvent(0);
|
2014-11-18 12:41:33 +00:00
|
|
|
_minimize.hide();
|
|
|
|
_restore.hide();
|
|
|
|
_maximize.hide();
|
|
|
|
_close.hide();
|
2015-12-08 12:33:37 +00:00
|
|
|
_a_update.start();
|
2014-05-30 08:53:19 +00:00
|
|
|
} else {
|
|
|
|
_update.hide();
|
2014-11-18 12:41:33 +00:00
|
|
|
if (cPlatform() == dbipWindows) {
|
|
|
|
_minimize.show();
|
2015-01-27 16:58:58 +00:00
|
|
|
maximizedChanged(lastMaximized, true);
|
2014-11-18 12:41:33 +00:00
|
|
|
_close.show();
|
|
|
|
}
|
2015-12-08 12:33:37 +00:00
|
|
|
_a_update.stop();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
resizeEvent(0);
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2014-11-18 12:41:33 +00:00
|
|
|
void TitleWidget::maximizedChanged(bool maximized, bool force) {
|
|
|
|
if (lastMaximized == maximized && !force) return;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
lastMaximized = maximized;
|
2014-06-15 12:31:03 +00:00
|
|
|
|
2014-11-18 12:41:33 +00:00
|
|
|
if (cPlatform() != dbipWindows || !_update.isHidden()) return;
|
2014-05-30 08:53:19 +00:00
|
|
|
if (maximized) {
|
|
|
|
_maximize.clearState();
|
|
|
|
} else {
|
|
|
|
_restore.clearState();
|
|
|
|
}
|
|
|
|
|
|
|
|
_maximize.setVisible(!maximized);
|
|
|
|
_restore.setVisible(maximized);
|
|
|
|
|
|
|
|
resizeEvent(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
HitTestType TitleWidget::hitTest(const QPoint &p) {
|
2015-12-07 18:09:05 +00:00
|
|
|
if (App::wnd() && Ui::isLayerShown()) return HitTestNone;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-10-01 14:05:05 +00:00
|
|
|
int x(p.x()), y(p.y()), w(width()), h(height());
|
2016-02-08 14:54:55 +00:00
|
|
|
if (!Adaptive::OneColumn() && hider && x >= App::main()->dlgsWidth()) return HitTestNone;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-12-15 15:55:45 +00:00
|
|
|
if (x >= st::titleIconPos.x() && y >= st::titleIconPos.y() && x < st::titleIconPos.x() + st::titleIconImg.pxWidth() && y < st::titleIconPos.y() + st::titleIconImg.pxHeight()) {
|
2014-05-30 08:53:19 +00:00
|
|
|
return HitTestIcon;
|
|
|
|
} else if (false
|
2015-03-02 12:34:16 +00:00
|
|
|
|| (_lock.hitTest(p - _lock.geometry().topLeft()) == HitTestSysButton && _lock.isVisible())
|
2014-07-09 05:54:12 +00:00
|
|
|
|| (_update.hitTest(p - _update.geometry().topLeft()) == HitTestSysButton && _update.isVisible())
|
2014-05-30 08:53:19 +00:00
|
|
|
|| (_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
|
2014-12-12 16:27:03 +00:00
|
|
|
|| (!_back.isHidden() && _back.geometry().contains(x, y))
|
|
|
|
|| (!_cancel.isHidden() && _cancel.geometry().contains(x, y))
|
|
|
|
|| (!_settings.isHidden() && _settings.geometry().contains(x, y))
|
2014-06-16 09:31:10 +00:00
|
|
|
|| (!_contacts.isHidden() && _contacts.geometry().contains(x, y))
|
2014-12-12 16:27:03 +00:00
|
|
|
|| (!_about.isHidden() && _about.geometry().contains(x, y))
|
2014-05-30 08:53:19 +00:00
|
|
|
) {
|
|
|
|
return HitTestClient;
|
|
|
|
}
|
|
|
|
return HitTestCaption;
|
|
|
|
}
|
|
|
|
return HitTestNone;
|
|
|
|
}
|