SF.net SVN: fclient: [601] trunk/fclient/src/fclient/Ui_ViewLogger.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-07-12 20:00:05
|
Revision: 601
http://fclient.svn.sourceforge.net/fclient/?rev=601&view=rev
Author: jUrner
Date: 2008-07-12 13:00:08 -0700 (Sat, 12 Jul 2008)
Log Message:
-----------
customize context menu
Modified Paths:
--------------
trunk/fclient/src/fclient/Ui_ViewLogger.py
Modified: trunk/fclient/src/fclient/Ui_ViewLogger.py
===================================================================
--- trunk/fclient/src/fclient/Ui_ViewLogger.py 2008-07-12 19:59:24 UTC (rev 600)
+++ trunk/fclient/src/fclient/Ui_ViewLogger.py 2008-07-12 20:00:08 UTC (rev 601)
@@ -7,7 +7,7 @@
import sys
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
-from PyQt4 import QtGui
+from PyQt4 import QtCore, QtGui
from . import config
@@ -21,9 +21,31 @@
_key_ = config.IdViewLoggerWidget
_settings_ = (
- ('MaxLines', 'UInt', 1000),
+ ('MaxLines', 'UInt', 1000, config.SettingScopeUser),
)
+#***********************************************************************
+#
+#***********************************************************************
+#TODO: more here...
+class TextEditActionClear(QtGui.QAction):
+
+ def __init__(self, menu, ed):
+ QtGui.QAction.__init__(self, ed)
+ self.setText(self.trUtf8('Clear'))
+ ##self.setShortcut(self.trUtf8("del"))
+ self.connect(self, QtCore.SIGNAL('triggered(bool)'), self.handleTriggered)
+ self.connect(menu, QtCore.SIGNAL('aboutToShow()'), self.handleMenuAboutToShow)
+
+ self.ed = ed
+
+ def handleMenuAboutToShow(self):
+ self.setEnabled(not self.ed.document().isEmpty())
+
+ def handleTriggered(self, isChecked):
+ self.ed.clear()
+
+
#***********************************************************************
#
#***********************************************************************
@@ -53,6 +75,7 @@
self.settings.restore()
ed = self.controlById(self.IdEddLogger)
ed.document().setMaximumBlockCount(self.settings.value('MaxLines'))
+ ed.contextMenuEvent = self.edLoggerContextMenuEvent
self.loggingHandler = self.MyLoggingHandler(self.addMessage)
logging.getLogger('').addHandler(self.loggingHandler)
@@ -65,6 +88,22 @@
ed = self.controlById(self.IdEddLogger)
ed.append(text)
+
+#########################################
+ ## overwritten events
+ #########################################
+ def edLoggerContextMenuEvent(self, event):
+ """customize context menu of the logger QTextEdit"""
+ ed = self.controlById(self.IdEddLogger)
+ menu = ed.createStandardContextMenu()
+
+ act = TextEditActionClear(menu, ed)
+ menu.addAction(act)
+
+ menu.exec_(event.globalPos())
+
+
+
#**********************************************************************************
#
#**********************************************************************************
@@ -91,14 +130,4 @@
def close(self):
pass
-#**********************************************************************************
-#
-#**********************************************************************************
-if __name__ == '__main__':
- import sys
-
- app = QtGui.QApplication(sys.argv)
- w = ViewLoggerWidget(None)
- w.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.
|