mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improve pattern wallpaper preview in Settings.
This commit is contained in:
parent
1e8e163bb1
commit
aaf0015be4
1 changed files with 14 additions and 11 deletions
|
@ -57,6 +57,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "facades.h"
|
#include "facades.h"
|
||||||
#include "styles/style_settings.h"
|
#include "styles/style_settings.h"
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
|
#include "styles/style_window.h"
|
||||||
|
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -581,26 +582,28 @@ void BackgroundRow::updateImage() {
|
||||||
}
|
}
|
||||||
const auto &prepared = background->prepared();
|
const auto &prepared = background->prepared();
|
||||||
if (!prepared.isNull()) {
|
if (!prepared.isNull()) {
|
||||||
const auto sx = (prepared.width() > prepared.height())
|
const auto pattern = background->paper().isPattern();
|
||||||
? ((prepared.width() - prepared.height()) / 2)
|
const auto w = prepared.width();
|
||||||
: 0;
|
const auto h = prepared.height();
|
||||||
const auto sy = (prepared.height() > prepared.width())
|
const auto use = [&] {
|
||||||
? ((prepared.height() - prepared.width()) / 2)
|
if (!pattern) {
|
||||||
: 0;
|
return std::min(w, h);
|
||||||
const auto s = (prepared.width() > prepared.height())
|
}
|
||||||
? prepared.height()
|
const auto scaledw = w * st::windowMinHeight / h;
|
||||||
: prepared.width();
|
const auto result = (w * size) / scaledw;
|
||||||
|
return std::min({ result, w, h });
|
||||||
|
}();
|
||||||
p.drawImage(
|
p.drawImage(
|
||||||
QRect(0, 0, size, size),
|
QRect(0, 0, size, size),
|
||||||
prepared,
|
prepared,
|
||||||
QRect(sx, sy, s, s));
|
QRect((w - use) / 2, (h - use) / 2, use, use));
|
||||||
}
|
}
|
||||||
if (!gradient.isNull()
|
if (!gradient.isNull()
|
||||||
&& !prepared.isNull()
|
&& !prepared.isNull()
|
||||||
&& patternOpacity < 0.
|
&& patternOpacity < 0.
|
||||||
&& patternOpacity > -1.) {
|
&& patternOpacity > -1.) {
|
||||||
p.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
p.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
||||||
p.setOpacity(patternOpacity);
|
p.setOpacity(1. + patternOpacity);
|
||||||
p.fillRect(QRect(0, 0, size, size), Qt::black);
|
p.fillRect(QRect(0, 0, size, size), Qt::black);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue