fclient-commit Mailing List for fclient
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-09-16 11:56:49
|
Revision: 971 http://fclient.svn.sourceforge.net/fclient/?rev=971&view=rev Author: jUrner Date: 2008-09-16 11:57:00 +0000 (Tue, 16 Sep 2008) Log Message: ----------- workbench segfaults ..no idea Removed Paths: ------------- trunk/fclient/fclient/impl/lib/RequestsWidget/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-09-16 11:46:58
|
Revision: 970 http://fclient.svn.sourceforge.net/fclient/?rev=970&view=rev Author: jUrner Date: 2008-09-16 11:47:09 +0000 (Tue, 16 Sep 2008) Log Message: ----------- mmmh Added Paths: ----------- trunk/fclient/fclient/impl/lib/RequestsWidget/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-09-06 12:39:51
|
Revision: 968 http://fclient.svn.sourceforge.net/fclient/?rev=968&view=rev Author: jUrner Date: 2008-09-06 12:39:55 +0000 (Sat, 06 Sep 2008) Log Message: ----------- naming Modified Paths: -------------- trunk/fclient/fclient/impl/ViewConnection/Settings.py trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py Modified: trunk/fclient/fclient/impl/ViewConnection/Settings.py =================================================================== --- trunk/fclient/fclient/impl/ViewConnection/Settings.py 2008-09-06 08:53:16 UTC (rev 967) +++ trunk/fclient/fclient/impl/ViewConnection/Settings.py 2008-09-06 12:39:55 UTC (rev 968) @@ -41,7 +41,7 @@ edHost.setText(self.value('FcpConnectionHost')) if 'FcpConnectionPort' in kws: - spinPort = parent.controlById(parent.IdFcpSpinFcpConnectionPort) + spinPort = parent.controlById(parent.IdSpinFcpConnectionPort) spinPort.setValue(self.value('FcpConnectionPort')) if 'FcpAutoConnect' in kws: @@ -54,5 +54,5 @@ edHost.setText(self.value('FproxyConnectionHost')) if 'FproxyConnectionPort' in kws: - spinPort = parent.controlById(parent.IdFproxySpinConnectionPort) + spinPort = parent.controlById(parent.IdSpinFproxyConnectionPort) spinPort.setValue(self.value('FproxyConnectionPort')) Modified: trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py =================================================================== --- trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py 2008-09-06 08:53:16 UTC (rev 967) +++ trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py 2008-09-06 12:39:55 UTC (rev 968) @@ -77,11 +77,11 @@ IdBtConnect = 'btConnect' IdEdFcpConnectionHost = 'edFcpConnectionHost' - IdFcpSpinFcpConnectionPort = 'spinFcpConnectionPort' + IdSpinFcpConnectionPort = 'spinFcpConnectionPort' IdCkFcpAutoConnect = 'ckFcpAutoConnect' IdEdFproxyConnectionHost = 'edFproxyConnectionHost' - IdFproxySpinConnectionPort = 'spinFproxyConnectionPort' + IdSpinFproxyConnectionPort = 'spinFproxyConnectionPort' def __init__(self, parent, idGlobalFeedback=config.IdViewObjectMainWindow): @@ -90,9 +90,9 @@ self.setupUi(self) # adjust spin box ranges - spinPort = self.controlById(self.IdFcpSpinFcpConnectionPort) + spinPort = self.controlById(self.IdSpinFcpConnectionPort) spinPort.setRange(0, 0xFFFF) #TODO: no idea if port range (0, 0xFFFF) this is reasonable - spinPort = self.controlById(self.IdFproxySpinConnectionPort) + spinPort = self.controlById(self.IdSpinFproxyConnectionPort) spinPort.setRange(0, 0xFFFF) #TODO: no idea if port range (0, 0xFFFF) this is reasonable self._isCreated = False @@ -153,10 +153,10 @@ ck.setChecked(doAutoConnect) self.connect(ck, QtCore.SIGNAL('stateChanged(int)'), self.onCkFcpAutoConnectStateChanged) - spinPort = self.controlById(self.IdFcpSpinFcpConnectionPort) + spinPort = self.controlById(self.IdSpinFcpConnectionPort) self.connect(spinPort, QtCore.SIGNAL('valueChanged(int)'), self.onSpinFcpConnectionPortChanged) - spinPort = self.controlById(self.IdFproxySpinConnectionPort) + spinPort = self.controlById(self.IdSpinFproxyConnectionPort) self.connect(spinPort, QtCore.SIGNAL('valueChanged(int)'), self.onSpinFproxyConnectionPortChanged) # setup fproxy host / port This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-09-06 08:53:07
|
Revision: 967 http://fclient.svn.sourceforge.net/fclient/?rev=967&view=rev Author: jUrner Date: 2008-09-06 08:53:16 +0000 (Sat, 06 Sep 2008) Log Message: ----------- added functionality to view html source of a page Modified Paths: -------------- trunk/fclient/fclient/README Modified: trunk/fclient/fclient/README =================================================================== --- trunk/fclient/fclient/README 2008-09-06 08:52:13 UTC (rev 966) +++ trunk/fclient/fclient/README 2008-09-06 08:53:16 UTC (rev 967) @@ -15,7 +15,9 @@ x. downloads can now be removed groupwise x. browser now knows what bookmarks are + x. page/frame html source can now be viewed in browser x. connection label on statusBar can now be used to easily connect/disconnect to the node (via conext menu) + bugfixes: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-09-06 08:52:05
|
Revision: 966 http://fclient.svn.sourceforge.net/fclient/?rev=966&view=rev Author: jUrner Date: 2008-09-06 08:52:13 +0000 (Sat, 06 Sep 2008) Log Message: ----------- added functionality to view html source of a page Modified Paths: -------------- trunk/fclient/fclient/impl/ViewBrowser/Actions.py trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py Added Paths: ----------- trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgViewPageSource.py trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgViewPageSource.ui trunk/fclient/fclient/impl/ViewBrowser/dlgs/Ui_DlgViewPageSource.py Modified: trunk/fclient/fclient/impl/ViewBrowser/Actions.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/Actions.py 2008-09-06 08:51:02 UTC (rev 965) +++ trunk/fclient/fclient/impl/ViewBrowser/Actions.py 2008-09-06 08:52:13 UTC (rev 966) @@ -199,8 +199,24 @@ text=self.trUtf8('Bookmark page..'), isEnabled=True, trigger=parent.onBookmarkPage, - ) + ) + + # others + self.action( + name='ActionViewPageSource', + text=self.trUtf8('View page source..'), + isEnabled=True, + trigger=parent.onViewPageSource, + ) + + self.action( + name='ActionViewFrameSource', + text=self.trUtf8('View frame source..'), + isEnabled=True, + trigger=parent.onViewFrameSource, + ) + def intertwineBrowserActions(self, browser=None): """intertwines Browser actions with BrowserWidget actions @note: call everytime the current browser changes Modified: trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py 2008-09-06 08:51:02 UTC (rev 965) +++ trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py 2008-09-06 08:52:13 UTC (rev 966) @@ -79,6 +79,7 @@ from .dlgs import DlgPropsBrowserObject from .dlgs import DlgBookmarks from .dlgs import DlgBookmarkPage +from .dlgs import DlgViewPageSource from .Ui_BrowserWidget import Ui_ViewBrowserWidget #***************************************************************************************** @@ -183,10 +184,13 @@ ## private methods ######################################### def _adjustCurrentBrowserDependendStuff(self): - self.fcActions.intertwineBrowserActions(self.currentBrowser()) + browser = self.currentBrowser() + self.fcActions.intertwineBrowserActions(browser) if self.sideBarLoadDetails.isVisible(): - self.sideBarLoadDetails.setBrowser(self.currentBrowser()) + self.sideBarLoadDetails.setBrowser(browser) + self.fcActions['ActionViewPageSource'].setEnabled(browser is not None) + #NOTE: to reduce flicker set min size to max size def _adjustTabText(self, qString): maxTabText = self.fcSettings.value('MaxTabText') @@ -391,6 +395,7 @@ menu.addAction(self.fcActions['ActionFindPrevious']) menu.addAction(self.fcActions['ActionEditBookmarks']) menu.addAction(self.fcActions['ActionBookmarkPage']) + menu.addAction(self.fcActions['ActionViewPageSource']) menu.addMenu(self.menuBookmarks) menu.addMenu(self.menuSideBars) @@ -472,6 +477,7 @@ menu.addSeparator() menu.addAction(browser.pageAction(page.Copy)) menu.addAction(self.fcActions['ActionObjectProperties']) + menu.addAction(self.fcActions['ActionViewFrameSource']) #TODO: QwebView assumes we can download queries - we can't browser.pageAction(page.DownloadLinkToDisk).setEnabled(config.fcpClient.isConnected()) @@ -789,7 +795,24 @@ # update status info addressBar.setText(lastBrowserState.url.toString()) - + + def onViewFrameSource(self, action): + browser = self.currentBrowser() + if browser is not None: + dlg = DlgViewPageSource.DlgViewPageSource(self, html= browser.page().currentFrame().toHtml()) + dlg.show() + if dlg.result() == dlg.Accepted: + pass + + def onViewPageSource(self, action): + browser = self.currentBrowser() + if browser is not None: + dlg = DlgViewPageSource.DlgViewPageSource(self, html= browser.page().mainFrame().toHtml()) + dlg.show() + if dlg.result() == dlg.Accepted: + pass + + #TODO: enable/disable, but no view gives non feedback on max/min zoom def onZoomIn(self, action): browser = self.currentBrowser() Added: trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgViewPageSource.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgViewPageSource.py (rev 0) +++ trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgViewPageSource.py 2008-09-06 08:52:13 UTC (rev 966) @@ -0,0 +1,86 @@ + +#********************************************************************************* +#TODO: +# +# x. html syntax highlighter +# +#********************************************************************************* +# some fixes for relative imports +# see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below) +# see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a +# ...package containing relative imports +from __future__ import absolute_import +if __name__ == '__main__': + import os + __path__ = [os.path.dirname(__file__)] + from ._fix_mexec import fix_mexec + fix_mexec(__name__, __file__) + del fix_mexec + +import os +from PyQt4 import QtCore, QtGui + +from ... import config +from .Ui_DlgViewPageSource import Ui_DlgViewPageSource +#********************************************************************************** +# +#********************************************************************************** +class Settings(config.SettingsBase): + _key_ = 'DlgBrowserViewpageSource' + _settings_ = ( + ('Geometry', 'ByteArray', QtCore.QByteArray()), + ) + +#********************************************************************************** +# +#********************************************************************************** +class HtmlSyntaxHighlighter(QtGui.QSyntaxHighlighter): + + def __init__(self, parent=None): + QtGui.QSyntaxHighlighter.__init__(self, parent) + + + def highlightBlock(self, text): + pass + +#********************************************************************************** +# +#********************************************************************************** +class DlgViewPageSource(QtGui.QDialog, Ui_DlgViewPageSource): + + + IdEd = 'ed' + + def __init__(self, parent=None, html=None): + QtGui.QDialog.__init__(self, parent) + + self.setupUi(self) + + self.fcSettings = Settings(self).restore() + self.restoreGeometry(self.fcSettings.value('Geometry')) + + + ed = self.controlById(self.IdEd) + if html is not None: + ed.setPlainText(html) + self.hilighter = HtmlSyntaxHighlighter(ed.document()) + + def controlById(self, idControl): + return getattr(self, idControl) + + def hideEvent(self, event): + self.fcSettings.setValues(Geometry=self.saveGeometry()) + +#********************************************************************************** +# +#********************************************************************************** +if __name__ == '__main__': + import sys + + app = QtGui.QApplication(sys.argv) + w = DlgViewPageSource(None, html='''<a href="foo">bar</a> + ''' + ) + w.show() + res = app.exec_() + sys.exit(res) Added: trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgViewPageSource.ui =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgViewPageSource.ui (rev 0) +++ trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgViewPageSource.ui 2008-09-06 08:52:13 UTC (rev 966) @@ -0,0 +1,73 @@ +<ui version="4.0" > + <class>DlgViewPageSource</class> + <widget class="QDialog" name="DlgViewPageSource" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>461</width> + <height>594</height> + </rect> + </property> + <property name="windowTitle" > + <string>View page source..</string> + </property> + <layout class="QGridLayout" name="gridLayout" > + <item row="0" column="0" > + <widget class="QPlainTextEdit" name="ed" > + <property name="readOnly" > + <bool>true</bool> + </property> + <property name="textInteractionFlags" > + <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> + </property> + </widget> + </item> + <item row="1" column="0" > + <widget class="QDialogButtonBox" name="buttonBox" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons" > + <set>QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>DlgViewPageSource</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel" > + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel" > + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>DlgViewPageSource</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel" > + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel" > + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> Added: trunk/fclient/fclient/impl/ViewBrowser/dlgs/Ui_DlgViewPageSource.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/dlgs/Ui_DlgViewPageSource.py (rev 0) +++ trunk/fclient/fclient/impl/ViewBrowser/dlgs/Ui_DlgViewPageSource.py 2008-09-06 08:52:13 UTC (rev 966) @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file '/home/me/src/fclient/trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgViewPageSource.ui' +# +# Created: Sat Sep 6 10:42:58 2008 +# by: PyQt4 UI code generator 4.4.2 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +class Ui_DlgViewPageSource(object): + def setupUi(self, DlgViewPageSource): + DlgViewPageSource.setObjectName("DlgViewPageSource") + DlgViewPageSource.resize(461,594) + self.gridLayout = QtGui.QGridLayout(DlgViewPageSource) + self.gridLayout.setObjectName("gridLayout") + self.ed = QtGui.QPlainTextEdit(DlgViewPageSource) + self.ed.setReadOnly(True) + self.ed.setTextInteractionFlags(QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse) + self.ed.setObjectName("ed") + self.gridLayout.addWidget(self.ed,0,0,1,1) + self.buttonBox = QtGui.QDialogButtonBox(DlgViewPageSource) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok) + self.buttonBox.setObjectName("buttonBox") + self.gridLayout.addWidget(self.buttonBox,1,0,1,1) + + self.retranslateUi(DlgViewPageSource) + QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("accepted()"),DlgViewPageSource.accept) + QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("rejected()"),DlgViewPageSource.reject) + QtCore.QMetaObject.connectSlotsByName(DlgViewPageSource) + + def retranslateUi(self, DlgViewPageSource): + DlgViewPageSource.setWindowTitle(QtGui.QApplication.translate("DlgViewPageSource", "View page source..", None, QtGui.QApplication.UnicodeUTF8)) + + +if __name__ == "__main__": + import sys + app = QtGui.QApplication(sys.argv) + DlgViewPageSource = QtGui.QDialog() + ui = Ui_DlgViewPageSource() + ui.setupUi(DlgViewPageSource) + DlgViewPageSource.show() + sys.exit(app.exec_()) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-09-06 08:50:59
|
Revision: 965 http://fclient.svn.sourceforge.net/fclient/?rev=965&view=rev Author: jUrner Date: 2008-09-06 08:51:02 +0000 (Sat, 06 Sep 2008) Log Message: ----------- whitespace Modified Paths: -------------- trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgBookmarks.py Modified: trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgBookmarks.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgBookmarks.py 2008-08-26 16:31:11 UTC (rev 964) +++ trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgBookmarks.py 2008-09-06 08:51:02 UTC (rev 965) @@ -78,4 +78,4 @@ w = DlgBookmarks(None) w.show() res = app.exec_() - sys.exit(res) \ No newline at end of file + sys.exit(res) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-26 16:31:03
|
Revision: 964 http://fclient.svn.sourceforge.net/fclient/?rev=964&view=rev Author: jUrner Date: 2008-08-26 16:31:11 +0000 (Tue, 26 Aug 2008) Log Message: ----------- fix for msg.data Modified Paths: -------------- trunk/fclient/fclient/impl/lib/fcp2/iohandler.py Modified: trunk/fclient/fclient/impl/lib/fcp2/iohandler.py =================================================================== --- trunk/fclient/fclient/impl/lib/fcp2/iohandler.py 2008-08-25 00:20:54 UTC (rev 963) +++ trunk/fclient/fclient/impl/lib/fcp2/iohandler.py 2008-08-26 16:31:11 UTC (rev 964) @@ -291,6 +291,8 @@ raise self.ErrorMessageParse('No message name present') msgName = p.pop(0) msgClass = message.MessagesAll.get(msgName, None) + + #TODO: can not pass unicode to type.__new__. maybe skip this part and log an error if msgClass is None: consts.ConstLogger.IOHandler.debug(consts.ConstLogMessages.CreatingNewMessageType + ' "%s"' % msgName) msgClass = message.newMessageClass(msgName) @@ -318,15 +320,15 @@ raise consts.ErrorMessageParse('DataLength must be type(int)') if n > 0: - while self._receiveBuffer: + while True: if len(self._receiveBuffer) >= n: msg.data, self._receiveBuffer = self._receiveBuffer[ :n], self._receiveBuffer[n: ] break try: self.readBytes(self.io.BufferSize) - except ErrorIOTimeout, details: # try again later + except consts.ErrorIOTimeout, details: # try again later self._receiveBuffer = chunk + self._receiveBuffer - raise ErrorIOTimeout(details) + raise consts.ErrorIOTimeout(details) consts.ConstLogger.IOHandler.log(consts.ConstDebugVerbosity.Message, consts.ConstLogMessages.Received + msg.pprint()) return msg This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-25 00:20:44
|
Revision: 963 http://fclient.svn.sourceforge.net/fclient/?rev=963&view=rev Author: jUrner Date: 2008-08-25 00:20:54 +0000 (Mon, 25 Aug 2008) Log Message: ----------- fix. dl key was broken Modified Paths: -------------- trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py Modified: trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py 2008-08-22 13:20:59 UTC (rev 962) +++ trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py 2008-08-25 00:20:54 UTC (rev 963) @@ -259,10 +259,10 @@ self.trUtf8('Can not download key (key is invalid)') ) return False - downloadsWidget = config.ObjectRegistry.get(config.IdViewDownloadsWidget, None) - if downloadsWidget is None: + voDownloads = config.ObjectRegistry.get(config.IdViewObjectDownloads, None) + if voDownloads is None: raise ValueError('no downloads widget found') - downloadsWidget.execDlgDownloadKey(fcpKey=fcpKey) + voDownloads.widget().execDlgDownloadKey(fcpKey=fcpKey) return True ######################################### @@ -542,7 +542,6 @@ browser = self.sender() qUrl = QtCore.QUrl(qUrl) query = unicode(qUrl.encodedQuery()) - if query.lower() == 'forcedownload': if not self._downloadKeyToDisk(qUrl): self.fcGlobalFeedback.setFeedback(self.trUtf8('Invalid key!')) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-22 13:20:50
|
Revision: 962 http://fclient.svn.sourceforge.net/fclient/?rev=962&view=rev Author: jUrner Date: 2008-08-22 13:20:59 +0000 (Fri, 22 Aug 2008) Log Message: ----------- fix. requests could get added multiple times ++ clear dls on fcpClient disconnect Modified Paths: -------------- trunk/fclient/fclient/README trunk/fclient/fclient/impl/BaseRequestsWidget/BaseRequestsWidget.py Modified: trunk/fclient/fclient/README =================================================================== --- trunk/fclient/fclient/README 2008-08-22 13:04:37 UTC (rev 961) +++ trunk/fclient/fclient/README 2008-08-22 13:20:59 UTC (rev 962) @@ -19,7 +19,9 @@ bugfixes: - x. many + x. downloadsWidget did not notice dls already present and could add the same dl multiple times. fixed + + x. many more ******************************************************************* Modified: trunk/fclient/fclient/impl/BaseRequestsWidget/BaseRequestsWidget.py =================================================================== --- trunk/fclient/fclient/impl/BaseRequestsWidget/BaseRequestsWidget.py 2008-08-22 13:04:37 UTC (rev 961) +++ trunk/fclient/fclient/impl/BaseRequestsWidget/BaseRequestsWidget.py 2008-08-22 13:20:59 UTC (rev 962) @@ -38,6 +38,7 @@ # to realize that this is a serious problem... # x. byte amount postfixes must be transllated ++ use Kib or Kb or let the user decide? # x. sometimes groups of dls get not removed +# x. tree is cleared on fcpClient disconnect. maybe a bit harsh. have to think about a better way to handle this #************************************************************************************************************** # some fixes for relative imports # see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below) @@ -332,6 +333,9 @@ @note: if you add a newly created request, make shure to set the requests PersistentUserData to the result of the call to L{persistentFcpRequestData} """ + if fcpRequest['Identifier'] in self.fcpRequests: + raise ValueError('Request already present') + tree = self.controlById(self.IdTree) root = tree.invisibleRootItem() item= TreeItem(fcpRequest, root) @@ -473,12 +477,14 @@ def onFcpClientConnected(self, event, msg): for action in self.fcActions: action.setEnabled(True) - - + def onFcpClientDisconnected(self, event, msg): + tree = self.controlById(self.IdTree) + tree.clear() + self.fcpRequests = {} for action in self.fcActions: action.setEnabled(False) - + def onFcpConfigData(self, fcpEvent, fcpRequest): pass @@ -552,6 +558,8 @@ def onFcpClientRequestStarted(self, fcpEvent, fcpRequest): if fcpRequest['RequestStatus'] & fcp2.ConstRequestStatus.Restored: + if fcpRequest['Identifier'] in self.fcpRequests: + return try: requestData = PersistentRequestData.load(fcpRequest['PersistentUserData']) except pmstruct.PMStructError: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-22 13:04:27
|
Revision: 961 http://fclient.svn.sourceforge.net/fclient/?rev=961&view=rev Author: jUrner Date: 2008-08-22 13:04:37 +0000 (Fri, 22 Aug 2008) Log Message: ----------- update Modified Paths: -------------- trunk/fclient/fclient/README Modified: trunk/fclient/fclient/README =================================================================== --- trunk/fclient/fclient/README 2008-08-22 13:03:28 UTC (rev 960) +++ trunk/fclient/fclient/README 2008-08-22 13:04:37 UTC (rev 961) @@ -15,6 +15,7 @@ x. downloads can now be removed groupwise x. browser now knows what bookmarks are + x. connection label on statusBar can now be used to easily connect/disconnect to the node (via conext menu) bugfixes: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-22 13:03:21
|
Revision: 960 http://fclient.svn.sourceforge.net/fclient/?rev=960&view=rev Author: jUrner Date: 2008-08-22 13:03:28 +0000 (Fri, 22 Aug 2008) Log Message: ----------- add a context menu to connection label on statusbar to easily connect/disconnect to the node Modified Paths: -------------- trunk/fclient/fclient/impl/MainWindow/StatusBar.py trunk/fclient/fclient/impl/ViewConnection/Actions.py trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py Modified: trunk/fclient/fclient/impl/MainWindow/StatusBar.py =================================================================== --- trunk/fclient/fclient/impl/MainWindow/StatusBar.py 2008-08-22 13:01:31 UTC (rev 959) +++ trunk/fclient/fclient/impl/MainWindow/StatusBar.py 2008-08-22 13:03:28 UTC (rev 960) @@ -1,4 +1,9 @@ - +#*************************************************************************************************** +#TODO +# +# x. maybe move connection labels to ViewConnection +# +#*************************************************************************************************** # some fixes for relative imports # see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below) # see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a @@ -63,6 +68,9 @@ for objectName, label in self.connectionLabels.items(): label.setObjectName(objectName) label.setVisible(False) + label.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.connect(label, QtCore.SIGNAL('customContextMenuRequested( const QPoint &)'), self.onConnectionLabelConextMenuRequested) + self.addWidget(label, 0) if config.fcpClient.isConnected(): self.connectionLabels['LabelConnectionConnected'].show() @@ -77,6 +85,18 @@ self.connectionLabels['LabelConnectionDisonnectedOn'].setText(self.trUtf8('DISCONNECTED')) self.connectionLabels['LabelConnectionDisonnectedOff'].setText(self.trUtf8('DISCONNECTED')) + + def onConnectionLabelConextMenuRequested(self, pt): + label = self.sender() + pt = label.mapToGlobal(pt) + voConnection = config.ObjectRegistry.get(config.IdViewObjectConnection, None) + if voConnection is not None: + actions = voConnection.widget().fcActions + menu = QtGui.QMenu(self) + menu.addAction(actions['ActionConnect']) + menu.addAction(actions['ActionDisconnect']) + menu.exec_(pt) + def onFcpClientConnected(self, event, msg): self._disconnectTimer.stop() for label in self.connectionLabels.values(): @@ -88,3 +108,5 @@ label.hide() self.connectionLabels['LabelConnectionDisonnectedOn'].show() self._disconnectTimer.start(self.parent().fcSettings.value('ConnectionLabelFlashRate')) + + Modified: trunk/fclient/fclient/impl/ViewConnection/Actions.py =================================================================== --- trunk/fclient/fclient/impl/ViewConnection/Actions.py 2008-08-22 13:01:31 UTC (rev 959) +++ trunk/fclient/fclient/impl/ViewConnection/Actions.py 2008-08-22 13:03:28 UTC (rev 960) @@ -17,4 +17,35 @@ # #********************************************************************************** class Actions(config.ActionsBase): - pass + + def __init__(self, parent): + config.ActionsBase.__init__(self, parent) + + group = self.group( + name='GroupConnection', + isExclusive=True, + trigger=parent.onGroupConnection, + ) + self.action( + name='ActionConnect', + group=group, + isEnabled=True, + isCheckable=True, + isChecked=False, + ) + self.action( + name='ActionDisconnect', + group=group, + isEnabled=True, + isCheckable=True, + isChecked=True, + ) + + + def retranslateUi(self, parent): + self['ActionConnect'].setText(self.trUtf8('Connect')) + self['ActionDisconnect'].setText(self.trUtf8('Disconnect')) + + + + Modified: trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py =================================================================== --- trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py 2008-08-22 13:01:31 UTC (rev 959) +++ trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py 2008-08-22 13:03:28 UTC (rev 960) @@ -86,6 +86,7 @@ def __init__(self, parent, idGlobalFeedback=config.IdViewObjectMainWindow): QtGui.QWidget.__init__(self, parent) + self.fcActions = Actions.Actions(self) self.setupUi(self) # adjust spin box ranges @@ -96,7 +97,6 @@ self._isCreated = False self.fcSettings = Settings.Settings(self).restore() - self.fcActions = Actions.Actions(self) self.fcGlobalFeedback = GlobalFeedback.GlobalFeedback(self,idGlobalFeedback) self._connectionTimer = ConnectionTimer(self) @@ -175,10 +175,11 @@ Ui_ViewConnectionWidget.retranslateUi(self, w) bt = self.controlById(self.IdBtConnect) bt.setText(self.trUtf8('Disconnect') if self.connected() else self.trUtf8('Connect')) + self.fcActions.retranslateUi(self) ######################################### - ## event onrs + ## event handlers ######################################### def onBtConnectClicked(self, isChecked): bt = self.controlById(self.IdBtConnect) @@ -192,8 +193,10 @@ if config.fcpClient.isConnected(): self._pollTimer.stop() config.fcpClient.close() - + def onGroupConnection(self, action): + self.setConnected(action == self.fcActions['ActionConnect']) + def onCkFcpAutoConnectStateChanged(self, state): self.fcSettings.setValues(FcpAutoConnect=state == QtCore.Qt.Checked) @@ -216,9 +219,12 @@ bt = self.controlById(self.IdBtConnect) if bt.isChecked(): bt.click() + self.fcActions['ActionDisconnect'].setChecked(True) + def onFcpClientConected(self, event, msg): self._pollTimer.start(self.fcSettings) + self.fcActions['ActionConnect'].setChecked(True) #********************************************************************************** # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-22 13:01:21
|
Revision: 959 http://fclient.svn.sourceforge.net/fclient/?rev=959&view=rev Author: jUrner Date: 2008-08-22 13:01:31 +0000 (Fri, 22 Aug 2008) Log Message: ----------- allow for text being None 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-22 13:01:07 UTC (rev 958) +++ trunk/fclient/fclient/impl/lib/qt4ex/lib/actions.py 2008-08-22 13:01:31 UTC (rev 959) @@ -8,7 +8,10 @@ class Action(QtGui.QAction): def __init__(self, text, parent, userData=None): - QtGui.QAction.__init__(self, text, parent) + if text is None: + QtGui.QAction.__init__(self, parent) + else: + QtGui.QAction.__init__(self, text, parent) self._userData = userData def userData(self): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-22 13:00:57
|
Revision: 958 http://fclient.svn.sourceforge.net/fclient/?rev=958&view=rev Author: jUrner Date: 2008-08-22 13:01:07 +0000 (Fri, 22 Aug 2008) Log Message: ----------- add mssing GlobalFeedback base method Modified Paths: -------------- trunk/fclient/fclient/impl/config.py Modified: trunk/fclient/fclient/impl/config.py =================================================================== --- trunk/fclient/fclient/impl/config.py 2008-08-22 13:00:19 UTC (rev 957) +++ trunk/fclient/fclient/impl/config.py 2008-08-22 13:01:07 UTC (rev 958) @@ -165,6 +165,9 @@ mthd = getattr(feedbackWidget, 'titleBar', None) if mthd is not None: self.titleBar = mthd() + + def setVisible(self, flag): + pass #******************************************************************************** # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-22 13:00:10
|
Revision: 957 http://fclient.svn.sourceforge.net/fclient/?rev=957&view=rev Author: jUrner Date: 2008-08-22 13:00:19 +0000 (Fri, 22 Aug 2008) Log Message: ----------- remove left over print statement Modified Paths: -------------- trunk/fclient/fclient/impl/BaseRequestsWidget/BaseRequestsWidget.py Modified: trunk/fclient/fclient/impl/BaseRequestsWidget/BaseRequestsWidget.py =================================================================== --- trunk/fclient/fclient/impl/BaseRequestsWidget/BaseRequestsWidget.py 2008-08-22 12:59:51 UTC (rev 956) +++ trunk/fclient/fclient/impl/BaseRequestsWidget/BaseRequestsWidget.py 2008-08-22 13:00:19 UTC (rev 957) @@ -557,7 +557,6 @@ except pmstruct.PMStructError: pass else: - print requestData.get('ClientName', None), self.objectName() if requestData.get('ClientName', None) == self.objectName(): item = self.addFcpRequest(fcpRequest) else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-22 12:59:43
|
Revision: 956 http://fclient.svn.sourceforge.net/fclient/?rev=956&view=rev Author: jUrner Date: 2008-08-22 12:59:51 +0000 (Fri, 22 Aug 2008) Log Message: ----------- ups, forgot to check in prefs of mainWindow Added Paths: ----------- trunk/fclient/fclient/impl/MainWindow/prefs/ trunk/fclient/fclient/impl/MainWindow/prefs/PrefsGlobal.py trunk/fclient/fclient/impl/MainWindow/prefs/PrefsGlobal.ui trunk/fclient/fclient/impl/MainWindow/prefs/PrefsSingleApp.py trunk/fclient/fclient/impl/MainWindow/prefs/PrefsSingleApp.ui trunk/fclient/fclient/impl/MainWindow/prefs/Ui_PrefsGlobal.py trunk/fclient/fclient/impl/MainWindow/prefs/Ui_PrefsSingleApp.py trunk/fclient/fclient/impl/MainWindow/prefs/__init__.py trunk/fclient/fclient/impl/MainWindow/prefs/_fix_mexec.py Added: trunk/fclient/fclient/impl/MainWindow/prefs/PrefsGlobal.py =================================================================== --- trunk/fclient/fclient/impl/MainWindow/prefs/PrefsGlobal.py (rev 0) +++ trunk/fclient/fclient/impl/MainWindow/prefs/PrefsGlobal.py 2008-08-22 12:59:51 UTC (rev 956) @@ -0,0 +1,145 @@ +# some fixes for relative imports +# see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below) +# see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a +# ...package containing relative imports +from __future__ import absolute_import +if __name__ == '__main__': + import os + __path__ = [os.path.dirname(__file__)] + from ._fix_mexec import fix_mexec + fix_mexec(__name__, __file__) + del fix_mexec + + +from PyQt4 import QtCore, QtGui + +from ... import config +from ...lib.qt4ex import dlgpreferences +from ...lib.qt4ex.lib import settings + +from .Ui_PrefsGlobal import Ui_PrefsGlobalWidget +#********************************************************************************** +# +#********************************************************************************** +class PrefsGlobalWidget(QtGui.QWidget, Ui_PrefsGlobalWidget): + + IdEdSettingsDir = 'edSettingsDir' + IdBtSelectSettingsDir = 'btSelectSettingsDir' + + IdCkSettingsAllUsers = 'ckSettingsAllUsers' + + IdEdDownloadDir = 'edDownloadDir' + IdBtSelectDownloadDir = 'btSelectDownloadDir' + + + def __init__(self, parent=None, page=None): + QtGui.QWidget.__init__(self, parent) + + self.setupUi(self) + + self.fcSettingsControler = settings.SettingsControler(config.fcSettings, parent=self) + if page is not None: + page.connect(self.fcSettingsControler, QtCore.SIGNAL('isDirty(bool)'), page.setDirty) + + self.fcSettingsControler.addLineEdit( + self.controlById(self.IdEdSettingsDir), + 'SettingsDir', + ) + self.fcSettingsControler.addCheckBox( + self.controlById(self.IdCkSettingsAllUsers), + 'SettingsAllUsers', + ) + self.fcSettingsControler.addLineEdit( + self.controlById(self.IdEdDownloadDir), + 'DownloadDir', + ) + + bt = self.controlById(self.IdBtSelectSettingsDir) + self.connect(bt, QtCore.SIGNAL('clicked()'), self.onBtSelectSettingsDirClicked) + bt = self.controlById(self.IdBtSelectDownloadDir) + self.connect(bt, QtCore.SIGNAL('clicked()'), self.onBtSelectDownloadDirClicked) + + + def controlById(self, idControl): + return getattr(self, idControl) + + def doApply(self): + if self.fcSettingsControler is not None: + return self.fcSettingsControler.apply() + return False + + def doRestoreDefaults(self): + if self.fcSettingsControler is not None: + return self.fcSettingsControler.restoreDefaults() + return False + + ##################### + ## event handlers + ##################### + def onBtSelectSettingsDirClicked(self): + ed = self.controlById(self.IdEdSettingsDir) + directory = QtGui.QFileDialog.getExistingDirectory( + self, + config.FcAppName + self.trUtf8(' - Select settings directory..'), + ed.text(), + ) + if directory: + ed.setText(directory) + + def onBtSelectDownloadDirClicked(self): + ed = self.controlById(self.IdEdDownloadDir) + directory = QtGui.QFileDialog.getExistingDirectory( + self, + config.FcAppName + self.trUtf8(' - Select download directory..'), + ed.text(), + ) + if directory: + ed.setText(directory) + +#*********************************************************************** +# +#*********************************************************************** +class PrefsPageGlobal(dlgpreferences.Page): + + UUID = '{ba654bd8-4c63-11dd-b8b1-a11c9b5c3981}' + + def __init__(self): + dlgpreferences.Page.__init__(self, self.UUID) + self._widget = None + + def displayName(self): + return self.trUtf8('Global') + + def canApply(self): return True + def canHelp(self): return False + def canRestoreDefaults(self): return True + + def doApply(self): + self._widget.doApply() + return True + + def doRestoreDefaults(self): + self._widget.doRestoreDefaults() + return True + + def setVisible(self, parent, flag): + createdNew = False + if flag and self._widget is None: + createdNew = True + self._widget = PrefsGlobalWidget(parent=parent, page=self) + self._widget.setVisible(flag) + return (createdNew, self._widget) + +#*********************************************************************** +# +#*********************************************************************** +if __name__ == '__main__': + from PyQt4 import QtGui + import sys + + app = QtGui.QApplication(sys.argv) + w = PrefsGlobalWidget(None) + w.show() + res = app.exec_() + sys.exit(res) + Added: trunk/fclient/fclient/impl/MainWindow/prefs/PrefsGlobal.ui =================================================================== --- trunk/fclient/fclient/impl/MainWindow/prefs/PrefsGlobal.ui (rev 0) +++ trunk/fclient/fclient/impl/MainWindow/prefs/PrefsGlobal.ui 2008-08-22 12:59:51 UTC (rev 956) @@ -0,0 +1,114 @@ +<ui version="4.0" > + <class>PrefsGlobalWidget</class> + <widget class="QWidget" name="PrefsGlobalWidget" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>465</width> + <height>316</height> + </rect> + </property> + <property name="windowTitle" > + <string>Form</string> + </property> + <layout class="QGridLayout" name="gridLayout" > + <item row="0" column="0" > + <widget class="QLabel" name="fieldHeader" > + <property name="text" > + <string>Settings directory:</string> + </property> + </widget> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="label" > + <property name="text" > + <string>Directory to store settings to.Leave empty to store settings in a location your os feels best with</string> + </property> + <property name="wordWrap" > + <bool>true</bool> + </property> + <property name="textInteractionFlags" > + <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard</set> + </property> + </widget> + </item> + <item row="2" column="0" > + <layout class="QHBoxLayout" > + <item> + <widget class="QLineEdit" name="edSettingsDir" /> + </item> + <item> + <widget class="QPushButton" name="btSelectSettingsDir" > + <property name="text" > + <string>...</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="3" column="0" > + <widget class="QLabel" name="label_2" > + <property name="text" > + <string>If no path for settings is specified, store settings only for the the current user or for all users?</string> + </property> + <property name="wordWrap" > + <bool>true</bool> + </property> + <property name="textInteractionFlags" > + <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> + </property> + </widget> + </item> + <item row="4" column="0" > + <widget class="QCheckBox" name="ckSettingsAllUsers" > + <property name="text" > + <string>Store settings for all users</string> + </property> + </widget> + </item> + <item row="5" column="0" > + <widget class="QLabel" name="fieldHeader_2" > + <property name="text" > + <string>Default download directory:</string> + </property> + <property name="wordWrap" > + <bool>true</bool> + </property> + <property name="textInteractionFlags" > + <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> + </property> + </widget> + </item> + <item row="6" column="0" > + <layout class="QHBoxLayout" name="horizontalLayout" > + <item> + <widget class="QLineEdit" name="edDownloadDir" /> + </item> + <item> + <widget class="QPushButton" name="btSelectDownloadDir" > + <property name="text" > + <string>...</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="7" column="0" > + <spacer name="verticalSpacer" > + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>20</width> + <height>38</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> Added: trunk/fclient/fclient/impl/MainWindow/prefs/PrefsSingleApp.py =================================================================== --- trunk/fclient/fclient/impl/MainWindow/prefs/PrefsSingleApp.py (rev 0) +++ trunk/fclient/fclient/impl/MainWindow/prefs/PrefsSingleApp.py 2008-08-22 12:59:51 UTC (rev 956) @@ -0,0 +1,110 @@ +# some fixes for relative imports +# see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below) +# see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a +# ...package containing relative imports +from __future__ import absolute_import +if __name__ == '__main__': + import os + __path__ = [os.path.dirname(__file__)] + from ._fix_mexec import fix_mexec + fix_mexec(__name__, __file__) + del fix_mexec + + +from PyQt4 import QtCore, QtGui + +from ... import config +from ...lib.qt4ex import dlgpreferences +from ...lib.qt4ex.lib import settings + +from .Ui_PrefsSingleApp import Ui_PrefsSingleApp +#********************************************************************************** +# +#********************************************************************************** +class PrefsSingleApp(QtGui.QWidget, Ui_PrefsSingleApp): + + IdEdHost = 'edHost' + IdSpinPort = 'spinPort' + + def __init__(self, parent=None, page=None): + QtGui.QWidget.__init__(self, parent) + + self.setupUi(self) + + self.fcSettingsControler = settings.SettingsControler(config.fcSettings, parent=self) + if page is not None: + page.connect(self.fcSettingsControler, QtCore.SIGNAL('isDirty(bool)'), page.setDirty) + + self.fcSettingsControler.addLineEdit( + self.controlById(self.IdEdHost), + 'SingleAppHost', + ) + + spinPort = self.controlById(self.IdSpinPort) + spinPort.setRange(0, 0xFFFF) #TODO: no idea if port range (0, 0xFFFF) this is reasonable + self.fcSettingsControler.addSpinBox( + spinPort, + 'SingleAppPort', + ) + + + def controlById(self, idControl): + return getattr(self, idControl) + + def doApply(self): + if self.fcSettingsControler is not None: + return self.fcSettingsControler.apply() + return False + + def doRestoreDefaults(self): + if self.fcSettingsControler is not None: + return self.fcSettingsControler.restoreDefaults() + return False + +#*********************************************************************** +# +#*********************************************************************** +class PrefsPageSingleApp(dlgpreferences.Page): + + UUID = '{9b76279c-46da-4fbe-9c02-a62fc843d6fc}' + + def __init__(self): + dlgpreferences.Page.__init__(self, self.UUID) + self._widget = None + + def displayName(self): + return self.trUtf8('Single application') + + def canApply(self): return True + def canHelp(self): return False + def canRestoreDefaults(self): return True + + def doApply(self): + self._widget.doApply() + return True + + def doRestoreDefaults(self): + self._widget.doRestoreDefaults() + return True + + def setVisible(self, parent, flag): + createdNew = False + if flag and self._widget is None: + createdNew = True + self._widget = PrefsSingleApp(parent=parent, page=self) + self._widget.setVisible(flag) + return (createdNew, self._widget) + +#*********************************************************************** +# +#*********************************************************************** +if __name__ == '__main__': + from PyQt4 import QtGui + import sys + + app = QtGui.QApplication(sys.argv) + w = PrefsSingleApp(None) + w.show() + res = app.exec_() + sys.exit(res) + Added: trunk/fclient/fclient/impl/MainWindow/prefs/PrefsSingleApp.ui =================================================================== --- trunk/fclient/fclient/impl/MainWindow/prefs/PrefsSingleApp.ui (rev 0) +++ trunk/fclient/fclient/impl/MainWindow/prefs/PrefsSingleApp.ui 2008-08-22 12:59:51 UTC (rev 956) @@ -0,0 +1,101 @@ +<ui version="4.0" > + <class>PrefsSingleApp</class> + <widget class="QWidget" name="PrefsSingleApp" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>533</width> + <height>399</height> + </rect> + </property> + <property name="windowTitle" > + <string>Form</string> + </property> + <layout class="QGridLayout" name="gridLayout" > + <item row="0" column="0" > + <widget class="QLabel" name="fieldHeader_3" > + <property name="text" > + <string>Single application:</string> + </property> + </widget> + </item> + <item row="1" column="0" colspan="2" > + <widget class="QLabel" name="label" > + <property name="text" > + <string>The gui uses a socket connection to enshure only one instance is running at a time. Use the boxes below to adjust host and port of the connection to your needs.</string> + </property> + <property name="alignment" > + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <property name="wordWrap" > + <bool>true</bool> + </property> + <property name="textInteractionFlags" > + <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> + </property> + </widget> + </item> + <item row="2" column="0" > + <layout class="QHBoxLayout" name="horizontalLayout" > + <item> + <layout class="QVBoxLayout" name="verticalLayout" > + <item> + <widget class="QLabel" name="fieldName" > + <property name="text" > + <string>Host: </string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="fieldName_2" > + <property name="text" > + <string>Port: </string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_2" > + <item> + <widget class="QLineEdit" name="edHost" /> + </item> + <item> + <widget class="QSpinBox" name="spinPort" /> + </item> + </layout> + </item> + </layout> + </item> + <item row="2" column="1" > + <spacer name="horizontalSpacer" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>251</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="3" column="0" > + <spacer name="verticalSpacer" > + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>20</width> + <height>218</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> Added: trunk/fclient/fclient/impl/MainWindow/prefs/Ui_PrefsGlobal.py =================================================================== --- trunk/fclient/fclient/impl/MainWindow/prefs/Ui_PrefsGlobal.py (rev 0) +++ trunk/fclient/fclient/impl/MainWindow/prefs/Ui_PrefsGlobal.py 2008-08-22 12:59:51 UTC (rev 956) @@ -0,0 +1,82 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file '/home/me/src/fclient/trunk/fclient/fclient/impl/MainWindow/prefs/PrefsGlobal.ui' +# +# Created: Sun Aug 17 14:17:01 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_PrefsGlobalWidget(object): + def setupUi(self, PrefsGlobalWidget): + PrefsGlobalWidget.setObjectName("PrefsGlobalWidget") + PrefsGlobalWidget.resize(465, 316) + self.gridLayout = QtGui.QGridLayout(PrefsGlobalWidget) + self.gridLayout.setObjectName("gridLayout") + self.fieldHeader = QtGui.QLabel(PrefsGlobalWidget) + self.fieldHeader.setObjectName("fieldHeader") + self.gridLayout.addWidget(self.fieldHeader, 0, 0, 1, 1) + self.label = QtGui.QLabel(PrefsGlobalWidget) + self.label.setWordWrap(True) + self.label.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextSelectableByKeyboard) + self.label.setObjectName("label") + self.gridLayout.addWidget(self.label, 1, 0, 1, 1) + self.hboxlayout = QtGui.QHBoxLayout() + self.hboxlayout.setObjectName("hboxlayout") + self.edSettingsDir = QtGui.QLineEdit(PrefsGlobalWidget) + self.edSettingsDir.setObjectName("edSettingsDir") + self.hboxlayout.addWidget(self.edSettingsDir) + self.btSelectSettingsDir = QtGui.QPushButton(PrefsGlobalWidget) + self.btSelectSettingsDir.setObjectName("btSelectSettingsDir") + self.hboxlayout.addWidget(self.btSelectSettingsDir) + self.gridLayout.addLayout(self.hboxlayout, 2, 0, 1, 1) + self.label_2 = QtGui.QLabel(PrefsGlobalWidget) + self.label_2.setWordWrap(True) + self.label_2.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse) + self.label_2.setObjectName("label_2") + self.gridLayout.addWidget(self.label_2, 3, 0, 1, 1) + self.ckSettingsAllUsers = QtGui.QCheckBox(PrefsGlobalWidget) + self.ckSettingsAllUsers.setObjectName("ckSettingsAllUsers") + self.gridLayout.addWidget(self.ckSettingsAllUsers, 4, 0, 1, 1) + self.fieldHeader_2 = QtGui.QLabel(PrefsGlobalWidget) + self.fieldHeader_2.setWordWrap(True) + self.fieldHeader_2.setTextInteractionFlags(QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse) + self.fieldHeader_2.setObjectName("fieldHeader_2") + self.gridLayout.addWidget(self.fieldHeader_2, 5, 0, 1, 1) + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.edDownloadDir = QtGui.QLineEdit(PrefsGlobalWidget) + self.edDownloadDir.setObjectName("edDownloadDir") + self.horizontalLayout.addWidget(self.edDownloadDir) + self.btSelectDownloadDir = QtGui.QPushButton(PrefsGlobalWidget) + self.btSelectDownloadDir.setObjectName("btSelectDownloadDir") + self.horizontalLayout.addWidget(self.btSelectDownloadDir) + self.gridLayout.addLayout(self.horizontalLayout, 6, 0, 1, 1) + spacerItem = QtGui.QSpacerItem(20, 38, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.gridLayout.addItem(spacerItem, 7, 0, 1, 1) + + self.retranslateUi(PrefsGlobalWidget) + QtCore.QMetaObject.connectSlotsByName(PrefsGlobalWidget) + + def retranslateUi(self, PrefsGlobalWidget): + PrefsGlobalWidget.setWindowTitle(QtGui.QApplication.translate("PrefsGlobalWidget", "Form", None, QtGui.QApplication.UnicodeUTF8)) + self.fieldHeader.setText(QtGui.QApplication.translate("PrefsGlobalWidget", "Settings directory:", None, QtGui.QApplication.UnicodeUTF8)) + self.label.setText(QtGui.QApplication.translate("PrefsGlobalWidget", "Directory to store settings to.Leave empty to store settings in a location your os feels best with", None, QtGui.QApplication.UnicodeUTF8)) + self.btSelectSettingsDir.setText(QtGui.QApplication.translate("PrefsGlobalWidget", "...", None, QtGui.QApplication.UnicodeUTF8)) + self.label_2.setText(QtGui.QApplication.translate("PrefsGlobalWidget", "If no path for settings is specified, store settings only for the the current user or for all users?", None, QtGui.QApplication.UnicodeUTF8)) + self.ckSettingsAllUsers.setText(QtGui.QApplication.translate("PrefsGlobalWidget", "Store settings for all users", None, QtGui.QApplication.UnicodeUTF8)) + self.fieldHeader_2.setText(QtGui.QApplication.translate("PrefsGlobalWidget", "Default download directory:", None, QtGui.QApplication.UnicodeUTF8)) + self.btSelectDownloadDir.setText(QtGui.QApplication.translate("PrefsGlobalWidget", "...", None, QtGui.QApplication.UnicodeUTF8)) + + +if __name__ == "__main__": + import sys + app = QtGui.QApplication(sys.argv) + PrefsGlobalWidget = QtGui.QWidget() + ui = Ui_PrefsGlobalWidget() + ui.setupUi(PrefsGlobalWidget) + PrefsGlobalWidget.show() + sys.exit(app.exec_()) + Added: trunk/fclient/fclient/impl/MainWindow/prefs/Ui_PrefsSingleApp.py =================================================================== --- trunk/fclient/fclient/impl/MainWindow/prefs/Ui_PrefsSingleApp.py (rev 0) +++ trunk/fclient/fclient/impl/MainWindow/prefs/Ui_PrefsSingleApp.py 2008-08-22 12:59:51 UTC (rev 956) @@ -0,0 +1,72 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file '/home/me/src/fclient/trunk/fclient/fclient/impl/MainWindow/prefs/PrefsSingleApp.ui' +# +# Created: Sun Aug 17 14:17:03 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_PrefsSingleApp(object): + def setupUi(self, PrefsSingleApp): + PrefsSingleApp.setObjectName("PrefsSingleApp") + PrefsSingleApp.resize(533, 399) + self.gridLayout = QtGui.QGridLayout(PrefsSingleApp) + self.gridLayout.setObjectName("gridLayout") + self.fieldHeader_3 = QtGui.QLabel(PrefsSingleApp) + self.fieldHeader_3.setObjectName("fieldHeader_3") + self.gridLayout.addWidget(self.fieldHeader_3, 0, 0, 1, 1) + self.label = QtGui.QLabel(PrefsSingleApp) + self.label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) + self.label.setWordWrap(True) + self.label.setTextInteractionFlags(QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse) + self.label.setObjectName("label") + self.gridLayout.addWidget(self.label, 1, 0, 1, 2) + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.verticalLayout = QtGui.QVBoxLayout() + self.verticalLayout.setObjectName("verticalLayout") + self.fieldName = QtGui.QLabel(PrefsSingleApp) + self.fieldName.setObjectName("fieldName") + self.verticalLayout.addWidget(self.fieldName) + self.fieldName_2 = QtGui.QLabel(PrefsSingleApp) + self.fieldName_2.setObjectName("fieldName_2") + self.verticalLayout.addWidget(self.fieldName_2) + self.horizontalLayout.addLayout(self.verticalLayout) + self.verticalLayout_2 = QtGui.QVBoxLayout() + self.verticalLayout_2.setObjectName("verticalLayout_2") + self.edHost = QtGui.QLineEdit(PrefsSingleApp) + self.edHost.setObjectName("edHost") + self.verticalLayout_2.addWidget(self.edHost) + self.spinPort = QtGui.QSpinBox(PrefsSingleApp) + self.spinPort.setObjectName("spinPort") + self.verticalLayout_2.addWidget(self.spinPort) + self.horizontalLayout.addLayout(self.verticalLayout_2) + self.gridLayout.addLayout(self.horizontalLayout, 2, 0, 1, 1) + spacerItem = QtGui.QSpacerItem(251, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.gridLayout.addItem(spacerItem, 2, 1, 1, 1) + spacerItem1 = QtGui.QSpacerItem(20, 218, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.gridLayout.addItem(spacerItem1, 3, 0, 1, 1) + + self.retranslateUi(PrefsSingleApp) + QtCore.QMetaObject.connectSlotsByName(PrefsSingleApp) + + def retranslateUi(self, PrefsSingleApp): + PrefsSingleApp.setWindowTitle(QtGui.QApplication.translate("PrefsSingleApp", "Form", None, QtGui.QApplication.UnicodeUTF8)) + self.fieldHeader_3.setText(QtGui.QApplication.translate("PrefsSingleApp", "Single application:", None, QtGui.QApplication.UnicodeUTF8)) + self.label.setText(QtGui.QApplication.translate("PrefsSingleApp", "The gui uses a socket connection to enshure only one instance is running at a time. Use the boxes below to adjust host and port of the connection to your needs.", None, QtGui.QApplication.UnicodeUTF8)) + self.fieldName.setText(QtGui.QApplication.translate("PrefsSingleApp", "Host: ", None, QtGui.QApplication.UnicodeUTF8)) + self.fieldName_2.setText(QtGui.QApplication.translate("PrefsSingleApp", "Port: ", None, QtGui.QApplication.UnicodeUTF8)) + + +if __name__ == "__main__": + import sys + app = QtGui.QApplication(sys.argv) + PrefsSingleApp = QtGui.QWidget() + ui = Ui_PrefsSingleApp() + ui.setupUi(PrefsSingleApp) + PrefsSingleApp.show() + sys.exit(app.exec_()) + Added: trunk/fclient/fclient/impl/MainWindow/prefs/__init__.py =================================================================== --- trunk/fclient/fclient/impl/MainWindow/prefs/__init__.py (rev 0) +++ trunk/fclient/fclient/impl/MainWindow/prefs/__init__.py 2008-08-22 12:59:51 UTC (rev 956) @@ -0,0 +1 @@ + Added: trunk/fclient/fclient/impl/MainWindow/prefs/_fix_mexec.py =================================================================== --- trunk/fclient/fclient/impl/MainWindow/prefs/_fix_mexec.py (rev 0) +++ trunk/fclient/fclient/impl/MainWindow/prefs/_fix_mexec.py 2008-08-22 12:59:51 UTC (rev 956) @@ -0,0 +1,99 @@ +'''in python 2.5 relative impports are srsly broken ..fix this to make relative imports work +when executing a module as main (-m), including relative imports up to the root package + +see: [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] + +@note: root package is the highest available package in the package hirarchy. +don't look at __name__ too closely. it gets adjusted for a module to just "do the right +thing" in __name__ == '__main__' comparisons +@note: this patch does not work if relative imports are done in __init__.py. no idea why +and to be honest, I don't wanna* know.. +@note: this is more or less a hack. so it may have unwanted side effects for example +when importing parent packages. use at your own risk. could improve this module +by adding a __main__.py to stop at this level or by fixing the __init__.py bug, but +I don't think its worth it. see what python2.6 or 3k brings.. + +usage:: + + # place this at the top a module, before doing any relative imports + from fix_mexec import fix_mexec + fix_mexec(__name__, __file__) + del fix_mexec + + from ...foo import bar + + + +##<-- copy and paste code, assuming _fix_mexec resides in the current dir.. + +# some fixes for relative imports +# see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below) +# see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a +# ...package containing relative imports +from __future__ import absolute_import +if __name__ == '__main__': + import os + __path__ = [os.path.dirname(__file__)] + from ._fix_mexec import fix_mexec + fix_mexec(__name__, __file__) + del fix_mexec + + +##--> copy and paste code +''' + +import imp, os, sys +#******************************************************************************** +# +#******************************************************************************** +class MainName(str): + def __eq__(self, other): + if other == '__main__': return True + return str.__eq__(self, other) + def __ne__(self, other): + if other == '__main__': return False + return str.__ne__(self, other) + + +def fix_mexec(_name_, _file_): + """bugfix for relative imports not working + @param _name_: __name__ of the module + @param _file_: __file__ of the module + + @note: not complete: relies on __init__.py, .pyo (...) is ignored currently + """ + if _name_ == '__main__': + out = [] + # find allparent packages + p = os.path.dirname(os.path.abspath(_file_)) + prev = p + while True: + pkg = os.path.join(p, '__init__.py') + if os.path.isfile(pkg): + out.append([pkg, os.path.basename(p)]) + else: + break + prev = p + p = os.path.dirname(p) + if p == prev: + break + out.reverse() + + # adjust sub package names an import parent modules + name = None + for n, (fpath, name) in enumerate(out): + if n > 0: + name = out[n][1] = out[n -1][1] + '.' + out[n][1] + m = imp.load_source(name, fpath) + m.__path__ = [os.path.dirname(fpath)] + + # adjust name of the __main__ module + if name is not None: + m = sys.modules.pop('__main__') + # 'foo.bar..__main__' does not work for some reason. 'foo.bar' seems to work as expected + ##m.__name__ = _Name_(name + '.' + '__main__') + m.__name__ = MainName(name) + sys.modules[m.__name__] = m + + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-22 12:22:53
|
Revision: 955 http://fclient.svn.sourceforge.net/fclient/?rev=955&view=rev Author: jUrner Date: 2008-08-22 12:23:00 +0000 (Fri, 22 Aug 2008) Log Message: ----------- split module into submodules Modified Paths: -------------- trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py Added Paths: ----------- trunk/fclient/fclient/impl/ViewConnection/Actions.py trunk/fclient/fclient/impl/ViewConnection/GlobalFeedback.py trunk/fclient/fclient/impl/ViewConnection/Settings.py Added: trunk/fclient/fclient/impl/ViewConnection/Actions.py =================================================================== --- trunk/fclient/fclient/impl/ViewConnection/Actions.py (rev 0) +++ trunk/fclient/fclient/impl/ViewConnection/Actions.py 2008-08-22 12:23:00 UTC (rev 955) @@ -0,0 +1,20 @@ +# some fixes for relative imports +# see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below) +# see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a +# ...package containing relative imports +from __future__ import absolute_import +if __name__ == '__main__': + import os + __path__ = [os.path.dirname(__file__)] + from ._fix_mexec import fix_mexec + fix_mexec(__name__, __file__) + del fix_mexec +from PyQt4 import QtCore, QtGui + +from .. import config +from ..lib import fcp2 +#********************************************************************************** +# +#********************************************************************************** +class Actions(config.ActionsBase): + pass Added: trunk/fclient/fclient/impl/ViewConnection/GlobalFeedback.py =================================================================== --- trunk/fclient/fclient/impl/ViewConnection/GlobalFeedback.py (rev 0) +++ trunk/fclient/fclient/impl/ViewConnection/GlobalFeedback.py 2008-08-22 12:23:00 UTC (rev 955) @@ -0,0 +1,43 @@ +# some fixes for relative imports +# see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below) +# see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a +# ...package containing relative imports +from __future__ import absolute_import +if __name__ == '__main__': + import os + __path__ = [os.path.dirname(__file__)] + from ._fix_mexec import fix_mexec + fix_mexec(__name__, __file__) + del fix_mexec +from PyQt4 import QtCore, QtGui + +from .. import config +#********************************************************************************** +# +#********************************************************************************** +class GlobalFeedback(config.GlobalFeedbackBase): + """wrapper for global statusbar widgets, menus""" + + def __init__(self, parent,idGlobalFeedback): + config.GlobalFeedbackBase.__init__(self, parent,idGlobalFeedback) + + # menus + self.menus = [] + if self.menuBar is not None: + viewObject = config.ObjectRegistry.get(config.IdViewObjectConnection, None) + menu = QtGui.QMenu(viewObject.displayName(), self.menuBar) + parent.populateMenu(menu) + self.menus.append(menu) + self.menuBar.addViewMenu(menu) + + # status bar widgets + self.label1 = None + #if self.statusBar is not None: + # self.label1 = QtGui.QLabel('foo here', self.statusBar) + + def setVisible(self, flag): + for menu in self.menus: + menu.children()[0].setEnabled(flag) + if self.label1 is not None: + self.label1.setVisible(flag) + \ No newline at end of file Added: trunk/fclient/fclient/impl/ViewConnection/Settings.py =================================================================== --- trunk/fclient/fclient/impl/ViewConnection/Settings.py (rev 0) +++ trunk/fclient/fclient/impl/ViewConnection/Settings.py 2008-08-22 12:23:00 UTC (rev 955) @@ -0,0 +1,58 @@ +# some fixes for relative imports +# see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below) +# see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a +# ...package containing relative imports +from __future__ import absolute_import +if __name__ == '__main__': + import os + __path__ = [os.path.dirname(__file__)] + from ._fix_mexec import fix_mexec + fix_mexec(__name__, __file__) + del fix_mexec +from PyQt4 import QtCore, QtGui + +from .. import config +from ..lib import fcp2 +#********************************************************************************** +# +#********************************************************************************** +class Settings(config.SettingsBase): + _key_ = config.IdViewObjectConnection + _settings_ = ( + ('FcpAutoConnect', 'Bool', True), + ('FcpConnectionName', 'String', config.FcConnectionName), + ('FcpConnectionHost', 'String', fcp2.Client.DefaultFcpHost), + ('FcpConnectionPort', 'UInt', fcp2.Client.DefaultFcpPort), + ('FcpConnectionTimerTimeout', 'UInt', 500), + ('FcpConnectionTimerMaxDuration', 'UInt', 20), + ('FcpPollTimerTimeout', 'UInt', 200), + + ('FproxyConnectionHost', 'String','127.0.0.1'), + ('FproxyConnectionPort', 'UInt', 8888), + ) + + def setValues(self, **kws): + config.SettingsBase.setValues(self, **kws) + parent = self.parent() + + # set fcp connection params + if 'FcpConnectionHost' in kws: + edHost = parent.controlById(parent.IdEdFcpConnectionHost) + edHost.setText(self.value('FcpConnectionHost')) + + if 'FcpConnectionPort' in kws: + spinPort = parent.controlById(parent.IdFcpSpinFcpConnectionPort) + spinPort.setValue(self.value('FcpConnectionPort')) + + if 'FcpAutoConnect' in kws: + ck = parent.controlById(parent.IdCkFcpAutoConnect) + ck.setChecked(self.value('FcpAutoConnect')) + + # set fproxy connection params + if 'FproxyConnectionHost' in kws: + edHost = parent.controlById(parent.IdEdFproxyConnectionHost) + edHost.setText(self.value('FproxyConnectionHost')) + + if 'FproxyConnectionPort' in kws: + spinPort = parent.controlById(parent.IdFproxySpinConnectionPort) + spinPort.setValue(self.value('FproxyConnectionPort')) Modified: trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py =================================================================== --- trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py 2008-08-22 08:09:32 UTC (rev 954) +++ trunk/fclient/fclient/impl/ViewConnection/ViewConnection.py 2008-08-22 12:23:00 UTC (rev 955) @@ -20,85 +20,13 @@ from .. import config from ..lib import fcp2 +from . import Actions +from . import GlobalFeedback +from. import Settings from .Ui_ConnectionWidgetTpl import Ui_ViewConnectionWidget #********************************************************************************** # #********************************************************************************** -class Actions(config.ActionsBase): - pass - - -class GlobalFeedback(config.GlobalFeedbackBase): - """wrapper for global statusbar widgets, menus""" - - def __init__(self, parent,idGlobalFeedback): - config.GlobalFeedbackBase.__init__(self, parent,idGlobalFeedback) - - # menus - self.menus = [] - if self.menuBar is not None: - viewObject = config.ObjectRegistry.get(config.IdViewObjectConnection, None) - menu = QtGui.QMenu(viewObject.displayName(), self.menuBar) - parent.populateMenu(menu) - self.menus.append(menu) - self.menuBar.addViewMenu(menu) - - # status bar widgets - self.label1 = None - #if self.statusBar is not None: - # self.label1 = QtGui.QLabel('foo here', self.statusBar) - - def setVisible(self, flag): - for menu in self.menus: - menu.children()[0].setEnabled(flag) - if self.label1 is not None: - self.label1.setVisible(flag) - - -class Settings(config.SettingsBase): - _key_ = config.IdViewObjectConnection - _settings_ = ( - ('FcpAutoConnect', 'Bool', True), - ('FcpConnectionName', 'String', config.FcConnectionName), - ('FcpConnectionHost', 'String', fcp2.Client.DefaultFcpHost), - ('FcpConnectionPort', 'UInt', fcp2.Client.DefaultFcpPort), - ('FcpConnectionTimerTimeout', 'UInt', 500), - ('FcpConnectionTimerMaxDuration', 'UInt', 20), - ('FcpPollTimerTimeout', 'UInt', 200), - - ('FproxyConnectionHost', 'String','127.0.0.1'), - ('FproxyConnectionPort', 'UInt', 8888), - ) - - def setValues(self, **kws): - config.SettingsBase.setValues(self, **kws) - parent = self.parent() - - # set fcp connection params - if 'FcpConnectionHost' in kws: - edHost = parent.controlById(parent.IdEdFcpConnectionHost) - edHost.setText(self.value('FcpConnectionHost')) - - if 'FcpConnectionPort' in kws: - spinPort = parent.controlById(parent.IdFcpSpinFcpConnectionPort) - spinPort.setValue(self.value('FcpConnectionPort')) - - if 'FcpAutoConnect' in kws: - ck = parent.controlById(parent.IdCkFcpAutoConnect) - ck.setChecked(self.value('FcpAutoConnect')) - - # set fproxy connection params - if 'FproxyConnectionHost' in kws: - edHost = parent.controlById(parent.IdEdFproxyConnectionHost) - edHost.setText(self.value('FproxyConnectionHost')) - - if 'FproxyConnectionPort' in kws: - spinPort = parent.controlById(parent.IdFproxySpinConnectionPort) - spinPort.setValue(self.value('FproxyConnectionPort')) - -#********************************************************************************** -# -#********************************************************************************** class ConnectionTimer(QtCore.QTimer): def __init__(self,parent): @@ -167,9 +95,9 @@ spinPort.setRange(0, 0xFFFF) #TODO: no idea if port range (0, 0xFFFF) this is reasonable self._isCreated = False - self.fcSettings = Settings(self).restore() - self.fcActions = Actions(self) - self.fcGlobalFeedback = GlobalFeedback(self,idGlobalFeedback) + self.fcSettings = Settings.Settings(self).restore() + self.fcActions = Actions.Actions(self) + self.fcGlobalFeedback = GlobalFeedback.GlobalFeedback(self,idGlobalFeedback) self._connectionTimer = ConnectionTimer(self) self._pollTimer = PollTimer(self) @@ -297,16 +225,39 @@ #********************************************************************************** if __name__ == '__main__': import sys - from .. import View, ViewLogger - + from ..MainWindow.ViewObject import ViewObjectMainWindow + from ..ViewView.ViewObject import ViewObjectView + from ..ViewConnection.ViewObject import ViewObjectConnection + from ..ViewLogger.ViewObject import ViewObjectLogger + app = QtGui.QApplication(sys.argv) - w = View.ViewWidget(None) - w.addTopViews(ViewConnectionWidget(None)) - w.addBottomViews(ViewLogger.ViewLoggerWidget(None)) - w.show() + voMainWindow = ViewObjectMainWindow(None) + voMainWindow.create() + + voView = ViewObjectView(voMainWindow) + viewWidget = voView.create() + voMainWindow.widget().setCentralWidget(viewWidget) + + topViews = ( + ViewObjectConnection, + ) + for view in topViews: + view = view(voView) + view.create() + viewWidget.addTopViews(view) + + bottomViews = ( + ViewObjectLogger, + ) + for view in bottomViews: + view = view(voView) + view.create() + viewWidget.addBottomViews(view) + + voMainWindow.widget().show() res = app.exec_() sys.exit(res) + - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-22 08:09:25
|
Revision: 954 http://fclient.svn.sourceforge.net/fclient/?rev=954&view=rev Author: jUrner Date: 2008-08-22 08:09:32 +0000 (Fri, 22 Aug 2008) Log Message: ----------- update Modified Paths: -------------- trunk/fclient/fclient/README Modified: trunk/fclient/fclient/README =================================================================== --- trunk/fclient/fclient/README 2008-08-22 08:06:27 UTC (rev 953) +++ trunk/fclient/fclient/README 2008-08-22 08:09:32 UTC (rev 954) @@ -14,6 +14,7 @@ news: x. downloads can now be removed groupwise + x. browser now knows what bookmarks are bugfixes: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-22 08:06:18
|
Revision: 953 http://fclient.svn.sourceforge.net/fclient/?rev=953&view=rev Author: jUrner Date: 2008-08-22 08:06:27 +0000 (Fri, 22 Aug 2008) Log Message: ----------- save dlg state Modified Paths: -------------- trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgPropsBrowserObject.py Modified: trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgPropsBrowserObject.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgPropsBrowserObject.py 2008-08-22 08:05:59 UTC (rev 952) +++ trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgPropsBrowserObject.py 2008-08-22 08:06:27 UTC (rev 953) @@ -19,7 +19,7 @@ del fix_mexec import posixpath -from PyQt4 import QtGui +from PyQt4 import QtCore, QtGui from ... import config from ...lib.compactpath.qt4 import pathlabelwrap @@ -29,6 +29,15 @@ #********************************************************************************** # #********************************************************************************** +class Settings(config.SettingsBase): + _key_ = 'DlgBookmarkPage' + _settings_ = ( + ('Geometry', 'ByteArray', QtCore.QByteArray()), + ) + +#********************************************************************************** +# +#********************************************************************************** class DlgPropsBrowserObject(QtGui.QDialog, Ui_DlgPropsBrowserObject): IdLabelType = 'labelType' @@ -43,6 +52,8 @@ QtGui.QDialog.__init__(self, parent) self.setupUi(self) + self.fcSettings = Settings(self).restore() + self.restoreGeometry(self.fcSettings.value('Geometry')) self.setWindowTitle(config.FcAppName + self.trUtf8(' - Properties')) if hitTestResult is not None: @@ -62,6 +73,9 @@ def controlById(self, idControl): return getattr(self, idControl) + + def hideEvent(self, event): + self.fcSettings.setValues(Geometry=self.saveGeometry()) #********************************************************************************** # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-22 08:05:53
|
Revision: 952 http://fclient.svn.sourceforge.net/fclient/?rev=952&view=rev Author: jUrner Date: 2008-08-22 08:05:59 +0000 (Fri, 22 Aug 2008) Log Message: ----------- add folder icons Added Paths: ----------- trunk/fclient/fclient/impl/res/icons/crystal/16x16/folder.png trunk/fclient/fclient/impl/res/icons/crystal/32x32/folder.png trunk/fclient/fclient/impl/res/icons/crystal/48x48/folder.png Property changes on: trunk/fclient/fclient/impl/res/icons/crystal/16x16/folder.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Property changes on: trunk/fclient/fclient/impl/res/icons/crystal/32x32/folder.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Property changes on: trunk/fclient/fclient/impl/res/icons/crystal/48x48/folder.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-22 08:04:57
|
Revision: 951 http://fclient.svn.sourceforge.net/fclient/?rev=951&view=rev Author: jUrner Date: 2008-08-22 08:05:06 +0000 (Fri, 22 Aug 2008) Log Message: ----------- whitespace Modified Paths: -------------- trunk/fclient/fclient/impl/ViewBrowser/Browser.py Modified: trunk/fclient/fclient/impl/ViewBrowser/Browser.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/Browser.py 2008-08-22 08:04:41 UTC (rev 950) +++ trunk/fclient/fclient/impl/ViewBrowser/Browser.py 2008-08-22 08:05:06 UTC (rev 951) @@ -213,4 +213,4 @@ networkReplyData.finished = True for signal, handler in self._networkReplySignals: self.disconnect(reply, QtCore.SIGNAL(signal), handler) - self.emit(QtCore.SIGNAL('networkReplyFinished(int, QObject*)'), i, networkReplyData) \ No newline at end of file + self.emit(QtCore.SIGNAL('networkReplyFinished(int, QObject*)'), i, networkReplyData) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-22 08:04:31
|
Revision: 950 http://fclient.svn.sourceforge.net/fclient/?rev=950&view=rev Author: jUrner Date: 2008-08-22 08:04:41 +0000 (Fri, 22 Aug 2008) Log Message: ----------- impl browser bookmarks. pages cann be bookmarked now ++ bookmark editor Modified Paths: -------------- trunk/fclient/fclient/impl/ViewBrowser/Actions.py trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py Modified: trunk/fclient/fclient/impl/ViewBrowser/Actions.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/Actions.py 2008-08-22 08:02:47 UTC (rev 949) +++ trunk/fclient/fclient/impl/ViewBrowser/Actions.py 2008-08-22 08:04:41 UTC (rev 950) @@ -186,7 +186,20 @@ isEnabled=True, trigger=parent.onCloseCurrentSideBar, ) - + + # bookmarks + self.action( + name='ActionEditBookmarks', + text=self.trUtf8('Edit bookmarks..'), + isEnabled=True, + trigger=parent.onEditBookmarks, + ) + self.action( + name='ActionBookmarkPage', + text=self.trUtf8('Bookmark page..'), + isEnabled=True, + trigger=parent.onBookmarkPage, + ) def intertwineBrowserActions(self, browser=None): """intertwines Browser actions with BrowserWidget actions @@ -218,3 +231,16 @@ myPageAction.setUserData((newPageAction, onActionChanged)) myPageAction.connect(newPageAction, QtCore.SIGNAL('changed()'), onActionChanged) newPageAction.connect(myPageAction, QtCore.SIGNAL('triggered()'), newPageAction.trigger) + +#*********************************************************************************** +# +#*********************************************************************************** +class BookmarkAction(QtGui.QAction): + + def __init__(self, parent, text, target): + QtGui.QAction.__init__(self, text, parent) + self.target = target + + + + Modified: trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py 2008-08-22 08:02:47 UTC (rev 949) +++ trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py 2008-08-22 08:04:41 UTC (rev 950) @@ -41,7 +41,7 @@ # 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 -# +# x. icons for bookmarks #******************************************************************************************* #TODO: code # @@ -77,6 +77,8 @@ from . import Settings from .dlgs import DlgPropsBrowserObject +from .dlgs import DlgBookmarks +from .dlgs import DlgBookmarkPage from .Ui_BrowserWidget import Ui_ViewBrowserWidget #***************************************************************************************** @@ -109,6 +111,8 @@ QtGui.QWidget.__init__(self, parent) self.menuSideBars = QtGui.QMenu(self.trUtf8('Side bars')) #TODO: retranslate + self.menuBookmarks = QtGui.QMenu(self.trUtf8('Bookmarks')) #TODO: retranslate + self.connect(self.menuBookmarks, QtCore.SIGNAL('aboutToShow()'), self.onMenuBookmarksAboutToShow) self.setupUi(self) self.isCreated = False @@ -274,6 +278,12 @@ if isinstance(widget, Browser.Browser): return widget + def currentUrl(self): + browser = self.currentBrowser() + if browser is not None: + lastBrowserState = browser.userData() + return lastBrowserState.url + def load(self, url, force=False, browser=None): """loads an url in the current browser. if there is no current browser, a new browser is created @param force: (bool) if True, a new browser is opend if there is no browser available @@ -379,7 +389,10 @@ menu.addAction(self.fcActions['ActionFind']) menu.addAction(self.fcActions['ActionFindNext']) menu.addAction(self.fcActions['ActionFindPrevious']) + menu.addAction(self.fcActions['ActionEditBookmarks']) + menu.addAction(self.fcActions['ActionBookmarkPage']) + menu.addMenu(self.menuBookmarks) menu.addMenu(self.menuSideBars) return menu @@ -417,6 +430,20 @@ ######################################### ## event handlers ######################################### + def onBookmarkPage(self, action): + dlg = DlgBookmarkPage.DlgBookmarkPage(self) + dlg.show() + if dlg.result() == dlg.Accepted: + pass + + def onBookmarkTriggered(self): + action = self.sender() + if self.fcSettings.value('OpenBookmarksInNewTab'): + browser = self.newBrowser(self.trUtf8('Loading')) + self.load(action.target, browser=browser) + else: + self.load(action.target, force=True) + #TODO: actions need some comb over def onBrowserCustomContextMenuRequested(self, pt): browser = self.sender() @@ -604,6 +631,12 @@ self.fcActions['ActionFindNext'].setEnabled(bool(text)) self.fcActions['ActionFindPrevious'].setEnabled(bool(text)) + def onEditBookmarks(self, action): + dlg = DlgBookmarks.DlgBookmarks(self) + dlg.show() + if dlg.result() == dlg.Accepted: + pass + def onFind(self, action): frameFind = self.controlById(self.IdFrameFind) ed = self.controlById(self.IdEdFind) @@ -651,6 +684,27 @@ qUrl = QtCore.QUrl(home) self.load(qUrl, force=True) + #TODO: how to know if we have bookmarks? + def onMenuBookmarksAboutToShow(self): + self.menuBookmarks.clear() + stack = [self.menuBookmarks, ] + try: + for event, params in DlgBookmarks.DlgBookmarks.walkBookmarks(DlgBookmarks.BookmarksFile): + if event == 'beginfolder': + menu = QtGui.QMenu(params['name'], stack[-1]) + stack[-1].addMenu(menu) + stack.append(menu) + elif event == 'endfolder': + stack.pop() + elif event == 'bookmark': + action = Actions.BookmarkAction(stack[-1], params['name'], params['target']) + stack[-1].addAction(action) + self.connect(action, QtCore.SIGNAL('triggered()'), self.onBookmarkTriggered) + except SyntaxError: + pass + except IOError: + pass + def onNavBarReturnPressed(self): text = self.controlById(self.IdEdAddressBar).text() if text.isEmpty(): @@ -683,6 +737,7 @@ if browser is not None and act is browser.pageAction(browser.page().Back): self._adjustBackIsClose() + #TODO: not yet implemented def onSavePage(self, action): # we have to cheat a bit here and reload the page to make shure the page has # all QNetWorkReplies present This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-22 08:02:38
|
Revision: 949 http://fclient.svn.sourceforge.net/fclient/?rev=949&view=rev Author: jUrner Date: 2008-08-22 08:02:47 +0000 (Fri, 22 Aug 2008) Log Message: ----------- add edit bookmarks ++ bookmark page dlgs Added Paths: ----------- trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgBookmarkPage.py trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgBookmarkPage.ui trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgBookmarks.py trunk/fclient/fclient/impl/ViewBrowser/dlgs/Ui_DlgBookmarkPage.py Added: trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgBookmarkPage.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgBookmarkPage.py (rev 0) +++ trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgBookmarkPage.py 2008-08-22 08:02:47 UTC (rev 949) @@ -0,0 +1,94 @@ +#********************************************************************* +#TODO: +# just a sketch so far +# +# x. link and image url are not selectable +# +# +#********************************************************************** +# some fixes for relative imports +# see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below) +# see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a +# ...package containing relative imports +from __future__ import absolute_import +if __name__ == '__main__': + import os + __path__ = [os.path.dirname(__file__)] + from ._fix_mexec import fix_mexec + fix_mexec(__name__, __file__) + del fix_mexec + +from PyQt4 import QtCore, QtGui + +from ... import config + +from . import DlgBookmarks +from .Ui_DlgBookmarkPage import Ui_DlgBookmarkPage +#********************************************************************************** +# +#********************************************************************************** +class Settings(config.SettingsBase): + _key_ = 'DlgBookmarkPage' + _settings_ = ( + ('Geometry', 'ByteArray', QtCore.QByteArray()), + ) + +#********************************************************************************** +# +#********************************************************************************** +class DlgBookmarkPage(QtGui.QDialog, Ui_DlgBookmarkPage): + + IdEdName = 'edName' + IdEdTarget = 'edTarget' + + def __init__(self, parent, browser=None, hitTestResult=None): + QtGui.QDialog.__init__(self, parent) + + self.setupUi(self) + self.fcSettings = Settings(self).restore() + self.restoreGeometry(self.fcSettings.value('Geometry')) + + voBrowser = config.ObjectRegistry.get(config.IdViewObjectBrowser, None) + if voBrowser is not None: + url = voBrowser.widget().currentUrl() + if url is not None: + edName = self.controlById(self.IdEdName) + edTarget = self.controlById(self.IdEdTarget) + + # do our best to suggest a name for the bookmark + url= url.toString() + fcpKey = config.qStringToFcpKey(url) + if fcpKey is not None: + name = config.guessFileNameFromKey(fcpKey, '') + edName.setText(name) + edTarget.setText(url) + + def controlById(self, idControl): + return getattr(self, idControl) + + def hideEvent(self, event): + self.fcSettings.setValues(Geometry=self.saveGeometry()) + + def accept(self): + edName = self.controlById(self.IdEdName) + edTarget = self.controlById(self.IdEdTarget) + DlgBookmarks.DlgBookmarks.appendBookmark( + DlgBookmarks.BookmarksFile, + unicode(edName.text()), + unicode(edTarget.text()) + ) + return QtGui.QDialog.accept(self) + +#********************************************************************************** +# +#********************************************************************************** +if __name__ == '__main__': + import sys + + app = QtGui.QApplication(sys.argv) + w = DlgBookmarkPage(None) + w.show() + res = app.exec_() + sys.exit(res) + + Added: trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgBookmarkPage.ui =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgBookmarkPage.ui (rev 0) +++ trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgBookmarkPage.ui 2008-08-22 08:02:47 UTC (rev 949) @@ -0,0 +1,107 @@ +<ui version="4.0" > + <class>DlgBookmarkPage</class> + <widget class="QDialog" name="DlgBookmarkPage" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>183</height> + </rect> + </property> + <property name="windowTitle" > + <string>Bookmark page..</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2" > + <item> + <layout class="QVBoxLayout" name="verticalLayout" > + <item> + <widget class="QLabel" name="label" > + <property name="text" > + <string>Name:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="edName" /> + </item> + <item> + <widget class="QLabel" name="label_2" > + <property name="text" > + <string>Target:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="edTarget" /> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer" > + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>20</width> + <height>5</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="Line" name="line" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons" > + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>DlgBookmarkPage</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel" > + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel" > + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>DlgBookmarkPage</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel" > + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel" > + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> Added: trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgBookmarks.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgBookmarks.py (rev 0) +++ trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgBookmarks.py 2008-08-22 08:02:47 UTC (rev 949) @@ -0,0 +1,81 @@ +#********************************************************************************* +#TODO: +# +# x. handle SyntaxErrors in bookmarks.xml +# +#********************************************************************************* +# some fixes for relative imports +# see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below) +# see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a +# ...package containing relative imports +from __future__ import absolute_import +if __name__ == '__main__': + import os + __path__ = [os.path.dirname(__file__)] + from ._fix_mexec import fix_mexec + fix_mexec(__name__, __file__) + del fix_mexec + +import os +from PyQt4 import QtCore, QtGui + +from ... import config +from ...lib.qt4ex import dlgbookmarks +#********************************************************************************** +# +#********************************************************************************** +BookmarksFile = os.path.join(unicode(config.FcSettingsDir), 'BrowserBookmarks.xml') + +#********************************************************************************** +# +#********************************************************************************** +class Settings(config.SettingsBase): + _key_ = 'DlgBrowserBookmarks' + _settings_ = ( + ('Geometry', 'ByteArray', QtCore.QByteArray()), + ) + +#********************************************************************************** +# +#********************************************************************************** +class DlgBookmarks(dlgbookmarks.DlgBookmarks): + + def __init__(self, parent=None): + dlgbookmarks.DlgBookmarks.__init__(self, parent) + + self.fcSettings = Settings(self).restore() + self.restoreGeometry(self.fcSettings.value('Geometry')) + self.restoreBookmarks(BookmarksFile) + + def iconForItem(self, itemType, itemTarget): + iconSize = config.fcSettings.value('IconSize') + iconTheme = config.fcSettings.value('IconTheme') + if itemType == self.ItemTypeFolder: + return config.fcResources.getIcon('folder', iconSize, iconTheme=iconTheme) + + return QtGui.QIcon() + + def closeEvent(self, event): + self.close() + + def hideEvent(self, event): + self.fcSettings.setValues(Geometry=self.saveGeometry()) + + def accept(self): + self.close() + return dlgbookmarks.DlgBookmarks.accept(self) + + def close(self): + self.saveBookmarks(BookmarksFile) + +#********************************************************************************** +# +#********************************************************************************** +if __name__ == '__main__': + import sys + + app = QtGui.QApplication(sys.argv) + w = DlgBookmarks(None) + w.show() + res = app.exec_() + sys.exit(res) \ No newline at end of file Added: trunk/fclient/fclient/impl/ViewBrowser/dlgs/Ui_DlgBookmarkPage.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/dlgs/Ui_DlgBookmarkPage.py (rev 0) +++ trunk/fclient/fclient/impl/ViewBrowser/dlgs/Ui_DlgBookmarkPage.py 2008-08-22 08:02:47 UTC (rev 949) @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file '/home/me/src/fclient/trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgBookmarkPage.ui' +# +# Created: Thu Aug 21 15:00:54 2008 +# by: PyQt4 UI code generator 4.4.2 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +class Ui_DlgBookmarkPage(object): + def setupUi(self, DlgBookmarkPage): + DlgBookmarkPage.setObjectName("DlgBookmarkPage") + DlgBookmarkPage.resize(400,183) + self.verticalLayout_2 = QtGui.QVBoxLayout(DlgBookmarkPage) + self.verticalLayout_2.setObjectName("verticalLayout_2") + self.verticalLayout = QtGui.QVBoxLayout() + self.verticalLayout.setObjectName("verticalLayout") + self.label = QtGui.QLabel(DlgBookmarkPage) + self.label.setObjectName("label") + self.verticalLayout.addWidget(self.label) + self.edName = QtGui.QLineEdit(DlgBookmarkPage) + self.edName.setObjectName("edName") + self.verticalLayout.addWidget(self.edName) + self.label_2 = QtGui.QLabel(DlgBookmarkPage) + self.label_2.setObjectName("label_2") + self.verticalLayout.addWidget(self.label_2) + self.edTarget = QtGui.QLineEdit(DlgBookmarkPage) + self.edTarget.setObjectName("edTarget") + self.verticalLayout.addWidget(self.edTarget) + self.verticalLayout_2.addLayout(self.verticalLayout) + spacerItem = QtGui.QSpacerItem(20,5,QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Expanding) + self.verticalLayout_2.addItem(spacerItem) + self.line = QtGui.QFrame(DlgBookmarkPage) + self.line.setFrameShape(QtGui.QFrame.HLine) + self.line.setFrameShadow(QtGui.QFrame.Sunken) + self.line.setObjectName("line") + self.verticalLayout_2.addWidget(self.line) + self.buttonBox = QtGui.QDialogButtonBox(DlgBookmarkPage) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) + self.buttonBox.setObjectName("buttonBox") + self.verticalLayout_2.addWidget(self.buttonBox) + + self.retranslateUi(DlgBookmarkPage) + QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("accepted()"),DlgBookmarkPage.accept) + QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("rejected()"),DlgBookmarkPage.reject) + QtCore.QMetaObject.connectSlotsByName(DlgBookmarkPage) + + def retranslateUi(self, DlgBookmarkPage): + DlgBookmarkPage.setWindowTitle(QtGui.QApplication.translate("DlgBookmarkPage", "Bookmark page..", None, QtGui.QApplication.UnicodeUTF8)) + self.label.setText(QtGui.QApplication.translate("DlgBookmarkPage", "Name:", None, QtGui.QApplication.UnicodeUTF8)) + self.label_2.setText(QtGui.QApplication.translate("DlgBookmarkPage", "Target:", None, QtGui.QApplication.UnicodeUTF8)) + + +if __name__ == "__main__": + import sys + app = QtGui.QApplication(sys.argv) + DlgBookmarkPage = QtGui.QDialog() + ui = Ui_DlgBookmarkPage() + ui.setupUi(DlgBookmarkPage) + DlgBookmarkPage.show() + sys.exit(app.exec_()) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-22 08:01:26
|
Revision: 948 http://fclient.svn.sourceforge.net/fclient/?rev=948&view=rev Author: jUrner Date: 2008-08-22 08:01:33 +0000 (Fri, 22 Aug 2008) Log Message: ----------- bit of a rewrite of bookmak file handling ++ some helper methods for clients Modified Paths: -------------- trunk/fclient/fclient/impl/lib/qt4ex/dlgbookmarks.py Modified: trunk/fclient/fclient/impl/lib/qt4ex/dlgbookmarks.py =================================================================== --- trunk/fclient/fclient/impl/lib/qt4ex/dlgbookmarks.py 2008-08-21 11:09:03 UTC (rev 947) +++ trunk/fclient/fclient/impl/lib/qt4ex/dlgbookmarks.py 2008-08-22 08:01:33 UTC (rev 948) @@ -21,6 +21,19 @@ from . import treewidgetwrap from .tpls.Ui_DlgBookmarks import Ui_DlgBookmarks #********************************************************************* +# helpers +#********************************************************************* +def UINT(value): + try: + n = int(value) + except ValueError: + pass + else: + if n > -1: + return n + return 0 + +#********************************************************************* # #********************************************************************* class Actions(object): @@ -66,7 +79,7 @@ ItemTypeFolder = 0 ItemTypeItem = 1 - def __init__(self, parent=None, rootElem=None): + def __init__(self, parent=None, bookmarksFile=None): QtGui.QDialog.__init__(self, parent) self.isCreated = False @@ -91,8 +104,8 @@ # init bookmarks if desired #TODO: move to a better place to speed up dlg show - if rootElem is not None: - self.restoreBookmarks(rootElem) + if bookmarksFile is not None: + self.restoreBookmarks(bookmarksFile) ################## ## private methods @@ -113,6 +126,72 @@ return item ################## + ## class methods + ################## + #TODO: in depth error checks + + @classmethod + def appendBookmark(clss, bookmarksFile, name, target, encoding='utf-8'): + """appends a bookmark to the specified bookmarks file + @param bookmarksFile: anything ElementTree.parse() can deal with + @param name: (str) name of the bookmark + @param target: (str) target of the bookmark + @note: make shure to pass name and target as properly encoded strings + """ + try: + tree = ET.parse(bookmarksFile) + except IOError: + pass + except SyntaxError: + pass + else: + rootElem = tree.getroot() + elem = ET.SubElement(rootElem, 'bookmark') + elemName = ET.SubElement(elem, 'name') + elemName.text = name + elemTarget = ET.SubElement(elem, 'target') + elemTarget.text = target + tree = ET.ElementTree(rootElem) + tree.write(bookmarksFile, encoding=encoding) + return True + return False + + @classmethod + def walkBookmarks(clss, bookmarksFile): + """walks bookmarks + @param bookmarksFile: anything ElementTree.iterparse can deal with + @return: tuple(event, paramsDict) for the next item in turn. event can + be: 'bookmarks', 'beginfolder', 'endfolder', 'bookmark'. paramsDict will + contain parameters of the event. + """ + enum = ET.iterparse(bookmarksFile, ('start', 'end')) + for event, elem in enum: + + if elem.tag == 'bookmarks': + if event == 'start': + columnWidthName = UINT(elem.get('columnWidthName', 0)) + yield 'bookmarks', {'columnWidthName': columnWidthName} + + elif elem.tag == 'folder': + if event == 'start': + selected = bool(elem.get('selected', False)) + expanded = bool(elem.get('expanded', False)) + name = elem.find('name') + name = '' if name is None else name.text + yield 'beginfolder', {'name': name, 'expanded': expanded, 'selected': selected} + else: + yield 'endfolder', {} + + elif elem.tag == 'bookmark': + if event == 'start': + selected = bool(elem.get('selected', False)) + name = elem.find('name') + name = '' if name is None else name.text + target = elem.find('target') + target = '' if target is None else target.text + yield 'bookmark', {'name': name, 'target': target, 'selected': selected} + + ################## ## methods ################## def retranslateUi(self, this): @@ -133,7 +212,7 @@ return True return False - def saveBookmarks(self): + def saveBookmarks(self, bookmarksFile, encoding='utf-8'): """saves the bookmarks @return: (ElementTree.Element) root """ @@ -147,13 +226,14 @@ selectedItem = selectedItems[0] if selectedItems else None for item in enum: + # clear parents from stack + parent = item.parent() + if parent is None: + parent = rootItem + while parent != stack[-1][1]: + stack.pop() + if item.type() == self.ItemTypeFolder: - # clear parents from stack - parent = item.parent() - if parent is None: - parent = rootItem - while parent != stack[-1][1]: - stack.pop() elem = ET.SubElement(stack[-1][0], 'folder', expanded=str(item.isExpanded()), selected=str(item is selectedItem)) stack.append((elem, item)) elemName = ET.SubElement(elem, 'name') @@ -165,11 +245,10 @@ elemTarget = ET.SubElement(elem, 'target') elemTarget.text = unicode(item.text(1)) - return ET.ElementTree(rootElem) - - - #TODO: in depth error checks - def restoreBookmarks(self, rootElem): + tree = ET.ElementTree(rootElem) + tree.write(bookmarksFile, encoding=encoding) + + def restoreBookmarks(self, bookmarksFile): """sets the bookmarks of the dialog @param rootElem: (ElementTree.Element) root @return: (bool) True if errors occured, False otherwise @@ -177,52 +256,27 @@ tree = self.controlById(self.IdTree) tree.clear() rootItem = tree.invisibleRootItem() - enum = rootElem.getiterator() - rootElem = enum.next() - parentMap = dict((c, p) for p in rootElem.getiterator() for c in p) + seletedItem = None + stack = [rootItem, ] ok = True - stack = [(rootElem, rootItem), ] - selectedItem = None - - if rootElem.tag != 'bookmarks': + try: + for event, params in self.walkBookmarks(bookmarksFile): + if event == 'bookmarks': + tree.setColumnWidth(0, params['columnWidthName']) + elif event == 'beginfolder': + item = self._addFolder(stack[-1], params['name']) + stack.append(item) + item.setExpanded(params['expanded']) + selectedItem = item if params['selected'] else selectedItem + elif event == 'endfolder': + stack.pop() + elif event == 'bookmark': + item = self._addBookmark(stack[-1], params['name'], params['target']) + selectedItem = item if params['selected'] else selectedItem + except SyntaxError: ok = False - else: - - # restore properties... - columnWidthName = rootElem.get('columnWidthName', None) - try: - tree.setColumnWidth(0, int(columnWidthName)) - except ValueError: - pass - - # restore elems.. - for elem in enum: - if elem.tag == 'folder': - # clear parents from stack - parent= parentMap[elem] - while parent != stack[-1][0]: - stack.pop() - name = elem.find('name') - if name is None: - ok = False - continue - item = self._addFolder(stack[-1][1], name.text) - stack.append((elem, item)) - if elem.get('expanded', 'False').lower() == 'true': - item.setExpanded(True) - selectedItem = item if elem.get('selected', 'False').lower() == 'true' else selectedItem - - elif elem.tag == 'bookmark': - name = elem.find('name') - if name is None: - ok = False - continue - target = elem.find('target') - if target is None: - ok = False - continue - item = self._addBookmark(stack[-1][1], name.text, target.text) - selectedItem = item if elem.get('selected', 'False').lower() == 'true' else selectedItem + except IOError: + ok = False if selectedItem is not None: tree.scrollToItem(selectedItem) @@ -339,28 +393,21 @@ #********************************************************************* # #********************************************************************* - if __name__ == '__main__': import sys, os # try to restore saved bookmarks - rootElem = None - fpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'bookmarks.xml') - try: - tree = ET.parse(fpath) - except IOError: - pass - else: - rootElem = tree.getroot() - + bookmarksFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'bookmarks.xml') + # show dialog app = QtGui.QApplication(sys.argv) - w = DlgBookmarks(None, rootElem=rootElem) + w = DlgBookmarks(None, bookmarksFile=bookmarksFile) w.show() res = app.exec_() # save bookmarks - rootElem = w.saveBookmarks() - rootElem.write(fpath, encoding='utf-8') - - sys.exit(res) \ No newline at end of file + w.saveBookmarks(bookmarksFile) + + sys.exit(res) + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-21 11:08:54
|
Revision: 947 http://fclient.svn.sourceforge.net/fclient/?rev=947&view=rev Author: jUrner Date: 2008-08-21 11:09:03 +0000 (Thu, 21 Aug 2008) Log Message: ----------- add bookmarks dialog Added Paths: ----------- trunk/fclient/fclient/impl/lib/qt4ex/dlgbookmarks.py trunk/fclient/fclient/impl/lib/qt4ex/tpls/Ui_DlgBookmarks.py Added: trunk/fclient/fclient/impl/lib/qt4ex/dlgbookmarks.py =================================================================== --- trunk/fclient/fclient/impl/lib/qt4ex/dlgbookmarks.py (rev 0) +++ trunk/fclient/fclient/impl/lib/qt4ex/dlgbookmarks.py 2008-08-21 11:09:03 UTC (rev 947) @@ -0,0 +1,366 @@ +#******************************************************************************************** +#TODO: +# +# x. QTreeWidget does not clear selections when items are collapsed. so selected items will +# always be set to visible even if they where collapsed by the user before saving bookmarks +# x. clients may want to adjust label texts +# x. clients may want to adjust "target" edit box to a custom thingy +# +# x. fresh from boilerplate. not tested +# +#******************************************************************************************* +"""bookmarks dialog""" +from __future__ import absolute_import +if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below + import os; __path__ = [os.path.dirname(__file__)] + +from PyQt4 import QtCore, QtGui + +from xml.etree import cElementTree as ET + +from . import treewidgetwrap +from .tpls.Ui_DlgBookmarks import Ui_DlgBookmarks +#********************************************************************* +# +#********************************************************************* +class Actions(object): + + def __init__(self, parent): + + self.newBookmark = QtGui.QAction(parent) + parent.connect(self.newBookmark, QtCore.SIGNAL('triggered()'), parent.onNewBookmark) + self.newFolder = QtGui.QAction(parent) + parent.connect(self.newFolder, QtCore.SIGNAL('triggered()'), parent.onNewFolder) + self.deleteItem = QtGui.QAction(parent) + parent.connect(self.deleteItem, QtCore.SIGNAL('triggered()'), parent.onDeleteItem) + self.deleteItem.setEnabled(False) + + def retranslateUi(self, parent): + self.newBookmark.setText(parent.trUtf8('New bookmark')) + self.newFolder.setText(parent.trUtf8('New folder')) + self.deleteItem.setText(parent.trUtf8('Remove')) + + +class EventFilter(QtCore.QObject): + """event filter for the dialog""" + + def eventFilter(self, obj, event): + # filter return pressed on dlg subwidgets if desired + if event.type() == event.KeyPress: + if event.key() == QtCore.Qt.Key_Return: + dlg = self.parent() + if dlg.swallowReturnPressed(): + return True + return False + +#********************************************************************* +# +#********************************************************************* +class DlgBookmarks(QtGui.QDialog, Ui_DlgBookmarks): + + IdTree = 'tree' + IdEdName = 'edName' + IdEdTarget = 'edTarget' + + + ItemTypeFolder = 0 + ItemTypeItem = 1 + + def __init__(self, parent=None, rootElem=None): + QtGui.QDialog.__init__(self, parent) + + self.isCreated = False + self.dlgActions = Actions(self) + self.setupUi(self) + self.installEventFilter(EventFilter(self)) + + # setup tree + tree = self.controlById(self.IdTree) + tree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.connect(tree, QtCore.SIGNAL('customContextMenuRequested(const QPoint &)'), self.onTreeCustomContextMenu) + self.connect(tree, QtCore.SIGNAL('currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)'), self.onTreeCurrentItemChanged) + + # setup edit boxes + edName = self.controlById(self.IdEdName) + self.connect(edName, QtCore.SIGNAL('returnPressed()'), self.onEdNameReturnPressed) + edName.setEnabled(False) + + edTarget = self.controlById(self.IdEdTarget) + self.connect(edTarget, QtCore.SIGNAL('returnPressed()'), self.onEdTargetReturnPressed) + edTarget.setEnabled(False) + + # init bookmarks if desired + #TODO: move to a better place to speed up dlg show + if rootElem is not None: + self.restoreBookmarks(rootElem) + + ################## + ## private methods + ################## + def _addBookmark(self, parent, name=None, target=None): + item= QtGui.QTreeWidgetItem(parent, self.ItemTypeItem) + item.setText(0, self.nameForNewItem(self.ItemTypeItem) if name is None else name) + item.setText(1, QtCore.QString('') if target is None else target) + item.setIcon(0, self.iconForItem(self.ItemTypeItem, QtCore.QString(''))) + item.setFlags(item.flags() & ~(QtCore.Qt.ItemIsDropEnabled | QtCore.Qt.ItemIsEditable)) + return item + + def _addFolder(self, parent, name=None): + item= QtGui.QTreeWidgetItem(parent, self.ItemTypeFolder) + item.setText(0, self.nameForNewItem(self.ItemTypeFolder) if name is None else name) + item.setIcon(0, self.iconForItem(self.ItemTypeFolder, QtCore.QString(''))) + item.setFlags(item.flags() & ~QtCore.Qt.ItemIsEditable) + return item + + ################## + ## methods + ################## + def retranslateUi(self, this): + Ui_DlgBookmarks.retranslateUi(self, this) + self.dlgActions.retranslateUi(self) + tree = self.controlById(self.IdTree) + tree.setHeaderLabels([ + self.trUtf8('Name'), + self.trUtf8('Target'), + ]) + + def controlById(self, idControl): + return getattr(self, idControl) + + def itemIsFolder(self, item): + tree = self.controlById(self.IdTree) + if item == tree.invisibleRootItem() or item.type() == self.ItemTypeFolder: + return True + return False + + def saveBookmarks(self): + """saves the bookmarks + @return: (ElementTree.Element) root + """ + tree = self.controlById(self.IdTree) + enum = treewidgetwrap.walkItem(tree.invisibleRootItem()) + rootItem = enum.next() + rootElem = ET.Element('bookmarks', columnWidthName=str(tree.columnWidth(0))) + stack = [(rootElem, rootItem), ] + + selectedItems = tree.selectedItems() + selectedItem = selectedItems[0] if selectedItems else None + + for item in enum: + if item.type() == self.ItemTypeFolder: + # clear parents from stack + parent = item.parent() + if parent is None: + parent = rootItem + while parent != stack[-1][1]: + stack.pop() + elem = ET.SubElement(stack[-1][0], 'folder', expanded=str(item.isExpanded()), selected=str(item is selectedItem)) + stack.append((elem, item)) + elemName = ET.SubElement(elem, 'name') + elemName.text = unicode(item.text(0)) + else: + elem = ET.SubElement(stack[-1][0], 'bookmark', selected=str(item is selectedItem)) + elemName = ET.SubElement(elem, 'name') + elemName.text = unicode(item.text(0)) + elemTarget = ET.SubElement(elem, 'target') + elemTarget.text = unicode(item.text(1)) + + return ET.ElementTree(rootElem) + + + #TODO: in depth error checks + def restoreBookmarks(self, rootElem): + """sets the bookmarks of the dialog + @param rootElem: (ElementTree.Element) root + @return: (bool) True if errors occured, False otherwise + """ + tree = self.controlById(self.IdTree) + tree.clear() + rootItem = tree.invisibleRootItem() + enum = rootElem.getiterator() + rootElem = enum.next() + parentMap = dict((c, p) for p in rootElem.getiterator() for c in p) + ok = True + stack = [(rootElem, rootItem), ] + selectedItem = None + + if rootElem.tag != 'bookmarks': + ok = False + else: + + # restore properties... + columnWidthName = rootElem.get('columnWidthName', None) + try: + tree.setColumnWidth(0, int(columnWidthName)) + except ValueError: + pass + + # restore elems.. + for elem in enum: + if elem.tag == 'folder': + # clear parents from stack + parent= parentMap[elem] + while parent != stack[-1][0]: + stack.pop() + name = elem.find('name') + if name is None: + ok = False + continue + item = self._addFolder(stack[-1][1], name.text) + stack.append((elem, item)) + if elem.get('expanded', 'False').lower() == 'true': + item.setExpanded(True) + selectedItem = item if elem.get('selected', 'False').lower() == 'true' else selectedItem + + elif elem.tag == 'bookmark': + name = elem.find('name') + if name is None: + ok = False + continue + target = elem.find('target') + if target is None: + ok = False + continue + item = self._addBookmark(stack[-1][1], name.text, target.text) + selectedItem = item if elem.get('selected', 'False').lower() == 'true' else selectedItem + + if selectedItem is not None: + tree.scrollToItem(selectedItem) + tree.setCurrentItem(selectedItem) + return ok + + ####################### + ## overwrite to customize the dialog + ####################### + def nameForNewItem(self, itemType): + """should return the default name for a new item + @param itemType: (ItemType*) one of the ItemType* consts + @return: (QString) + """ + if itemType == self.ItemTypeFolder: + return self.trUtf8('New folder') + return self.trUtf8('Unnamed') + + + def iconForItem(self, itemType, itemTarget): + """"should return the icon associated to an item + @param itemType: (ItemType*) one of the ItemType* consts + @param itemTarget: (QString) the target the item points to + @return (QIcon) + """ + return QtGui.QIcon() + + + def swallowReturnPressed(self): + """called to check if return pressed on a subwidget should be swallowed or not + @return: (bool) True if so, False otherwise + @note: use this to swallow for example return presses in edit boxes to not end the dialog + """ + return self.controlById(self.IdEdName).hasFocus() or self.controlById(self.IdEdTarget).hasFocus() + + ###################### + ## event handlers + ###################### + def onDeleteItem(self): + tree = self.controlById(self.IdTree) + item = tree.currentItem() + if item is not None: + parent = item.parent() + if parent is None: + parent = tree.invisibleRootItem() + parent.takeChild(parent.indexOfChild(item)) + + def onEdNameReturnPressed(self): + ed = self.controlById(self.IdEdName) + tree = self.controlById(self.IdTree) + item = tree.currentItem() + if item is not None: + item.setText(0, ed.text()) + + def onEdTargetReturnPressed(self): + ed = self.controlById(self.IdEdTarget) + tree = self.controlById(self.IdTree) + item = tree.currentItem() + if item is not None: + item.setText(1, ed.text()) + item.setIcon(0, self.iconForItem(self.ItemTypeItem, QtCore.QString(''))) + + + def onNewBookmark(self): + tree = self.controlById(self.IdTree) + parent = tree.currentItem() + if parent is None: + parent = tree.invisibleRootItem() + item = self._addBookmark(parent) + tree.scrollToItem(item) + tree.setCurrentItem(item) + + def onNewFolder(self): + tree = self.controlById(self.IdTree) + parent = tree.currentItem() + if parent is None: + parent = tree.invisibleRootItem() + + item = self._addFolder(parent) + tree.scrollToItem(item) + tree.setCurrentItem(item) + + + def onTreeCustomContextMenu(self, pt): + tree = self.controlById(self.IdTree) + pt = tree.viewport().mapToGlobal(pt) + + menu = QtGui.QMenu(self) + + menu.addAction(self.dlgActions.newBookmark) + menu.addAction(self.dlgActions.newFolder) + menu.addSeparator() + menu.addAction(self.dlgActions.deleteItem) + + menu.exec_(pt) + + + def onTreeCurrentItemChanged(self, current, prev): + edName = self.controlById(self.IdEdName) + edTarget = self.controlById(self.IdEdTarget) + tree = self.controlById(self.IdTree) + + itemIsFolder = True if current is None else self.itemIsFolder(current) + + edName.setEnabled(not current is None) + edTarget.setEnabled(not current is None and not itemIsFolder) + edName.setText('' if current is None else current.text(0)) + edTarget.setText('' if current is None else current.text(1)) + + self.dlgActions.newBookmark.setEnabled(itemIsFolder) + self.dlgActions.newFolder.setEnabled(itemIsFolder) + self.dlgActions.deleteItem.setEnabled(not current is None) + +#********************************************************************* +# +#********************************************************************* + +if __name__ == '__main__': + import sys, os + + # try to restore saved bookmarks + rootElem = None + fpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'bookmarks.xml') + try: + tree = ET.parse(fpath) + except IOError: + pass + else: + rootElem = tree.getroot() + + # show dialog + app = QtGui.QApplication(sys.argv) + w = DlgBookmarks(None, rootElem=rootElem) + w.show() + res = app.exec_() + + # save bookmarks + rootElem = w.saveBookmarks() + rootElem.write(fpath, encoding='utf-8') + + sys.exit(res) \ No newline at end of file Added: trunk/fclient/fclient/impl/lib/qt4ex/tpls/Ui_DlgBookmarks.py =================================================================== --- trunk/fclient/fclient/impl/lib/qt4ex/tpls/Ui_DlgBookmarks.py (rev 0) +++ trunk/fclient/fclient/impl/lib/qt4ex/tpls/Ui_DlgBookmarks.py 2008-08-21 11:09:03 UTC (rev 947) @@ -0,0 +1,81 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file '/home/me/src/fclient/trunk/fclient/fclient/impl/lib/qt4ex/tpls/DlgBookmarks.ui' +# +# Created: Thu Aug 21 13:07:31 2008 +# by: PyQt4 UI code generator 4.4.2 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +class Ui_DlgBookmarks(object): + def setupUi(self, DlgBookmarks): + DlgBookmarks.setObjectName("DlgBookmarks") + DlgBookmarks.resize(400,567) + self.gridLayout = QtGui.QGridLayout(DlgBookmarks) + self.gridLayout.setObjectName("gridLayout") + self.labelHeader = QtGui.QLabel(DlgBookmarks) + self.labelHeader.setObjectName("labelHeader") + self.gridLayout.addWidget(self.labelHeader,0,0,1,1) + self.tree = QtGui.QTreeWidget(DlgBookmarks) + self.tree.setDragEnabled(True) + self.tree.setDragDropMode(QtGui.QAbstractItemView.InternalMove) + self.tree.setColumnCount(2) + self.tree.setObjectName("tree") + self.gridLayout.addWidget(self.tree,1,0,1,1) + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.verticalLayout = QtGui.QVBoxLayout() + self.verticalLayout.setObjectName("verticalLayout") + self.label = QtGui.QLabel(DlgBookmarks) + self.label.setObjectName("label") + self.verticalLayout.addWidget(self.label) + self.label_2 = QtGui.QLabel(DlgBookmarks) + self.label_2.setObjectName("label_2") + self.verticalLayout.addWidget(self.label_2) + self.horizontalLayout.addLayout(self.verticalLayout) + self.verticalLayout_2 = QtGui.QVBoxLayout() + self.verticalLayout_2.setObjectName("verticalLayout_2") + self.edName = QtGui.QLineEdit(DlgBookmarks) + self.edName.setObjectName("edName") + self.verticalLayout_2.addWidget(self.edName) + self.edTarget = QtGui.QLineEdit(DlgBookmarks) + self.edTarget.setObjectName("edTarget") + self.verticalLayout_2.addWidget(self.edTarget) + self.horizontalLayout.addLayout(self.verticalLayout_2) + self.gridLayout.addLayout(self.horizontalLayout,2,0,1,1) + self.line = QtGui.QFrame(DlgBookmarks) + self.line.setFrameShape(QtGui.QFrame.HLine) + self.line.setFrameShadow(QtGui.QFrame.Sunken) + self.line.setObjectName("line") + self.gridLayout.addWidget(self.line,3,0,1,1) + self.buttonBox = QtGui.QDialogButtonBox(DlgBookmarks) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) + self.buttonBox.setObjectName("buttonBox") + self.gridLayout.addWidget(self.buttonBox,4,0,1,1) + + self.retranslateUi(DlgBookmarks) + QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("accepted()"),DlgBookmarks.accept) + QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("rejected()"),DlgBookmarks.reject) + QtCore.QMetaObject.connectSlotsByName(DlgBookmarks) + + def retranslateUi(self, DlgBookmarks): + DlgBookmarks.setWindowTitle(QtGui.QApplication.translate("DlgBookmarks", "Edit bookmarks..", None, QtGui.QApplication.UnicodeUTF8)) + self.labelHeader.setText(QtGui.QApplication.translate("DlgBookmarks", "Edit bookmarks", None, QtGui.QApplication.UnicodeUTF8)) + self.tree.headerItem().setText(0,QtGui.QApplication.translate("DlgBookmarks", "1", None, QtGui.QApplication.UnicodeUTF8)) + self.tree.headerItem().setText(1,QtGui.QApplication.translate("DlgBookmarks", "2", None, QtGui.QApplication.UnicodeUTF8)) + self.label.setText(QtGui.QApplication.translate("DlgBookmarks", "Name:", None, QtGui.QApplication.UnicodeUTF8)) + self.label_2.setText(QtGui.QApplication.translate("DlgBookmarks", "Target:", None, QtGui.QApplication.UnicodeUTF8)) + + +if __name__ == "__main__": + import sys + app = QtGui.QApplication(sys.argv) + DlgBookmarks = QtGui.QDialog() + ui = Ui_DlgBookmarks() + ui.setupUi(DlgBookmarks) + DlgBookmarks.show() + sys.exit(app.exec_()) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-08-21 11:08:26
|
Revision: 946 http://fclient.svn.sourceforge.net/fclient/?rev=946&view=rev Author: jUrner Date: 2008-08-21 11:08:36 +0000 (Thu, 21 Aug 2008) Log Message: ----------- add bookmarks dialog Added Paths: ----------- trunk/fclient/fclient/impl/lib/qt4ex/tpls/DlgBookmarks.ui Added: trunk/fclient/fclient/impl/lib/qt4ex/tpls/DlgBookmarks.ui =================================================================== --- trunk/fclient/fclient/impl/lib/qt4ex/tpls/DlgBookmarks.ui (rev 0) +++ trunk/fclient/fclient/impl/lib/qt4ex/tpls/DlgBookmarks.ui 2008-08-21 11:08:36 UTC (rev 946) @@ -0,0 +1,132 @@ +<ui version="4.0" > + <class>DlgBookmarks</class> + <widget class="QDialog" name="DlgBookmarks" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>567</height> + </rect> + </property> + <property name="windowTitle" > + <string>Edit bookmarks..</string> + </property> + <layout class="QGridLayout" name="gridLayout" > + <item row="0" column="0" > + <widget class="QLabel" name="labelHeader" > + <property name="text" > + <string>Edit bookmarks</string> + </property> + </widget> + </item> + <item row="1" column="0" > + <widget class="QTreeWidget" name="tree" > + <property name="dragEnabled" > + <bool>true</bool> + </property> + <property name="dragDropMode" > + <enum>QAbstractItemView::InternalMove</enum> + </property> + <property name="columnCount" > + <number>2</number> + </property> + <column> + <property name="text" > + <string>1</string> + </property> + </column> + <column> + <property name="text" > + <string>2</string> + </property> + </column> + </widget> + </item> + <item row="2" column="0" > + <layout class="QHBoxLayout" name="horizontalLayout" > + <item> + <layout class="QVBoxLayout" name="verticalLayout" > + <item> + <widget class="QLabel" name="label" > + <property name="text" > + <string>Name:</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_2" > + <property name="text" > + <string>Target:</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_2" > + <item> + <widget class="QLineEdit" name="edName" /> + </item> + <item> + <widget class="QLineEdit" name="edTarget" /> + </item> + </layout> + </item> + </layout> + </item> + <item row="3" column="0" > + <widget class="Line" name="line" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="4" column="0" > + <widget class="QDialogButtonBox" name="buttonBox" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons" > + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>DlgBookmarks</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel" > + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel" > + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>DlgBookmarks</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel" > + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel" > + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |