Commits

Aleš Erjavec  committed 68ae91b

Set the application version from the package info and display it in the splash screen.

  • Participants
  • Parent commits d6a84c9

Comments (0)

Files changed (4)

File Orange/OrangeCanvas/application/aboutdialog.py

 import sys
 import pkg_resources
 
-from PyQt4.QtGui import QDialog, QDialogButtonBox, QVBoxLayout, QLabel, QPixmap
+from PyQt4.QtGui import QDialog, QDialogButtonBox, QVBoxLayout, QLabel
 from PyQt4.QtCore import Qt
 
-
-import Orange
-from Orange import OrangeCanvas
+from .. import config
 
 ABOUT_TEMPLATE = """\
 <center>
         layout = QVBoxLayout()
         label = QLabel(self)
 
-        filename = pkg_resources.resource_filename(
-                        OrangeCanvas.__name__,
-                        "icons/orange-splash-screen.png")
+        pixmap, _ = config.splash_screen()
 
-        label.setPixmap(QPixmap(filename))
+        label.setPixmap(pixmap)
+
         layout.addWidget(label, Qt.AlignCenter)
 
         try:

File Orange/OrangeCanvas/config.py

 
 import pkg_resources
 
-from PyQt4.QtGui import QDesktopServices
-from PyQt4.QtCore import QCoreApplication
+from PyQt4.QtGui import (
+    QDesktopServices, QPainter, QFont, QFontMetrics, QColor, QPixmap
+)
+
+from PyQt4.QtCore import Qt, QCoreApplication, QPoint, QRect
 
 from .utils.settings import Settings, config_slot
 
 
 
 def init():
-    """Initialize the QCoreApplication.organizationDomain, applicationName,
+    """
+    Initialize the QCoreApplication.organizationDomain, applicationName,
     applicationVersion and the default settings format. Will only run once.
 
     .. note:: This should not be run before QApplication has been initialized.
               Otherwise it can break Qt's plugin search paths.
 
     """
-    # Set application name, version and org. domain
+    dist = pkg_resources.get_distribution("Orange")
+    version = dist.version
+    # Use only major.minor
+    version = ".".join(version.split(".", 2)[:2])
+
     QCoreApplication.setOrganizationDomain("biolab.si")
     QCoreApplication.setApplicationName("Orange Canvas")
-    QCoreApplication.setApplicationVersion("2.6")
+    QCoreApplication.setApplicationVersion(version)
     QSettings.setDefaultFormat(QSettings.IniFormat)
 
     # Make it a null op.
              ep_iter
              ]
     return itertools.chain(*chain)
+
+
+def splash_screen():
+    """
+    """
+    pm = QPixmap(
+        pkg_resources.resource_filename(
+            __name__, "icons/orange-splash-screen.png")
+    )
+
+    version = QCoreApplication.applicationVersion()
+    size = 21 if len(version) < 5 else 16
+    font = QFont("Helvetica")
+    font.setPixelSize(size)
+    font.setBold(True)
+    font.setItalic(True)
+    font.setLetterSpacing(QFont.AbsoluteSpacing, 2)
+    metrics = QFontMetrics(font)
+    br = metrics.boundingRect(version).adjusted(-5, 0, 5, 0)
+    br.moveCenter(QPoint(436, 224))
+
+    p = QPainter(pm)
+    p.setRenderHint(QPainter.Antialiasing)
+    p.setRenderHint(QPainter.TextAntialiasing)
+    p.setFont(font)
+    p.setPen(QColor("#231F20"))
+    p.drawText(br, Qt.AlignCenter, version)
+    p.end()
+    return pm, QRect(88, 193, 200, 20)

File Orange/OrangeCanvas/icons/orange-splash-screen.png

Old
Old image
New
New image

File Orange/OrangeCanvas/main.py

 import pkg_resources
 
 from PyQt4.QtGui import QFont, QColor
-from PyQt4.QtCore import Qt, QRect, QDir
+from PyQt4.QtCore import Qt, QDir
 
 from Orange import OrangeCanvas
 from Orange.OrangeCanvas.application.application import CanvasApplication
 from Orange.OrangeCanvas.application.canvasmain import CanvasMainWindow
 from Orange.OrangeCanvas.application.outputview import TextStream, ExceptHook
 
-from Orange.OrangeCanvas.gui.splashscreen import SplashScreen, QPixmap
+from Orange.OrangeCanvas.gui.splashscreen import SplashScreen
 from Orange.OrangeCanvas.config import cache_dir
 from Orange.OrangeCanvas import config
 from Orange.OrangeCanvas.utils.redirect import redirect_stdout, redirect_stderr
         not options.no_splash
 
     if want_splash:
-        pm = QPixmap(pkg_resources.resource_filename(
-                        __name__, "icons/orange-splash-screen.png")
-                     )
-        # Text rectangle in which to fit the message.
-        rect = QRect(88, 193, 200, 20)
+        pm, rect = config.splash_screen()
         splash_screen = SplashScreen(pixmap=pm, textRect=rect)
         splash_screen.setFont(QFont("Helvetica", 12))
         color = QColor("#FFD39F")