SF.net SVN: fclient:[966] trunk/fclient/fclient/impl/ViewBrowser
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-09-06 08:52:05
|
Revision: 966
http://fclient.svn.sourceforge.net/fclient/?rev=966&view=rev
Author: jUrner
Date: 2008-09-06 08:52:13 +0000 (Sat, 06 Sep 2008)
Log Message:
-----------
added functionality to view html source of a page
Modified Paths:
--------------
trunk/fclient/fclient/impl/ViewBrowser/Actions.py
trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py
Added Paths:
-----------
trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgViewPageSource.py
trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgViewPageSource.ui
trunk/fclient/fclient/impl/ViewBrowser/dlgs/Ui_DlgViewPageSource.py
Modified: trunk/fclient/fclient/impl/ViewBrowser/Actions.py
===================================================================
--- trunk/fclient/fclient/impl/ViewBrowser/Actions.py 2008-09-06 08:51:02 UTC (rev 965)
+++ trunk/fclient/fclient/impl/ViewBrowser/Actions.py 2008-09-06 08:52:13 UTC (rev 966)
@@ -199,8 +199,24 @@
text=self.trUtf8('Bookmark page..'),
isEnabled=True,
trigger=parent.onBookmarkPage,
- )
+ )
+
+ # others
+ self.action(
+ name='ActionViewPageSource',
+ text=self.trUtf8('View page source..'),
+ isEnabled=True,
+ trigger=parent.onViewPageSource,
+ )
+
+ self.action(
+ name='ActionViewFrameSource',
+ text=self.trUtf8('View frame source..'),
+ isEnabled=True,
+ trigger=parent.onViewFrameSource,
+ )
+
def intertwineBrowserActions(self, browser=None):
"""intertwines Browser actions with BrowserWidget actions
@note: call everytime the current browser changes
Modified: trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py
===================================================================
--- trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py 2008-09-06 08:51:02 UTC (rev 965)
+++ trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py 2008-09-06 08:52:13 UTC (rev 966)
@@ -79,6 +79,7 @@
from .dlgs import DlgPropsBrowserObject
from .dlgs import DlgBookmarks
from .dlgs import DlgBookmarkPage
+from .dlgs import DlgViewPageSource
from .Ui_BrowserWidget import Ui_ViewBrowserWidget
#*****************************************************************************************
@@ -183,10 +184,13 @@
## private methods
#########################################
def _adjustCurrentBrowserDependendStuff(self):
- self.fcActions.intertwineBrowserActions(self.currentBrowser())
+ browser = self.currentBrowser()
+ self.fcActions.intertwineBrowserActions(browser)
if self.sideBarLoadDetails.isVisible():
- self.sideBarLoadDetails.setBrowser(self.currentBrowser())
+ self.sideBarLoadDetails.setBrowser(browser)
+ self.fcActions['ActionViewPageSource'].setEnabled(browser is not None)
+
#NOTE: to reduce flicker set min size to max size
def _adjustTabText(self, qString):
maxTabText = self.fcSettings.value('MaxTabText')
@@ -391,6 +395,7 @@
menu.addAction(self.fcActions['ActionFindPrevious'])
menu.addAction(self.fcActions['ActionEditBookmarks'])
menu.addAction(self.fcActions['ActionBookmarkPage'])
+ menu.addAction(self.fcActions['ActionViewPageSource'])
menu.addMenu(self.menuBookmarks)
menu.addMenu(self.menuSideBars)
@@ -472,6 +477,7 @@
menu.addSeparator()
menu.addAction(browser.pageAction(page.Copy))
menu.addAction(self.fcActions['ActionObjectProperties'])
+ menu.addAction(self.fcActions['ActionViewFrameSource'])
#TODO: QwebView assumes we can download queries - we can't
browser.pageAction(page.DownloadLinkToDisk).setEnabled(config.fcpClient.isConnected())
@@ -789,7 +795,24 @@
# update status info
addressBar.setText(lastBrowserState.url.toString())
-
+
+ def onViewFrameSource(self, action):
+ browser = self.currentBrowser()
+ if browser is not None:
+ dlg = DlgViewPageSource.DlgViewPageSource(self, html= browser.page().currentFrame().toHtml())
+ dlg.show()
+ if dlg.result() == dlg.Accepted:
+ pass
+
+ def onViewPageSource(self, action):
+ browser = self.currentBrowser()
+ if browser is not None:
+ dlg = DlgViewPageSource.DlgViewPageSource(self, html= browser.page().mainFrame().toHtml())
+ dlg.show()
+ if dlg.result() == dlg.Accepted:
+ pass
+
+
#TODO: enable/disable, but no view gives non feedback on max/min zoom
def onZoomIn(self, action):
browser = self.currentBrowser()
Added: trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgViewPageSource.py
===================================================================
--- trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgViewPageSource.py (rev 0)
+++ trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgViewPageSource.py 2008-09-06 08:52:13 UTC (rev 966)
@@ -0,0 +1,86 @@
+
+#*********************************************************************************
+#TODO:
+#
+# x. html syntax highlighter
+#
+#*********************************************************************************
+# some fixes for relative imports
+# see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below)
+# see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a
+# ...package containing relative imports
+from __future__ import absolute_import
+if __name__ == '__main__':
+ import os
+ __path__ = [os.path.dirname(__file__)]
+ from ._fix_mexec import fix_mexec
+ fix_mexec(__name__, __file__)
+ del fix_mexec
+
+import os
+from PyQt4 import QtCore, QtGui
+
+from ... import config
+from .Ui_DlgViewPageSource import Ui_DlgViewPageSource
+#**********************************************************************************
+#
+#**********************************************************************************
+class Settings(config.SettingsBase):
+ _key_ = 'DlgBrowserViewpageSource'
+ _settings_ = (
+ ('Geometry', 'ByteArray', QtCore.QByteArray()),
+ )
+
+#**********************************************************************************
+#
+#**********************************************************************************
+class HtmlSyntaxHighlighter(QtGui.QSyntaxHighlighter):
+
+ def __init__(self, parent=None):
+ QtGui.QSyntaxHighlighter.__init__(self, parent)
+
+
+ def highlightBlock(self, text):
+ pass
+
+#**********************************************************************************
+#
+#**********************************************************************************
+class DlgViewPageSource(QtGui.QDialog, Ui_DlgViewPageSource):
+
+
+ IdEd = 'ed'
+
+ def __init__(self, parent=None, html=None):
+ QtGui.QDialog.__init__(self, parent)
+
+ self.setupUi(self)
+
+ self.fcSettings = Settings(self).restore()
+ self.restoreGeometry(self.fcSettings.value('Geometry'))
+
+
+ ed = self.controlById(self.IdEd)
+ if html is not None:
+ ed.setPlainText(html)
+ self.hilighter = HtmlSyntaxHighlighter(ed.document())
+
+ def controlById(self, idControl):
+ return getattr(self, idControl)
+
+ def hideEvent(self, event):
+ self.fcSettings.setValues(Geometry=self.saveGeometry())
+
+#**********************************************************************************
+#
+#**********************************************************************************
+if __name__ == '__main__':
+ import sys
+
+ app = QtGui.QApplication(sys.argv)
+ w = DlgViewPageSource(None, html='''<a href="foo">bar</a>
+ '''
+ )
+ w.show()
+ res = app.exec_()
+ sys.exit(res)
Added: trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgViewPageSource.ui
===================================================================
--- trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgViewPageSource.ui (rev 0)
+++ trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgViewPageSource.ui 2008-09-06 08:52:13 UTC (rev 966)
@@ -0,0 +1,73 @@
+<ui version="4.0" >
+ <class>DlgViewPageSource</class>
+ <widget class="QDialog" name="DlgViewPageSource" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>461</width>
+ <height>594</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>View page source..</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout" >
+ <item row="0" column="0" >
+ <widget class="QPlainTextEdit" name="ed" >
+ <property name="readOnly" >
+ <bool>true</bool>
+ </property>
+ <property name="textInteractionFlags" >
+ <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QDialogButtonBox" name="buttonBox" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons" >
+ <set>QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>DlgViewPageSource</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>DlgViewPageSource</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
Added: trunk/fclient/fclient/impl/ViewBrowser/dlgs/Ui_DlgViewPageSource.py
===================================================================
--- trunk/fclient/fclient/impl/ViewBrowser/dlgs/Ui_DlgViewPageSource.py (rev 0)
+++ trunk/fclient/fclient/impl/ViewBrowser/dlgs/Ui_DlgViewPageSource.py 2008-09-06 08:52:13 UTC (rev 966)
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file '/home/me/src/fclient/trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgViewPageSource.ui'
+#
+# Created: Sat Sep 6 10:42:58 2008
+# by: PyQt4 UI code generator 4.4.2
+#
+# WARNING! All changes made in this file will be lost!
+
+from PyQt4 import QtCore, QtGui
+
+class Ui_DlgViewPageSource(object):
+ def setupUi(self, DlgViewPageSource):
+ DlgViewPageSource.setObjectName("DlgViewPageSource")
+ DlgViewPageSource.resize(461,594)
+ self.gridLayout = QtGui.QGridLayout(DlgViewPageSource)
+ self.gridLayout.setObjectName("gridLayout")
+ self.ed = QtGui.QPlainTextEdit(DlgViewPageSource)
+ self.ed.setReadOnly(True)
+ self.ed.setTextInteractionFlags(QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse)
+ self.ed.setObjectName("ed")
+ self.gridLayout.addWidget(self.ed,0,0,1,1)
+ self.buttonBox = QtGui.QDialogButtonBox(DlgViewPageSource)
+ self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
+ self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
+ self.buttonBox.setObjectName("buttonBox")
+ self.gridLayout.addWidget(self.buttonBox,1,0,1,1)
+
+ self.retranslateUi(DlgViewPageSource)
+ QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("accepted()"),DlgViewPageSource.accept)
+ QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("rejected()"),DlgViewPageSource.reject)
+ QtCore.QMetaObject.connectSlotsByName(DlgViewPageSource)
+
+ def retranslateUi(self, DlgViewPageSource):
+ DlgViewPageSource.setWindowTitle(QtGui.QApplication.translate("DlgViewPageSource", "View page source..", None, QtGui.QApplication.UnicodeUTF8))
+
+
+if __name__ == "__main__":
+ import sys
+ app = QtGui.QApplication(sys.argv)
+ DlgViewPageSource = QtGui.QDialog()
+ ui = Ui_DlgViewPageSource()
+ ui.setupUi(DlgViewPageSource)
+ DlgViewPageSource.show()
+ sys.exit(app.exec_())
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|