[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8695 - in trunk/gnue-forms/src/uidrivers/qt: . widgets widgets/f
From: |
johannes |
Subject: |
[gnue] r8695 - in trunk/gnue-forms/src/uidrivers/qt: . widgets widgets/form |
Date: |
Mon, 25 Sep 2006 08:18:04 -0500 (CDT) |
Author: johannes
Date: 2006-09-25 08:18:03 -0500 (Mon, 25 Sep 2006)
New Revision: 8695
Added:
trunk/gnue-forms/src/uidrivers/qt/dialogs.py
Modified:
trunk/gnue-forms/src/uidrivers/qt/ToolBar.py
trunk/gnue-forms/src/uidrivers/qt/UIdriver.py
trunk/gnue-forms/src/uidrivers/qt/widgets/entry.py
trunk/gnue-forms/src/uidrivers/qt/widgets/form/widget.py
Log:
Started refactoring of UI driver.
Added an exception dialog (so debugging gets easier :)
issue88 in-progress
Modified: trunk/gnue-forms/src/uidrivers/qt/ToolBar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt/ToolBar.py 2006-09-25 09:27:22 UTC
(rev 8694)
+++ trunk/gnue-forms/src/uidrivers/qt/ToolBar.py 2006-09-25 13:18:03 UTC
(rev 8695)
@@ -59,7 +59,7 @@
print "** WARNING: Cannot add '%s' to toolbar; no icon" %
userAction.event
return
- action = QAction(self.toolbar, name)
+ action = QAction(self.toolbar)
action.setIconSet(icon)
action.setText(name)
if userAction.canToggle:
Modified: trunk/gnue-forms/src/uidrivers/qt/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt/UIdriver.py 2006-09-25 09:27:22 UTC
(rev 8694)
+++ trunk/gnue-forms/src/uidrivers/qt/UIdriver.py 2006-09-25 13:18:03 UTC
(rev 8695)
@@ -1,6 +1,9 @@
+# GNU Enterprise Forms - QT UI Driver - User Interface
#
-# This file is part of GNU Enterprise.
+# Copyright 2001-2006 Free Software Foundation
#
+# This file is part of GNU Enterprise
+#
# GNU Enterprise is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
@@ -16,27 +19,20 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# Copyright 2000-2006 Free Software Foundation
-#
-# FILE:
-# UIqt.py
-#
-# DESCRIPTION:
+# $Id: $
"""
A pyQT based user interface driver for GNUe forms.
"""
-# NOTES:
-#
import sys
-import string
from gnue.forms.uidrivers._base import Exceptions
try:
from qt import *
except ImportError:
- raise Exceptions.DriverNotSupported, _("The GNUe-Forms QT3 driver requires
PyQT.")
+ raise Exceptions.DriverNotSupported, \
+ _("The GNUe-Forms QT3 driver requires PyQT.")
from gnue.common import events
from gnue.common.apps import GConfig
@@ -52,132 +48,120 @@
from gnue.forms.uidrivers.qt.common import _eventObjToQtWindow,
setWidgetBaseFont
from common import *
+from gnue.forms.uidrivers.qt import dialogs
+# =============================================================================
+# This class implements the User Interface for QT3
+# =============================================================================
-#
-# GFUserInterface
-#
-# The public interface to the User Interface
-# All UIs must provide this class
-#
class GFUserInterface(commonToolkit.GFUserInterface):
- def initialize(self):
+ # -------------------------------------------------------------------------
+ # Initialization
+ # -------------------------------------------------------------------------
- self._disabledColour = None
+ def initialize(self):
- self._qtapp = getQtApp()
+ self._disabledColour = None
+ self._qtapp = getQtApp()
+ fdb = QFontDatabase()
- fdb = QFontDatabase()
+ font = QFont("Courier 10 Pitch", int(gConfigForms('pointSize')))
+ font.setFixedPitch(True)
- #
- # TODO: Wouldn't it be nice if this actually picked a font
- # TODO: that didn't suck.
- #
- #fixedFont = ""
- #for family in fdb.families():
- # for style in fdb.styles(family):
- # if fdb.isFixedPitch(family,style):
- # fixedFont = fdb.font(family,style,int(gConfigForms('pointSize')))
- # break
- # if fixedFont != "":
- # break
- #font = fixedFont
+ font.setPointSize(int(gConfigForms('pointSize')))
+ setWidgetBaseFont(font)
- font = QFont("Courier 10 Pitch", int(gConfigForms('pointSize')))
- font.setFixedPitch(True)
+ #
+ # SplashScreen
+ #
+ if not self._disableSplash:
+ self.splash = QTSplashScreen()
- #info = QFontInfo(font)
- #print "DATA:", info.family(),info.fixedPitch()
- font.setPointSize(int(gConfigForms('pointSize')))
- setWidgetBaseFont(font)
+ fm = QFontMetrics(font)
+ # TODO: Making some assumptions here!!
+ maxWidth=0
+ checkchars = string.printable
+ for letter in checkchars:
+ width = fm.width("W")
+ maxWidth = max(maxWidth,width)
- #
- # SplashScreen
- #
- if not self._disableSplash:
- self.splash = QTSplashScreen()
+ print "Max Width = ", maxWidth, fm.width("i")
+ #maxWidth=fm.width("W")
+ maxHeight = fm.height()
+ maxDescent = fm.descent()
+ maxLeading = fm.leading()
- fm = QFontMetrics(font)
- # TODO: Making some assumptions here!!
- maxWidth=0
- checkchars = string.printable
- for letter in checkchars:
- width = fm.width("W")
- maxWidth = max(maxWidth,width)
-
- print "Max Width = ", maxWidth, fm.width("i")
- #maxWidth=fm.width("W")
- maxHeight = fm.height()
- maxDescent = fm.descent()
- maxLeading = fm.leading()
-
- # The pixel width of text inside a widget
- self.textWidth = int(maxWidth+maxLeading)
+ # The pixel width of text inside a widget
+ self.textWidth = int(maxWidth+maxLeading)
- # The pixel height of text inside a widget
- self.textHeight = int(maxHeight+maxDescent)
+ # The pixel height of text inside a widget
+ self.textHeight = int(maxHeight+maxDescent)
- # The pixel width of a 1 char widget (for things like buttons)
- self.widgetWidth = self.textWidth
+ # The pixel width of a 1 char widget (for things like buttons)
+ self.widgetWidth = self.textWidth
- # The pixel height of a 1 char widget (for things like buttons)
- self.widgetHeight = self.textHeight + 4
+ # The pixel height of a 1 char widget (for things like buttons)
+ self.widgetHeight = self.textHeight + 4
- #############################################################################
- #
- # Incoming Event Processors
- #
- # Processes the incoming events from other objects
- # From here down should be nothing but eventListeners listed
+ # -------------------------------------------------------------------------
+ # Start the application's main loop
+ # -------------------------------------------------------------------------
- #
- # mainLoop
- #
- # The primary loop of the user interface. Called once the UI is
- # fully activated
- #
- def mainLoop(self):
- self._qtapp.exec_loop()
+ def mainLoop(self):
+ """
+ Start the main loop of the current application instance
+ """
- #
- # Clipboard routines
- #
- # If a particular UI has a system-wide clipboard,
- # these methods should be overridden to use that
- # clipboard.
- #
- def getClipboardContents(self, event):
- event.__result__ = str(self._qtapp.clipboard().text())
+ assert gEnter(6)
+ self._qtapp.exec_loop()
- def setClipboardContents(self, event):
- self._qtapp.clipboard().setText(event.text)
+ assert gLeave(6)
+ # -------------------------------------------------------------------------
+ # Clipbard routines
+ # -------------------------------------------------------------------------
- #############################################################################
- #
- # Internal Event Processors
- #
- # Processes the events from the widget set
- #
- #
- # closeTrap
- #
- # intercepts the applications closure and generates an event to the form
requesting
- # closure. Allows the form to control closure. If the form approves it'll
send
- # back an event closing the application
- #`
- def closeTrap(self,event):
- if event.CanVeto():
- self.dispatchEvent('requestEXIT',_form=self._form)
- else:
- object = _eventObjToQtWindow(event)
- object.Destroy()
-
- def _ui_show_error_(self, message):
- QMessageBox.critical(None, "GNU Enterprise", message)
+ def getClipboardContents(self, event):
+ event.__result__ = str(self._qtapp.clipboard().text())
- def _ui_show_exception_(self, group, name, message, detail):
- self._ui_show_error_(detail)
+ # -------------------------------------------------------------------------
+
+ def setClipboardContents(self, event):
+ self._qtapp.clipboard().setText(event.text)
+
+
+ # -------------------------------------------------------------------------
+ # Show a simple error message
+ # -------------------------------------------------------------------------
+
+ def _ui_show_error_(self, message):
+
+ QMessageBox.critical(None, "GNU Enterprise", message)
+
+
+ # -------------------------------------------------------------------------
+ # Show Exception dialog
+ # -------------------------------------------------------------------------
+
+ def _ui_show_exception_(self, group, name, message, detail):
+
+ # TODO: check for splash screen
+ dlg = dialogs.ExceptionDialog(group, name, message, detail)
+ dlg.exec_loop()
+
+
+ # -------------------------------------------------------------------------
+ # Exit the application
+ # -------------------------------------------------------------------------
+
+ def _ui_exit_(self):
+
+ assert gEnter(6)
+
+ for child in self._children:
+ child.mainWindow.close()
+
+ assert gLeave(6)
Added: trunk/gnue-forms/src/uidrivers/qt/dialogs.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt/dialogs.py 2006-09-25 09:27:22 UTC
(rev 8694)
+++ trunk/gnue-forms/src/uidrivers/qt/dialogs.py 2006-09-25 13:18:03 UTC
(rev 8695)
@@ -0,0 +1,115 @@
+# GNU Enterprise Forms - QT3 UI Driver - UI specific dialogs
+#
+# Copyright 2001-2006 Free Software Foundation
+#
+# This file is part of GNU Enterprise
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+"""
+Implementation of some common dialogs for the QT3 driver
+"""
+
+import qt
+
+__all__ = ['ExceptionDialog']
+
+# =============================================================================
+# Exception display dialog
+# =============================================================================
+
+class ExceptionDialog(qt.QDialog):
+ """
+ Dialog for displaying exceptions. The traceback of the exception is
+ available via a detail button.
+ """
+
+ _TITLE = {'system' : _("GNUe Internal System Error"),
+ 'admin' : _("GNUe Unexpected Error"),
+ 'application': _("GNUe Application Error")}
+
+ _FORMAT = {
+ 'system': u_("An unexpected internal error has occured:\n%s.\n"
+ "This means you have found a bug in GNU Enterprise. "
+ "Please report it to address@hidden"),
+ 'admin': u_("An unexpected error has occured:\n%s.\n"
+ "Please contact your system administrator."),
+ 'application': u_("An unexpected error has occured:\n%s.\n"
+ "Please contact your system administrator.")}
+
+ # -------------------------------------------------------------------------
+ # Constructor
+ # -------------------------------------------------------------------------
+
+ def __init__ (self, group, name, message, detail):
+
+ qt.QDialog.__init__(self)
+
+ self.vbox = qt.QVBoxLayout(self, 4)
+
+ hbox = qt.QHBoxLayout(5)
+ self.vbox.addLayout(hbox, 0)
+
+ pxm = qt.QMessageBox.standardIcon(qt.QMessageBox.Critical)
+ self.icon = qt.QLabel('', self)
+ self.icon.setPixmap(pxm)
+ hbox.addWidget(self.icon, 0)
+
+ self.msg = qt.QLabel(self._FORMAT.get(group) % message, self)
+ hbox.addWidget(self.msg, 1)
+
+ self.ext = qt.QMultiLineEdit(self)
+ self.ext.setText(detail)
+ self.ext.setReadOnly(True)
+
+ self._ext_visible = False
+ self.setExtension(self.ext)
+ self.setOrientation(qt.Qt.Vertical)
+
+ sep = qt.QFrame(self, "separatorline")
+ sep.setFrameStyle(qt.QFrame.HLine | qt.QFrame.Sunken)
+ self.vbox.addWidget(sep, 0)
+
+ bbox = qt.QHBoxLayout()
+ bbox.addStretch(1)
+
+ self.cbtn = qt.QPushButton(u_("Close"), self)
+ self.connect(self.cbtn, qt.SIGNAL('clicked()'),
+ self.reject)
+ bbox.addWidget(self.cbtn, 0)
+
+ self.det = qt.QPushButton(u_(">> Detail"), self)
+ self.connect(self.det, qt.SIGNAL('clicked()'),
+ self.__toggle_detail)
+ bbox.addWidget(self.det, 0)
+
+ self.vbox.addLayout(bbox, 0)
+
+ self.setCaption(self._TITLE.get(group, u'Error'))
+
+ # -------------------------------------------------------------------------
+
+ def __toggle_detail(self):
+
+ view = not self._ext_visible
+ self._ext_visible = view
+ if view:
+ self.det.setText (u_('<< Detail'))
+ else:
+ self.det.setText (u_('>> Detail'))
+
+ self.showExtension(view)
Property changes on: trunk/gnue-forms/src/uidrivers/qt/dialogs.py
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/gnue-forms/src/uidrivers/qt/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt/widgets/entry.py 2006-09-25 09:27:22 UTC
(rev 8694)
+++ trunk/gnue-forms/src/uidrivers/qt/widgets/entry.py 2006-09-25 13:18:03 UTC
(rev 8695)
@@ -99,12 +99,6 @@
self.itemWidth,self.itemHeight)
-## # Attach the events to our entry and call it a night...
-## if event.initialize:
-## self._eventHandler = event.eventHandler
-## _setDefaultEventHandlers(newWidget, event.eventHandler,
event.initialize,self._uiDriver)
-
-
return newWidget
Modified: trunk/gnue-forms/src/uidrivers/qt/widgets/form/widget.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt/widgets/form/widget.py 2006-09-25
09:27:22 UTC (rev 8694)
+++ trunk/gnue-forms/src/uidrivers/qt/widgets/form/widget.py 2006-09-25
13:18:03 UTC (rev 8695)
@@ -245,3 +245,6 @@
if title is None:
title = _MBOX_KIND [kind]['title']
result = boxClass (None, title, lineWrap(message,80))
+
+ def _ui_close_(self):
+ self.mainWindow.hide()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8695 - in trunk/gnue-forms/src/uidrivers/qt: . widgets widgets/form,
johannes <=