CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AboutDialog.py
Go to the documentation of this file.
1 from PyQt4.QtCore import Qt, SIGNAL, SLOT
2 from PyQt4.QtGui import QDialog, QPalette, QVBoxLayout, QLabel, QPushButton, QDialogButtonBox, QSizePolicy
3 from PyQt4.QtSvg import QSvgWidget
4 
5 from Vispa.Main.Directories import websiteUrl
6 import logging
7 
8 class AboutDialog(QDialog):
9  def __init__(self, application):
10  self._application = application
11  QDialog.__init__(self, self._application.mainWindow())
12  self.setAttribute(Qt.WA_DeleteOnClose)
13  self.setFocusPolicy(Qt.StrongFocus)
14  self.setWindowFlags(Qt.Window)
15  self.setAutoFillBackground(True)
16  #self.setPalette(QPalette(Qt.white))
17  self.fill()
18  self.setWindowTitle("About "+self._application.windowTitle())
19  self.resize(220, 200)
20 
21  def setApplication(self, app):
22  self._application = app
23 
24  def fill(self):
25  # Vispa
26  # icon
27  # Version
28  # Release date os.path.getmtime(filename)
29  # website url
30  # license
31  self.setLayout(QVBoxLayout())
32  if "vispa" in self._application.windowTitle().lower():
33  self._logo = QSvgWidget(":/resources/vispa_logo.svg")
34  sizeHint = self._logo.sizeHint()
35  logo_width_height_ratio = 1.0 * sizeHint.width() / sizeHint.height()
36  logo_width = 200
37  self._logo.setFixedSize(logo_width, logo_width/logo_width_height_ratio)
38  self.layout().addWidget(self._logo)
39  else:
40  label=QLabel(self._application.windowTitle())
41  self.layout().addWidget(label)
42  self.layout().addWidget(QLabel("Version "+ self._application.version()))
43  self.layout().addWidget(QLabel("More information can be found on:"))
44  websiteLink = QLabel("<a href='"+ websiteUrl +"'>"+ websiteUrl +"</a>")
45  websiteLink.setTextInteractionFlags(Qt.LinksAccessibleByMouse | Qt.TextSelectableByMouse)
46  websiteLink.setOpenExternalLinks(True)
47  self.layout().addWidget(websiteLink)
48  buttonBox=QDialogButtonBox()
49  buttonBox.addButton(QDialogButtonBox.Close)
50  self.connect(buttonBox,SIGNAL("rejected()"),self,SLOT("reject()"))
51  self.layout().addWidget(buttonBox)
52 
53  def onScreen(self):
54  self.show()
55  self.raise_()
56  self.activateWindow()
57  self.setFocus()