2018-03-31 01:45:40 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#include "passport/passport_panel.h"
|
|
|
|
|
|
|
|
#include "passport/passport_panel_controller.h"
|
|
|
|
#include "passport/passport_panel_form.h"
|
|
|
|
#include "passport/passport_panel_password.h"
|
|
|
|
#include "window/main_window.h"
|
|
|
|
#include "platform/platform_specific.h"
|
|
|
|
#include "ui/widgets/shadow.h"
|
|
|
|
#include "ui/widgets/buttons.h"
|
|
|
|
#include "ui/widgets/labels.h"
|
2018-04-15 15:06:53 +00:00
|
|
|
#include "ui/wrap/padding_wrap.h"
|
2018-03-31 01:45:40 +00:00
|
|
|
#include "ui/wrap/fade_wrap.h"
|
|
|
|
#include "lang/lang_keys.h"
|
2018-04-06 16:23:09 +00:00
|
|
|
#include "window/layer_widget.h"
|
2018-03-31 01:45:40 +00:00
|
|
|
#include "messenger.h"
|
|
|
|
#include "styles/style_passport.h"
|
|
|
|
#include "styles/style_widgets.h"
|
|
|
|
#include "styles/style_calls.h"
|
|
|
|
|
|
|
|
namespace Passport {
|
|
|
|
|
|
|
|
Panel::Panel(not_null<PanelController*> controller)
|
|
|
|
: _controller(controller)
|
|
|
|
, _close(this, st::passportPanelClose)
|
|
|
|
, _title(
|
|
|
|
this,
|
|
|
|
lang(lng_passport_title),
|
|
|
|
Ui::FlatLabel::InitType::Simple,
|
|
|
|
st::passportPanelTitle)
|
2018-04-06 16:23:09 +00:00
|
|
|
, _back(this, object_ptr<Ui::IconButton>(this, st::passportPanelBack))
|
|
|
|
, _body(this) {
|
2018-03-31 01:45:40 +00:00
|
|
|
setMouseTracking(true);
|
|
|
|
setWindowIcon(Window::CreateIcon());
|
|
|
|
initControls();
|
|
|
|
initLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::initControls() {
|
|
|
|
widthValue(
|
|
|
|
) | rpl::start_with_next([=](int width) {
|
|
|
|
_back->moveToLeft(_padding.left(), _padding.top());
|
|
|
|
_close->moveToRight(_padding.right(), _padding.top());
|
|
|
|
_title->resizeToWidth(width
|
|
|
|
- _padding.left() - _back->width()
|
|
|
|
- _padding.right() - _close->width());
|
|
|
|
updateTitlePosition();
|
|
|
|
}, lifetime());
|
|
|
|
|
|
|
|
_close->addClickHandler([=] {
|
2018-04-13 18:14:14 +00:00
|
|
|
_controller->cancelAuth();
|
2018-03-31 01:45:40 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
_back->toggledValue(
|
|
|
|
) | rpl::start_with_next([=](bool toggled) {
|
|
|
|
_titleLeft.start(
|
|
|
|
[=] { updateTitlePosition(); },
|
|
|
|
toggled ? 0. : 1.,
|
|
|
|
toggled ? 1. : 0.,
|
|
|
|
st::fadeWrapDuration);
|
|
|
|
}, _title->lifetime());
|
|
|
|
_back->hide(anim::type::instant);
|
|
|
|
_titleLeft.finish();
|
|
|
|
|
|
|
|
_title->setAttribute(Qt::WA_TransparentForMouseEvents);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::updateTitlePosition() {
|
|
|
|
const auto progress = _titleLeft.current(_back->toggled() ? 1. : 0.);
|
|
|
|
const auto left = anim::interpolate(
|
|
|
|
st::passportPanelTitleLeft,
|
|
|
|
_back->width() + st::passportPanelTitleSkip,
|
|
|
|
progress);
|
|
|
|
_title->moveToLeft(
|
|
|
|
_padding.left() + left,
|
|
|
|
_padding.top() + st::passportPanelTitleTop);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
rpl::producer<> Panel::backRequests() const {
|
2018-04-09 17:56:07 +00:00
|
|
|
return rpl::merge(
|
|
|
|
_back->entity()->clicks(),
|
|
|
|
_synteticBackRequests.events());
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::setBackAllowed(bool allowed) {
|
|
|
|
if (allowed != _back->toggled()) {
|
|
|
|
_back->toggle(allowed, anim::type::normal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::showAndActivate() {
|
|
|
|
toggleOpacityAnimation(true);
|
|
|
|
raise();
|
|
|
|
setWindowState(windowState() | Qt::WindowActive);
|
|
|
|
activateWindow();
|
|
|
|
setFocus();
|
|
|
|
}
|
|
|
|
|
2018-04-09 17:56:07 +00:00
|
|
|
void Panel::keyPressEvent(QKeyEvent *e) {
|
|
|
|
if (e->key() == Qt::Key_Escape && _back->toggled()) {
|
|
|
|
_synteticBackRequests.fire({});
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
2018-04-09 17:56:07 +00:00
|
|
|
return RpWidget::keyPressEvent(e);
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::initLayout() {
|
|
|
|
setWindowFlags(Qt::WindowFlags(Qt::FramelessWindowHint)
|
|
|
|
| Qt::WindowStaysOnTopHint
|
|
|
|
| Qt::BypassWindowManagerHint
|
|
|
|
| Qt::NoDropShadowWindowHint
|
|
|
|
| Qt::Dialog);
|
|
|
|
setAttribute(Qt::WA_MacAlwaysShowToolWindow);
|
|
|
|
setAttribute(Qt::WA_NoSystemBackground, true);
|
|
|
|
setAttribute(Qt::WA_TranslucentBackground, true);
|
|
|
|
|
|
|
|
initGeometry();
|
|
|
|
createBorderImage();
|
|
|
|
|
|
|
|
Platform::InitOnTopPanel(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::createBorderImage() {
|
|
|
|
if (!_useTransparency || !_borderParts.isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto cacheSize = st::passportPanelBorderCacheSize;
|
|
|
|
auto cache = QImage(
|
|
|
|
cacheSize * cIntRetinaFactor(),
|
|
|
|
cacheSize * cIntRetinaFactor(),
|
|
|
|
QImage::Format_ARGB32_Premultiplied);
|
|
|
|
cache.setDevicePixelRatio(cRetinaFactor());
|
|
|
|
cache.fill(Qt::transparent);
|
|
|
|
{
|
|
|
|
Painter p(&cache);
|
|
|
|
auto inner = QRect(0, 0, cacheSize, cacheSize).marginsRemoved(
|
|
|
|
_padding);
|
|
|
|
Ui::Shadow::paint(p, inner, width(), st::callShadow);
|
|
|
|
p.setCompositionMode(QPainter::CompositionMode_Source);
|
|
|
|
p.setBrush(st::windowBg);
|
|
|
|
p.setPen(Qt::NoPen);
|
|
|
|
PainterHighQualityEnabler hq(p);
|
|
|
|
p.drawRoundedRect(
|
|
|
|
myrtlrect(inner),
|
|
|
|
st::callRadius,
|
|
|
|
st::callRadius);
|
|
|
|
}
|
|
|
|
_borderParts = App::pixmapFromImageInPlace(std::move(cache));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::toggleOpacityAnimation(bool visible) {
|
|
|
|
if (_visible == visible) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_visible = visible;
|
|
|
|
if (_useTransparency) {
|
|
|
|
if (_animationCache.isNull()) {
|
|
|
|
showControls();
|
|
|
|
_animationCache = Ui::GrabWidget(this);
|
|
|
|
hideChildren();
|
|
|
|
}
|
|
|
|
_opacityAnimation.start(
|
|
|
|
[this] { opacityCallback(); },
|
|
|
|
_visible ? 0. : 1.,
|
|
|
|
_visible ? 1. : 0.,
|
|
|
|
st::callPanelDuration,
|
|
|
|
_visible ? anim::easeOutCirc : anim::easeInCirc);
|
|
|
|
}
|
|
|
|
if (isHidden() && _visible) {
|
|
|
|
show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::opacityCallback() {
|
|
|
|
update();
|
|
|
|
if (!_visible && !_opacityAnimation.animating()) {
|
|
|
|
finishAnimating();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::finishAnimating() {
|
|
|
|
_animationCache = QPixmap();
|
|
|
|
if (_visible) {
|
|
|
|
showControls();
|
|
|
|
_inner->setFocus();
|
|
|
|
} else {
|
|
|
|
destroyDelayed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::showControls() {
|
|
|
|
showChildren();
|
|
|
|
if (!_back->toggled()) {
|
|
|
|
_back->setVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::destroyDelayed() {
|
|
|
|
hide();
|
|
|
|
_controller->cancelAuth();
|
|
|
|
}
|
|
|
|
|
2018-04-13 18:14:14 +00:00
|
|
|
int Panel::hideAndDestroyGetDuration() {
|
2018-03-31 01:45:40 +00:00
|
|
|
toggleOpacityAnimation(false);
|
|
|
|
if (_animationCache.isNull()) {
|
|
|
|
destroyDelayed();
|
2018-04-13 18:14:14 +00:00
|
|
|
return 0;
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
2018-04-13 18:14:14 +00:00
|
|
|
return st::callPanelDuration;
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::showAskPassword() {
|
2018-04-06 16:23:09 +00:00
|
|
|
showInner(base::make_unique_q<PanelAskPassword>(_body, _controller));
|
|
|
|
setBackAllowed(false);
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::showNoPassword() {
|
2018-04-06 16:23:09 +00:00
|
|
|
showInner(base::make_unique_q<PanelNoPassword>(_body, _controller));
|
|
|
|
setBackAllowed(false);
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
2018-04-15 15:06:53 +00:00
|
|
|
void Panel::showCriticalError(const QString &error) {
|
|
|
|
auto container = base::make_unique_q<Ui::PaddingWrap<Ui::FlatLabel>>(
|
|
|
|
_body,
|
|
|
|
object_ptr<Ui::FlatLabel>(
|
|
|
|
_body,
|
|
|
|
error,
|
|
|
|
Ui::FlatLabel::InitType::Simple,
|
|
|
|
st::passportErrorLabel),
|
|
|
|
style::margins(0, st::passportPanelHeight / 3, 0, 0));
|
|
|
|
container->widthValue(
|
|
|
|
) | rpl::start_with_next([label = container->entity()](int width) {
|
|
|
|
label->resize(width, label->height());
|
|
|
|
}, container->lifetime());
|
|
|
|
showInner(std::move(container));
|
|
|
|
setBackAllowed(false);
|
|
|
|
}
|
|
|
|
|
2018-03-31 01:45:40 +00:00
|
|
|
void Panel::showForm() {
|
2018-04-06 16:23:09 +00:00
|
|
|
showInner(base::make_unique_q<PanelForm>(_body, _controller));
|
|
|
|
setBackAllowed(false);
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::showEditValue(object_ptr<Ui::RpWidget> from) {
|
|
|
|
showInner(base::unique_qptr<Ui::RpWidget>(from.data()));
|
|
|
|
}
|
|
|
|
|
2018-04-16 17:02:40 +00:00
|
|
|
void Panel::showBox(
|
|
|
|
object_ptr<BoxContent> box,
|
|
|
|
LayerOptions options,
|
|
|
|
anim::type animated) {
|
2018-04-06 16:23:09 +00:00
|
|
|
ensureLayerCreated();
|
2018-04-16 17:02:40 +00:00
|
|
|
_layer->showBox(std::move(box), options, animated);
|
2018-04-06 16:23:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::ensureLayerCreated() {
|
|
|
|
if (_layer) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_layer.create(_body);
|
2018-04-17 15:41:52 +00:00
|
|
|
_layer->setHideByBackgroundClick(false);
|
2018-04-06 16:23:09 +00:00
|
|
|
_layer->move(0, 0);
|
|
|
|
_body->sizeValue(
|
|
|
|
) | rpl::start_with_next([=](QSize size) {
|
|
|
|
_layer->resize(size);
|
|
|
|
}, _layer->lifetime());
|
|
|
|
_layer->hideFinishEvents(
|
|
|
|
) | rpl::start_with_next([=, pointer = _layer.data()]{
|
|
|
|
if (_layer != pointer) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto saved = std::exchange(_layer, nullptr);
|
|
|
|
if (Ui::InFocusChain(saved)) {
|
|
|
|
setFocus();
|
|
|
|
}
|
|
|
|
saved.destroyDelayed();
|
|
|
|
}, _layer->lifetime());
|
|
|
|
}
|
|
|
|
|
2018-03-31 01:45:40 +00:00
|
|
|
void Panel::showInner(base::unique_qptr<Ui::RpWidget> inner) {
|
|
|
|
_inner = std::move(inner);
|
2018-04-06 16:23:09 +00:00
|
|
|
_inner->setParent(_body);
|
|
|
|
_inner->move(0, 0);
|
|
|
|
_body->sizeValue(
|
|
|
|
) | rpl::start_with_next([=](QSize size) {
|
|
|
|
_inner->resize(size);
|
2018-03-31 01:45:40 +00:00
|
|
|
}, _inner->lifetime());
|
2018-04-06 16:23:09 +00:00
|
|
|
_inner->show();
|
2018-03-31 01:45:40 +00:00
|
|
|
|
2018-04-09 17:56:07 +00:00
|
|
|
if (_layer) {
|
|
|
|
_layer->raise();
|
|
|
|
}
|
|
|
|
|
2018-03-31 01:45:40 +00:00
|
|
|
showAndActivate();
|
2018-04-06 16:23:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::focusInEvent(QFocusEvent *e) {
|
2018-04-13 05:11:53 +00:00
|
|
|
crl::on_main(this, [=] {
|
|
|
|
if (_layer) {
|
|
|
|
_layer->setInnerFocus();
|
|
|
|
} else if (!_inner->isHidden()) {
|
|
|
|
_inner->setFocus();
|
|
|
|
}
|
|
|
|
});
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::initGeometry() {
|
2018-04-12 10:20:54 +00:00
|
|
|
const auto center = Messenger::Instance().getPointForCallPanelCenter();
|
2018-03-31 01:45:40 +00:00
|
|
|
_useTransparency = Platform::TranslucentWindowsSupported(center);
|
|
|
|
setAttribute(Qt::WA_OpaquePaintEvent, !_useTransparency);
|
|
|
|
_padding = _useTransparency
|
|
|
|
? st::callShadow.extend
|
|
|
|
: style::margins(
|
|
|
|
st::lineWidth,
|
|
|
|
st::lineWidth,
|
|
|
|
st::lineWidth,
|
|
|
|
st::lineWidth);
|
2018-04-12 10:20:54 +00:00
|
|
|
const auto screen = QApplication::desktop()->screenGeometry(center);
|
|
|
|
const auto rect = QRect(
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
st::passportPanelWidth,
|
|
|
|
st::passportPanelHeight);
|
|
|
|
setGeometry(
|
|
|
|
rect.translated(center - rect.center()).marginsAdded(_padding));
|
2018-03-31 01:45:40 +00:00
|
|
|
updateControlsGeometry();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::resizeEvent(QResizeEvent *e) {
|
|
|
|
updateControlsGeometry();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::updateControlsGeometry() {
|
2018-04-06 16:23:09 +00:00
|
|
|
const auto top = _padding.top() + st::passportPanelTitleHeight;
|
|
|
|
_body->setGeometry(
|
|
|
|
_padding.left(),
|
|
|
|
top,
|
|
|
|
width() - _padding.left() - _padding.right(),
|
|
|
|
height() - top - _padding.bottom());
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::paintEvent(QPaintEvent *e) {
|
|
|
|
Painter p(this);
|
|
|
|
if (!_animationCache.isNull()) {
|
|
|
|
auto opacity = _opacityAnimation.current(
|
|
|
|
getms(),
|
|
|
|
_visible ? 1. : 0.);
|
|
|
|
if (!_opacityAnimation.animating()) {
|
|
|
|
finishAnimating();
|
|
|
|
if (isHidden()) return;
|
|
|
|
} else {
|
|
|
|
Platform::StartTranslucentPaint(p, e);
|
|
|
|
p.setOpacity(opacity);
|
|
|
|
|
|
|
|
PainterHighQualityEnabler hq(p);
|
|
|
|
auto marginRatio = (1. - opacity) / 5;
|
|
|
|
auto marginWidth = qRound(width() * marginRatio);
|
|
|
|
auto marginHeight = qRound(height() * marginRatio);
|
|
|
|
p.drawPixmap(
|
|
|
|
rect().marginsRemoved(
|
|
|
|
QMargins(
|
|
|
|
marginWidth,
|
|
|
|
marginHeight,
|
|
|
|
marginWidth,
|
|
|
|
marginHeight)),
|
|
|
|
_animationCache,
|
|
|
|
QRect(QPoint(0, 0), _animationCache.size()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_useTransparency) {
|
|
|
|
Platform::StartTranslucentPaint(p, e);
|
|
|
|
paintShadowBorder(p);
|
|
|
|
} else {
|
|
|
|
paintOpaqueBorder(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::paintShadowBorder(Painter &p) const {
|
|
|
|
const auto factor = cIntRetinaFactor();
|
|
|
|
const auto size = st::passportPanelBorderCacheSize;
|
|
|
|
const auto part1 = size / 3;
|
|
|
|
const auto part2 = size - part1;
|
|
|
|
const auto corner = QSize(part1, part1) * factor;
|
2018-04-12 10:20:54 +00:00
|
|
|
|
2018-03-31 01:45:40 +00:00
|
|
|
const auto topleft = QRect(QPoint(0, 0), corner);
|
|
|
|
p.drawPixmap(QRect(0, 0, part1, part1), _borderParts, topleft);
|
2018-04-12 10:20:54 +00:00
|
|
|
|
2018-03-31 01:45:40 +00:00
|
|
|
const auto topright = QRect(QPoint(part2, 0) * factor, corner);
|
2018-04-12 10:20:54 +00:00
|
|
|
p.drawPixmap(
|
|
|
|
QRect(width() - part1, 0, part1, part1),
|
|
|
|
_borderParts,
|
|
|
|
topright);
|
|
|
|
|
2018-03-31 01:45:40 +00:00
|
|
|
const auto bottomleft = QRect(QPoint(0, part2) * factor, corner);
|
2018-04-12 10:20:54 +00:00
|
|
|
p.drawPixmap(
|
|
|
|
QRect(0, height() - part1, part1, part1),
|
|
|
|
_borderParts,
|
|
|
|
bottomleft);
|
2018-03-31 01:45:40 +00:00
|
|
|
|
2018-04-12 10:20:54 +00:00
|
|
|
const auto bottomright = QRect(QPoint(part2, part2) * factor, corner);
|
|
|
|
p.drawPixmap(
|
|
|
|
QRect(width() - part1, height() - part1, part1, part1),
|
|
|
|
_borderParts,
|
|
|
|
bottomright);
|
|
|
|
|
|
|
|
const auto left = QRect(
|
|
|
|
QPoint(0, part1) * factor,
|
|
|
|
QSize(_padding.left(), part2 - part1) * factor);
|
|
|
|
p.drawPixmap(
|
|
|
|
QRect(0, part1, _padding.left(), height() - 2 * part1),
|
|
|
|
_borderParts,
|
|
|
|
left);
|
|
|
|
|
|
|
|
const auto top = QRect(
|
|
|
|
QPoint(part1, 0) * factor,
|
|
|
|
QSize(part2 - part1, _padding.top() + st::callRadius) * factor);
|
|
|
|
p.drawPixmap(
|
|
|
|
QRect(
|
|
|
|
part1,
|
|
|
|
0,
|
|
|
|
width() - 2 * part1,
|
|
|
|
_padding.top() + st::callRadius),
|
|
|
|
_borderParts,
|
|
|
|
top);
|
|
|
|
|
|
|
|
const auto right = QRect(
|
|
|
|
QPoint(size - _padding.right(), part1) * factor,
|
|
|
|
QSize(_padding.right(), part2 - part1) * factor);
|
|
|
|
p.drawPixmap(
|
|
|
|
QRect(
|
|
|
|
width() - _padding.right(),
|
|
|
|
part1,
|
|
|
|
_padding.right(),
|
|
|
|
height() - 2 * part1),
|
|
|
|
_borderParts,
|
|
|
|
right);
|
|
|
|
|
|
|
|
const auto bottom = QRect(
|
|
|
|
QPoint(part1, size - _padding.bottom() - st::callRadius) * factor,
|
|
|
|
QSize(part2 - part1, _padding.bottom() + st::callRadius) * factor);
|
|
|
|
p.drawPixmap(
|
|
|
|
QRect(
|
|
|
|
part1,
|
|
|
|
height() - _padding.bottom() - st::callRadius,
|
|
|
|
width() - 2 * part1,
|
|
|
|
_padding.bottom() + st::callRadius),
|
|
|
|
_borderParts,
|
|
|
|
bottom);
|
|
|
|
|
|
|
|
p.fillRect(
|
|
|
|
_padding.left(),
|
|
|
|
_padding.top() + st::callRadius,
|
|
|
|
width() - _padding.left() - _padding.right(),
|
|
|
|
height() - _padding.top() - _padding.bottom() - 2 * st::callRadius,
|
|
|
|
st::windowBg);
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::paintOpaqueBorder(Painter &p) const {
|
|
|
|
const auto border = st::windowShadowFgFallback;
|
|
|
|
p.fillRect(0, 0, width(), _padding.top(), border);
|
2018-04-12 10:20:54 +00:00
|
|
|
p.fillRect(
|
|
|
|
myrtlrect(
|
|
|
|
0,
|
|
|
|
_padding.top(),
|
|
|
|
_padding.left(),
|
|
|
|
height() - _padding.top()),
|
|
|
|
border);
|
|
|
|
p.fillRect(
|
|
|
|
myrtlrect(
|
|
|
|
width() - _padding.right(),
|
|
|
|
_padding.top(),
|
|
|
|
_padding.right(),
|
|
|
|
height() - _padding.top()),
|
|
|
|
border);
|
|
|
|
p.fillRect(
|
|
|
|
_padding.left(),
|
|
|
|
height() - _padding.bottom(),
|
|
|
|
width() - _padding.left() - _padding.right(),
|
|
|
|
_padding.bottom(),
|
|
|
|
border);
|
2018-03-31 01:45:40 +00:00
|
|
|
|
2018-04-12 10:20:54 +00:00
|
|
|
p.fillRect(
|
|
|
|
_padding.left(),
|
|
|
|
_padding.top(),
|
|
|
|
width() - _padding.left() - _padding.right(),
|
|
|
|
height() - _padding.top() - _padding.bottom(),
|
|
|
|
st::windowBg);
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::closeEvent(QCloseEvent *e) {
|
2018-04-15 15:06:53 +00:00
|
|
|
// #TODO passport
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::mousePressEvent(QMouseEvent *e) {
|
|
|
|
auto dragArea = myrtlrect(
|
|
|
|
_padding.left(),
|
|
|
|
_padding.top(),
|
|
|
|
width() - _padding.left() - _padding.right(),
|
|
|
|
st::passportPanelTitleHeight);
|
|
|
|
if (e->button() == Qt::LeftButton) {
|
|
|
|
if (dragArea.contains(e->pos())) {
|
|
|
|
_dragging = true;
|
|
|
|
_dragStartMousePosition = e->globalPos();
|
|
|
|
_dragStartMyPosition = QPoint(x(), y());
|
|
|
|
} else if (!rect().contains(e->pos())) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::mouseMoveEvent(QMouseEvent *e) {
|
|
|
|
if (_dragging) {
|
|
|
|
if (!(e->buttons() & Qt::LeftButton)) {
|
|
|
|
_dragging = false;
|
|
|
|
} else {
|
2018-04-12 10:20:54 +00:00
|
|
|
move(_dragStartMyPosition
|
|
|
|
+ (e->globalPos() - _dragStartMousePosition));
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::mouseReleaseEvent(QMouseEvent *e) {
|
|
|
|
if (e->button() == Qt::LeftButton) {
|
|
|
|
_dragging = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::leaveEventHook(QEvent *e) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::leaveToChildEvent(QEvent *e, QWidget *child) {
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Passport
|