add possibility to use icon from system theme for tray icon

This commit is contained in:
Mohammadreza Abdollahzadeh 2018-04-17 11:58:20 +04:30
parent b34ac9630e
commit eea6f686f6
No known key found for this signature in database
GPG key ID: 478E38B51BB8DE23

View file

@ -590,7 +590,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
if ( cfg.preferences.enableTrayIcon )
{
trayIcon = new QSystemTrayIcon( QIcon( ":/icons/programicon_old.png" ), this );
trayIcon = new QSystemTrayIcon( QIcon::fromTheme("goldendict-tray", QIcon( ":/icons/programicon_old.png" )), this );
trayIcon->setToolTip( tr( "Loading..." ) );
trayIcon->show();
}
@ -1113,7 +1113,7 @@ void MainWindow::updateTrayIcon()
if ( !trayIcon && cfg.preferences.enableTrayIcon )
{
// Need to show it
trayIcon = new QSystemTrayIcon( QIcon( ":/icons/programicon_old.png" ), this );
trayIcon = new QSystemTrayIcon( QIcon::fromTheme("goldendict-tray", QIcon( ":/icons/programicon_old.png" )), this );
trayIcon->setContextMenu( &trayIconMenu );
trayIcon->show();
@ -1131,10 +1131,9 @@ void MainWindow::updateTrayIcon()
if ( trayIcon )
{
// Update the icon to reflect the scanning mode
trayIcon->setIcon( QIcon(
enableScanPopup->isChecked() ?
":/icons/programicon_scan.png" :
":/icons/programicon_old.png" ) );
trayIcon->setIcon( enableScanPopup->isChecked() ?
QIcon::fromTheme("goldendict-scan-tray", QIcon( ":/icons/programicon_scan.png" )) :
QIcon::fromTheme("goldendict-tray", QIcon( ":/icons/programicon_old.png" )) );
trayIcon->setToolTip( "GoldenDict" );
}