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)
|
||||
: Platform::MainWindow(controller) {
|
||||
QString iconFilename(cWorkingDir() + "tdata/icon.png");
|
||||
auto iconImage = App::readImage(iconFilename, nullptr, false);
|
||||
QImage iconImage(cWorkingDir() + "tdata/icon.png");
|
||||
|
||||
if (iconImage.isNull()) {
|
||||
auto logo = Core::App().logo();
|
||||
icon16 = logo.scaledToWidth(16, Qt::SmoothTransformation);
|
||||
icon32 = logo.scaledToWidth(32, Qt::SmoothTransformation);
|
||||
icon64 = logo.scaledToWidth(64, Qt::SmoothTransformation);
|
||||
auto logo = iconImage.isNull()
|
||||
? Core::App().logo()
|
||||
: iconImage;
|
||||
|
||||
auto logoNoMargin = Core::App().logoNoMargin();
|
||||
iconbig16 = logoNoMargin.scaledToWidth(16, Qt::SmoothTransformation);
|
||||
iconbig32 = logoNoMargin.scaledToWidth(32, 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);
|
||||
icon16 = logo.scaledToWidth(16, Qt::SmoothTransformation);
|
||||
icon32 = logo.scaledToWidth(32, Qt::SmoothTransformation);
|
||||
icon64 = logo.scaledToWidth(64, Qt::SmoothTransformation);
|
||||
|
||||
iconbig16 = iconImage.scaledToWidth(16, Qt::SmoothTransformation);
|
||||
iconbig32 = iconImage.scaledToWidth(32, Qt::SmoothTransformation);
|
||||
iconbig64 = iconImage.scaledToWidth(64, Qt::SmoothTransformation);
|
||||
}
|
||||
auto logoNoMargin = iconImage.isNull()
|
||||
? Core::App().logoNoMargin()
|
||||
: iconImage;
|
||||
|
||||
iconbig16 = logoNoMargin.scaledToWidth(16, Qt::SmoothTransformation);
|
||||
iconbig32 = logoNoMargin.scaledToWidth(32, Qt::SmoothTransformation);
|
||||
iconbig64 = logoNoMargin.scaledToWidth(64, Qt::SmoothTransformation);
|
||||
|
||||
resize(st::windowDefaultWidth, st::windowDefaultHeight);
|
||||
|
||||
|
|
|
|||
|
|
@ -180,8 +180,7 @@ QIcon TrayIconGen(int counter, bool muted) {
|
|||
.toImage();
|
||||
}
|
||||
} else {
|
||||
QString iconFilename(cWorkingDir() + "tdata/icon.png");
|
||||
currentImageBack = App::readImage(iconFilename, nullptr, false);
|
||||
currentImageBack = QImage(cWorkingDir() + "tdata/icon.png");
|
||||
if (currentImageBack.isNull()) {
|
||||
currentImageBack = Core::App().logo();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -564,25 +564,21 @@ void MainWindow::psSetupTrayIcon() {
|
|||
if (!trayIcon) {
|
||||
trayIcon = new QSystemTrayIcon(this);
|
||||
QIcon icon;
|
||||
QString iconFilename(cWorkingDir() + "tdata/icon.png");
|
||||
QString iconFilenameSelected(cWorkingDir() + "tdata/icon_selected.png");
|
||||
QPixmap iconPixmap(cWorkingDir() + "tdata/icon.png");
|
||||
QPixmap iconPixmapSelected(cWorkingDir() + "tdata/icon_selected.png");
|
||||
|
||||
auto iconImage = App::readImage(iconFilename, nullptr, false);
|
||||
|
||||
if (iconImage.isNull()) {
|
||||
iconImage = psTrayIcon();
|
||||
if (!iconPixmap.isNull()) {
|
||||
icon.addPixmap(iconPixmap);
|
||||
} else {
|
||||
icon.addPixmap(QPixmap::fromImage(psTrayIcon(), Qt::ColorOnly));
|
||||
}
|
||||
|
||||
icon = QIcon(QPixmap::fromImage(iconImage, Qt::ColorOnly));
|
||||
|
||||
auto iconImageSelected = App::readImage(iconFilenameSelected, nullptr, false);
|
||||
|
||||
if (iconImageSelected.isNull()) {
|
||||
iconImageSelected = psTrayIcon(true);
|
||||
if (!iconPixmapSelected.isNull()) {
|
||||
icon.addPixmap(iconPixmapSelected, QIcon::Selected);
|
||||
} else {
|
||||
icon.addPixmap(QPixmap::fromImage(psTrayIcon(true), Qt::ColorOnly), QIcon::Selected);
|
||||
}
|
||||
|
||||
icon.addPixmap(QPixmap::fromImage(iconImageSelected, Qt::ColorOnly), QIcon::Selected);
|
||||
|
||||
trayIcon->setIcon(icon);
|
||||
attachToTrayIcon(trayIcon);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -684,15 +684,11 @@ void MainWindow::psTrayMenuUpdated() {
|
|||
void MainWindow::psSetupTrayIcon() {
|
||||
if (!trayIcon) {
|
||||
trayIcon = new QSystemTrayIcon(this);
|
||||
QString iconFilename(cWorkingDir() + "tdata/icon.png");
|
||||
auto iconImage = App::readImage(iconFilename, nullptr, false);
|
||||
|
||||
if (iconImage.isNull()) {
|
||||
iconImage = Core::App().logoNoMargin();
|
||||
auto icon = QIcon(cWorkingDir() + "tdata/icon.png");
|
||||
if (icon.isNull()) {
|
||||
icon = QIcon(App::pixmapFromImageInPlace(Core::App().logoNoMargin()));
|
||||
}
|
||||
|
||||
auto icon = QIcon(App::pixmapFromImageInPlace(std::move(iconImage)));
|
||||
|
||||
trayIcon->setIcon(icon);
|
||||
connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(showFromTray()));
|
||||
attachToTrayIcon(trayIcon);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue