From 39b346c884431075d09f8dd6111bf424c4ea2579 Mon Sep 17 00:00:00 2001 From: Alberto Sottile Date: Mon, 18 Sep 2017 22:54:26 +0200 Subject: [PATCH] Add About dialog with license info on macOS --- buildPy2app.py | 2 +- resources/third-party-notices.txt | 1 + syncplay/ui/gui.py | 51 +++++++++++++++++++++++++------ 3 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 resources/third-party-notices.txt diff --git a/buildPy2app.py b/buildPy2app.py index 5cc8ccb..0a7bdbc 100644 --- a/buildPy2app.py +++ b/buildPy2app.py @@ -11,7 +11,7 @@ import syncplay APP = ['syncplayClient.py'] DATA_FILES = [ - ('resources', glob('resources/*.png')), + ('resources', glob('resources/*.png') + glob('resources/*.txt')), ] OPTIONS = { 'iconfile':'resources/icon.icns', diff --git a/resources/third-party-notices.txt b/resources/third-party-notices.txt new file mode 100644 index 0000000..f4e7000 --- /dev/null +++ b/resources/third-party-notices.txt @@ -0,0 +1 @@ +Write here third party copyright notices. \ No newline at end of file diff --git a/syncplay/ui/gui.py b/syncplay/ui/gui.py index 30d5255..e04de2c 100644 --- a/syncplay/ui/gui.py +++ b/syncplay/ui/gui.py @@ -86,6 +86,46 @@ class UserlistItemDelegate(QtGui.QStyledItemDelegate): optionQStyleOptionViewItem.rect.setX(optionQStyleOptionViewItem.rect.x()+16) QtGui.QStyledItemDelegate.paint(self, itemQPainter, optionQStyleOptionViewItem, indexQModelIndex) +class AboutDialog(QtGui.QDialog): + if sys.platform.startswith('win'): + resourcespath = utils.findWorkingDir() + u"\\resources\\" + else: + resourcespath = utils.findWorkingDir() + u"/resources/" + + def __init__(self, parent=None): + super(AboutDialog, self).__init__(parent) + self.setWindowTitle("") + nameLabel = QtGui.QLabel("
Syncplay
") + nameLabel.setFont(QtGui.QFont("Helvetica", 20)) + linkLabel = QtGui.QLabel("
syncplay.pl
") + linkLabel.setOpenExternalLinks(True) + versionLabel = QtGui.QLabel("
Version v" + version + "
") + licenseLabel = QtGui.QLabel("

Copyright © 2017 Syncplay

Licensed under the Apache License, Version 2.0

") + aboutIconPixmap = QtGui.QPixmap(self.resourcespath + u"syncplay.png") + aboutIconLabel = QtGui.QLabel() + aboutIconLabel.setPixmap(aboutIconPixmap.scaled(120, 120, Qt.KeepAspectRatio)) + aboutLayout = QtGui.QGridLayout() + aboutLayout.addWidget(aboutIconLabel, 0, 0, 4, 2) + aboutLayout.addWidget(nameLabel, 0, 2, 1, 2) + aboutLayout.addWidget(linkLabel, 1, 2, 1, 2) + aboutLayout.addWidget(versionLabel, 2, 2, 1, 2) + aboutLayout.addWidget(licenseLabel, 3, 2, 1, 2) + licenseButton = QtGui.QPushButton("License") + licenseButton.clicked.connect(self.openLicense) + aboutLayout.addWidget(licenseButton, 4, 2) + dependenciesButton = QtGui.QPushButton("Dependencies") + dependenciesButton.clicked.connect(self.openDependencies) + aboutLayout.addWidget(dependenciesButton, 4, 3) + aboutLayout.setSizeConstraint(QtGui.QLayout.SetFixedSize) + self.setSizeGripEnabled(False) + self.setLayout(aboutLayout) + + def openLicense(self): + QtGui.QDesktopServices.openUrl(QUrl("file://" + self.resourcespath + u"license.txt")) + + def openDependencies(self): + QtGui.QDesktopServices.openUrl(QUrl("file://" + self.resourcespath + u"third-party-notices.txt")) + class MainWindow(QtGui.QMainWindow): insertPosition = None playlistState = [] @@ -1376,15 +1416,8 @@ class MainWindow(QtGui.QMainWindow): window.mainLayout.setMenuBar(window.menuBar) def openAbout(self): - #AboutMsgBox = QtGui.QMessageBox.about(self,"Syncplay","Syncplay v" + version) - AboutMsgBox = QtGui.QMessageBox(self) - AboutMsgBox.setText("
Syncplay
syncplay.pl
") - AboutMsgBox.setInformativeText("
Version v" + version + "

Copyright © 2017 Syncplay

Licensed under the Apache License, Version 2.0

") - AboutIcon = QtGui.QPixmap(self.resourcespath + u"syncplay.png") - AboutMsgBox.setIconPixmap(AboutIcon.scaled(120, 120)) - AboutMsgBox.setModal(True) - AboutMsgBox.exec_() - + aboutMsgBox = AboutDialog() + aboutMsgBox.exec_() def addMainFrame(self, window): window.mainFrame = QtGui.QFrame()