SF.net SVN: fclient:[949] trunk/fclient/fclient/impl/ViewBrowser/dlgs
Status: Pre-Alpha
Brought to you by:
jurner
|
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.
|