File indexing completed on 2021-12-21 14:33:23

0001 #!/usr/bin/python
0002 # -*- coding: utf-8 -*-
0003 
0004 import os, sys
0005 import ConfigParser
0006 
0007 from PyQt4.QtCore import *
0008 from PyQt4.QtGui import *
0009 from PyQt4.QtWebKit import *
0010 from PyQt4 import uic
0011 
0012 base_directory = os.path.dirname (sys.argv[0])
0013 slideshow_path = os.path.abspath(base_directory + "/ubiquity-slideshow/")
0014 
0015 slideshow_config = ConfigParser.ConfigParser()
0016 slideshow_config.read(os.path.join(slideshow_path,'slideshow.conf'))
0017 
0018 config_width = int(slideshow_config.get('Slideshow','width'))
0019 config_height = int(slideshow_config.get('Slideshow','height'))
0020 
0021 ui = None
0022 updateTimer = QTimer()
0023 
0024 def progress_increment():
0025     newVal = ui.progressBar.value() + 1
0026     if newVal >= 100:
0027         ui.progressBar.setValue(100)
0028         updateTimer.timeout.disconnect(progress_increment)
0029         return
0030     
0031     ui.progressBar.setValue(newVal)
0032     return True
0033     
0034 def openLink(qUrl):
0035     QDesktopServices.openUrl(qUrl)
0036 
0037 if __name__ == "__main__":
0038     app = QApplication(sys.argv)
0039 
0040     ui = uic.loadUi(os.path.join(base_directory, "slideshow.ui"))
0041     
0042     ui.progressBar.setValue(0)
0043     ui.progressBar.setFormat("Fake install... %p% complete")
0044     
0045     ui.webView.setMinimumSize(700, 420) # ubiquity kde_ui sets these hardcoded rather than use the config values
0046     ui.webView.linkClicked.connect(openLink)
0047     
0048     ui.webView.setContextMenuPolicy(Qt.NoContextMenu)
0049     ui.webView.page().setLinkDelegationPolicy(QWebPage.DelegateExternalLinks)
0050     ui.webView.page().mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
0051     ui.webView.page().mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)
0052     
0053     ui.webView.load(QUrl(os.path.join(slideshow_path, "slides", "index.html")))
0054     
0055     ui.setWindowTitle("Ubiquity Slideshow with Webkit")
0056     ui.show()
0057     
0058     updateTimer.timeout.connect(progress_increment)
0059     updateTimer.start(2000)
0060 
0061     app.exec_()