forked from github_mirror/framelesshelper
Minor tweaks
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
85edd9abbd
commit
43d0e5f95d
|
@ -227,12 +227,7 @@ void QtAcrylicEffectHelper::paintBackground(QPainter *painter, const QRect &rect
|
|||
} else {
|
||||
// Emulate blur behind window by blurring the desktop wallpaper.
|
||||
updateBehindWindowBackground();
|
||||
QPoint point = m_window->mapToGlobal(QPoint{0, 0});
|
||||
const QRect geometry = Utilities::getScreenAvailableGeometry(m_window);
|
||||
if (geometry.isValid()) {
|
||||
point -= geometry.topLeft();
|
||||
}
|
||||
painter->drawPixmap(QPoint{0, 0}, m_bluredWallpaper, QRect{point, rect.size()});
|
||||
painter->drawPixmap(QPoint{0, 0}, m_bluredWallpaper, QRect{m_window->mapToGlobal(QPoint{0, 0}), rect.size()});
|
||||
}
|
||||
painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
|
||||
painter->setOpacity(1);
|
||||
|
@ -310,7 +305,7 @@ void QtAcrylicEffectHelper::updateBehindWindowBackground()
|
|||
if (!m_bluredWallpaper.isNull()) {
|
||||
return;
|
||||
}
|
||||
const QSize size = Utilities::getScreenAvailableGeometry(m_window).size();
|
||||
const QSize size = Utilities::getScreenGeometry(m_window).size();
|
||||
m_bluredWallpaper = QPixmap(size);
|
||||
m_bluredWallpaper.fill(Qt::transparent);
|
||||
QImage image = Utilities::getDesktopWallpaperImage();
|
||||
|
@ -321,17 +316,18 @@ void QtAcrylicEffectHelper::updateBehindWindowBackground()
|
|||
const Utilities::DesktopWallpaperAspectStyle aspectStyle = Utilities::getDesktopWallpaperAspectStyle();
|
||||
QImage buffer(size, QImage::Format_ARGB32_Premultiplied);
|
||||
#ifdef Q_OS_WINDOWS
|
||||
if (aspectStyle == Utilities::DesktopWallpaperAspectStyle::Central) {
|
||||
if ((aspectStyle == Utilities::DesktopWallpaperAspectStyle::Central) ||
|
||||
(aspectStyle == Utilities::DesktopWallpaperAspectStyle::KeepRatioFit)) {
|
||||
buffer.fill(Utilities::getDesktopBackgroundColor());
|
||||
}
|
||||
#endif
|
||||
if (aspectStyle == Utilities::DesktopWallpaperAspectStyle::IgnoreRatioFill ||
|
||||
aspectStyle == Utilities::DesktopWallpaperAspectStyle::KeepRatioFill ||
|
||||
if (aspectStyle == Utilities::DesktopWallpaperAspectStyle::IgnoreRatioFit ||
|
||||
aspectStyle == Utilities::DesktopWallpaperAspectStyle::KeepRatioFit ||
|
||||
aspectStyle == Utilities::DesktopWallpaperAspectStyle::KeepRatioByExpanding) {
|
||||
Qt::AspectRatioMode mode = Qt::KeepAspectRatioByExpanding;
|
||||
if (aspectStyle == Utilities::DesktopWallpaperAspectStyle::IgnoreRatioFill) {
|
||||
Qt::AspectRatioMode mode;
|
||||
if (aspectStyle == Utilities::DesktopWallpaperAspectStyle::IgnoreRatioFit) {
|
||||
mode = Qt::IgnoreAspectRatio;
|
||||
} else if (aspectStyle == Utilities::DesktopWallpaperAspectStyle::KeepRatioFill) {
|
||||
} else if (aspectStyle == Utilities::DesktopWallpaperAspectStyle::KeepRatioFit) {
|
||||
mode = Qt::KeepAspectRatio;
|
||||
} else {
|
||||
mode = Qt::KeepAspectRatioByExpanding;
|
||||
|
|
|
@ -487,3 +487,25 @@ QRect Utilities::getScreenAvailableGeometry(const QPoint &pos)
|
|||
}
|
||||
return QGuiApplication::primaryScreen()->availableGeometry();
|
||||
}
|
||||
|
||||
QRect Utilities::getScreenGeometry(const QWindow *window)
|
||||
{
|
||||
if (window) {
|
||||
const QScreen *screen = window->screen();
|
||||
if (screen) {
|
||||
return screen->geometry();
|
||||
}
|
||||
}
|
||||
return QGuiApplication::primaryScreen()->geometry();
|
||||
}
|
||||
|
||||
QRect Utilities::getScreenGeometry(const QPoint &pos)
|
||||
{
|
||||
if (!pos.isNull()) {
|
||||
const QScreen *screen = QGuiApplication::screenAt(pos);
|
||||
if (screen) {
|
||||
return screen->geometry();
|
||||
}
|
||||
}
|
||||
return QGuiApplication::primaryScreen()->geometry();
|
||||
}
|
||||
|
|
|
@ -41,8 +41,8 @@ enum class DesktopWallpaperAspectStyle
|
|||
{
|
||||
Central,
|
||||
Tiled,
|
||||
IgnoreRatioFill, // Stretch
|
||||
KeepRatioFill, // Fit
|
||||
IgnoreRatioFit, // Stretch
|
||||
KeepRatioFit, // Fit
|
||||
KeepRatioByExpanding, // Fill
|
||||
Span // Span
|
||||
};
|
||||
|
@ -66,6 +66,9 @@ FRAMELESSHELPER_EXPORT DesktopWallpaperAspectStyle getDesktopWallpaperAspectStyl
|
|||
FRAMELESSHELPER_EXPORT QRect getScreenAvailableGeometry(const QWindow *window);
|
||||
FRAMELESSHELPER_EXPORT QRect getScreenAvailableGeometry(const QPoint &pos);
|
||||
|
||||
FRAMELESSHELPER_EXPORT QRect getScreenGeometry(const QWindow *window);
|
||||
FRAMELESSHELPER_EXPORT QRect getScreenGeometry(const QPoint &pos);
|
||||
|
||||
FRAMELESSHELPER_EXPORT QRect alignedRect(const Qt::LayoutDirection direction, const Qt::Alignment alignment, const QSize &size, const QRect &rectangle);
|
||||
|
||||
FRAMELESSHELPER_EXPORT void blurImage(QImage &blurImage, const qreal radius, const bool quality, const int transposed = 0);
|
||||
|
|
|
@ -623,9 +623,9 @@ Utilities::DesktopWallpaperAspectStyle Utilities::getDesktopWallpaperAspectStyle
|
|||
case DWPOS_TILE:
|
||||
return DesktopWallpaperAspectStyle::Tiled;
|
||||
case DWPOS_STRETCH:
|
||||
return DesktopWallpaperAspectStyle::IgnoreRatioFill;
|
||||
return DesktopWallpaperAspectStyle::IgnoreRatioFit;
|
||||
case DWPOS_FIT:
|
||||
return DesktopWallpaperAspectStyle::KeepRatioFill;
|
||||
return DesktopWallpaperAspectStyle::KeepRatioFit;
|
||||
case DWPOS_FILL:
|
||||
return DesktopWallpaperAspectStyle::KeepRatioByExpanding;
|
||||
case DWPOS_SPAN:
|
||||
|
@ -663,9 +663,9 @@ Utilities::DesktopWallpaperAspectStyle Utilities::getDesktopWallpaperAspectStyle
|
|||
case WPSTYLE_TILE:
|
||||
return DesktopWallpaperAspectStyle::Tiled;
|
||||
case WPSTYLE_STRETCH:
|
||||
return DesktopWallpaperAspectStyle::IgnoreRatioFill;
|
||||
return DesktopWallpaperAspectStyle::IgnoreRatioFit;
|
||||
case WPSTYLE_KEEPASPECT:
|
||||
return DesktopWallpaperAspectStyle::KeepRatioFill;
|
||||
return DesktopWallpaperAspectStyle::KeepRatioFit;
|
||||
case WPSTYLE_CROPTOFIT:
|
||||
return DesktopWallpaperAspectStyle::KeepRatioByExpanding;
|
||||
case WPSTYLE_SPAN:
|
||||
|
@ -698,9 +698,9 @@ Utilities::DesktopWallpaperAspectStyle Utilities::getDesktopWallpaperAspectStyle
|
|||
}
|
||||
}
|
||||
case 2:
|
||||
return DesktopWallpaperAspectStyle::IgnoreRatioFill;
|
||||
return DesktopWallpaperAspectStyle::IgnoreRatioFit;
|
||||
case 6:
|
||||
return DesktopWallpaperAspectStyle::KeepRatioFill;
|
||||
return DesktopWallpaperAspectStyle::KeepRatioFit;
|
||||
case 10:
|
||||
return DesktopWallpaperAspectStyle::KeepRatioByExpanding;
|
||||
case 22:
|
||||
|
|
Loading…
Reference in New Issue