Avoid converting with custom icon (#12)
This commit is contained in:
parent
e0f0787861
commit
06e5dd6145
4 changed files with 28 additions and 42 deletions
|
|
@ -78,28 +78,23 @@ void FeedLangTestingKey(int key) {
|
||||||
|
|
||||||
MainWindow::MainWindow(not_null<Window::Controller*> controller)
|
MainWindow::MainWindow(not_null<Window::Controller*> controller)
|
||||||
: Platform::MainWindow(controller) {
|
: Platform::MainWindow(controller) {
|
||||||
QString iconFilename(cWorkingDir() + "tdata/icon.png");
|
QImage iconImage(cWorkingDir() + "tdata/icon.png");
|
||||||
auto iconImage = App::readImage(iconFilename, nullptr, false);
|
|
||||||
|
|
||||||
if (iconImage.isNull()) {
|
auto logo = iconImage.isNull()
|
||||||
auto logo = Core::App().logo();
|
? Core::App().logo()
|
||||||
icon16 = logo.scaledToWidth(16, Qt::SmoothTransformation);
|
: iconImage;
|
||||||
icon32 = logo.scaledToWidth(32, Qt::SmoothTransformation);
|
|
||||||
icon64 = logo.scaledToWidth(64, Qt::SmoothTransformation);
|
|
||||||
|
|
||||||
auto logoNoMargin = Core::App().logoNoMargin();
|
icon16 = logo.scaledToWidth(16, Qt::SmoothTransformation);
|
||||||
iconbig16 = logoNoMargin.scaledToWidth(16, Qt::SmoothTransformation);
|
icon32 = logo.scaledToWidth(32, Qt::SmoothTransformation);
|
||||||
iconbig32 = logoNoMargin.scaledToWidth(32, Qt::SmoothTransformation);
|
icon64 = logo.scaledToWidth(64, Qt::SmoothTransformation);
|
||||||
iconbig64 = logoNoMargin.scaledToWidth(64, Qt::SmoothTransformation);
|
|
||||||
} else {
|
|
||||||
icon16 = iconImage.scaledToWidth(16, Qt::SmoothTransformation);
|
|
||||||
icon32 = iconImage.scaledToWidth(32, Qt::SmoothTransformation);
|
|
||||||
icon64 = iconImage.scaledToWidth(64, Qt::SmoothTransformation);
|
|
||||||
|
|
||||||
iconbig16 = iconImage.scaledToWidth(16, Qt::SmoothTransformation);
|
auto logoNoMargin = iconImage.isNull()
|
||||||
iconbig32 = iconImage.scaledToWidth(32, Qt::SmoothTransformation);
|
? Core::App().logoNoMargin()
|
||||||
iconbig64 = iconImage.scaledToWidth(64, Qt::SmoothTransformation);
|
: iconImage;
|
||||||
}
|
|
||||||
|
iconbig16 = logoNoMargin.scaledToWidth(16, Qt::SmoothTransformation);
|
||||||
|
iconbig32 = logoNoMargin.scaledToWidth(32, Qt::SmoothTransformation);
|
||||||
|
iconbig64 = logoNoMargin.scaledToWidth(64, Qt::SmoothTransformation);
|
||||||
|
|
||||||
resize(st::windowDefaultWidth, st::windowDefaultHeight);
|
resize(st::windowDefaultWidth, st::windowDefaultHeight);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -180,8 +180,7 @@ QIcon TrayIconGen(int counter, bool muted) {
|
||||||
.toImage();
|
.toImage();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QString iconFilename(cWorkingDir() + "tdata/icon.png");
|
currentImageBack = QImage(cWorkingDir() + "tdata/icon.png");
|
||||||
currentImageBack = App::readImage(iconFilename, nullptr, false);
|
|
||||||
if (currentImageBack.isNull()) {
|
if (currentImageBack.isNull()) {
|
||||||
currentImageBack = Core::App().logo();
|
currentImageBack = Core::App().logo();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -564,25 +564,21 @@ void MainWindow::psSetupTrayIcon() {
|
||||||
if (!trayIcon) {
|
if (!trayIcon) {
|
||||||
trayIcon = new QSystemTrayIcon(this);
|
trayIcon = new QSystemTrayIcon(this);
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
QString iconFilename(cWorkingDir() + "tdata/icon.png");
|
QPixmap iconPixmap(cWorkingDir() + "tdata/icon.png");
|
||||||
QString iconFilenameSelected(cWorkingDir() + "tdata/icon_selected.png");
|
QPixmap iconPixmapSelected(cWorkingDir() + "tdata/icon_selected.png");
|
||||||
|
|
||||||
auto iconImage = App::readImage(iconFilename, nullptr, false);
|
if (!iconPixmap.isNull()) {
|
||||||
|
icon.addPixmap(iconPixmap);
|
||||||
if (iconImage.isNull()) {
|
} else {
|
||||||
iconImage = psTrayIcon();
|
icon.addPixmap(QPixmap::fromImage(psTrayIcon(), Qt::ColorOnly));
|
||||||
}
|
}
|
||||||
|
|
||||||
icon = QIcon(QPixmap::fromImage(iconImage, Qt::ColorOnly));
|
if (!iconPixmapSelected.isNull()) {
|
||||||
|
icon.addPixmap(iconPixmapSelected, QIcon::Selected);
|
||||||
auto iconImageSelected = App::readImage(iconFilenameSelected, nullptr, false);
|
} else {
|
||||||
|
icon.addPixmap(QPixmap::fromImage(psTrayIcon(true), Qt::ColorOnly), QIcon::Selected);
|
||||||
if (iconImageSelected.isNull()) {
|
|
||||||
iconImageSelected = psTrayIcon(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
icon.addPixmap(QPixmap::fromImage(iconImageSelected, Qt::ColorOnly), QIcon::Selected);
|
|
||||||
|
|
||||||
trayIcon->setIcon(icon);
|
trayIcon->setIcon(icon);
|
||||||
attachToTrayIcon(trayIcon);
|
attachToTrayIcon(trayIcon);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -684,15 +684,11 @@ void MainWindow::psTrayMenuUpdated() {
|
||||||
void MainWindow::psSetupTrayIcon() {
|
void MainWindow::psSetupTrayIcon() {
|
||||||
if (!trayIcon) {
|
if (!trayIcon) {
|
||||||
trayIcon = new QSystemTrayIcon(this);
|
trayIcon = new QSystemTrayIcon(this);
|
||||||
QString iconFilename(cWorkingDir() + "tdata/icon.png");
|
auto icon = QIcon(cWorkingDir() + "tdata/icon.png");
|
||||||
auto iconImage = App::readImage(iconFilename, nullptr, false);
|
if (icon.isNull()) {
|
||||||
|
icon = QIcon(App::pixmapFromImageInPlace(Core::App().logoNoMargin()));
|
||||||
if (iconImage.isNull()) {
|
|
||||||
iconImage = Core::App().logoNoMargin();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto icon = QIcon(App::pixmapFromImageInPlace(std::move(iconImage)));
|
|
||||||
|
|
||||||
trayIcon->setIcon(icon);
|
trayIcon->setIcon(icon);
|
||||||
connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(showFromTray()));
|
connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(showFromTray()));
|
||||||
attachToTrayIcon(trayIcon);
|
attachToTrayIcon(trayIcon);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue