mirror of https://github.com/procxx/kepka.git
Returned render color theme in main menu when background is filled.
This commit is contained in:
parent
9871184953
commit
b45705f39d
|
@ -49,6 +49,20 @@ inline bool AreTestingTheme() {
|
||||||
return !GlobalApplying.paletteForRevert.isEmpty();
|
return !GlobalApplying.paletteForRevert.isEmpty();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool CalculateIsMonoColorImage(const QImage &image) {
|
||||||
|
if (!image.isNull()) {
|
||||||
|
const auto bits = reinterpret_cast<const uint32*>(image.constBits());
|
||||||
|
const auto first = bits[0];
|
||||||
|
for (auto i = 0; i < image.width() * image.height(); i++) {
|
||||||
|
if (first != bits[i]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray readThemeContent(const QString &path) {
|
QByteArray readThemeContent(const QString &path) {
|
||||||
QFile file(path);
|
QFile file(path);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
|
@ -580,6 +594,7 @@ void ChatBackground::preparePixmaps(QImage image) {
|
||||||
}
|
}
|
||||||
_pixmapForTiled = App::pixmapFromImageInPlace(std::move(imageForTiled));
|
_pixmapForTiled = App::pixmapFromImageInPlace(std::move(imageForTiled));
|
||||||
}
|
}
|
||||||
|
_isMonoColorImage = CalculateIsMonoColorImage(image);
|
||||||
_pixmap = App::pixmapFromImageInPlace(std::move(image));
|
_pixmap = App::pixmapFromImageInPlace(std::move(image));
|
||||||
if (!isSmallForTiled) {
|
if (!isSmallForTiled) {
|
||||||
_pixmapForTiled = _pixmap;
|
_pixmapForTiled = _pixmap;
|
||||||
|
@ -671,6 +686,10 @@ bool ChatBackground::tileNight() const {
|
||||||
return _tileNightValue;
|
return _tileNightValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ChatBackground::isMonoColorImage() const {
|
||||||
|
return _isMonoColorImage;
|
||||||
|
}
|
||||||
|
|
||||||
void ChatBackground::ensureStarted() {
|
void ChatBackground::ensureStarted() {
|
||||||
if (_pixmap.isNull() && !_paper.backgroundColor()) {
|
if (_pixmap.isNull() && !_paper.backgroundColor()) {
|
||||||
// We should start first, otherwise the default call
|
// We should start first, otherwise the default call
|
||||||
|
|
|
@ -126,6 +126,7 @@ public:
|
||||||
[[nodiscard]] bool tile() const;
|
[[nodiscard]] bool tile() const;
|
||||||
[[nodiscard]] bool tileDay() const;
|
[[nodiscard]] bool tileDay() const;
|
||||||
[[nodiscard]] bool tileNight() const;
|
[[nodiscard]] bool tileNight() const;
|
||||||
|
[[nodiscard]] bool isMonoColorImage() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct AdjustableColor {
|
struct AdjustableColor {
|
||||||
|
@ -174,6 +175,8 @@ private:
|
||||||
bool _tileDayValue = false;
|
bool _tileDayValue = false;
|
||||||
bool _tileNightValue = true;
|
bool _tileNightValue = true;
|
||||||
|
|
||||||
|
bool _isMonoColorImage = false;
|
||||||
|
|
||||||
QString _themeAbsolutePath;
|
QString _themeAbsolutePath;
|
||||||
QImage _themeImage;
|
QImage _themeImage;
|
||||||
bool _themeTile = false;
|
bool _themeTile = false;
|
||||||
|
|
|
@ -331,7 +331,14 @@ void MainMenu::paintEvent(QPaintEvent *e) {
|
||||||
const auto cover = QRect(0, 0, width(), st::mainMenuCoverHeight)
|
const auto cover = QRect(0, 0, width(), st::mainMenuCoverHeight)
|
||||||
.intersected(e->rect());
|
.intersected(e->rect());
|
||||||
|
|
||||||
if (!_background.isNull()) {
|
const auto background = Window::Theme::Background();
|
||||||
|
const auto isFill = background->tile()
|
||||||
|
|| background->colorForFill().has_value()
|
||||||
|
|| background->isMonoColorImage()
|
||||||
|
|| background->paper().isPattern()
|
||||||
|
|| Data::IsLegacy1DefaultWallPaper(background->paper());
|
||||||
|
|
||||||
|
if (!isFill && !_background.isNull()) {
|
||||||
PainterHighQualityEnabler hq(p);
|
PainterHighQualityEnabler hq(p);
|
||||||
p.drawImage(0, 0, _background);
|
p.drawImage(0, 0, _background);
|
||||||
}
|
}
|
||||||
|
@ -340,6 +347,10 @@ void MainMenu::paintEvent(QPaintEvent *e) {
|
||||||
const auto widthText = _cloudButton
|
const auto widthText = _cloudButton
|
||||||
? _cloudButton->x() - st::mainMenuCloudSize
|
? _cloudButton->x() - st::mainMenuCloudSize
|
||||||
: width() - 2 * st::mainMenuCoverTextLeft;
|
: width() - 2 * st::mainMenuCoverTextLeft;
|
||||||
|
|
||||||
|
if (isFill) {
|
||||||
|
p.fillRect(cover, st::mainMenuCoverBg);
|
||||||
|
}
|
||||||
p.setPen(st::mainMenuCoverFg);
|
p.setPen(st::mainMenuCoverFg);
|
||||||
p.setFont(st::semiboldFont);
|
p.setFont(st::semiboldFont);
|
||||||
Auth().user()->nameText.drawLeftElided(
|
Auth().user()->nameText.drawLeftElided(
|
||||||
|
@ -357,8 +368,8 @@ void MainMenu::paintEvent(QPaintEvent *e) {
|
||||||
_cloudButton->y() + (_cloudButton->height() - st::mainMenuCloudSize) / 2,
|
_cloudButton->y() + (_cloudButton->height() - st::mainMenuCloudSize) / 2,
|
||||||
width(),
|
width(),
|
||||||
st::mainMenuCloudSize,
|
st::mainMenuCloudSize,
|
||||||
st::msgServiceBg,
|
isFill ? st::mainMenuCloudBg : st::msgServiceBg,
|
||||||
st::mainMenuCloudFg);
|
isFill ? st::mainMenuCloudFg : st::msgServiceFg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto other = QRect(0, st::mainMenuCoverHeight, width(), height() - st::mainMenuCoverHeight).intersected(clip);
|
auto other = QRect(0, st::mainMenuCoverHeight, width(), height() - st::mainMenuCoverHeight).intersected(clip);
|
||||||
|
|
Loading…
Reference in New Issue