2020-06-04 14:26:51 +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
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "window/window_title.h"
|
2020-07-18 05:06:29 +00:00
|
|
|
#include "window/window_controls_layout.h"
|
2020-06-04 14:26:51 +00:00
|
|
|
#include "base/object_ptr.h"
|
|
|
|
|
|
|
|
namespace style {
|
|
|
|
struct WindowTitle;
|
|
|
|
} // namespace style
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class IconButton;
|
|
|
|
class PlainShadow;
|
|
|
|
} // namespace Ui
|
|
|
|
|
|
|
|
namespace Window {
|
|
|
|
|
2020-10-02 13:17:53 +00:00
|
|
|
// If we toggle frameless window hint in maximized window, and
|
|
|
|
// show it back too quickly, the mouse position inside the window
|
|
|
|
// won't be correct (from Qt-s point of view) until we Alt-Tab from
|
|
|
|
// that window. If we show the window back with this delay it works.
|
|
|
|
inline constexpr auto kShowAfterWindowFlagChangeDelay = crl::time(1000);
|
|
|
|
|
2020-06-04 14:26:51 +00:00
|
|
|
class TitleWidgetQt : public TitleWidget {
|
|
|
|
public:
|
|
|
|
TitleWidgetQt(QWidget *parent);
|
2020-07-07 17:33:34 +00:00
|
|
|
~TitleWidgetQt();
|
2020-06-04 14:26:51 +00:00
|
|
|
|
|
|
|
void init() override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
2020-10-12 20:37:55 +00:00
|
|
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
2020-06-04 14:26:51 +00:00
|
|
|
|
|
|
|
bool eventFilter(QObject *obj, QEvent *e) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void windowStateChanged(Qt::WindowState state = Qt::WindowNoState);
|
2020-08-28 12:07:29 +00:00
|
|
|
void visibleChanged(bool visible);
|
|
|
|
void updateWindowExtents();
|
2020-06-04 14:26:51 +00:00
|
|
|
void updateButtonsState();
|
|
|
|
void updateControlsPosition();
|
2020-07-18 05:06:29 +00:00
|
|
|
void updateControlsPositionBySide(
|
|
|
|
const std::vector<Control> &controls,
|
|
|
|
bool right);
|
2020-06-04 14:26:51 +00:00
|
|
|
|
2020-07-07 17:33:34 +00:00
|
|
|
void toggleFramelessWindow(bool enabled);
|
2020-08-28 12:07:29 +00:00
|
|
|
bool hasShadow() const;
|
|
|
|
int getResizeArea(Qt::Edge edge) const;
|
2020-06-04 14:26:51 +00:00
|
|
|
Qt::Edges edgesFromPos(const QPoint &pos);
|
2020-07-01 14:28:33 +00:00
|
|
|
void updateCursor(Qt::Edges edges);
|
2020-07-07 17:33:34 +00:00
|
|
|
void restoreCursor();
|
2020-07-10 23:06:19 +00:00
|
|
|
bool startMove();
|
2020-07-01 14:28:33 +00:00
|
|
|
bool startResize(Qt::Edges edges);
|
2020-06-04 14:26:51 +00:00
|
|
|
|
|
|
|
const style::WindowTitle &_st;
|
|
|
|
object_ptr<Ui::IconButton> _minimize;
|
|
|
|
object_ptr<Ui::IconButton> _maximizeRestore;
|
|
|
|
object_ptr<Ui::IconButton> _close;
|
|
|
|
object_ptr<Ui::PlainShadow> _shadow;
|
|
|
|
|
|
|
|
bool _maximizedState = false;
|
|
|
|
bool _activeState = false;
|
2020-07-07 17:33:34 +00:00
|
|
|
bool _windowWasFrameless = false;
|
|
|
|
bool _cursorOverriden = false;
|
2020-08-28 21:00:09 +00:00
|
|
|
bool _extentsSet = false;
|
2020-10-12 20:37:55 +00:00
|
|
|
bool _pressedForMove = false;
|
|
|
|
crl::time _pressedForMoveTime = 0;
|
|
|
|
QPoint _pressedForMovePoint;
|
2020-06-04 14:26:51 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Window
|