def aboutInfo(self) -> None: about_html = '''<style> a { color:#441d4e; text-decoration:none; font-weight:bold; } a:hover { text-decoration:underline; } </style> <p style="font-size:26pt; font-weight:bold;">%s</p> <p> <span style="font-size:13pt;"><b>Version: %s</b></span> <span style="font-size:10pt;position:relative;left:5px;">( %s )</span> </p> <p style="font-size:13px;"> Copyright © 2016 <a href="mailto:[email protected]">Pete Alexandrou</a> <br/> Website: <a href="%s">%s</a> </p> <p style="font-size:13px;"> Thanks to the folks behind the <b>Qt</b>, <b>PyQt</b> and <b>FFmpeg</b> projects for all their hard and much appreciated work. </p> <p style="font-size:11px;"> 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. </p> <p style="font-size:11px;"> This software uses libraries from the <a href="https://www.ffmpeg.org">FFmpeg</a> project under the <a href="https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html">LGPLv2.1</a> </p>''' % (qApp.applicationName(), qApp.applicationVersion(), platform.architecture()[0], qApp.organizationDomain(), qApp.organizationDomain()) QMessageBox.about(self.parent, 'About %s' % qApp.applicationName(), about_html)
def about_app(self) -> None: about_html = '''<style> a { color:#441d4e; text-decoration:none; font-weight:bold; } a:hover { text-decoration:underline; } </style> <p style="font-size:24pt; font-weight:bold; color:#6A687D;">%s</p> <p> <span style="font-size:13pt;"><b>Version: %s</b></span> <span style="font-size:10pt;position:relative;left:5px;">( %s )</span> </p> <p style="font-size:13px;"> Copyright © %s <a href="mailto:[email protected]">Pete Alexandrou</a> <br/> Web: <a href="%s">%s</a> </p> <p style="font-size:11px;"> 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. </p>''' % (qApp.applicationName(), qApp.applicationVersion(), platform.architecture()[0], datetime.now().year, qApp.organizationDomain(), qApp.organizationDomain()) QMessageBox.about(self, 'About %s' % qApp.applicationName(), about_html)
def saveStandardItemModelXML(mdl, xml=None): """Saves the given QStandardItemModel to XML. If xml (filename) is given, saves to xml. Otherwise returns as string.""" root = ET.Element("model") root.attrib["version"] = qApp.applicationVersion() # Header header = ET.SubElement(root, "header") vHeader = ET.SubElement(header, "vertical") for x in range(mdl.rowCount()): vH = ET.SubElement(vHeader, "label") vH.attrib["row"] = str(x) vH.attrib["text"] = str(mdl.headerData(x, Qt.Vertical)) hHeader = ET.SubElement(header, "horizontal") for y in range(mdl.columnCount()): hH = ET.SubElement(hHeader, "label") hH.attrib["row"] = str(y) hH.attrib["text"] = str(mdl.headerData(y, Qt.Horizontal)) # Data data = ET.SubElement(root, "data") saveItem(data, mdl) #print(qApp.tr("Saving to {}.").format(xml)) if xml: ET.ElementTree(root).write(xml, encoding="UTF-8", xml_declaration=True, pretty_print=True) else: return ET.tostring(root, encoding="UTF-8", xml_declaration=True, pretty_print=True)
def aboutDialog(self): mbox = QMessageBox.about( self, self.tr("Lilii Yükleyici Hakkında"), self. tr("<h1>Lilii {}</h1>" "<b>Lime Linux için Sistem Yükleyici</b>" "<p>Copyright 2017 Metehan Özbek - <b>[email protected]</b><br>" "Teşekkürler: Fatih Kaya - <b>[email protected]</b></p>". format(qApp.applicationVersion())))
def aboutDialog(self): distro_name = Settings().value("distro_name") self.aboutBox = QMessageBox() self.aboutBox.setWindowTitle(self.tr("About Lime Installer")) self.aboutBox.setText(self.tr("<h1>Lime Installer {}</h1>" "<b>System installer for {}</b>" "<p>Copyright 2017 Metehan Ozbek - <b>[email protected]</b><br>" "Thanks to: Fatih Kaya - <b>[email protected]</b></p>").format( qApp.applicationVersion(), distro_name)) self.aboutBox.exec_()
def notify_no_update(parent: QWidget) -> None: mbox = QMessageBox(parent) mbox.setIconPixmap(QIcon(':/images/thumbsup.png').pixmap(64, 64)) mbox.setWindowTitle('%s UPDATER' % qApp.applicationName()) mbox.setText('<h3 style="color:#6A4572;">%s %s</h3>' % (qApp.applicationName(), qApp.applicationVersion())) mbox.setInformativeText( 'You are already running the latest version.' + '<table width="350"><tr><td></td></tr></table>') mbox.setStandardButtons(QMessageBox.Close) mbox.setDefaultButton(QMessageBox.Close) return mbox.exec_()
def done(self, reply: QNetworkReply): if reply.error() != QNetworkReply.NoError: sys.stderr.write(reply.errorString()) return try: json_data = json.loads(str(reply.readAll(), 'utf-8')) reply.deleteLater() latest = json_data.get('tag_name') current = qApp.applicationVersion() self.parent.update_available(latest, current) except json.JSONDecodeError: self.logger.exception('Error retrieving data', exc_info=True) raise
def done(self, reply: QNetworkReply) -> None: if reply.error() != QNetworkReply.NoError: self.logger.error(reply.errorString()) sys.stderr.write(reply.errorString()) return if os.getenv('DEBUG', False): self.log_request(reply) # noinspection PyTypeChecker jsonobj = json.loads(str(reply.readAll(), 'utf-8')) reply.deleteLater() latest = parse_version(jsonobj.get('tag_name')) current = parse_version(qApp.applicationVersion()) self.mbox.show_result(latest, current)
def check_latest_pypi(self) -> None: try: res = json.loads( urlopen(self.pypi_api_endpoint).read().decode('utf-8')) if 'info' in res.keys(): latest_release = str(res['info']['version']) if LooseVersion(latest_release) > LooseVersion( qApp.applicationVersion()): # self.notify_update(version=latest_release, installer=self.install_update) self.updateAvailable.emit(True, latest_release) return self.updateAvailable.emit(False, None) except HTTPError: self.updateAvailable.emit(False, None)
def notify_update(parent: QWidget, version: str) -> QMessageBox.ButtonRole: mbox = QMessageBox(parent) mbox.setIconPixmap(qApp.windowIcon().pixmap(64, 64)) mbox.setWindowTitle('%s UPDATER' % qApp.applicationName()) mbox.setText( '<table border="0" width="350"><tr><td><h4 align="center">Your Version: %s <br/> Available Version: %s' % (qApp.applicationVersion(), version) + '</h4></td></tr></table><br/>') mbox.setInformativeText( 'A new version of %s has been detected. Would you like to update now?' % qApp.applicationName()) install_btn = mbox.addButton('Install Update', QMessageBox.AcceptRole) reject_btn = mbox.addButton('Not Now', QMessageBox.RejectRole) mbox.setDefaultButton(install_btn) return mbox.exec_()
def done(self, reply: QNetworkReply) -> None: if reply.error() != QNetworkReply.NoError: self.logger.error(reply.errorString()) sys.stderr.write(reply.errorString()) return if os.getenv('DEBUG', False): self.log_request(reply) try: jsonobj = loads(str(reply.readAll(), 'utf-8')) reply.deleteLater() latest = jsonobj.get('tag_name') current = qApp.applicationVersion() self.mbox.show_result(latest, current) except JSONDecodeError: self.logger.exception('Updater JSON decoding error', exc_info=True) raise
def saveStandardItemModelXML(mdl, xml=None): """Saves the given QStandardItemModel to XML. If xml (filename) is given, saves to xml. Otherwise returns as string.""" root = ET.Element("model") root.attrib["version"] = qApp.applicationVersion() # Header header = ET.SubElement(root, "header") vHeader = ET.SubElement(header, "vertical") for x in range(mdl.rowCount()): vH = ET.SubElement(vHeader, "label") vH.attrib["row"] = str(x) vH.attrib["text"] = str(mdl.headerData(x, Qt.Vertical)) hHeader = ET.SubElement(header, "horizontal") for y in range(mdl.columnCount()): hH = ET.SubElement(hHeader, "label") hH.attrib["row"] = str(y) hH.attrib["text"] = str(mdl.headerData(y, Qt.Horizontal)) # Data data = ET.SubElement(root, "data") saveItem(data, mdl) # print(qApp.tr("Saving to {}.").format(xml)) if xml: ET.ElementTree(root).write(xml, encoding="UTF-8", xml_declaration=True, pretty_print=True) else: return ET.tostring(root, encoding="UTF-8", xml_declaration=True, pretty_print=True)
def aboutDialog(self): mbox = QMessageBox.about(self, self.tr("About Lilii"), self.tr("<h1>Lilii {}</h1>" "<b>System installer for Lime GNU/Linux</b>" "<p>Copyright 2017 Metehan Özbek - <b>[email protected]</b><br>" "Thanks to: Fatih Kaya - <b>[email protected]</b></p>".format(qApp.applicationVersion())))
def __init__(self, parent=None, f=Qt.WindowCloseButtonHint): super(About, self).__init__(parent, f) self.parent = parent self.setObjectName('aboutwidget') self.setContentsMargins(0, 0, 0, 0) self.setWindowModality(Qt.ApplicationModal) pencolor1 = '#9A45A2' if self.parent.theme == 'dark' else '#642C68' pencolor2 = '#FFF' if self.parent.theme == 'dark' else '#000' appicon = self.parent.getAppIcon(encoded=True) appversion = qApp.applicationVersion() apparch = platform.architecture()[0] builddate = About.builddate() headercontent = '''<style>table {{ color: {pencolor2}; background-color: transparent; }}</style> <table border="0" cellpadding="3" cellspacing="1" width="100%%"> <tr> <td width="82" style="padding-top:10px;padding-right:10px;"> <img src="{appicon}" width="82" /> </td> <td style="padding:4px;"> <div style="font-family:'Futura-Light', sans-serif;font-size:40px;font-weight:400;color:{pencolor1};"> <span style="font-size:58px;">V</span>ID<span style="font-size:58px;">C</span>UTTER </div> <div style="margin-top:6px; margin-left:15px;"> <table border="0" cellpadding="0" cellspacing="0" width="100%%">'''.format( **locals()) if builddate is None: headercontent += '''<tr valign="middle" style="padding-left:30px;"> <td style="text-align:right;font-size:10pt;font-weight:500;color:{pencolor1};">version:</td> <td> </td> <td> <span style="font-size:18px;font-weight:400;">{appversion}</span> <span style="font-size:10pt;margin-left:5px;">({apparch})</span> </td> </tr>'''.format(**locals()) else: headercontent += '''<tr valign="middle"> <td style="text-align:right;font-size:10pt;font-weight:500;color:{pencolor1};">version:</td> <td> </td> <td> <span style="font-size:18px;font-weight:400;">{appversion}</span> <span style="font-size:10pt;margin-left:5px;">({apparch})</span> </td> </tr> <tr valign="middle"> <td style="text-align:right;font-size:10pt;font-weight:500;color:{pencolor1};">build date:</td> <td> </td> <td style="font-size:10pt;font-weight:400;">{builddate}</td> </tr>'''.format(**locals()) headercontent += '''</table> </div> </td> <td valign="bottom" align="right" style="padding-top:30px;"> <div align="right" style="position:relative; right:5px;"> <img src=":/images/{0}/python.png"/> </div> <div align="right" style="position:relative; right:5px; top:10px;"> <img src=":/images/qt.png" /> </div> </td> </tr> </table>'''.format(self.parent.theme) header = QLabel(headercontent, self) header.setStyleSheet('border:none;') self.tab_about = AboutTab(self) self.tab_credits = CreditsTab(self) self.tab_license = LicenseTab(self) tabs = QTabWidget() tabs.addTab(self.tab_about, 'About') tabs.addTab(self.tab_credits, 'Credits') tabs.addTab(self.tab_license, 'License') buttons = QDialogButtonBox(QDialogButtonBox.Ok) buttons.accepted.connect(self.close) layout = QVBoxLayout() layout.addWidget(header) layout.addWidget(tabs) layout.addWidget(buttons) self.setLayout(layout) self.setWindowTitle('About %s' % qApp.applicationName()) self.setWindowIcon(self.parent.windowIcon()) self.setMinimumSize(self.get_size(self.parent.parent.scale))
def __init__(self, parent=None, f=Qt.WindowCloseButtonHint): super(About, self).__init__(parent, f) self.parent = parent self.setObjectName('aboutwidget') self.setContentsMargins(0, 0, 0, 0) self.setWindowModality(Qt.ApplicationModal) builddate = datetime.fromtimestamp(os.path.getmtime( About.getBinPath())).strftime('%d %b %Y') pencolor1 = '#9A45A2' if self.parent.theme == 'dark' else '#642C68' pencolor2 = '#FFF' if self.parent.theme == 'dark' else '#000' appicon = self.parent.getAppIcon(encoded=True) header = QLabel( ''' <style>table { color: %s; background-color: transparent; }</style> <table border="0" cellpadding="5" cellspacing="1" width="100%%"> <tr> <td width="82" style="padding-top:10px;padding-right:10px;"> <img src="%s" width="82" /> </td> <td style="padding:4px;"> <div style="font-family:'Futura-Light', sans-serif;font-size:40px;font-weight:400;color:%s;"> <span style="font-size:58px;">V</span>ID<span style="font-size:58px;">C</span>UTTER </div> <div style="padding:0; margin:0; margin-left:10px;"> <table border="0" cellpadding="2" cellspacing="0"> <tr valign="middle"> <td style="text-align:right;font-size:10pt;font-weight:500;color:%s;">version:</td> <td> <span style="font-size:18px;font-weight:400;">%s</span> <span style="font-size:10pt;margin-left:5px;">(%s)</span> </td> </tr> <tr valign="middle"> <td style="text-align:right;font-size:10pt;font-weight:500;color:%s;">build date:</td> <td style="font-size:10pt;font-weight:400;">%s</td> </tr> </table> </div> </td> <td valign="bottom" align="right" style="padding:30px 15px 15px 15px;"> <div style="padding:20px 0 10px 0;"> <img src=":/images/%s/python.png"/> </div> <div style="margin-top:10px;"> <img src=":/images/qt.png" /> </div> </td> </tr> </table>''' % (pencolor2, appicon, pencolor1, pencolor1, qApp.applicationVersion(), platform.architecture()[0], pencolor1, builddate.upper(), self.parent.theme), self) header.setStyleSheet('border:none;') self.tab_about = AboutTab(self) self.tab_credits = CreditsTab(self) self.tab_license = LicenseTab(self) tabs = QTabWidget() tabs.addTab(self.tab_about, 'About') tabs.addTab(self.tab_credits, 'Credits') tabs.addTab(self.tab_license, 'License') buttons = QDialogButtonBox(QDialogButtonBox.Ok) buttons.accepted.connect(self.close) layout = QVBoxLayout() layout.addWidget(header) layout.addWidget(tabs) layout.addWidget(buttons) self.setLayout(layout) self.setWindowTitle('About %s' % qApp.applicationName()) self.setWindowIcon(self.parent.windowIcon()) self.setMinimumSize(self.get_size(self.parent.parent.scale))
def __init__(self, ffmpeg_service: QObject, mpv_service: QObject, parent: QWidget): super(About, self).__init__(parent) self.parent = parent self.logger = logging.getLogger(__name__) self.ffmpeg_service = ffmpeg_service self.mpv_service = mpv_service self.theme = self.parent.theme self.setObjectName('aboutwidget') self.setContentsMargins(0, 0, 0, 0) self.setWindowFlags(Qt.Window | Qt.Dialog | Qt.WindowCloseButtonHint) self.setWindowModality(Qt.ApplicationModal) logolabel = QLabel(self) logolabel.setPixmap(QPixmap(':/images/about-logo.png')) versionlabel = QLabel(''' <style> b.label {{ font-family: "Noto Sans", sans-serif; font-size: 14px; font-weight: 500; color: {0}; }} b.version {{ font-family: "Futura LT", sans-serif; font-size: 16px; font-weight: 600; }} </style> <b class="label">version:</b> <b class="version">{1}</b> '''.format('#EA95FF' if self.theme == 'dark' else '#441D4E', qApp.applicationVersion(), self)) if self.parent.parent.flatpak: versionlabel.setText( versionlabel.text() + ' <span style="font-size:12px;">- FLATPAK</span>') versionspacing = 75 else: versionspacing = 95 versionlabel.setAlignment(Qt.AlignBottom) versionlayout = QHBoxLayout() versionlayout.setSpacing(0) versionlayout.setContentsMargins(0, 0, 0, 0) versionlayout.addStretch(1) versionlayout.addWidget(versionlabel) versionlayout.addSpacing(versionspacing) headerlayout = QVBoxLayout() headerlayout.setSpacing(0) headerlayout.setContentsMargins(0, 0, 0, 0) headerlayout.addWidget(logolabel, 1) headerlayout.addLayout(versionlayout) self.tab_about = AboutTab(self) self.tab_credits = CreditsTab(self) self.tab_license = LicenseTab(self) scrollarea = QScrollArea(self) scrollarea.setStyleSheet('QScrollArea { background:transparent; }') scrollarea.setWidgetResizable(True) scrollarea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) scrollarea.setFrameShape(QScrollArea.NoFrame) scrollarea.setWidget(self.tab_license) if sys.platform in {'win32', 'darwin'}: scrollarea.setStyle(QStyleFactory.create('Fusion')) tabs = QTabWidget() tabs.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) tabs.addTab(self.tab_about, 'About') tabs.addTab(self.tab_credits, 'Credits') tabs.addTab(scrollarea, 'License') buttons = QDialogButtonBox(QDialogButtonBox.Ok) buttons.accepted.connect(self.close) layout = QVBoxLayout() layout.addLayout(headerlayout) layout.addWidget(tabs, 1) layout.addWidget(buttons) self.setLayout(layout) self.setWindowTitle('About {}'.format(qApp.applicationName())) self.setFixedSize(self.sizeHint())
def __init__(self, parent=None): super(AboutTab, self).__init__(parent) self.parent = parent weight = 500 if sys.platform == 'win32' else 600 linebreak = '<br/>' if sys.platform == 'win32' else ' ' try: ffmpeg_version = self.parent.parent.mediaPlayer.ffmpeg_version except AttributeError: ffmpeg_version = '2.8.10' self.setHtml('''<style> a { color:#441d4e; text-decoration:none; font-weight:bold; } a:hover { text-decoration:underline; } table { width: 100%%; font-family: "Open Sans", sans-serif; } </style> <table border="0" cellpadding="6" cellspacing="4"> <tr> <td> <img src=":/images/vidcutter.png" /> </td> <td> <p> <span style="font-size:36pt; font-weight:%i; color:#6A4572;">%s</span> <br/> <span style="font-size:13pt;font-weight:600;">Version:</span> <span style="font-size:13pt;font-weight:%i;">%s</span> <span style="font-size:10pt;position:relative;left:5px;">- %s</span> </p> <p style="font-size:13px;"> + <b>libmpv:</b> %s %s + <b>FFmpeg:</b> %s <br/> + <b>Python:</b> %s + <b>PyQt5:</b> %s + <b>SIP:</b> %s </p> <p style="font-size:13px;"> Copyright © 2017 <a href="mailto:[email protected]">Pete Alexandrou</a> <br/> Website: <a href="%s">%s</a> </p> <p style="font-size:13px;"> Icon design by <a href="https://github.com/PapirusDevelopmentTeam">Papirus Development Team</a> </p> <p style="font-size:11px;"> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3, or (at your option) any later version. This software uses libraries from the <a href="https://mpv.io">mpv</a> and <a href="https://www.ffmpeg.org">FFmpeg</a> projects under the <a href="https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html">LGPLv2.1</a> license. </p> </td> </tr> </table>''' % (weight, qApp.applicationName(), weight, qApp.applicationVersion(), platform.architecture()[0], self.parent.parent.mediaPlayer.mpv_version.replace( 'mpv ', ''), linebreak, ffmpeg_version, sys.version.split(' ')[0], PYQT_VERSION_STR, SIP_VERSION_STR, qApp.organizationDomain(), qApp.organizationDomain()))
def __init__(self, parent=None, f=Qt.WindowCloseButtonHint): super(About, self).__init__(parent, f) self.parent = parent self.setObjectName('aboutwidget') self.setContentsMargins(0, 0, 0, 0) self.setWindowModality(Qt.ApplicationModal) builddate = datetime.fromtimestamp(os.path.getmtime(mpv.__file__)).strftime('%d %b %Y') pencolor1 = '#9A45A2' if self.parent.theme == 'dark' else '#642C68' pencolor2 = '#FFF' if self.parent.theme == 'dark' else '#000' # use theme app icon image if one exists appicon = ':/images/vidcutter-small.png' if QIcon.hasThemeIcon(qApp.applicationName().lower()): themeicon = QIcon.fromTheme(qApp.applicationName().lower(), QIcon(appicon)) themeimg = themeicon.pixmap(82, 82).toImage() data = QByteArray() buffer = QBuffer(data) buffer.open(QBuffer.WriteOnly) themeimg.save(buffer, 'PNG') base64enc = str(data.toBase64().data(), 'latin1') appicon = 'data:vidcutter.png;base64,%s' % base64enc header = QLabel(''' <style>table { color: %s; background-color: transparent; }</style> <table border="0" cellpadding="5" cellspacing="1" width="100%%"> <tr> <td width="82" style="padding-top:10px;padding-right:10px;"> <img src="%s" width="82" /> </td> <td style="padding:4px;"> <div style="font-family:'Futura-Light', sans-serif;font-size:40px;font-weight:400;color:%s;"> <span style="font-size:58px;">V</span>ID<span style="font-size:58px;">C</span>UTTER </div> <div style="padding:0; margin:0; margin-left:0px;"> <table border="0" cellpadding="2" cellspacing="0"> <tr valign="bottom"> <td style="text-align:right;font-size:10pt;font-weight:500;color:%s;">version:</td> <td> <span style="font-size:18px;font-weight:400;">%s</span> <span style="font-size:10pt;margin-left:5px;">(Special HD Ver.)</span><!--%s--> </td> </tr> <tr valign="bottom"> <td style="text-align:right;font-size:10pt;font-weight:500;color:%s;">build date:</td> <td style="font-size:10pt;font-weight:400;">%s</td> </tr> </table> </div> </td> <td valign="bottom" align="right" style="padding:30px 15px 15px 15px;"> <div style="padding:20px 0 10px 0;"> <img src=":/images/%s/python.png"/> </div> <div style="margin-top:10px;"> <img src=":/images/qt.png" /> </div> </td> </tr> </table>''' % (pencolor2, appicon, pencolor1, pencolor1, qApp.applicationVersion(), platform.architecture()[0], pencolor1, builddate.upper(), self.parent.theme), self) header.setStyleSheet('border:none;') self.tab_about = AboutTab(self) self.tab_credits = CreditsTab(self) self.tab_license = LicenseTab(self) tabs = QTabWidget() tabs.addTab(self.tab_about, 'About') tabs.addTab(self.tab_credits, 'Credits') tabs.addTab(self.tab_license, 'License') buttons = QDialogButtonBox(QDialogButtonBox.Ok) buttons.accepted.connect(self.close) layout = QVBoxLayout() layout.addWidget(header) layout.addWidget(tabs) layout.addWidget(buttons) self.setLayout(layout) self.setWindowTitle('About %s' % qApp.applicationName()) self.setWindowIcon(self.parent.windowIcon()) self.setMinimumSize(self.get_size(self.parent.parent.scale))