1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
# -*- coding: utf-8 -*-
# This file is part of the Frescobaldi project, http://www.frescobaldi.org/
#
# Copyright (c) 2008 - 2014 by Wilbert Berendsen
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# See http://www.gnu.org/licenses/ for more information.
"""
About dialog.
"""
from PyQt5.QtCore import QSettings, QSize, Qt, QUrl
from PyQt5.QtWidgets import (
QDialog, QDialogButtonBox, QLabel, QLayout, QTabWidget, QTextBrowser,
QVBoxLayout, QWidget)
import app
import appinfo
import icons
import helpers
import debuginfo
import userguide.page
class AboutDialog(QDialog):
"""A simple 'About Frescobaldi' dialog.
Most of the information is taken from the info module.
"""
def __init__(self, mainwindow):
"""Creates the about dialog. You can simply exec_() it."""
super(AboutDialog, self).__init__(mainwindow)
self.setWindowTitle(_("About {appname}").format(appname = appinfo.appname))
layout = QVBoxLayout()
self.setLayout(layout)
tabw = QTabWidget()
layout.addWidget(tabw)
tabw.addTab(About(self), _("About"))
tabw.addTab(Credits(self), _("Credits"))
tabw.addTab(Version(self), _("Version"))
button = QDialogButtonBox(QDialogButtonBox.Ok)
button.setCenterButtons(True)
button.accepted.connect(self.accept)
layout.addWidget(button)
layout.setSizeConstraint(QLayout.SetFixedSize)
class About(QWidget):
"""About widget."""
def __init__(self, parent=None):
super(About, self).__init__(parent)
layout = QVBoxLayout()
self.setLayout(layout)
size = QSize(100, 100)
pic = QLabel()
pic.setPixmap(icons.get("frescobaldi").pixmap(size))
pic.setFixedSize(size)
layout.addWidget(pic, 0, Qt.AlignHCenter)
text = QLabel()
text.setText(html())
text.linkActivated.connect(self.openLink)
layout.addWidget(text)
def openLink(self, url):
helpers.openUrl(QUrl(url))
class Credits(QTextBrowser):
"""Credits widget."""
def __init__(self, parent=None):
super(Credits, self).__init__(parent)
self.setOpenLinks(False)
self.anchorClicked.connect(helpers.openUrl)
self.setHtml(userguide.page.Page('credits').body())
class Version(QTextBrowser):
"""Version information."""
def __init__(self, parent=None):
super(Version, self).__init__(parent)
self.setPlainText(debuginfo.version_info_string())
def html():
"""Returns a HTML string for the about dialog."""
appname = appinfo.appname
version = _("Version {version}").format(version = appinfo.version)
description = _("A LilyPond Music Editor")
copyright = _("Copyright (c) {year} by {author}").format(
year = "2008-2016",
author = """<a href="mailto:{0}" title="{1}">{2}</a>""".format(
appinfo.maintainer_email,
_("Send an e-mail message to the maintainers."),
appinfo.maintainer))
# L10N: Translate this sentence and fill in your own name to have it appear in the About Dialog.
translator = _("Translated by Your Name.")
if translator == "Translated by Your Name.":
translator = ""
else:
translator = "<p>{0}</p>".format(translator)
license = _("Licensed under the {gpl}.").format(
gpl = """<a href="http://www.gnu.org/licenses/gpl.html">GNU GPL</a>""")
homepage = appinfo.url
return html_template.format(**locals())
html_template = """<html>
<body><div align="center">
<h1>{appname}</h1>
<h3>{version}</h3>
<p>{description}</p>
<p>{copyright}</p>
{translator}
<p>{license}</p>
<p><a href="{homepage}">{homepage}</a></p>
</div></body>
</html>
"""
|