From c785ecead2a7b7762226c46b2d3b155db6996d71 Mon Sep 17 00:00:00 2001 From: alby128 Date: Mon, 18 Sep 2017 20:18:18 +0200 Subject: [PATCH] Add About dialog with license info on macOS --- resources/third-party-notices.txt | 1 + syncplay/ui/gui.py | 50 ++++++++++++++++++++++++++----- 2 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 resources/third-party-notices.txt 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 78d5a65..8e38279 100755 --- a/syncplay/ui/gui.py +++ b/syncplay/ui/gui.py @@ -84,6 +84,46 @@ class UserlistItemDelegate(QtWidgets.QStyledItemDelegate): optionQStyleOptionViewItem.rect.setX(optionQStyleOptionViewItem.rect.x()+16) QtWidgets.QStyledItemDelegate.paint(self, itemQPainter, optionQStyleOptionViewItem, indexQModelIndex) +class AboutDialog(QtWidgets.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 = QtWidgets.QLabel("
Syncplay
") + nameLabel.setFont(QtGui.QFont("Helvetica", 20)) + linkLabel = QtWidgets.QLabel("
syncplay.pl
") + linkLabel.setOpenExternalLinks(True) + versionLabel = QtWidgets.QLabel("
Version v" + version + "
") + licenseLabel = QtWidgets.QLabel("

Copyright © 2017 Syncplay

Licensed under the Apache License, Version 2.0

") + aboutIconPixmap = QtGui.QPixmap(self.resourcespath + u"syncplay.png") + aboutIconLabel = QtWidgets.QLabel() + aboutIconLabel.setPixmap(aboutIconPixmap.scaled(120, 120, Qt.KeepAspectRatio)) + aboutLayout = QtWidgets.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 = QtWidgets.QPushButton("License") + licenseButton.clicked.connect(self.openLicense) + aboutLayout.addWidget(licenseButton, 4, 2) + dependenciesButton = QtWidgets.QPushButton("Dependencies") + dependenciesButton.clicked.connect(self.openDependencies) + aboutLayout.addWidget(dependenciesButton, 4, 3) + aboutLayout.setSizeConstraint(QtWidgets.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(QtWidgets.QMainWindow): insertPosition = None playlistState = [] @@ -1358,14 +1398,8 @@ class MainWindow(QtWidgets.QMainWindow): window.mainLayout.setMenuBar(window.menuBar) def openAbout(self): - #AboutMsgBox = QtWidgets.QMessageBox.about(self,"Syncplay","Syncplay v" + version) - AboutMsgBox = QtWidgets.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 = QtWidgets.QFrame()