Thread: SF.net SVN: fclient:[864] trunk/fclient/fclient
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-08-02 13:21:20
|
Revision: 864
http://fclient.svn.sourceforge.net/fclient/?rev=864&view=rev
Author: jUrner
Date: 2008-08-02 13:21:29 +0000 (Sat, 02 Aug 2008)
Log Message:
-----------
save geometry of signle app error dlg
Modified Paths:
--------------
trunk/fclient/fclient/fclient.py
trunk/fclient/fclient/impl/config.py
Modified: trunk/fclient/fclient/fclient.py
===================================================================
--- trunk/fclient/fclient/fclient.py 2008-08-02 11:37:20 UTC (rev 863)
+++ trunk/fclient/fclient/fclient.py 2008-08-02 13:21:29 UTC (rev 864)
@@ -52,18 +52,22 @@
magicToRespond='{2e86f6f1-0707-415d-bfe6-6d485603a98c}'
)
try:
+ #raise singleapp.ErrorCanNotConnect() #<-- uncomment for testing DlgSingleAppError()
singleApp.start()
+
except singleapp.ErrorOtherAppIsRunning:
print 'looks like another %s application is already running' % config.FcAppName
print 'exit'
sys.exit(5)
+
except singleapp.ErrorCanNotConnect:
app = QtGui.QApplication(sys.argv)
dlg = DlgSingleAppError()
+ dlg.restoreGeometry(config.fcSettings.value('DlgSingleAppErrorGeometry'))
dlg.exec_()
-
- else:
- # start gui
+ config.fcSettings.setValues(DlgSingleAppErrorGeometry=dlg.saveGeometry())
+
+ else: # everything went well. start gui
app = QtGui.QApplication(sys.argv)
mainWindow = MainWindow()
singleApp.userData = mainWindow
Modified: trunk/fclient/fclient/impl/config.py
===================================================================
--- trunk/fclient/fclient/impl/config.py 2008-08-02 11:37:20 UTC (rev 863)
+++ trunk/fclient/fclient/impl/config.py 2008-08-02 13:21:29 UTC (rev 864)
@@ -103,6 +103,8 @@
class Settings(SettingsBase):
_key_ = 'ConfigSettings'
_settings_ = (
+ ('DlgSingleAppErrorGeometry', 'ByteArray', QtCore.QByteArray(), SettingScopePrivate),
+
('Version', 'String', QtCore.QString(FcVersion), SettingScopePrivate),
('SingleAppHost', 'String', QtCore.QString('localhost'), SettingScopeExpert),
('SingleAppPort', 'UInt', 45663, SettingScopeExpert),
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-08-10 08:30:03
|
Revision: 888
http://fclient.svn.sourceforge.net/fclient/?rev=888&view=rev
Author: jUrner
Date: 2008-08-10 08:30:12 +0000 (Sun, 10 Aug 2008)
Log Message:
-----------
prep release
Added Paths:
-----------
trunk/fclient/fclient/LICENCE.MIT
trunk/fclient/fclient/README
Added: trunk/fclient/fclient/LICENCE.MIT
===================================================================
--- trunk/fclient/fclient/LICENCE.MIT (rev 0)
+++ trunk/fclient/fclient/LICENCE.MIT 2008-08-10 08:30:12 UTC (rev 888)
@@ -0,0 +1,20 @@
+fclient - a python gui for freenet
+
+Copyright (c) 2008 J\xFCrgen Urner
+
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+and associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial
+portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
Added: trunk/fclient/fclient/README
===================================================================
--- trunk/fclient/fclient/README (rev 0)
+++ trunk/fclient/fclient/README 2008-08-10 08:30:12 UTC (rev 888)
@@ -0,0 +1,26 @@
+fclient - a python gui for freenet
+
+ProjectHome: [http://fclient.sourceforge.net/]
+Requirements: Python >= 2.5, Qt >= 4.4.0, PyQt >= 4.4.3
+
+Version history:
+
+*******************************************************************
+0.0.1 - (08.10.08)
+*******************************************************************
+first pre-alpha release
+
+news:
+
+ x.
+
+bugfixes:
+
+ x.
+
+
+
+
+
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-08-12 08:43:44
|
Revision: 905
http://fclient.svn.sourceforge.net/fclient/?rev=905&view=rev
Author: jUrner
Date: 2008-08-12 08:43:51 +0000 (Tue, 12 Aug 2008)
Log Message:
-----------
add an uploads widget to play around with
Modified Paths:
--------------
trunk/fclient/fclient/fclient.py
trunk/fclient/fclient/impl/config.py
Added Paths:
-----------
trunk/fclient/fclient/impl/ViewUploads.py
Modified: trunk/fclient/fclient/fclient.py
===================================================================
--- trunk/fclient/fclient/fclient.py 2008-08-12 08:42:46 UTC (rev 904)
+++ trunk/fclient/fclient/fclient.py 2008-08-12 08:43:51 UTC (rev 905)
@@ -18,6 +18,7 @@
from .impl.ViewConnection import ViewConnectionWidget
from .impl.ViewDownloads import ViewDownloadsWidget
from .impl.ViewLogger import ViewLoggerWidget
+from .impl.ViewUploads import ViewUploadsWidget
from .impl.DlgSingleAppError import DlgSingleAppError
#*************************************************************
@@ -78,6 +79,7 @@
ViewConnectionWidget(mainWindow),
ViewBrowserWidget(mainWindow),
ViewDownloadsWidget(mainWindow),
+ ViewUploadsWidget(mainWindow),
)
viewWidget.addBottomViews(ViewLoggerWidget(mainWindow))
Added: trunk/fclient/fclient/impl/ViewUploads.py
===================================================================
--- trunk/fclient/fclient/impl/ViewUploads.py (rev 0)
+++ trunk/fclient/fclient/impl/ViewUploads.py 2008-08-12 08:43:51 UTC (rev 905)
@@ -0,0 +1,173 @@
+
+""""""
+
+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 .BaseRequestsWidget import RequestsWidget
+#************************************************************************************
+#
+#************************************************************************************
+class UploadsWidgetGlobalFeedback(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].setEnabled(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 DownloadsViewObject(config.ViewObject):
+
+ def __init__(self, parent):
+ config.ViewObject. __init__(self, parent)
+
+ self.name=parent.objectName()
+ self.displayName=self.trUtf8('Uploads')
+ self.icon=QtGui.QIcon()
+
+
+class UploadsWidgetSettings(config.SettingsBase):
+
+
+ _key_ = config.IdViewUploadsWidget
+ _settings_ = (
+ )
+
+
+class ViewUploadsWidget(RequestsWidget):
+
+ def __init__(self, parent, idGlobalFeedback=config.IdMainWindow):
+
+ self.menuRemoveGroup = None
+
+ RequestsWidget.__init__(self, parent)
+
+ self.setObjectName(config.IdViewUploadsWidget)
+ config.ObjectRegistry.register(self)
+ self.fcSettings = UploadsWidgetSettings(self).restore()
+ self.fcViewObject = DownloadsViewObject(self)
+ self.fcGlobalFeedback = UploadsWidgetGlobalFeedback(self, idGlobalFeedback)
+
+ # setup menus
+ self.menuRemoveGroup = QtGui.QMenu(self)
+ self.menuRemoveGroup.setTitle(self.trUtf8('Remove group'))
+ for action in self.fcActions['GroupRemoveGroup'].actions():
+ self.menuRemoveGroup.addAction(action)
+
+
+ ###################################
+ ## overwritten methods
+ ###################################
+ def hideEvent(self, event):
+ self.fcGlobalFeedback.setVisible(False)
+ RequestsWidget.hideEvent(self, event)
+
+ def showEvent(self, event):
+ self.fcGlobalFeedback.setVisible(True)
+ RequestsWidget.showEvent(self, event)
+
+ def retranslateUi(self, parent):
+ RequestsWidget.retranslateUi(self, parent)
+ if self.menuRemoveGroup is not None:
+ self.menuRemoveGroup.setTitle(self.trUtf8('Remove group'))
+
+ ###################################
+ ## methods
+ ###################################
+
+ ###################################
+ ## event handlers
+ ###################################
+ def onTreeCustomContextMenuRequested(self, pt):
+ tree = self.controlById(self.IdTree)
+ pt = tree.viewport().mapToGlobal(pt)
+
+ menu = QtGui.QMenu(self)
+ menu.addMenu(self.menuRemoveGroup)
+ menu.exec_(pt)
+
+ def onTreeItemSelectionChanged(self):
+ tree = self.controlById(self.IdTree)
+ hasSelectedItems = tree.selectionModel().hasSelection()
+
+#**********************************************************************************
+#
+#**********************************************************************************
+if __name__ == '__main__':
+ import sys
+ from . import View
+ from . import ViewConnection
+ from . import ViewLogger
+ from . import MainWindow
+
+ app = QtGui.QApplication(sys.argv)
+
+ mainWindow = MainWindow.MainWindow()
+ viewWidget = View.ViewWidget(mainWindow)
+ mainWindow.setCentralWidget(viewWidget)
+
+ viewWidget.addTopViews(
+ ViewConnection.ViewConnectionWidget(None),
+ ViewUploadsWidget(None),
+ )
+ viewWidget.addBottomViews(ViewLogger.ViewLoggerWidget(None))
+
+ mainWindow.show()
+ res = app.exec_()
+ sys.exit(res)
\ No newline at end of file
Modified: trunk/fclient/fclient/impl/config.py
===================================================================
--- trunk/fclient/fclient/impl/config.py 2008-08-12 08:42:46 UTC (rev 904)
+++ trunk/fclient/fclient/impl/config.py 2008-08-12 08:43:51 UTC (rev 905)
@@ -45,6 +45,7 @@
IdViewDownloadsWidget = 'ViewDownloadsWidget'
IdViewLoggerWidget = 'ViewDownloadsWidget'
IdViewLoggerWidget = 'ViewLoggerWidget'
+IdViewUploadsWidget = 'ViewUploadsWidget'
IdDlgPrefs = 'DlgPrefs'
IdSideBarLoadDetails = 'SideBarLoadDetails'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-08-16 06:49:37
|
Revision: 907
http://fclient.svn.sourceforge.net/fclient/?rev=907&view=rev
Author: jUrner
Date: 2008-08-16 06:49:45 +0000 (Sat, 16 Aug 2008)
Log Message:
-----------
another package redesign. finally found a way to separate components while leaving
relative imports intact for testing
Modified Paths:
--------------
trunk/fclient/fclient/fclient.py
Added Paths:
-----------
trunk/fclient/fclient/impl/MainWindow/
trunk/fclient/fclient/impl/MainWindow/Actions.py
trunk/fclient/fclient/impl/MainWindow/MainWindow.py
trunk/fclient/fclient/impl/MainWindow/MainWindow.ui
trunk/fclient/fclient/impl/MainWindow/MenuBar.py
trunk/fclient/fclient/impl/MainWindow/Settings.py
trunk/fclient/fclient/impl/MainWindow/StatusBar.py
trunk/fclient/fclient/impl/MainWindow/TitleBar.py
trunk/fclient/fclient/impl/MainWindow/Ui_MainWindow.py
trunk/fclient/fclient/impl/MainWindow/__init__.py
trunk/fclient/fclient/impl/MainWindow/_fix_mexec.py
Removed Paths:
-------------
trunk/fclient/fclient/impl/MainWindow.py
trunk/fclient/fclient/impl/tpls/MainWindowTpl.ui
trunk/fclient/fclient/impl/tpls/Ui_MainWindowTpl.py
Modified: trunk/fclient/fclient/fclient.py
===================================================================
--- trunk/fclient/fclient/fclient.py 2008-08-12 08:44:19 UTC (rev 906)
+++ trunk/fclient/fclient/fclient.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -70,7 +70,7 @@
else: # everything went well. start gui
app = QtGui.QApplication(sys.argv)
- mainWindow = MainWindow()
+ mainWindow = MainWindow.MainWindow()
singleApp.userData = mainWindow
viewWidget = ViewWidget(mainWindow)
Added: trunk/fclient/fclient/impl/MainWindow/Actions.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/Actions.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/Actions.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -0,0 +1,45 @@
+
+# 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
+
+from .. import config
+
+from PyQt4 import QtCore, QtGui
+#**********************************************************************************
+#
+#**********************************************************************************
+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,
+ )
+
\ No newline at end of file
Added: trunk/fclient/fclient/impl/MainWindow/MainWindow.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/MainWindow.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/MainWindow.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -0,0 +1,103 @@
+
+# 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
+
+from PyQt4 import QtCore, QtGui
+
+from .. import config
+from .. import Prefs
+from ..lib.qt4ex import dlgabout
+
+from . import Actions
+from . import MenuBar
+from . import Settings
+from . import StatusBar
+from . import TitleBar
+from . import Ui_MainWindow
+#**********************************************************************************
+#
+#**********************************************************************************
+class MainWindow(QtGui.QMainWindow, Ui_MainWindow.Ui_MainWindow):
+
+ def __init__(self, parent=None):
+ QtGui.QMainWindow.__init__(self, parent)
+ self._isCreated = False
+
+ self.setupUi(self)
+ config.ObjectRegistry.register(self)
+
+ self.fcSettings = Settings.Settings().restore()
+ self.fcActions = Actions.Actions(self)
+ self.setMenuBar(MenuBar.MenuBar(self))
+ self.setStatusBar(StatusBar.StatusBar(self))
+ self.fcTitleBar = TitleBar.TitleBar(self)
+
+ self.setWindowIcon(config.fcResources.getIcon('fclient', 32, iconTheme='application', ext='.svg'))
+ self.restoreGeometry(self.fcSettings.value('Geometry'))
+
+ ##################################
+ ## methods
+ ##################################
+ def titleBar(self):
+ return self.fcTitleBar
+
+ ##################################
+ ## events
+ ##################################
+ def closeEvent(self, event):
+ self.fcSettings.setValues(Geometry=self.saveGeometry())
+
+ def showEvent(self, event):
+ if self._isCreated:
+ return
+ self._isCreated = True
+
+ ###################################
+ ## event onrs
+ ###################################
+ def onActPreferencesTriggered(self):
+ dlg = 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.FcAppName + ' - ' + self.trUtf8('About'),
+ appName=config.FcAppName,
+ description=self.trUtf8('a freenet client written in Fc and Qt4'),
+ version=config.FcVersion,
+ author=config.FcAuthor,
+ licence=config.FcLicence,
+ copyright=config.FcCopyright,
+ homepage=config.FcHomepage
+ )
+ 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)
Added: trunk/fclient/fclient/impl/MainWindow/MainWindow.ui
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/MainWindow.ui (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/MainWindow.ui 2008-08-16 06:49:45 UTC (rev 907)
@@ -0,0 +1,70 @@
+<ui version="4.0" >
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>774</width>
+ <height>591</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralwidget" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>774</width>
+ <height>568</height>
+ </rect>
+ </property>
+ <zorder>frame</zorder>
+ </widget>
+ <widget class="QStatusBar" name="statusbar" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>568</y>
+ <width>774</width>
+ <height>23</height>
+ </rect>
+ </property>
+ </widget>
+ <action name="action_Preferences" >
+ <property name="text" >
+ <string>_Preferences</string>
+ </property>
+ </action>
+ <action name="actPreferences" >
+ <property name="text" >
+ <string>&Preferences..</string>
+ </property>
+ </action>
+ <action name="actExit" >
+ <property name="text" >
+ <string>E&xit</string>
+ </property>
+ </action>
+ <action name="actHelp" >
+ <property name="text" >
+ <string>&Help..</string>
+ </property>
+ <property name="toolTip" >
+ <string>Help</string>
+ </property>
+ </action>
+ <action name="actAbout" >
+ <property name="text" >
+ <string>A&bout..</string>
+ </property>
+ <property name="iconText" >
+ <string>About</string>
+ </property>
+ </action>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
Added: trunk/fclient/fclient/impl/MainWindow/MenuBar.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/MenuBar.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/MenuBar.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -0,0 +1,26 @@
+
+from PyQt4 import QtGui
+#**********************************************************************************
+#
+#**********************************************************************************
+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.fcActions['ActionPreferences'])
+ self.menuApplication.addAction(parent.fcActions['ActionExit'])
+
+ self.menuHelp = QtGui.QMenu(self.trUtf8('&Help'), self)
+ self.addMenu(self.menuHelp)
+ self.menuHelp.addAction(parent.fcActions['ActionAbout'])
+ self.menuHelp.addAction(parent.fcActions['ActionHelp'])
+
+
+ def addViewMenu(self, menu):
+ self.insertMenu(self.menuHelp.children()[0], menu)
+ return menu
\ No newline at end of file
Added: trunk/fclient/fclient/impl/MainWindow/Settings.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/Settings.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/Settings.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -0,0 +1,26 @@
+# 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
+
+from .. import config
+
+from PyQt4 import QtCore, QtGui
+#**********************************************************************************
+#
+#**********************************************************************************
+class Settings(config.SettingsBase):
+
+ _key_ = config.IdMainWindow
+ _settings_ = (
+ ('Geometry', 'ByteArray', QtCore.QByteArray()),
+ ('ConnectionLabelFlashRate', 'UInt', 800),
+ )
+
Added: trunk/fclient/fclient/impl/MainWindow/StatusBar.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/StatusBar.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/StatusBar.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -0,0 +1,90 @@
+
+# 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
+
+from .. import config
+
+from PyQt4 import QtCore, QtGui
+#**********************************************************************************
+#
+#**********************************************************************************
+class StatusBar(QtGui.QStatusBar):
+
+
+ class DisconnectTimer(QtCore.QTimer):
+
+ def __init__(self,statusBar):
+ QtCore.QTimer.__init__(self, statusBar)
+ self.connect(self, QtCore.SIGNAL('timeout()'), self.onNext)
+
+ def start(self, n):
+ QtCore.QTimer.start(self, n)
+
+ def onNext(self):
+ statusBar = self.parent()
+ if statusBar.connectionLabels['LabelConnectionConnected'].isVisible():
+ self.stop()
+ else:
+ statusBar.connectionLabels['LabelConnectionDisonnectedOn'].setVisible(
+ not statusBar.connectionLabels['LabelConnectionDisonnectedOn'].isVisible()
+ )
+ statusBar.connectionLabels['LabelConnectionDisonnectedOff'].setVisible(
+ not statusBar.connectionLabels['LabelConnectionDisonnectedOff'].isVisible()
+ )
+
+ def __init__(self, mainWindow):
+ QtGui.QStatusBar.__init__(self, mainWindow)
+ self.setObjectName('StatusBar')
+ #config.ObjectRegistry.register(self)
+ mainWindow.setStatusBar(self)
+
+ self._disconnectTimer = self.DisconnectTimer(self)
+
+ # setup connection labels
+ self.fcpEvents = (
+ (config.fcpClient.events.ClientConnected, self.onFcpClientConnected),
+ (config.fcpClient.events.ClientDisconnected, self.onFcpClientDisconnected),
+ )
+ config.fcpClient.events += self.fcpEvents
+ self.connectionLabels = {
+ 'LabelConnectionConnected': QtGui.QLabel(self),
+ 'LabelConnectionDisonnectedOn': QtGui.QLabel(self),
+ 'LabelConnectionDisonnectedOff': QtGui.QLabel(self),
+ }
+ for objectName, label in self.connectionLabels.items():
+ label.setObjectName(objectName)
+ label.setVisible(False)
+ self.addWidget(label, 0)
+ if config.fcpClient.isConnected():
+ self.connectionLabels['LabelConnectionConnected'].show()
+ else :
+ self.connectionLabels['LabelConnectionDisonnectedOn'].show()
+
+ self.retranslateUi(self)
+
+
+ def retranslateUi(self, this):
+ self.connectionLabels['LabelConnectionConnected'].setText(self.trUtf8('CONNECTED'))
+ self.connectionLabels['LabelConnectionDisonnectedOn'].setText(self.trUtf8('DISCONNECTED'))
+ self.connectionLabels['LabelConnectionDisonnectedOff'].setText(self.trUtf8('DISCONNECTED'))
+
+ def onFcpClientConnected(self, event, msg):
+ self._disconnectTimer.stop()
+ for label in self.connectionLabels.values():
+ label.hide()
+ self.connectionLabels['LabelConnectionConnected'].show()
+
+ def onFcpClientDisconnected(self, event, msg):
+ for label in self.connectionLabels.values():
+ label.hide()
+ self.connectionLabels['LabelConnectionDisonnectedOn'].show()
+ self._disconnectTimer.start(self.parent().fcSettings.value('ConnectionLabelFlashRate'))
Added: trunk/fclient/fclient/impl/MainWindow/TitleBar.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/TitleBar.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/TitleBar.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -0,0 +1,32 @@
+
+# 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
+
+from .. import config
+
+
+from PyQt4 import QtCore
+#**********************************************************************************
+#
+#**********************************************************************************
+class TitleBar(QtCore.QObject):
+
+ def __init__(self, parent):
+ QtCore.QObject.__init__(self, parent)
+ self.setInfo('')
+
+ def setInfo(self, text):
+ if text:
+ title = config.FcAppName + ' - [%s]' % text
+ else:
+ title = config.FcAppName
+ self.parent().setWindowTitle(title)
Added: trunk/fclient/fclient/impl/MainWindow/Ui_MainWindow.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/Ui_MainWindow.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/Ui_MainWindow.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file '/home/me/src/fclient/trunk/fclient/fclient/impl/MainWindow/MainWindow.ui'
+#
+# Created: Thu Aug 14 13:55:41 2008
+# by: PyQt4 UI code generator 4.4.3-snapshot-20080705
+#
+# WARNING! All changes made in this file will be lost!
+
+from PyQt4 import QtCore, QtGui
+
+class Ui_MainWindow(object):
+ def setupUi(self, MainWindow):
+ MainWindow.setObjectName("MainWindow")
+ MainWindow.resize(774, 591)
+ self.centralwidget = QtGui.QWidget(MainWindow)
+ self.centralwidget.setGeometry(QtCore.QRect(0, 0, 774, 568))
+ self.centralwidget.setObjectName("centralwidget")
+ MainWindow.setCentralWidget(self.centralwidget)
+ self.statusbar = QtGui.QStatusBar(MainWindow)
+ self.statusbar.setGeometry(QtCore.QRect(0, 568, 774, 23))
+ self.statusbar.setObjectName("statusbar")
+ MainWindow.setStatusBar(self.statusbar)
+ self.action_Preferences = QtGui.QAction(MainWindow)
+ self.action_Preferences.setObjectName("action_Preferences")
+ self.actPreferences = QtGui.QAction(MainWindow)
+ self.actPreferences.setObjectName("actPreferences")
+ self.actExit = QtGui.QAction(MainWindow)
+ self.actExit.setObjectName("actExit")
+ self.actHelp = QtGui.QAction(MainWindow)
+ self.actHelp.setObjectName("actHelp")
+ self.actAbout = QtGui.QAction(MainWindow)
+ self.actAbout.setObjectName("actAbout")
+
+ self.retranslateUi(MainWindow)
+ QtCore.QMetaObject.connectSlotsByName(MainWindow)
+
+ def retranslateUi(self, MainWindow):
+ MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
+ self.action_Preferences.setText(QtGui.QApplication.translate("MainWindow", "_Preferences", None, QtGui.QApplication.UnicodeUTF8))
+ self.actPreferences.setText(QtGui.QApplication.translate("MainWindow", "&Preferences..", None, QtGui.QApplication.UnicodeUTF8))
+ self.actExit.setText(QtGui.QApplication.translate("MainWindow", "E&xit", None, QtGui.QApplication.UnicodeUTF8))
+ self.actHelp.setText(QtGui.QApplication.translate("MainWindow", "&Help..", None, QtGui.QApplication.UnicodeUTF8))
+ self.actHelp.setToolTip(QtGui.QApplication.translate("MainWindow", "Help", None, QtGui.QApplication.UnicodeUTF8))
+ self.actAbout.setText(QtGui.QApplication.translate("MainWindow", "A&bout..", None, QtGui.QApplication.UnicodeUTF8))
+ self.actAbout.setIconText(QtGui.QApplication.translate("MainWindow", "About", None, QtGui.QApplication.UnicodeUTF8))
+
+
+if __name__ == "__main__":
+ import sys
+ app = QtGui.QApplication(sys.argv)
+ MainWindow = QtGui.QMainWindow()
+ ui = Ui_MainWindow()
+ ui.setupUi(MainWindow)
+ MainWindow.show()
+ sys.exit(app.exec_())
+
Added: trunk/fclient/fclient/impl/MainWindow/__init__.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/__init__.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/__init__.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -0,0 +1 @@
+
Added: trunk/fclient/fclient/impl/MainWindow/_fix_mexec.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/_fix_mexec.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/_fix_mexec.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -0,0 +1,99 @@
+'''in python 2.5 relative impports are srsly broken ..fix this to make relative imports work
+when executing a module as main (-m), including relative imports up to the root package
+
+see: [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html]
+
+@note: root package is the highest available package in the package hirarchy.
+don't look at __name__ too closely. it gets adjusted for a module to just "do the right
+thing" in __name__ == '__main__' comparisons
+@note: this patch does not work if relative imports are done in __init__.py. no idea why
+and to be honest, I don't wanna* know..
+@note: this is more or less a hack. so it may have unwanted side effects for example
+when importing parent packages. use at your own risk. could improve this module
+by adding a __main__.py to stop at this level or by fixing the __init__.py bug, but
+I don't think its worth it. see what python2.6 or 3k brings..
+
+usage::
+
+ # place this at the top a module, before doing any relative imports
+ from fix_mexec import fix_mexec
+ fix_mexec(__name__, __file__)
+ del fix_mexec
+
+ from ...foo import bar
+
+
+
+##<-- copy and paste code, assuming _fix_mexec resides in the current dir..
+
+# 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
+
+
+##--> copy and paste code
+'''
+
+import imp, os, sys
+#********************************************************************************
+#
+#********************************************************************************
+class MainName(str):
+ def __eq__(self, other):
+ if other == '__main__': return True
+ return str.__eq__(self, other)
+ def __ne__(self, other):
+ if other == '__main__': return False
+ return str.__ne__(self, other)
+
+
+def fix_mexec(_name_, _file_):
+ """bugfix for relative imports not working
+ @param _name_: __name__ of the module
+ @param _file_: __file__ of the module
+
+ @note: not complete: relies on __init__.py, .pyo (...) is ignored currently
+ """
+ if _name_ == '__main__':
+ out = []
+ # find allparent packages
+ p = os.path.dirname(os.path.abspath(_file_))
+ prev = p
+ while True:
+ pkg = os.path.join(p, '__init__.py')
+ if os.path.isfile(pkg):
+ out.append([pkg, os.path.basename(p)])
+ else:
+ break
+ prev = p
+ p = os.path.dirname(p)
+ if p == prev:
+ break
+ out.reverse()
+
+ # adjust sub package names an import parent modules
+ name = None
+ for n, (fpath, name) in enumerate(out):
+ if n > 0:
+ name = out[n][1] = out[n -1][1] + '.' + out[n][1]
+ m = imp.load_source(name, fpath)
+ m.__path__ = [os.path.dirname(fpath)]
+
+ # adjust name of the __main__ module
+ if name is not None:
+ m = sys.modules.pop('__main__')
+ # 'foo.bar..__main__' does not work for some reason. 'foo.bar' seems to work as expected
+ ##m.__name__ = _Name_(name + '.' + '__main__')
+ m.__name__ = MainName(name)
+ sys.modules[m.__name__] = m
+
+
+
Deleted: trunk/fclient/fclient/impl/MainWindow.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow.py 2008-08-12 08:44:19 UTC (rev 906)
+++ trunk/fclient/fclient/impl/MainWindow.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -1,246 +0,0 @@
-from __future__ import absolute_import
-if __name__ == '__main__': # see --> http://bugs.Fc.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 Prefs
-from .lib.qt4ex import dlgabout
-
-from .tpls.Ui_MainWindowTpl import Ui_MainWindow
-#**********************************************************************************
-#
-#**********************************************************************************
-class Settings(config.SettingsBase):
-
- _key_ = config.IdMainWindow
- _settings_ = (
- ('Geometry', 'ByteArray', QtCore.QByteArray()),
- ('ConnectionLabelFlashRate', 'UInt', 800),
- )
-
-
-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.fcActions['ActionPreferences'])
- self.menuApplication.addAction(parent.fcActions['ActionExit'])
-
- self.menuHelp = QtGui.QMenu(self.trUtf8('&Help'), self)
- self.addMenu(self.menuHelp)
- self.menuHelp.addAction(parent.fcActions['ActionAbout'])
- self.menuHelp.addAction(parent.fcActions['ActionHelp'])
-
-
- def addViewMenu(self, menu):
- self.insertMenu(self.menuHelp.children()[0], menu)
- return menu
-
-
-class StatusBar(QtGui.QStatusBar):
-
-
- class DisconnectTimer(QtCore.QTimer):
-
- def __init__(self,statusBar):
- QtCore.QTimer.__init__(self, statusBar)
- self.connect(self, QtCore.SIGNAL('timeout()'), self.onNext)
-
- def start(self, n):
- QtCore.QTimer.start(self, n)
-
- def onNext(self):
- statusBar = self.parent()
- if statusBar.connectionLabels['LabelConnectionConnected'].isVisible():
- self.stop()
- else:
- statusBar.connectionLabels['LabelConnectionDisonnectedOn'].setVisible(
- not statusBar.connectionLabels['LabelConnectionDisonnectedOn'].isVisible()
- )
- statusBar.connectionLabels['LabelConnectionDisonnectedOff'].setVisible(
- not statusBar.connectionLabels['LabelConnectionDisonnectedOff'].isVisible()
- )
-
- def __init__(self, mainWindow):
- QtGui.QStatusBar.__init__(self, mainWindow)
- self.setObjectName('StatusBar')
- #config.ObjectRegistry.register(self)
- mainWindow.setStatusBar(self)
-
- self._disconnectTimer = self.DisconnectTimer(self)
-
- # setup connection labels
- self.fcpEvents = (
- (config.fcpClient.events.ClientConnected, self.onFcpClientConnected),
- (config.fcpClient.events.ClientDisconnected, self.onFcpClientDisconnected),
- )
- config.fcpClient.events += self.fcpEvents
- self.connectionLabels = {
- 'LabelConnectionConnected': QtGui.QLabel(self),
- 'LabelConnectionDisonnectedOn': QtGui.QLabel(self),
- 'LabelConnectionDisonnectedOff': QtGui.QLabel(self),
- }
- for objectName, label in self.connectionLabels.items():
- label.setObjectName(objectName)
- label.setVisible(False)
- self.addWidget(label, 0)
- if config.fcpClient.isConnected():
- self.connectionLabels['LabelConnectionConnected'].show()
- else :
- self.connectionLabels['LabelConnectionDisonnectedOn'].show()
-
- self.retranslateUi(self)
-
-
- def retranslateUi(self, this):
- self.connectionLabels['LabelConnectionConnected'].setText(self.trUtf8('CONNECTED'))
- self.connectionLabels['LabelConnectionDisonnectedOn'].setText(self.trUtf8('DISCONNECTED'))
- self.connectionLabels['LabelConnectionDisonnectedOff'].setText(self.trUtf8('DISCONNECTED'))
-
- def onFcpClientConnected(self, event, msg):
- self._disconnectTimer.stop()
- for label in self.connectionLabels.values():
- label.hide()
- self.connectionLabels['LabelConnectionConnected'].show()
-
- def onFcpClientDisconnected(self, event, msg):
- for label in self.connectionLabels.values():
- label.hide()
- self.connectionLabels['LabelConnectionDisonnectedOn'].show()
- self._disconnectTimer.start(self.parent().fcSettings.value('ConnectionLabelFlashRate'))
-
-
-
-class TitleBar(QtCore.QObject):
-
- def __init__(self, parent):
- QtCore.QObject.__init__(self, parent)
- self.setInfo('')
-
- def setInfo(self, text):
- if text:
- title = config.FcAppName + ' - [%s]' % text
- else:
- title = config.FcAppName
- self.parent().setWindowTitle(title)
-
-#**********************************************************************************
-#
-#**********************************************************************************
-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.fcSettings = Settings().restore()
- self.fcActions = Actions(self)
- self.setMenuBar(MenuBar(self))
- self.setStatusBar(StatusBar(self))
- self.fcTitleBar = TitleBar(self)
-
- self.setWindowIcon(config.fcResources.getIcon('fclient', 32, iconTheme='application', ext='.svg'))
- self.restoreGeometry(self.fcSettings.value('Geometry'))
-
- ##################################
- ## methods
- ##################################
- def titleBar(self):
- return self.fcTitleBar
-
-...
[truncated message content] |
|
From: <jU...@us...> - 2008-08-16 07:43:10
|
Revision: 910
http://fclient.svn.sourceforge.net/fclient/?rev=910&view=rev
Author: jUrner
Date: 2008-08-16 07:43:18 +0000 (Sat, 16 Aug 2008)
Log Message:
-----------
isolated browser view
Modified Paths:
--------------
trunk/fclient/fclient/fclient.py
trunk/fclient/fclient/impl/Prefs.py
Added Paths:
-----------
trunk/fclient/fclient/impl/ViewBrowser/
trunk/fclient/fclient/impl/ViewBrowser/Actions.py
trunk/fclient/fclient/impl/ViewBrowser/Browser.py
trunk/fclient/fclient/impl/ViewBrowser/BrowserWidget.ui
trunk/fclient/fclient/impl/ViewBrowser/GlobalFeedback.py
trunk/fclient/fclient/impl/ViewBrowser/NetworkAccessManager.py
trunk/fclient/fclient/impl/ViewBrowser/Page.py
trunk/fclient/fclient/impl/ViewBrowser/Settings.py
trunk/fclient/fclient/impl/ViewBrowser/SideBar.py
trunk/fclient/fclient/impl/ViewBrowser/SideBars/
trunk/fclient/fclient/impl/ViewBrowser/SideBars/SideBarLoadDetails.py
trunk/fclient/fclient/impl/ViewBrowser/SideBars/SideBarLoadDetailsTpl.ui
trunk/fclient/fclient/impl/ViewBrowser/SideBars/Ui_SideBarLoadDetailsTpl.py
trunk/fclient/fclient/impl/ViewBrowser/SideBars/__init__.py
trunk/fclient/fclient/impl/ViewBrowser/SideBars/_fix_mexec.py
trunk/fclient/fclient/impl/ViewBrowser/TabBar.py
trunk/fclient/fclient/impl/ViewBrowser/Ui_BrowserWidget.py
trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py
trunk/fclient/fclient/impl/ViewBrowser/__init__.py
trunk/fclient/fclient/impl/ViewBrowser/_fix_mexec.py
trunk/fclient/fclient/impl/ViewBrowser/dlgs/
trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgPropsBrowserObject.py
trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgPropsBrowserObjectTpl.ui
trunk/fclient/fclient/impl/ViewBrowser/dlgs/Ui_DlgPropsBrowserObjectTpl.py
trunk/fclient/fclient/impl/ViewBrowser/dlgs/__init__.py
trunk/fclient/fclient/impl/ViewBrowser/dlgs/_fix_mexec.py
trunk/fclient/fclient/impl/ViewBrowser/prefs/
trunk/fclient/fclient/impl/ViewBrowser/prefs/PrefsBrowserWidget.py
trunk/fclient/fclient/impl/ViewBrowser/prefs/PrefsBrowserWidgetTpl.ui
trunk/fclient/fclient/impl/ViewBrowser/prefs/Ui_PrefsBrowserWidgetTpl.py
trunk/fclient/fclient/impl/ViewBrowser/prefs/__init__.py
trunk/fclient/fclient/impl/ViewBrowser/prefs/_fix_mexec.py
Removed Paths:
-------------
trunk/fclient/fclient/impl/DlgPropsBrowserObject.py
trunk/fclient/fclient/impl/PrefsBrowserWidget.py
trunk/fclient/fclient/impl/tpls/DlgPropsBrowserObjectTpl.ui
trunk/fclient/fclient/impl/tpls/PrefsBrowserWidgetTpl.ui
trunk/fclient/fclient/impl/tpls/Ui_DlgPropsBrowserObjectTpl.py
trunk/fclient/fclient/impl/tpls/Ui_PrefsBrowserWidgetTpl.py
trunk/fclient/fclient/impl/tpls/Ui_ViewBrowserWidgetTpl.py
trunk/fclient/fclient/impl/tpls/ViewBrowserWidgetTpl.ui
Modified: trunk/fclient/fclient/fclient.py
===================================================================
--- trunk/fclient/fclient/fclient.py 2008-08-16 06:51:24 UTC (rev 909)
+++ trunk/fclient/fclient/fclient.py 2008-08-16 07:43:18 UTC (rev 910)
@@ -14,7 +14,7 @@
from .impl.MainWindow import MainWindow
from .impl.View import ViewWidget
-from .impl.ViewBrowser import ViewBrowserWidget
+from .impl.ViewBrowser import ViewBrowser
from .impl.ViewConnection import ViewConnectionWidget
from .impl.ViewDownloads import ViewDownloadsWidget
from .impl.ViewLogger import ViewLoggerWidget
@@ -77,7 +77,7 @@
mainWindow.setCentralWidget(viewWidget)
viewWidget.addTopViews(
ViewConnectionWidget(mainWindow),
- ViewBrowserWidget(mainWindow),
+ ViewBrowser.ViewBrowserWidget(mainWindow),
ViewDownloadsWidget(mainWindow),
ViewUploadsWidget(mainWindow),
)
Deleted: trunk/fclient/fclient/impl/DlgPropsBrowserObject.py
===================================================================
--- trunk/fclient/fclient/impl/DlgPropsBrowserObject.py 2008-08-16 06:51:24 UTC (rev 909)
+++ trunk/fclient/fclient/impl/DlgPropsBrowserObject.py 2008-08-16 07:43:18 UTC (rev 910)
@@ -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 DlgPropsBrowserObject(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.FcAppName + 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)
-
Modified: trunk/fclient/fclient/impl/Prefs.py
===================================================================
--- trunk/fclient/fclient/impl/Prefs.py 2008-08-16 06:51:24 UTC (rev 909)
+++ trunk/fclient/fclient/impl/Prefs.py 2008-08-16 07:43:18 UTC (rev 910)
@@ -8,7 +8,7 @@
from . import config
from .lib.qt4ex import dlgpreferences
from .PrefsGlobal import PrefsPageGlobal
-from .PrefsBrowserWidget import PrefsPageBrowser
+from .ViewBrowser.prefs import PrefsBrowserWidget
from .PrefsConnectionWidget import PrefsPageConnectionExpertSettings
from .PrefsSingleApp import PrefsPageSingleApp
#**********************************************************************************
@@ -59,7 +59,7 @@
(
PrefsPageSingleApp(),
),
- PrefsPageBrowser(),
+ PrefsBrowserWidget.PrefsPageBrowser(),
)
dlgpreferences.DlgPreferencesFlatTree.__init__(self,
parent,
Deleted: trunk/fclient/fclient/impl/PrefsBrowserWidget.py
===================================================================
--- trunk/fclient/fclient/impl/PrefsBrowserWidget.py 2008-08-16 06:51:24 UTC (rev 909)
+++ trunk/fclient/fclient/impl/PrefsBrowserWidget.py 2008-08-16 07:43:18 UTC (rev 910)
@@ -1,131 +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 .lib.qt4ex.lib import settings
-
-
-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=None, page=None):
- QtGui.QWidget.__init__(self, parent)
-
- self.setupUi(self)
-
- browserWidget = config.ObjectRegistry.get(config.IdViewBrowserWidget, None)
- if browserWidget is None:
- self.setEnabled(False)
- else:
- self.fcSettingsControler = settings.SettingsControler(browserWidget.fcSettings, parent=self)
- if page is not None:
- page.connect(self.fcSettingsControler, QtCore.SIGNAL('isDirty(bool)'), page.setDirty)
-
- self.fcSettingsControler.addLineEdit(
- self.controlById(self.IdEdHomePage),
- 'HomePage',
- )
- self.fcSettingsControler.addCheckBox(
- self.controlById(self.IdCkOpenAddressBarInNewTab),
- 'OpenAddressBarInNewTab',
- )
- self.fcSettingsControler.addCheckBox(
- self.controlById(self.IdCkOpenBookmarksInNewTab),
- 'OpenBookmarksInNewTab',
- )
- self.fcSettingsControler.addCheckBox(
- self.controlById(self.IdCkOpenLinksInNewTab),
- 'OpenLinksInNewTab',
- )
- self.fcSettingsControler.addCheckBox(
- self.controlById(self.IdCkOpenHomePageOnNewTabCreated),
- 'OpenHomePageOnNewTabCreated',
- )
- self.fcSettingsControler.addCheckBox(
- self.controlById(self.IdCkBackIsClose),
- 'BackIsClose',
- )
- self.fcSettingsControler.addCheckBox(
- self.controlById(self.IdCkAutoLoadImages),
- 'AutoLoadImages',
- )
-
- def controlById(self, idControl):
- return getattr(self, idControl)
-
- def doApply(self):
- if self.fcSettingsControler is not None:
- return self.fcSettingsControler.apply()
- return False
-
- def doRestoreDefaults(self):
- if self.fcSettingsControler is not None:
- return self.fcSettingsControler.restoreDefaults()
- return False
-
-#***********************************************************************
-#
-#***********************************************************************
-class PrefsPageBrowser(dlgpreferences.Page):
-
- UUID = '{c85e63a8-6806-435a-81ce-f4b46872246f}'
-
- def __init__(self):
- dlgpreferences.Page.__init__(self, self.UUID)
- self._widget = None
-
- def displayName(self):
- return self.trUtf8('Browser')
-
- def canApply(self): return True
- def canHelp(self): return False
- def canRestoreDefaults(self): return True
-
- def setVisible(self, parent, flag):
- createdNew = False
- if flag and self._widget is None:
- createdNew = True
- self._widget = PrefsBrowserWidget(parent=parent, page=self)
- self._widget.setVisible(flag)
- return (createdNew, self._widget)
-
-
- def doApply(self):
- self._widget.doApply()
- return True
-
- def doRestoreDefaults(self):
- self._widget.doRestoreDefaults()
- 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)
-
Added: trunk/fclient/fclient/impl/ViewBrowser/Actions.py
===================================================================
--- trunk/fclient/fclient/impl/ViewBrowser/Actions.py (rev 0)
+++ trunk/fclient/fclient/impl/ViewBrowser/Actions.py 2008-08-16 07:43:18 UTC (rev 910)
@@ -0,0 +1,220 @@
+# 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
+
+
+from PyQt4 import QtCore, QtGui, QtWebKit
+
+from .. import config
+
+from PyQt4 import QtCore, QtGui
+#**********************************************************************************
+#
+#**********************************************************************************
+class Actions(config.ActionsBase):
+
+ def __init__(self, parent):
+ config.ActionsBase.__init__(self, parent)
+
+ iconSize = config.fcSettings.value('IconSize')
+ iconTheme = config.fcSettings.value('IconTheme')
+
+ #TODO: shortcut
+ self.action(
+ name='ActionCloseCurrentTab',
+ text=self.trUtf8('Close ¤t tab'),
+ trigger=parent.onCloseCurrentTab,
+ )
+ #TODO: shortcut
+ 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,
+ )
+ #TODO: shortcut
+ self.action(
+ name='ActionCreateNewTab',
+ text=self.trUtf8('Create &new tab'),
+ trigger=parent.onCreateNewTab,
+ )
+ #TODO: shortcut
+ self.action(
+ name='ActionDuplicateTab',
+ text=self.trUtf8('&Duplicate tab'),
+ trigger=parent.onDuplicateTab,
+ )
+
+ #TODO: shortcut
+ 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'),
+ shortcut=QtGui.QKeySequence(self.trUtf8('Alt+Home')),
+ trigger=parent.onGoToHomePage,
+ )
+ #TODO: shortcut
+ self.action(
+ name='ActionObjectProperties',
+ text=self.trUtf8('Properties..'),
+ trigger=None,
+ )
+ self.action(
+ name='ActionZoomIn',
+ text=self.trUtf8('Zoom in'),
+ shortcut=QtGui.QKeySequence(QtGui.QKeySequence.ZoomIn),
+ trigger=parent.onZoomIn,
+ )
+ self.action(
+ name='ActionZoomOut',
+ text=self.trUtf8('Zoom out'),
+ shortcut=QtGui.QKeySequence(QtGui.QKeySequence.ZoomOut),
+ trigger=parent.onZoomOut,
+ )
+
+ # default browser actions
+ self.action(
+ name='ActionBack',
+ text=self.trUtf8('Back'),
+ trigger=None,
+ isEnabled=False,
+ shortcut=QtGui.QKeySequence(QtGui.QKeySequence.Back),
+ icon=config.fcResources.getIcon('back', iconSize, iconTheme=iconTheme),
+ userData=(None, None),
+ )
+ self.action(
+ name='ActionForward',
+ text=self.trUtf8('Forward'),
+ trigger=None,
+ isEnabled=False,
+ shortcut=QtGui.QKeySequence(QtGui.QKeySequence.Forward),
+ icon=config.fcResources.getIcon('forward', iconSize, iconTheme=iconTheme),
+ userData=(None, None),
+ )
+ self.action(
+ name='ActionReload',
+ text=self.trUtf8('Reload'),
+ #EXPERIMENTAL: we handle it, cos page.url() is empty if fproxy did not respond.
+ # for some reason QWebView has "Reload" enabled in this case. we keep track of
+ # the last known url and reload it manually. hope we don't get into trouble with
+ # this. NOTE: we may have to do this for other actions aswell
+ trigger=parent.onBrowserReloadTriggered,
+ isEnabled=False,
+ #TODO: how to assign QKeySequence.Refresh and* F5 ?
+ shortcut=QtGui.QKeySequence(QtGui.QKeySequence.Refresh),
+ icon=config.fcResources.getIcon('reload_page', iconSize, iconTheme=iconTheme),
+ userData=(None, None),
+ )
+ self.action(
+ name='ActionStop',
+ text=self.trUtf8('Stop'),
+ trigger=None,
+ isEnabled=False,
+ shortcut=QtGui.QKeySequence(self.trUtf8('Esc')),
+ icon=config.fcResources.getIcon('stop', iconSize, iconTheme=iconTheme),
+ userData=(None, None),
+ )
+ self.action(
+ name='ActionBackIsClose',
+ text=self.trUtf8('Back is close'),
+ icon=config.fcResources.getIcon('button_cancel', iconSize, iconTheme=iconTheme),
+ trigger=None,
+ )
+
+ # find actions
+ self.action(
+ name='ActionFind',
+ text=self.trUtf8('Find'),
+ shortcut=QtGui.QKeySequence(QtGui.QKeySequence.Find),
+ trigger=parent.onFind,
+ )
+ self.action(
+ name='ActionFindNext',
+ text=self.trUtf8('Find next'),
+ isEnabled=False,
+ shortcut=QtGui.QKeySequence(QtGui.QKeySequence.FindNext),
+ trigger=parent.onFindNext,
+ )
+ self.action(
+ name='ActionFindPrevious',
+ text=self.trUtf8('Find previous'),
+ isEnabled=False,
+ shortcut=QtGui.QKeySequence(QtGui.QKeySequence.FindPrevious),
+ trigger=parent.onFindPrevious,
+ )
+ self.action(
+ name='ActionSavePage',
+ text=self.trUtf8('Save page..'),
+ isEnabled=True,
+ ##shortcut=QtGui.QKeySequence(QtGui.QKeySequence.FindPrevious),
+ trigger=parent.onSavePage,
+ )
+
+ # sideBars
+ group = self.group(
+ name='GroupSideBars',
+ isExclusive=True,
+ trigger=parent.onShowSidebar,
+ )
+ self.action(
+ name='ActionShowSideBarLoadDetails',
+ group=group,
+ text=self.trUtf8('Load details'),
+ isEnabled=True,
+ isCheckable=True,
+ )
+
+ self.action(
+ name='ActionCloseCurrentSideBar',
+ text=self.trUtf8('Close sidebar'),
+ isEnabled=True,
+ trigger=parent.onCloseCurrentSideBar,
+ )
+
+
+ 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)
Added: trunk/fclient/fclient/impl/ViewBrowser/Browser.py
===================================================================
--- trunk/fclient/fclient/impl/ViewBrowser/Browser.py (rev 0)
+++ trunk/fclient/fclient/impl/ViewBrowser/Browser.py 2008-08-16 07:43:18 UTC (rev 910)
@@ -0,0 +1,216 @@
+# 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
+
+from . import Page
+
+from PyQt4 import QtCore, QtGui, QtWebKit, QtNetwork
+
+#*****************************************************************************************
+#
+#*****************************************************************************************
+class NetworkReplyData(QtCore.QObject):
+ def __init__(self, parent, url):
+ QtCore.QObject.__init__(self, parent)
+ self.url = url
+ self.bytesReceived = 0
+ self.bytesTotal = 0
+ self.finished = False
+ self.errorCode = None
+
+#*****************************************************************************************
+#
+#*****************************************************************************************
+#TODO: impl functionality in browser
+class LastBrowserState(object):
+ """records the last known state browser"""
+
+ StateNone = 0x0
+ StateLoading = 0x1
+ StateComplete = 0x2
+ StateError = 0x4
+ StateHideProgressBar = 0x100
+
+
+ __slots__ = ('clearProgressBarTimers', 'icon', 'progress', 'state', 'statusMessage', 'title', 'url')
+
+ def __init__(self, icon=None, progress=0, statusMessage=None, state=StateNone, title=None, url=None):
+ self.clearProgressBarTimers = [] # timers scheduled for hiding progressBar
+ self.progress = 0
+ self.icon = tCore.QIcon() if icon is None else icon
+ self.state = state
+ 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
+
+#*****************************************************************************************
+#
+#*****************************************************************************************
+class Browser(QtWebKit.QWebView):
+ """ browser customized for freenet
+ """
+
+ MaxProgress = 100
+
+ def __init__(self, parent=None, userData=None):
+ QtWebKit.QWebView.__init__(self, parent)
+
+ page = Page.Page(self)
+ self.setPage(page)
+
+ #NOTE: we store last progress made to set busy cursor accordingly
+ self._lastProgress = 0
+ self._userData = userData
+ self._networkGetReplies = [[], []] # (QNetworkReplies, urls)
+ self._networkReplySignals = (
+ ('downloadProgress(qint64, qint64)', self.onNetworkReplyDownloadProgress),
+ ('error(QNetworkReply::NetworkError)', self.onNetworkReplyError),
+ ('finished()', self.onNetworkReplyFinished),
+ )
+
+ # 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
+ ################################
+ #TODO: impl in BrowserWidget
+ def lastProgress(self):
+ """returns the last progress made by the browser
+ @return: (int) last progress
+ """
+ return self._lastProgress
+
+ def networkGetReplies(self):
+ return self._networkGetReplies[1]
+
+ def networkGetReply(self, indexReply):
+ return self._networkGetReplies[1][indexReply]
+
+ def setUserData(self, userData):
+ self._userData = userData
+
+ def userData(self):
+ return self._userData
+
+ ################################
+ ## overwritten methods
+ ################################
+ #def createWindow(self, typeWindow):
+ # pass
+
+ def load(self, url):
+ self._lastProgress = 0
+ return QtWebKit.QWebView.load(self, url)
+
+ 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):
+ """"""
+ self._lastProgress = 0
+ self.connect(
+ page.networkAccessManager(),
+ QtCore.SIGNAL('networkRequestCreated(QNetworkReply*)'),
+ self.onNetworkRequestCreated
+ )
+
+ self.emit(QtCore.SIGNAL('pageSet(QWebPage*)'), page)
+ return QtWebKit.QWebView.setPage(self, page)
+
+ def mouseMoveEvent(self, event):
+ QtWebKit.QWebView.mouseMoveEvent(self, event)
+ if self._lastProgress < self.MaxProgress:
+ self.setCursor(QtCore.Qt.BusyCursor)
+
+ ###############################
+ ## 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
+ self._networkGetReplies = [[], []]
+
+ def onLoadProgress(self, n):
+ self._lastProgress = n
+
+ def onLoadFinished(self, ok):
+ if ok:
+ self._lastProgress = self.MaxProgress
+ self.onActionStopTriggered()
+
+ def onPageDownloadRequested(self, networkRequest):
+ self.emit(QtCore.SIGNAL('downloadRequested(const QNetworkRequest &)'), networkRequest)
+
+ def onNetworkRequestCreated(self, reply):
+ if reply.operation() == QtNetwork.QNetworkAccessManager.GetOperation:
+ self._networkGetReplies[0].append(reply)
+ url = QtCore.QUrl(reply.url()) # copy url, qt nules it on return
+ networkReplyData = NetworkReplyData(self, url)
+ self._networkGetReplies[1].append(networkReplyData)
+ for signal, handler in self._networkReplySignals:
+ self.connect(reply, QtCore.SIGNAL(signal), handler)
+ self.emit(QtCore.SIGNAL('networkGetRequestCreated(int, QObject*)'), self._networkGetReplies[0].index(reply), networkReplyData)
+
+ def onNetworkReplyDownloadProgress(self, bytesReceived, bytesTotal):
+ reply = self.sender()
+ i = self._networkGetReplies[0].index(reply)
+ networkReplyData = self._networkGetReplies[1][i]
+ networkReplyData.bytesReceived = bytesReceived
+ networkReplyData.bytesTotal = bytesTotal
+ self.emit(QtCore.SIGNAL('networkReplyProgress(int, QObject*)'), i, networkReplyData)
+
+ def onNetworkReplyError(self, errorCode):
+ reply = self.sender()
+ i = self._networkGetReplies[0].index(reply)
+ networkReplyData = self._networkGetReplies[1][i]
+ networkReplyData.finished = True
+ networkReplyData.errorCode = errorCode
+ self.emit(QtCore.SIGNAL('networkReplyError(int, QObject*)'), i, networkReplyData)
+ #for signal, handler in self._networkReplySignals:
+ # self.disconnect(reply, QtCore.SIGNAL(signal), handler)
+
+ def onNetworkReplyFinished(self):
+ reply = self.sender()
+ i = self._networkGetReplies[0].index(reply)
+ networkReplyData = self._networkGetReplies[1][i]
+ networkReplyData.finished = True
+ for signal, handler in self._networkReplySignals:
+ self.disconnect(reply, QtCore.SIGNAL(signal), handler)
+ self.emit(QtCore.SIGNAL('networkReplyFinished(int, QObject*)'), i, networkReplyData)
\ No newline at end of file
Added: trunk/fclient/fclient/impl/ViewBrowser/BrowserWidget.ui
===================================================================
--- trunk/fclient/fclient/impl/ViewBrowser/BrowserWidget.ui (rev 0)
+++ trunk/fclient/fclient/impl/ViewBrowser/BrowserWidget.ui 2008-08-16 07:43:18 UTC (rev 910)
@@ -0,0 +1,267 @@
+<ui version="4.0" >
+ <class>ViewBrowserWidget</class>
+ <widget class="QWidget" name="ViewBrowserWidget" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>710</width>
+ <height>794</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_4" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>0</number>
+ </property>
+ <item row="0" column="0" >
+ <layout class="QHBoxLayout" name="horizontalLayout" >
+ <property name="spacing" >
+ <number>0</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" >
+ <item>
+ <widget class="QFrame" name="frameTools" >
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>0</number>
+ </property>
+ <item row="0" column="0" >
+ <widget class="QToolButton" name="btBack" >
+ <property name="text" >
+ <string>Back</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QToolButton" name="btForward" >
+ <property name="text" >
+ <string>Forward</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3" >
+ <widget class="QToolButton" name="btReload" >
+ <property name="text" >
+ <string>Reload</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="4" >
+ <widget class="QToolButton" name="btStop" >
+ <property name="text" >
+ <string>Stop</string>
+ </property>
+ </widget>
+ ...
[truncated message content] |
|
From: <jU...@us...> - 2008-08-16 07:54:30
|
Revision: 911
http://fclient.svn.sourceforge.net/fclient/?rev=911&view=rev
Author: jUrner
Date: 2008-08-16 07:54:39 +0000 (Sat, 16 Aug 2008)
Log Message:
-----------
isolated connection view
Modified Paths:
--------------
trunk/fclient/fclient/fclient.py
trunk/fclient/fclient/impl/Prefs.py
Added Paths:
-----------
trunk/fclient/fclient/impl/ViewConnection/
trunk/fclient/fclient/impl/ViewConnection/ConnectionWidgetTpl.ui
trunk/fclient/fclient/impl/ViewConnection/Ui_ConnectionWidgetTpl.py
trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py
trunk/fclient/fclient/impl/ViewConnection/__init__.py
trunk/fclient/fclient/impl/ViewConnection/_fix_mexec.py
trunk/fclient/fclient/impl/ViewConnection/prefs/
trunk/fclient/fclient/impl/ViewConnection/prefs/PrefsConnectionExpertSettings.ui
trunk/fclient/fclient/impl/ViewConnection/prefs/PrefsConnectionWidget.py
trunk/fclient/fclient/impl/ViewConnection/prefs/Ui_PrefsConnectionExpertSettings.py
trunk/fclient/fclient/impl/ViewConnection/prefs/__init__.py
trunk/fclient/fclient/impl/ViewConnection/prefs/_fix_mexec.py
Removed Paths:
-------------
trunk/fclient/fclient/impl/PrefsConnectionWidget.py
trunk/fclient/fclient/impl/ViewConnection.py
trunk/fclient/fclient/impl/tpls/PrefsConnectionExpertSettingsTpl.ui
trunk/fclient/fclient/impl/tpls/Ui_PrefsConnectionExpertSettingsTpl.py
trunk/fclient/fclient/impl/tpls/Ui_ViewConnectionWidgetTpl.py
trunk/fclient/fclient/impl/tpls/ViewConnectionWidgetTpl.ui
Modified: trunk/fclient/fclient/fclient.py
===================================================================
--- trunk/fclient/fclient/fclient.py 2008-08-16 07:43:18 UTC (rev 910)
+++ trunk/fclient/fclient/fclient.py 2008-08-16 07:54:39 UTC (rev 911)
@@ -15,7 +15,7 @@
from .impl.MainWindow import MainWindow
from .impl.View import ViewWidget
from .impl.ViewBrowser import ViewBrowser
-from .impl.ViewConnection import ViewConnectionWidget
+from .impl.ViewConnection import ViewConnection
from .impl.ViewDownloads import ViewDownloadsWidget
from .impl.ViewLogger import ViewLoggerWidget
from .impl.ViewUploads import ViewUploadsWidget
@@ -76,7 +76,7 @@
viewWidget = ViewWidget(mainWindow)
mainWindow.setCentralWidget(viewWidget)
viewWidget.addTopViews(
- ViewConnectionWidget(mainWindow),
+ ViewConnection.ViewConnectionWidget(mainWindow),
ViewBrowser.ViewBrowserWidget(mainWindow),
ViewDownloadsWidget(mainWindow),
ViewUploadsWidget(mainWindow),
Modified: trunk/fclient/fclient/impl/Prefs.py
===================================================================
--- trunk/fclient/fclient/impl/Prefs.py 2008-08-16 07:43:18 UTC (rev 910)
+++ trunk/fclient/fclient/impl/Prefs.py 2008-08-16 07:54:39 UTC (rev 911)
@@ -9,7 +9,7 @@
from .lib.qt4ex import dlgpreferences
from .PrefsGlobal import PrefsPageGlobal
from .ViewBrowser.prefs import PrefsBrowserWidget
-from .PrefsConnectionWidget import PrefsPageConnectionExpertSettings
+from .ViewConnection.prefs.PrefsConnectionWidget import PrefsPageConnectionExpertSettings
from .PrefsSingleApp import PrefsPageSingleApp
#**********************************************************************************
#
Deleted: trunk/fclient/fclient/impl/PrefsConnectionWidget.py
===================================================================
--- trunk/fclient/fclient/impl/PrefsConnectionWidget.py 2008-08-16 07:43:18 UTC (rev 910)
+++ trunk/fclient/fclient/impl/PrefsConnectionWidget.py 2008-08-16 07:54:39 UTC (rev 911)
@@ -1,128 +0,0 @@
-"""
-"""
-#*******************************************************************************
-#TODO:
-#
-# x. should we reconnect when the user changes the fcp connection name?
-#
-#
-#******************************************************************************
-
-from __future__ import absolute_import
-if __name__ == '__main__': # see --> http://bugs.Fc.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 .lib.qt4ex.lib import settings
-
-from .tpls.Ui_PrefsConnectionExpertSettingsTpl import Ui_PrefsConnectionExpertSettings
-#**********************************************************************************
-#
-#**********************************************************************************
-class PrefsConnectionExpertSettingsWidget(QtGui.QWidget, Ui_PrefsConnectionExpertSettings):
-
- IdEdFcpConnectionName = 'edFcpConnectionName'
- IdSpinFcpConnectionTimerMaxDuration = 'spinFcpConnectionTimerMaxDuration'
- IdSpinConnectionTimerTimeout = 'spinConnectionTimerTimeout'
- IdSpinFcpPollTimerTimeout = 'spinFcpPollTimerTimeout'
-
-
- def __init__(self, parent=None, page=None):
- QtGui.QWidget.__init__(self, parent)
-
- self.setupUi(self)
- self.setWindowTitle(config.FcAppName + self.trUtf8(' - Connection expert settings'))
- self.fcSettingsControler = None
-
- #
- connectionWidget = config.ObjectRegistry.get(config.IdViewConnectionWidget, None)
- if connectionWidget is None:
- self.setEnabled(False)
- else:
- self.fcSettingsControler = settings.SettingsControler(connectionWidget.fcSettings, parent=self)
- if page is not None:
- page.connect(self.fcSettingsControler, QtCore.SIGNAL('isDirty(bool)'), page.setDirty)
- self.fcSettingsControler.addLineEdit(
- self.controlById(self.IdEdFcpConnectionName),
- 'FcpConnectionName',
- )
- self.fcSettingsControler.addSpinBox(
- self.controlById(self.IdSpinFcpConnectionTimerMaxDuration),
- 'FcpConnectionTimerMaxDuration',
- )
- self.fcSettingsControler.addSpinBox(
- self.controlById(self.IdSpinConnectionTimerTimeout),
- 'FcpConnectionTimerTimeout',
- )
- self.fcSettingsControler.addSpinBox(
- self.controlById(self.IdSpinFcpPollTimerTimeout),
- 'FcpPollTimerTimeout',
- )
-
- def controlById(self, idControl):
- return getattr(self, idControl)
-
- def doApply(self):
- if self.fcSettingsControler is not None:
- return self.fcSettingsControler.apply()
- return False
-
- def doRestoreDefaults(self):
- if self.fcSettingsControler is not None:
- return self.fcSettingsControler.restoreDefaults()
- return False
-
-#***********************************************************************
-#
-#***********************************************************************
-class PrefsPageConnectionExpertSettings(dlgpreferences.Page):
-
- UUID = '{{98c7efcb-5636-4bf5-8192-10e7ccb09314}'
-
- def __init__(self):
- dlgpreferences.Page.__init__(self, self.UUID)
- self._widget = None
-
- def displayName(self):
- return self.trUtf8('Connection')
-
- def canApply(self): return True
- def canHelp(self): return False
- def canRestoreDefaults(self): return True
-
- def doApply(self):
- self._widget.doApply()
- return True
-
- def doRestoreDefaults(self):
- self._widget.doRestoreDefaults()
- return True
-
- def setVisible(self, parent, flag):
- createdNew = False
- if flag and self._widget is None:
- createdNew = True
- self._widget = PrefsConnectionExpertSettingsWidget(parent, page=self)
- self.connect(self._widget, QtCore.SIGNAL('setDirty(bool)'), self.setDirty)
- self._widget.setVisible(flag)
- return (createdNew, self._widget)
-
-
-
-#***********************************************************************
-#
-#***********************************************************************
-if __name__ == '__main__':
- from PyQt4 import QtGui
- import sys
-
- app = QtGui.QApplication(sys.argv)
- w = PrefsConnectionExpertSettingsWidget(None)
- w.show()
- res = app.exec_()
- sys.exit(res)
-
Added: trunk/fclient/fclient/impl/ViewConnection/ConnectionWidgetTpl.ui
===================================================================
--- trunk/fclient/fclient/impl/ViewConnection/ConnectionWidgetTpl.ui (rev 0)
+++ trunk/fclient/fclient/impl/ViewConnection/ConnectionWidgetTpl.ui 2008-08-16 07:54:39 UTC (rev 911)
@@ -0,0 +1,170 @@
+<ui version="4.0" >
+ <class>ViewConnectionWidget</class>
+ <widget class="QWidget" name="ViewConnectionWidget" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>421</width>
+ <height>558</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="fieldHeader" >
+ <property name="text" >
+ <string>Fcp connection:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <layout class="QHBoxLayout" name="horizontalLayout" >
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout" >
+ <item>
+ <widget class="QLabel" name="fieldName" >
+ <property name="text" >
+ <string>Host:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="fieldName_2" >
+ <property name="text" >
+ <string>Port:</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" >
+ <item>
+ <widget class="QLineEdit" name="edFcpConnectionHost" >
+ <property name="dragEnabled" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="spinFcpConnectionPort" />
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item rowspan="5" row="1" column="1" >
+ <widget class="Line" name="line" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2" >
+ <spacer name="horizontalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>229</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QCheckBox" name="ckFcpAutoConnect" >
+ <property name="text" >
+ <string>Auto Connect</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="Line" name="line_2" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0" >
+ <widget class="QLabel" name="fieldHeader_2" >
+ <property name="text" >
+ <string>Fproxy connection:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" >
+ <layout class="QVBoxLayout" name="verticalLayout_5" >
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2" >
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_3" >
+ <item>
+ <widget class="QLabel" name="fieldName_3" >
+ <property name="text" >
+ <string>Host:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="fieldName_4" >
+ <property name="text" >
+ <string>Port:</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2" >
+ <item>
+ <widget class="QLineEdit" name="edFproxyConnectionHost" >
+ <property name="dragEnabled" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="spinFproxyConnectionPort" />
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item row="6" column="0" >
+ <spacer name="verticalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>20</width>
+ <height>97</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="7" column="0" colspan="3" >
+ <widget class="QPushButton" name="btConnect" >
+ <property name="text" >
+ <string>Connect</string>
+ </property>
+ <property name="checkable" >
+ <bool>true</bool>
+ </property>
+ <property name="autoExclusive" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
Added: trunk/fclient/fclient/impl/ViewConnection/Ui_ConnectionWidgetTpl.py
===================================================================
--- trunk/fclient/fclient/impl/ViewConnection/Ui_ConnectionWidgetTpl.py (rev 0)
+++ trunk/fclient/fclient/impl/ViewConnection/Ui_ConnectionWidgetTpl.py 2008-08-16 07:54:39 UTC (rev 911)
@@ -0,0 +1,117 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file '/home/me/src/fclient/trunk/fclient/fclient/impl/ViewConnection/ConnectionWidgetTpl.ui'
+#
+# Created: Sat Aug 16 09:44:39 2008
+# by: PyQt4 UI code generator 4.4.3-snapshot-20080705
+#
+# WARNING! All changes made in this file will be lost!
+
+from PyQt4 import QtCore, QtGui
+
+class Ui_ViewConnectionWidget(object):
+ def setupUi(self, ViewConnectionWidget):
+ ViewConnectionWidget.setObjectName("ViewConnectionWidget")
+ ViewConnectionWidget.resize(421, 558)
+ self.gridLayout = QtGui.QGridLayout(ViewConnectionWidget)
+ self.gridLayout.setObjectName("gridLayout")
+ self.fieldHeader = QtGui.QLabel(ViewConnectionWidget)
+ self.fieldHeader.setObjectName("fieldHeader")
+ self.gridLayout.addWidget(self.fieldHeader, 0, 0, 1, 1)
+ self.horizontalLayout = QtGui.QHBoxLayout()
+ self.horizontalLayout.setObjectName("horizontalLayout")
+ self.verticalLayout = QtGui.QVBoxLayout()
+ self.verticalLayout.setObjectName("verticalLayout")
+ self.fieldName = QtGui.QLabel(ViewConnectionWidget)
+ self.fieldName.setObjectName("fieldName")
+ self.verticalLayout.addWidget(self.fieldName)
+ self.fieldName_2 = QtGui.QLabel(ViewConnectionWidget)
+ self.fieldName_2.setObjectName("fieldName_2")
+ self.verticalLayout.addWidget(self.fieldName_2)
+ self.horizontalLayout.addLayout(self.verticalLayout)
+ self.vboxlayout = QtGui.QVBoxLayout()
+ self.vboxlayout.setObjectName("vboxlayout")
+ self.edFcpConnectionHost = QtGui.QLineEdit(ViewConnectionWidget)
+ self.edFcpConnectionHost.setDragEnabled(True)
+ self.edFcpConnectionHost.setObjectName("edFcpConnectionHost")
+ self.vboxlayout.addWidget(self.edFcpConnectionHost)
+ self.spinFcpConnectionPort = QtGui.QSpinBox(ViewConnectionWidget)
+ self.spinFcpConnectionPort.setObjectName("spinFcpConnectionPort")
+ self.vboxlayout.addWidget(self.spinFcpConnectionPort)
+ self.horizontalLayout.addLayout(self.vboxlayout)
+ self.gridLayout.addLayout(self.horizontalLayout, 1, 0, 1, 1)
+ self.line = QtGui.QFrame(ViewConnectionWidget)
+ self.line.setFrameShape(QtGui.QFrame.VLine)
+ self.line.setFrameShadow(QtGui.QFrame.Sunken)
+ self.line.setObjectName("line")
+ self.gridLayout.addWidget(self.line, 1, 1, 5, 1)
+ spacerItem = QtGui.QSpacerItem(229, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
+ self.gridLayout.addItem(spacerItem, 1, 2, 1, 1)
+ self.ckFcpAutoConnect = QtGui.QCheckBox(ViewConnectionWidget)
+ self.ckFcpAutoConnect.setObjectName("ckFcpAutoConnect")
+ self.gridLayout.addWidget(self.ckFcpAutoConnect, 2, 0, 1, 1)
+ self.line_2 = QtGui.QFrame(ViewConnectionWidget)
+ self.line_2.setFrameShape(QtGui.QFrame.HLine)
+ self.line_2.setFrameShadow(QtGui.QFrame.Sunken)
+ self.line_2.setObjectName("line_2")
+ self.gridLayout.addWidget(self.line_2, 3, 0, 1, 1)
+ self.fieldHeader_2 = QtGui.QLabel(ViewConnectionWidget)
+ self.fieldHeader_2.setObjectName("fieldHeader_2")
+ self.gridLayout.addWidget(self.fieldHeader_2, 4, 0, 1, 1)
+ self.verticalLayout_5 = QtGui.QVBoxLayout()
+ self.verticalLayout_5.setObjectName("verticalLayout_5")
+ self.horizontalLayout_2 = QtGui.QHBoxLayout()
+ self.horizontalLayout_2.setObjectName("horizontalLayout_2")
+ self.verticalLayout_3 = QtGui.QVBoxLayout()
+ self.verticalLayout_3.setObjectName("verticalLayout_3")
+ self.fieldName_3 = QtGui.QLabel(ViewConnectionWidget)
+ self.fieldName_3.setObjectName("fieldName_3")
+ self.verticalLayout_3.addWidget(self.fieldName_3)
+ self.fieldName_4 = QtGui.QLabel(ViewConnectionWidget)
+ self.fieldName_4.setObjectName("fieldName_4")
+ self.verticalLayout_3.addWidget(self.fieldName_4)
+ self.horizontalLayout_2.addLayout(self.verticalLayout_3)
+ self.verticalLayout_2 = QtGui.QVBoxLayout()
+ self.verticalLayout_2.setObjectName("verticalLayout_2")
+ self.edFproxyConnectionHost = QtGui.QLineEdit(ViewConnectionWidget)
+ self.edFproxyConnectionHost.setDragEnabled(True)
+ self.edFproxyConnectionHost.setObjectName("edFproxyConnectionHost")
+ self.verticalLayout_2.addWidget(self.edFproxyConnectionHost)
+ self.spinFproxyConnectionPort = QtGui.QSpinBox(ViewConnectionWidget)
+ self.spinFproxyConnectionPort.setObjectName("spinFproxyConnectionPort")
+ self.verticalLayout_2.addWidget(self.spinFproxyConnectionPort)
+ self.horizontalLayout_2.addLayout(self.verticalLayout_2)
+ self.verticalLayout_5.addLayout(self.horizontalLayout_2)
+ self.gridLayout.addLayout(self.verticalLayout_5, 5, 0, 1, 1)
+ spacerItem1 = QtGui.QSpacerItem(20, 97, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
+ self.gridLayout.addItem(spacerItem1, 6, 0, 1, 1)
+ self.btConnect = QtGui.QPushButton(ViewConnectionWidget)
+ self.btConnect.setCheckable(True)
+ self.btConnect.setAutoExclusive(False)
+ self.btConnect.setObjectName("btConnect")
+ self.gridLayout.addWidget(self.btConnect, 7, 0, 1, 3)
+
+ self.retranslateUi(ViewConnectionWidget)
+ QtCore.QMetaObject.connectSlotsByName(ViewConnectionWidget)
+
+ def retranslateUi(self, ViewConnectionWidget):
+ ViewConnectionWidget.setWindowTitle(QtGui.QApplication.translate("ViewConnectionWidget", "Form", None, QtGui.QApplication.UnicodeUTF8))
+ self.fieldHeader.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Fcp connection:", None, QtGui.QApplication.UnicodeUTF8))
+ self.fieldName.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Host:", None, QtGui.QApplication.UnicodeUTF8))
+ self.fieldName_2.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Port:", None, QtGui.QApplication.UnicodeUTF8))
+ self.ckFcpAutoConnect.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Auto Connect", None, QtGui.QApplication.UnicodeUTF8))
+ self.fieldHeader_2.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Fproxy connection:", None, QtGui.QApplication.UnicodeUTF8))
+ self.fieldName_3.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Host:", None, QtGui.QApplication.UnicodeUTF8))
+ self.fieldName_4.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Port:", None, QtGui.QApplication.UnicodeUTF8))
+ self.btConnect.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Connect", None, QtGui.QApplication.UnicodeUTF8))
+
+
+if __name__ == "__main__":
+ import sys
+ app = QtGui.QApplication(sys.argv)
+ ViewConnectionWidget = QtGui.QWidget()
+ ui = Ui_ViewConnectionWidget()
+ ui.setupUi(ViewConnectionWidget)
+ ViewConnectionWidget.show()
+ sys.exit(app.exec_())
+
Added: trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py
===================================================================
--- trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py (rev 0)
+++ trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py 2008-08-16 07:54:39 UTC (rev 911)
@@ -0,0 +1,324 @@
+#*********************************************************************
+#TODO:
+# x. setting fcp/fproxy connection params currently won't reset connection. how to handle?
+#
+#
+#*********************************************************************
+# 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
+from PyQt4 import QtCore, QtGui
+
+from .. import config
+from ..lib import fcp2
+
+from .Ui_ConnectionWidgetTpl import Ui_ViewConnectionWidget
+#**********************************************************************************
+#
+#**********************************************************************************
+class Actions(config.ActionsBase):
+ pass
+
+
+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)
+
+ # status bar widgets
+ self.label1 = None
+ #if self.statusBar is not None:
+ # self.label1 = QtGui.QLabel('foo here', self.statusBar)
+
+ def setVisible(self, flag):
+ for menu in self.menus:
+ menu.children()[0].setEnabled(flag)
+ if self.label1 is not None:
+ self.label1.setVisible(flag)
+
+
+class Settings(config.SettingsBase):
+ _key_ = config.IdViewConnectionWidget
+ _settings_ = (
+ ('FcpAutoConnect', 'Bool', True),
+ ('FcpConnectionName', 'String', config.FcConnectionName),
+ ('FcpConnectionHost', 'String', fcp2.Client.DefaultFcpHost),
+ ('FcpConnectionPort', 'UInt', fcp2.Client.DefaultFcpPort),
+ ('FcpConnectionTimerTimeout', 'UInt', 500),
+ ('FcpConnectionTimerMaxDuration', 'UInt', 20),
+ ('FcpPollTimerTimeout', 'UInt', 200),
+
+ ('FproxyConnectionHost', 'String','127.0.0.1'),
+ ('FproxyConnectionPort', 'UInt', 8888),
+ )
+
+ def setValues(self, **kws):
+ config.SettingsBase.setValues(self, **kws)
+ parent = self.parent()
+
+ # set fcp connection params
+ if 'FcpConnectionHost' in kws:
+ edHost = parent.controlById(parent.IdEdFcpConnectionHost)
+ edHost.setText(self.value('FcpConnectionHost'))
+
+ if 'FcpConnectionPort' in kws:
+ spinPort = parent.controlById(parent.IdFcpSpinFcpConnectionPort)
+ spinPort.setValue(self.value('FcpConnectionPort'))
+
+ if 'FcpAutoConnect' in kws:
+ ck = parent.controlById(parent.IdCkFcpAutoConnect)
+ ck.setChecked(self.value('FcpAutoConnect'))
+
+ # set fproxy connection params
+ if 'FproxyConnectionHost' in kws:
+ edHost = parent.controlById(parent.IdEdFproxyConnectionHost)
+ edHost.setText(self.value('FproxyConnectionHost'))
+
+ if 'FproxyConnectionPort' in kws:
+ spinPort = parent.controlById(parent.IdFproxySpinConnectionPort)
+ spinPort.setValue(self.value('FproxyConnectionPort'))
+
+
+class ConnectionViewObject(config.ViewObject):
+
+ def __init__(self, parent):
+ config.ViewObject. __init__(self, parent)
+
+ self.name=parent.objectName()
+ self.displayName=self.trUtf8('Connection')
+ self.icon=QtGui.QIcon()
+
+
+#**********************************************************************************
+#
+#**********************************************************************************
+class ConnectionTimer(QtCore.QTimer):
+
+ def __init__(self,parent):
+ QtCore.QTimer.__init__(self, parent)
+ self.fcpIterConnect = None
+ self.connect(self, QtCore.SIGNAL('timeout()'), self.onNext)
+
+ def start(self, settings):
+ config.fcpClient.setConnectionName(settings.value('FcpConnectionName'))
+ self.fcpIterConnect = config.fcpClient.iterConnect(
+ host=settings.value('FcpConnectionHost'),
+ port=settings.value('FcpConnectionPort'),
+ duration=settings.value('FcpConnectionTimerMaxDuration'),
+ timeout=0
+ )
+ if not self.onNext():
+ QtCore.QTimer.start(self, settings.value('FcpConnectionTimerTimeout'))
+
+ def onNext(self):
+ try:
+ result = self.fcpIterConnect.next()
+ except StopIteration:
+ self.stop()
+ else:
+ if result is not None:
+ self.stop()
+ return True
+ return False
+
+
+class PollTimer(QtCore.QTimer):
+
+ def __init__(self,parent):
+ QtCore.QTimer.__init__(self, parent)
+ self.connect(self, QtCore.SIGNAL('timeout()'), self.onNext)
+
+ def start(self, settings):
+ QtCore.QTimer.start(self, settings.value('FcpPollTimerTimeout'))
+
+ def onNext(self):
+ if config.fcpClient.isConnected():
+ result = config.fcpClient.next()
+
+#***********************************************************************
+#
+#***********************************************************************
+class ViewConnectionWidget(QtGui.QWidget, Ui_ViewConnectionWidget):
+
+ IdBtConnect = 'btConnect'
+ IdEdFcpConnectionHost = 'edFcpConnectionHost'
+ IdFcpSpinFcpConnectionPort = 'spinFcpConnectionPort'
+ IdCkFcpAutoConnect = 'ckFcpAutoConnect'
+
+ IdEdFproxyConnectionHost = 'edFproxyConnectionHost'
+ IdFproxySpinConnectionPort = 'spinFproxyConnectionPort'
+
+
+ def __init__(self, parent, idGlobalFeedback=config.IdMainWindow):
+ QtGui.QWidget.__init__(self, parent)
+ self.setupUi(self)
+
+ # adjust spin box ranges
+ spinPort = self.controlById(self.IdFcpSpinFcpConnectionPort)
+ spinPort.setRange(0, 0xFFFF) #TODO: no idea if port range (0, 0xFFFF) this is reasonable
+ spinPort = self.controlById(self.IdFproxySpinConnectionPort)
+ spinPort.setRange(0, 0xFFFF) #TODO: no idea if port range (0, 0xFFFF) this is reasonable
+
+ self._isCreated = False
+ config.ObjectRegistry.register(self)
+ self.fcSettings = Settings(self).restore()
+ self.fcActions = Actions(self)
+ self.fcViewObject = ConnectionViewObject(self)
+ self.fcGlobalFeedback = GlobalFeedback(self,idGlobalFeedback)
+
+ self._connectionTimer = ConnectionTimer(self)
+ self._pollTimer = PollTimer(self)
+ self._fcpEventonrs = (
+ (config.fcpClient.events.ClientConnected, self.onFcpClientConected),
+ (config.fcpClient.events.ClientDisconnected, self.onFcpClientDisconected),
+ )
+ config.fcpClient.events += self._fcpEventonrs
+ self._mainWindowMenus = ()
+
+ #########################################
+ ## methods
+ #########################################
+ def connected(self):
+ return self.controlById(self.IdBtConnect).isChecked()
+
+ def controlById(self, idControl):
+ return getattr(self, idControl)
+
+ def populateMenu(self, menu):
+ return menu
+
+ def setConnected(self, flag):
+ bt = self.controlById(self.IdBtConnect)
+ if (bt.isChecked() and not flag) or (not bt.isChecked() and flag):
+ bt.click()
+ return True
+ return False
+
+ #########################################
+ ## view methods
+ #########################################
+ def viewClose(self):
+ config.fcpClient.events -= self._fcpEventonrs
+
+ #########################################
+ ## overwritten events
+ #########################################
+ def closeEvent(self, event):
+ self.viewClose()
+
+ def hideEvent(self, event):
+ self.fcGlobalFeedback.setVisible(False)
+
+ def showEvent(self, event):
+ self.fcGlobalFeedback.setVisible(True)
+ if self._isCreated:
+ return
+ self._isCreated = True
+
+ doAutoConnect = self.fcSettings.value('FcpAutoConnect')
+ ck = self.controlById(self.IdCkFcpAutoConnect)
+ ck.setChecked(doAutoConnect)
+ self.connect(ck, QtCore.SIGNAL('stateChanged(int)'), self.onCkFcpAutoConnectStateChanged)
+
+ spinPort = self.controlById(self.IdFcpSpinFcpConnectionPort)
+ self.connect(spinPort, QtCore.SIGNAL('valueChanged(int)'), self.onSpinFcpConnectionPortChanged)
+
+ spinPort = self.controlById(self.IdFproxySpinConnectionPort)
+ self.connect(spinPort, QtCore.SIGNAL('valueChanged(int)'), self.onSpinFproxyConnectionPortChanged)
+
+ # setup fproxy host / port
+ edHost = self.controlById(self.IdEdFproxyConnectionHost)
+ self.connect(edHost, QtCore.SIGNAL('textChanged(const QString &)'), self.onEdFproxyConnectionHostChanged)
+
+ bt = self.controlById(self.IdBtConnect)
+ self.connect(bt, QtCore.SIGNAL('clicked(bool)'), self.onBtConnectClicked)
+ if doAutoConnect:
+ self.controlById(self.IdBtConnect).click()
+
+ ########################################
+ ## overwritten methods
+ #########################################
+ def retranslateUi(self, w):
+ Ui_ViewConnectionWidget.retranslateUi(self, w)
+ bt = self.controlById(self.IdBtConnect)
+ bt.setText(self.trUtf8('Disconnect') if self.connected() else self.trUtf8('Connect'))
+
+
+ #########################################
+ ## event onrs
+ #########################################
+ def onBtConnectClicked(self, isChecked):
+ bt = self.controlById(self.IdBtConnect)
+ bt.setText(self.trUtf8('Disconnect') if isChecked else self.trUtf8('Connect'))
+ if isChecked:
+ if config.fcpClient.isConnected():
+ config.fcpClient.close()
+ self._connectionTimer.start(self.fcSettings)
+ else:
+ self._connectionTimer.stop()
+ if config.fcpClient.isConnected():
+ self._pollTimer.stop()
+ config.fcpClient.close()
+
+
+ def onCkFcpAutoConnectStateChanged(self, state):
+ self.fcSettings.setValues(FcpAutoConnect=state == QtCore.Qt.Checked)
+
+ d...
[truncated message content] |
|
From: <jU...@us...> - 2008-08-16 07:59:01
|
Revision: 912
http://fclient.svn.sourceforge.net/fclient/?rev=912&view=rev
Author: jUrner
Date: 2008-08-16 07:59:09 +0000 (Sat, 16 Aug 2008)
Log Message:
-----------
isolated logger view
Modified Paths:
--------------
trunk/fclient/fclient/fclient.py
Added Paths:
-----------
trunk/fclient/fclient/impl/ViewLogger/
trunk/fclient/fclient/impl/ViewLogger/LoggerWidget.ui
trunk/fclient/fclient/impl/ViewLogger/Ui_LoggerWidget.py
trunk/fclient/fclient/impl/ViewLogger/ViewLogger.py
trunk/fclient/fclient/impl/ViewLogger/__init__.py
trunk/fclient/fclient/impl/ViewLogger/_fix_mexec.py
Removed Paths:
-------------
trunk/fclient/fclient/impl/ViewLogger.py
trunk/fclient/fclient/impl/tpls/SideBarLoadDetailsTpl.ui
trunk/fclient/fclient/impl/tpls/Ui_ViewLoggerWidgetTpl.py
trunk/fclient/fclient/impl/tpls/ViewLoggerWidgetTpl.ui
Modified: trunk/fclient/fclient/fclient.py
===================================================================
--- trunk/fclient/fclient/fclient.py 2008-08-16 07:54:39 UTC (rev 911)
+++ trunk/fclient/fclient/fclient.py 2008-08-16 07:59:09 UTC (rev 912)
@@ -17,7 +17,7 @@
from .impl.ViewBrowser import ViewBrowser
from .impl.ViewConnection import ViewConnection
from .impl.ViewDownloads import ViewDownloadsWidget
-from .impl.ViewLogger import ViewLoggerWidget
+from .impl.ViewLogger import ViewLogger
from .impl.ViewUploads import ViewUploadsWidget
from .impl.DlgSingleAppError import DlgSingleAppError
@@ -81,7 +81,7 @@
ViewDownloadsWidget(mainWindow),
ViewUploadsWidget(mainWindow),
)
- viewWidget.addBottomViews(ViewLoggerWidget(mainWindow))
+ viewWidget.addBottomViews(ViewLogger.ViewLoggerWidget(mainWindow))
mainWindow.show()
res = app.exec_()
Added: trunk/fclient/fclient/impl/ViewLogger/LoggerWidget.ui
===================================================================
--- trunk/fclient/fclient/impl/ViewLogger/LoggerWidget.ui (rev 0)
+++ trunk/fclient/fclient/impl/ViewLogger/LoggerWidget.ui 2008-08-16 07:59:09 UTC (rev 912)
@@ -0,0 +1,30 @@
+<ui version="4.0" >
+ <class>ViewLoggerWidget</class>
+ <widget class="QWidget" name="ViewLoggerWidget" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>550</width>
+ <height>471</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout" >
+ <item row="0" column="0" >
+ <widget class="QPlainTextEdit" name="edLogger" >
+ <property name="lineWrapMode" >
+ <enum>QPlainTextEdit::NoWrap</enum>
+ </property>
+ <property name="readOnly" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
Added: trunk/fclient/fclient/impl/ViewLogger/Ui_LoggerWidget.py
===================================================================
--- trunk/fclient/fclient/impl/ViewLogger/Ui_LoggerWidget.py (rev 0)
+++ trunk/fclient/fclient/impl/ViewLogger/Ui_LoggerWidget.py 2008-08-16 07:59:09 UTC (rev 912)
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file '/home/me/src/fclient/trunk/fclient/fclient/impl/ViewLogger/LoggerWidget.ui'
+#
+# Created: Sat Aug 16 09:56:26 2008
+# by: PyQt4 UI code generator 4.4.3-snapshot-20080705
+#
+# WARNING! All changes made in this file will be lost!
+
+from PyQt4 import QtCore, QtGui
+
+class Ui_ViewLoggerWidget(object):
+ def setupUi(self, ViewLoggerWidget):
+ ViewLoggerWidget.setObjectName("ViewLoggerWidget")
+ ViewLoggerWidget.resize(550, 471)
+ self.gridLayout = QtGui.QGridLayout(ViewLoggerWidget)
+ self.gridLayout.setObjectName("gridLayout")
+ self.edLogger = QtGui.QPlainTextEdit(ViewLoggerWidget)
+ self.edLogger.setLineWrapMode(QtGui.QPlainTextEdit.NoWrap)
+ self.edLogger.setReadOnly(True)
+ self.edLogger.setObjectName("edLogger")
+ self.gridLayout.addWidget(self.edLogger, 0, 0, 1, 1)
+
+ self.retranslateUi(ViewLoggerWidget)
+ QtCore.QMetaObject.connectSlotsByName(ViewLoggerWidget)
+
+ def retranslateUi(self, ViewLoggerWidget):
+ ViewLoggerWidget.setWindowTitle(QtGui.QApplication.translate("ViewLoggerWidget", "Form", None, QtGui.QApplication.UnicodeUTF8))
+
+
+if __name__ == "__main__":
+ import sys
+ app = QtGui.QApplication(sys.argv)
+ ViewLoggerWidget = QtGui.QWidget()
+ ui = Ui_ViewLoggerWidget()
+ ui.setupUi(ViewLoggerWidget)
+ ViewLoggerWidget.show()
+ sys.exit(app.exec_())
+
Added: trunk/fclient/fclient/impl/ViewLogger/ViewLogger.py
===================================================================
--- trunk/fclient/fclient/impl/ViewLogger/ViewLogger.py (rev 0)
+++ trunk/fclient/fclient/impl/ViewLogger/ViewLogger.py 2008-08-16 07:59:09 UTC (rev 912)
@@ -0,0 +1,276 @@
+
+# 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 sys
+import logging
+
+from PyQt4 import QtCore, QtGui
+
+from .. import config
+from ..lib import fcp2
+
+from .Ui_LoggerWidget import Ui_ViewLoggerWidget
+#**********************************************************************************
+#
+#**********************************************************************************
+class Actions(config.ActionsBase):
+
+ PrefixVerbosity = 'ActionVerbosity'
+
+ def __init__(self, parent):
+ config.ActionsBase.__init__(self, parent)
+
+ # for ease of use verbosities are mapped to verbosity actions like this: PrefixVerbosity + Verbosity
+ self.action(
+ name='ActionLoggerClear',
+ text=self.trUtf8('C&lear'),
+ trigger=parent.onActionLoggerClear,
+ )
+
+ groupVerbosity = self.group(
+ name='GroupVerbosity',
+ trigger=parent.onGroupVerbosityTriggered,
+ isExclusive=True,
+ )
+ self.action(
+ name='ActionVerbosityInfo',
+ text=self.trUtf8('Info'),
+ group=groupVerbosity,
+ trigger=None,
+ isCheckable=True,
+ userData=fcp2.ConstDebugVerbosity.Info,
+ )
+ self.action(
+ name='ActionVerbosityMessage',
+ text=self.trUtf8('Message'),
+ group=groupVerbosity,
+ trigger=None,
+ isCheckable=True,
+ userData=fcp2.ConstDebugVerbosity.Message,
+ )
+ self.action(
+ name='ActionVerbosityDebug',
+ text=self.trUtf8('Debug'),
+ group=groupVerbosity,
+ trigger=None,
+ isCheckable=True,
+ userData=fcp2.ConstDebugVerbosity.Debug,
+ )
+ self.action(
+ name='ActionVerbosityChatty',
+ text=self.trUtf8('Chatty'),
+ group=groupVerbosity,
+ trigger=None,
+ isCheckable=True,
+ userData=fcp2.ConstDebugVerbosity.Chatty,
+ )
+
+
+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)
+
+ # status bar widgets
+ self.label1 = None
+ #if self.statusBar is not None:
+ # self.label1 = QtGui.QLabel('foo here', self.statusBar)
+
+ def setVisible(self, flag):
+ for menu in self.menus:
+ menu.children()[0].setVisible(flag)
+ if self.label1 is not None:
+ self.label1.setVisible(flag)
+
+
+class Settings(config.SettingsBase):
+
+ PrefixVerbosityColorFg = 'ColorFgVerbosity'
+
+ _key_ = config.IdViewLoggerWidget
+ _settings_ = (
+ ('MaxLines', 'UInt', 1000),
+ ('Verbosity', 'PyString', 'Info'),
+
+ #TODO: Chatty does not seem to work. check in fcp2.client
+ ('ColorFgVerbosityCRITICAL', 'QColor', QtGui.QColor('red')),
+ ('ColorFgVerbosityERROR', 'QColor', QtGui.QColor('red')),
+ ('ColorFgVerbosityWARNING', 'QColor', QtGui.QColor('red')),
+ ('ColorFgVerbosityINFO', 'QColor', QtGui.QColor('black')),
+ ('ColorFgVerbosityMESSAGE', 'QColor', QtGui.QColor('blue')),
+ ('ColorFgVerbosityDEBUG', 'QColor', QtGui.QColor('slategray')),
+ ('ColorFgVerbosityCHATTY', 'QColor', QtGui.QColor('lightslategray')),
+ )
+
+
+class LoggerViewObject(config.ViewObject):
+
+ def __init__(self, parent):
+ config.ViewObject. __init__(self, parent)
+
+ self.name=parent.objectName()
+ self.displayName=self.trUtf8('Logger')
+ self.icon=QtGui.QIcon()
+
+
+#***********************************************************************
+#
+#***********************************************************************
+class MyLoggingHandler(logging.Handler):
+
+ def __init__(self, cb, *args, **kwargs):
+ logging.Handler.__init__(self, *args, **kwargs)
+ self.cb = cb
+
+ def emit(self, record):
+ self.cb(record)
+
+#***********************************************************************
+#
+#***********************************************************************
+class ViewLoggerWidget(QtGui.QWidget, Ui_ViewLoggerWidget):
+
+ IdEdLogger = 'edLogger'
+
+
+ def __init__(self, parent, idGlobalFeedback=config.IdMainWindow):
+ QtGui.QWidget.__init__(self, parent)
+ self._isCreated = False
+ self._mainWindowMenus = {} #TODO: wrap along with toolbars to a handy class MainWindowStuff
+
+ self.setupUi(self)
+ config.ObjectRegistry.register(self)
+
+ self.fcActions = Actions(self)
+ self.fcSettings = Settings(self).restore()
+ self.fcViewObject = LoggerViewObject(self)
+ self.fcGlobalFeedback = GlobalFeedback(self, idGlobalFeedback)
+
+
+ # setup editbox
+ #NOTE: do not move to showEvent(). we want to be up and alive as soon as possible to catch logs
+ ed = self.controlById(self.IdEdLogger)
+ ed.document().setMaximumBlockCount(self.fcSettings.value('MaxLines'))
+ ed.contextMenuEvent = self.loggerContextMenuEvent
+ self.connect(ed, QtCore.SIGNAL('textChanged()'), self.onLoggerTextChanged)
+
+ # setup logger
+ self.loggingHandler = MyLoggingHandler(self.addRecord)
+ logging.getLogger('').addHandler(self.loggingHandler)
+
+ # setup actions
+ verbosity = self.fcSettings.value('Verbosity').title()
+ action = self.fcActions.get(self.fcActions.PrefixVerbosity + verbosity, None)
+ if action is None:
+ verbosity = self.fcSettings.restoreDefaults('Verbosity')['Verbosity']
+ action = self.fcActions.get(self.fcActions.PrefixVerbosity + verbosity, None)
+ if action is None:
+ raise ValueError('default verbosity action "%s" not found. WTF?' % self.actions.PrefixVerbosity + verbosity)
+ action.trigger()
+
+ #########################################
+ ## methods
+ #########################################
+ def addRecord(self, record):
+ """adds a logging record"""
+ ed = self.controlById(self.IdEdLogger)
+ fmt = ed.currentCharFormat()
+ colorFg = self.fcSettings.value(self.fcSettings.PrefixVerbosityColorFg + record.levelname)
+ fmt.setForeground(QtGui.QBrush(colorFg))
+ ed.setCurrentCharFormat(fmt)
+
+ text = '%s:%s:%s' % (record.levelname, record.name, record.getMessage())
+ ed.appendPlainText(text)
+
+ def controlById(self, idControl):
+ return getattr(self, idControl)
+
+ def populateMenu(self, menu):
+ menu.addAction(self.fcActions['ActionLoggerClear'])
+ subMenu = menu.addMenu(self.trUtf8('Verbosity'))
+ subMenu.addActions(self.fcActions['GroupVerbosity'].actions())
+ return menu
+
+ #########################################
+ ##view methods
+ #########################################
+ def viewClose(self):
+ pass
+
+ def viewDisplayName(self):
+ return self.trUtf8('Logger')
+
+ def viewIcon(self):
+ return QtGui.QIcon()
+
+ def viewName(self):
+ return self.objectName()
+
+ #########################################
+ ## overwritten events
+ #########################################
+ def loggerContextMenuEvent(self, event):
+ """customize context menu of the logger QTextEdit"""
+ ed = self.controlById(self.IdEdLogger)
+ menu = ed.createStandardContextMenu()
+ self.populateMenu(menu)
+ menu.exec_(event.globalPos())
+
+ def hideEvent(self, event):
+ self.fcGlobalFeedback.setVisible(False)
+
+ def showEvent(self, event):
+ self.fcGlobalFeedback.setVisible(True)
+ if self._isCreated:
+ return
+ self._isCreated = True
+
+ #########################################
+ ## event onrs
+ #########################################
+ def onActionLoggerClear(self, action):
+ self.controlById(self.IdEdLogger).clear()
+
+ def onGroupVerbosityTriggered(self, action):
+ nameVerbosity = action.objectName()[len(self.fcActions.PrefixVerbosity):]
+ self.fcSettings.setValues(Verbosity=nameVerbosity)
+ logging.getLogger().setLevel(action.userData())
+
+ def onLoggerTextChanged(self):
+ ed = self.controlById(self.IdEdLogger)
+ self.fcActions['ActionLoggerClear'].setEnabled(not ed.document().isEmpty())
+
+#**********************************************************************************
+#
+#**********************************************************************************
+if __name__ == '__main__':
+ import sys
+
+ app = QtGui.QApplication(sys.argv)
+ w = ViewLoggerWidget(None)
+
+ w.show()
+ res = app.exec_()
+ sys.exit(res)
+
+
+
Added: trunk/fclient/fclient/impl/ViewLogger/__init__.py
===================================================================
--- trunk/fclient/fclient/impl/ViewLogger/__init__.py (rev 0)
+++ trunk/fclient/fclient/impl/ViewLogger/__init__.py 2008-08-16 07:59:09 UTC (rev 912)
@@ -0,0 +1 @@
+
Added: trunk/fclient/fclient/impl/ViewLogger/_fix_mexec.py
===================================================================
--- trunk/fclient/fclient/impl/ViewLogger/_fix_mexec.py (rev 0)
+++ trunk/fclient/fclient/impl/ViewLogger/_fix_mexec.py 2008-08-16 07:59:09 UTC (rev 912)
@@ -0,0 +1,99 @@
+'''in python 2.5 relative impports are srsly broken ..fix this to make relative imports work
+when executing a module as main (-m), including relative imports up to the root package
+
+see: [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html]
+
+@note: root package is the highest available package in the package hirarchy.
+don't look at __name__ too closely. it gets adjusted for a module to just "do the right
+thing" in __name__ == '__main__' comparisons
+@note: this patch does not work if relative imports are done in __init__.py. no idea why
+and to be honest, I don't wanna* know..
+@note: this is more or less a hack. so it may have unwanted side effects for example
+when importing parent packages. use at your own risk. could improve this module
+by adding a __main__.py to stop at this level or by fixing the __init__.py bug, but
+I don't think its worth it. see what python2.6 or 3k brings..
+
+usage::
+
+ # place this at the top a module, before doing any relative imports
+ from fix_mexec import fix_mexec
+ fix_mexec(__name__, __file__)
+ del fix_mexec
+
+ from ...foo import bar
+
+
+
+##<-- copy and paste code, assuming _fix_mexec resides in the current dir..
+
+# 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
+
+
+##--> copy and paste code
+'''
+
+import imp, os, sys
+#********************************************************************************
+#
+#********************************************************************************
+class MainName(str):
+ def __eq__(self, other):
+ if other == '__main__': return True
+ return str.__eq__(self, other)
+ def __ne__(self, other):
+ if other == '__main__': return False
+ return str.__ne__(self, other)
+
+
+def fix_mexec(_name_, _file_):
+ """bugfix for relative imports not working
+ @param _name_: __name__ of the module
+ @param _file_: __file__ of the module
+
+ @note: not complete: relies on __init__.py, .pyo (...) is ignored currently
+ """
+ if _name_ == '__main__':
+ out = []
+ # find allparent packages
+ p = os.path.dirname(os.path.abspath(_file_))
+ prev = p
+ while True:
+ pkg = os.path.join(p, '__init__.py')
+ if os.path.isfile(pkg):
+ out.append([pkg, os.path.basename(p)])
+ else:
+ break
+ prev = p
+ p = os.path.dirname(p)
+ if p == prev:
+ break
+ out.reverse()
+
+ # adjust sub package names an import parent modules
+ name = None
+ for n, (fpath, name) in enumerate(out):
+ if n > 0:
+ name = out[n][1] = out[n -1][1] + '.' + out[n][1]
+ m = imp.load_source(name, fpath)
+ m.__path__ = [os.path.dirname(fpath)]
+
+ # adjust name of the __main__ module
+ if name is not None:
+ m = sys.modules.pop('__main__')
+ # 'foo.bar..__main__' does not work for some reason. 'foo.bar' seems to work as expected
+ ##m.__name__ = _Name_(name + '.' + '__main__')
+ m.__name__ = MainName(name)
+ sys.modules[m.__name__] = m
+
+
+
Deleted: trunk/fclient/fclient/impl/ViewLogger.py
===================================================================
--- trunk/fclient/fclient/impl/ViewLogger.py 2008-08-16 07:54:39 UTC (rev 911)
+++ trunk/fclient/fclient/impl/ViewLogger.py 2008-08-16 07:59:09 UTC (rev 912)
@@ -1,269 +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 sys
-import logging
-
-from PyQt4 import QtCore, QtGui
-
-from . import config
-from .lib import fcp2
-
-from .tpls.Ui_ViewLoggerWidgetTpl import Ui_ViewLoggerWidget
-#**********************************************************************************
-#
-#**********************************************************************************
-class Actions(config.ActionsBase):
-
- PrefixVerbosity = 'ActionVerbosity'
-
- def __init__(self, parent):
- config.ActionsBase.__init__(self, parent)
-
- # for ease of use verbosities are mapped to verbosity actions like this: PrefixVerbosity + Verbosity
- self.action(
- name='ActionLoggerClear',
- text=self.trUtf8('C&lear'),
- trigger=parent.onActionLoggerClear,
- )
-
- groupVerbosity = self.group(
- name='GroupVerbosity',
- trigger=parent.onGroupVerbosityTriggered,
- isExclusive=True,
- )
- self.action(
- name='ActionVerbosityInfo',
- text=self.trUtf8('Info'),
- group=groupVerbosity,
- trigger=None,
- isCheckable=True,
- userData=fcp2.ConstDebugVerbosity.Info,
- )
- self.action(
- name='ActionVerbosityMessage',
- text=self.trUtf8('Message'),
- group=groupVerbosity,
- trigger=None,
- isCheckable=True,
- userData=fcp2.ConstDebugVerbosity.Message,
- )
- self.action(
- name='ActionVerbosityDebug',
- text=self.trUtf8('Debug'),
- group=groupVerbosity,
- trigger=None,
- isCheckable=True,
- userData=fcp2.ConstDebugVerbosity.Debug,
- )
- self.action(
- name='ActionVerbosityChatty',
- text=self.trUtf8('Chatty'),
- group=groupVerbosity,
- trigger=None,
- isCheckable=True,
- userData=fcp2.ConstDebugVerbosity.Chatty,
- )
-
-
-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)
-
- # status bar widgets
- self.label1 = None
- #if self.statusBar is not None:
- # self.label1 = QtGui.QLabel('foo here', self.statusBar)
-
- def setVisible(self, flag):
- for menu in self.menus:
- menu.children()[0].setVisible(flag)
- if self.label1 is not None:
- self.label1.setVisible(flag)
-
-
-class Settings(config.SettingsBase):
-
- PrefixVerbosityColorFg = 'ColorFgVerbosity'
-
- _key_ = config.IdViewLoggerWidget
- _settings_ = (
- ('MaxLines', 'UInt', 1000),
- ('Verbosity', 'PyString', 'Info'),
-
- #TODO: Chatty does not seem to work. check in fcp2.client
- ('ColorFgVerbosityCRITICAL', 'QColor', QtGui.QColor('red')),
- ('ColorFgVerbosityERROR', 'QColor', QtGui.QColor('red')),
- ('ColorFgVerbosityWARNING', 'QColor', QtGui.QColor('red')),
- ('ColorFgVerbosityINFO', 'QColor', QtGui.QColor('black')),
- ('ColorFgVerbosityMESSAGE', 'QColor', QtGui.QColor('blue')),
- ('ColorFgVerbosityDEBUG', 'QColor', QtGui.QColor('slategray')),
- ('ColorFgVerbosityCHATTY', 'QColor', QtGui.QColor('lightslategray')),
- )
-
-
-class LoggerViewObject(config.ViewObject):
-
- def __init__(self, parent):
- config.ViewObject. __init__(self, parent)
-
- self.name=parent.objectName()
- self.displayName=self.trUtf8('Logger')
- self.icon=QtGui.QIcon()
-
-
-#***********************************************************************
-#
-#***********************************************************************
-class MyLoggingHandler(logging.Handler):
-
- def __init__(self, cb, *args, **kwargs):
- logging.Handler.__init__(self, *args, **kwargs)
- self.cb = cb
-
- def emit(self, record):
- self.cb(record)
-
-#***********************************************************************
-#
-#***********************************************************************
-class ViewLoggerWidget(QtGui.QWidget, Ui_ViewLoggerWidget):
-
- IdEdLogger = 'edLogger'
-
-
- def __init__(self, parent, idGlobalFeedback=config.IdMainWindow):
- QtGui.QWidget.__init__(self, parent)
- self._isCreated = False
- self._mainWindowMenus = {} #TODO: wrap along with toolbars to a handy class MainWindowStuff
-
- self.setupUi(self)
- config.ObjectRegistry.register(self)
-
- self.fcActions = Actions(self)
- self.fcSettings = Settings(self).restore()
- self.fcViewObject = LoggerViewObject(self)
- self.fcGlobalFeedback = GlobalFeedback(self, idGlobalFeedback)
-
-
- # setup editbox
- #NOTE: do not move to showEvent(). we want to be up and alive as soon as possible to catch logs
- ed = self.controlById(self.IdEdLogger)
- ed.document().setMaximumBlockCount(self.fcSettings.value('MaxLines'))
- ed.contextMenuEvent = self.loggerContextMenuEvent
- self.connect(ed, QtCore.SIGNAL('textChanged()'), self.onLoggerTextChanged)
-
- # setup logger
- self.loggingHandler = MyLoggingHandler(self.addRecord)
- logging.getLogger('').addHandler(self.loggingHandler)
-
- # setup actions
- verbosity = self.fcSettings.value('Verbosity').title()
- action = self.fcActions.get(self.fcActions.PrefixVerbosity + verbosity, None)
- if action is None:
- verbosity = self.fcSettings.restoreDefaults('Verbosity')['Verbosity']
- action = self.fcActions.get(self.fcActions.PrefixVerbosity + verbosity, None)
- if action is None:
- raise ValueError('default verbosity action "%s" not found. WTF?' % self.actions.PrefixVerbosity + verbosity)
- action.trigger()
-
- #########################################
- ## methods
- #########################################
- def addRecord(self, record):
- """adds a logging record"""
- ed = self.controlById(self.IdEdLogger)
- fmt = ed.currentCharFormat()
- colorFg = self.fcSettings.value(self.fcSettings.PrefixVerbosityColorFg + record.levelname)
- fmt.setForeground(QtGui.QBrush(colorFg))
- ed.setCurrentCharFormat(fmt)
-
- text = '%s:%s:%s' % (record.levelname, record.name, record.getMessage())
- ed.appendPlainText(text)
-
- def controlById(self, idControl):
- return getattr(self, idControl)
-
- def populateMenu(self, menu):
- menu.addAction(self.fcActions['ActionLoggerClear'])
- subMenu = menu.addMenu(self.trUtf8('Verbosity'))
- subMenu.addActions(self.fcActions['GroupVerbosity'].actions())
- return menu
-
- #########################################
- ##view methods
- #########################################
- def viewClose(self):
- pass
-
- def viewDisplayName(self):
- return self.trUtf8('Logger')
-
- def viewIcon(self):
- return QtGui.QIcon()
-
- def viewName(self):
- return self.objectName()
-
- #########################################
- ## overwritten events
- #########################################
- def loggerContextMenuEvent(self, event):
- """customize context menu of the logger QTextEdit"""
- ed = self.controlById(self.IdEdLogger)
- menu = ed.createStandardContextMenu()
- self.populateMenu(menu)
- menu.exec_(event.globalPos())
-
- def hideEvent(self, event):
- self.fcGlobalFeedback.setVisible(False)
-
- def showEvent(self, event):
- self.fcGlobalFeedback.setVisible(True)
- if self._isCreated:
- return
- self._isCreated = True
-
- #########################################
- ## event onrs
- #########################################
- def onActionLoggerClear(self, action):
- self.controlById(self.IdEdLogger).clear()
-
- def onGroupVerbosityTriggered(self, action):
- nameVerbosity = action.objectName()[len(self.fcActions.PrefixVerbosity):]
- self.fcSettings.setValues(Verbosity=nameVerbosity)
- logging.getLogger().setLevel(action.userData())
-
- def onLoggerTextChanged(self):
- ed = self.controlById(self.IdEdLogger)
- self.fcActions['ActionLoggerClear'].setEnabled(not ed.document().isEmpty())
-
-#**********************************************************************************
-#
-#**********************************************************************************
-if __name__ == '__main__':
- import sys
- from . import Ui_ViewLogger
-
- app = QtGui.QApplication(sys.argv)
- w = ViewLoggerWidget(None)
-
- w.show()
- res = app.exec_()
- sys.exit(res)
-
-
-
Deleted: trunk/fclient/fclient/impl/tpls/SideBarLoadDetailsTpl.ui
===================================================================
--- trunk/fclient/fclient/impl/tpls/SideBarLoadDetailsTpl.ui 2008-08-16 07:54:39 UTC (rev 911)
+++ trunk/fclient/fclient/impl/tpls/SideBarLoadDetailsTpl.ui 2008-08-16 07:59:09 UTC (rev 912)
@@ -1,47 +0,0 @@
-<ui version="4.0" >
- <class>SideBarLoadDetails</class>
- <widget class="QWidget" name="SideBarLoadDetails" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>497</width>
- <height>488</height>
- </rect>
- </property>
- <property name="windowTitle" >
- <string>Form</string>
- </property>
- <layout class="QGridLayout" name="gridLayout" >
- <item row="0" column="0" >
- <layout class="QHBoxLayout" name="horizontalLayout" >
- <item>
- <widget class="QLabel" name="header" >
- <property name="text" >
- <string>Load details</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="btClose" >
- <property name="text" >
- <string>...</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="1" column="0" >
- <widget class="QTreeWidget" name="tree" >
- <column>
- <property name="text" >
- <string>1</string>
- </property>
- </column>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
Deleted: trunk/fclient/fclient/impl/tpls/Ui_ViewLoggerWidgetTpl.py
===================================================================
--- trunk/fclient/fclient/impl/tpls/Ui_ViewLoggerWidgetTpl.py 2008-08-16 07:54:39 UTC (rev 911)
+++ trunk/fclient/fclient/impl/tpls/Ui_ViewLoggerWidgetTpl.py 2008-08-16 07:59:09 UTC (rev 912)
@@ -1,39 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Form implementation generated from reading ui file '/home/me/src/proj/fclient/trunk/fclient/src/fclient/tpls/ViewLoggerWidgetTpl.ui'
-#
-# Created: Tue Jul 15 16:03:24 2008
-# by: PyQt4 UI code generator 4.4.3-snapshot-20080705
-#
-# WARNING! All changes made in this file will be lost!
-
-from PyQt4 import QtCore, QtGui
-
-class Ui_ViewLoggerWidget(object):
- def setupUi(self, ViewLoggerWidget):
- ViewLoggerWidget.setObjectName("ViewLoggerWidget")
- ViewLoggerWidget.resize(550, 471)
- self.gridLayout = QtGui.QGridLayout(ViewLoggerWidget)
- self.gridLayout.setObjectName("gridLayout")
- self.edLogger = QtGui.QPlainTextEdit(ViewLoggerWidget)
- self.edLogger.setLineWrapMode(QtGui.QPlainTextEdit.NoWrap)
- self.edLogger.setReadOnly(True)
- self.edLogger.setObjectName("edLogger")
- self.gridLayout.addWidget(self.edLogger, 0, 0, 1, 1)
-
- self.retranslateUi(ViewLoggerWidget)
- QtCore.QMetaObject.connectSlotsByName(ViewLoggerWidget)
-
- def retranslateUi(self, ViewLoggerWidget):
- ViewLoggerWidget.setWindowTitle(QtGui.QApplication.translate("ViewLoggerWidget", "Form", None, QtGui.QApplication.UnicodeUTF8))
-
-
-if __name__ == "__main__":
- import sys
- app = QtGui.QApplication(sys.argv)
- ViewLoggerWidget = QtGui.QWidget()
- ui = Ui_ViewLoggerWidget()
- ui.setupUi(ViewLoggerWidget)
- ViewLoggerWidget.show()
- sys.exit(app.exec_())
-
Deleted: trunk/fclient/fclient/impl/tpls/ViewLoggerWidgetTpl.ui
===================================================================
--- trunk/fclient/fclient/impl/tpls/ViewLoggerWidgetTpl.ui 2008-08-16 07:54:39 UTC (rev 911)
+++ trunk/fclient/fclient/impl/tpls/ViewLoggerWidgetTpl.ui 2008-08-16 07:59:09 UTC (rev 912)
@@ -1,30 +0,0 @@
-<ui version="4.0" >
- <class>ViewLoggerWidget</class>
- <widget class="QWidget" name="ViewLoggerWidget" >
- <proper...
[truncated message content] |
|
From: <jU...@us...> - 2008-08-16 08:10:41
|
Revision: 915
http://fclient.svn.sourceforge.net/fclient/?rev=915&view=rev
Author: jUrner
Date: 2008-08-16 08:10:49 +0000 (Sat, 16 Aug 2008)
Log Message:
-----------
isolated downloads view
Modified Paths:
--------------
trunk/fclient/fclient/fclient.py
Added Paths:
-----------
trunk/fclient/fclient/impl/BaseRequestsWidget/
trunk/fclient/fclient/impl/BaseRequestsWidget/BaseRequestsWidget.py
trunk/fclient/fclient/impl/BaseRequestsWidget/RequestsWidget.ui
trunk/fclient/fclient/impl/BaseRequestsWidget/Ui_RequestsWidget.py
trunk/fclient/fclient/impl/BaseRequestsWidget/__init__.py
trunk/fclient/fclient/impl/BaseRequestsWidget/_fix_mexec.py
trunk/fclient/fclient/impl/BaseRequestsWidget/dlgs/
trunk/fclient/fclient/impl/BaseRequestsWidget/dlgs/DlgDownloadKeyToDisk.py
trunk/fclient/fclient/impl/BaseRequestsWidget/dlgs/DlgDownloadKeyToDiskTpl.ui
trunk/fclient/fclient/impl/BaseRequestsWidget/dlgs/Ui_DlgDownloadKeyToDiskTpl.py
trunk/fclient/fclient/impl/BaseRequestsWidget/dlgs/__init__.py
trunk/fclient/fclient/impl/BaseRequestsWidget/dlgs/_fix_mexec.py
trunk/fclient/fclient/impl/ViewDownloads/
trunk/fclient/fclient/impl/ViewDownloads/ViewDownloads.py
trunk/fclient/fclient/impl/ViewDownloads/__init__.py
trunk/fclient/fclient/impl/ViewDownloads/_fix_mexec.py
Removed Paths:
-------------
trunk/fclient/fclient/impl/ViewDownloads.py
trunk/fclient/fclient/impl/tpls/DlgDownloadKeyToDiskTpl.ui
trunk/fclient/fclient/impl/tpls/Ui_DlgDownloadKeyToDiskTpl.py
trunk/fclient/fclient/impl/tpls/Ui_SideBarLoadDetailsTpl.py
Modified: trunk/fclient/fclient/fclient.py
===================================================================
--- trunk/fclient/fclient/fclient.py 2008-08-16 08:01:13 UTC (rev 914)
+++ trunk/fclient/fclient/fclient.py 2008-08-16 08:10:49 UTC (rev 915)
@@ -16,7 +16,7 @@
from .impl.View import ViewWidget
from .impl.ViewBrowser import ViewBrowser
from .impl.ViewConnection import ViewConnection
-from .impl.ViewDownloads import ViewDownloadsWidget
+from .impl.ViewDownloads import ViewDownloads
from .impl.ViewLogger import ViewLogger
from .impl.ViewUploads import ViewUploadsWidget
@@ -78,7 +78,7 @@
viewWidget.addTopViews(
ViewConnection.ViewConnectionWidget(mainWindow),
ViewBrowser.ViewBrowserWidget(mainWindow),
- ViewDownloadsWidget(mainWindow),
+ ViewDownloads.ViewDownloadsWidget(mainWindow),
ViewUploadsWidget(mainWindow),
)
viewWidget.addBottomViews(ViewLogger.ViewLoggerWidget(mainWindow))
Added: trunk/fclient/fclient/impl/BaseRequestsWidget/BaseRequestsWidget.py
===================================================================
--- trunk/fclient/fclient/impl/BaseRequestsWidget/BaseRequestsWidget.py (rev 0)
+++ trunk/fclient/fclient/impl/BaseRequestsWidget/BaseRequestsWidget.py 2008-08-16 08:10:49 UTC (rev 915)
@@ -0,0 +1,561 @@
+
+#**************************************************************************************************************
+#TODO:
+#
+# x. prtty tricky to get dls right when the node or client may disconnect unexpectedly
+# problem: dls that we send and that have not reached the node
+# problem: what to do when the user wants to quit and we still have dls to push to the node
+#
+# solution would require keeping track of all requests
+# a. keep identifiers of requests that reached the node (have to do it anyways)
+# b. keep track of requests ahead of sending them to the node (feels not too good doubeling downloads.dat.gz)
+#
+# best idea seems to be to ignore the problem
+# 1. wait till (if ever) freenet devels fdrop node keeping track of client requests
+#
+# 2. a box thrown to the user (x. do not show this message again) to inform him about pendings
+# should be enough. maybe along with a separate widget or some separate color code for pendings
+#
+# x. performance
+# start with a standard model and improve it over time. no need to set any hard
+# limits. the user will find out by himself how many dls his machine can handle.
+# have to be carefrul though when adding dls, like from a *.frdx to provide appropriate
+# warnings
+# x. it may take a while untill the final DataFound message arrives when a request is % completed. feedback would be nice
+# x. DataFound for a request the file has been removed by the user. no idea what happens. have to test this
+# x. when the node is about to start up, looks like persistents may arrive or not. check
+# x. how to get early information about mimetype/size? maybe use FcpClient.getFileInfo()
+# x. show/hide header izems
+# x. sort by header
+# x. indicate over all time / dl speed
+# x. indicate status / remove items by status
+# x. item properties
+# x. how to handle inserting huge number of dls?
+# idea: insert with lowest priority to get the node to know them, increase priority when a slot in
+# MaxSimultaneousDls (if set) is free. atatch progressBar no sooner as priority > MinDlPriority
+# x. how to handle huge numbers of dls. the node will flood us on startup with persistents. looks
+# like the only way to control the flood is to have one connection/dl. maybe wait for freenet devels
+# to realize that this is a serious problem...
+# x. byte amount postfixes must be transllated ++ use Kib or Kb or let the user decide?
+# x. sometimes groups of dls get not removed
+#**************************************************************************************************************
+# 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 mimetypes
+import os
+from PyQt4 import QtCore, QtGui
+
+from .. import config
+from ..lib import fcp2
+from ..lib.fcp2.lib import pmstruct
+from ..lib.qt4ex import treewidgetwrap
+from ..lib import numbers
+
+from .dlgs import DlgDownloadKeyToDisk
+
+from .Ui_RequestsWidget import Ui_ViewRequestsWidget
+#**********************************************************************************
+#
+#**********************************************************************************
+BLOCK_SIZE = 32768 # from CHKBlock.java
+
+#**********************************************************************************
+#
+#**********************************************************************************
+class PersistentRequestData(pmstruct.PMStruct):
+ _fields_ = (
+ ('ClientName', pmstruct.STRING),
+ )
+
+#**********************************************************************************
+#
+#**********************************************************************************
+class TreeItem(QtGui.QTreeWidgetItem):
+
+ IndexName = 0
+ IndexSize = 1
+ IndexMimeType = 2
+ IndexStatus = 3
+ IndexProgress = 4
+ IndexPriority = 5
+ IndexElapsed = 6
+
+ ProgressBarName = 'downloadKey'
+
+ StatusPending = 'pending'
+ StatusLoading = 'loading'
+ StatusComplete = 'complete'
+ StatusError = 'error'
+ StatusRemoved = 'removed'
+ StatusCompressing = 'compressing'
+ ##StatusCompressed = 'compressed' #TODO: no way to distinguish compressed an loading
+
+ def __init__(self, fcpRequest, *params):
+ QtGui.QTreeWidgetItem.__init__(self, *params)
+ self.fcpRequest = fcpRequest
+ self.fcOldStatus = self.StatusPending
+
+ def status(self):
+ if self.fcpRequest is None:
+ return self.StatusRemoved
+ elif self.fcpRequest['RequestStatus'] & fcp2.ConstRequestStatus.Success:
+ return self.StatusComplete
+ elif self.fcpRequest['RequestStatus'] & fcp2.ConstRequestStatus.Error:
+ return self.StatusError
+
+ #TODO: more or less aguess ..have to check this in detail
+ elif self.fcpRequest['RequestStatus'] & fcp2.ConstRequestStatus.Started:
+ if self.fcpRequest['RequestStatus'] & fcp2.ConstRequestStatus.Compressing:
+ if self.fcpRequest['RequestStatus'] & fcp2.ConstRequestStatus.Compressed:
+ return self.StatusLoading
+ else:
+ return self.compressing
+ else:
+ return self.StatusLoading
+ else:
+ return self.StatusPending
+
+# exposes status property for stylesheets
+class ProgressBar(QtGui.QProgressBar):
+
+ def __init__(self, parent, item):
+ QtGui.QProgressBar.__init__(self, parent)
+ self.item = item
+
+ def _get_status(self):
+ return self.item.status()
+ status= QtCore.pyqtProperty("QString", _get_status)
+
+
+class RequestsWidgetActions(config.ActionsBase):
+
+ def __init__(self, parent):
+ config.ActionsBase.__init__(self, parent)
+
+ self.action(
+ name='ActionDownloadKeyToDisk',
+ text=self.trUtf8('Download &key...'),
+ trigger=parent.onDlgDownloadKey,
+ )
+ self.action(
+ name='ActionRemoveSelectedDownloads',
+ text=self.trUtf8('Remove download'),
+ trigger=parent.onRemoveSelectedDownloads,
+ isEnabled=False,
+ )
+ self.action(
+ name='ActionRestartSelectedDownloads',
+ text=self.trUtf8('Restart download'),
+ trigger=parent.onRestartSelectedDownloads,
+ isEnabled=False,
+ )
+
+ #TODO: enable/disable if items of that type are available?
+ group = self.group(
+ name='GroupRemoveGroup',
+ trigger=parent.onRemoveGroup,
+ )
+ self.action(
+ name='ActionRemoveFailed',
+ group=group,
+ text=self.trUtf8('Failed'),
+ isEnabled=False,
+ )
+ self.action(
+ name='ActionRemoveCompleted',
+ group=group,
+ text=self.trUtf8('Completed'),
+ isEnabled=False,
+ )
+
+#**********************************************************************************
+#
+#**********************************************************************************
+class RequestsWidget(QtGui.QWidget, Ui_ViewRequestsWidget):
+
+ IdTree = 'tree'
+
+ def __init__(self, parent, idGlobalFeedback=config.IdMainWindow):
+ QtGui.QWidget.__init__(self, parent)
+ self._isCreated = False
+ self.fcHeaderLabels = {} # fcpIdentifier --> treeItem
+ self.fcActions = RequestsWidgetActions(self)
+ self.fcpRequests = {}
+ self.fcRequestStatusNames = {}
+ self.menuRemoveGroup = QtGui.QMenu(self)
+
+ self.setupUi(self)
+ self.fcpClientEvents = (
+ (config.fcpClient.events.ClientConnected, self.onFcpClientConnected),
+ (config.fcpClient.events.ClientDisconnected, self.onFcpClientDisconnected),
+ (config.fcpClient.events.ConfigData, self.onFcpConfigData),
+ (config.fcpClient.events.RequestCompleted, self.onFcpClientRequestCompleted),
+ (config.fcpClient.events.RequestFailed, self.onFcpClientRequestFailed),
+ (config.fcpClient.events.RequestModified, self.onFcpClientRequestModified),
+ (config.fcpClient.events.RequestProgress, self.onFcpClientRequestProgress),
+ (config.fcpClient.events.RequestStarted, self.onFcpClientRequestStarted),
+ (config.fcpClient.events.RequestRemoved, self.onFcpClientRequestRemoved),
+ (config.fcpClient.events.RequestCompressionStarted, self.onFcpClientRequestCompressionStarted),
+ (config.fcpClient.events.RequestCompressionCompleted, self.onFcpClientRequestCompressionCompleted),
+ )
+ config.fcpClient.events += self.fcpClientEvents
+
+
+ ############################
+ ## private methods
+ ############################
+ def _adjustItemStatus(self, item):
+ # to take Css styling into account we have to set a new statusBar for each state change
+ tree = self.controlById(self.IdTree)
+ oldProgressBar = progressBar = self.tree.itemWidget(item, TreeItem.IndexProgress)
+ itemStatus = item.status()
+ itemStatusChanged = itemStatus != item.fcOldStatus
+ if itemStatusChanged:
+ progressBar = ProgressBar(self.tree, item)
+
+ # adjust statusBar and set a new one if necessary
+ # ..bit much work here, but necessary, cos Fcp might come up with
+ # ..a completed message without any prior progress notifications
+ if itemStatus == TreeItem.StatusPending:
+ progressBar.setRange(0, 0)
+ elif itemStatus == TreeItem.StatusLoading:
+ progressBar.setRange(0, item.fcpRequest['ProgressRequired'])
+ progressBar.setValue(item.fcpRequest['ProgressSucceeded'])
+ elif itemStatus == TreeItem.StatusComplete:
+ progressBar.setRange(0, 1)
+ progressBar.setValue(progressBar.maximum())
+ elif itemStatus == TreeItem.StatusError:
+ progressBar.setMinimum(oldProgressBar.minimum())
+ progressBar.setMaximum(oldProgressBar.maximum())
+ progressBar.setValue(oldProgressBar.value())
+ elif itemStatus == TreeItem.StatusRemoved:
+ pass
+ elif itemStatus == TreeItem.StatusCompressing:
+ progressBar.setRange(0, 0)
+ else:
+ raise ValueError('Unknown status: %r' % itemStatus)
+ if itemStatusChanged:
+ progressBar.setObjectName(TreeItem.ProgressBarName)
+ tree.setItemWidget(item, TreeItem.IndexProgress, progressBar)
+ item.setData(
+ TreeItem.IndexStatus,
+ QtCore.Qt.DisplayRole,
+ QtCore.QVariant(self.fcRequestStatusNames[itemStatus]),
+ )
+ item.fcOldStatus = itemStatus
+
+ ############################
+ ##
+ ############################
+ def retranslateUi(self, parent):
+ Ui_ViewRequestsWidget.retranslateUi(self, parent)
+ tree = self.controlById(self.IdTree)
+ root = tree.invisibleRootItem()
+
+ # adjust header labels
+ self.fcHeaderLabels = {
+ TreeItem.IndexName: self.trUtf8('Name'),
+ TreeItem.IndexSize: self.trUtf8('Size'),
+ TreeItem.IndexMimeType: self.trUtf8('MimeType'),
+ TreeItem.IndexStatus: self.trUtf8('Status'),
+ TreeItem.IndexPriority: self.trUtf8('Priority'),
+ TreeItem.IndexProgress: self.trUtf8('Progress'),
+ TreeItem.IndexElapsed: self.trUtf8('Elapsed'),
+ }
+ tree.setHeaderLabels([i[1] for i in sorted(self.fcHeaderLabels.items())])
+
+ # adjust status names and retranslate all items
+ self.fcRequestStatusNames = {
+ TreeItem.StatusPending: self.trUtf8('Pending'),
+ TreeItem.StatusLoading: self.trUtf8('Loading'),
+ TreeItem.StatusComplete: self.trUtf8('Complete'),
+ TreeItem.StatusError: self.trUtf8('Error'),
+ TreeItem.StatusRemoved: self.trUtf8('Removed'),
+ TreeItem.StatusCompressing: self.trUtf8('Compressing'),
+ ##TreeItem.StatusCompressed: self.trUtf8('Compressed'), #TODO: no way to distinguish compressed an loading
+ }
+ for item in treewidgetwrap.walkItem(root):
+ fcpRequest = getattr(item, 'fcpRequest', None)
+ if hasattr(item, 'fcpRequest'):
+ item.setText(TreeItem.IndexStatus, self.fcRequestStatusNames[item.status()])
+
+ # others
+ self.menuRemoveGroup.setTitle(self.trUtf8('Remove group'))
+
+ def closeEvent(self):
+ self.viewClose()
+
+ def hideEvent(self, event):
+ self.fcGlobalFeedback.setVisible(False)
+
+ def showEvent(self, event):
+ self.fcGlobalFeedback.setVisible(True)
+ if not self._isCreated:
+ self._isCreated = True
+
+ # setup tree
+ tree = self.controlById(self.IdTree)
+ tree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
+ tree.setRootIsDecorated(False)
+ tree.setSelectionMode(tree.ExtendedSelection)
+ tree.setUniformRowHeights(True)
+ self.connect(tree, QtCore.SIGNAL('customContextMenuRequested(const QPoint &)'), self.onTreeCustomContextMenuRequested)
+ self.connect(tree, QtCore.SIGNAL('itemSelectionChanged() '), self.onTreeItemSelectionChanged)
+
+ def viewClose(self):
+ config.fcpClient.events -= self.fcpClientEvents
+
+ #########################################
+ ## methods
+ #########################################
+ #TODO: much...
+ def addFcpRequest(self, fcpRequest):
+ """
+ @note: if you add a newly created request, make shure to set the requests PersistentUserData
+ to the result of the call to L{persistentFcpRequestData}
+ """
+ tree = self.controlById(self.IdTree)
+ root = tree.invisibleRootItem()
+ item= TreeItem(fcpRequest, root)
+ progressBar = ProgressBar(self.tree, item)
+
+ progressBar.setObjectName(TreeItem.ProgressBarName)
+ tree.setItemWidget(item, TreeItem.IndexProgress, progressBar)
+ fileName = fcpRequest['Filename']
+ mimeType = mimetypes.guess_type(fileName)[0]
+ icon = config.fcResources.getIcon(
+ config.mimeTypeIconName(mimeType),
+ config.fcSettings.value('IconSize'),
+ config.fcSettings.value('IconTheme'),
+ )
+ item.setIcon(0, icon)
+ item.setData(
+ TreeItem.IndexName,
+ QtCore.Qt.DisplayRole,
+ QtCore.QVariant(os.path.basename(fcpRequest['Filename']))
+ )
+
+ #TODO: take a wild guess at the size. no other way to do it currently
+ estimatedSize = int((BLOCK_SIZE * fcpRequest['ProgressRequired']) + 1)
+ item.setData(
+ TreeItem.IndexSize,
+ QtCore.Qt.DisplayRole,
+ QtCore.QVariant(self.trUtf8('< ') + numbers.format_num_bytes(estimatedSize)),
+ )
+
+ self.fcpRequests[fcpRequest['Identifier']] = item
+ self._adjustItemStatus(item)
+ return item
+
+ self.fcpRequests[fcpRequest['Identifier']] = item
+ self._adjustItemStatus(item)
+ return item
+
+
+ def controlById(idGlobalFeedback, idControl):
+ return getattr(idGlobalFeedback, idControl)
+
+ # overwrite
+ def populateMenu(self, menu):
+ return menu
+
+ def execDlgDownloadKey(self, fcpKey=None):
+ """pops up the dialog to allow the user to download a key to disk
+ @param fcpKey: key to initialize the key with or None
+ """
+ dlg = DlgDownloadKeyToDisk.DlgDownloadKeyToDisk(self, fcpKey=fcpKey)
+ if dlg.exec_() == dlg.Accepted:
+ self.downloadFile(
+ dlg.fcpKey(),
+ dlg.fileName(),
+ persistence=fcp2.ConstPersistence.Forever,
+ handleFilenameCollision=True,
+ )
+
+ def persistentFcpRequestData(self):
+ return PersistentRequestData(ClientName=unicode(self.objectName())).dump()
+
+ #########################################
+ ## event handlers
+ #########################################
+ def onDlgDownloadKey(self, action):
+ self.execDlgDownloadKey(fcpKey=None)
+
+ def onRemoveSelectedDownloads(self, action):
+ tree = self.controlById(self.IdTree)
+ selectedItems = tree.selectedItems()
+
+ # remove items
+ for item in selectedItems:
+ parent = item.parent()
+ if parent is None:
+ parent = tree.invisibleRootItem()
+ parent.removeChild(item)
+
+ # cancel all requests
+ for item in selectedItems:
+ for tmp_item in treewidgetwrap.walkItem(item):
+ if tmp_item.fcpRequest is not None: # we may come across the same item multiple times
+ if tmp_item.fcpRequest['Identifier'] in self.fcpRequests: #TODO: should never be False?! check
+ del self.fcpRequests[tmp_item.fcpRequest['Identifier']]
+ config.fcpClient.removeRequest(tmp_item.fcpRequest)
+ tmp_item.fcpRequest = None
+
+ def onRestartSelectedDownloads(self, action):
+ tree = self.controlById(self.IdTree)
+ for item in tree.selectedItems():
+ if item.fcpRequest is None:
+ raise RuntimeError('fcpRequest is None. should not happen')
+ del self.fcpRequests[item.fcpRequest['Identifier']]
+ item.fcpRequest = config.fcpClient.resendRequest(item.fcpRequest)
+ self.fcpRequests[item.fcpRequest['Identifier']] = item
+ self._adjustItemStatus(item)
+
+ def onRemoveGroup(self, action):
+ tree = self.controlById(self.IdTree)
+ root = tree.invisibleRootItem()
+
+ if action == self.fcActions['ActionRemoveCompleted']:
+ flag = fcp2.ConstRequestStatus.Success
+ elif action == self.fcActions['ActionRemoveFailed']:
+ flag = fcp2.ConstRequestStatus.Error
+ else:
+ raise ValueError('Not implemented')
+
+ for item in treewidgetwrap.walkItem(root, topdown=False):
+ fcpRequest = getattr(item, 'fcpRequest', None)
+ if fcpRequest is not None:
+ if fcpRequest['Identifier'] in self.fcpRequests: #TODO: should never be False?! check
+ del self.fcpRequests[fcpRequest['Identifier']]
+
+ if fcpRequest['RequestStatus'] & fcp2.ConstRequestStatus.Removed:
+ pass
+ elif not fcpRequest['RequestStatus'] & flag:
+ continue
+ else:
+ item.fcpRequest = None
+ config.fcpClient.removeRequest(fcpRequest)
+ parent = item.parent()
+ if parent is None:
+ parent = root
+ parent.removeChild(item)
+
+
+ # overwrite
+ def onTreeCustomContextMenuRequested(self, pt):
+ pass
+
+ # overwrite
+ def onTreeItemSelectionChanged(self):
+ pass
+
+ #########################################
+ ## fcp event handlers
+ #########################################
+ def onFcpClientConnected(self, event, msg):
+ for action in self.fcActions:
+ action.setEnabled(True)
+
+
+ def onFcpClientDisconnected(self, event, msg):
+ for action in self.fcActions:
+ action.setEnabled(False)
+
+ def onFcpConfigData(self, fcpEvent, fcpRequest):
+ pass
+
+
+ def onFcpClientRequestCompleted(self, fcpEvent, fcpRequest):
+ item = self.fcpRequests.get(fcpRequest['Identifier'], None)
+ if item is not None:
+ mimeType = fcpRequest['MetadataContentType']
+ item.setData(
+ TreeItem.IndexSize,
+ QtCore.Qt.DisplayRole,
+ QtCore.QVariant(numbers.format_num_bytes(fcpRequest['MetadataSize']))
+ )
+ item.setData(
+ TreeItem.IndexMimeType,
+ QtCore.Qt.DisplayRole,
+ QtCore.QVariant(mimeType)
+ )
+ icon = config.fcResources.getIcon(
+ config.mimeTypeIconName(mimeType),
+ config.fcSettings.value('IconSize'),
+ config.fcSettings.value('IconTheme'),
+ )
+ item.setIcon(0, icon)
+ self._adjustItemStatus(item)
+
+ def onFcpClientRequestCompressionStarted(self, fcpEvent, fcpRequest):
+ item = self.fcpRequests.get(fcpRequest['Identifier'], None)
+ if item is not None:
+ self._adjustItemStatus(item)
+
+ def onFcpClientRequestCompressionCompleted(self, fcpEvent, fcpRequest):
+ item = self.fcpRequests.get(fcpRequest['Identifier'], None)
+ if item is not None:
+ self._adjustItemStatus(item)
+
+ def onFcpClientRequestFailed(self, fcpEvent, fcpRequest):
+ item = self.fcpRequests.get(fcpRequest['Identifier'], None)
+ if item is not None:
+ self._adjustItemStatus(item)
+
+ #TODO: not tested
+ def onFcpClientRequestModified(self, fcpEvent, fcpRequest):
+
+ requestIdentifier = fcpRequest['Modified'].get(fcp2.ConstRequestModified.Identifier, None)
+ if requestIdentifier is None:
+ requestIdentifier = fcpRequest['Identifier']
+ item = self.fcpRequests.get(requestIdentifier, None)
+
+ if item is not None:
+ if fcp2.ConstRequestModified.Identifier in fcpRequest['Modified']:
+ newFcpIdentifier = fcpRequest['Identifier']
+ del self.fcpRequests[requestIdentifier]
+ self.fcpRequests[newFcpIdentifier] = item
+
+ if fcp2.ConstRequestModified.Filename in fcpRequest['Modified']:
+ item.setData(
+ TreeItem.IndexName,
+ QtCore.Qt.DisplayRole,
+ QtCore.QVariant(os.path.basename(fcpRequest['Filename']))
+ )
+
+
+ def onFcpClientRequestProgress(self, fcpEvent, fcpRequest):
+ item = self.fcpRequests.get(fcpRequest['Identifier'], None)
+ if item is not None:
+ self._adjustItemStatus(item)
+
+ def onFcpClientRequestRemoved(self, fcpEvent, fcpRequest):
+ pass
+
+ def onFcpClientRequestStarted(self, fcpEvent, fcpRequest):
+ if fcpRequest['RequestStatus'] & fcp2.ConstRequestStatus.Restored:
+ try:
+ requestData = PersistentRequestData.load(fcpRequest['PersistentUserData'])
+ except pmstruct.PMStructError:
+ pass
+ else:
+ if requestData.get('ClientName', None) == self.objectName():
+ item = self.addFcpRequest(fcpRequest)
+ else:
+ item = self.fcpRequests.get(fcpRequest['Identifier'], None)
+ if item is not None:
+ self._adjustItemStatus(item)
+
+
+#**********************************************************************************
+#
+#**********************************************************************************
Added: trunk/fclient/fclient/impl/BaseRequestsWidget/RequestsWidget.ui
===================================================================
--- trunk/fclient/fclient/impl/BaseRequestsWidget/RequestsWidget.ui (rev 0)
+++ trunk/fclient/fclient/impl/BaseRequestsWidget/RequestsWidget.ui 2008-08-16 08:10:49 UTC (rev 915)
@@ -0,0 +1,35 @@
+<ui version="4.0" >
+ <class>ViewRequestsWidget</class>
+ <widget class="QWidget" name="ViewRequestsWidget" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>0</number>
+ </property>
+ <item row="0" column="0" >
+ <widget class="QTreeWidget" name="tree" >
+ <column>
+ <property name="text" >
+ <string>1</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
Added: trunk/fclient/fclient/impl/BaseRequestsWidget/Ui_RequestsWidget.py
===================================================================
--- trunk/fclient/fclient/impl/BaseRequestsWidget/Ui_RequestsWidget.py (rev 0)
+++ trunk/fclient/fclient/impl/BaseRequestsWidget/Ui_RequestsWidget.py 2008-08-16 08:10:49 UTC (rev 915)
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file '/home/me/src/fclient/trunk/fclient/fclient/impl/XBaseRequestsWidget/RequestsWidget.ui'
+#
+# Created: Sat Aug 16 10:04:59 2008
+# by: PyQt4 UI code generator 4.4.3-snapshot-20080705
+#
+# WARNING! All changes made in this file will be lost!
+
+from PyQt4 import QtCore, QtGui
+
+class Ui_ViewRequestsWidget(object):
+ def setupUi(self, ViewRequestsWidget):
+ ViewRequestsWidget.setObjectName("ViewRequestsWidget")
+ ViewRequestsWidget.resize(400, 300)
+ self.gridLayout = QtGui.QGridLayout(ViewRequestsWidget)
+ self.gridLayout.setMargin(0)
+ self.gridLayout.setSpacing(0)
+ self.gridLayout.setObjectName("gridLayout")
+ self.tree = QtGui.QTreeWidget(ViewRequestsWidget)
+ self.tree.setObjectName("tree")
+ self.gridLayout.addWidget(self.tree, 0, 0, 1, 1)
+
+ self.retranslateUi(ViewRequestsWidget)
+ QtCore.QMetaObject.connectSlotsByName(ViewRequestsWidget)
+
+ def retranslateUi(self, ViewRequestsWidget):
+ ViewRequestsWidget.setWindowTitle(QtGui.QApplication.translate("ViewRequestsWidget", "Form", None, QtGui.QApplication.UnicodeUTF8))
+ self.tree.headerItem().setText(0, QtGui.QApplication.translate("ViewRequestsWidget", "1", None, QtGui.QApplication.UnicodeUTF8))
+
+
+if __name__ == "__main__":
+ import sys
+ app = QtGui.QApplication(sys.argv)
+ ViewRequestsWidget = QtGui.QWidget()
+ ui = Ui_ViewRequestsWidget()
+ ui.setupUi(ViewRequestsWidget)
+ ViewRequestsWidget.show()
+ sys.exit(app.exec_())
+
Added: trunk/fclient/fclient/impl/BaseRequestsWidget/__init__.py
===================================================================
--- trunk/fclient/fclient/impl/BaseRequestsWidget/__init__.py (rev 0)
+++ trunk/fclient/fclient/impl/BaseRequestsWidget/__init__.py 2008-08-16 08:10:49 UTC (rev 915)
@@ -0,0 +1 @@
+
Added: trunk/fclient/fclient/impl/BaseRequestsWidget/_fix_mexec.py
===================================================================
--- trunk/fclient/fclient/impl/BaseRequestsWidget/_fix_mexec.py (rev 0)
+++ trunk/fclient/fclient/impl/BaseRequestsWidget/_fix_mexec.py 2008-08-16 08:10:49 UTC (rev 915)
@@ -0,0 +1,99 @@
+'''in python 2.5 relative impports are srsly broken ..fix this to make relative imports work
+when executing a module as main (-m), including relative imports up to the root package
+
+see: [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html]
+
+@note: root package is the highest available package in the package hirarchy.
+don't look at __name__ too closely. it gets adjusted for a module to just "do the right
+thing" in __name__ == '__main__' comparisons
+@note: this patch does not work if relative imports are done in __init__.py. no idea why
+and to be honest, I don't wanna* know..
+@note: this is more or less a hack. so it may have unwanted side effects for example
+when importing parent packages. use at your own risk. could improve this module
+by adding a __main__.py to stop at this level or by fixing the __init__.py bug, but
+I don't think its worth it. see what python2.6 or 3k brings..
+
+usage::
+
+ # place this at the top a module, before doing any relative imports
+ from fix_mexec import fix_mexec
+ fix_mexec(__name__, __file__)
+ del fix_mexec
+
+ from ...foo import bar
+
+
+
+##<-- copy and paste code, assuming _fix_mexec resides in the current dir..
+
+# 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
+
+
+##--> copy and paste code
+'''
+
+import imp, os, sys
+#********************************************************************************
+#
+#********************************************************************************
+class MainName(str):
+ def __eq__(self, other):
+ if other == '__main__': return True
+ return str.__eq__(self, other)
+ def __ne__(self, other):
+ if other == '__main__': return False
+ return str.__ne__(self, other)
+
+
+def fix_mexec(_name_, _file_):
+ """bugfix for relative imports not working
+ @param _name_: __name__ of the module
+ @param _file_: __file__ of the module
+
+ @note: not complete: relies on __init__.py, .pyo (...) is ignored currently
+ """
+ if _name_ == '__main__':
+ out = []
+ # find allparent packages
+ p = os.path.dirname(os.path.abspath(_file_))
+ prev = p
+ while True:
+ pkg = os.path.join(p, '__init__.py')
+ if os.path.isfile(pkg):
+ out.a...
[truncated message content] |
|
From: <jU...@us...> - 2008-08-16 08:19:16
|
Revision: 917
http://fclient.svn.sourceforge.net/fclient/?rev=917&view=rev
Author: jUrner
Date: 2008-08-16 08:19:24 +0000 (Sat, 16 Aug 2008)
Log Message:
-----------
isolated uploads view
Modified Paths:
--------------
trunk/fclient/fclient/fclient.py
Added Paths:
-----------
trunk/fclient/fclient/impl/ViewUploads/
trunk/fclient/fclient/impl/ViewUploads/ViewUploads.py
trunk/fclient/fclient/impl/ViewUploads/__init__.py
trunk/fclient/fclient/impl/ViewUploads/_fix_mexec.py
Removed Paths:
-------------
trunk/fclient/fclient/impl/ViewUploads.py
Modified: trunk/fclient/fclient/fclient.py
===================================================================
--- trunk/fclient/fclient/fclient.py 2008-08-16 08:13:58 UTC (rev 916)
+++ trunk/fclient/fclient/fclient.py 2008-08-16 08:19:24 UTC (rev 917)
@@ -18,7 +18,7 @@
from .impl.ViewConnection import ViewConnection
from .impl.ViewDownloads import ViewDownloads
from .impl.ViewLogger import ViewLogger
-from .impl.ViewUploads import ViewUploadsWidget
+from .impl.ViewUploads import ViewUploads
from .impl.DlgSingleAppError import DlgSingleAppError
#*************************************************************
@@ -79,7 +79,7 @@
ViewConnection.ViewConnectionWidget(mainWindow),
ViewBrowser.ViewBrowserWidget(mainWindow),
ViewDownloads.ViewDownloadsWidget(mainWindow),
- ViewUploadsWidget(mainWindow),
+ ViewUploads.ViewUploadsWidget(mainWindow),
)
viewWidget.addBottomViews(ViewLogger.ViewLoggerWidget(mainWindow))
Added: trunk/fclient/fclient/impl/ViewUploads/ViewUploads.py
===================================================================
--- trunk/fclient/fclient/impl/ViewUploads/ViewUploads.py (rev 0)
+++ trunk/fclient/fclient/impl/ViewUploads/ViewUploads.py 2008-08-16 08:19:24 UTC (rev 917)
@@ -0,0 +1,181 @@
+
+""""""
+
+# 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
+
+
+from PyQt4 import QtCore, QtGui
+
+from .. import config
+from ..BaseRequestsWidget import BaseRequestsWidget
+#************************************************************************************
+#
+#************************************************************************************
+class UploadsWidgetGlobalFeedback(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].setEnabled(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 DownloadsViewObject(config.ViewObject):
+
+ def __init__(self, parent):
+ config.ViewObject. __init__(self, parent)
+
+ self.name=parent.objectName()
+ self.displayName=self.trUtf8('Uploads')
+ self.icon=QtGui.QIcon()
+
+
+class UploadsWidgetSettings(config.SettingsBase):
+
+
+ _key_ = config.IdViewUploadsWidget
+ _settings_ = (
+ )
+
+
+class ViewUploadsWidget(BaseRequestsWidget.RequestsWidget):
+
+ def __init__(self, parent, idGlobalFeedback=config.IdMainWindow):
+
+ self.menuRemoveGroup = None
+
+ BaseRequestsWidget.RequestsWidget.__init__(self, parent)
+
+ self.setObjectName(config.IdViewUploadsWidget)
+ config.ObjectRegistry.register(self)
+ self.fcSettings = UploadsWidgetSettings(self).restore()
+ self.fcViewObject = DownloadsViewObject(self)
+ self.fcGlobalFeedback = UploadsWidgetGlobalFeedback(self, idGlobalFeedback)
+
+ # setup menus
+ self.menuRemoveGroup = QtGui.QMenu(self)
+ self.menuRemoveGroup.setTitle(self.trUtf8('Remove group'))
+ for action in self.fcActions['GroupRemoveGroup'].actions():
+ self.menuRemoveGroup.addAction(action)
+
+
+ ###################################
+ ## overwritten methods
+ ###################################
+ def hideEvent(self, event):
+ self.fcGlobalFeedback.setVisible(False)
+ BaseRequestsWidget.RequestsWidget.hideEvent(self, event)
+
+ def showEvent(self, event):
+ self.fcGlobalFeedback.setVisible(True)
+ BaseRequestsWidget.RequestsWidget.showEvent(self, event)
+
+ def retranslateUi(self, parent):
+ BaseRequestsWidget.RequestsWidget.retranslateUi(self, parent)
+ if self.menuRemoveGroup is not None:
+ self.menuRemoveGroup.setTitle(self.trUtf8('Remove group'))
+
+ ###################################
+ ## methods
+ ###################################
+
+ ###################################
+ ## event handlers
+ ###################################
+ def onTreeCustomContextMenuRequested(self, pt):
+ tree = self.controlById(self.IdTree)
+ pt = tree.viewport().mapToGlobal(pt)
+
+ menu = QtGui.QMenu(self)
+ menu.addMenu(self.menuRemoveGroup)
+ menu.exec_(pt)
+
+ def onTreeItemSelectionChanged(self):
+ tree = self.controlById(self.IdTree)
+ hasSelectedItems = tree.selectionModel().hasSelection()
+
+#**********************************************************************************
+#
+#**********************************************************************************
+if __name__ == '__main__':
+ import sys
+ from .. import View
+ from ..ViewConnection import ViewConnection
+ from ..ViewLogger import ViewLogger
+ from ..MainWindow import MainWindow
+
+ app = QtGui.QApplication(sys.argv)
+
+ mainWindow = MainWindow.MainWindow()
+ viewWidget = View.ViewWidget(mainWindow)
+ mainWindow.setCentralWidget(viewWidget)
+
+ viewWidget.addTopViews(
+ ViewConnection.ViewConnectionWidget(None),
+ ViewUploadsWidget(None),
+ )
+ viewWidget.addBottomViews(ViewLogger.ViewLoggerWidget(None))
+
+ mainWindow.show()
+ res = app.exec_()
+ sys.exit(res)
\ No newline at end of file
Added: trunk/fclient/fclient/impl/ViewUploads/__init__.py
===================================================================
--- trunk/fclient/fclient/impl/ViewUploads/__init__.py (rev 0)
+++ trunk/fclient/fclient/impl/ViewUploads/__init__.py 2008-08-16 08:19:24 UTC (rev 917)
@@ -0,0 +1 @@
+
Added: trunk/fclient/fclient/impl/ViewUploads/_fix_mexec.py
===================================================================
--- trunk/fclient/fclient/impl/ViewUploads/_fix_mexec.py (rev 0)
+++ trunk/fclient/fclient/impl/ViewUploads/_fix_mexec.py 2008-08-16 08:19:24 UTC (rev 917)
@@ -0,0 +1,93 @@
+'''python 2.5 relative impports are srsly broken ..fix this to make relative imports work
+when executing a module as main (-m), including relative imports up to the root package
+
+see: [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html]
+
+@note: root package is the highest available package in the package hirarchy.
+don't look at __name__ too closely. it gets adjusted for a module to just "do the right
+thing" in __name__ == '__main__' comparisons.
+
+usage::
+
+ # place this at the top a module, before doing any relative imports
+ from fix_mexec import fix_mexec
+ fix_mexec(__name__, __file__)
+ del fix_mexec
+
+ from ...foo import bar
+
+
+
+##<-- copy and paste code, assuming _fix_mexec resides in the current dir..
+
+# 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
+
+
+##--> copy and paste code
+'''
+
+import imp, os, sys
+#********************************************************************************
+#
+#********************************************************************************
+class MainName(str):
+ def __eq__(self, other):
+ if other == '__main__': return True
+ return str.__eq__(self, other)
+ def __ne__(self, other):
+ if other == '__main__': return False
+ return str.__ne__(self, other)
+
+
+def fix_mexec(_name_, _file_):
+ """bugfix for relative imports not working
+ @param _name_: __name__ of the module
+ @param _file_: __file__ of the module
+
+ @note: not complete: relies on __init__.py, .pyo (...) is ignored currently
+ """
+ if _name_ == '__main__':
+ out = []
+ # find allparent packages
+ p = os.path.dirname(os.path.abspath(_file_))
+ prev = p
+ while True:
+ pkg = os.path.join(p, '__init__.py')
+ if os.path.isfile(pkg):
+ out.append([pkg, os.path.basename(p)])
+ else:
+ break
+ prev = p
+ p = os.path.dirname(p)
+ if p == prev:
+ break
+ out.reverse()
+
+ # adjust sub package names an import parent modules
+ name = None
+ for n, (fpath, name) in enumerate(out):
+ if n > 0:
+ name = out[n][1] = out[n -1][1] + '.' + out[n][1]
+ m = imp.load_source(name, fpath)
+ m.__path__ = [os.path.dirname(fpath)]
+
+ # adjust name of the __main__ module
+ if name is not None:
+ m = sys.modules.pop('__main__')
+ # 'foo.bar..__main__' does not work for some reason. 'foo.bar' seems to work as expected
+ ##m.__name__ = _Name_(name + '.' + '__main__')
+ m.__name__ = MainName(name)
+ sys.modules[m.__name__] = m
+
+
+
Deleted: trunk/fclient/fclient/impl/ViewUploads.py
===================================================================
--- trunk/fclient/fclient/impl/ViewUploads.py 2008-08-16 08:13:58 UTC (rev 916)
+++ trunk/fclient/fclient/impl/ViewUploads.py 2008-08-16 08:19:24 UTC (rev 917)
@@ -1,173 +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 .BaseRequestsWidget import RequestsWidget
-#************************************************************************************
-#
-#************************************************************************************
-class UploadsWidgetGlobalFeedback(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].setEnabled(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 DownloadsViewObject(config.ViewObject):
-
- def __init__(self, parent):
- config.ViewObject. __init__(self, parent)
-
- self.name=parent.objectName()
- self.displayName=self.trUtf8('Uploads')
- self.icon=QtGui.QIcon()
-
-
-class UploadsWidgetSettings(config.SettingsBase):
-
-
- _key_ = config.IdViewUploadsWidget
- _settings_ = (
- )
-
-
-class ViewUploadsWidget(RequestsWidget):
-
- def __init__(self, parent, idGlobalFeedback=config.IdMainWindow):
-
- self.menuRemoveGroup = None
-
- RequestsWidget.__init__(self, parent)
-
- self.setObjectName(config.IdViewUploadsWidget)
- config.ObjectRegistry.register(self)
- self.fcSettings = UploadsWidgetSettings(self).restore()
- self.fcViewObject = DownloadsViewObject(self)
- self.fcGlobalFeedback = UploadsWidgetGlobalFeedback(self, idGlobalFeedback)
-
- # setup menus
- self.menuRemoveGroup = QtGui.QMenu(self)
- self.menuRemoveGroup.setTitle(self.trUtf8('Remove group'))
- for action in self.fcActions['GroupRemoveGroup'].actions():
- self.menuRemoveGroup.addAction(action)
-
-
- ###################################
- ## overwritten methods
- ###################################
- def hideEvent(self, event):
- self.fcGlobalFeedback.setVisible(False)
- RequestsWidget.hideEvent(self, event)
-
- def showEvent(self, event):
- self.fcGlobalFeedback.setVisible(True)
- RequestsWidget.showEvent(self, event)
-
- def retranslateUi(self, parent):
- RequestsWidget.retranslateUi(self, parent)
- if self.menuRemoveGroup is not None:
- self.menuRemoveGroup.setTitle(self.trUtf8('Remove group'))
-
- ###################################
- ## methods
- ###################################
-
- ###################################
- ## event handlers
- ###################################
- def onTreeCustomContextMenuRequested(self, pt):
- tree = self.controlById(self.IdTree)
- pt = tree.viewport().mapToGlobal(pt)
-
- menu = QtGui.QMenu(self)
- menu.addMenu(self.menuRemoveGroup)
- menu.exec_(pt)
-
- def onTreeItemSelectionChanged(self):
- tree = self.controlById(self.IdTree)
- hasSelectedItems = tree.selectionModel().hasSelection()
-
-#**********************************************************************************
-#
-#**********************************************************************************
-if __name__ == '__main__':
- import sys
- from . import View
- from . import ViewConnection
- from . import ViewLogger
- from . import MainWindow
-
- app = QtGui.QApplication(sys.argv)
-
- mainWindow = MainWindow.MainWindow()
- viewWidget = View.ViewWidget(mainWindow)
- mainWindow.setCentralWidget(viewWidget)
-
- viewWidget.addTopViews(
- ViewConnection.ViewConnectionWidget(None),
- ViewUploadsWidget(None),
- )
- viewWidget.addBottomViews(ViewLogger.ViewLoggerWidget(None))
-
- mainWindow.show()
- res = app.exec_()
- sys.exit(res)
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-08-16 10:54:52
|
Revision: 921
http://fclient.svn.sourceforge.net/fclient/?rev=921&view=rev
Author: jUrner
Date: 2008-08-16 10:55:00 +0000 (Sat, 16 Aug 2008)
Log Message:
-----------
redesdigned view objects
Modified Paths:
--------------
trunk/fclient/fclient/fclient.py
trunk/fclient/fclient/impl/MainWindow/MainWindow.py
trunk/fclient/fclient/impl/ViewBrowser/SideBars/SideBarLoadDetails.py
trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py
trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py
trunk/fclient/fclient/impl/ViewDownloads/ViewDownloads.py
trunk/fclient/fclient/impl/ViewLogger/ViewLogger.py
trunk/fclient/fclient/impl/ViewUploads/ViewUploads.py
trunk/fclient/fclient/impl/config.py
Modified: trunk/fclient/fclient/fclient.py
===================================================================
--- trunk/fclient/fclient/fclient.py 2008-08-16 08:22:18 UTC (rev 920)
+++ trunk/fclient/fclient/fclient.py 2008-08-16 10:55:00 UTC (rev 921)
@@ -12,13 +12,13 @@
from .impl import config
from .impl.lib.qt4ex import singleapp
-from .impl.MainWindow import MainWindow
-from .impl.View import ViewWidget
-from .impl.ViewBrowser import ViewBrowser
-from .impl.ViewConnection import ViewConnection
-from .impl.ViewDownloads import ViewDownloads
-from .impl.ViewLogger import ViewLogger
-from .impl.ViewUploads import ViewUploads
+from .impl.MainWindow.ViewObject import ViewObjectMainWindow
+from .impl.ViewView.ViewObject import ViewObjectView
+from .impl.ViewConnection.ViewObject import ViewObjectConnection
+from .impl.ViewBrowser.ViewObject import ViewObjectBrowser
+from .impl.ViewDownloads.ViewObject import ViewObjectDownloads
+from .impl.ViewLogger.ViewObject import ViewObjectLogger
+from .impl.ViewUploads.ViewObject import ViewObjectUploads
from .impl.DlgSingleAppError import DlgSingleAppError
#*************************************************************
@@ -30,8 +30,8 @@
#TODO: looks like no way to bring the window to the foreground
# the calls do not work on x11. may work on windows though
#
- ##QtGui.QApplication.instance().setActiveWindow(self.userData)
- ##self.userData.activateWindow()
+ ##QtGui.QApplication.instance().setActiveWindow(self.userData.widget())
+ ##self.userData.widget().activateWindow()
pass
def main():
@@ -70,20 +70,37 @@
else: # everything went well. start gui
app = QtGui.QApplication(sys.argv)
- mainWindow = MainWindow.MainWindow()
- singleApp.userData = mainWindow
+
+ #print MainWindow.ViewObject
+
+ voMainWindow = ViewObjectMainWindow(None)
+ voMainWindow.create()
+ singleApp.userData = voMainWindow
- viewWidget = ViewWidget(mainWindow)
- mainWindow.setCentralWidget(viewWidget)
- viewWidget.addTopViews(
- ViewConnection.ViewConnectionWidget(mainWindow),
- ViewBrowser.ViewBrowserWidget(mainWindow),
- ViewDownloads.ViewDownloadsWidget(mainWindow),
- ViewUploads.ViewUploadsWidget(mainWindow),
+ voView = ViewObjectView(voMainWindow)
+ viewWidget = voView.create()
+ voMainWindow.widget().setCentralWidget(viewWidget)
+
+ topViews = (
+ ViewObjectConnection,
+ ViewObjectBrowser,
+ ViewObjectDownloads,
+ ViewObjectUploads,
)
- viewWidget.addBottomViews(ViewLogger.ViewLoggerWidget(mainWindow))
+ for view in topViews:
+ view = view(voView)
+ view.create()
+ viewWidget.addTopViews(view)
- mainWindow.show()
+ bottomViews = (
+ ViewObjectLogger,
+ )
+ for view in bottomViews:
+ view = view(voView)
+ view.create()
+ viewWidget.addBottomViews(view)
+
+ voMainWindow.widget().show()
res = app.exec_()
sys.exit(res)
Modified: trunk/fclient/fclient/impl/MainWindow/MainWindow.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/MainWindow.py 2008-08-16 08:22:18 UTC (rev 920)
+++ trunk/fclient/fclient/impl/MainWindow/MainWindow.py 2008-08-16 10:55:00 UTC (rev 921)
@@ -33,8 +33,6 @@
self._isCreated = False
self.setupUi(self)
- config.ObjectRegistry.register(self)
-
self.fcSettings = Settings.Settings().restore()
self.fcActions = Actions.Actions(self)
self.setMenuBar(MenuBar.MenuBar(self))
Modified: trunk/fclient/fclient/impl/ViewBrowser/SideBars/SideBarLoadDetails.py
===================================================================
--- trunk/fclient/fclient/impl/ViewBrowser/SideBars/SideBarLoadDetails.py 2008-08-16 08:22:18 UTC (rev 920)
+++ trunk/fclient/fclient/impl/ViewBrowser/SideBars/SideBarLoadDetails.py 2008-08-16 10:55:00 UTC (rev 921)
@@ -68,8 +68,6 @@
self.statusNames = {} # TreeItem.Status* --> displayName
self.setupUi(self)
-
- config.ObjectRegistry.register(self)
self.fcSettings = SideBarLoadDetailsSettings(self).restore()
self.baseKey = None # base key of the page
Modified: trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py
===================================================================
--- trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py 2008-08-16 08:22:18 UTC (rev 920)
+++ trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py 2008-08-16 10:55:00 UTC (rev 921)
@@ -82,18 +82,6 @@
#*****************************************************************************************
#
#*****************************************************************************************
-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 ViewBrowserWidget(QtGui.QWidget, Ui_ViewBrowserWidget):
IdTabBrowsers = 'tabBrowsers'
@@ -123,14 +111,9 @@
self.menuSideBars = QtGui.QMenu(self.trUtf8('Side bars')) #TODO: retranslate
self.setupUi(self)
- config.ObjectRegistry.register(self)
-
self.isCreated = False
- self._initialConfigDataArrived = False
-
self.fcSettings = Settings.Settings(self).restore()
self.fcActions = Actions.Actions(self)
- self.fcViewObject = BrowserWidgetViewObject(self)
self.fcGlobalFeedback = GlobalFeedback.GlobalFeedback(self, idGlobalFeedback)
# setup
@@ -308,9 +291,10 @@
if browser is None:
return False
- connectionWidget = config.ObjectRegistry.get(config.IdViewConnectionWidget, None)
- if connectionWidget is None:
- raise ValueError('No connection widget found')
+ connectionView = config.ObjectRegistry.get(config.IdViewObjectConnection, None)
+ if connectionView is None:
+ raise ValueError('No connection view found')
+ connectionWidget = connectionView.widget()
# load url
url.setScheme('http')
@@ -774,29 +758,38 @@
#**********************************************************************************
if __name__ == '__main__':
import sys
- from ..ViewLogger import ViewLoggerWidget
- from ..MainWindow import MainWindow
- from ..View import ViewWidget
- from ..ViewConnection import ViewConnectionWidget
- from ..ViewDownloads import ViewDownloadsWidget
+ from ..MainWindow.ViewObject import ViewObjectMainWindow
+ from ..ViewView.ViewObject import ViewObjectView
+ from ..ViewConnection.ViewObject import ViewObjectConnection
+ from ..ViewLogger.ViewObject import ViewObjectLogger
+ from ..ViewBrowser.ViewObject import ViewObjectBrowser
app = QtGui.QApplication(sys.argv)
- mainWindow = MainWindow.MainWindow()
- viewWidget = ViewWidget(mainWindow)
- mainWindow.setCentralWidget(viewWidget)
-
- browserWidget = ViewBrowserWidget(mainWindow)
- viewWidget.addTopViews(
- ViewConnectionWidget(mainWindow),
- browserWidget,
- ViewDownloadsWidget(mainWindow),
+ voMainWindow = ViewObjectMainWindow(None)
+ voMainWindow.create()
+
+ voView = ViewObjectView(voMainWindow)
+ viewWidget = voView.create()
+ voMainWindow.widget().setCentralWidget(viewWidget)
+
+ topViews = (
+ ViewObjectConnection,
+ ViewObjectBrowser,
)
- viewWidget.addBottomViews(
- ViewLoggerWidget(mainWindow),
- )
-
- mainWindow.show()
+ for view in topViews:
+ view = view(voView)
+ view.create()
+ viewWidget.addTopViews(view)
+
+ bottomViews = (
+ ViewObjectLogger,
+ )
+ for view in bottomViews:
+ view = view(voView)
+ view.create()
+ viewWidget.addBottomViews(view)
+
+ voMainWindow.widget().show()
res = app.exec_()
sys.exit(res)
-
Modified: trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py
===================================================================
--- trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py 2008-08-16 08:22:18 UTC (rev 920)
+++ trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py 2008-08-16 10:55:00 UTC (rev 921)
@@ -95,17 +95,6 @@
spinPort = parent.controlById(parent.IdFproxySpinConnectionPort)
spinPort.setValue(self.value('FproxyConnectionPort'))
-
-class ConnectionViewObject(config.ViewObject):
-
- def __init__(self, parent):
- config.ViewObject. __init__(self, parent)
-
- self.name=parent.objectName()
- self.displayName=self.trUtf8('Connection')
- self.icon=QtGui.QIcon()
-
-
#**********************************************************************************
#
#**********************************************************************************
@@ -177,10 +166,8 @@
spinPort.setRange(0, 0xFFFF) #TODO: no idea if port range (0, 0xFFFF) this is reasonable
self._isCreated = False
- config.ObjectRegistry.register(self)
self.fcSettings = Settings(self).restore()
self.fcActions = Actions(self)
- self.fcViewObject = ConnectionViewObject(self)
self.fcGlobalFeedback = GlobalFeedback(self,idGlobalFeedback)
self._connectionTimer = ConnectionTimer(self)
Modified: trunk/fclient/fclient/impl/ViewDownloads/ViewDownloads.py
===================================================================
--- trunk/fclient/fclient/impl/ViewDownloads/ViewDownloads.py 2008-08-16 08:22:18 UTC (rev 920)
+++ trunk/fclient/fclient/impl/ViewDownloads/ViewDownloads.py 2008-08-16 10:55:00 UTC (rev 921)
@@ -78,17 +78,6 @@
# self.labelFeedbackWrap.setPath(unicode(qString))
-
-class DownloadsViewObject(config.ViewObject):
-
- def __init__(self, parent):
- config.ViewObject. __init__(self, parent)
-
- self.name=parent.objectName()
- self.displayName=self.trUtf8('Downloads')
- self.icon=QtGui.QIcon()
-
-
class DownloadsWidgetSettings(config.SettingsBase):
@@ -107,9 +96,7 @@
BaseRequestsWidget.RequestsWidget.__init__(self, parent)
self.setObjectName(config.IdViewDownloadsWidget)
- config.ObjectRegistry.register(self)
self.fcSettings = DownloadsWidgetSettings(self).restore()
- self.fcViewObject = DownloadsViewObject(self)
self.fcGlobalFeedback = DownloadsWidgetGlobalFeedback(self, idGlobalFeedback)
# setup menus
@@ -181,23 +168,39 @@
#**********************************************************************************
if __name__ == '__main__':
import sys
- from .. import View
- from ..ViewConnection import ViewConnection
- from ..ViewLogger import ViewLogger
- from ..MainWindow import MainWindow
-
+ from ..MainWindow.ViewObject import ViewObjectMainWindow
+ from ..ViewView.ViewObject import ViewObjectView
+ from ..ViewConnection.ViewObject import ViewObjectConnection
+ from ..ViewLogger.ViewObject import ViewObjectLogger
+ from ..ViewDownloads.ViewObject import ViewObjectDownloads
+
app = QtGui.QApplication(sys.argv)
- mainWindow = MainWindow.MainWindow()
- viewWidget = View.ViewWidget(mainWindow)
- mainWindow.setCentralWidget(viewWidget)
-
- viewWidget.addTopViews(
- ViewConnection.ViewConnectionWidget(None),
- ViewDownloadsWidget(None),
+ voMainWindow = ViewObjectMainWindow(None)
+ voMainWindow.create()
+
+ voView = ViewObjectView(voMainWindow)
+ viewWidget = voView.create()
+ voMainWindow.widget().setCentralWidget(viewWidget)
+
+ topViews = (
+ ViewObjectConnection,
+ ViewObjectDownloads,
)
- viewWidget.addBottomViews(ViewLogger.ViewLoggerWidget(None))
+ for view in topViews:
+ view = view(voView)
+ view.create()
+ viewWidget.addTopViews(view)
+
+ bottomViews = (
+ ViewObjectLogger,
+ )
+ for view in bottomViews:
+ view = view(voView)
+ view.create()
+ viewWidget.addBottomViews(view)
+
+ voMainWindow.widget().show()
+ res = app.exec_()
+ sys.exit(res)
- mainWindow.show()
- res = app.exec_()
- sys.exit(res)
\ No newline at end of file
Modified: trunk/fclient/fclient/impl/ViewLogger/ViewLogger.py
===================================================================
--- trunk/fclient/fclient/impl/ViewLogger/ViewLogger.py 2008-08-16 08:22:18 UTC (rev 920)
+++ trunk/fclient/fclient/impl/ViewLogger/ViewLogger.py 2008-08-16 10:55:00 UTC (rev 921)
@@ -121,17 +121,6 @@
('ColorFgVerbosityCHATTY', 'QColor', QtGui.QColor('lightslategray')),
)
-
-class LoggerViewObject(config.ViewObject):
-
- def __init__(self, parent):
- config.ViewObject. __init__(self, parent)
-
- self.name=parent.objectName()
- self.displayName=self.trUtf8('Logger')
- self.icon=QtGui.QIcon()
-
-
#***********************************************************************
#
#***********************************************************************
@@ -158,11 +147,8 @@
self._mainWindowMenus = {} #TODO: wrap along with toolbars to a handy class MainWindowStuff
self.setupUi(self)
- config.ObjectRegistry.register(self)
-
self.fcActions = Actions(self)
self.fcSettings = Settings(self).restore()
- self.fcViewObject = LoggerViewObject(self)
self.fcGlobalFeedback = GlobalFeedback(self, idGlobalFeedback)
Modified: trunk/fclient/fclient/impl/ViewUploads/ViewUploads.py
===================================================================
--- trunk/fclient/fclient/impl/ViewUploads/ViewUploads.py 2008-08-16 08:22:18 UTC (rev 920)
+++ trunk/fclient/fclient/impl/ViewUploads/ViewUploads.py 2008-08-16 10:55:00 UTC (rev 921)
@@ -79,17 +79,6 @@
# self.labelFeedbackWrap.setPath(unicode(qString))
-
-class DownloadsViewObject(config.ViewObject):
-
- def __init__(self, parent):
- config.ViewObject. __init__(self, parent)
-
- self.name=parent.objectName()
- self.displayName=self.trUtf8('Uploads')
- self.icon=QtGui.QIcon()
-
-
class UploadsWidgetSettings(config.SettingsBase):
@@ -107,9 +96,7 @@
BaseRequestsWidget.RequestsWidget.__init__(self, parent)
self.setObjectName(config.IdViewUploadsWidget)
- config.ObjectRegistry.register(self)
self.fcSettings = UploadsWidgetSettings(self).restore()
- self.fcViewObject = DownloadsViewObject(self)
self.fcGlobalFeedback = UploadsWidgetGlobalFeedback(self, idGlobalFeedback)
# setup menus
@@ -159,23 +146,38 @@
#**********************************************************************************
if __name__ == '__main__':
import sys
- from .. import View
- from ..ViewConnection import ViewConnection
- from ..ViewLogger import ViewLogger
- from ..MainWindow import MainWindow
-
+ from ..MainWindow.ViewObject import ViewObjectMainWindow
+ from ..ViewView.ViewObject import ViewObjectView
+ from ..ViewConnection.ViewObject import ViewObjectConnection
+ from ..ViewLogger.ViewObject import ViewObjectLogger
+ from ..ViewUploads.ViewObject import ViewObjectUploads
+
app = QtGui.QApplication(sys.argv)
- mainWindow = MainWindow.MainWindow()
- viewWidget = View.ViewWidget(mainWindow)
- mainWindow.setCentralWidget(viewWidget)
-
- viewWidget.addTopViews(
- ViewConnection.ViewConnectionWidget(None),
- ViewUploadsWidget(None),
+ voMainWindow = ViewObjectMainWindow(None)
+ voMainWindow.create()
+
+ voView = ViewObjectView(voMainWindow)
+ viewWidget = voView.create()
+ voMainWindow.widget().setCentralWidget(viewWidget)
+
+ topViews = (
+ ViewObjectConnection,
+ ViewObjectUploads,
)
- viewWidget.addBottomViews(ViewLogger.ViewLoggerWidget(None))
-
- mainWindow.show()
+ for view in topViews:
+ view = view(voView)
+ view.create()
+ viewWidget.addTopViews(view)
+
+ bottomViews = (
+ ViewObjectLogger,
+ )
+ for view in bottomViews:
+ view = view(voView)
+ view.create()
+ viewWidget.addBottomViews(view)
+
+ voMainWindow.widget().show()
res = app.exec_()
sys.exit(res)
\ No newline at end of file
Modified: trunk/fclient/fclient/impl/config.py
===================================================================
--- trunk/fclient/fclient/impl/config.py 2008-08-16 08:22:18 UTC (rev 920)
+++ trunk/fclient/fclient/impl/config.py 2008-08-16 10:55:00 UTC (rev 921)
@@ -50,6 +50,16 @@
IdSideBarLoadDetails = 'SideBarLoadDetails'
+#####
+IdViewObjectBrowser = QtCore.QString('ViewObjectBrowser')
+IdViewObjectConnection = QtCore.QString('ViewObjectConnection')
+IdViewObjectDownloads = QtCore.QString('ViewObjectDownloads')
+IdViewObjectLogger = QtCore.QString('ViewObjectLogger')
+IdViewObjectMainWindow = QtCore.QString('ViewObjectMainWindow')
+IdViewObjectUploads = QtCore.QString('ViewObjectUploads')
+IdViewObjectView = QtCore.QString('ViewObjectView')
+
+
class ObjectRegistry(weakref.WeakValueDictionary):
"""global object registry
@@ -57,19 +67,19 @@
ObjectRegistry is actually a WeakValueDictionary. so use as a dict
"""
- def register(self, obj):
+ def register(self, viewObject):
"""regisdters an object in the registry
- @param obj: (QObject) object to register
+ @param viewObject: view object to register
@note: QObject.objectName() is taken as id. ids have to be unique throughout the runtime of the gui
"""
- ido = str(obj.objectName())
+ ido = viewObject.name()
if ido in self:
- raise ValueError('ui object already registered: %s' % ido)
- self[ido] = obj
+ raise ValueError('view object already registered: %s' % ido)
+ self[ido] = viewObject
+
+ def unregister(self, viewObject):
+ del self[str(viewObject.name())]
- def unregister(self, obj):
- del self[str(obj.objectName())]
-
ObjectRegistry = ObjectRegistry()
#**********************************************************************************
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-08-18 19:36:58
|
Revision: 941
http://fclient.svn.sourceforge.net/fclient/?rev=941&view=rev
Author: jUrner
Date: 2008-08-18 19:36:54 +0000 (Mon, 18 Aug 2008)
Log Message:
-----------
more package layout changes
Modified Paths:
--------------
trunk/fclient/fclient/fclient.py
trunk/fclient/fclient/impl/MainWindow/MainWindow.py
Added Paths:
-----------
trunk/fclient/fclient/impl/dlgs/
trunk/fclient/fclient/impl/dlgs/DlgPrefs.py
trunk/fclient/fclient/impl/dlgs/DlgSingleAppError.py
trunk/fclient/fclient/impl/dlgs/DlgSingleAppErrorTpl.ui
trunk/fclient/fclient/impl/dlgs/Ui_DlgSingleAppErrorTpl.py
trunk/fclient/fclient/impl/dlgs/__init__.py
trunk/fclient/fclient/impl/dlgs/_fix_mexec.py
Removed Paths:
-------------
trunk/fclient/fclient/impl/tpls/
Modified: trunk/fclient/fclient/fclient.py
===================================================================
--- trunk/fclient/fclient/fclient.py 2008-08-17 13:00:14 UTC (rev 940)
+++ trunk/fclient/fclient/fclient.py 2008-08-18 19:36:54 UTC (rev 941)
@@ -20,7 +20,7 @@
from .impl.ViewLogger.ViewObject import ViewObjectLogger
from .impl.ViewUploads.ViewObject import ViewObjectUploads
-from .impl.DlgSingleAppError import DlgSingleAppError
+from .impl.dlgs.DlgSingleAppError import DlgSingleAppError
#*************************************************************
#
#*************************************************************
Modified: trunk/fclient/fclient/impl/MainWindow/MainWindow.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/MainWindow.py 2008-08-17 13:00:14 UTC (rev 940)
+++ trunk/fclient/fclient/impl/MainWindow/MainWindow.py 2008-08-18 19:36:54 UTC (rev 941)
@@ -14,7 +14,7 @@
from PyQt4 import QtCore, QtGui
from .. import config
-from .. import Prefs
+from ..dlgs import DlgPrefs
from ..lib.qt4ex import dlgabout
from . import Actions
@@ -63,7 +63,7 @@
## event onrs
###################################
def onActPreferencesTriggered(self):
- dlg = Prefs.PrefsDlg(self)
+ dlg = DlgPrefs.DlgPrefs(self)
if dlg.exec_() == dlg.Accepted:
pass
@@ -94,8 +94,11 @@
#**********************************************************************************
if __name__ == '__main__':
import sys
+
app = QtGui.QApplication(sys.argv)
- w = MainWindow(None)
- w.show()
+
+ mainWindow = MainWindow(None)
+
+ mainWindow.show()
res = app.exec_()
- sys.exit(res)
+ sys.exit(res)
\ No newline at end of file
Added: trunk/fclient/fclient/impl/dlgs/DlgPrefs.py
===================================================================
--- trunk/fclient/fclient/impl/dlgs/DlgPrefs.py (rev 0)
+++ trunk/fclient/fclient/impl/dlgs/DlgPrefs.py 2008-08-18 19:36:54 UTC (rev 941)
@@ -0,0 +1,96 @@
+# 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
+
+
+from PyQt4 import QtCore, QtGui
+
+from .. import config
+from ..lib.qt4ex import dlgpreferences
+#**********************************************************************************
+#
+#**********************************************************************************
+class Settings(config.SettingsBase):
+ _key_ = config.IdDlgPrefs
+ _settings_ = (
+ ('DlgState', 'String', QtCore.QString('')),
+ )
+
+
+#***********************************************************************
+#
+#***********************************************************************
+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 DlgPrefs(dlgpreferences.DlgPreferencesFlatTree):
+
+ def __init__(self, parent):
+ root = PrefsPageRoot()
+ for viewObject in config.ObjectRegistry:
+ prefsPage = viewObject.prefsPage()
+ if prefsPage is not None:
+ root(prefsPage)
+ dlgpreferences.DlgPreferencesFlatTree.__init__(self,
+ parent,
+ pages=root,
+ startPage=root.children()[0].uuid() if root.children() else None,
+ )
+ self.setObjectName(config.IdDlgPrefs)
+ 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 = DlgPrefs(None)
+ w.show()
+ res = app.exec_()
+ sys.exit(res)
+
+
Added: trunk/fclient/fclient/impl/dlgs/DlgSingleAppError.py
===================================================================
--- trunk/fclient/fclient/impl/dlgs/DlgSingleAppError.py (rev 0)
+++ trunk/fclient/fclient/impl/dlgs/DlgSingleAppError.py 2008-08-18 19:36:54 UTC (rev 941)
@@ -0,0 +1,139 @@
+#***************************************************************************************
+#TODO:
+# x. error icon
+#
+#*************************************************************************************
+# 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_DlgSingleAppErrorTpl import Ui_DlgSingleAppError
+#**********************************************************************************
+#
+#**********************************************************************************
+class Settings(config.SettingsBase):
+ _key_ = 'DlgSingleAppError'
+ _settings_ = (
+ ('Geometry', 'ByteArray', QtCore.QByteArray()),
+ ('SplitterPos', 'ByteArray', QtCore.QByteArray()),
+ )
+
+
+#**********************************************************************************
+#
+#**********************************************************************************
+class DlgSingleAppError(QtGui.QDialog, Ui_DlgSingleAppError):
+
+ IdTextEdit = 'textEdit'
+ IdEdHost = 'edHost'
+ IdSpinPort = 'spinPort'
+ IdSplitter = 'splitter'
+
+
+ def __init__(self, parent=None, fcpKey=None):
+ QtGui.QDialog.__init__(self, parent)
+
+ self.setupUi(self)
+ self.fcSettings = Settings(self).restore()
+
+ # setup dialog
+ self.restoreGeometry(self.fcSettings.value('Geometry'))
+ self.setWindowTitle(config.FcAppName + self.trUtf8(' - Error starting up'))
+
+
+ # setup host / port
+ edHost = self.controlById(self.IdEdHost)
+ edHost.setText(config.fcSettings.value('SingleAppHost'))
+
+ spinPort = self.controlById(self.IdSpinPort)
+ spinPort.setRange(0, 0xFFFF) #TODO: no idea if port range (0, 0xFFFF) this is reasonable
+ spinPort.setValue(config.fcSettings.value('SingleAppPort'))
+
+
+ # setup text edit
+ ed = self.controlById(self.IdTextEdit)
+ text = self.trUtf8('<b>%1 could not be started!</b>').arg(config.FcAppName)
+ ed.insertHtml(text)
+ ed.insertHtml('<br><br>')
+ text = self.trUtf8('%1 could not establish a socket connection needed to enshure only one application is running at a time. Possible reasons are:').arg(config.FcAppName)
+ ed.insertHtml(text)
+
+ text = '''<ol>
+ <li>%s</li>
+ <li>%s</li>
+
+ </ol>
+ ''' % (
+ self.trUtf8('Your firewall blocks the connection. Adjust your firewall to allow the connection as shown to the left.'),
+ self.trUtf8('Another application may already use host and port as shown. Adjust host and port to your needs. In most cases setting port to an arbitrary (high) number should do the job.'),
+
+ )
+ ed.insertHtml(text)
+ cursor = ed.textCursor()
+ cursor.movePosition(cursor.Start, cursor.MoveAnchor)
+ ed.setTextCursor(cursor)
+
+ # setup splitter
+ splitter = self.controlById(self.IdSplitter)
+ splitter.restoreState(self.fcSettings.value('SplitterPos'))
+ self.connect(splitter, QtCore.SIGNAL('splitterMoved(int, int)'), self.onSplitterMoved)
+
+ ##############################
+ ## methods
+ ##############################
+ def controlById(self, idControl):
+ return getattr(self, idControl)
+
+ ##############################
+ ## overwritten methods
+ ##############################
+ def accept(self):
+ edHost = self.controlById(self.IdEdHost)
+ spinPort = self.controlById(self.IdSpinPort)
+ config.fcSettings.setValues(
+ SingleAppHost=edHost.text(),
+ SingleAppPort=spinPort.value(),
+ )
+
+
+ self.done(self.Accepted)
+
+ ##############################
+ ## overwritten events
+ ##############################
+ def hideEvent(self, event):
+ self.fcSettings.setValues(Geometry=self.saveGeometry())
+
+ ##############################
+ ## event handlers
+ ##############################
+ def onSplitterMoved(self, pos, index):
+ splitter = self.controlById(self.IdSplitter)
+ self.fcSettings.setValues(SplitterPos=splitter.saveState())
+
+#**********************************************************************************
+#
+#**********************************************************************************
+if __name__ == '__main__':
+ import sys
+
+ app = QtGui.QApplication(sys.argv)
+ w = DlgSingleAppError()
+ w.show()
+ res = app.exec_()
+ sys.exit(res)
+
+
Added: trunk/fclient/fclient/impl/dlgs/DlgSingleAppErrorTpl.ui
===================================================================
--- trunk/fclient/fclient/impl/dlgs/DlgSingleAppErrorTpl.ui (rev 0)
+++ trunk/fclient/fclient/impl/dlgs/DlgSingleAppErrorTpl.ui 2008-08-18 19:36:54 UTC (rev 941)
@@ -0,0 +1,119 @@
+<ui version="4.0" >
+ <class>DlgSingleAppError</class>
+ <widget class="QDialog" name="DlgSingleAppError" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>410</width>
+ <height>277</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Dialog</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout" >
+ <item row="1" column="0" >
+ <widget class="Line" name="line" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QDialogButtonBox" name="buttonBox" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons" >
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QSplitter" name="splitter" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <widget class="QTextEdit" name="textEdit" />
+ <widget class="QWidget" name="layoutWidget" >
+ <layout class="QVBoxLayout" name="verticalLayout_2" >
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout" >
+ <item>
+ <widget class="QLabel" name="fieldHeader" >
+ <property name="text" >
+ <string>Host: </string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="edHost" />
+ </item>
+ <item>
+ <widget class="QLabel" name="fieldHeader_2" >
+ <property name="text" >
+ <string>Port: </string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="spinPort" />
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>DlgSingleAppError</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>DlgSingleAppError</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/dlgs/Ui_DlgSingleAppErrorTpl.py
===================================================================
--- trunk/fclient/fclient/impl/dlgs/Ui_DlgSingleAppErrorTpl.py (rev 0)
+++ trunk/fclient/fclient/impl/dlgs/Ui_DlgSingleAppErrorTpl.py 2008-08-18 19:36:54 UTC (rev 941)
@@ -0,0 +1,75 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file '/home/me/src/fclient/trunk/fclient/fclient/impl/tpls/DlgSingleAppErrorTpl.ui'
+#
+# Created: Thu Jul 31 20:24:37 2008
+# by: PyQt4 UI code generator 4.4.3-snapshot-20080705
+#
+# WARNING! All changes made in this file will be lost!
+
+from PyQt4 import QtCore, QtGui
+
+class Ui_DlgSingleAppError(object):
+ def setupUi(self, DlgSingleAppError):
+ DlgSingleAppError.setObjectName("DlgSingleAppError")
+ DlgSingleAppError.resize(410, 277)
+ self.gridLayout = QtGui.QGridLayout(DlgSingleAppError)
+ self.gridLayout.setObjectName("gridLayout")
+ self.line = QtGui.QFrame(DlgSingleAppError)
+ self.line.setFrameShape(QtGui.QFrame.HLine)
+ self.line.setFrameShadow(QtGui.QFrame.Sunken)
+ self.line.setObjectName("line")
+ self.gridLayout.addWidget(self.line, 1, 0, 1, 1)
+ self.buttonBox = QtGui.QDialogButtonBox(DlgSingleAppError)
+ self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
+ self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
+ self.buttonBox.setObjectName("buttonBox")
+ self.gridLayout.addWidget(self.buttonBox, 2, 0, 1, 1)
+ self.splitter = QtGui.QSplitter(DlgSingleAppError)
+ self.splitter.setOrientation(QtCore.Qt.Horizontal)
+ self.splitter.setObjectName("splitter")
+ self.textEdit = QtGui.QTextEdit(self.splitter)
+ self.textEdit.setObjectName("textEdit")
+ self.layoutWidget = QtGui.QWidget(self.splitter)
+ self.layoutWidget.setObjectName("layoutWidget")
+ self.verticalLayout_2 = QtGui.QVBoxLayout(self.layoutWidget)
+ self.verticalLayout_2.setObjectName("verticalLayout_2")
+ self.verticalLayout = QtGui.QVBoxLayout()
+ self.verticalLayout.setObjectName("verticalLayout")
+ self.fieldHeader = QtGui.QLabel(self.layoutWidget)
+ self.fieldHeader.setObjectName("fieldHeader")
+ self.verticalLayout.addWidget(self.fieldHeader)
+ self.edHost = QtGui.QLineEdit(self.layoutWidget)
+ self.edHost.setObjectName("edHost")
+ self.verticalLayout.addWidget(self.edHost)
+ self.fieldHeader_2 = QtGui.QLabel(self.layoutWidget)
+ self.fieldHeader_2.setObjectName("fieldHeader_2")
+ self.verticalLayout.addWidget(self.fieldHeader_2)
+ self.spinPort = QtGui.QSpinBox(self.layoutWidget)
+ self.spinPort.setObjectName("spinPort")
+ self.verticalLayout.addWidget(self.spinPort)
+ self.verticalLayout_2.addLayout(self.verticalLayout)
+ spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
+ self.verticalLayout_2.addItem(spacerItem)
+ self.gridLayout.addWidget(self.splitter, 0, 0, 1, 1)
+
+ self.retranslateUi(DlgSingleAppError)
+ QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), DlgSingleAppError.accept)
+ QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), DlgSingleAppError.reject)
+ QtCore.QMetaObject.connectSlotsByName(DlgSingleAppError)
+
+ def retranslateUi(self, DlgSingleAppError):
+ DlgSingleAppError.setWindowTitle(QtGui.QApplication.translate("DlgSingleAppError", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
+ self.fieldHeader.setText(QtGui.QApplication.translate("DlgSingleAppError", "Host: ", None, QtGui.QApplication.UnicodeUTF8))
+ self.fieldHeader_2.setText(QtGui.QApplication.translate("DlgSingleAppError", "Port: ", None, QtGui.QApplication.UnicodeUTF8))
+
+
+if __name__ == "__main__":
+ import sys
+ app = QtGui.QApplication(sys.argv)
+ DlgSingleAppError = QtGui.QDialog()
+ ui = Ui_DlgSingleAppError()
+ ui.setupUi(DlgSingleAppError)
+ DlgSingleAppError.show()
+ sys.exit(app.exec_())
+
Added: trunk/fclient/fclient/impl/dlgs/__init__.py
===================================================================
--- trunk/fclient/fclient/impl/dlgs/__init__.py (rev 0)
+++ trunk/fclient/fclient/impl/dlgs/__init__.py 2008-08-18 19:36:54 UTC (rev 941)
@@ -0,0 +1 @@
+
Added: trunk/fclient/fclient/impl/dlgs/_fix_mexec.py
===================================================================
--- trunk/fclient/fclient/impl/dlgs/_fix_mexec.py (rev 0)
+++ trunk/fclient/fclient/impl/dlgs/_fix_mexec.py 2008-08-18 19:36:54 UTC (rev 941)
@@ -0,0 +1,99 @@
+'''in python 2.5 relative impports are srsly broken ..fix this to make relative imports work
+when executing a module as main (-m), including relative imports up to the root package
+
+see: [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html]
+
+@note: root package is the highest available package in the package hirarchy.
+don't look at __name__ too closely. it gets adjusted for a module to just "do the right
+thing" in __name__ == '__main__' comparisons
+@note: this patch does not work if relative imports are done in __init__.py. no idea why
+and to be honest, I don't wanna* know..
+@note: this is more or less a hack. so it may have unwanted side effects for example
+when importing parent packages. use at your own risk. could improve this module
+by adding a __main__.py to stop at this level or by fixing the __init__.py bug, but
+I don't think its worth it. see what python2.6 or 3k brings..
+
+usage::
+
+ # place this at the top a module, before doing any relative imports
+ from fix_mexec import fix_mexec
+ fix_mexec(__name__, __file__)
+ del fix_mexec
+
+ from ...foo import bar
+
+
+
+##<-- copy and paste code, assuming _fix_mexec resides in the current dir..
+
+# 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
+
+
+##--> copy and paste code
+'''
+
+import imp, os, sys
+#********************************************************************************
+#
+#********************************************************************************
+class MainName(str):
+ def __eq__(self, other):
+ if other == '__main__': return True
+ return str.__eq__(self, other)
+ def __ne__(self, other):
+ if other == '__main__': return False
+ return str.__ne__(self, other)
+
+
+def fix_mexec(_name_, _file_):
+ """bugfix for relative imports not working
+ @param _name_: __name__ of the module
+ @param _file_: __file__ of the module
+
+ @note: not complete: relies on __init__.py, .pyo (...) is ignored currently
+ """
+ if _name_ == '__main__':
+ out = []
+ # find allparent packages
+ p = os.path.dirname(os.path.abspath(_file_))
+ prev = p
+ while True:
+ pkg = os.path.join(p, '__init__.py')
+ if os.path.isfile(pkg):
+ out.append([pkg, os.path.basename(p)])
+ else:
+ break
+ prev = p
+ p = os.path.dirname(p)
+ if p == prev:
+ break
+ out.reverse()
+
+ # adjust sub package names an import parent modules
+ name = None
+ for n, (fpath, name) in enumerate(out):
+ if n > 0:
+ name = out[n][1] = out[n -1][1] + '.' + out[n][1]
+ m = imp.load_source(name, fpath)
+ m.__path__ = [os.path.dirname(fpath)]
+
+ # adjust name of the __main__ module
+ if name is not None:
+ m = sys.modules.pop('__main__')
+ # 'foo.bar..__main__' does not work for some reason. 'foo.bar' seems to work as expected
+ ##m.__name__ = _Name_(name + '.' + '__main__')
+ m.__name__ = MainName(name)
+ sys.modules[m.__name__] = m
+
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jU...@us...> - 2008-08-22 13:20:50
|
Revision: 962
http://fclient.svn.sourceforge.net/fclient/?rev=962&view=rev
Author: jUrner
Date: 2008-08-22 13:20:59 +0000 (Fri, 22 Aug 2008)
Log Message:
-----------
fix. requests could get added multiple times ++ clear dls on fcpClient disconnect
Modified Paths:
--------------
trunk/fclient/fclient/README
trunk/fclient/fclient/impl/BaseRequestsWidget/BaseRequestsWidget.py
Modified: trunk/fclient/fclient/README
===================================================================
--- trunk/fclient/fclient/README 2008-08-22 13:04:37 UTC (rev 961)
+++ trunk/fclient/fclient/README 2008-08-22 13:20:59 UTC (rev 962)
@@ -19,7 +19,9 @@
bugfixes:
- x. many
+ x. downloadsWidget did not notice dls already present and could add the same dl multiple times. fixed
+
+ x. many more
*******************************************************************
Modified: trunk/fclient/fclient/impl/BaseRequestsWidget/BaseRequestsWidget.py
===================================================================
--- trunk/fclient/fclient/impl/BaseRequestsWidget/BaseRequestsWidget.py 2008-08-22 13:04:37 UTC (rev 961)
+++ trunk/fclient/fclient/impl/BaseRequestsWidget/BaseRequestsWidget.py 2008-08-22 13:20:59 UTC (rev 962)
@@ -38,6 +38,7 @@
# to realize that this is a serious problem...
# x. byte amount postfixes must be transllated ++ use Kib or Kb or let the user decide?
# x. sometimes groups of dls get not removed
+# x. tree is cleared on fcpClient disconnect. maybe a bit harsh. have to think about a better way to handle this
#**************************************************************************************************************
# some fixes for relative imports
# see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below)
@@ -332,6 +333,9 @@
@note: if you add a newly created request, make shure to set the requests PersistentUserData
to the result of the call to L{persistentFcpRequestData}
"""
+ if fcpRequest['Identifier'] in self.fcpRequests:
+ raise ValueError('Request already present')
+
tree = self.controlById(self.IdTree)
root = tree.invisibleRootItem()
item= TreeItem(fcpRequest, root)
@@ -473,12 +477,14 @@
def onFcpClientConnected(self, event, msg):
for action in self.fcActions:
action.setEnabled(True)
-
-
+
def onFcpClientDisconnected(self, event, msg):
+ tree = self.controlById(self.IdTree)
+ tree.clear()
+ self.fcpRequests = {}
for action in self.fcActions:
action.setEnabled(False)
-
+
def onFcpConfigData(self, fcpEvent, fcpRequest):
pass
@@ -552,6 +558,8 @@
def onFcpClientRequestStarted(self, fcpEvent, fcpRequest):
if fcpRequest['RequestStatus'] & fcp2.ConstRequestStatus.Restored:
+ if fcpRequest['Identifier'] in self.fcpRequests:
+ return
try:
requestData = PersistentRequestData.load(fcpRequest['PersistentUserData'])
except pmstruct.PMStructError:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|