Custom tray and taskbar icon
This commit is contained in:
parent
64266cd7f5
commit
1cf2a336b7
4 changed files with 51 additions and 12 deletions
|
|
@ -78,6 +78,10 @@ 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);
|
||||
|
||||
if (iconImage.isNull()) {
|
||||
auto logo = Core::App().logo();
|
||||
icon16 = logo.scaledToWidth(16, Qt::SmoothTransformation);
|
||||
icon32 = logo.scaledToWidth(32, Qt::SmoothTransformation);
|
||||
|
|
@ -87,6 +91,15 @@ MainWindow::MainWindow(not_null<Window::Controller*> controller)
|
|||
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);
|
||||
|
||||
iconbig16 = iconImage.scaledToWidth(16, Qt::SmoothTransformation);
|
||||
iconbig32 = iconImage.scaledToWidth(32, Qt::SmoothTransformation);
|
||||
iconbig64 = iconImage.scaledToWidth(64, Qt::SmoothTransformation);
|
||||
}
|
||||
|
||||
resize(st::windowDefaultWidth, st::windowDefaultHeight);
|
||||
|
||||
|
|
|
|||
|
|
@ -143,8 +143,12 @@ QIcon TrayIconGen() {
|
|||
.toImage();
|
||||
}
|
||||
} else {
|
||||
QString iconFilename(cWorkingDir() + "tdata/icon.png");
|
||||
currentImageBack = App::readImage(iconFilename, nullptr, false);
|
||||
if (currentImageBack.isNull()) {
|
||||
currentImageBack = Core::App().logo();
|
||||
}
|
||||
}
|
||||
|
||||
if (currentImageBack.size() != desiredSize) {
|
||||
currentImageBack = currentImageBack.scaled(
|
||||
|
|
|
|||
|
|
@ -563,9 +563,25 @@ void MainWindow::psTrayMenuUpdated() {
|
|||
void MainWindow::psSetupTrayIcon() {
|
||||
if (!trayIcon) {
|
||||
trayIcon = new QSystemTrayIcon(this);
|
||||
QIcon icon;
|
||||
QString iconFilename(cWorkingDir() + "tdata/icon.png");
|
||||
QString iconFilenameSelected(cWorkingDir() + "tdata/icon_selected.png");
|
||||
|
||||
QIcon icon(QPixmap::fromImage(psTrayIcon(), Qt::ColorOnly));
|
||||
icon.addPixmap(QPixmap::fromImage(psTrayIcon(true), Qt::ColorOnly), QIcon::Selected);
|
||||
auto iconImage = App::readImage(iconFilename, nullptr, false);
|
||||
|
||||
if (iconImage.isNull()) {
|
||||
iconImage = psTrayIcon();
|
||||
}
|
||||
|
||||
icon = QIcon(QPixmap::fromImage(iconImage, Qt::ColorOnly));
|
||||
|
||||
auto iconImageSelected = App::readImage(iconFilenameSelected, nullptr, false);
|
||||
|
||||
if (iconImageSelected.isNull()) {
|
||||
iconImageSelected = psTrayIcon(true);
|
||||
}
|
||||
|
||||
icon.addPixmap(QPixmap::fromImage(iconImageSelected, Qt::ColorOnly), QIcon::Selected);
|
||||
|
||||
trayIcon->setIcon(icon);
|
||||
attachToTrayIcon(trayIcon);
|
||||
|
|
|
|||
|
|
@ -684,8 +684,14 @@ 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);
|
||||
|
||||
auto 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);
|
||||
connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(showFromTray()));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue