Updated lib_ui sources to TDesktop version 2.4.3

This commit is contained in:
Eric Kotato 2020-10-19 18:31:57 +03:00
commit 1c102f2e6a
7 changed files with 77 additions and 11 deletions

View file

@ -42,6 +42,10 @@ void Integration::startFontsBegin() {
void Integration::startFontsEnd() {
}
QString Integration::timeFormat() {
return u"hh:mm"_q;
}
std::shared_ptr<ClickHandler> Integration::createLinkHandler(
const EntityLinkData &data,
const std::any &context) {

View file

@ -44,6 +44,8 @@ public:
virtual void startFontsBegin();
virtual void startFontsEnd();
[[nodiscard]] virtual QString timeFormat();
[[nodiscard]] virtual std::shared_ptr<ClickHandler> createLinkHandler(
const EntityLinkData &data,
const std::any &context);

View file

@ -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);
}
}

View file

@ -16,6 +16,11 @@ namespace Platform {
BasicWindowHelper::BasicWindowHelper(not_null<RpWidget*> 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<RpWidget*> BasicWindowHelper::body() {

View file

@ -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 <QtCore/QAbstractNativeEventFilter>
@ -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;
}
}
}
}
}

View file

@ -7,6 +7,7 @@
#pragma once
#include "base/basic_types.h"
#include "base/algorithm.h"
#include <QtCore/QList>
#include <QtCore/QVector>

View file

@ -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.