/
erhoof
/
telegraf
Обзор
Документация
Войти
/
erhoof
/
telegraf
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
qml/js/layoutUtils.js
117 строк
2 KB
mbarashkov
Улучшили отображение видео...
18 сен 2025, 13:58
18 сен 2025, 13:58
e347b53
Код
Авторство
О чём код?
.pragma library .import Sailfish.Silica 1.0 as Silica function isWidescreen(appWindow) { return isLandscape(appWindow) || isTablet(); } function isPhone() { return Silica.Screen.sizeCategory === Silica.Screen.Small || Silica.Screen.sizeCategory === Silica.Screen.Medium; } function isTablet() { return !isPhone(); } function isLandscape(appWindow) { return appWindow.deviceOrientation & Silica.Orientation.LandscapeMask; } function getBaseContentItemWidth(parentWidth, appWindow) { if(isPhone()) { if(isLandscape(appWindow)) { return parentWidth * 0.5; } else { return parentWidth * 0.9; } } else { if(!isLandscape(appWindow)) { return parentWidth * 0.9; } else { return parentWidth * 0.7; } } } function getAlbumMediaAttachmentWidth(baseWidth, appWindow) { if(isPhone()) { if(isLandscape(appWindow)) { return baseWidth * 0.7; } else { return baseWidth; } } else { if(isLandscape(appWindow)) { return baseWidth * 0.7; } else { return baseWidth * 0.9; } } } function getMediaAttachmentWidth(contentWidth, parentWidth, appWindow) { var res = parentWidth; if(isPhone()) { if(isLandscape(appWindow)) { res = parentWidth * 0.5; } } else { if(!isLandscape(appWindow)) { res = parentWidth * 0.7; } else { res = parentWidth * 0.4; } } return Math.min(res, contentWidth); } function getMediaAttachmentHeight(width, aspectRatio, parentContainerHeight, appWindow) { var result = width / aspectRatio; if(result > parentContainerHeight * 0.5) { result = parentContainerHeight * 0.5; } return result; } /*function getVideoAttachmentHeight(width, aspectRatio, parentWidth, parentContainerHeight, appWindow) { var aspectHeight = width / aspectRatio; if(aspectHeight > parentContainerHeight * 0.5) { aspectHeight = parentContainerHeight * 0.5; } return aspectHeight; }*/