fclient-commit Mailing List for fclient (Page 4)
Status: Pre-Alpha
Brought to you by:
jurner
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(23) |
Nov
(54) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(17) |
Feb
(209) |
Mar
(63) |
Apr
(31) |
May
(7) |
Jun
(39) |
Jul
(390) |
Aug
(122) |
Sep
(6) |
Oct
|
Nov
|
Dec
|
From: <jU...@us...> - 2008-08-11 10:41:55
|
Revision: 895 http://fclient.svn.sourceforge.net/fclient/?rev=895&view=rev Author: jUrner Date: 2008-08-11 10:42:00 +0000 (Mon, 11 Aug 2008) Log Message: ----------- massive comb over ++ irems can now be removed groupwise Modified Paths: -------------- trunk/fclient/fclient/impl/ViewDownloads.py Modified: trunk/fclient/fclient/impl/ViewDownloads.py =================================================================== --- trunk/fclient/fclient/impl/ViewDownloads.py 2008-08-11 10:41:15 UTC (rev 894) +++ trunk/fclient/fclient/impl/ViewDownloads.py 2008-08-11 10:42:00 UTC (rev 895) @@ -38,6 +38,7 @@ # 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 #************************************************************************************************************** from __future__ import absolute_import if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below @@ -155,12 +156,31 @@ 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 DownloadsWidgetSettings(config.SettingsBase): _key_ = config.IdViewDownloadsWidget _settings_ = ( + ('MaxSimultaneousDownloads', 'UInt', 3), ) #********************************************************************************** # @@ -175,28 +195,49 @@ #********************************************************************************** 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' + def __init__(self, fcpRequest, *params): QtGui.QTreeWidgetItem.__init__(self, *params) self.fcpRequest = fcpRequest + self.fcOldStatus = self.StatusPending - -# exposes properties for stylesheets + 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 + elif self.fcpRequest['RequestStatus'] & fcp2.ConstRequestStatus.Started: + 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 _status(self): - if self.item.fcpRequest is not None: - if self.item.fcpRequest['RequestStatus'] & fcp2.ConstRequestStatus.Error: - return "error" - elif self.item.fcpRequest['RequestStatus'] & fcp2.ConstRequestStatus.Completed: - return "complete" - else: - return QtCore.QString("loading") - return "notset" - status= QtCore.pyqtProperty("QString", _status) + def _get_status(self): + return self.item.status() + status= QtCore.pyqtProperty("QString", _get_status) #********************************************************************************** # @@ -204,21 +245,14 @@ class ViewDownloadsWidget(QtGui.QWidget, Ui_ViewDownloadsWidget): IdTree = 'tree' - - - HeaderIndexName = 0 - HeaderIndexSize = 1 - HeaderIndexMimeType = 2 - HeaderIndexStatus = 3 - HeaderIndexProgress = 4 - HeaderIndexElapsed = 5 - + def __init__(self, parent, idGlobalFeedback=config.IdMainWindow): QtGui.QWidget.__init__(self, parent) self._isCreated = False self.fcHeaderLabels = {} # fcpIdentifier --> treeItem self.fcpRequests = {} - self.fcRequestStatus = {} + self.fcRequestStatusNames = {} + self.menuRemoveGroup = QtGui.QMenu(self) self.setupUi(self) @@ -240,29 +274,59 @@ ) config.fcpClient.events += self.fcpClientEvents + # setup menus + for action in self.fcActions['GroupRemoveGroup'].actions(): + self.menuRemoveGroup.addAction(action) + ############################ ## private methods ############################ - def _adjustStatusBar(self, item, status): + def _adjustItemStatus(self, item): # to take Css styling into account we have to set a new statusBar for each state change - oldProgressBar= self.tree.itemWidget(item, self.HeaderIndexProgress) - progressBar = ProgressBar(self.tree, item) - progressBar.setObjectName('downloadKey') - if status == 'loading': + 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 status == 'complete': + 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 status == 'error': - progressbar.setMinimum(oldProgressBar.minimum()) - progressbar.setMaximum(oldProgressBar.maximum()) - progressbar.setValue(oldProgressBar.value()) + elif itemStatus == TreeItem.StatusError: + progressBar.setMinimum(oldProgressBar.minimum()) + progressBar.setMaximum(oldProgressBar.maximum()) + progressBar.setValue(oldProgressBar.value()) + elif itemStatus == TreeItem.StatusRemoved: + pass else: - raise ValueError('Unknown status: %r' % status) - self.tree.setItemWidget(item, self.HeaderIndexProgress, progressBar) + 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 _createItemFromFcpRequest(self, fcpRequest): - item= TreeItem(fcpRequest, self.tree) + 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( @@ -272,12 +336,21 @@ ) item.setIcon(0, icon) item.setData( - self.HeaderIndexName, + TreeItem.IndexName, QtCore.Qt.DisplayRole, QtCore.QVariant(os.path.basename(fcpRequest['Filename'])) ) - self._adjustStatusBar(item, 'loading') + + #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 ############################ @@ -286,24 +359,36 @@ def retranslateUi(self, parent): Ui_ViewDownloadsWidget.retranslateUi(self, parent) tree = self.controlById(self.IdTree) + root = tree.invisibleRootItem() + + # adjust header labels self.fcHeaderLabels = { - self.HeaderIndexName: self.trUtf8('Name'), - self.HeaderIndexSize: self.trUtf8('Size'), - self.HeaderIndexMimeType: self.trUtf8('MimeType'), - self.HeaderIndexStatus: self.trUtf8('Status'), - self.HeaderIndexProgress: self.trUtf8('Progress'), - self.HeaderIndexElapsed: self.trUtf8('Elapsed'), + 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())]) - self.fcRequestStatus = { - None: self.trUtf8('Pending'), - fcp2.ConstRequestStatus.Started: self.trUtf8('Loading'), - fcp2.ConstRequestStatus.Completed: self.trUtf8('Complete'), - fcp2.ConstRequestStatus.Error: self.trUtf8('Error'), + # 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'), } - #TODO: retranslate all tree items - + 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() @@ -335,7 +420,6 @@ def downloadFile(self, fcpKey, fileName, **kws): """""" - fileName = unicode(fileName) fcpRequest = config.fcpClient.getFile( fcpKey, @@ -347,13 +431,7 @@ **kws ) item = self._createItemFromFcpRequest(fcpRequest) - item.setData( - self.HeaderIndexStatus, - QtCore.Qt.DisplayRole, - QtCore.QVariant(self.fcRequestStatus[None]), - ) - def populateMenu(self, menu): menu.addAction(self.fcActions['ActionDownloadKeyToDisk']) return menu @@ -397,9 +475,7 @@ 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(): @@ -408,8 +484,37 @@ del self.fcpRequests[item.fcpRequest['Identifier']] item.fcpRequest = config.fcpClient.resendRequest(item.fcpRequest) self.fcpRequests[item.fcpRequest['Identifier']] = item - self._adjustStatusBar(item, 'loading') + 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) + def onTreeCustomContextMenuRequested(self, pt): tree = self.controlById(self.IdTree) pt = tree.viewport().mapToGlobal(pt) @@ -417,13 +522,12 @@ menu = QtGui.QMenu(self) menu.addAction(self.fcActions['ActionRemoveSelectedDownloads']) menu.addAction(self.fcActions['ActionRestartSelectedDownloads']) - + menu.addMenu(self.menuRemoveGroup) menu.exec_(pt) def onTreeItemSelectionChanged(self): tree = self.controlById(self.IdTree) hasSelectedItems = tree.selectionModel().hasSelection() - self.fcActions['ActionRemoveSelectedDownloads'].setEnabled(hasSelectedItems) self.fcActions['ActionRestartSelectedDownloads'].setEnabled(hasSelectedItems) @@ -447,33 +551,22 @@ item = self.fcpRequests.get(fcpRequest['Identifier'], None) if item is not None: item.setData( - self.HeaderIndexSize, + TreeItem.IndexSize, QtCore.Qt.DisplayRole, QtCore.QVariant(numbers.format_num_bytes(fcpRequest['MetadataSize'])) ) item.setData( - self.HeaderIndexMimeType, + TreeItem.IndexMimeType, QtCore.Qt.DisplayRole, QtCore.QVariant(fcpRequest['MetadataContentType']) ) - item.setData( - self.HeaderIndexStatus, - QtCore.Qt.DisplayRole, - QtCore.QVariant(self.fcRequestStatus[fcp2.ConstRequestStatus.Completed]), - ) - self._adjustStatusBar(item, 'complete') + self._adjustItemStatus(item) def onFcpClientRequestFailed(self, fcpEvent, fcpRequest): - item = self.fcpRequests.get(rfcpRequest['Identifier'], None) + item = self.fcpRequests.get(fcpRequest['Identifier'], None) if item is not None: - self._adjustStatusBar(item, 'error') - item.setData( - self.HeaderIndexStatus, - QtCore.Qt.DisplayRole, - QtCore.QVariant(self.fcRequestStatus[fcp2.ConstRequestStatus.Error]), - ) - - + self._adjustItemStatus(item) + #TODO: not tested def onFcpClientRequestModified(self, fcpEvent, fcpRequest): @@ -490,7 +583,7 @@ if fcp2.ConstRequestModified.Filename in fcpRequest['Modified']: item.setData( - self.HeaderIndexName, + TreeItem.IndexName, QtCore.Qt.DisplayRole, QtCore.QVariant(os.path.basename(fcpRequest['Filename'])) ) @@ -499,20 +592,8 @@ def onFcpClientRequestProgress(self, fcpEvent, fcpRequest): item = self.fcpRequests.get(fcpRequest['Identifier'], None) if item is not None: - progressBar = self.tree.itemWidget(item, self.HeaderIndexProgress) - - progressBar.setRange(0, fcpRequest['ProgressRequired']) - progressBar.setValue(fcpRequest['ProgressSucceeded']) - - #TODO: take a wild guess at the size. no other way to do it currently - estimatedSize = int((BLOCK_SIZE * fcpRequest['ProgressRequired']) + 1) - item.setData( - self.HeaderIndexSize, - QtCore.Qt.DisplayRole, - QtCore.QVariant(self.trUtf8('< ') + numbers.format_num_bytes(estimatedSize)), - ) + self._adjustItemStatus(item) - def onFcpClientRequestRemoved(self, fcpEvent, fcpRequest): pass @@ -525,11 +606,10 @@ else: if requestData.get('ClientName', None) == self.objectName(): item = self._createItemFromFcpRequest(fcpRequest) - item.setData( - self.HeaderIndexStatus, - QtCore.Qt.DisplayRole, - QtCore.QVariant(self.fcRequestStatus[fcp2.ConstRequestStatus.Started]), - ) + else: + item = self.fcpRequests.get(fcpRequest['Identifier'], None) + if item is not None: + self._adjustItemStatus(item) #********************************************************************************** # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-11 10:41:14
|
Revision: 894 http://fclient.svn.sourceforge.net/fclient/?rev=894&view=rev Author: jUrner Date: 2008-08-11 10:41:15 +0000 (Mon, 11 Aug 2008) Log Message: ----------- impl bottom up item walks Modified Paths: -------------- trunk/fclient/fclient/impl/lib/qt4ex/treewidgetwrap.py Modified: trunk/fclient/fclient/impl/lib/qt4ex/treewidgetwrap.py =================================================================== --- trunk/fclient/fclient/impl/lib/qt4ex/treewidgetwrap.py 2008-08-11 10:40:25 UTC (rev 893) +++ trunk/fclient/fclient/impl/lib/qt4ex/treewidgetwrap.py 2008-08-11 10:41:15 UTC (rev 894) @@ -40,10 +40,20 @@ # #thow in a walker to fix this.. #************************************************************************************** -def walkItem(item): - yield item - for i in xrange(item.childCount()): - child = item.child(i) +def walkItem(item, topdown=True): + """walks over a treeWidgetItem + @param item: item to walk + @topdown: if True, walks the item top down, else bottom up + """ + if topdown: + yield item + + children = [item.child(i) for i in xrange(item.childCount())] + for child in children: for x in walkItem(child): yield x - \ No newline at end of file + + if not topdown: + yield item + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-11 10:40:18
|
Revision: 893 http://fclient.svn.sourceforge.net/fclient/?rev=893&view=rev Author: jUrner Date: 2008-08-11 10:40:25 +0000 (Mon, 11 Aug 2008) Log Message: ----------- weird typo Modified Paths: -------------- trunk/fclient/fclient/impl/lib/fcp2/client.py trunk/fclient/fclient/impl/lib/fcp2/message.py Modified: trunk/fclient/fclient/impl/lib/fcp2/client.py =================================================================== --- trunk/fclient/fclient/impl/lib/fcp2/client.py 2008-08-10 19:23:17 UTC (rev 892) +++ trunk/fclient/fclient/impl/lib/fcp2/client.py 2008-08-11 10:40:25 UTC (rev 893) @@ -833,7 +833,7 @@ initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Success initialRequest['MetadataContentType'] = msg.get('Metadata.ContentType', '') initialRequest['MetadataSize'] = msg.get('DataLength', 0) - initialRequest['ProgressSucceeeded'] = initialRequest['ProgressRequired'] + initialRequest['ProgressSucceeded'] = initialRequest['ProgressRequired'] # except from GetData all requests are complete here. Next GetData will run through AllData... @@ -1016,7 +1016,7 @@ # we ignore them initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Success initialRequest['URI'] = msg['URI'] - initialRequest['ProgressSucceeeded'] = initialRequest['ProgressRequired'] + initialRequest['ProgressSucceeded'] = initialRequest['ProgressRequired'] self._finalizeRequest(msg, initialRequest, self.events.RequestCompleted) return True Modified: trunk/fclient/fclient/impl/lib/fcp2/message.py =================================================================== --- trunk/fclient/fclient/impl/lib/fcp2/message.py 2008-08-10 19:23:17 UTC (rev 892) +++ trunk/fclient/fclient/impl/lib/fcp2/message.py 2008-08-11 10:40:25 UTC (rev 893) @@ -232,7 +232,7 @@ _PrivateParam('ProgressRequired'): 0, _PrivateParam('ProgressFailed'): 0, _PrivateParam('ProgressFatalyFailed'): 0, - _PrivateParam('ProgressSucceeeded'): 0, + _PrivateParam('ProgressSucceeded'): 0, } _AdditionalParamsGet.update(_AdditionalParamsCommon) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-10 19:23:10
|
Revision: 892 http://fclient.svn.sourceforge.net/fclient/?rev=892&view=rev Author: jUrner Date: 2008-08-10 19:23:17 +0000 (Sun, 10 Aug 2008) Log Message: ----------- some updates for the release Modified Paths: -------------- trunk/web/download-fclient.html trunk/web/intro.html Modified: trunk/web/download-fclient.html =================================================================== --- trunk/web/download-fclient.html 2008-08-10 08:33:28 UTC (rev 891) +++ trunk/web/download-fclient.html 2008-08-10 19:23:17 UTC (rev 892) @@ -13,7 +13,31 @@ <div class="topic"> <br> <br> - Not Yet + + <h3>Prerequesites:</h3> + + In order to run the gui you should have the following packages installed on your machine: + + <ul> + <li> + a recent freenet node. See [<a href="http://freenetproject.org/">http://freenetproject.org/</a>] for details + <li> + Python >= 2.5 from [<a href="http://python.org/download/">http://python.org/download/</a>] + <li> + Qt >= 4.4.3 from trolltech [<a href="http://trolltech.com/downloads/">http://trolltech.com/downloads/</a>] + <li> + PyQt >= 4.4.3 from riverbank computing [<a href="http://www.riverbankcomputing.co.uk/software/pyqt/download/">http://www.riverbankcomputing.co.uk/software/pyqt/download/</a>] + </ul> + + + <br> + Finally, download the latest release of fclient from sourceforge [<a href="http://sourceforge.net/projects/fclient">http://sourceforge.net/projects/fclient</a>] + <br> + <br> + + ..and run it right away from any folder you feel best with. No need to install it to lib-sitepackages. On the project page you will find a bug tracker and a mailing list to discuss the project and report any bugs or feature requests. + + </div> Modified: trunk/web/intro.html =================================================================== --- trunk/web/intro.html 2008-08-10 08:33:28 UTC (rev 891) +++ trunk/web/intro.html 2008-08-10 19:23:17 UTC (rev 892) @@ -9,8 +9,8 @@ <div class="topic"> - <b>fclient:</b> Gui frontend for freenet written in python and Qt. The Gui - is yet under developement + <b>fclient:</b> Gui frontend for freenet written in python and Qt. A pre-alpha release + for testing is available in the downloads section. <br> [<a href="more-fclient.html" target="mainFrame">..more</a>] [<a href="download-fclient.html" target="mainFrame">download</a>] [<a href="screenshots-fclient.html" target="mainFrame">screenshots</a>] 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:33:18
|
Revision: 891 http://fclient.svn.sourceforge.net/fclient/?rev=891&view=rev Author: jUrner Date: 2008-08-10 08:33:28 +0000 (Sun, 10 Aug 2008) Log Message: ----------- prep release Added Paths: ----------- tags/fclient/0.0.1/ Removed Paths: ------------- tags/fclient/fclient/ 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:32:45
|
Revision: 890 http://fclient.svn.sourceforge.net/fclient/?rev=890&view=rev Author: jUrner Date: 2008-08-10 08:32:54 +0000 (Sun, 10 Aug 2008) Log Message: ----------- prep release Added Paths: ----------- tags/fclient/fclient/ 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:31:22
|
Revision: 889 http://fclient.svn.sourceforge.net/fclient/?rev=889&view=rev Author: jUrner Date: 2008-08-10 08:31:32 +0000 (Sun, 10 Aug 2008) Log Message: ----------- prep release Added Paths: ----------- tags/fclient/ 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-10 08:01:45
|
Revision: 887 http://fclient.svn.sourceforge.net/fclient/?rev=887&view=rev Author: jUrner Date: 2008-08-10 08:01:53 +0000 (Sun, 10 Aug 2008) Log Message: ----------- update version Modified Paths: -------------- trunk/fclient/fclient/impl/config.py Modified: trunk/fclient/fclient/impl/config.py =================================================================== --- trunk/fclient/fclient/impl/config.py 2008-08-10 07:54:24 UTC (rev 886) +++ trunk/fclient/fclient/impl/config.py 2008-08-10 08:01:53 UTC (rev 887) @@ -16,7 +16,7 @@ #********************************************************************************** FcOrgName = 'fclient' FcAppName = 'fclient' -FcVersion = '0.1.0' +FcVersion = '0.0.1' FcAuthor = 'Juergen Urner' FcLicence = 'MIT' FcCopyright = '(c) 2008 Juergen Urner' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-10 07:54:15
|
Revision: 886 http://fclient.svn.sourceforge.net/fclient/?rev=886&view=rev Author: jUrner Date: 2008-08-10 07:54:24 +0000 (Sun, 10 Aug 2008) Log Message: ----------- enable/disable actions depending on Fcp connected Modified Paths: -------------- trunk/fclient/fclient/impl/ViewBrowser.py trunk/fclient/fclient/impl/ViewDownloads.py Modified: trunk/fclient/fclient/impl/ViewBrowser.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser.py 2008-08-10 07:53:22 UTC (rev 885) +++ trunk/fclient/fclient/impl/ViewBrowser.py 2008-08-10 07:54:24 UTC (rev 886) @@ -101,8 +101,6 @@ def createRequest(self, operation, request, outgoingData): reply = QtNetwork.QNetworkAccessManager.createRequest(self, operation, request, outgoingData) self.emit(QtCore.SIGNAL('networkRequestCreated(QNetworkReply*)'), reply) - - #print 'createRequest', reply.url() #self.connect(reply, QtCore.SIGNAL('downloadProgress(qint64, qint64)'), self.foo) return reply @@ -948,7 +946,8 @@ act.setText(self.trUtf8('Open image in new tab')) act = browser.pageAction(page.OpenFrameInNewWindow) act.setText(self.trUtf8('Open frame in new tab')) - + + # customize page page.setLinkDelegationPolicy(page.DelegateAllLinks) @@ -1042,6 +1041,7 @@ menu.addAction(self.fcActions['ActionObjectProperties']) #TODO: QwebView assumes we can download queries - we can't + browser.pageAction(page.DownloadLinkToDisk).setEnabled(config.fcpClient.isConnected()) if browser.pageAction(page.DownloadLinkToDisk).isEnabled(): result = config.qStringToFcpKey(hitTestResult.linkUrl().toString()) if result is None: @@ -1303,17 +1303,19 @@ tabWidget = self.controlById(self.IdTabBrowsers) pt = tabWidget.mapToGlobal(pt) pt2 = tabWidget.tabBar().mapFromGlobal(pt) - i = tabWidget.tabBar().tabAt(pt2) + index = tabWidget.tabBar().tabAt(pt2) + # setup actions + self.fcActions['ActionCloseBrowserUnderMouse'].setEnabled(index >-1) + self.fcActions['ActionDuplicateTab'].setEnabled(index >-1) + # setup menu - actCloseBrowserUnderMouse = self.fcActions['ActionCloseBrowserUnderMouse'] - actCloseBrowserUnderMouse.setEnabled(i >-1) - menu.addAction(actCloseBrowserUnderMouse) + menu.addAction(self.fcActions['ActionCloseBrowserUnderMouse']) menu.addAction(self.fcActions['ActionCreateNewTab']) menu.addAction(self.fcActions['ActionDuplicateTab']) menu.addAction(self.fcActions['ActionCloseAllTabs']) act = menu.exec_(pt) - if act == actCloseBrowserUnderMouse: + if act == self.fcActions['ActionCloseBrowserUnderMouse']: tabWidget.removeTab(i) self._adjustCurrentBrowserDependendStuff() @@ -1344,7 +1346,7 @@ browser.setTextSizeMultiplier(browser.textSizeMultiplier() - 0.2) if browser.textSizeMultiplier() >= oldMultiplier: menu.addAction(self.fcActions['ActionZoomOut']).setEnabled(False) - + #********************************************************************************** # #********************************************************************************** Modified: trunk/fclient/fclient/impl/ViewDownloads.py =================================================================== --- trunk/fclient/fclient/impl/ViewDownloads.py 2008-08-10 07:53:22 UTC (rev 885) +++ trunk/fclient/fclient/impl/ViewDownloads.py 2008-08-10 07:54:24 UTC (rev 886) @@ -227,16 +227,18 @@ self.fcActions = DownloadsWidgetActions(self) self.fcViewObject = DownloadsViewObject(self) self.fcGlobalFeedback = DownloadsWidgetGlobalFeedback(self, idGlobalFeedback) - self.fcpEvents = ( + 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.onFcpRequestCompleted), - (config.fcpClient.events.RequestFailed, self.onFcpRequestFailed), - (config.fcpClient.events.RequestModified, self.onFcpRequestModified), - (config.fcpClient.events.RequestProgress, self.onFcpRequestProgress), - (config.fcpClient.events.RequestStarted, self.onFcpRequestStarted), - (config.fcpClient.events.RequestRemoved, self.onFcpRequestRemoved), + (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 += self.fcpEvents + config.fcpClient.events += self.fcpClientEvents ############################ ## private methods @@ -323,7 +325,7 @@ self.connect(tree, QtCore.SIGNAL('itemSelectionChanged() '), self.onTreeItemSelectionChanged) def viewClose(self): - config.fcpClient.events -= self.fcpEvents + config.fcpClient.events -= self.fcpClientEvents ######################################### ## methods @@ -428,11 +430,20 @@ ######################################### ## 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 onFcpRequestCompleted(self, fcpEvent, fcpRequest): + def onFcpClientRequestCompleted(self, fcpEvent, fcpRequest): item = self.fcpRequests.get(fcpRequest['Identifier'], None) if item is not None: item.setData( @@ -452,7 +463,7 @@ ) self._adjustStatusBar(item, 'complete') - def onFcpRequestFailed(self, fcpEvent, fcpRequest): + def onFcpClientRequestFailed(self, fcpEvent, fcpRequest): item = self.fcpRequests.get(rfcpRequest['Identifier'], None) if item is not None: self._adjustStatusBar(item, 'error') @@ -464,7 +475,7 @@ #TODO: not tested - def onFcpRequestModified(self, fcpEvent, fcpRequest): + def onFcpClientRequestModified(self, fcpEvent, fcpRequest): requestIdentifier = fcpRequest['Modified'].get(fcp2.ConstRequestModified.Identifier, None) if requestIdentifier is None: @@ -485,7 +496,7 @@ ) - def onFcpRequestProgress(self, fcpEvent, fcpRequest): + def onFcpClientRequestProgress(self, fcpEvent, fcpRequest): item = self.fcpRequests.get(fcpRequest['Identifier'], None) if item is not None: progressBar = self.tree.itemWidget(item, self.HeaderIndexProgress) @@ -502,10 +513,10 @@ ) - def onFcpRequestRemoved(self, fcpEvent, fcpRequest): + def onFcpClientRequestRemoved(self, fcpEvent, fcpRequest): pass - def onFcpRequestStarted(self, fcpEvent, fcpRequest): + def onFcpClientRequestStarted(self, fcpEvent, fcpRequest): if fcpRequest['RequestStatus'] & fcp2.ConstRequestStatus.Restored: try: requestData = PersistentRequestData.load(fcpRequest['PersistentUserData']) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-10 07:53:13
|
Revision: 885 http://fclient.svn.sourceforge.net/fclient/?rev=885&view=rev Author: jUrner Date: 2008-08-10 07:53:22 +0000 (Sun, 10 Aug 2008) Log Message: ----------- whatevs Modified Paths: -------------- trunk/fclient/fclient/impl/tpls/SideBarLoadDetailsTpl.ui Modified: trunk/fclient/fclient/impl/tpls/SideBarLoadDetailsTpl.ui =================================================================== --- trunk/fclient/fclient/impl/tpls/SideBarLoadDetailsTpl.ui 2008-08-10 07:53:08 UTC (rev 884) +++ trunk/fclient/fclient/impl/tpls/SideBarLoadDetailsTpl.ui 2008-08-10 07:53:22 UTC (rev 885) @@ -16,7 +16,7 @@ <item row="0" column="0" > <layout class="QHBoxLayout" name="horizontalLayout" > <item> - <widget class="QLabel" name="labelHeader" > + <widget class="QLabel" name="header" > <property name="text" > <string>Load details</string> </property> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-10 07:52:59
|
Revision: 884 http://fclient.svn.sourceforge.net/fclient/?rev=884&view=rev Author: jUrner Date: 2008-08-10 07:53:08 +0000 (Sun, 10 Aug 2008) Log Message: ----------- actions could use an iterator Modified Paths: -------------- trunk/fclient/fclient/impl/lib/qt4ex/lib/actions.py Modified: trunk/fclient/fclient/impl/lib/qt4ex/lib/actions.py =================================================================== --- trunk/fclient/fclient/impl/lib/qt4ex/lib/actions.py 2008-08-10 07:52:51 UTC (rev 883) +++ trunk/fclient/fclient/impl/lib/qt4ex/lib/actions.py 2008-08-10 07:53:08 UTC (rev 884) @@ -99,6 +99,10 @@ return self._actions[self._actionNames.index(name)] + def __iter__(self): + return iter(self._actions) + + def get(self, name, default=None): if name in self._actionNames: return self[name] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-10 07:52:43
|
Revision: 883 http://fclient.svn.sourceforge.net/fclient/?rev=883&view=rev Author: jUrner Date: 2008-08-10 07:52:51 +0000 (Sun, 10 Aug 2008) Log Message: ----------- some more debug verbosity consts Modified Paths: -------------- trunk/fclient/fclient/impl/lib/fcp2/consts.py Modified: trunk/fclient/fclient/impl/lib/fcp2/consts.py =================================================================== --- trunk/fclient/fclient/impl/lib/fcp2/consts.py 2008-08-09 11:23:32 UTC (rev 882) +++ trunk/fclient/fclient/impl/lib/fcp2/consts.py 2008-08-10 07:52:51 UTC (rev 883) @@ -107,7 +107,9 @@ Warning = logging.WARNING Error = logging.ERROR Critical = logging.CRITICAL - Quiet = 1000000 + Quiet = Critical + 1 + Max = Quiet + 1 + Notset = logging.NOTSET class ConstDisconnectReason(_BaseBitFlags): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-09 11:23:23
|
Revision: 882 http://fclient.svn.sourceforge.net/fclient/?rev=882&view=rev Author: jUrner Date: 2008-08-09 11:23:32 +0000 (Sat, 09 Aug 2008) Log Message: ----------- removing items is still a bit tricky Modified Paths: -------------- trunk/fclient/fclient/impl/ViewDownloads.py Modified: trunk/fclient/fclient/impl/ViewDownloads.py =================================================================== --- trunk/fclient/fclient/impl/ViewDownloads.py 2008-08-09 11:22:54 UTC (rev 881) +++ trunk/fclient/fclient/impl/ViewDownloads.py 2008-08-09 11:23:32 UTC (rev 882) @@ -391,7 +391,8 @@ 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 - del self.fcpRequests[tmp_item.fcpRequest['Identifier']] + 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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-09 11:22:45
|
Revision: 881 http://fclient.svn.sourceforge.net/fclient/?rev=881&view=rev Author: jUrner Date: 2008-08-09 11:22:54 +0000 (Sat, 09 Aug 2008) Log Message: ----------- got a nice connection label on the statusBar now Modified Paths: -------------- trunk/fclient/fclient/impl/MainWindow.py trunk/fclient/fclient/impl/res/stylesheets/default.css Modified: trunk/fclient/fclient/impl/MainWindow.py =================================================================== --- trunk/fclient/fclient/impl/MainWindow.py 2008-08-09 11:22:16 UTC (rev 880) +++ trunk/fclient/fclient/impl/MainWindow.py 2008-08-09 11:22:54 UTC (rev 881) @@ -21,6 +21,7 @@ _key_ = config.IdMainWindow _settings_ = ( ('Geometry', 'ByteArray', QtCore.QByteArray()), + ('ConnectionLabelFlashRate', 'UInt', 800), ) @@ -78,12 +79,78 @@ class StatusBar(QtGui.QStatusBar): - def __init__(self, parent): - QtGui.QStatusBar.__init__(self, parent) + + 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) - parent.setStatusBar(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): Modified: trunk/fclient/fclient/impl/res/stylesheets/default.css =================================================================== --- trunk/fclient/fclient/impl/res/stylesheets/default.css 2008-08-09 11:22:16 UTC (rev 880) +++ trunk/fclient/fclient/impl/res/stylesheets/default.css 2008-08-09 11:22:54 UTC (rev 881) @@ -95,3 +95,21 @@ background:red; } */ + + +QLabel#LabelConnectionConnected{ + color: green; + font: bold; + background: white; + } +QLabel#LabelConnectionDisonnectedOn{ + color: red; + font: bold; + background: white; + } +QLabel#LabelConnectionDisonnectedOff{ + color: lightsalmon; + font: bold; + background: white; + } + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-09 11:22:06
|
Revision: 880 http://fclient.svn.sourceforge.net/fclient/?rev=880&view=rev Author: jUrner Date: 2008-08-09 11:22:16 +0000 (Sat, 09 Aug 2008) Log Message: ----------- whitespace Modified Paths: -------------- trunk/fclient/fclient/impl/config.py Modified: trunk/fclient/fclient/impl/config.py =================================================================== --- trunk/fclient/fclient/impl/config.py 2008-08-09 08:21:58 UTC (rev 879) +++ trunk/fclient/fclient/impl/config.py 2008-08-09 11:22:16 UTC (rev 880) @@ -281,5 +281,3 @@ def mimeTypeIconName(mimeType): return KnownMimeTypes.get(mimeType, 'mimetype-unknown') - - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-09 08:21:48
|
Revision: 879 http://fclient.svn.sourceforge.net/fclient/?rev=879&view=rev Author: jUrner Date: 2008-08-09 08:21:58 +0000 (Sat, 09 Aug 2008) Log Message: ----------- left over print statement Modified Paths: -------------- trunk/fclient/fclient/impl/DlgDownloadKeyToDisk.py Modified: trunk/fclient/fclient/impl/DlgDownloadKeyToDisk.py =================================================================== --- trunk/fclient/fclient/impl/DlgDownloadKeyToDisk.py 2008-08-09 08:21:06 UTC (rev 878) +++ trunk/fclient/fclient/impl/DlgDownloadKeyToDisk.py 2008-08-09 08:21:58 UTC (rev 879) @@ -49,7 +49,6 @@ # setup key editbox ed = self.controlById(self.IdEdKey) - print fcpKey if fcpKey is not None: ed.setText(fcpKey.toString()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-09 08:20:56
|
Revision: 878 http://fclient.svn.sourceforge.net/fclient/?rev=878&view=rev Author: jUrner Date: 2008-08-09 08:21:06 +0000 (Sat, 09 Aug 2008) Log Message: ----------- dl key was broken. fixed Modified Paths: -------------- trunk/fclient/fclient/impl/ViewBrowser.py Modified: trunk/fclient/fclient/impl/ViewBrowser.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser.py 2008-08-09 07:41:22 UTC (rev 877) +++ trunk/fclient/fclient/impl/ViewBrowser.py 2008-08-09 08:21:06 UTC (rev 878) @@ -68,7 +68,6 @@ from .lib.compactpath.qt4 import pathlabelwrap from . import DlgPropsBrowserObject -from . import DlgDownloadKeyToDisk from . import SideBarLoadDetails from .tpls.Ui_ViewBrowserWidgetTpl import Ui_ViewBrowserWidget @@ -847,28 +846,19 @@ @return: (bool) False if the key in the url is invalid, True otherwise """ fcpKey = config.qStringToFcpKey(QtCore.QString(qUrl.encodedPath())) - if fcpKey is not None: - dlg = DlgDownloadKeyToDisk.DlgDownloadKeyToDisk(self, fcpKey=fcpKey) - if dlg.exec_() == dlg.Accepted: - fileName = dlg.fileName() - downloadsWidget = config.ObjectRegistry.get(config.IdViewDownloadsWidget, None) - if downloadsWidget is None: - raise ValueError('no downloads widget found') - downloadsWidget.downloadFile( - fcpKey, - fileName, - persistence=fcp2.ConstPersistence.Forever, - handleFilenameCollision=True, - ) - return True + if fcpKey is None: + QtGui.QMessageBox.critical( + self, + config.FcAppName + self.trUtf8(' - Browser error'), + self.trUtf8('Can not download key (key is invalid)') + ) + return False + downloadsWidget = config.ObjectRegistry.get(config.IdViewDownloadsWidget, None) + if downloadsWidget is None: + raise ValueError('no downloads widget found') + downloadsWidget.execDlgDownloadKey(fcpKey=fcpKey) + return True - QtGui.QMessageBox.critical( - self, - config.FcAppName + self.trUtf8(' - Browser error'), - self.trUtf8('Can not download key (key is invalid)') - ) - return False - ######################################### ## methods ######################################### This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-09 07:41:12
|
Revision: 877 http://fclient.svn.sourceforge.net/fclient/?rev=877&view=rev Author: jUrner Date: 2008-08-09 07:41:22 +0000 (Sat, 09 Aug 2008) Log Message: ----------- todos Modified Paths: -------------- trunk/fclient/fclient/impl/ViewBrowser.py Modified: trunk/fclient/fclient/impl/ViewBrowser.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser.py 2008-08-09 07:34:39 UTC (rev 876) +++ trunk/fclient/fclient/impl/ViewBrowser.py 2008-08-09 07:41:22 UTC (rev 877) @@ -37,19 +37,18 @@ # x. dropping. accept keys +1. what else to accept? # x. option to upload content from browser? "upload current page" / image ..whatevs # x. print contents - # x. a note on "save link". if it points to a html page, no media is saved, just the html -# -# x. save page ++ load progress details -# idea: we get pretty detailed information about page load via NetworkAccessManager. -# 1. collect all replies -# 2. request replies one by one via urllib if user wants to dl a page. <dl page to folder...> -# 3. provide detailed feedback for the user on page load. a global widget for all browsers -# should get too heavy. a toolDialog for each page is better maybe. not too hard to -# implement. downside is dialogs flapping around ++ feedback to what browser a -# dialog belongs. upside is: multiple pages can be easily monitored while loading. -# maybe a later version can provide a manager for the dialogs to bundle them # x. close icon for ActionCloseSideBar +# x. peformance of QWebView sucks when it comes to rendering images +# x. on some pages images are not be loaded (no network error?!) while ff loads them without any problems +# +#******************************************************************************************* +#TODO: code +# +# x. isolate browser better. state data should be provided by browser +# x. when done, assign timers for tabProgressbars to browser as userData +# x. separate browser and sideBar controllers +# #****************************************************************************************** """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-09 07:34:30
|
Revision: 876 http://fclient.svn.sourceforge.net/fclient/?rev=876&view=rev Author: jUrner Date: 2008-08-09 07:34:39 +0000 (Sat, 09 Aug 2008) Log Message: ----------- comb over Modified Paths: -------------- trunk/fclient/fclient/impl/SideBarLoadDetails.py Modified: trunk/fclient/fclient/impl/SideBarLoadDetails.py =================================================================== --- trunk/fclient/fclient/impl/SideBarLoadDetails.py 2008-08-09 07:34:24 UTC (rev 875) +++ trunk/fclient/fclient/impl/SideBarLoadDetails.py 2008-08-09 07:34:39 UTC (rev 876) @@ -3,14 +3,11 @@ #TODO: # # x. how to adjust item colors via stylesheet? -# x. assumed we get a networkReplyError() signal when for example an image culd not be loaded. does not happen. check -# x. limit number of requests we keep track off? +# x. limit number of requests we keep track off (performance)? # x. context menu actions for items like ...load in browser ..download key (...) # x. save column widths # #******************************************************************************** - - 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__)] @@ -28,23 +25,46 @@ _settings_ = ( ('ColorFgItem', 'QColor', QtGui.QColor('black')), ('ColorBgItem', 'QColor', QtGui.QColor('white')), - ('ColorFgItemError', 'QColor', QtGui.QColor('black')), - ('ColorBgItemError', 'QColor', QtGui.QColor('red')), - + ('ColorFgItemError', 'QColor', QtGui.QColor('red')), + ('ColorBgItemError', 'QColor', QtGui.QColor('white')), + ('ColorFgItemComplete', 'QColor', QtGui.QColor('green')), + ('ColorBgItemComplete', 'QColor', QtGui.QColor('white')), ) + +class TreeItem(QtGui.QTreeWidgetItem): + + StatusNone = 0 + StatusLoading = 1 + StatusComplete = 2 + StatusError = 3 + def __init__(self, *args): + QtGui.QTreeWidgetItem.__init__(self, *args) + self.status = self.StatusNone + self.url = None + + + class SideBarLoadDetails(QtGui.QWidget, Ui_SideBarLoadDetails): IdTree = 'tree' IdBtClose = 'btClose' + IndexProgress = 0 + IndexStatus = 1 + IndexName = 2 + def __init__(self, parent=None, closeAction=None): QtGui.QWidget.__init__(self, parent) + 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 + # setup tree tree = self.controlById(self.IdTree) tree.setUniformRowHeights(True) @@ -56,6 +76,29 @@ bt.setDefaultAction(closeAction) ############################## + ## private methods + ############################## + def _splitBaseKey(self, url): + baseKey = '' + fileName = tmp_fileName = unicode(url.path()) + if tmp_fileName: + tmp_fileName = tmp_fileName.lstrip('/') + if tmp_fileName: + # prep fileName to extract freenetKey + T = tmp_fileName.split('/', 1) + if len(T) == 2: + tmp_baseKey, tmp_fileName = T + else: + tmp_baseKey, tmp_fileName = T[0], '' + # check if baseKey is a freenet key + if config.qStringToFcpKey(tmp_baseKey) is not None: + baseKey = tmp_baseKey + fileName = tmp_fileName + else: + fileName = fileName.lstrip('/') + return baseKey, fileName + + ############################## ## methods ############################## def addNetworkReply(self, indexReply, networkReplyData): @@ -65,42 +108,69 @@ if indexReply < n: return - key = unicode(networkReplyData.url.toString()) - fname = posixpath.basename(posixpath.basename(key)) - if not fname: - fname = '/' + if indexReply == 0: + self.baseKey, fileName = self._splitBaseKey(networkReplyData.url) + else: + #problem: index page may point somewhere deep into a container + # ..so we can not assume all following requests of are lokated deeper + # ..in the age hirarchy. anyways. links to external resources are + # ..always displayed as absolute urls + baseKey, fileName = self._splitBaseKey(networkReplyData.url) + if baseKey != self.baseKey: + fileName = unicode(networkReplyData.url.toString()) + if not fileName: + fileName = '/' - item= QtGui.QTreeWidgetItem(tree) - item.setData( - 0, - QtCore.Qt.DisplayRole, - QtCore.QVariant('0%') - ) - item.setData( - 1, - QtCore.Qt.DisplayRole, - QtCore.QVariant(fname), - ) + item = TreeItem(tree) + item.url = networkReplyData.url + # set progress if networkReplyData.bytesTotal < 1: progress = '0%' else: progress = str(int((float(networkReplyData.bytesReceived) / networkReplyData.bytesTotal * 100))) + '%' - if item is not None: - item.setData( - 0, - QtCore.Qt.DisplayRole, - QtCore.QVariant(progress), - ) - item.setForeground(0, self.fcSettings.value('ColorFgItem')) - item.setBackground(0, self.fcSettings.value('ColorBgItem')) - + item.setData( + self.IndexProgress, + QtCore.Qt.DisplayRole, + QtCore.QVariant(progress), + ) + # set status + if networkReplyData.bytesReceived: + item.status = TreeItem.StatusLoading + if networkReplyData.errorCode is not None: + item.status = TreeItem.StatusError + if networkReplyData.finished: + item.status = TreeItem.StatusComplete + item.setData( + self.IndexStatus, + QtCore.Qt.DisplayRole, + QtCore.QVariant(self.statusNames[item.status]), + ) + # set fileName + item.setData( + self.IndexName, + QtCore.Qt.DisplayRole, + QtCore.QVariant(fileName), + ) + # set vcolors + item.setForeground(self.IndexStatus, self.fcSettings.value('ColorFgItem')) + item.setBackground(self.IndexStatus, self.fcSettings.value('ColorBgItem')) + def controlById(self, idControl): return getattr(self, idControl) + def setCurrent(self, browserWidget, flag): + if flag: + self.setBrowser(browserWidget.currentBrowser()) + else: + tree = self.controlById(self.IdTree) + tree.clear() + self.baseUrl = None + def setBrowser(self, browser): tree = self.controlById(self.IdTree) tree.clear() + self.baseUrl = None # setup browser if browser is not None: self.connect(browser, QtCore.SIGNAL('networkRequestCreated(int, QObject*)'), self.addNetworkReply) @@ -111,23 +181,33 @@ for indexReply, networkReplyData in enumerate(browser.networkGetReplies()): self.addNetworkReply(indexReply, networkReplyData) - def onSetCurrent(self, browserWidget, flag): - if flag: - self.setBrowser(browserWidget.currentBrowser()) - else: - self._items = {} - ########################### - ## + ## overwritten methods ########################### def retranslateUi(self, this): Ui_SideBarLoadDetails.retranslateUi(self, this) tree = self.controlById(self.IdTree) - tree.setHeaderLabels(( - self.trUtf8('Progress'), - self.trUtf8('Name'), - )) - + headerLabels = [ + (self.IndexProgress, self.trUtf8('Progress')), + (self.IndexStatus, self.trUtf8('Status')), + (self.IndexName, self.trUtf8('Name')), + ] + headerLabels.sort() + tree.setHeaderLabels([i[1] for i in headerLabels]) + self.statusNames = { + TreeItem.StatusNone: self.trUtf8('waiting'), + TreeItem.StatusLoading: self.trUtf8('loading'), + TreeItem.StatusComplete: self.trUtf8('complete'), + TreeItem.StatusError: self.trUtf8('error'), + } + root = tree.invisibleRootItem() + for i in xrange(root.childCount()): + item = root.child(i) + item.setData( + self.IndexStatus, + QtCore.Qt.DisplayRole, + QtCore.QVariant(self.statusNames[item.status]), + ) ############################## ## event handlers ############################## @@ -138,26 +218,53 @@ def onBrowserNetworkReplyProgress(self, indexReply, networkReplyData): tree = self.controlById(self.IdTree) item = tree.invisibleRootItem().child(indexReply) - if networkReplyData.bytesTotal < 1: - progress = '0%' - else: - progress = str(int((float(networkReplyData.bytesReceived) / networkReplyData.bytesTotal * 100))) + '%' - if item is not None: + if item is None: + return + if item.status != TreeItem.StatusError: + item.status = item.StatusLoading + if networkReplyData.bytesTotal < 1: + progress = '0%' + else: + progress = str(int((float(networkReplyData.bytesReceived) / networkReplyData.bytesTotal * 100))) + '%' + item.setData( - 0, - QtCore.Qt.DisplayRole, - QtCore.QVariant(progress), - ) + self.IndexProgress, + QtCore.Qt.DisplayRole, + QtCore.QVariant(progress), + ) + item.setData( + self.IndexStatus, + QtCore.Qt.DisplayRole, + QtCore.QVariant(self.statusNames[item.status]), + ) def onBrowserNetworkReplyError(self, indexReply, networkReplyData): tree = self.controlById(self.IdTree) item = tree.invisibleRootItem().child(indexReply) - item.setForeground(0, self.fcSettings.value('ColorFgItemError')) - item.setBackground(0, self.fcSettings.value('ColorBgItemError')) + if item is None: + return + item.setForeground(self.IndexStatus, self.fcSettings.value('ColorFgItemError')) + item.setBackground(self.IndexStatus, self.fcSettings.value('ColorBgItemError')) + item.status = item.StatusError + item.setData( + self.IndexStatus, + QtCore.Qt.DisplayRole, + QtCore.QVariant(self.statusNames[item.status]), + ) def onBrowserNetworkReplyFinished(self, indexReply, networkReplyData): tree = self.controlById(self.IdTree) - item = tree.invisibleRootItem().child(indexReply) - + item = tree.invisibleRootItem().child(indexReply) + if item is None: + return + if item.status != TreeItem.StatusError: + item.status = item.StatusComplete + item.setData( + self.IndexStatus, + QtCore.Qt.DisplayRole, + QtCore.QVariant(self.statusNames[item.status]), + ) + item.setForeground(self.IndexStatus, self.fcSettings.value('ColorFgItemComplete')) + item.setBackground(self.IndexStatus, self.fcSettings.value('ColorBgItemComplete')) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-09 07:34:14
|
Revision: 875 http://fclient.svn.sourceforge.net/fclient/?rev=875&view=rev Author: jUrner Date: 2008-08-09 07:34:24 +0000 (Sat, 09 Aug 2008) Log Message: ----------- bit more work to guess a fileName from a key Modified Paths: -------------- trunk/fclient/fclient/impl/config.py Modified: trunk/fclient/fclient/impl/config.py =================================================================== --- trunk/fclient/fclient/impl/config.py 2008-08-09 07:33:38 UTC (rev 874) +++ trunk/fclient/fclient/impl/config.py 2008-08-09 07:34:24 UTC (rev 875) @@ -4,6 +4,7 @@ if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below import os; __path__ = [os.path.dirname(__file__)] +import posixpath import os import weakref from PyQt4 import QtCore @@ -189,15 +190,19 @@ @paran default: what to return when no filename could be guessed? @return: (QString) filename or or default if no filename was found """ - key = fcpKey.toString().rstrip('/') filename = '' if fcpKey.KeyType == fcp2.ConstKeyType.KSK: if fcpKey.docName is not None: - filename = os.path.basename(fcpKey.docName) + filename = posixpath.basename(fcpKey.docName) + elif fcpKey.KeyType == fcp2.ConstKeyType.CHK: #TODO: docName and tail allowed for CHKs? check fcp2.Key.CHK + if fcpKey.tail is not None: + filename = posixpath.basename(fcpKey.tail) + else: + if fcpKey.docName is not None: + filename = posixpath.basename(fcpKey.docName) else: - filename = os.path.basename(key) - if filename == key: - filename = '' + if fcpKey.tail is not None: + filename = posixpath.basename(fcpKey.tail) if filename: return QtCore.QString(filename) return default This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-09 07:33:28
|
Revision: 874 http://fclient.svn.sourceforge.net/fclient/?rev=874&view=rev Author: jUrner Date: 2008-08-09 07:33:38 +0000 (Sat, 09 Aug 2008) Log Message: ----------- layout Modified Paths: -------------- trunk/fclient/fclient/impl/tpls/Ui_ViewBrowserWidgetTpl.py trunk/fclient/fclient/impl/tpls/ViewBrowserWidgetTpl.ui Modified: trunk/fclient/fclient/impl/tpls/Ui_ViewBrowserWidgetTpl.py =================================================================== --- trunk/fclient/fclient/impl/tpls/Ui_ViewBrowserWidgetTpl.py 2008-08-09 07:33:21 UTC (rev 873) +++ trunk/fclient/fclient/impl/tpls/Ui_ViewBrowserWidgetTpl.py 2008-08-09 07:33:38 UTC (rev 874) @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file '/home/me/src/fclient/trunk/fclient/fclient/impl/tpls/ViewBrowserWidgetTpl.ui' # -# Created: Thu Aug 7 09:08:51 2008 +# Created: Fri Aug 8 10:17:43 2008 # by: PyQt4 UI code generator 4.4.3-snapshot-20080705 # # WARNING! All changes made in this file will be lost! @@ -71,27 +71,27 @@ self.tabSideBar = QtGui.QTabWidget(self.splitter) self.tabSideBar.setObjectName("tabSideBar") self.tab_2 = QtGui.QWidget() - self.tab_2.setGeometry(QtCore.QRect(0, 0, 154, 736)) + self.tab_2.setGeometry(QtCore.QRect(0, 0, 137, 736)) self.tab_2.setObjectName("tab_2") self.tabSideBar.addTab(self.tab_2, "") self.tab_3 = QtGui.QWidget() self.tab_3.setGeometry(QtCore.QRect(0, 0, 150, 712)) self.tab_3.setObjectName("tab_3") self.tabSideBar.addTab(self.tab_3, "") - self.widget = QtGui.QWidget(self.splitter) - self.widget.setObjectName("widget") - self.verticalLayout = QtGui.QVBoxLayout(self.widget) - self.verticalLayout.setSpacing(99) + self.layoutWidget = QtGui.QWidget(self.splitter) + self.layoutWidget.setObjectName("layoutWidget") + self.verticalLayout = QtGui.QVBoxLayout(self.layoutWidget) + self.verticalLayout.setSpacing(0) self.verticalLayout.setMargin(0) self.verticalLayout.setObjectName("verticalLayout") - self.tabBrowsers = QtGui.QTabWidget(self.widget) + self.tabBrowsers = QtGui.QTabWidget(self.layoutWidget) self.tabBrowsers.setObjectName("tabBrowsers") self.tab = QtGui.QWidget() - self.tab.setGeometry(QtCore.QRect(0, 0, 540, 601)) + self.tab.setGeometry(QtCore.QRect(0, 0, 557, 700)) self.tab.setObjectName("tab") self.tabBrowsers.addTab(self.tab, "") self.verticalLayout.addWidget(self.tabBrowsers) - self.frameFind = QtGui.QFrame(self.widget) + self.frameFind = QtGui.QFrame(self.layoutWidget) self.frameFind.setFrameShape(QtGui.QFrame.StyledPanel) self.frameFind.setFrameShadow(QtGui.QFrame.Raised) self.frameFind.setObjectName("frameFind") Modified: trunk/fclient/fclient/impl/tpls/ViewBrowserWidgetTpl.ui =================================================================== --- trunk/fclient/fclient/impl/tpls/ViewBrowserWidgetTpl.ui 2008-08-09 07:33:21 UTC (rev 873) +++ trunk/fclient/fclient/impl/tpls/ViewBrowserWidgetTpl.ui 2008-08-09 07:33:38 UTC (rev 874) @@ -127,7 +127,7 @@ <rect> <x>0</x> <y>0</y> - <width>154</width> + <width>137</width> <height>736</height> </rect> </property> @@ -149,10 +149,10 @@ </attribute> </widget> </widget> - <widget class="QWidget" name="" > + <widget class="QWidget" name="layoutWidget" > <layout class="QVBoxLayout" name="verticalLayout" > <property name="spacing" > - <number>99</number> + <number>0</number> </property> <property name="margin" > <number>0</number> @@ -167,8 +167,8 @@ <rect> <x>0</x> <y>0</y> - <width>540</width> - <height>601</height> + <width>557</width> + <height>700</height> </rect> </property> <attribute name="title" > This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-09 07:33:11
|
Revision: 873 http://fclient.svn.sourceforge.net/fclient/?rev=873&view=rev Author: jUrner Date: 2008-08-09 07:33:21 +0000 (Sat, 09 Aug 2008) Log Message: ----------- network errors did not arrive ++ some sideBar stuff Modified Paths: -------------- trunk/fclient/fclient/impl/ViewBrowser.py Modified: trunk/fclient/fclient/impl/ViewBrowser.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser.py 2008-08-07 10:33:37 UTC (rev 872) +++ trunk/fclient/fclient/impl/ViewBrowser.py 2008-08-09 07:33:21 UTC (rev 873) @@ -76,6 +76,23 @@ #***************************************************************************************** # #***************************************************************************************** +class BrowserSideBar: + """template for sidebars""" + + def __init__(self, parent=None, closeAction=None): + """ + @param parent: parent widget + @param closeAction: (QAction) that should be triggered to close the sideBar + """ + def setCurrent(self, browserWidget, flag): + """ + @param browserWidget: browser widget the sideBar is attatched to + @param flag: (bool) True if the sideBar is the current sidebar now, False otherwise + """ + +#***************************************************************************************** +# +#***************************************************************************************** # to browse via fcp... from PyQt4 import QtNetwork class NetworkAccessManager(QtNetwork.QNetworkAccessManager): @@ -135,7 +152,7 @@ self._networkGetReplies = [[], []] # (QNetworkReplies, urls) self._networkReplySignals = ( ('downloadProgress(qint64, qint64)', self.onNetworkReplyDownloadProgress), - ('error(int)', self.onNetworkReplyError), + ('error(QNetworkReply::NetworkError)', self.onNetworkReplyError), ('finished()', self.onNetworkReplyFinished), ) @@ -1172,7 +1189,7 @@ def onCloseCurrentSideBar(self, action): tabWidget = self.controlById(self.IdTabSideBar) sideBar = tabWidget.currentWidget() - sideBar.onSetCurrent(self, False) + sideBar.setCurrent(self, False) tabWidget.setVisible(False) checkedAction = self.fcActions['GroupSideBars'].checkedAction() if checkedAction is not None: @@ -1280,7 +1297,7 @@ tabWidget = self.controlById(self.IdTabSideBar) if action == self.fcActions['ActionShowSideBarLoadDetails']: index = tabWidget.indexOf(self.sideBarLoadDetails) - self.sideBarLoadDetails.onSetCurrent(self, True) + self.sideBarLoadDetails.setCurrent(self, True) else: raise ValueError('No such sideBar') self.fcSettings.setValues(LastSideBarAction=action.objectName()) @@ -1350,10 +1367,6 @@ from .ViewConnection import ViewConnectionWidget from .ViewDownloads import ViewDownloadsWidget - - from .ViewBrowserDetails import ViewBrowserDetailsWidget - - app = QtGui.QApplication(sys.argv) mainWindow = MainWindow() @@ -1368,7 +1381,6 @@ ) viewWidget.addBottomViews( ViewLoggerWidget(mainWindow), - ViewBrowserDetailsWidget(mainWindow), ) mainWindow.show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-07 10:33:31
|
Revision: 872 http://fclient.svn.sourceforge.net/fclient/?rev=872&view=rev Author: jUrner Date: 2008-08-07 10:33:37 +0000 (Thu, 07 Aug 2008) Log Message: ----------- add a sideBar to browser to display detailed load info Modified Paths: -------------- trunk/fclient/fclient/impl/ViewBrowser.py trunk/fclient/fclient/impl/config.py trunk/fclient/fclient/impl/res/stylesheets/default.css trunk/fclient/fclient/impl/tpls/Ui_ViewBrowserWidgetTpl.py trunk/fclient/fclient/impl/tpls/ViewBrowserWidgetTpl.ui Added Paths: ----------- trunk/fclient/fclient/impl/SideBarLoadDetails.py trunk/fclient/fclient/impl/tpls/SideBarLoadDetailsTpl.ui trunk/fclient/fclient/impl/tpls/Ui_SideBarLoadDetailsTpl.py Added: trunk/fclient/fclient/impl/SideBarLoadDetails.py =================================================================== --- trunk/fclient/fclient/impl/SideBarLoadDetails.py (rev 0) +++ trunk/fclient/fclient/impl/SideBarLoadDetails.py 2008-08-07 10:33:37 UTC (rev 872) @@ -0,0 +1,163 @@ +"""sideBar for the browser to show detailed information on page load""" +#******************************************************************************** +#TODO: +# +# x. how to adjust item colors via stylesheet? +# x. assumed we get a networkReplyError() signal when for example an image culd not be loaded. does not happen. check +# x. limit number of requests we keep track off? +# x. context menu actions for items like ...load in browser ..download key (...) +# x. save column widths +# +#******************************************************************************** + + +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 QtCore, QtGui + +from . import config +from .tpls.Ui_SideBarLoadDetailsTpl import Ui_SideBarLoadDetails +#********************************************************************************** +# +#********************************************************************************** +class SideBarLoadDetailsSettings(config.SettingsBase): + _key_ = config.IdSideBarLoadDetails + _settings_ = ( + ('ColorFgItem', 'QColor', QtGui.QColor('black')), + ('ColorBgItem', 'QColor', QtGui.QColor('white')), + ('ColorFgItemError', 'QColor', QtGui.QColor('black')), + ('ColorBgItemError', 'QColor', QtGui.QColor('red')), + + ) + +class SideBarLoadDetails(QtGui.QWidget, Ui_SideBarLoadDetails): + + IdTree = 'tree' + IdBtClose = 'btClose' + + + def __init__(self, parent=None, closeAction=None): + QtGui.QWidget.__init__(self, parent) + self.setupUi(self) + config.ObjectRegistry.register(self) + self.fcSettings = SideBarLoadDetailsSettings(self).restore() + + # setup tree + tree = self.controlById(self.IdTree) + tree.setUniformRowHeights(True) + tree.setRootIsDecorated(False) + + # setup close button + if closeAction is not None: + bt = self.controlById(self.IdBtClose) + bt.setDefaultAction(closeAction) + + ############################## + ## methods + ############################## + def addNetworkReply(self, indexReply, networkReplyData): + #TODO: better extraction of filename part + tree = self.controlById(self.IdTree) + n = tree.topLevelItemCount() + if indexReply < n: + return + + key = unicode(networkReplyData.url.toString()) + fname = posixpath.basename(posixpath.basename(key)) + if not fname: + fname = '/' + + item= QtGui.QTreeWidgetItem(tree) + item.setData( + 0, + QtCore.Qt.DisplayRole, + QtCore.QVariant('0%') + ) + item.setData( + 1, + QtCore.Qt.DisplayRole, + QtCore.QVariant(fname), + ) + if networkReplyData.bytesTotal < 1: + progress = '0%' + else: + progress = str(int((float(networkReplyData.bytesReceived) / networkReplyData.bytesTotal * 100))) + '%' + if item is not None: + item.setData( + 0, + QtCore.Qt.DisplayRole, + QtCore.QVariant(progress), + ) + item.setForeground(0, self.fcSettings.value('ColorFgItem')) + item.setBackground(0, self.fcSettings.value('ColorBgItem')) + + + def controlById(self, idControl): + return getattr(self, idControl) + + def setBrowser(self, browser): + tree = self.controlById(self.IdTree) + tree.clear() + # setup browser + if browser is not None: + self.connect(browser, QtCore.SIGNAL('networkRequestCreated(int, QObject*)'), self.addNetworkReply) + self.connect(browser, QtCore.SIGNAL('networkReplyProgress(int, QObject*)'), self.onBrowserNetworkReplyProgress) + self.connect(browser, QtCore.SIGNAL('networkReplyError(int, QObject*)'), self.onBrowserNetworkReplyError) + self.connect(browser, QtCore.SIGNAL('networkReplyFinished(int, QObject*)'), self.onBrowserNetworkReplyFinished) + self.connect(browser, QtCore.SIGNAL('loadStarted()'), self.onBrowserLoadStarted) + for indexReply, networkReplyData in enumerate(browser.networkGetReplies()): + self.addNetworkReply(indexReply, networkReplyData) + + def onSetCurrent(self, browserWidget, flag): + if flag: + self.setBrowser(browserWidget.currentBrowser()) + else: + self._items = {} + + ########################### + ## + ########################### + def retranslateUi(self, this): + Ui_SideBarLoadDetails.retranslateUi(self, this) + tree = self.controlById(self.IdTree) + tree.setHeaderLabels(( + self.trUtf8('Progress'), + self.trUtf8('Name'), + )) + + ############################## + ## event handlers + ############################## + def onBrowserLoadStarted(self): + tree = self.controlById(self.IdTree) + tree.clear() + + def onBrowserNetworkReplyProgress(self, indexReply, networkReplyData): + tree = self.controlById(self.IdTree) + item = tree.invisibleRootItem().child(indexReply) + if networkReplyData.bytesTotal < 1: + progress = '0%' + else: + progress = str(int((float(networkReplyData.bytesReceived) / networkReplyData.bytesTotal * 100))) + '%' + if item is not None: + item.setData( + 0, + QtCore.Qt.DisplayRole, + QtCore.QVariant(progress), + ) + + def onBrowserNetworkReplyError(self, indexReply, networkReplyData): + tree = self.controlById(self.IdTree) + item = tree.invisibleRootItem().child(indexReply) + item.setForeground(0, self.fcSettings.value('ColorFgItemError')) + item.setBackground(0, self.fcSettings.value('ColorBgItemError')) + + def onBrowserNetworkReplyFinished(self, indexReply, networkReplyData): + tree = self.controlById(self.IdTree) + item = tree.invisibleRootItem().child(indexReply) + + + Modified: trunk/fclient/fclient/impl/ViewBrowser.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser.py 2008-08-03 19:18:54 UTC (rev 871) +++ trunk/fclient/fclient/impl/ViewBrowser.py 2008-08-07 10:33:37 UTC (rev 872) @@ -37,8 +37,19 @@ # x. dropping. accept keys +1. what else to accept? # x. option to upload content from browser? "upload current page" / image ..whatevs # x. print contents -# x. save page + # x. a note on "save link". if it points to a html page, no media is saved, just the html +# +# x. save page ++ load progress details +# idea: we get pretty detailed information about page load via NetworkAccessManager. +# 1. collect all replies +# 2. request replies one by one via urllib if user wants to dl a page. <dl page to folder...> +# 3. provide detailed feedback for the user on page load. a global widget for all browsers +# should get too heavy. a toolDialog for each page is better maybe. not too hard to +# implement. downside is dialogs flapping around ++ feedback to what browser a +# dialog belongs. upside is: multiple pages can be easily monitored while loading. +# maybe a later version can provide a manager for the dialogs to bundle them +# x. close icon for ActionCloseSideBar #****************************************************************************************** """ @@ -59,37 +70,53 @@ from . import DlgPropsBrowserObject from . import DlgDownloadKeyToDisk +from . import SideBarLoadDetails + from .tpls.Ui_ViewBrowserWidgetTpl import Ui_ViewBrowserWidget #***************************************************************************************** # #***************************************************************************************** # to browse via fcp... -#from PyQt4 import QtNetwork -#class NetworkAccessManager(QtNetwork.QNetworkAccessManager): -# -# def __init__(self, parent): -# QtNetwork.QNetworkAccessManager.__init__(self, parent) -# -# def createRequest(self, operation, request, outgoingData): -# print 'createRequest', request.url() -# reply = QtNetwork.QNetworkAccessManager.createRequest(self, operation, request, outgoingData) -# #TODO: implement QNetworkReply() -# return reply +from PyQt4 import QtNetwork +class NetworkAccessManager(QtNetwork.QNetworkAccessManager): + + def __init__(self, parent): + QtNetwork.QNetworkAccessManager.__init__(self, parent) + + def createRequest(self, operation, request, outgoingData): + reply = QtNetwork.QNetworkAccessManager.createRequest(self, operation, request, outgoingData) + self.emit(QtCore.SIGNAL('networkRequestCreated(QNetworkReply*)'), reply) + + + #print 'createRequest', reply.url() + #self.connect(reply, QtCore.SIGNAL('downloadProgress(qint64, qint64)'), self.foo) + return reply + + def foo(self, *args): + print args - class Page(QtWebKit.QWebPage): def __init__(self, parent): QtWebKit.QWebPage.__init__(self, parent) - #self.setNetworkAccessManager(NetworkAccessManager(self)) - + self.setNetworkAccessManager(NetworkAccessManager(self)) #def acceptNavigationRequest(self, frame, request, typeRequest): # return True #***************************************************************************************** # #***************************************************************************************** +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 + + class Browser(QtWebKit.QWebView): """ browser customized for freenet """ @@ -105,16 +132,44 @@ #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(int)', 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 @@ -136,22 +191,22 @@ return QtWebKit.QWebView.setHtm(self, *args) def setPage(self, page): - """sets the contents of the browser without changing its url""" + """""" 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 setUserData(self, userData): - self._userData = userData - def mouseMoveEvent(self, event): + QtWebKit.QWebView.mouseMoveEvent(self, event) if self._lastProgress < self.MaxProgress: self.setCursor(QtCore.Qt.BusyCursor) - else: - QtWebKit.QWebView.mouseMoveEvent(self, event) - - def userData(self): - return self._userData - + ############################### ## event handlers ############################### @@ -168,16 +223,55 @@ def onLoadStarted(self): self._lastProgress = 0 - + self._networkGetReplies = [[], []] + def onLoadProgress(self, n): self._lastProgress = n - def onLoadFinished(self): - self._lastProgress = self.MaxProgress + 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() == NetworkAccessManager.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('networkRequestCreated(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) #********************************************************************************** # @@ -246,6 +340,10 @@ ('TabProgressBarColor', 'QColor', QtGui.QColor('blue')), ('TabProgressBarAlpha', 'UInt', 55), + + ('SplitterPos', 'ByteArray', QtCore.QByteArray()), + ('LastSideBarAction', 'String', QtCore.QString('')), + ) def setValues(self, **kws): @@ -301,12 +399,19 @@ ) #TODO: shortcut self.action( - name='ActionOpenNewTab', - text=self.trUtf8('Open &new tab'), - trigger=parent.onOpenNewTab, + 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, @@ -406,6 +511,35 @@ 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 @@ -464,7 +598,7 @@ # 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 BrowserTabBar(QtGui.QTabBar): """customized tabBar to show progress indicstor on tabs""" @@ -533,6 +667,9 @@ IdFrameAddressBar = 'frameAddressBar' IdEdAddressBar = 'edAddressBar' + IdTabSideBar = 'tabSideBar' + IdSplitter = 'splitter' + IdBtBack = 'btBack' IdBtForward = 'btForward' IdBtReload = 'btReload' @@ -549,6 +686,8 @@ def __init__(self, parent, idGlobalFeedback=config.IdMainWindow): QtGui.QWidget.__init__(self, parent) + self.menuSideBars = QtGui.QMenu(self.trUtf8('Side bars')) #TODO: retranslate + self.setupUi(self) config.ObjectRegistry.register(self) @@ -572,10 +711,27 @@ self.connect(tabWidget, QtCore.SIGNAL('currentChanged(int)'), self.onTabCurrentChanged) self.connect(tabWidget, QtCore.SIGNAL('customContextMenuRequested(const QPoint &)'), self.onTabContextMenuEvent) - # setup addressbar + # setup sideBar + tabWidget = self.controlById(self.IdTabSideBar) + tabWidget.clear() # clear, setTabBar() seems to take over alreeady present tabs (qt-designer!) + tabWidget.setVisible(False) + tabWidget.tabBar().setVisible(False) + + # add sideBars + for action in self.fcActions['GroupSideBars'].actions(): + self.menuSideBars.addAction(action) + self.sideBarLoadDetails = SideBarLoadDetails.SideBarLoadDetails(tabWidget, closeAction=self.fcActions['ActionCloseCurrentSideBar']) + tabWidget.addTab(self.sideBarLoadDetails, self.trUtf8('Load details')) + + # setup splitter + splitter = self.controlById(self.IdSplitter) + splitter.restoreState(self.fcSettings.value('SplitterPos')) + self.connect(splitter, QtCore.SIGNAL('splitterMoved(int, int)'), self.onSplitterMoved) + + # setup addressBar addressbar = self.controlById(self.IdEdAddressBar) self.connect(addressbar, QtCore.SIGNAL('returnPressed()'), self.onNavBarReturnPressed) - + # setup tool buttons self.controlById(self.IdBtBack).setDefaultAction(self.fcActions['ActionBack']) self.controlById(self.IdBtForward).setDefaultAction(self.fcActions['ActionForward']) @@ -595,9 +751,21 @@ frameFind = self.controlById(self.IdFrameFind) frameFind.setVisible(False) + # finally + #TODO: hopefuly the user will not play around with this setting + actionName = self.fcSettings.value('LastSideBarAction') + action = self.fcActions.get(actionName, None) + if action is not None: + action.trigger() + ######################################### ## private methods ######################################### + def _adjustCurrentBrowserDependendStuff(self): + self.fcActions.intertwineBrowserActions(self.currentBrowser()) + if self.sideBarLoadDetails.isVisible(): + self.sideBarLoadDetails.setBrowser(self.currentBrowser()) + #NOTE: to reduce flicker set min size to max size def _adjustTabText(self, qString): maxTabText = self.fcSettings.value('MaxTabText') @@ -755,7 +923,7 @@ settings.setAttribute(settings.JavascriptCanAccessClipboard, False) settings.setAttribute(settings.PluginsEnabled, False) settings.setAttribute(settings.AutoLoadImages, self.fcSettings.value('AutoLoadImages')) - + # connect browser signals self.connect(browser, QtCore.SIGNAL('loadStarted()'), self.onBrowserLoadStarted) self.connect(browser, QtCore.SIGNAL('loadProgress(int)'), self.onBrowserLoadProgress) @@ -782,6 +950,7 @@ self.connect(page, QtCore.SIGNAL('linkHovered(const QString &, const QString &, const QString &)'), self.onPageLinkHovered) tabWidget.addTab(browser, self._adjustTabText(title)) + self._adjustCurrentBrowserDependendStuff() return browser #TODO: rework. we need more then one menu @@ -794,12 +963,14 @@ menu.addAction(self.fcActions['ActionGoToHomePage']) menu.addAction(self.fcActions['ActionCloseCurrentTab']) menu.addAction(self.fcActions['ActionCloseAllTabs']) - menu.addAction(self.fcActions['ActionOpenNewTab']) + menu.addAction(self.fcActions['ActionCreateNewTab']) menu.addAction(self.fcActions['ActionZoomIn']) menu.addAction(self.fcActions['ActionZoomOut']) menu.addAction(self.fcActions['ActionFind']) menu.addAction(self.fcActions['ActionFindNext']) menu.addAction(self.fcActions['ActionFindPrevious']) + + menu.addMenu(self.menuSideBars) return menu ######################################### @@ -989,20 +1160,74 @@ # have to do it by hand to reset [BackIsClose] tabWidget = self.controlById(self.IdTabBrowsers) tabWidget.clear() - self.fcActions.intertwineBrowserActions(self.currentBrowser()) + self._adjustCurrentBrowserDependendStuff() def onCloseCurrentTab(self, action): tabWidget = self.controlById(self.IdTabBrowsers) i = tabWidget.currentIndex() if i > -1: tabWidget.removeTab(i) - self.fcActions.intertwineBrowserActions(self.currentBrowser()) + self._adjustCurrentBrowserDependendStuff() + + def onCloseCurrentSideBar(self, action): + tabWidget = self.controlById(self.IdTabSideBar) + sideBar = tabWidget.currentWidget() + sideBar.onSetCurrent(self, False) + tabWidget.setVisible(False) + checkedAction = self.fcActions['GroupSideBars'].checkedAction() + if checkedAction is not None: + checkedAction.setChecked(False) + self.fcSettings.setValues(LastSideBarAction=QtCore.QString('')) + + def onDuplicateTab(self, action): + tabWidget = self.controlById(self.IdTabBrowsers) + browser = self.currentBrowser() + print browser + lastBrowserState = browser.userData() + self.fcActions['ActionCreateNewTab'].trigger() + browser = tabWidget.widget(tabWidget.count() -1) + self.load(lastBrowserState.url, browser=browser) def onEdFindTextChanged(self, text): self.fcActions['ActionFindNext'].setEnabled(bool(text)) self.fcActions['ActionFindPrevious'].setEnabled(bool(text)) + def onFind(self, action): + frameFind = self.controlById(self.IdFrameFind) + ed = self.controlById(self.IdEdFind) + #ed.setText('fooBar') + + frameFind.setVisible(not frameFind.isVisible()) + #self.fcActions['ActionFindNext'].setEnabled() + #self.fcActions['ActionFindPrevious'].setEnabled() + if frameFind.isVisible(): + ed.setFocus(QtCore.Qt.OtherFocusReason) + ed.selectAll() + + #TODO: give feedback when no matching text was found + def onFindNext(self): + browser = self.currentBrowser() + if browser is not None: + page = browser.page() + ed = self.controlById(self.IdEdFind) + ck = self.controlById(self.IdCkFindCaseSensitive) + flags = page.FindWrapsAroundDocument + if ck.checkState() == QtCore.Qt.Checked: + flags |= page.FindCaseSensitively + if not browser.findText(ed.text(), flags): + pass + def onFindPrevious(self): + browser = self.currentBrowser() + if browser is not None: + page = browser.page() + ed = self.controlById(self.IdEdFind) + ck = self.controlById(self.IdCkFindCaseSensitive) + flags = page.FindWrapsAroundDocument | page.FindBackward + if ck.checkState() == QtCore.Qt.Checked: + flags |= page.FindCaseSensitively + browser.findText(ed.text(), flags) + #TODO: open in new tab option? def onGoToFProxy(self, action): url = QtCore.QUrl() @@ -1025,12 +1250,17 @@ self.load(qUrl, browser=browser) #TODO: we get no load progress feedback here? - #TODO: more choices for page to load - def onOpenNewTab(self, action): + #TODO: more choices for page to load + #TODO: we load fproxy in new page. this is because we enforce fproxy host/port on urls + # ...no way to distinguish in onDuplicateTab() between an empty page and fproxy page + # ...cos it relies on lastBrowserState.url + def onCreateNewTab(self, action): browser = self.newBrowser(title=self.trUtf8('Empty')) if self.fcSettings.value('OpenHomePageOnNewTabCreated'): homePage = self.fcSettings.value('HomePage') self.load(QtCore.QUrl(homePage), browser=browser) + else: + self.load(QtCore.QUrl(), browser=browser) def onPageLinkHovered(self, link, title, textContent): self.fcGlobalFeedback.setFeedback(QtCore.QString(link)) @@ -1041,62 +1271,50 @@ if browser is not None and act is browser.pageAction(browser.page().Back): self._adjustBackIsClose() - def onFind(self, action): - frameFind = self.controlById(self.IdFrameFind) - ed = self.controlById(self.IdEdFind) - #ed.setText('fooBar') - - frameFind.setVisible(not frameFind.isVisible()) - #self.fcActions['ActionFindNext'].setEnabled() - #self.fcActions['ActionFindPrevious'].setEnabled() - if frameFind.isVisible(): - ed.setFocus(QtCore.Qt.OtherFocusReason) - ed.selectAll() - - #TODO: give feedback when no matching text was found - def onFindNext(self): + def onSavePage(self, action): + # we have to cheat a bit here and reload the page to make shure the page has + # all QNetWorkReplies present browser = self.currentBrowser() - if browser is not None: - page = browser.page() - ed = self.controlById(self.IdEdFind) - ck = self.controlById(self.IdCkFindCaseSensitive) - flags = page.FindWrapsAroundDocument - if ck.checkState() == QtCore.Qt.Checked: - flags |= page.FindCaseSensitively - if not browser.findText(ed.text(), flags): - pass - def onFindPrevious(self): - browser = self.currentBrowser() - if browser is not None: - page = browser.page() - ed = self.controlById(self.IdEdFind) - ck = self.controlById(self.IdCkFindCaseSensitive) - flags = page.FindWrapsAroundDocument | page.FindBackward - if ck.checkState() == QtCore.Qt.Checked: - flags |= page.FindCaseSensitively - browser.findText(ed.text(), flags) + def onShowSidebar(self, action): + tabWidget = self.controlById(self.IdTabSideBar) + if action == self.fcActions['ActionShowSideBarLoadDetails']: + index = tabWidget.indexOf(self.sideBarLoadDetails) + self.sideBarLoadDetails.onSetCurrent(self, True) + else: + raise ValueError('No such sideBar') + self.fcSettings.setValues(LastSideBarAction=action.objectName()) + tabWidget.setCurrentIndex(index) + tabWidget.setVisible(True) + + def onSplitterMoved(self, pos, index): + splitter = self.controlById(self.IdSplitter) + self.fcSettings.setValues(SplitterPos=splitter.saveState()) def onTabContextMenuEvent(self, pt): menu = QtGui.QMenu() + browser = self.currentBrowser() tabWidget = self.controlById(self.IdTabBrowsers) pt = tabWidget.mapToGlobal(pt) pt2 = tabWidget.tabBar().mapFromGlobal(pt) i = tabWidget.tabBar().tabAt(pt2) + # setup menu actCloseBrowserUnderMouse = self.fcActions['ActionCloseBrowserUnderMouse'] actCloseBrowserUnderMouse.setEnabled(i >-1) menu.addAction(actCloseBrowserUnderMouse) + menu.addAction(self.fcActions['ActionCreateNewTab']) + menu.addAction(self.fcActions['ActionDuplicateTab']) menu.addAction(self.fcActions['ActionCloseAllTabs']) act = menu.exec_(pt) if act == actCloseBrowserUnderMouse: tabWidget.removeTab(i) - self.fcActions.intertwineBrowserActions(self.currentBrowser()) - + self._adjustCurrentBrowserDependendStuff() + def onTabCurrentChanged(self, i): tabWidget = self.controlById(self.IdTabBrowsers) browser = tabWidget.widget(i) - self.fcActions.intertwineBrowserActions(browser) + self._adjustCurrentBrowserDependendStuff() if browser is not None: lastBrowserState = browser.userData() addressBar = self.controlById(self.IdEdAddressBar) @@ -1132,6 +1350,10 @@ from .ViewConnection import ViewConnectionWidget from .ViewDownloads import ViewDownloadsWidget + + from .ViewBrowserDetails import ViewBrowserDetailsWidget + + app = QtGui.QApplication(sys.argv) mainWindow = MainWindow() @@ -1144,7 +1366,10 @@ browserWidget, ViewDownloadsWidget(mainWindow), ) - viewWidget.addBottomViews(ViewLoggerWidget(mainWindow)) + viewWidget.addBottomViews( + ViewLoggerWidget(mainWindow), + ViewBrowserDetailsWidget(mainWindow), + ) mainWindow.show() res = app.exec_() Modified: trunk/fclient/fclient/impl/config.py =================================================================== --- trunk/fclient/fclient/impl/config.py 2008-08-03 19:18:54 UTC (rev 871) +++ trunk/fclient/fclient/impl/config.py 2008-08-07 10:33:37 UTC (rev 872) @@ -46,6 +46,7 @@ IdViewLoggerWidget = 'ViewLoggerWidget' IdDlgPrefs = 'DlgPrefs' +IdSideBarLoadDetails = 'SideBarLoadDetails' class ObjectRegistry(weakref.WeakValueDictionary): """global object registry Modified: trunk/fclient/fclient/impl/res/stylesheets/default.css =================================================================== --- trunk/fclient/fclient/impl/res/stylesheets/default.css 2008-08-03 19:18:54 UTC (rev 871) +++ trunk/fclient/fclient/impl/res/stylesheets/default.css 2008-08-07 10:33:37 UTC (rev 872) @@ -13,6 +13,21 @@ **********************************************************************************************/ /* label style. sample: + MyHeader*/ +QLabel#labelHeader, +QLabel#labelHeader_2, +QLabel#labelHeader_3, +QLabel#labelHeader_4, +QLabel#labelHeader_5, +QLabel#labelHeader_6, +QLabel#labelHeader_7, +QLabel#labelHeader_8, +QLabel#labelHeader_9{ + font: bold; + } + + +/* label style. sample: Host: | 9999| */ QLabel#fieldHeader, Added: trunk/fclient/fclient/impl/tpls/SideBarLoadDetailsTpl.ui =================================================================== --- trunk/fclient/fclient/impl/tpls/SideBarLoadDetailsTpl.ui (rev 0) +++ trunk/fclient/fclient/impl/tpls/SideBarLoadDetailsTpl.ui 2008-08-07 10:33:37 UTC (rev 872) @@ -0,0 +1,47 @@ +<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="labelHeader" > + <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> Added: trunk/fclient/fclient/impl/tpls/Ui_SideBarLoadDetailsTpl.py =================================================================== --- trunk/fclient/fclient/impl/tpls/Ui_SideBarLoadDetailsTpl.py (rev 0) +++ trunk/fclient/fclient/impl/tpls/Ui_SideBarLoadDetailsTpl.py 2008-08-07 10:33:37 UTC (rev 872) @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file '/home/me/src/fclient/trunk/fclient/fclient/impl/tpls/SideBarLoadDetailsTpl.ui' +# +# Created: Thu Aug 7 11:44:00 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_SideBarLoadDetails(object): + def setupUi(self, SideBarLoadDetails): + SideBarLoadDetails.setObjectName("SideBarLoadDetails") + SideBarLoadDetails.resize(497, 488) + self.gridLayout = QtGui.QGridLayout(SideBarLoadDetails) + self.gridLayout.setObjectName("gridLayout") + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.labelHeader = QtGui.QLabel(SideBarLoadDetails) + self.labelHeader.setObjectName("labelHeader") + self.horizontalLayout.addWidget(self.labelHeader) + self.btClose = QtGui.QToolButton(SideBarLoadDetails) + self.btClose.setObjectName("btClose") + self.horizontalLayout.addWidget(self.btClose) + self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1) + self.tree = QtGui.QTreeWidget(SideBarLoadDetails) + self.tree.setObjectName("tree") + self.gridLayout.addWidget(self.tree, 1, 0, 1, 1) + + self.retranslateUi(SideBarLoadDetails) + QtCore.QMetaObject.connectSlotsByName(SideBarLoadDetails) + + def retranslateUi(self, SideBarLoadDetails): + SideBarLoadDetails.setWindowTitle(QtGui.QApplication.translate("SideBarLoadDetails", "Form", None, QtGui.QApplication.UnicodeUTF8)) + self.labelHeader.setText(QtGui.QApplication.translate("SideBarLoadDetails", "Load details", None, QtGui.QApplication.UnicodeUTF8)) + self.btClose.setText(QtGui.QApplication.translate("SideBarLoadDetails", "...", None, QtGui.QApplication.UnicodeUTF8)) + self.tree.headerItem().setText(0, QtGui.QApplication.translate("SideBarLoadDetails", "1", None, QtGui.QApplication.UnicodeUTF8)) + + +if __name__ == "__main__": + import sys + app = QtGui.QApplication(sys.argv) + SideBarLoadDetails = QtGui.QWidget() + ui = Ui_SideBarLoadDetails() + ui.setupUi(SideBarLoadDetails) + SideBarLoadDetails.show() + sys.exit(app.exec_()) + Modified: trunk/fclient/fclient/impl/tpls/Ui_ViewBrowserWidgetTpl.py =================================================================== --- trunk/fclient/fclient/impl/tpls/Ui_ViewBrowserWidgetTpl.py 2008-08-03 19:18:54 UTC (rev 871) +++ trunk/fclient/fclient/impl/tpls/Ui_ViewBrowserWidgetTpl.py 2008-08-07 10:33:37 UTC (rev 872) @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file '/home/me/src/proj/fclient/trunk/fclient/src/fclient/impl/tpls/ViewBrowserWidgetTpl.ui' +# Form implementation generated from reading ui file '/home/me/src/fclient/trunk/fclient/fclient/impl/tpls/ViewBrowserWidgetTpl.ui' # -# Created: Tue Jul 29 12:29:18 2008 +# Created: Thu Aug 7 09:08:51 2008 # by: PyQt4 UI code generator 4.4.3-snapshot-20080705 # # WARNING! All changes made in this file will be lost! @@ -14,6 +14,8 @@ ViewBrowserWidget.setObjectName("ViewBrowserWidget") ViewBrowserWidget.resize(710, 794) self.gridLayout_4 = QtGui.QGridLayout(ViewBrowserWidget) + self.gridLayout_4.setMargin(0) + self.gridLayout_4.setSpacing(0) self.gridLayout_4.setObjectName("gridLayout_4") self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setSpacing(0) @@ -58,14 +60,38 @@ self.gridLayout.addWidget(self.edAddressBar, 0, 0, 1, 1) self.horizontalLayout.addWidget(self.frameAddressBar) self.gridLayout_4.addLayout(self.horizontalLayout, 0, 0, 1, 1) - self.tabBrowsers = QtGui.QTabWidget(ViewBrowserWidget) + self.splitter = QtGui.QSplitter(ViewBrowserWidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.splitter.sizePolicy().hasHeightForWidth()) + self.splitter.setSizePolicy(sizePolicy) + self.splitter.setOrientation(QtCore.Qt.Horizontal) + self.splitter.setObjectName("splitter") + self.tabSideBar = QtGui.QTabWidget(self.splitter) + self.tabSideBar.setObjectName("tabSideBar") + self.tab_2 = QtGui.QWidget() + self.tab_2.setGeometry(QtCore.QRect(0, 0, 154, 736)) + self.tab_2.setObjectName("tab_2") + self.tabSideBar.addTab(self.tab_2, "") + self.tab_3 = QtGui.QWidget() + self.tab_3.setGeometry(QtCore.QRect(0, 0, 150, 712)) + self.tab_3.setObjectName("tab_3") + self.tabSideBar.addTab(self.tab_3, "") + self.widget = QtGui.QWidget(self.splitter) + self.widget.setObjectName("widget") + self.verticalLayout = QtGui.QVBoxLayout(self.widget) + self.verticalLayout.setSpacing(99) + self.verticalLayout.setMargin(0) + self.verticalLayout.setObjectName("verticalLayout") + self.tabBrowsers = QtGui.QTabWidget(self.widget) self.tabBrowsers.setObjectName("tabBrowsers") self.tab = QtGui.QWidget() - self.tab.setGeometry(QtCore.QRect(0, 0, 688, 672)) + self.tab.setGeometry(QtCore.QRect(0, 0, 540, 601)) self.tab.setObjectName("tab") self.tabBrowsers.addTab(self.tab, "") - self.gridLayout_4.addWidget(self.tabBrowsers, 1, 0, 1, 1) - self.frameFind = QtGui.QFrame(ViewBrowserWidget) + self.verticalLayout.addWidget(self.tabBrowsers) + self.frameFind = QtGui.QFrame(self.widget) self.frameFind.setFrameShape(QtGui.QFrame.StyledPanel) self.frameFind.setFrameShadow(QtGui.QFrame.Raised) self.frameFind.setObjectName("frameFind") @@ -97,7 +123,8 @@ spacerItem = QtGui.QSpacerItem(48, 25, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem) self.gridLayout_3.addLayout(self.horizontalLayout_2, 0, 0, 1, 1) - self.gridLayout_4.addWidget(self.frameFind, 2, 0, 1, 1) + self.verticalLayout.addWidget(self.frameFind) + self.gridLayout_4.addWidget(self.splitter, 1, 0, 1, 1) self.retranslateUi(ViewBrowserWidget) self.tabBrowsers.setCurrentIndex(0) @@ -109,6 +136,8 @@ self.btForward.setText(QtGui.QApplication.translate("ViewBrowserWidget", "Forward", None, QtGui.QApplication.UnicodeUTF8)) self.btReload.setText(QtGui.QApplication.translate("ViewBrowserWidget", "Reload", None, QtGui.QApplication.UnicodeUTF8)) self.btStop.setText(QtGui.QApplication.translate("ViewBrowserWidget", "Stop", None, QtGui.QApplication.UnicodeUTF8)) + self.tabSideBar.setTabText(self.tabSideBar.indexOf(self.tab_2), QtGui.QApplication.translate("ViewBrowserWidget", "Tab 1", None, QtGui.QApplication.UnicodeUTF8)) + self.tabSideBar.setTabText(self.tabSideBar.indexOf(self.tab_3), QtGui.QApplication.translate("ViewBrowserWidget", "Tab 2", None, QtGui.QApplication.UnicodeUTF8)) self.tabBrowsers.setTabText(self.tabBrowsers.indexOf(self.tab), QtGui.QApplication.translate("ViewBrowserWidget", "Tab 1", None, QtGui.QApplication.UnicodeUTF8)) self.label.setText(QtGui.QApplication.translate("ViewBrowserWidget", "Find:", None, QtGui.QApplication.UnicodeUTF8)) self.btFindNext.setText(QtGui.QApplication.translate("ViewBrowserWidget", "Next", None, QtGui.QApplication.UnicodeUTF8)) Modified: trunk/fclient/fclient/impl/tpls/ViewBrowserWidgetTpl.ui =================================================================== --- trunk/fclient/fclient/impl/tpls/ViewBrowserWidgetTpl.ui 2008-08-03 19:18:54 UTC (rev 871) +++ trunk/fclient/fclient/impl/tpls/ViewBrowserWidgetTpl.ui 2008-08-07 10:33:37 UTC (rev 872) @@ -13,6 +13,12 @@ <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" > @@ -105,102 +111,153 @@ </layout> </item> <item row="1" column="0" > - <widget class="QTabWidget" name="tabBrowsers" > - <property name="currentIndex" > - <number>0</number> + <widget class="QSplitter" name="splitter" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Expanding" hsizetype="Expanding" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> - <widget class="QWidget" name="tab" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>688</width> - <height>672</height> - </rect> - </property> - <attribute name="title" > - <string>Tab 1</string> - </attribute> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <widget class="QTabWidget" name="tabSideBar" > + <widget class="QWidget" name="tab_2" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>154</width> + <height>736</height> + </rect> + </property> + <attribute name="title" > + <string>Tab 1</string> + </attribute> + </widget> + <widget class="QWidget" name="tab_3" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>150</width> + <height>712</height> + </rect> + </property> + <attribute name="title" > + <string>Tab 2</string> + </attribute> + </widget> </widget> - </widget> - </item> - <item row="2" column="0" > - <widget class="QFrame" name="frameFind" > - <property name="frameShape" > - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow" > - <enum>QFrame::Raised</enum> - </property> - <layout class="QGridLayout" name="gridLayout_3" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>0</number> - </property> - <item row="0" column="0" > - <layout class="QHBoxLayout" name="horizontalLayout_2" > - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="label" > - <property name="text" > - <string>Find:</string> + <widget class="QWidget" name="" > + <layout class="QVBoxLayout" name="verticalLayout" > + <property name="spacing" > + <number>99</number> + </property> + <property name="margin" > + <number>0</number> + </property> + <item> + <widget class="QTabWidget" name="tabBrowsers" > + <property name="currentIndex" > + <number>0</number> + </property> + <widget class="QWidget" name="tab" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>540</width> + <height>601</height> + </rect> </property> + <attribute name="title" > + <string>Tab 1</string> + </attribute> </widget> - </item> - <item> - <widget class="QLineEdit" name="edFind" > - <property name="dragEnabled" > - <bool>true</bool> + </widget> + </item> + <item> + <widget class="QFrame" name="frameFind" > + <property name="frameShape" > + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow" > + <enum>QFrame::Raised</enum> + </property> + <layout class="QGridLayout" name="gridLayout_3" > + <property name="margin" > + <number>0</number> </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="btFindNext" > - <property name="text" > - <string>Next</string> + <property name="spacing" > + <number>0</number> </property> - <property name="flat" > - <bool>false</bool> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="btFindPrevious" > - <property name="text" > - <string>Previous</string> - </property> - <property name="flat" > - <bool>false</bool> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="ckFindCaseSensitive" > - <property name="text" > - <string>Case sensitive</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer" > - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0" > - <size> - <width>48</width> - <height>25</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> + <item row="0" column="0" > + <layout class="QHBoxLayout" name="horizontalLayout_2" > + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QLabel" name="label" > + <property name="text" > + <string>Find:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="edFind" > + <property name="dragEnabled" > + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="btFindNext" > + <property name="text" > + <string>Next</string> + </property> + <property name="flat" > + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="btFindPrevious" > + <property name="text" > + <string>Previous</string> + </property> + <property name="flat" > + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="ckFindCaseSensitive" > + <property name="text" > + <string>Case sensitive</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>48</width> + <height>25</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + </item> + </layout> + </widget> </widget> </item> </layout> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-03 19:18:46
|
Revision: 871 http://fclient.svn.sourceforge.net/fclient/?rev=871&view=rev Author: jUrner Date: 2008-08-03 19:18:54 +0000 (Sun, 03 Aug 2008) Log Message: ----------- this and that Modified Paths: -------------- trunk/fclient/fclient/impl/DlgDownloadKeyToDisk.py trunk/fclient/fclient/impl/DlgSingleAppError.py trunk/fclient/fclient/impl/MainWindow.py trunk/fclient/fclient/impl/Prefs.py trunk/fclient/fclient/impl/View.py trunk/fclient/fclient/impl/ViewBrowser.py trunk/fclient/fclient/impl/ViewConnection.py trunk/fclient/fclient/impl/ViewDownloads.py trunk/fclient/fclient/impl/ViewLogger.py trunk/fclient/fclient/impl/config.py trunk/fclient/fclient/impl/lib/fcp2/client.py trunk/fclient/fclient/impl/lib/fcp2/consts.py trunk/fclient/fclient/impl/lib/fcp2/key.py trunk/fclient/fclient/impl/lib/numbers.py Modified: trunk/fclient/fclient/impl/DlgDownloadKeyToDisk.py =================================================================== --- trunk/fclient/fclient/impl/DlgDownloadKeyToDisk.py 2008-08-03 08:21:56 UTC (rev 870) +++ trunk/fclient/fclient/impl/DlgDownloadKeyToDisk.py 2008-08-03 19:18:54 UTC (rev 871) @@ -22,7 +22,7 @@ class Settings(config.SettingsBase): _key_ = 'DlgDownloadKeyToDisk' _settings_ = ( - ('Geometry', 'ByteArray', QtCore.QByteArray(), config.SettingScopePrivate), + ('Geometry', 'ByteArray', QtCore.QByteArray()), ) @@ -49,6 +49,7 @@ # setup key editbox ed = self.controlById(self.IdEdKey) + print fcpKey if fcpKey is not None: ed.setText(fcpKey.toString()) Modified: trunk/fclient/fclient/impl/DlgSingleAppError.py =================================================================== --- trunk/fclient/fclient/impl/DlgSingleAppError.py 2008-08-03 08:21:56 UTC (rev 870) +++ trunk/fclient/fclient/impl/DlgSingleAppError.py 2008-08-03 19:18:54 UTC (rev 871) @@ -21,8 +21,8 @@ class Settings(config.SettingsBase): _key_ = 'DlgSingleAppError' _settings_ = ( - ('Geometry', 'ByteArray', QtCore.QByteArray(), config.SettingScopePrivate), - ('SplitterPos', 'ByteArray', QtCore.QByteArray(), config.SettingScopePrivate), + ('Geometry', 'ByteArray', QtCore.QByteArray()), + ('SplitterPos', 'ByteArray', QtCore.QByteArray()), ) Modified: trunk/fclient/fclient/impl/MainWindow.py =================================================================== --- trunk/fclient/fclient/impl/MainWindow.py 2008-08-03 08:21:56 UTC (rev 870) +++ trunk/fclient/fclient/impl/MainWindow.py 2008-08-03 19:18:54 UTC (rev 871) @@ -20,7 +20,7 @@ _key_ = config.IdMainWindow _settings_ = ( - ('Geometry', 'ByteArray', QtCore.QByteArray(), config.SettingScopePrivate), + ('Geometry', 'ByteArray', QtCore.QByteArray()), ) Modified: trunk/fclient/fclient/impl/Prefs.py =================================================================== --- trunk/fclient/fclient/impl/Prefs.py 2008-08-03 08:21:56 UTC (rev 870) +++ trunk/fclient/fclient/impl/Prefs.py 2008-08-03 19:18:54 UTC (rev 871) @@ -3,7 +3,7 @@ import os; __path__ = [os.path.dirname(__file__)] -from PyQt4 import QtGui +from PyQt4 import QtCore, QtGui from . import config from .lib.qt4ex import dlgpreferences @@ -17,7 +17,7 @@ class Settings(config.SettingsBase): _key_ = config.IdDlgPrefs _settings_ = ( - ('DlgState', 'String', '', config.SettingScopePrivate), + ('DlgState', 'String', QtCore.QString('')), ) Modified: trunk/fclient/fclient/impl/View.py =================================================================== --- trunk/fclient/fclient/impl/View.py 2008-08-03 08:21:56 UTC (rev 870) +++ trunk/fclient/fclient/impl/View.py 2008-08-03 19:18:54 UTC (rev 871) @@ -2,8 +2,8 @@ #TODO: # # x. shortcuts for "Go to" menus and items +# x. detatch tabs # -# #*************************************************************************** from __future__ import absolute_import if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below @@ -60,11 +60,11 @@ class Settings(config.SettingsBase): _key_ = config.IdViewWidget _settings_ = ( - ('LastViewTop', 'String', '', config.SettingScopePrivate), - ('LastViewBottom', 'String', '', config.SettingScopePrivate), - ('SplitterPos', 'ByteArray', QtCore.QByteArray(), config.SettingScopePrivate), - ('ShowTopTabBar', 'Bool', True, config.SettingScopePrivate), - ('ShowBottomTabBar', 'Bool', True, config.SettingScopePrivate), + ('LastViewTop', 'String', QtCore.QString('')), + ('LastViewBottom', 'String', QtCore.QString('')), + ('SplitterPos', 'ByteArray', QtCore.QByteArray()), + ('ShowTopTabBar', 'Bool', True), + ('ShowBottomTabBar', 'Bool', True), ) Modified: trunk/fclient/fclient/impl/ViewBrowser.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser.py 2008-08-03 08:21:56 UTC (rev 870) +++ trunk/fclient/fclient/impl/ViewBrowser.py 2008-08-03 19:18:54 UTC (rev 871) @@ -36,6 +36,9 @@ # more menu entries # x. dropping. accept keys +1. what else to accept? # x. option to upload content from browser? "upload current page" / image ..whatevs +# x. print contents +# x. save page +# x. a note on "save link". if it points to a html page, no media is saved, just the html #****************************************************************************************** """ @@ -60,9 +63,26 @@ #***************************************************************************************** # #***************************************************************************************** +# to browse via fcp... +#from PyQt4 import QtNetwork +#class NetworkAccessManager(QtNetwork.QNetworkAccessManager): +# +# def __init__(self, parent): +# QtNetwork.QNetworkAccessManager.__init__(self, parent) +# +# def createRequest(self, operation, request, outgoingData): +# print 'createRequest', request.url() +# reply = QtNetwork.QNetworkAccessManager.createRequest(self, operation, request, outgoingData) +# #TODO: implement QNetworkReply() +# return reply + + + class Page(QtWebKit.QWebPage): def __init__(self, parent): QtWebKit.QWebPage.__init__(self, parent) + + #self.setNetworkAccessManager(NetworkAccessManager(self)) #def acceptNavigationRequest(self, frame, request, typeRequest): # return True @@ -214,18 +234,18 @@ class BrowserWidgetSettings(config.SettingsBase): _key_ = config.IdViewBrowserWidget _settings_ = ( - ('OpenLinksInNewTab', 'Bool', False, config.SettingScopeUser), - ('OpenAddressBarInNewTab', 'Bool', False, config.SettingScopeUser), - ('OpenBookmarksInNewTab', 'Bool', False, config.SettingScopeUser), - ('OpenHomePageOnNewTabCreated', 'Bool', False, config.SettingScopeUser), - ('BackIsClose', 'Bool', False, config.SettingScopeUser), #TODO: not implemented - ('HomePage', 'String', QtCore.QString(), config.SettingScopeUser), - ('AutoLoadImages', 'Bool', True, config.SettingScopeUser), #TODO: not yet implemented - ('MaxTabText', 'UInt', 15, config.SettingScopeUser), #NOTE: make shure Max >= Min and Max and Min > 0 - ('MinTabText', 'UInt', 15, config.SettingScopeUser), + ('OpenLinksInNewTab', 'Bool', False), + ('OpenAddressBarInNewTab', 'Bool', False), + ('OpenBookmarksInNewTab', 'Bool', False), + ('OpenHomePageOnNewTabCreated', 'Bool', False), + ('BackIsClose', 'Bool', False), #TODO: not implemented + ('HomePage', 'String', QtCore.QString()), + ('AutoLoadImages', 'Bool', True), #TODO: not yet implemented + ('MaxTabText', 'UInt', 15), #NOTE: make shure Max >= Min and Max and Min > 0 + ('MinTabText', 'UInt', 15), - ('TabProgressBarColor', 'QColor', QtGui.QColor('blue'), config.SettingScopeUser), - ('TabProgressBarAlpha', 'UInt', 55, config.SettingScopeUser), + ('TabProgressBarColor', 'QColor', QtGui.QColor('blue')), + ('TabProgressBarAlpha', 'UInt', 55), ) def setValues(self, **kws): @@ -647,7 +667,7 @@ dlg = DlgDownloadKeyToDisk.DlgDownloadKeyToDisk(self, fcpKey=fcpKey) if dlg.exec_() == dlg.Accepted: fileName = dlg.fileName() - downloadsWidget = config.ObjectRegistry.get(config.IdViewCDownloadsWidget, None) + downloadsWidget = config.ObjectRegistry.get(config.IdViewDownloadsWidget, None) if downloadsWidget is None: raise ValueError('no downloads widget found') downloadsWidget.downloadFile( @@ -822,7 +842,7 @@ page = browser.page() hitTestResult = frame.hitTestContent(pt) pt = browser.mapToGlobal(pt) - + #if not hitTest.isNull(): #TODO: looks like hitTest.isNull() alwas returns True menu = QtGui.QMenu() @@ -936,6 +956,7 @@ url = browser.userData().url self.load(url, browser=browser) + def onBrowserStatusBarMessage(self, qString): browser = self.sender() qString = QtCore.QString(qString) # copy it - qt nukes it on return @@ -1129,33 +1150,3 @@ res = app.exec_() sys.exit(res) -#********************************************************************************** -# -#********************************************************************************** -## looks we could serve pages via fcp, bypassing fproxy -## no reason to do so.. -## -##class NetworkAccessManager(QtNetwork.QNetworkAccessManager): -## -## def __init__(self, parent): -## QtNetwork.QNetworkAccessManager.__init__(self, parent) -## -## def createRequest(self, operation, request, outgoingData): -## print 'createRequest', request.url() -## reply = QtNetwork.QNetworkAccessManager.createRequest(self, operation, request, outgoingData) -## #TODO: implement QNetworkReply() -## return reply -## -## -##class Browser(QtWebKit.QWebView): -## -##def __init__(self, browserWidget): -## QtWebKit.QWebView.__init__(self, browserWidget) -## -## self.nam = NetworkAccessManager(self) -## self.page().setNetworkAccessManager(self.nam) -## -#********************************************************************************** -# -#********************************************************************************** - \ No newline at end of file Modified: trunk/fclient/fclient/impl/ViewConnection.py =================================================================== --- trunk/fclient/fclient/impl/ViewConnection.py 2008-08-03 08:21:56 UTC (rev 870) +++ trunk/fclient/fclient/impl/ViewConnection.py 2008-08-03 19:18:54 UTC (rev 871) @@ -50,16 +50,16 @@ class Settings(config.SettingsBase): _key_ = config.IdViewConnectionWidget _settings_ = ( - ('FcpAutoConnect', 'Bool', True, config.SettingScopeUser), - ('FcpConnectionName', 'String', config.FcConnectionName, config.SettingScopeExpert), - ('FcpConnectionHost', 'String', fcp2.Client.DefaultFcpHost, config.SettingScopeUser), - ('FcpConnectionPort', 'UInt', fcp2.Client.DefaultFcpPort, config.SettingScopeUser), - ('FcpConnectionTimerTimeout', 'UInt', 500, config.SettingScopeExpert), - ('FcpConnectionTimerMaxDuration', 'UInt', 20, config.SettingScopeExpert), - ('FcpPollTimerTimeout', 'UInt', 200, config.SettingScopeExpert), + ('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', config.SettingScopeUser), - ('FproxyConnectionPort', 'UInt', 8888, config.SettingScopeUser), + ('FproxyConnectionHost', 'String','127.0.0.1'), + ('FproxyConnectionPort', 'UInt', 8888), ) def setValues(self, **kws): Modified: trunk/fclient/fclient/impl/ViewDownloads.py =================================================================== --- trunk/fclient/fclient/impl/ViewDownloads.py 2008-08-03 08:21:56 UTC (rev 870) +++ trunk/fclient/fclient/impl/ViewDownloads.py 2008-08-03 19:18:54 UTC (rev 871) @@ -25,13 +25,20 @@ # 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. ...whatevs - #************************************************************************************************************** +# 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? +#************************************************************************************************************** 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__)] @@ -134,7 +141,7 @@ self.action( name='ActionDownloadKeyToDisk', text=self.trUtf8('Download &key...'), - trigger=parent.onDownloadKey, + trigger=parent.onDlgDownloadKey, ) self.action( name='ActionRemoveSelectedDownloads', @@ -152,7 +159,7 @@ class DownloadsWidgetSettings(config.SettingsBase): - _key_ = config.IdViewCDownloadsWidget + _key_ = config.IdViewDownloadsWidget _settings_ = ( ) #********************************************************************************** @@ -209,8 +216,12 @@ def __init__(self, parent, idGlobalFeedback=config.IdMainWindow): QtGui.QWidget.__init__(self, parent) self._isCreated = False + self.fcHeaderLabels = {} # fcpIdentifier --> treeItem + self.fcpRequests = {} + self.fcRequestStatus = {} + + self.setupUi(self) - self.setupUi(self) config.ObjectRegistry.register(self) self.fcSettings = DownloadsWidgetSettings(self).restore() self.fcActions = DownloadsWidgetActions(self) @@ -226,8 +237,6 @@ (config.fcpClient.events.RequestRemoved, self.onFcpRequestRemoved), ) config.fcpClient.events += self.fcpEvents - self.fcHeadeLabels = {} # fcpIdentifier --> treeItem - self.fcpRequests = {} ############################ ## private methods @@ -275,7 +284,7 @@ def retranslateUi(self, parent): Ui_ViewDownloadsWidget.retranslateUi(self, parent) tree = self.controlById(self.IdTree) - self.fcHeadeLabels = { + self.fcHeaderLabels = { self.HeaderIndexName: self.trUtf8('Name'), self.HeaderIndexSize: self.trUtf8('Size'), self.HeaderIndexMimeType: self.trUtf8('MimeType'), @@ -283,7 +292,15 @@ self.HeaderIndexProgress: self.trUtf8('Progress'), self.HeaderIndexElapsed: self.trUtf8('Elapsed'), } - tree.setHeaderLabels([i[1] for i in sorted(self.fcHeadeLabels.items())]) + tree.setHeaderLabels([i[1] for i in sorted(self.fcHeaderLabels.items())]) + + self.fcRequestStatus = { + None: self.trUtf8('Pending'), + fcp2.ConstRequestStatus.Started: self.trUtf8('Loading'), + fcp2.ConstRequestStatus.Completed: self.trUtf8('Complete'), + fcp2.ConstRequestStatus.Error: self.trUtf8('Error'), + } + #TODO: retranslate all tree items def closeEvent(self): self.viewClose() @@ -328,17 +345,23 @@ **kws ) item = self._createItemFromFcpRequest(fcpRequest) + item.setData( + self.HeaderIndexStatus, + QtCore.Qt.DisplayRole, + QtCore.QVariant(self.fcRequestStatus[None]), + ) def populateMenu(self, menu): menu.addAction(self.fcActions['ActionDownloadKeyToDisk']) return menu - ######################################### - ## event handlers - ######################################### - def onDownloadKey(self, action): - dlg = DlgDownloadKeyToDisk.DlgDownloadKeyToDisk(self, fcpKey=None) + + 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(), @@ -346,7 +369,13 @@ persistence=fcp2.ConstPersistence.Forever, handleFilenameCollision=True, ) - + + ######################################### + ## event handlers + ######################################### + def onDlgDownloadKey(self, action): + self.execDlgDownloadKey(fcpKey=None) + def onRemoveSelectedDownloads(self, action): tree = self.controlById(self.IdTree) selectedItems = tree.selectedItems() @@ -415,16 +444,24 @@ QtCore.Qt.DisplayRole, QtCore.QVariant(fcpRequest['MetadataContentType']) ) + item.setData( + self.HeaderIndexStatus, + QtCore.Qt.DisplayRole, + QtCore.QVariant(self.fcRequestStatus[fcp2.ConstRequestStatus.Completed]), + ) self._adjustStatusBar(item, 'complete') def onFcpRequestFailed(self, fcpEvent, fcpRequest): item = self.fcpRequests.get(rfcpRequest['Identifier'], None) if item is not None: self._adjustStatusBar(item, 'error') + item.setData( + self.HeaderIndexStatus, + QtCore.Qt.DisplayRole, + QtCore.QVariant(self.fcRequestStatus[fcp2.ConstRequestStatus.Error]), + ) - pass - #TODO: not tested def onFcpRequestModified(self, fcpEvent, fcpRequest): @@ -476,7 +513,12 @@ else: if requestData.get('ClientName', None) == self.objectName(): item = self._createItemFromFcpRequest(fcpRequest) - + item.setData( + self.HeaderIndexStatus, + QtCore.Qt.DisplayRole, + QtCore.QVariant(self.fcRequestStatus[fcp2.ConstRequestStatus.Started]), + ) + #********************************************************************************** # #********************************************************************************** @@ -493,7 +535,6 @@ viewWidget = View.ViewWidget(mainWindow) mainWindow.setCentralWidget(viewWidget) - viewWidget.addTopViews( ViewConnection.ViewConnectionWidget(None), ViewDownloadsWidget(None), Modified: trunk/fclient/fclient/impl/ViewLogger.py =================================================================== --- trunk/fclient/fclient/impl/ViewLogger.py 2008-08-03 08:21:56 UTC (rev 870) +++ trunk/fclient/fclient/impl/ViewLogger.py 2008-08-03 19:18:54 UTC (rev 871) @@ -100,17 +100,17 @@ _key_ = config.IdViewLoggerWidget _settings_ = ( - ('MaxLines', 'UInt', 1000, config.SettingScopeUser), - ('Verbosity', 'PyString', 'Info', config.SettingScopePrivate), + ('MaxLines', 'UInt', 1000), + ('Verbosity', 'PyString', 'Info'), #TODO: Chatty does not seem to work. check in fcp2.client - ('ColorFgVerbosityCRITICAL', 'QColor', QtGui.QColor('red'), config.SettingScopeUser), - ('ColorFgVerbosityERROR', 'QColor', QtGui.QColor('red'), config.SettingScopeUser), - ('ColorFgVerbosityWARNING', 'QColor', QtGui.QColor('red'), config.SettingScopeUser), - ('ColorFgVerbosityINFO', 'QColor', QtGui.QColor('black'), config.SettingScopeUser), - ('ColorFgVerbosityMESSAGE', 'QColor', QtGui.QColor('blue'), config.SettingScopeUser), - ('ColorFgVerbosityDEBUG', 'QColor', QtGui.QColor('slategray'), config.SettingScopeUser), - ('ColorFgVerbosityCHATTY', 'QColor', QtGui.QColor('lightslategray'), config.SettingScopeUser), + ('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')), ) Modified: trunk/fclient/fclient/impl/config.py =================================================================== --- trunk/fclient/fclient/impl/config.py 2008-08-03 08:21:56 UTC (rev 870) +++ trunk/fclient/fclient/impl/config.py 2008-08-03 19:18:54 UTC (rev 871) @@ -41,7 +41,7 @@ IdViewWidget = 'ViewWidget' IdViewBrowserWidget = 'ViewBrowserWidget' IdViewConnectionWidget = 'ViewConnectionWidget' -IdViewCDownloadsWidget = 'ViewDownloadsWidget' +IdViewDownloadsWidget = 'ViewDownloadsWidget' IdViewLoggerWidget = 'ViewDownloadsWidget' IdViewLoggerWidget = 'ViewLoggerWidget' IdDlgPrefs = 'DlgPrefs' @@ -72,11 +72,6 @@ #********************************************************************************** # #********************************************************************************** -SettingScopeExpert = 0x1 -SettingScopePrivate = 0x2 -SettingScopeUser = 0x4 -SettingSkopeMask = SettingScopeExpert | SettingScopePrivate | SettingScopeUser - class SettingsBase(settings.SettingsBase): """application wide base class for settings""" @@ -103,17 +98,17 @@ class Settings(SettingsBase): _key_ = 'ConfigSettings' _settings_ = ( - ('DlgSingleAppErrorGeometry', 'ByteArray', QtCore.QByteArray(), SettingScopePrivate), + ('DlgSingleAppErrorGeometry', 'ByteArray', QtCore.QByteArray()), - ('Version', 'String', QtCore.QString(FcVersion), SettingScopePrivate), - ('SingleAppHost', 'String', QtCore.QString('localhost'), SettingScopeExpert), - ('SingleAppPort', 'UInt', 45663, SettingScopeExpert), + ('Version', 'String', QtCore.QString(FcVersion)), + ('SingleAppHost', 'String', QtCore.QString('localhost')), + ('SingleAppPort', 'UInt', 45663), - ('SettingsDir', 'String', QtCore.QString(FcSettingsDir), SettingScopeUser), # if not None, settings are stored locally in the app folder - ('SettingsAllUsers', 'Bool', False, SettingScopeUser), # store settings for all users? - ('IconTheme', 'String', QtCore.QString('crystal'), SettingScopeUser), #TODO: global icon theme? - ('IconSize', 'UInt', 32, SettingScopeUser), - ('DownloadDir', 'String', FcDownloadDir, SettingScopeUser), + ('SettingsDir', 'String', QtCore.QString(FcSettingsDir)), # if not None, settings are stored locally in the app folder + ('SettingsAllUsers', 'Bool', False), # store settings for all users? + ('IconTheme', 'String', QtCore.QString('crystal')), #TODO: global icon theme? + ('IconSize', 'UInt', 32), + ('DownloadDir', 'String', FcDownloadDir), ) SettingsBase._config_settings_ = Settings() Modified: trunk/fclient/fclient/impl/lib/fcp2/client.py =================================================================== --- trunk/fclient/fclient/impl/lib/fcp2/client.py 2008-08-03 08:21:56 UTC (rev 870) +++ trunk/fclient/fclient/impl/lib/fcp2/client.py 2008-08-03 19:18:54 UTC (rev 871) @@ -920,6 +920,7 @@ del initialRequest.params['Started'] initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Restored + initialRequest['RequestStatus'] |= consts.ConstRequestStatus.Started self.events.RequestStarted(initialRequest) return True Modified: trunk/fclient/fclient/impl/lib/fcp2/consts.py =================================================================== --- trunk/fclient/fclient/impl/lib/fcp2/consts.py 2008-08-03 08:21:56 UTC (rev 870) +++ trunk/fclient/fclient/impl/lib/fcp2/consts.py 2008-08-03 19:18:54 UTC (rev 871) @@ -450,12 +450,13 @@ of the bitflags it picked up while running through the client. """ Null = 0x0 - Restored = 0x1 - Compressing = 0x2 - Compressed = 0x4 - Success = 0x8 - Error = 0x10 - Removed = 0x20 + Started = 0x1 + Restored = 0x2 + Compressing = 0x4 + Compressed = 0x8 + Success = 0x10 + Error = 0x20 + Removed = 0x40 Completed =0x10000000 RemovedFromQueue = 0x2000000 Modified: trunk/fclient/fclient/impl/lib/fcp2/key.py =================================================================== --- trunk/fclient/fclient/impl/lib/fcp2/key.py 2008-08-03 08:21:56 UTC (rev 870) +++ trunk/fclient/fclient/impl/lib/fcp2/key.py 2008-08-03 19:18:54 UTC (rev 871) @@ -351,7 +351,6 @@ edition = int(edition) return clss(d['keyData'], docName=d['docName'], edition=edition, tail=d['tail'], pManifest=bool(d['pManifest'])) - #**************************************************************************************************** # #**************************************************************************************************** Modified: trunk/fclient/fclient/impl/lib/numbers.py =================================================================== --- trunk/fclient/fclient/impl/lib/numbers.py 2008-08-03 08:21:56 UTC (rev 870) +++ trunk/fclient/fclient/impl/lib/numbers.py 2008-08-03 19:18:54 UTC (rev 871) @@ -8,7 +8,7 @@ #*************************************************************** class ByteSizeNames: Binary = ('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB') - Common = ('', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb', 'Zb', 'Yb') + Common = ('B', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb', 'Zb', 'Yb') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |