2017-04-19 20:25:48 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "base/weak_unique_ptr.h"
|
2017-04-25 16:45:41 +00:00
|
|
|
#include "base/timer.h"
|
2017-04-29 18:41:41 +00:00
|
|
|
#include "calls/calls_call.h"
|
|
|
|
#include "ui/widgets/tooltip.h"
|
2017-04-19 20:25:48 +00:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class IconButton;
|
|
|
|
class FlatLabel;
|
2017-05-05 10:14:40 +00:00
|
|
|
template <typename Widget>
|
|
|
|
class WidgetFadeWrap;
|
2017-04-19 20:25:48 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
|
|
|
namespace Calls {
|
|
|
|
|
2017-04-29 18:41:41 +00:00
|
|
|
class Panel : public TWidget, private base::Subscriber, private Ui::AbstractTooltipShower {
|
2017-04-19 20:25:48 +00:00
|
|
|
public:
|
|
|
|
Panel(gsl::not_null<Call*> call);
|
|
|
|
|
2017-04-25 20:36:04 +00:00
|
|
|
void showAndActivate();
|
2017-05-04 12:29:32 +00:00
|
|
|
void replaceCall(gsl::not_null<Call*> call);
|
2017-05-04 13:32:56 +00:00
|
|
|
void hideAndDestroy();
|
2017-05-04 12:29:32 +00:00
|
|
|
|
2017-04-19 20:25:48 +00:00
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
2017-05-12 15:27:19 +00:00
|
|
|
void closeEvent(QCloseEvent *e) override;
|
2017-04-19 20:25:48 +00:00
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *e) override;
|
2017-04-29 18:41:41 +00:00
|
|
|
void leaveEventHook(QEvent *e) override;
|
|
|
|
void leaveToChildEvent(QEvent *e, QWidget *child) override;
|
2017-04-25 20:36:04 +00:00
|
|
|
bool event(QEvent *e) override;
|
2017-04-19 20:25:48 +00:00
|
|
|
|
|
|
|
private:
|
2017-04-25 16:45:41 +00:00
|
|
|
using State = Call::State;
|
|
|
|
using Type = Call::Type;
|
|
|
|
|
2017-04-29 18:41:41 +00:00
|
|
|
// AbstractTooltipShower interface
|
|
|
|
QString tooltipText() const override;
|
|
|
|
QPoint tooltipPos() const override;
|
|
|
|
bool tooltipWindowActive() const override;
|
|
|
|
|
2017-04-19 20:25:48 +00:00
|
|
|
void initControls();
|
2017-05-04 12:29:32 +00:00
|
|
|
void reinitControls();
|
2017-04-19 20:25:48 +00:00
|
|
|
void initLayout();
|
|
|
|
void initGeometry();
|
2017-04-25 20:36:04 +00:00
|
|
|
void hideDeactivated();
|
2017-04-19 20:25:48 +00:00
|
|
|
void createBottomImage();
|
|
|
|
void createDefaultCacheImage();
|
|
|
|
void refreshCacheImageUserPhoto();
|
|
|
|
|
|
|
|
void processUserPhoto();
|
|
|
|
void refreshUserPhoto();
|
|
|
|
bool isGoodUserPhoto(PhotoData *photo);
|
|
|
|
void createUserpicCache(ImagePtr image);
|
|
|
|
|
2017-04-25 16:45:41 +00:00
|
|
|
void updateControlsGeometry();
|
2017-05-05 10:14:40 +00:00
|
|
|
void updateHangupGeometry();
|
2017-04-25 16:45:41 +00:00
|
|
|
void updateStatusGeometry();
|
|
|
|
void stateChanged(State state);
|
2017-05-05 10:14:40 +00:00
|
|
|
void showControls();
|
2017-04-25 16:45:41 +00:00
|
|
|
void updateStatusText(State state);
|
|
|
|
void startDurationUpdateTimer(TimeMs currentDuration);
|
2017-04-29 18:41:41 +00:00
|
|
|
void fillFingerprint();
|
2017-05-04 13:32:56 +00:00
|
|
|
void toggleOpacityAnimation(bool visible);
|
|
|
|
void finishAnimation();
|
|
|
|
void destroyDelayed();
|
2017-04-19 20:25:48 +00:00
|
|
|
|
2017-05-04 13:32:56 +00:00
|
|
|
Call *_call = nullptr;
|
2017-04-19 20:25:48 +00:00
|
|
|
gsl::not_null<UserData*> _user;
|
|
|
|
|
|
|
|
bool _useTransparency = true;
|
|
|
|
style::margins _padding;
|
|
|
|
int _contentTop = 0;
|
|
|
|
|
|
|
|
bool _dragging = false;
|
|
|
|
QPoint _dragStartMousePosition;
|
|
|
|
QPoint _dragStartMyPosition;
|
|
|
|
|
2017-05-04 12:29:32 +00:00
|
|
|
int _stateChangedSubscription = 0;
|
|
|
|
|
2017-04-19 20:25:48 +00:00
|
|
|
class Button;
|
2017-05-05 10:14:40 +00:00
|
|
|
object_ptr<Button> _answerHangupRedial;
|
|
|
|
object_ptr<Ui::WidgetFadeWrap<Button>> _decline;
|
|
|
|
object_ptr<Ui::WidgetFadeWrap<Button>> _cancel;
|
|
|
|
bool _hangupShown = false;
|
|
|
|
Animation _hangupShownProgress;
|
2017-04-19 20:25:48 +00:00
|
|
|
object_ptr<Ui::IconButton> _mute;
|
|
|
|
object_ptr<Ui::FlatLabel> _name;
|
|
|
|
object_ptr<Ui::FlatLabel> _status;
|
|
|
|
std::vector<EmojiPtr> _fingerprint;
|
2017-04-29 18:41:41 +00:00
|
|
|
QRect _fingerprintArea;
|
2017-04-19 20:25:48 +00:00
|
|
|
|
2017-04-25 16:45:41 +00:00
|
|
|
base::Timer _updateDurationTimer;
|
2017-05-07 19:09:20 +00:00
|
|
|
base::Timer _updateOuterRippleTimer;
|
2017-04-25 16:45:41 +00:00
|
|
|
|
2017-05-05 10:14:40 +00:00
|
|
|
bool _visible = false;
|
2017-04-19 20:25:48 +00:00
|
|
|
QPixmap _userPhoto;
|
|
|
|
PhotoId _userPhotoId = 0;
|
|
|
|
bool _userPhotoFull = false;
|
|
|
|
|
2017-05-04 13:32:56 +00:00
|
|
|
Animation _opacityAnimation;
|
|
|
|
QPixmap _animationCache;
|
2017-04-19 20:25:48 +00:00
|
|
|
QPixmap _bottomCache;
|
|
|
|
QPixmap _cache;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Calls
|