From 92d48a7846d306d8f8e5dff3bad306eafeb5baa6 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 20 Oct 2019 15:32:44 +0400 Subject: [PATCH] Fix build on Windows. --- .../platform/win/main_window_win.cpp | 2 +- .../platform/win/window_title_win.cpp | 42 ++++++++++++++----- .../platform/win/window_title_win.h | 5 +++ 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/Telegram/SourceFiles/platform/win/main_window_win.cpp b/Telegram/SourceFiles/platform/win/main_window_win.cpp index 721eb3dd3..1b6c8c370 100644 --- a/Telegram/SourceFiles/platform/win/main_window_win.cpp +++ b/Telegram/SourceFiles/platform/win/main_window_win.cpp @@ -192,7 +192,7 @@ public: max_w = avail.width(); accumulate_max(max_w, st::windowMinWidth); max_h = avail.height(); - accumulate_max(max_h, st::titleHeight + st::windowMinHeight); + accumulate_max(max_h, st::defaultWindowTitle.height + st::windowMinHeight); HINSTANCE appinst = (HINSTANCE)GetModuleHandle(0); HWND hwnd = _window ? _window->psHwnd() : nullptr; diff --git a/Telegram/SourceFiles/platform/win/window_title_win.cpp b/Telegram/SourceFiles/platform/win/window_title_win.cpp index 194eda739..9e2687f4f 100644 --- a/Telegram/SourceFiles/platform/win/window_title_win.cpp +++ b/Telegram/SourceFiles/platform/win/window_title_win.cpp @@ -15,10 +15,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Platform { -TitleWidget::TitleWidget(QWidget *parent) : Window::TitleWidget(parent) -, _minimize(this, st::titleButtonMinimize) -, _maximizeRestore(this, st::titleButtonMaximize) -, _close(this, st::titleButtonClose) +TitleWidget::TitleWidget(QWidget *parent) +: Window::TitleWidget(parent) +, _st(st::defaultWindowTitle) +, _minimize(this, _st.minimize) +, _maximizeRestore(this, _st.maximize) +, _close(this, _st.close) , _shadow(this, st::titleShadow) , _maximizedState(parent->window()->windowState() & Qt::WindowMaximized) { _minimize->setClickedCallback([this]() { @@ -38,7 +40,7 @@ TitleWidget::TitleWidget(QWidget *parent) : Window::TitleWidget(parent) _close->setPointerCursor(false); setAttribute(Qt::WA_OpaquePaintEvent); - resize(width(), st::titleHeight); + resize(width(), _st.height); } void TitleWidget::init() { @@ -54,7 +56,7 @@ void TitleWidget::paintEvent(QPaintEvent *e) { _activeState = active; updateButtonsState(); } - Painter(this).fillRect(rect(), active ? st::titleBgActive : st::titleBg); + Painter(this).fillRect(rect(), active ? _st.bgActive : _st.bg); } void TitleWidget::updateControlsPosition() { @@ -85,13 +87,33 @@ void TitleWidget::onWindowStateChanged(Qt::WindowState state) { } void TitleWidget::updateButtonsState() { - _minimize->setIconOverride(_activeState ? &st::titleButtonMinimizeIconActive : nullptr, _activeState ? &st::titleButtonMinimizeIconActiveOver : nullptr); + _minimize->setIconOverride(_activeState + ? &_st.minimizeIconActive + : nullptr, + _activeState + ? &_st.minimizeIconActiveOver + : nullptr); if (_maximizedState) { - _maximizeRestore->setIconOverride(_activeState ? &st::titleButtonRestoreIconActive : &st::titleButtonRestoreIcon, _activeState ? &st::titleButtonRestoreIconActiveOver : &st::titleButtonRestoreIconOver); + _maximizeRestore->setIconOverride( + _activeState + ? &_st.restoreIconActive : &_st.restoreIcon, + _activeState + ? &_st.restoreIconActiveOver + : &_st.restoreIconOver); } else { - _maximizeRestore->setIconOverride(_activeState ? &st::titleButtonMaximizeIconActive : nullptr, _activeState ? &st::titleButtonMaximizeIconActiveOver : nullptr); + _maximizeRestore->setIconOverride(_activeState + ? &_st.maximizeIconActive + : nullptr, + _activeState + ? &_st.maximizeIconActiveOver + : nullptr); } - _close->setIconOverride(_activeState ? &st::titleButtonCloseIconActive : nullptr, _activeState ? &st::titleButtonCloseIconActiveOver : nullptr); + _close->setIconOverride(_activeState + ? &_st.closeIconActive + : nullptr, + _activeState + ? &_st.closeIconActiveOver + : nullptr); } Window::HitTestResult TitleWidget::hitTest(const QPoint &p) const { diff --git a/Telegram/SourceFiles/platform/win/window_title_win.h b/Telegram/SourceFiles/platform/win/window_title_win.h index 19e0a1246..ce7af371e 100644 --- a/Telegram/SourceFiles/platform/win/window_title_win.h +++ b/Telegram/SourceFiles/platform/win/window_title_win.h @@ -10,6 +10,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "platform/platform_window_title.h" #include "base/object_ptr.h" +namespace style { +struct WindowTitle; +} // namespace style + namespace Ui { class IconButton; class PlainShadow; @@ -48,6 +52,7 @@ private: void updateButtonsState(); void updateControlsPosition(); + const style::WindowTitle &_st; object_ptr _minimize; object_ptr _maximizeRestore; object_ptr _close;