"""
qtgui/HelpAboutDialog.py: CCP4MG Molecular Graphics Program
Copyright (C) 2001-2008 University of York, CCLRC
Copyright (C) 2009-2011 University of York
Copyright (C) 2012 STFC
This library is free software: you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
version 3, modified in accordance with the provisions of the
license to address the requirements of UK law.
You should have received a copy of the modified GNU Lesser General
Public License along with this library. If not, copies may be
downloaded from http://www.ccp4.ac.uk/ccp4license.php
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
"""
from PyQt4 import QtCore, QtGui, QtOpenGL
import MGSimpleDialog
import os
class HelpAboutDialog(MGSimpleDialog.MGSimpleDialog):
def showChangelog(self,url):
f = open(url,"r")
text = f.read()
f.close()
if not hasattr(self,"changelogWidget"):
self.changelogWidget = QtGui.QTextEdit()
self.changelogWidget.setWindowTitle(self.tr("Version History"))
self.changelogWidget.setHtml(text)
geom = QtGui.QDesktopWidget().screenGeometry()
height = abs(geom.top()-geom.bottom())-60 # 40 is a random number
width = abs(geom.left()-geom.right())-60
self.changelogWidget.setReadOnly(True)
self.changelogWidget.resize(min(800,width),height)
self.changelogWidget.show()
self.changelogWidget.raise_()
def showLicence(self,url):
f = open(url,"r")
lines = f.readlines()
f.close()
text = ''
max_width = 0;
font = QtGui.QFont("Courier");
font.setFixedPitch(True)
fm = QtGui.QFontMetrics(font)
geom = QtGui.QDesktopWidget().screenGeometry()
height = abs(geom.top()-geom.bottom())-60 # 40 is a random number
width = abs(geom.left()-geom.right())-60
for l in lines:
text += l
max_width = max(max_width,len(l))
if not hasattr(self,"licenceTextEdit"):
self.licenceTextEdit = QtGui.QTextEdit()
self.licenceTextEdit.setWindowTitle(self.tr("CCP4MG Licence"))
self.licenceTextEdit.setCurrentFont(font)
self.licenceTextEdit.setPlainText(text)
self.licenceTextEdit.setLineWrapMode(QtGui.QTextEdit.FixedColumnWidth)
self.licenceTextEdit.setLineWrapColumnOrWidth(80)
max_w = fm.width('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
self.licenceTextEdit.setReadOnly(True)
self.licenceTextEdit.resize(min(width,max_w),min(max_w,height))
self.licenceTextEdit.show()
self.licenceTextEdit.raise_()
def __init__(self,parent=None):
MGSimpleDialog.MGSimpleDialog.__init__(self,parent)
import version
#self.setAttribute(QtCore.Qt.WA_MacMetalStyle)
copyrightText = "Copyright (C) 2001-2008 University of York, CCLRC
Copyright (C) 2009-2011 University of York
Copyright (C) 2012-2013 STFC"
licenceUrl = "(Licence information)"
changelogUrl = "Change log"
url = 'http://www.ccp4.ac.uk/MG/'
layout = QtGui.QVBoxLayout(self)
pixmap = QtGui.QPixmap(os.path.join(os.environ["CCP4MG"],"ccp4mg_icon-64.png"))
label = QtGui.QLabel(self)
label2 = QtGui.QLabel(self)
label3 = QtGui.QLabel(self)
label5 = QtGui.QLabel(self)
label6 = QtGui.QLabel(self)
label_licence = QtGui.QLabel(self)
label_changelog = QtGui.QLabel(self)
label5.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
label6.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
label5.setOpenExternalLinks(True)
label.setPixmap(pixmap)
#svg = QtGui.QPixmap(os.path.join(os.environ["CCP4MG"],"ellipse2.svg"))
label2.setText("CCP4MG v. "+version.ccp4mg_version+" ")
label3.setText("The CCP4 Molecular Graphics Program
"+copyrightText)
label5.setText(url)
label6.setText(self.tr("Contact: ")+"ccp4mg@ysbl.york.ac.uk")
label_licence.setText(licenceUrl)
label_changelog.setText(changelogUrl)
self.setWindowTitle(self.tr("About CCP4MG"))
label.setAlignment(QtCore.Qt.AlignHCenter)
label2.setAlignment(QtCore.Qt.AlignHCenter)
label3.setAlignment(QtCore.Qt.AlignHCenter)
label5.setAlignment(QtCore.Qt.AlignHCenter)
label6.setAlignment(QtCore.Qt.AlignHCenter)
label_licence.setAlignment(QtCore.Qt.AlignHCenter)
label_licence.setOpenExternalLinks(False)
self.connect(label_licence,QtCore.SIGNAL('linkActivated(const QString&)'),self.showLicence)
label_changelog.setAlignment(QtCore.Qt.AlignHCenter)
label_changelog.setOpenExternalLinks(False)
self.connect(label_changelog,QtCore.SIGNAL('linkActivated(const QString&)'),self.showChangelog)
layout.addWidget(label)
layout.addWidget(label2)
layout.addWidget(label3)
layout.addWidget(label_licence)
layout.addWidget(label5)
layout.addWidget(label_changelog)
layout.addWidget(label6)
self.setLayout(layout)
self.setSizeGripEnabled(0)
#self.menu = "Windows"
self.show()
#self.CreateMenuEntry()