2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Refactor icon unread counter painting.

This commit is contained in:
John Preston
2021-11-02 17:10:40 +04:00
parent 87af865604
commit aef45b3a1d
15 changed files with 300 additions and 258 deletions

View File

@@ -305,7 +305,7 @@ QIcon TrayIconGen(int counter, bool muted) {
}
}
} else {
currentImageBack = Core::App().logo();
currentImageBack = Window::Logo();
}
if (dprSize(currentImageBack) != desiredSize) {
@@ -324,20 +324,19 @@ QIcon TrayIconGen(int counter, bool muted) {
: st::trayCounterBg;
const auto &fg = st::trayCounterFg;
if (iconSize >= 22) {
auto layerSize = -16;
if (iconSize >= 48) {
layerSize = -32;
} else if (iconSize >= 36) {
layerSize = -24;
} else if (iconSize >= 32) {
layerSize = -20;
}
const auto layer = App::wnd()->iconWithCounter(
layerSize,
counter,
bg,
fg,
false);
const auto layerSize = (iconSize >= 48)
? 32
: (iconSize >= 36)
? 24
: (iconSize >= 32)
? 20
: 16;
const auto layer = Window::GenerateCounterLayer({
.size = layerSize,
.count = counter,
.bg = bg,
.fg = fg,
});
QPainter p(&iconImage);
p.drawImage(
@@ -345,13 +344,12 @@ QIcon TrayIconGen(int counter, bool muted) {
iconImage.height() - layer.height() - 1,
layer);
} else {
App::wnd()->placeSmallCounter(
iconImage,
16,
counter,
bg,
QPoint(),
fg);
iconImage = Window::WithSmallCounter(std::move(iconImage), {
.size = 16,
.count = counter,
.bg = bg,
.fg = fg,
});
}
}

View File

@@ -20,13 +20,6 @@ class MainWindow : public Window::MainWindow {
public:
explicit MainWindow(not_null<Window::Controller*> controller);
virtual QImage iconWithCounter(
int size,
int count,
style::color bg,
style::color fg,
bool smallIcon) = 0;
void psShowTrayMenu();
bool trayAvailable() {
@@ -54,14 +47,6 @@ protected:
void psTrayMenuUpdated();
void psSetupTrayIcon();
virtual void placeSmallCounter(
QImage &img,
int size,
int count,
style::color bg,
const QPoint &shift,
style::color color) = 0;
private:
class Private;
friend class Private;