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 {
|
|
|
|
|
|
|
|
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;
|
2021-02-02 13:03:00 +00:00
|
|
|
void mouseMoveEvent(QMouseEvent *e) override;
|
|
|
|
void mouseDoubleClickEvent(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;
|
2021-02-02 13:03:00 +00:00
|
|
|
QMargins resizeArea() const;
|
|
|
|
Qt::Edges edgesFromPos(const QPoint &pos) const;
|
2020-07-01 14:28:33 +00:00
|
|
|
void updateCursor(Qt::Edges edges);
|
2021-02-03 05:34:37 +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;
|
2021-02-03 05:34:37 +00:00
|
|
|
bool _cursorOverriden = false;
|
2020-08-28 21:00:09 +00:00
|
|
|
bool _extentsSet = false;
|
2021-02-02 13:03:00 +00:00
|
|
|
bool _mousePressed = false;
|
2020-06-04 14:26:51 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Window
|