2016-10-08 18:28:43 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-10-08 18:28:43 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-10-08 18:28:43 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-02-28 10:51:00 +00:00
|
|
|
#include "platform/platform_window_title.h"
|
2019-09-13 12:22:54 +00:00
|
|
|
#include "base/object_ptr.h"
|
2016-10-08 18:28:43 +00:00
|
|
|
|
2019-10-20 11:32:44 +00:00
|
|
|
namespace style {
|
|
|
|
struct WindowTitle;
|
|
|
|
} // namespace style
|
|
|
|
|
2016-11-04 08:23:50 +00:00
|
|
|
namespace Ui {
|
|
|
|
class IconButton;
|
2016-11-04 11:14:47 +00:00
|
|
|
class PlainShadow;
|
2016-11-04 08:23:50 +00:00
|
|
|
} // namespace Ui
|
2016-10-08 18:28:43 +00:00
|
|
|
|
2016-12-23 13:21:01 +00:00
|
|
|
namespace Window {
|
|
|
|
namespace Theme {
|
|
|
|
|
|
|
|
int DefaultPreviewTitleHeight();
|
|
|
|
void DefaultPreviewWindowFramePaint(QImage &preview, const style::palette &palette, QRect body, int outerWidth);
|
|
|
|
|
|
|
|
} // namespace Theme
|
|
|
|
} // namespace Window
|
|
|
|
|
2016-11-04 08:23:50 +00:00
|
|
|
namespace Platform {
|
|
|
|
|
|
|
|
class TitleWidget : public Window::TitleWidget, private base::Subscriber {
|
|
|
|
Q_OBJECT
|
2016-10-08 18:28:43 +00:00
|
|
|
|
|
|
|
public:
|
2016-11-04 08:23:50 +00:00
|
|
|
TitleWidget(QWidget *parent);
|
2016-10-08 18:28:43 +00:00
|
|
|
|
2016-11-07 15:24:28 +00:00
|
|
|
void init() override;
|
|
|
|
|
2016-11-04 08:23:50 +00:00
|
|
|
Window::HitTestResult hitTest(const QPoint &p) const override;
|
2016-10-08 18:28:43 +00:00
|
|
|
|
2016-11-04 08:23:50 +00:00
|
|
|
public slots:
|
|
|
|
void onWindowStateChanged(Qt::WindowState state = Qt::WindowNoState);
|
|
|
|
void updateControlsVisibility();
|
2016-10-08 18:28:43 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
2016-11-04 08:23:50 +00:00
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2016-10-08 18:28:43 +00:00
|
|
|
|
|
|
|
private:
|
2017-01-16 13:27:11 +00:00
|
|
|
void updateButtonsState();
|
2016-11-04 08:23:50 +00:00
|
|
|
void updateControlsPosition();
|
2016-10-08 18:28:43 +00:00
|
|
|
|
2019-10-20 11:32:44 +00:00
|
|
|
const style::WindowTitle &_st;
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::IconButton> _minimize;
|
|
|
|
object_ptr<Ui::IconButton> _maximizeRestore;
|
|
|
|
object_ptr<Ui::IconButton> _close;
|
|
|
|
object_ptr<Ui::PlainShadow> _shadow;
|
2016-11-04 08:23:50 +00:00
|
|
|
|
2017-01-16 13:27:11 +00:00
|
|
|
bool _maximizedState = false;
|
|
|
|
bool _activeState = false;
|
2016-10-08 18:28:43 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
inline object_ptr<Window::TitleWidget> CreateTitleWidget(QWidget *parent) {
|
|
|
|
return object_ptr<TitleWidget>(parent);
|
2016-11-04 08:23:50 +00:00
|
|
|
}
|
|
|
|
|
2016-12-23 13:21:01 +00:00
|
|
|
inline int PreviewTitleHeight() {
|
|
|
|
return Window::Theme::DefaultPreviewTitleHeight();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void PreviewWindowFramePaint(QImage &preview, const style::palette &palette, QRect body, int outerWidth) {
|
|
|
|
return Window::Theme::DefaultPreviewWindowFramePaint(preview, palette, body, outerWidth);
|
|
|
|
}
|
|
|
|
|
2016-11-04 08:23:50 +00:00
|
|
|
} // namespace Platform
|