Repository: spyder-ide/spyder

Issue:
Add icon to mac dock when running with bootstrap



Discussion:

Resolving patch:
diff --git a/spyder/app/mainwindow.py b/spyder/app/mainwindow.py
--- a/spyder/app/mainwindow.py
+++ b/spyder/app/mainwindow.py
@@ -78,7 +78,7 @@
 from qtpy.compat import from_qvariant
 from qtpy.QtCore import (QByteArray, QCoreApplication, QPoint, QSize, Qt,
                          QThread, QTimer, QUrl, Signal, Slot)
-from qtpy.QtGui import QColor, QDesktopServices, QKeySequence, QPixmap
+from qtpy.QtGui import QColor, QDesktopServices, QIcon, QKeySequence, QPixmap
 from qtpy.QtWidgets import (QAction, QApplication, QDockWidget, QMainWindow,
                             QMenu, QMessageBox, QShortcut, QSplashScreen,
                             QStyleFactory)
@@ -113,13 +113,21 @@
 # splash screen created below
 #==============================================================================
 from spyder.utils.qthelpers import qapplication, MENU_SEPARATOR
+from spyder.config.base import get_image_path
 MAIN_APP = qapplication()
 
+if PYQT5:
+    APP_ICON = QIcon(get_image_path("spyder.svg"))
+else:
+    APP_ICON = QIcon(get_image_path("spyder.png"))
+
+MAIN_APP.setWindowIcon(APP_ICON)
 
 #==============================================================================
 # Create splash screen out of MainWindow to reduce perceived startup time. 
 #==============================================================================
 from spyder.config.base import _, get_image_path, DEV, PYTEST
+
 if not PYTEST:
     SPLASH = QSplashScreen(QPixmap(get_image_path('splash.svg')))
     SPLASH_FONT = SPLASH.font()
@@ -132,7 +140,6 @@
 else:
     SPLASH = None
 
-
 #==============================================================================
 # Local utility imports
 #==============================================================================
@@ -434,10 +441,7 @@ def signal_handler(signum, frame=None):
 
         self.base_title = title
         self.update_window_title()
-        resample = os.name != 'nt'
-        icon = ima.icon('spyder', resample=resample)
-        # Resampling SVG icon only on non-Windows platforms (see Issue 1314):
-        self.setWindowIcon(icon)
+
         if set_windows_appusermodelid != None:
             res = set_windows_appusermodelid()
             debug_print("appusermodelid: " + str(res))
@@ -2859,6 +2863,9 @@ def initialize():
     # possible
     app = qapplication()
 
+    # --- Set application icon
+    app.setWindowIcon(APP_ICON)
+
     #----Monkey patching QApplication
     class FakeQApplication(QApplication):
         """Spyder's fake QApplication"""
diff --git a/spyder/app/restart.py b/spyder/app/restart.py
--- a/spyder/app/restart.py
+++ b/spyder/app/restart.py
@@ -21,14 +21,14 @@
 import time
 
 # Third party imports
+from qtpy import PYQT5
 from qtpy.QtCore import Qt, QTimer
-from qtpy.QtGui import QColor, QPixmap
+from qtpy.QtGui import QColor, QPixmap, QIcon
 from qtpy.QtWidgets import QApplication, QMessageBox, QSplashScreen, QWidget
 
 # Local imports
 from spyder.config.base import _, get_image_path
 from spyder.py3compat import to_text_string
-from spyder.utils import icon_manager as ima
 from spyder.utils.qthelpers import qapplication
 
 
@@ -158,10 +158,12 @@ def main():
     # Start Qt Splash to inform the user of the current status
     app = qapplication()
     restarter = Restarter()
-    resample = not IS_WINDOWS
-    # Resampling SVG icon only on non-Windows platforms (see Issue 1314):
-    icon = ima.icon('spyder', resample=resample)
-    app.setWindowIcon(icon)
+
+    if PYQT5:
+        APP_ICON = QIcon(get_image_path("spyder.svg"))
+    else:
+        APP_ICON = QIcon(get_image_path("spyder.png"))
+    app.setWindowIcon(APP_ICON)
     restarter.set_splash_message(_('Closing Spyder'))
 
     # Get variables


Test patch: