Skip to content

Commit

Permalink
Merge pull request #4443 from goanpeca/fix/icon
Browse files Browse the repository at this point in the history
PR: Add icon earlier when running application
  • Loading branch information
ccordoba12 authored Aug 14, 2017
2 parents f5b82ba + 010202e commit b91a80d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
19 changes: 13 additions & 6 deletions spyder/app/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -110,13 +110,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()
Expand All @@ -129,7 +137,6 @@
else:
SPLASH = None


#==============================================================================
# Local utility imports
#==============================================================================
Expand Down Expand Up @@ -439,10 +446,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))
Expand Down Expand Up @@ -2903,6 +2907,9 @@ def initialize():
# possible
app = qapplication()

# --- Set application icon
app.setWindowIcon(APP_ICON)

#----Monkey patching QApplication
class FakeQApplication(QApplication):
"""Spyder's fake QApplication"""
Expand Down
14 changes: 8 additions & 6 deletions spyder/app/restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
from spyder.config.main import CONF

Expand Down Expand Up @@ -174,10 +174,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
Expand Down

0 comments on commit b91a80d

Please sign in to comment.