diff --git a/ui/integration.cpp b/ui/integration.cpp index b2bb3bf..ae49b3e 100644 --- a/ui/integration.cpp +++ b/ui/integration.cpp @@ -42,6 +42,10 @@ void Integration::startFontsBegin() { void Integration::startFontsEnd() { } +QString Integration::timeFormat() { + return u"hh:mm"_q; +} + std::shared_ptr Integration::createLinkHandler( const EntityLinkData &data, const std::any &context) { diff --git a/ui/integration.h b/ui/integration.h index 67fc358..0ae8343 100644 --- a/ui/integration.h +++ b/ui/integration.h @@ -44,6 +44,8 @@ public: virtual void startFontsBegin(); virtual void startFontsEnd(); + [[nodiscard]] virtual QString timeFormat(); + [[nodiscard]] virtual std::shared_ptr createLinkHandler( const EntityLinkData &data, const std::any &context); diff --git a/ui/layers/box_layer_widget.cpp b/ui/layers/box_layer_widget.cpp index 52d1097..92adb6d 100644 --- a/ui/layers/box_layer_widget.cpp +++ b/ui/layers/box_layer_widget.cpp @@ -225,8 +225,11 @@ void BoxLayerWidget::updateTitlePosition() { _titleLeft = st::boxTitlePosition.x(); _titleTop = st::boxTitlePosition.y(); if (_title) { - const auto buttonWidth = (_topButton ? _titleLeft : 0); - _title->resizeToWidth(qMin(_title->naturalWidth(), width() - _titleLeft * 2 - buttonWidth)); + const auto topButtonSkip = _topButton ? (_topButton->width() / 2) : 0; + _title->resizeToWidth( + std::min( + _title->naturalWidth(), + width() - _titleLeft * 2 - topButtonSkip)); _title->moveToLeft(_titleLeft, _titleTop); } } diff --git a/ui/platform/ui_platform_window.cpp b/ui/platform/ui_platform_window.cpp index b45cdf4..c1b88eb 100644 --- a/ui/platform/ui_platform_window.cpp +++ b/ui/platform/ui_platform_window.cpp @@ -16,6 +16,11 @@ namespace Platform { BasicWindowHelper::BasicWindowHelper(not_null window) : _window(window) { +#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) + _window->setWindowFlag(Qt::Window); +#else // Qt >= 5.9 + _window->setWindowFlags(_window->windowFlags() | Qt::Window); +#endif // Qt >= 5.9 } not_null BasicWindowHelper::body() { diff --git a/ui/platform/win/ui_window_win.cpp b/ui/platform/win/ui_window_win.cpp index 5e2652b..15fee67 100644 --- a/ui/platform/win/ui_window_win.cpp +++ b/ui/platform/win/ui_window_win.cpp @@ -10,6 +10,7 @@ #include "ui/platform/win/ui_window_title_win.h" #include "base/platform/base_platform_info.h" #include "base/platform/win/base_windows_safe_library.h" +#include "base/integration.h" #include "styles/palette.h" #include @@ -33,6 +34,56 @@ bool IsCompositionEnabled() { return success && result; } +HWND FindTaskbarWindow(LPRECT rcMon = nullptr) { + HWND hTaskbar = nullptr; + RECT rcTaskbar, rcMatch; + + while ((hTaskbar = FindWindowEx( + nullptr, + hTaskbar, + L"Shell_TrayWnd", + nullptr)) != nullptr) { + if (!rcMon) { + break; // OK, return first found + } + if (GetWindowRect(hTaskbar, &rcTaskbar) + && IntersectRect(&rcMatch, &rcTaskbar, rcMon)) { + break; // OK, taskbar match monitor + } + } + + return hTaskbar; +} + +bool IsTaskbarAutoHidden(LPRECT rcMon = nullptr, PUINT pEdge = nullptr) { + HWND hTaskbar = FindTaskbarWindow(rcMon); + if (!hTaskbar) { + if (pEdge) { + *pEdge = (UINT)-1; + } + return false; + } + + APPBARDATA state = {sizeof(state), hTaskbar}; + APPBARDATA pos = {sizeof(pos), hTaskbar}; + + LRESULT lState = SHAppBarMessage(ABM_GETSTATE, &state); + bool bAutoHidden = (lState & ABS_AUTOHIDE); + + if (SHAppBarMessage(ABM_GETTASKBARPOS, &pos)) { + if (pEdge) { + *pEdge = pos.uEdge; + } + } else { + base::Integration::Instance().logMessage("Failed to get taskbar pos"); + if (pEdge) { + *pEdge = ABE_BOTTOM; + } + } + + return bAutoHidden; +} + HRESULT WinApiSetWindowTheme( HWND hWnd, LPCWSTR pszSubAppName, @@ -236,6 +287,15 @@ bool WindowHelper::handleNativeEvent( mi.cbSize = sizeof(mi); if (GetMonitorInfo(hMonitor, &mi)) { *r = mi.rcWork; + UINT uEdge = (UINT)-1; + if (IsTaskbarAutoHidden(&mi.rcMonitor, &uEdge)) { + switch (uEdge) { + case ABE_LEFT: r->left += 1; break; + case ABE_RIGHT: r->right -= 1; break; + case ABE_TOP: r->top += 1; break; + case ABE_BOTTOM: r->bottom -= 1; break; + } + } } } } diff --git a/ui/text/text_entity.h b/ui/text/text_entity.h index 8003626..83f4384 100644 --- a/ui/text/text_entity.h +++ b/ui/text/text_entity.h @@ -7,6 +7,7 @@ #pragma once #include "base/basic_types.h" +#include "base/algorithm.h" #include #include diff --git a/ui/ui_pch.cpp b/ui/ui_pch.cpp deleted file mode 100644 index 4e95b75..0000000 --- a/ui/ui_pch.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// This file is part of Desktop App Toolkit, -// a set of libraries for developing nice desktop applications. -// -// For license and copyright information please follow this link: -// https://github.com/desktop-app/legal/blob/master/LEGAL -// -#include "ui/ui_pch.h" - -// Precompiled header helper.