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