SF.net SVN: fclient:[764] trunk/fclient/src/fclient
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-07-27 11:22:37
|
Revision: 764
http://fclient.svn.sourceforge.net/fclient/?rev=764&view=rev
Author: jUrner
Date: 2008-07-27 11:22:45 +0000 (Sun, 27 Jul 2008)
Log Message:
-----------
new package structure
Added Paths:
-----------
trunk/fclient/src/fclient/impl/Ui_DlgConnectionExpertSettings.py
trunk/fclient/src/fclient/impl/Ui_DlgDownloadKeyToDisk.py
trunk/fclient/src/fclient/impl/Ui_DlgPropsBrowserObject.py
trunk/fclient/src/fclient/impl/Ui_MainWindow.py
trunk/fclient/src/fclient/impl/Ui_Prefs.py
trunk/fclient/src/fclient/impl/Ui_PrefsBrowserWidget.py
trunk/fclient/src/fclient/impl/Ui_PrefsGlobal.py
trunk/fclient/src/fclient/impl/Ui_View.py
trunk/fclient/src/fclient/impl/Ui_ViewBrowser.py
trunk/fclient/src/fclient/impl/Ui_ViewConnection.py
trunk/fclient/src/fclient/impl/Ui_ViewDownloads.py
trunk/fclient/src/fclient/impl/Ui_ViewLogger.py
trunk/fclient/src/fclient/impl/__init__.py
trunk/fclient/src/fclient/impl/config.py
Removed Paths:
-------------
trunk/fclient/src/fclient/Ui_DlgConnectionExpertSettings.py
trunk/fclient/src/fclient/Ui_DlgDownloadKeyToDisk.py
trunk/fclient/src/fclient/Ui_DlgPropsBrowserObject.py
trunk/fclient/src/fclient/Ui_MainWindow.py
trunk/fclient/src/fclient/Ui_Prefs.py
trunk/fclient/src/fclient/Ui_PrefsBrowserWidget.py
trunk/fclient/src/fclient/Ui_PrefsGlobal.py
trunk/fclient/src/fclient/Ui_View.py
trunk/fclient/src/fclient/Ui_ViewBrowser.py
trunk/fclient/src/fclient/Ui_ViewConnection.py
trunk/fclient/src/fclient/Ui_ViewDownloads.py
trunk/fclient/src/fclient/Ui_ViewLogger.py
trunk/fclient/src/fclient/__init__.py
trunk/fclient/src/fclient/config.py
Deleted: trunk/fclient/src/fclient/Ui_DlgConnectionExpertSettings.py
===================================================================
--- trunk/fclient/src/fclient/Ui_DlgConnectionExpertSettings.py 2008-07-27 11:20:49 UTC (rev 763)
+++ trunk/fclient/src/fclient/Ui_DlgConnectionExpertSettings.py 2008-07-27 11:22:45 UTC (rev 764)
@@ -1,73 +0,0 @@
-
-from __future__ import absolute_import
-if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
- import os; __path__ = [os.path.dirname(__file__)]
-
-from PyQt4 import QtCore, QtGui
-
-from . import config
-
-from .tpls.Ui_DlgConnectionExpertSettingsTpl import Ui_DlgConnectionExpertSettings
-#**********************************************************************************
-#
-#**********************************************************************************
-class ConnectionExpertSettingsDlg(QtGui.QDialog, Ui_DlgConnectionExpertSettings ):
-
- IdEdFcpConnectionName = 'edFcpConnectionName'
- IdSpinFcpConnectionTimerMaxDuration = 'spinFcpConnectionTimerMaxDuration'
- IdSpinConnectionTimerTimeout = 'spinConnectionTimerTimeout'
- IdSpinFcpPollTimerTimeout = 'spinFcpPollTimerTimeout'
-
- def __init__(self, parent=None):
- QtGui.QDialog.__init__(self, parent)
-
- self.setupUi(self)
- self.setWindowTitle(config.FclientAppName + self.trUtf8(' - Connection expert settings'))
-
- edName = self.controlById(self.IdEdFcpConnectionName)
- edName.setText(config.settings.value('FcpConnectionName'))
- self.connect(edName, QtCore.SIGNAL('textChanged(const QString &)'), self.onEdFcpConnectionNameChanged)
-
- connectionWidget = config.ObjectRegistry.get(config.IdViewConnectionWidget, None)
- spins = (
- (self.IdSpinFcpConnectionTimerMaxDuration, 'FcpConnectionTimerMaxDuration'),
- (self.IdSpinConnectionTimerTimeout, 'FcpConnectionTimerTimeout'),
- (self.IdSpinFcpPollTimerTimeout, 'FcpPollTimerTimeout'),
- )
- for idControl, settingName in spins:
- spin = self.controlById(idControl)
- if connectionWidget is None:
- spin.setEnabled(False)
- else:
- spin.setValue(connectionWidget.fcSettings.value(settingName))
-
-
-
-
- def controlById(self, idControl):
- return getattr(self, idControl)
-
-
- def onEdFcpConnectionNameChanged(self, text):
- config.settings.setValues(FcpConnectionName=text)
-
-
-
-#**********************************************************************************
-#
-#**********************************************************************************
-if __name__ == '__main__':
- import sys
-
- class DummyKey(object):
- KeyType = 'USK@'
- def __init__(self): self.key = 'USG@qweqqweqwe'
- def toString(self): return self.key
-
- app = QtGui.QApplication(sys.argv)
- w = ConnectionExpertSettingsDlg(None)
- w.show()
- res = app.exec_()
- sys.exit(res)
-
-
Deleted: trunk/fclient/src/fclient/Ui_DlgDownloadKeyToDisk.py
===================================================================
--- trunk/fclient/src/fclient/Ui_DlgDownloadKeyToDisk.py 2008-07-27 11:20:49 UTC (rev 763)
+++ trunk/fclient/src/fclient/Ui_DlgDownloadKeyToDisk.py 2008-07-27 11:22:45 UTC (rev 764)
@@ -1,79 +0,0 @@
-from __future__ import absolute_import
-if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
- import os; __path__ = [os.path.dirname(__file__)]
-
-import os
-from PyQt4 import QtCore, QtGui
-
-from . import config
-from .lib.compactpath.qt4 import pathlabelwrap
-
-
-from .tpls.Ui_DlgDownloadKeyToDiskTpl import Ui_DlgDownloadKeyToDisk
-#**********************************************************************************
-#
-#**********************************************************************************
-class DownloadKeyToDiskDlg(QtGui.QDialog, Ui_DlgDownloadKeyToDisk):
-
- IdLabelKey = 'labelKey'
- IdEdDownloadFileName = 'edDownloadFileName'
- IdBtChooseDownloadFileName = 'btChooseDownloadFileName'
-
-
- def __init__(self, parent=None, fcpKey=None):
- QtGui.QDialog.__init__(self, parent)
-
- self.setupUi(self)
- self.setWindowTitle(config.FclientAppName + self.trUtf8(' - Download key..'))
-
- self._filePath = None
- self._fcpKey = fcpKey
-
- self.pathLabelWrap = pathlabelwrap.PathLabelWrap(
- self.labelKey,
- fpath=unicode(self.labelKey.text()),
- path_module=config.CompactPathFcpKeyModule
- )
- self.connect(self.btChooseDownloadFileName, QtCore.SIGNAL('clicked()'), self.onChooseDownloadFileName)
-
- # find out fileName to dl key to
- fileName = config.guessFileNameFromKey(fcpKey)
- if fileName is None:
- fileName = self.trUtf8('UNKNOWN')
- self._filePath = os.path.join(unicode(config.settings.value('DownloadDir')), unicode(fileName))
- self.edDownloadFileName.setText(self._filePath)
- if self._fcpKey is not None:
- self.pathLabelWrap.setPath(self._fcpKey.toString())
-
- def filePath(self):
- return self._filePath
-
- def onChooseDownloadFileName(self):
- filePath = QtGui.QFileDialog.getSaveFileName(
- self,
- config.FclientAppName + self.trUtf8(' - Save key To..'),
- self.edDownloadFileName.text(),
- )
- if filePath:
- self._filePath = filePath
- self.edDownloadFileName.setText(filePath)
-
-
-#**********************************************************************************
-#
-#**********************************************************************************
-if __name__ == '__main__':
- import sys
-
- class DummyKey(object):
- KeyType = 'USK@'
- def __init__(self): self.key = 'USG@qweqqweqwe'
- def toString(self): return self.key
-
- app = QtGui.QApplication(sys.argv)
- w = DownloadKeyToDiskDlg(None, fcpKey=DummyKey())
- w.show()
- res = app.exec_()
- sys.exit(res)
-
-
Deleted: trunk/fclient/src/fclient/Ui_DlgPropsBrowserObject.py
===================================================================
--- trunk/fclient/src/fclient/Ui_DlgPropsBrowserObject.py 2008-07-27 11:20:49 UTC (rev 763)
+++ trunk/fclient/src/fclient/Ui_DlgPropsBrowserObject.py 2008-07-27 11:22:45 UTC (rev 764)
@@ -1,69 +0,0 @@
-#*********************************************************************
-#TODO:
-# just a sketch so far
-#
-# x. link and image url are not selectable
-#
-#
-#**********************************************************************
-from __future__ import absolute_import
-if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
- import os; __path__ = [os.path.dirname(__file__)]
-
-import posixpath
-from PyQt4 import QtGui
-
-from . import config
-from .lib.compactpath.qt4 import pathlabelwrap
-from .lib.qt4ex.lib import tools as qtools
-
-from .tpls.Ui_DlgPropsBrowserObjectTpl import Ui_DlgPropsBrowserObject
-#**********************************************************************************
-#
-#**********************************************************************************
-class PropsBrowserObjectDlg(QtGui.QDialog, Ui_DlgPropsBrowserObject):
-
- IdLabelType = 'labelType'
- IdLabelTitle = 'labelTitle'
- IdLabelName = 'labelName'
- IdLabelLinkUrl = 'labelLinkUrl'
- IdLabelImageUrl = 'labelImageUrl'
-
- MaxText = 80
-
- def __init__(self, parent, browser=None, hitTestResult=None):
- QtGui.QDialog.__init__(self, parent)
-
- self.setupUi(self)
- self.setWindowTitle(config.FclientAppName + self.trUtf8(' - Properties'))
-
- if hitTestResult is not None:
-
- if not hitTestResult.linkUrl().isEmpty():
- labelLinkUrl = self.controlById(self.IdLabelLinkUrl)
- self.wrapLinkUrl = pathlabelwrap.PathLabelWrap(labelLinkUrl, path_module=config.CompactPathFcpKeyModule)
- self.wrapLinkUrl.setPath(unicode(hitTestResult.linkUrl().toString()))
- if not hitTestResult.imageUrl().isEmpty():
- labelImageUrl = self.controlById(self.IdLabelImageUrl)
- self.wrapImageUrl = pathlabelwrap.PathLabelWrap(labelImageUrl, path_module=config.CompactPathFcpKeyModule)
- self.wrapImageUrl.setPath(unicode(hitTestResult.imageUrl().toString()))
-
- ellipsis = self.trUtf8('..')
- self.labelTitle.setText(qtools.truncateString(self.MaxText, hitTestResult.linkTitle().toString(), ellipsis))
- self.labelTitle.setText(qtools.truncateString(self.MaxText, hitTestResult.linkText(), ellipsis))
-
- def controlById(self, idControl):
- return getattr(self, idControl)
-
-#**********************************************************************************
-#
-#**********************************************************************************
-if __name__ == '__main__':
- import sys
-
- app = QtGui.QApplication(sys.argv)
- w = PropsBrowserObjectDlg(None)
- w.show()
- res = app.exec_()
- sys.exit(res)
-
Deleted: trunk/fclient/src/fclient/Ui_MainWindow.py
===================================================================
--- trunk/fclient/src/fclient/Ui_MainWindow.py 2008-07-27 11:20:49 UTC (rev 763)
+++ trunk/fclient/src/fclient/Ui_MainWindow.py 2008-07-27 11:22:45 UTC (rev 764)
@@ -1,160 +0,0 @@
-from __future__ import absolute_import
-if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
- import os; __path__ = [os.path.dirname(__file__)]
-
-import logging
-import sys
-logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
-
-from PyQt4 import QtCore, QtGui
-
-from . import config
-from . import Ui_Prefs
-from . import Ui_View
-from .lib.qt4ex import dlgabout
-
-from .tpls.Ui_MainWindowTpl import Ui_MainWindow
-#**********************************************************************************
-#
-#**********************************************************************************
-class Settings(config.SettingsBase):
-
- _key_ = config.IdMainWindow
- _settings_ = (
- ('Geometry', 'ByteArray', QtCore.QByteArray(), config.SettingScopePrivate),
- )
-
-
-class Actions(config.ActionsBase):
-
- def __init__(self, parent):
- config.ActionsBase.__init__(self, parent)
-
- self.action(
- name='ActionPreferences',
- text=self.trUtf8('&Preferences...'),
- trigger=parent.onActPreferencesTriggered,
- )
- self.action(
- name='ActionExit',
- text=self.trUtf8('E&xit'),
- trigger=parent.onActExitTriggered,
- )
- self.action(
- name='ActionAbout',
- text=self.trUtf8('A&bout...'),
- trigger=parent.onActAboutTriggered,
- )
- self.action(
- name='ActionHelp',
- text=self.trUtf8('&Help...'),
- trigger=parent.onActHelpTriggered,
- )
-
-#**********************************************************************************
-#
-#**********************************************************************************
-class MenuBar(QtGui.QMenuBar):
-
- def __init__(self, parent):
- QtGui.QMenuBar.__init__(self, parent)
- self.setObjectName('MenuBar')
- #config.ObjectRegistry.register(self)
-
- self.menuApplication = QtGui.QMenu(self.trUtf8('&Application'), self)
- self.addMenu(self.menuApplication)
- self.menuApplication.addAction(parent.fclientActions['ActionPreferences'])
- self.menuApplication.addAction(parent.fclientActions['ActionExit'])
-
- self.menuHelp = QtGui.QMenu(self.trUtf8('&Help'), self)
- self.addMenu(self.menuHelp)
- self.menuHelp.addAction(parent.fclientActions['ActionAbout'])
- self.menuHelp.addAction(parent.fclientActions['ActionHelp'])
-
-
- def addViewMenu(self, menu):
- self.insertMenu(self.menuHelp.children()[0], menu)
- return menu
-
-
-
-class StatusBar(QtGui.QStatusBar):
-
- def __init__(self, parent):
- QtGui.QStatusBar.__init__(self, parent)
- self.setObjectName('StatusBar')
- #config.ObjectRegistry.register(self)
- parent.setStatusBar(self)
-
-#**********************************************************************************
-#
-#**********************************************************************************
-class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
-
- def __init__(self, parent=None):
- QtGui.QMainWindow.__init__(self, parent)
- self._isCreated = False
-
- self.setupUi(self)
- config.ObjectRegistry.register(self)
-
- self.fclientSettings = Settings().restore()
- self.fclientActions = Actions(self)
- self.setMenuBar(MenuBar(self))
- self.setStatusBar(StatusBar(self))
-
- self.restoreGeometry(self.fclientSettings.value('Geometry'))
-
- ##################################################
- ## events
- ##################################################
- def closeEvent(self, event):
- self.fclientSettings.setValues(Geometry=self.saveGeometry())
-
-
- def showEvent(self, event):
- if self._isCreated:
- return
- self._isCreated = True
-
- ##################################################
- ## event onrs
- ##################################################
- def onActPreferencesTriggered(self):
- dlg = Ui_Prefs.PrefsDlg(self)
- if dlg.exec_() == dlg.Accepted:
- pass
-
- def onActExitTriggered(self):
- self.close()
-
- def onActHelpTriggered(self):
- pass
-
- def onActAboutTriggered(self):
- dlg = dlgabout.DlgAbout(
- self,
- ##state=self.guiSettings['DlgAboutState'],
- caption=config.FclientAppName + ' - ' + self.trUtf8('About'),
- appName=config.FclientAppName,
- description=self.trUtf8('a freenet client written in python and Qt4'),
- version=config.FclientVersion,
- author=config.FclientAuthor,
- licence=config.FclientLicence,
- copyright=config.FclientCopyright,
- homepage=config.FclientHomepage
- )
- dlg.exec_()
- #self.guiSettings['DlgAboutState'] = dlg.saveState()
-
-#**********************************************************************************
-#
-#**********************************************************************************
-if __name__ == '__main__':
- import sys
-
- app = QtGui.QApplication(sys.argv)
- w = MainWindow(None)
- w.show()
- res = app.exec_()
- sys.exit(res)
\ No newline at end of file
Deleted: trunk/fclient/src/fclient/Ui_Prefs.py
===================================================================
--- trunk/fclient/src/fclient/Ui_Prefs.py 2008-07-27 11:20:49 UTC (rev 763)
+++ trunk/fclient/src/fclient/Ui_Prefs.py 2008-07-27 11:22:45 UTC (rev 764)
@@ -1,91 +0,0 @@
-from __future__ import absolute_import
-if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
- import os; __path__ = [os.path.dirname(__file__)]
-
-
-from PyQt4 import QtGui
-
-from . import config
-from .lib.qt4ex import dlgpreferences
-from .Ui_PrefsGlobal import PrefsPageGlobal
-from .Ui_PrefsBrowserWidget import PrefsPageBrowser
-#**********************************************************************************
-#
-#**********************************************************************************
-class Settings(config.SettingsBase):
- _key_ = config.IdViewBrowserWidget
- _settings_ = (
- ('DlgState', 'String', '', config.SettingScopePrivate),
- )
-
-
-#***********************************************************************
-#
-#***********************************************************************
-class PrefsPageRoot(dlgpreferences.Page):
-
- UUID = '{a61e2758-4c66-11dd-a3e6-8814a37cbeed}'
-
- def __init__(self):
- dlgpreferences.Page.__init__(self, self.UUID)
- self._widget = None
- self.setDirty(True)
-
- def displayName(self):
- return QtGui.QApplication.translate("PreferencesGlobal", 'All', None, QtGui.QApplication.UnicodeUTF8)
-
- def canApply(self): return False
- def canHelp(self): return False
-
- def setVisible(self, parent, flag):
- createdNew = False
- if flag and self._widget is None:
- createdNew = True
- self._widget = QtGui.QWidget(parent)
- self._widget.setVisible(flag)
- return (createdNew, self._widget)
-
-#**********************************************************************************
-#
-#**********************************************************************************
-class PrefsDlg(dlgpreferences.DlgPreferencesFlatTree):
-
- def __init__(self, parent):
-
- pages = PrefsPageRoot()(
- PrefsPageGlobal(),
- PrefsPageBrowser(),
-
- )
-
- dlgpreferences.DlgPreferencesFlatTree.__init__(self,
- parent,
- pages=pages,
- startPage=PrefsPageGlobal.UUID,
- )
- self.fcSettings = Settings(self).restore()
-
-
- def showEvent(self, event):
- self.restoreState(self.fcSettings.value('DlgState'))
-
- def hideEvent(self, event):
- self.fcSettings.setValues(DlgState=self.saveState())
-
- def closeEvent(self, event):
- pass
-
-
-#**********************************************************************************
-#
-#**********************************************************************************
-if __name__ == '__main__':
- import sys
-
- app = QtGui.QApplication(sys.argv)
- w = PrefsDlg(None)
- w.show()
- res = app.exec_()
- sys.exit(res)
-
-
Deleted: trunk/fclient/src/fclient/Ui_PrefsBrowserWidget.py
===================================================================
--- trunk/fclient/src/fclient/Ui_PrefsBrowserWidget.py 2008-07-27 11:20:49 UTC (rev 763)
+++ trunk/fclient/src/fclient/Ui_PrefsBrowserWidget.py 2008-07-27 11:22:45 UTC (rev 764)
@@ -1,113 +0,0 @@
-
-from __future__ import absolute_import
-if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
- import os; __path__ = [os.path.dirname(__file__)]
-
-
-from PyQt4 import QtCore, QtGui
-
-from . import config
-from .lib.qt4ex import dlgpreferences
-
-from .tpls.Ui_PrefsBrowserWidgetTpl import Ui_PrefsBrowserWidget
-#**********************************************************************************
-#
-#**********************************************************************************
-class PrefsBrowserWidget(QtGui.QWidget, Ui_PrefsBrowserWidget):
-
- IdEdHomePage = 'edHomePage'
- IdCkOpenAddressBarInNewTab = 'ckOpenAddressBarInNewTab'
- IdCkOpenBookmarksInNewTab = 'ckOpenBookmarksInNewTab'
- IdCkOpenLinksInNewTab = 'ckOpenLinksInNewTab'
- IdCkOpenHomePageOnNewTabCreated = 'ckOpenHomePageOnNewTabCreated'
- IdCkBackIsClose = 'ckBackIsClose'
- IdCkAutoLoadImages = 'ckAutoLoadImages'
-
- def __init__(self, parent):
- QtGui.QWidget.__init__(self, parent)
- self.setupUi(self)
-
- browser = config.ObjectRegistry.get(config.IdViewBrowserWidget, None)
- self.setEnabled(browser is not None)
- if browser is not None:
- self.controlById(self.IdEdHomePage).setText(browser.fcSettings.value('HomePage'))
- ck = self.controlById(self.IdCkOpenAddressBarInNewTab)
- ck.setCheckState(QtCore.Qt.Checked if browser.fcSettings.value('OpenAddressBarInNewTab') else QtCore.Qt.Unchecked)
- ck = self.controlById(self.IdCkOpenBookmarksInNewTab)
- ck.setCheckState(QtCore.Qt.Checked if browser.fcSettings.value('OpenBookmarksInNewTab') else QtCore.Qt.Unchecked)
- ck = self.controlById(self.IdCkOpenLinksInNewTab)
- ck.setCheckState(QtCore.Qt.Checked if browser.fcSettings.value('OpenLinksInNewTab') else QtCore.Qt.Unchecked)
- ck = self.controlById(self.IdCkOpenHomePageOnNewTabCreated)
- ck.setCheckState(QtCore.Qt.Checked if browser.fcSettings.value('OpenHomePageOnNewTabCreated') else QtCore.Qt.Unchecked)
- ck = self.controlById(self.IdCkBackIsClose)
- ck.setCheckState(QtCore.Qt.Checked if browser.fcSettings.value('BackIsClose') else QtCore.Qt.Unchecked)
- ck = self.controlById(self.IdCkAutoLoadImages)
- ck.setCheckState(QtCore.Qt.Checked if browser.fcSettings.value('AutoLoadImages') else QtCore.Qt.Unchecked)
-
- def controlById(self, idControl):
- return getattr(self, idControl)
-
- def apply(self):
- browser = config.ObjectRegistry.get(config.IdViewBrowserWidget, None)
- if browser is not None:
- edHomePage = self.controlById(self.IdEdHomePage)
-
- browser.fcSettings.setValues(
- HomePage=edHomePage.text(),
- OpenAddressBarInNewTab=self.controlById(self.IdCkOpenAddressBarInNewTab).checkState() == QtCore.Qt.Checked,
- OpenBookmarksInNewTab=self.controlById(self.IdCkOpenBookmarksInNewTab).checkState() == QtCore.Qt.Checked,
- OpenLinksInNewTab=self.controlById(self.IdCkOpenLinksInNewTab).checkState() == QtCore.Qt.Checked,
- OpenHomePageOnNewTabCreated=self.controlById(self.IdCkOpenHomePageOnNewTabCreated).checkState() == QtCore.Qt.Checked,
- BackIsClose=self.controlById(self.IdCkBackIsClose).checkState() == QtCore.Qt.Checked,
- AutoLoadImages=self.controlById(self.IdCkAutoLoadImages).checkState() == QtCore.Qt.Checked,
- )
-
-
-#***********************************************************************
-#
-#***********************************************************************
-class PrefsPageBrowser(dlgpreferences.Page):
-
- UUID = '{c85e63a8-6806-435a-81ce-f4b46872246f}'
-
- def __init__(self):
- dlgpreferences.Page.__init__(self, self.UUID)
- self._widget = None
- self.setDirty(True)
-
- def displayName(self):
- return self.trUtf8('Browser')
-
- def canApply(self): return True
- def canHelp(self): return True
-
- def setVisible(self, parent, flag):
- createdNew = False
- if flag and self._widget is None:
- createdNew = True
- self._widget = PrefsBrowserWidget(parent)
- self._widget.setVisible(flag)
- return (createdNew, self._widget)
-
-
- def doApply(self):
- self._widget.apply()
- return True
-
- def doOk(self):
- return True
-
-
-#***********************************************************************
-#
-#***********************************************************************
-if __name__ == '__main__':
- from PyQt4 import QtGui
- import sys
-
- app = QtGui.QApplication(sys.argv)
- w = PrefsBrowserWidget(None)
- w.show()
- res = app.exec_()
- sys.exit(res)
-
Deleted: trunk/fclient/src/fclient/Ui_PrefsGlobal.py
===================================================================
--- trunk/fclient/src/fclient/Ui_PrefsGlobal.py 2008-07-27 11:20:49 UTC (rev 763)
+++ trunk/fclient/src/fclient/Ui_PrefsGlobal.py 2008-07-27 11:22:45 UTC (rev 764)
@@ -1,62 +0,0 @@
-
-from __future__ import absolute_import
-if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
- import os; __path__ = [os.path.dirname(__file__)]
-
-
-from PyQt4 import QtGui
-
-from . import config
-from .lib.qt4ex import dlgpreferences
-
-from .tpls.Ui_PrefsGlobalWidgetTpl import Ui_PrefsGlobalWidget
-#**********************************************************************************
-#
-#**********************************************************************************
-class PrefsGlobalWidget(QtGui.QWidget, Ui_PrefsGlobalWidget):
-
- def __init__(self, parent):
- QtGui.QWidget.__init__(self, parent)
- self.setupUi(self)
-
-#***********************************************************************
-#
-#***********************************************************************
-class PrefsPageGlobal(dlgpreferences.Page):
-
- UUID = '{ba654bd8-4c63-11dd-b8b1-a11c9b5c3981}'
-
- def __init__(self):
- dlgpreferences.Page.__init__(self, self.UUID)
- self._widget = None
- self.setDirty(True)
-
- def displayName(self):
- return self.trUtf8('Global')
-
- def canApply(self): return True
- def canHelp(self): return True
-
- def setVisible(self, parent, flag):
- createdNew = False
- if flag and self._widget is None:
- createdNew = True
- self._widget = PrefsGlobalWidget(parent)
- self._widget.setVisible(flag)
- return (createdNew, self._widget)
-
-
-
-#***********************************************************************
-#
-#***********************************************************************
-if __name__ == '__main__':
- from PyQt4 import QtGui
- import sys
-
- app = QtGui.QApplication(sys.argv)
- w = PrefsGlobalWidget(None)
- w.show()
- res = app.exec_()
- sys.exit(res)
-
Deleted: trunk/fclient/src/fclient/Ui_View.py
===================================================================
--- trunk/fclient/src/fclient/Ui_View.py 2008-07-27 11:20:49 UTC (rev 763)
+++ trunk/fclient/src/fclient/Ui_View.py 2008-07-27 11:22:45 UTC (rev 764)
@@ -1,277 +0,0 @@
-#FIXES
-#***************************************************************************
-# [0001]
-#
-# QTabWidget.closeEvent() does not seem to propagate close events
-# to child widgets
-#
-#
-#***************************************************************************
-from __future__ import absolute_import
-if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
- import os; __path__ = [os.path.dirname(__file__)]
-
-
-from PyQt4 import QtCore, QtGui
-
-
-from . import config
-from .lib import fcp2
-from .tpls.Ui_ViewWidgetTpl import Ui_ViewWidget
-#**********************************************************************************
-#
-#**********************************************************************************
-class Actions(config.ActionsBase):
-
- def __init__(self, parent):
- config.ActionsBase.__init__(self, parent)
-
- self.action(
- name='ActionShowTopTabBar',
- text=self.trUtf8('Show top &tabs'),
- trigger=parent.onActionShowTabsTop,
- isCheckable=True,
- isChecked=True,
- )
-
-
-class GlobalFeedback(config.GlobalFeedbackBase):
- """wrapper for global statusbar widgets, menus"""
-
- def __init__(self, parent, idGlobalFeedback):
- config.GlobalFeedbackBase.__init__(self, parent, idGlobalFeedback)
-
- # menus
- self.menus = []
- if self.menuBar is not None and hasattr(parent, 'fcViewObject'):
- menu = QtGui.QMenu(parent.fcViewObject.displayName, self.menuBar)
- parent.populateMenu(menu)
- self.menus.append(menu)
- self.menuBar.addViewMenu(menu)
-
- def setVisible(self, flag):
- for menu in self.menus:
- menu.children()[0].setVisible(flag)
-
-
-
-class Settings(config.SettingsBase):
- _key_ = config.IdViewWidget
- _settings_ = (
- ('LastViewTop', 'String', '', config.SettingScopePrivate),
- ('LastViewBottom', 'String', '', config.SettingScopePrivate),
- ('SplitterPos', 'ByteArray', QtCore.QByteArray(), config.SettingScopePrivate),
- ('ShowTopTabBar', 'Bool', True, config.SettingScopePrivate),
-
- )
-
-
-class ViewObject(config.ViewObject):
-
- def __init__(self, parent):
- config.ViewObject. __init__(self, parent)
-
- self.name=parent.objectName()
- self.displayName=self.trUtf8('View')
- self.icon=QtGui.QIcon()
-
-#***********************************************************************
-#
-#***********************************************************************
-class ViewWidget(QtGui.QWidget, Ui_ViewWidget):
-
- IdSplitter = 'Splitter'
- IdTabTop = 'tabTop'
- IdTabBottom = 'tabBottom'
-
-
- def __init__(self, parent, idGlobalFeedback=config.IdMainWindow):
- QtGui.QWidget.__init__(self, parent)
-
- self._isCreated = False
-
- self.views = {}
-
- self.setupUi(self)
- config.ObjectRegistry.register(self)
- self.fcActions = Actions(self)
- self.fcSettings = Settings().restore()
- self.fcViewObject = ViewObject(self)
- self.fcGlobalFeedback = GlobalFeedback(self, idGlobalFeedback)
-
- # setup tab widgets
- tabWidgetTop = self.controlById(self.IdTabTop)
- tabWidgetTop.removeTab(0)
- tabWidgetBottom = self.controlById(self.IdTabBottom)
- tabWidgetBottom.removeTab(0)
-
- # setup splitter
- splitter = self.controlById(self.IdSplitter)
- splitter.restoreState(self.fcSettings.value('SplitterPos'))
- self.connect(splitter, QtCore.SIGNAL('splitterMoved(int, int)'), self.onSplitterMoved)
-
- # setup actions
- showTopTabBar = self.fcSettings.value('ShowTopTabBar')
- self.fcActions['ActionShowTopTabBar'].setChecked(showTopTabBar)
- tabWidgetTop.tabBar().setVisible(showTopTabBar)
-
-
-
- def controlById(self, idControl):
- return getattr(self, idControl)
-
-
- def _addViews(self, toTop, *views):
- tabWidget = self.controlById(self.IdTabTop) if toTop else self.controlById(self.IdTabBottom)
- for view in views:
- name = view.fcViewObject.name
- if not name:
- raise ValueError('view must have a name')
- if name in self.views:
- raise ValueError('view with that name is already present: %s' % name)
- view.setParent(tabWidget)
- i = tabWidget.addTab(view, view.fcViewObject.icon, view.fcViewObject.displayName)
- self.views[name] = (tabWidget, view)
-
- #tab.tabBar().setVisible(tab.count() > 1)
-
-
- def addBottomViews(self, *views):
- return self._addViews(False, *views)
-
-
- def addTopViews(self, *views):
- return self._addViews(True, *views)
-
-
- def populateMenu(self, menu):
- menu.addAction(self.fcActions['ActionShowTopTabBar'])
- return menu
-
-
-
- def setCurrentView(self, name):
- result = self.views.get(name, None)
- if result is not None:
- tab, view = result
- tab.setCurrentWidget(view)
- return True
- return False
-
-
- def viewFromName(self, name):
- result = self.views.get(name, None)
- if result is not None:
- return result[1]
- return None
-
- #########################################################
- ##
- #########################################################
- def hideEvent(self, event):
- self.fcGlobalFeedback.setVisible(False)
-
-
- def showEvent(self, event):
- self.fcGlobalFeedback.setVisible(True)
-
-
- #########################################################
- ##
- #########################################################
- def closeEvent(self, event):
- for tab, view in self.views.values():
- view.viewClose()
-
-
- def showEvent(self, event):
- if self._isCreated:
- return
- self._isCreated = True
-
- # restore current views
- tabWidgetTop = self.controlById(self.IdTabTop)
- lastName = self.fcSettings.value('LastViewTop')
- self.setCurrentView(lastName)
-
- tabWidgetBottom = self.controlById(self.IdTabBottom)
- lastName = self.fcSettings.value('LastViewBottom')
- self.setCurrentView(lastName)
-
- # finally connect... not to overwrite settings
- self.connect(tabWidgetTop, QtCore.SIGNAL('currentChanged(int)'), self.onTabTopCurrentChanged)
- self.connect(tabWidgetBottom, QtCore.SIGNAL('currentChanged(int)'), self.onTabBottomCurrentChanged)
-
- #########################################################
- ##
- #########################################################
- def onActionShowTabsTop(self, action):
- tabWidgetTop = self.controlById(self.IdTabTop)
- tabWidgetTop.tabBar().setVisible(action.isChecked())
- self.fcSettings.setValues(ShowTopTabBar=action.isChecked())
-
-
- def onSplitterMoved(self, pos, index):
- splitter = self.controlById(self.IdSplitter)
- self.fcSettings.setValues(SplitterPos=splitter.saveState())
-
-
- def onTabTopCurrentChanged(self, index):
- tabWidget = self.controlById(self.IdTabTop)
- view = tabWidget.currentWidget()
- self.fcSettings.setValues(LastViewTop=view.fcViewObject.name)
-
-
- def onTabBottomCurrentChanged(self, index):
- tab = self.controlById(self.IdTabBottom)
- view = tab.currentWidget()
- self.fcSettings.setValues(LastViewBottom=view.fcViewObject.name)
-
-#**********************************************************************************
-#
-#**********************************************************************************
-#NOTE: to self. no need to register views to config.ObjectRegistry. they are just
-# opaque objects private to ViewWidget
-class View(object):
- """base class for views ond by L{ViewWidget}"""
-
- def __init__(self):
- raise NotImplemetedError()
-
- def viewClose(self):
- """called when the view is about to be closed"""
-
- def viewDisplayName(self):
- """should return the user visible name of the view
- @return: (QString)
- """
- raise NotImplemetedError()
-
-
- def viewIcon(self):
- """should return the icon associated to the view
- @return: (QIcon)
- """
- raise NotImplemetedError()
-
- def viewName(self):
- """should return the internally used id of the view
- @return: (str) id
- """
- raise NotImplemetedError()
-
-#**********************************************************************************
-#
-#**********************************************************************************
-if __name__ == '__main__':
- import sys
-
- app = QtGui.QApplication(sys.argv)
- w = ViewWidget(None)
- w.show()
- res = app.exec_()
- sys.exit(res)
-
-
-
-
Deleted: trunk/fclient/src/fclient/Ui_ViewBrowser.py
===================================================================
--- trunk/fclient/src/fclient/Ui_ViewBrowser.py 2008-07-27 11:20:49 UTC (rev 763)
+++ trunk/fclient/src/fclient/Ui_ViewBrowser.py 2008-07-27 11:22:45 UTC (rev 764)
@@ -1,1030 +0,0 @@
-#******************************************************************************************
-#TODO:
-# x. someday. maybe. reimpl to browse via fcp.
-# x. page history is cleared if we get an error on loading a page. reimpl page history?
-# x. back-is-close like behaviour
-# x. backand forward buttons suck somehow. sometimes fwd is enabled even if no fwd is available. reimpl page history?
-# x. save page to disk
-# x. download. idea is to add dls to global download widget and mark them (some color code) as new content.
-# alt would be to to do it firefox like in a separate widget. maybe an option to adjust if browser dls should be
-# persistent or not
-# x. tool buttons do not adjust their size to icon size. maybe it is some global setting via qt-config
-# x. fProxy is a bit tight-lipped when it comes to feedback. no idea
-# x. give feedback on tabs about load / finisched / error. maybe some color code. wait for new QTabWidget features (qt4.5)
-# x. close button on tabs. wait for new QTabWidget features (qt4.5)
-# x. page actions: CopyImageToClipboard,
-# x. when mouse pointer is over an opend image a magnifier cursor appears. no idea how this is handled
-# x. open new tab on tab bar double click. IIRC looks like no way before qt4.5. tabBars are not stretched to fit in qt4.4
-# x. global feedback on statusbar flickers. reason: first label is holds arbitrary length text
-# x. fproxy. "force browser to dl" should we dl it in downloads or store emidiately? no idea
-# x. visiting plugins via fproxy does not work
-# x. real toolbars
-# x. remove host/port from urls?
-# x. browser settings - QWebSettings
-# x. shortcuts
-# x. user staring gui for first time. maybe we should not connext untill the user connects explicitely
-#******************************************************************************************
-"""
-
-@newfield signal: signal, signals
-"""
-from __future__ import absolute_import
-if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
- import os; __path__ = [os.path.dirname(__file__)]
-
-from PyQt4 import QtCore, QtGui, QtWebKit
-
-from . import config
-
-from .lib import fcp2
-from .lib.qt4ex.lib import tools as qtools
-from .lib.compactpath.qt4 import pathlabelwrap
-
-from . import Ui_DlgPropsBrowserObject
-from . import Ui_DlgDownloadKeyToDisk
-from .tpls.Ui_ViewBrowserWidgetTpl import Ui_ViewBrowserWidget
-#*****************************************************************************************
-#
-#*****************************************************************************************
-class Page(QtWebKit.QWebPage):
- def __init__(self, parent):
- QtWebKit.QWebPage.__init__(self, parent)
-
- #def acceptNavigationRequest(self, frame, request, typeRequest):
- # return True
-
-#*****************************************************************************************
-#
-#*****************************************************************************************
-class Browser(QtWebKit.QWebView):
- """ browser customized for freenet
- """
-
- MaxProgress = 100
-
- def __init__(self, parent=None, userData=None):
- QtWebKit.QWebView.__init__(self, parent)
-
- page = Page(self)
- self.setPage(page)
-
- #NOTE: we store last progress made to set busy cursor accordingly
- self._lastProgress = 0
- self._userData = userData
-
- # connect actions
- self.connect(self, QtCore.SIGNAL('loadStarted()'), self.onLoadStarted)
- self.connect(self, QtCore.SIGNAL('loadProgress(int)'), self.onLoadProgress)
- self.connect(self, QtCore.SIGNAL('loadFinished(bool)'), self.onLoadFinished)
- self.connect(self.pageAction(QtWebKit.QWebPage.Stop), QtCore.SIGNAL('triggered()'), self.onActionStopTriggered)
-
- ################################
- ## methods
- ################################
- #def createWindow(self, typeWindow):
- # pass
-
- def load(self, url):
- self._lastProgress = 0
- return QtWebKit.QWebView.load(self, url)
-
- def setLastStatusMessage(self, qString):
- self._lastStatusMessage = qString
-
- def setUrl(self, url):
- return self.load(url)
-
- def setContents(self, *args):
- """sets the contents of the browser without changing its url"""
- self._lastProgress = 0
- return QtWebKit.QWebView.setContents(self, *args)
-
- def setHtml(self, *args):
- """sets the contents of the browser without changing its url"""
- self._lastProgress = 0
- return QtWebKit.QWebView.setHtm(self, *args)
-
- def setPage(self, page):
- """sets the contents of the browser without changing its url"""
- self._lastProgress = 0
- return QtWebKit.QWebView.setPage(self, page)
-
- def setUserData(self, userData):
- self._userData = userData
-
- def mouseMoveEvent(self, event):
- if self._lastProgress < self.MaxProgress:
- self.setCursor(QtCore.Qt.BusyCursor)
- else:
- QtWebKit.QWebView.mouseMoveEvent(self, event)
-
- def userData(self):
- return self._userData
-
- ###############################
- ## event handlers
- ###############################
- def onActionStopTriggered(self):
- # check wich cursor to set cos we may have busy cursor set
- pt = self.mapFromGlobal(self.cursor().pos()) #TODO: self.mapFromGlobal(self.viewPort().cursor().pos()) ??
- frame = self.page().currentFrame()
- hitTest = frame.hitTestContent(pt)
- #if not hitTest.isNull(): #TODO: looks like hitTest.isNull() alwas returns True
- if hitTest.linkUrl().isValid():
- self.setCursor(QtCore.Qt.PointingHandCursor)
- else:
- self.setCursor(QtCore.Qt.ArrowCursor)
-
- def onLoadStarted(self):
- self._lastProgress = 0
-
- def onLoadProgress(self, n):
- self._lastProgress = n
-
- def onLoadFinished(self):
- self._lastProgress = self.MaxProgress
- self.onActionStopTriggered()
-
- def onPageDownloadRequested(self, networkRequest):
- self.emit(QtCore.SIGNAL('downloadRequested(const QNetworkRequest &)'), networkRequest)
-
-#**********************************************************************************
-#
-#**********************************************************************************
-class BrowserWidgetGlobalFeedback(config.GlobalFeedbackBase):
- """wrapper for global statusbar widgets, menus"""
-
- def __init__(self, parent, idGlobalFeedback):
- config.GlobalFeedbackBase.__init__(self, parent, idGlobalFeedback)
-
- # menus
- self.menus = []
- if self.menuBar is not None and hasattr(parent, 'fcViewObject'):
- menu = QtGui.QMenu(parent.fcViewObject.displayName, self.menuBar)
- parent.populateMenu(menu)
- self.menus.append(menu)
- self.menuBar.addViewMenu(menu)
-
- # status bar widgets
- self.labelStatus = None
- self.progress = None
- self.labelFeedbackWrap = None
- if self.statusBar is not None:
- self.labelStatus = QtGui.QLabel(QtCore.QString(), self.statusBar)
- self.statusBar.addWidget(self.labelStatus)
-
- self.progress = QtGui.QProgressBar(self.statusBar)
- self.progress.setRange(0, Browser.MaxProgress)
- self.progress.setValue(0)
- self.statusBar.addWidget(self.progress)
-
- label = QtGui.QLabel(self.statusBar)
- label.setFrameStyle(QtGui.QLabel.Sunken | QtGui.QLabel.Box)
- self.labelFeedbackWrap = pathlabelwrap.PathLabelWrap(
- label,
- path_module=config.CompactPathFcpKeyModule,
- )
- self.statusBar.addWidget(self.labelFeedbackWrap.label, 1)
-
-
- def setVisible(self, flag):
- if self.menuBar is not None:
- for menu in self.menus:
- menu.children()[0].setVisible(flag)
- if self.statusBar is not None:
- self.progress.setVisible(flag)
- self.labelStatus.setVisible(flag)
- self.labelFeedbackWrap.label.setVisible(flag)
-
- def setProgress(self, n):
- if self.progress is not None:
- self.progress.setValue(n)
-
- def setStatusMessage(self, qString):
- if self.labelStatus is not None:
- self.labelStatus.setText(qString)
-
- def setFeedback(self, qString):
- if self.labelFeedbackWrap is not None:
- self.labelFeedbackWrap.setPath(unicode(qString))
-
-
-class BrowserWidgetViewObject(config.ViewObject):
-
- def __init__(self, parent):
- config.ViewObject. __init__(self, parent)
-
- self.name=parent.objectName()
- self.displayName=self.trUtf8('Browser')
- self.icon=QtGui.QIcon()
-
-
-class BrowserWidgetSettings(config.SettingsBase):
- _key_ = config.IdViewBrowserWidget
- _settings_ = (
- ('OpenLinksInNewTab', 'Bool', False, config.SettingScopeUser),
- ('OpenAddressBarInNewTab', 'Bool', False, config.SettingScopeUser),
- ('OpenBookmarksInNewTab', 'Bool', False, config.SettingScopeUser),
- ('OpenHomePageOnNewTabCreated', 'Bool', False, config.SettingScopeUser),
- ('BackIsClose', 'Bool', False, config.SettingScopeUser), #TODO: not implemented
- ('HomePage', 'String', QtCore.QString(), config.SettingScopeUser),
- ('IconSize', 'UInt', 32, config.SettingScopeUser),
- ('IconTheme', 'String', QtCore.QString('crystal'), config.SettingScopeUser),
- ('AutoLoadImages', 'Bool', True, config.SettingScopeUser), #TODO: not yet implemented
- ('MaxTabText', 'UInt', 20, config.SettingScopeUser), #NOTE: make shure Max >= Min and Max and Min > 0
- ('MinTabText', 'UInt', 7, config.SettingScopeUser),
- )
-
- def setValues(self, **kws):
- autoLoadImages = kws.get('AutoLoadImages', None)
- if autoLoadImages is not None:
- browserWidget = self.parent()
- tabWidget = browserWidget.controlById(browserWidget.IdTabBrowsers)
- for i in xrange(tabWidget.count()):
- browser = tabWidget.widget(i)
- settings = browser.settings()
- settings.setAttribute(settings.AutoLoadImages, autoLoadImages)
- config.SettingsBase.setValues(self, **kws)
-
- #backIsClose = kws.get('BackIsClose', None)
- #if backIsClose is not None:
- # self.parent()._adjustBackIsClose()
-
-
-
-class BrowserWidgetActions(config.ActionsBase):
-
- def __init__(self, parent):
- config.ActionsBase.__init__(self, parent)
-
- iconSize = parent.fcSettings.value('IconSize')
- iconTheme = parent.fcSettings.value('IconTheme')
-
- self.action(
- name='ActionCloseCurrentTab',
- text=self.trUtf8('Close ¤t tab'),
- trigger=parent.onCloseCurrentTab,
- )
- self.action( # context menu only
- name='ActionCloseBrowserUnderMouse',
- text=self.trUtf8('&Close tab'),
- trigger=None,
- )
- self.action(
- name='ActionCloseAllTabs',
- text=self.trUtf8('Close &all tabs'),
- trigger=parent.onCloseAllTabs,
- )
- self.action(
- name='ActionOpenNewTab',
- text=self.trUtf8('Open &new tab'),
- trigger=parent.onOpenNewTab,
- )
- self.action(
- name='ActionGoToFProxy',
- text=self.trUtf8('Go to f&Proxy homepage'),
- trigger=parent.onGoToFProxy,
- )
- self.action(
- name='ActionGoToHomePage',
- text=self.trUtf8('Go to &homepage'),
- trigger=parent.onGoToHomePage,
- )
- self.action(
- name='ActionObjectProperties',
- text=self.trUtf8('Properties..'),
- trigger=None,
- )
- self.action(
- name='ActionZoomIn',
- text=self.trUtf8('Zoom in'),
- trigger=parent.onZoomIn,
- )
- self.action(
- name='ActionZoomOut',
- text=self.trUtf8('Zoom out'),
- trigger=parent.onZoomOut,
- )
-
- # default browser actions
- self.action(
- name='ActionBack',
- text=self.trUtf8('Back'),
- trigger=None,
- isEnabled=False,
- icon=config.resources.getIcon('back', iconSize, iconTheme=iconTheme),
- userData=(None, None),
- )
- self.action(
- name='ActionForward',
- text=self.trUtf8('Forward'),
- trigger=None,
- isEnabled=False,
- icon=config.resources.getIcon('forward', iconSize, iconTheme=iconTheme),
- userData=(None, None),
- )
- self.action(
- name='ActionReload',
- text=self.trUtf8('Reload'),
- trigger=None,
- isEnabled=False,
- icon=config.resources.getIcon('reload_page', iconSize, iconTheme=iconTheme),
- userData=(None, None),
- )
- self.action(
- name='ActionStop',
- text=self.trUtf8('Stop'),
- trigger=None,
- isEnabled=False,
- icon=config.resources.getIcon('stop', iconSize, iconTheme=iconTheme),
- userData=(None, None),
- )
-
- self.action(
- name='ActionBackIsClose',
- text=self.trUtf8('Back is close'),
- icon=config.resources.getIcon('button_cancel', iconSize, iconTheme=iconTheme),
- trigger=None,
- )
-
- # search actions
- self.action(
- parent=parent,
- name='ActionSearch',
- text=self.trUtf8('Search'),
- shortcut=QtGui.QKeySequence(self.trUtf8('Ctrl+F')),
- trigger=parent.onSearch,
- )
-
- def intertwineBrowserActions(self, browser=None):
- """intertwines Browser actions with BrowserWidget actions
- @note: call everytime the current browser changes
- """
- actions = (
- ('ActionBack', QtWebKit.QWebPage.Back),
- ('ActionForward', QtWebKit.QWebPage.Forward),
- ('ActionReload', QtWebKit.QWebPage.Reload),
- ('ActionStop', QtWebKit.QWebPage.Stop),
- )
- for actionName, pageAction in actions:
- myPageAction = self[actionName]
- newPageAction = None if browser is None else browser.pageAction(pageAction)
- oldPageAction, cb = myPageAction.userData()
-
- if oldPageAction is not None:
- myPageAction.disconnect(oldPageAction, QtCore.SIGNAL('changed()'), cb)
- oldPageAction.disconnect(myPageAction, QtCore.SIGNAL('triggered()'), oldPageAction.trigger)
-
- if newPageAction is None:
- myPageAction.setUserData((None, None))
- myPageAction.setEnabled(False)
- else:
- def onActionChanged(browser=browser, myPageAction=myPageAction, browserPageAction=newPageAction):
- myPageAction.setEnabled(browserPageAction.isEnabled())
-
- myPageAction.setEnabled(newPageAction.isEnabled())
- myPageAction.setUserData((newPageAction, onActionChanged))
- myPageAction.connect(newPageAction, QtCore.SIGNAL('changed()'), onActionChanged)
- newPageAction.connect(myPageAction, QtCore.SIGNAL('triggered()'), newPageAction.trigger)
-
-
-class LastBrowserState(object):
- """records the last known state browser"""
-
- __slots__ = ('icon', 'progress', 'statusMessage', 'title', 'url')
-
- def __init__(self, icon=None, progress=0, statusMessage=None, title=None, url=None):
- self.progress = 0
- self.icon = tCore.QIcon() if icon is None else icon
- self.statusMessage = QtCore.QString() if statusMessage is None else statusMessage
- self.title = QtCore.QString() if title is None else title
- #NOTE: opening a browser in a new tab may take a while to load.
- # self.url() will return '' untill the page is found, so we handle
- # it ourself and keep track of the last known url in self._lastUrl
- # to give feedback to the user on the navbar. downside is we have
- # to reimplement contextMenuEvent() :-(
- self.url = QtCore.QUrl() if url is None else url
-
-#**********************************************************************************
-#
-#**********************************************************************************
-#TODO: strip host:port on address bar?
-#TODO: rename home page to start page
-class ViewBrowserWidget(QtGui.QWidget, Ui_ViewBrowserWidget):
-
- IdTabBrowsers = 'tabBrowsers'
- IdFrameTools = 'frameTools'
- IdFrameAddressBar = 'frameAddressBar'
- IdEdAddressBar = 'edAddressBar'
-
- IdBtBack = 'btBack'
- IdBtForward = 'btForward'
- IdBtReload = 'btReload'
- IdBtStop = 'btStop'
-
- IdFrameSearch = 'frameSearch'
- IdEdSearch = 'edSearch'
- IdBtSearchUpwards = 'btSearchUpwards'
- IdBtSearchDownwards = 'btSearchDownwards'
- IdCkSearchCaseSensitive = 'ckSearchCaseSensitive'
-
- ForcedMinBrowserTabText = 5 # forced minimum number of chars on browser tabBar
-
- def __init__(self, parent, idGlobalFeedback=config.IdMainWindow):
- QtGui.QWidget.__init__(self, parent)
-
- self.setupUi(self)
- config.ObjectRegistry.register(self)
-
- self._initialConfigDataArrived = False
-
- self.fcSettings = BrowserWidgetSettings(self).restore()
- self.fcActions = BrowserWidgetActions(self)
- self.fcViewObject = BrowserWidgetViewObject(self)
- self.fcGlobalFeedback = BrowserWidgetGlobalFeedback(self, idGlobalFeedback)
-
- # setup tab bar
- tabWidget = self.controlById(self.IdTabBrowsers)
- tabWidget.clear()
- tabWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
- self.connect(tabWidget, QtCore.SIGNAL('currentChanged(int)'), self.onTabCurrentChanged)
- self.connect(tabWidget, QtCore.SIGNAL('customContextMenuRequested(const QPoint &)'), self.onTabContextMenuEvent)
-
- # setup addressbar
- addressbar = self.controlById(self.IdEdAddressBar)
- self.connect(addressbar, QtCore.SIGNAL('returnPressed()'), self.onNavBarReturnPressed)
-
- # setup tool buttons
- self.controlById(self.IdBtBack).setDefaultAction(self.fcActions['ActionBack'])
- self.controlById(self.IdBtForward).setDefaultAction(self.fcActions['ActionForward'])
- self.controlById(self.IdBtReload).setDefaultAction(self.fcActions['ActionReload'])
- self.controlById(self.IdBtStop).setDefaultAction(self.fcActions['ActionStop'])
-
- # setupp search bar
- bt = self.controlById(self.IdBtSearchUpwards)
- self.connect(bt, QtCore.SIGNAL('clicked()'), self.onSearchUpwards)
- bt = self.controlById(self.IdBtSearchDownwards)
- self.connect(bt, QtCore.SIGNAL('clicked()'), self.onSearchDownwards)
- ed = self.controlById(self.IdEdSearch)
- self.connect(ed, QtCore.SIGNAL('returnPressed()'), self.onSearchDownwards)
- frameSearch = self.controlById(self.IdFrameSearch)
- frameSearch.setVisible(False)
-
- # fire up a new broser to make a start
- self.newBrowser(title=self.trUtf8('Waiting for fproxy'))
- self.fcActions['ActionGoToHomePage'].trigger()
-
- #########################################
- ## private methods
- #########################################
- #NOTE: to reduce flicker set min size to max size
- def _adjustTabText(self, qString):
- maxTabText = self.fcSettings.value('MaxTabText')
- minTabText = self.fcSettings.value('MinTabText')
- ellipsis = self.trUtf8('..')
-
- if minTabText < self.ForcedMinBrowserTabText:
- minTabText = self.ForcedMinBrowserTabText
- self.fcSettings.setValues(MinTabText=minTabText)
- if maxTabText < self.ForcedMinBrowserTabText:
- maxTabText = self.ForcedMinBrowserTabText
- self.fcSettings.setValues(MaxTabText=maxTabText)
- if minTabText > maxTabText:
- minTabText = maxTabText
- self.fcSettings.setValues(MinTabText=maxTabText)
-
- if qString.count() < minTabText:
- qString = qString.append('\x20' * (minTabText - qString.count()))
- else:
- if maxTabText < self.ForcedMinBrowserTabText:
- maxTabText = sminTabText
- qString = qtools.truncateString(maxTabText, qString, ellipsis)
- return qString
-
- def _downloadImageToDisk(self, hitTestResult):
- px = hitTestResult.pixmap()
- if px.isNull():
- return False
-
- key = config.qStringToFcpKey(hitTestResult.imageUrl().toString())
- if key is None:
- return False
-
- # thow a dialog box at the user to select a filename
- # ..qt seems to place the filename part as suggestion into the filename box. so try it
- caption = config.FclientAppName + self.trUtf8(' - Save Image To..')
- directory = unicode(config.settings.value('DownloadDir'))
- fileName = unicode(config.guessFileNameFromKey(key, default=QtCore.QString('')))
-
- if directory and fileName:
- directory = os.path.join(directory, fileName)
- elif not directory:
- directory = fileName
- filePath = QtGui.QFileDialog.getSaveFileName(self, caption, directory)
-
- if filePath:
- filePath= unicode(filePath)
- if os.path.exists(filePath):
- try:
- os.remove(filePath)
- except Exception, details:
- QtGui.QMessageBox.critical(
- self,
- caption,
- self.trUtf8('Could not remove file'), #NOTE: no details please, may contain arbitrary lenght filepath
- )
- return False
- px.save(filePath)
- return True
-
- def _downloadKeyToDisk(self, qUrl):
- """
- @return: (bool) False if the key in the url is invalid, True otherwise
- """
- fcpKey = config.qStringToFcpKey(QtCore.QString(qUrl.encodedPath()))
- if fcpKey is not None:
- dlg = Ui_DlgDownloadKeyToDisk.DownloadKeyToDiskDlg(self, fcpKey=fcpKey)
- if dlg.exec_() == dlg.Accepted:
- filePath = dlg.filePath()
- downloadsWidget = config.ObjectRegistry.get(config.IdViewCDownloadsWidget, None)
- if downloadsWidget is None:
- raise ValueError('no downloads widget found')
- downloadsWidget.downloadFile(
- fcpKey,
- filePath,
- persistence=fcp2.ConstPersistence.Forever,
- handleFilenameCollision=True,
-
- )
- return True
- return False
-
- #########################################
- ## methods
- #########################################
- def controlById(self, idControl):
- return getattr(self, idControl)
-
- def currentBrowser(self):
- """returns the current browser or None"""
- tabWidget = self.controlById(self.IdTabBrowsers)
- return tabWidget.currentWidget()
-
- def load(self, url, force=False, browser=None):
- """loads an url in the current browser. if there is no current browser, a new browser is created
- @param force: (bool) if True, a new browser is opend if there is no browser available
- @param browser: browser to load the url in or None to use the current browser
- @return: (bool)
- """
- browser = self.currentBrowser() if browser is None else browser
- tabWidget = self.controlById(self.IdTabBrowsers)
- addressBar = self.controlById(self.IdEdAddressBar)
- url = QtCore.QUrl(url)
-
- # check if we have a browser at hand
- if force and browser is None:
- browser = self.newBrowser()
- if browser is None:
- return False
-
- # load url
- url.setScheme('http')
- url.setHost(config.settings.value('FproxyConnectionHost'))
- url.setPort(config.settings.value('FproxyConnectionPort'))
- tabWidget.setTabText(tabWidget.indexOf(browser), self._adjustTabText(self.trUtf8('Loading')))
- addressBar.setText(url.toString())
- lastBrowserState = browser.userData()
- lastBrowserState.url = url
- browser.load(url)
- return True
-
- def newBrowser(self, title=''):
- """opens a browser in a new tab"""
- tabWidget = self.controlById(self.IdTabBrowsers)
- browser = Browser(self)
- page = browser.page()
- settings = browser.settings()
- title = QtCore.QString(title)
-
- # attatch browser state information
- lastBrowserState = LastBrowserState(
- icon=browser.icon(),
- statusMessage=self.trUtf8('Waiting'),
- )
- browser.setUserData(lastBrowserState)
-
- # customize browser
- browser.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
- settings.setAttribute(settings.DeveloperExtrasEnabled, False)
- settings.setAttribute(settings.JavaEnabled, False)
- settings.setAttribute(settings.JavascriptEnabled, False)
- settings.setAttribute(settings.JavascriptCanOpenWindows, False)
- settings.setAttribute(settings.JavascriptCanAccessClipboard, False)
- settings.setAttribute(settings.PluginsEnabled, False)
- settings.setAttribute(settings.AutoLoadImages, self.fcSettings.value('AutoLoadImages'))
-
- # connect browser signals
- self.connect(browser, QtCore.SIGNAL('loadStarted()'), self.onBrowserLoadStarted)
- self.connect(browser, QtCore.SIGNAL('loadProgress(int)'), self.onBrowserLoadProgress)
- self.connect(browser, QtCore.SIGNAL('loadFinished(bool)'), self.onBrowserLoadFinished)
- self.connect(browser, QtCore.SIGNAL('iconChanged()'), self.onBrowserIconChanged)
- self.connect(browser, QtCore.SIGNAL('statusBarMessage(const QString &)'), self.onBrowserStatusBarMessage)
- self.connect(browser, QtCore.SIGNAL('titleChanged(const QString &)'), self.onBrowserTitleChanged)
- self.connect(browser, QtCore.SIGNAL('urlChanged(const QUrl &)'), self.onBrowserUrlChanged)
- self.connect(browser, QtCore.SIGNAL('customContextMenuRequested(const QPoint &)'), self.onBrowserCustomContextMenuRequested)
- self.connect(browser, QtCore.SIGNAL('linkClicked(const QUrl &)'), self.onBrowserLinkClicked)
-
- # adjust browser actions
- act = browser.pageAction(page.OpenLinkInNewWindow)
- act.setText(self.trUtf8('Open page in new tab'))
- act = browser.pageAction(page.OpenImageInNewWindow)
- act.setText(self.trUtf8('Open image in new tab'))
- act = browser.pageAction(page.OpenFrameInNewWindow)
- act.setText(self.trUtf8('Open frame in new tab'))
-
- # customize page
- page.setLinkDelegationPolicy(page.DelegateAllLinks)
-
- # connect page signals
- self.connect(page, QtCore.SIGNAL('linkHovered(const QString &, const QString &, const QString &)'), self.onPageLinkHovered)
-
- tabWidget.addTab(browser, self._adjustTabText(title))
- if tabWidget.currentWidget() == browser:
- self.fcGlobalFeedback.setStatusMessage(lastBrowserState.statusMessage)
- return browser
-
- #TODO: rework. we need more then one menu
- def populateMenu(self, menu):
- menu.addAction(self.fcActions['ActionGoToFProxy'])
- menu.addAction(self.fcActions['ActionGoToHomePage'])
- menu.addAction(self.fcActions['ActionCloseCurrentTab'])
- menu.addAction(self.fcActions['ActionCloseAllTabs'])
- menu.addAction(self.fcActions['ActionOpenNewTab'])
- menu.addAction(self.fcActions['ActionZoomIn'])
- menu.addAction(self.fcActions['ActionZoomOut'])
- menu.addAction(self.fcActions['ActionSearch'])
- return menu
-
- #########################################
- ## overwritten events
- #########################################
- def closeEvent(self):
- self.viewClose()
-
- def hideEvent(self, event):
- self.fcGlobalFeedback.setVisible(False)
-
- def showEvent(self, event):
- self.fcGlobalFeedback.setVisible(True)
-
- def viewClose(self):
- pass
-
- #########################################
- ## event handlers
- #########################################
- #TODO: actions need some comb over
- def onBrowserCustomContextMenuRequested(self, pt):
- browser = self.sender()
- frame = browser.page().currentFrame()
- page = browser.page()
- hitTestResult = frame.hitTestContent(pt)
-
- #if not hitTest.isNull(): #TODO: looks like hitTest.isNull() alwas returns True
-
- menu = QtGui.QMenu()
-
- menu.addAction(browser.pageAction(page.OpenLink))
- menu.addAction(browser.pageAction(page.OpenLinkInNewWindow))
- menu.addAction(browser.pageAction(page.CopyLinkToClipboard))
- menu.addAction(browser.pageAction(page.DownloadLinkToDisk))
-
- menu.addSeparator()
- menu.addAction(browser.pageAction(page.OpenImageInNewWindow))
- menu.addAction(browser.pageAction(page.CopyImageToClipboard))
- menu.addAction(browser.pageAction(page.Downl...
[truncated message content] |