Fallback to non-panel icon when tray counter is disabled
This commit is contained in:
		
							parent
							
								
									02bc999bd5
								
							
						
					
					
						commit
						db2aa7000a
					
				
					 1 changed files with 27 additions and 14 deletions
				
			
		| 
						 | 
				
			
			@ -44,7 +44,7 @@ int32 _trayIconCount = 0;
 | 
			
		|||
QImage _trayIconImageBack, _trayIconImage;
 | 
			
		||||
QString _trayIconThemeName, _trayIconName;
 | 
			
		||||
 | 
			
		||||
QString GetTrayIconName() {
 | 
			
		||||
QString GetPanelIconName() {
 | 
			
		||||
	const auto counter = Core::App().unreadBadge();
 | 
			
		||||
	const auto muted = Core::App().unreadBadgeMuted();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -55,6 +55,24 @@ QString GetTrayIconName() {
 | 
			
		|||
		: kPanelTrayIconName.utf16();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString GetTrayIconName() {
 | 
			
		||||
	const auto panelIconName = GetPanelIconName();
 | 
			
		||||
 | 
			
		||||
	if (QIcon::hasThemeIcon(panelIconName)) {
 | 
			
		||||
		return panelIconName;
 | 
			
		||||
	} else if (InSandbox()) {
 | 
			
		||||
		const auto launcherBasename = GetLauncherBasename();
 | 
			
		||||
 | 
			
		||||
		if (QIcon::hasThemeIcon(launcherBasename)) {
 | 
			
		||||
			return launcherBasename;
 | 
			
		||||
		}
 | 
			
		||||
	} else if (QIcon::hasThemeIcon(kTrayIconName.utf16())) {
 | 
			
		||||
		return kTrayIconName.utf16();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return QString();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QImage TrayIconImageGen() {
 | 
			
		||||
	const auto counter = Core::App().unreadBadge();
 | 
			
		||||
	const auto muted = Core::App().unreadBadgeMuted();
 | 
			
		||||
| 
						 | 
				
			
			@ -76,16 +94,8 @@ QImage TrayIconImageGen() {
 | 
			
		|||
			|| _trayIconImageBack.size() != desiredSize
 | 
			
		||||
			|| iconThemeName != _trayIconThemeName
 | 
			
		||||
			|| iconName != _trayIconName) {
 | 
			
		||||
			const auto hasPanelIcon = QIcon::hasThemeIcon(iconName);
 | 
			
		||||
 | 
			
		||||
			if (hasPanelIcon || QIcon::hasThemeIcon(kTrayIconName.utf16())) {
 | 
			
		||||
				QIcon systemIcon;
 | 
			
		||||
 | 
			
		||||
				if (hasPanelIcon) {
 | 
			
		||||
					systemIcon = QIcon::fromTheme(iconName);
 | 
			
		||||
				} else {
 | 
			
		||||
					systemIcon = QIcon::fromTheme(kTrayIconName.utf16());
 | 
			
		||||
				}
 | 
			
		||||
			if (!iconName.isEmpty()) {
 | 
			
		||||
				const auto systemIcon = QIcon::fromTheme(iconName);
 | 
			
		||||
 | 
			
		||||
				if (systemIcon.actualSize(desiredSize) == desiredSize) {
 | 
			
		||||
					_trayIconImageBack = systemIcon
 | 
			
		||||
| 
						 | 
				
			
			@ -118,7 +128,8 @@ QImage TrayIconImageGen() {
 | 
			
		|||
		_trayIconThemeName = iconThemeName;
 | 
			
		||||
		_trayIconName = iconName;
 | 
			
		||||
 | 
			
		||||
		if (counter > 0) {
 | 
			
		||||
		if (!qEnvironmentVariableIsSet(kDisableTrayCounter.utf8())
 | 
			
		||||
			&& counter > 0) {
 | 
			
		||||
			QPainter p(&_trayIconImage);
 | 
			
		||||
			int32 layerSize = -16;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -270,8 +281,10 @@ void MainWindow::psTrayMenuUpdated() {
 | 
			
		|||
#ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION
 | 
			
		||||
void MainWindow::setSNITrayIcon(
 | 
			
		||||
		const QIcon &icon, const QImage &iconImage) {
 | 
			
		||||
	if (qEnvironmentVariableIsSet(kDisableTrayCounter.utf8())) {
 | 
			
		||||
		const auto iconName = GetTrayIconName();
 | 
			
		||||
	const auto iconName = GetTrayIconName();
 | 
			
		||||
 | 
			
		||||
	if (qEnvironmentVariableIsSet(kDisableTrayCounter.utf8())
 | 
			
		||||
		&& !iconName.isEmpty()) {
 | 
			
		||||
		_sniTrayIcon->setIconByName(iconName);
 | 
			
		||||
		_sniTrayIcon->setToolTipIconByName(iconName);
 | 
			
		||||
	} else if (NeedTrayIconFile()) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue