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 {
|
} else {
|
||||||
// Emulate blur behind window by blurring the desktop wallpaper.
|
// Emulate blur behind window by blurring the desktop wallpaper.
|
||||||
updateBehindWindowBackground();
|
updateBehindWindowBackground();
|
||||||
QPoint point = m_window->mapToGlobal(QPoint{0, 0});
|
painter->drawPixmap(QPoint{0, 0}, m_bluredWallpaper, QRect{m_window->mapToGlobal(QPoint{0, 0}), rect.size()});
|
||||||
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->setCompositionMode(QPainter::CompositionMode_SourceOver);
|
painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
|
||||||
painter->setOpacity(1);
|
painter->setOpacity(1);
|
||||||
|
@ -310,7 +305,7 @@ void QtAcrylicEffectHelper::updateBehindWindowBackground()
|
||||||
if (!m_bluredWallpaper.isNull()) {
|
if (!m_bluredWallpaper.isNull()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const QSize size = Utilities::getScreenAvailableGeometry(m_window).size();
|
const QSize size = Utilities::getScreenGeometry(m_window).size();
|
||||||
m_bluredWallpaper = QPixmap(size);
|
m_bluredWallpaper = QPixmap(size);
|
||||||
m_bluredWallpaper.fill(Qt::transparent);
|
m_bluredWallpaper.fill(Qt::transparent);
|
||||||
QImage image = Utilities::getDesktopWallpaperImage();
|
QImage image = Utilities::getDesktopWallpaperImage();
|
||||||
|
@ -321,17 +316,18 @@ void QtAcrylicEffectHelper::updateBehindWindowBackground()
|
||||||
const Utilities::DesktopWallpaperAspectStyle aspectStyle = Utilities::getDesktopWallpaperAspectStyle();
|
const Utilities::DesktopWallpaperAspectStyle aspectStyle = Utilities::getDesktopWallpaperAspectStyle();
|
||||||
QImage buffer(size, QImage::Format_ARGB32_Premultiplied);
|
QImage buffer(size, QImage::Format_ARGB32_Premultiplied);
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
if (aspectStyle == Utilities::DesktopWallpaperAspectStyle::Central) {
|
if ((aspectStyle == Utilities::DesktopWallpaperAspectStyle::Central) ||
|
||||||
|
(aspectStyle == Utilities::DesktopWallpaperAspectStyle::KeepRatioFit)) {
|
||||||
buffer.fill(Utilities::getDesktopBackgroundColor());
|
buffer.fill(Utilities::getDesktopBackgroundColor());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (aspectStyle == Utilities::DesktopWallpaperAspectStyle::IgnoreRatioFill ||
|
if (aspectStyle == Utilities::DesktopWallpaperAspectStyle::IgnoreRatioFit ||
|
||||||
aspectStyle == Utilities::DesktopWallpaperAspectStyle::KeepRatioFill ||
|
aspectStyle == Utilities::DesktopWallpaperAspectStyle::KeepRatioFit ||
|
||||||
aspectStyle == Utilities::DesktopWallpaperAspectStyle::KeepRatioByExpanding) {
|
aspectStyle == Utilities::DesktopWallpaperAspectStyle::KeepRatioByExpanding) {
|
||||||
Qt::AspectRatioMode mode = Qt::KeepAspectRatioByExpanding;
|
Qt::AspectRatioMode mode;
|
||||||
if (aspectStyle == Utilities::DesktopWallpaperAspectStyle::IgnoreRatioFill) {
|
if (aspectStyle == Utilities::DesktopWallpaperAspectStyle::IgnoreRatioFit) {
|
||||||
mode = Qt::IgnoreAspectRatio;
|
mode = Qt::IgnoreAspectRatio;
|
||||||
} else if (aspectStyle == Utilities::DesktopWallpaperAspectStyle::KeepRatioFill) {
|
} else if (aspectStyle == Utilities::DesktopWallpaperAspectStyle::KeepRatioFit) {
|
||||||
mode = Qt::KeepAspectRatio;
|
mode = Qt::KeepAspectRatio;
|
||||||
} else {
|
} else {
|
||||||
mode = Qt::KeepAspectRatioByExpanding;
|
mode = Qt::KeepAspectRatioByExpanding;
|
||||||
|
|
|
@ -487,3 +487,25 @@ QRect Utilities::getScreenAvailableGeometry(const QPoint &pos)
|
||||||
}
|
}
|
||||||
return QGuiApplication::primaryScreen()->availableGeometry();
|
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,
|
Central,
|
||||||
Tiled,
|
Tiled,
|
||||||
IgnoreRatioFill, // Stretch
|
IgnoreRatioFit, // Stretch
|
||||||
KeepRatioFill, // Fit
|
KeepRatioFit, // Fit
|
||||||
KeepRatioByExpanding, // Fill
|
KeepRatioByExpanding, // Fill
|
||||||
Span // Span
|
Span // Span
|
||||||
};
|
};
|
||||||
|
@ -66,6 +66,9 @@ FRAMELESSHELPER_EXPORT DesktopWallpaperAspectStyle getDesktopWallpaperAspectStyl
|
||||||
FRAMELESSHELPER_EXPORT QRect getScreenAvailableGeometry(const QWindow *window);
|
FRAMELESSHELPER_EXPORT QRect getScreenAvailableGeometry(const QWindow *window);
|
||||||
FRAMELESSHELPER_EXPORT QRect getScreenAvailableGeometry(const QPoint &pos);
|
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 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);
|
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:
|
case DWPOS_TILE:
|
||||||
return DesktopWallpaperAspectStyle::Tiled;
|
return DesktopWallpaperAspectStyle::Tiled;
|
||||||
case DWPOS_STRETCH:
|
case DWPOS_STRETCH:
|
||||||
return DesktopWallpaperAspectStyle::IgnoreRatioFill;
|
return DesktopWallpaperAspectStyle::IgnoreRatioFit;
|
||||||
case DWPOS_FIT:
|
case DWPOS_FIT:
|
||||||
return DesktopWallpaperAspectStyle::KeepRatioFill;
|
return DesktopWallpaperAspectStyle::KeepRatioFit;
|
||||||
case DWPOS_FILL:
|
case DWPOS_FILL:
|
||||||
return DesktopWallpaperAspectStyle::KeepRatioByExpanding;
|
return DesktopWallpaperAspectStyle::KeepRatioByExpanding;
|
||||||
case DWPOS_SPAN:
|
case DWPOS_SPAN:
|
||||||
|
@ -663,9 +663,9 @@ Utilities::DesktopWallpaperAspectStyle Utilities::getDesktopWallpaperAspectStyle
|
||||||
case WPSTYLE_TILE:
|
case WPSTYLE_TILE:
|
||||||
return DesktopWallpaperAspectStyle::Tiled;
|
return DesktopWallpaperAspectStyle::Tiled;
|
||||||
case WPSTYLE_STRETCH:
|
case WPSTYLE_STRETCH:
|
||||||
return DesktopWallpaperAspectStyle::IgnoreRatioFill;
|
return DesktopWallpaperAspectStyle::IgnoreRatioFit;
|
||||||
case WPSTYLE_KEEPASPECT:
|
case WPSTYLE_KEEPASPECT:
|
||||||
return DesktopWallpaperAspectStyle::KeepRatioFill;
|
return DesktopWallpaperAspectStyle::KeepRatioFit;
|
||||||
case WPSTYLE_CROPTOFIT:
|
case WPSTYLE_CROPTOFIT:
|
||||||
return DesktopWallpaperAspectStyle::KeepRatioByExpanding;
|
return DesktopWallpaperAspectStyle::KeepRatioByExpanding;
|
||||||
case WPSTYLE_SPAN:
|
case WPSTYLE_SPAN:
|
||||||
|
@ -698,9 +698,9 @@ Utilities::DesktopWallpaperAspectStyle Utilities::getDesktopWallpaperAspectStyle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
return DesktopWallpaperAspectStyle::IgnoreRatioFill;
|
return DesktopWallpaperAspectStyle::IgnoreRatioFit;
|
||||||
case 6:
|
case 6:
|
||||||
return DesktopWallpaperAspectStyle::KeepRatioFill;
|
return DesktopWallpaperAspectStyle::KeepRatioFit;
|
||||||
case 10:
|
case 10:
|
||||||
return DesktopWallpaperAspectStyle::KeepRatioByExpanding;
|
return DesktopWallpaperAspectStyle::KeepRatioByExpanding;
|
||||||
case 22:
|
case 22:
|
||||||
|
|
Loading…
Reference in New Issue