[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8939 - in trunk/gnue-forms/src/uidrivers/qt3: . widgets
From: |
johannes |
Subject: |
[gnue] r8939 - in trunk/gnue-forms/src/uidrivers/qt3: . widgets |
Date: |
Fri, 27 Oct 2006 03:53:17 -0500 (CDT) |
Author: johannes
Date: 2006-10-27 03:53:16 -0500 (Fri, 27 Oct 2006)
New Revision: 8939
Modified:
trunk/gnue-forms/src/uidrivers/qt3/QTApp.py
trunk/gnue-forms/src/uidrivers/qt3/UIdriver.py
trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py
Log:
Fixed handling of form.close(). Only start a single main loop
Modified: trunk/gnue-forms/src/uidrivers/qt3/QTApp.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/QTApp.py 2006-10-27 06:50:50 UTC (rev
8938)
+++ trunk/gnue-forms/src/uidrivers/qt3/QTApp.py 2006-10-27 08:53:16 UTC (rev
8939)
@@ -1,6 +1,9 @@
+# GNU Enterprise Forms - QT 3 UI driver - Application object
#
-# 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,38 +19,62 @@
# 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:
-"""
-A QT-based user interface driver for GNUe forms.
-"""
-# NOTES:
-#
+# $Id$
-from gnue.common.apps import GDebug
import sys
+import qt
-from qt import *
+from gnue.common.apps import GDebug
__QtApp = None
+# -----------------------------------------------------------------------------
+# get the global application object
+# -----------------------------------------------------------------------------
+
def getQtApp():
+ """
+ Get the global qt application instance or (if none has been created) build
+ a new one
+ """
global __QtApp
if not __QtApp:
assert gDebug(6,"QtApp initializing")
__QtApp = GFqtApp()
+
return __QtApp
-class GFqtApp(QApplication):
- def __init__(self):
- QApplication.__init__(self, sys.argv)
- QObject.connect(self, SIGNAL('lastWindowClosed()'),
- self, SLOT('quit()'))
- # TODO: self.setFont() will set fonts for all child widgets!!!
+# =============================================================================
+# QT Application
+# =============================================================================
+class GFqtApp(qt.QApplication):
+ """
+ The QT Application object as used by GNUe Forms
+ """
+
+ # -------------------------------------------------------------------------
+ # Constructor
+ # -------------------------------------------------------------------------
+
+ def __init__(self):
+
+ self.__started = False
+ qt.QApplication.__init__(self, sys.argv)
+ self.connect(self, qt.SIGNAL('lastWindowClosed()'), self.quit)
+
+
+ # -------------------------------------------------------------------------
+ # Start the main loop
+ # -------------------------------------------------------------------------
+
+ def start(self):
+ """
+ Start the applications main loop, but do it only once !
+ """
+
+ if not self.__started:
+ self.__started = True
+ self.exec_loop()
Modified: trunk/gnue-forms/src/uidrivers/qt3/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/UIdriver.py 2006-10-27 06:50:50 UTC
(rev 8938)
+++ trunk/gnue-forms/src/uidrivers/qt3/UIdriver.py 2006-10-27 08:53:16 UTC
(rev 8939)
@@ -123,7 +123,7 @@
assert gEnter(6)
- self._qtapp.exec_loop()
+ self._qtapp.start()
assert gLeave(6)
@@ -185,6 +185,7 @@
assert gEnter(6)
for child in self._children:
+ child.main_window._closing_ = True
child.main_window.close()
assert gLeave(6)
Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py 2006-10-27 06:50:50 UTC
(rev 8938)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py 2006-10-27 08:53:16 UTC
(rev 8939)
@@ -28,7 +28,7 @@
import os
from gnue.common.apps import GConfig
-from gnue.forms.uidrivers.qt3 import dialogs
+from gnue.forms.uidrivers.qt3 import dialogs, QTApp
from gnue.forms.uidrivers.qt3.MenuBar import MenuBar
from gnue.forms.uidrivers.qt3.ToolBar import ToolBar
from gnue.forms.uidrivers.qt3.widgets._base import UIHelper
@@ -86,9 +86,9 @@
if self._form.style != 'dialog':
self.main_window = self._uiDriver._parentContainer
if not self.main_window:
- self.main_window = qt.QMainWindow()
+ self.main_window = MainWindow(self)
else:
- self.main_window = qt.QDialog()
+ self.main_window = Dialog(self)
self.main_window.setCaption(self._form.title)
@@ -245,8 +245,7 @@
"""
Ring the system bell
"""
- # TODO: QApplication.beep()
- pass
+ QTApp.getQtApp().beep()
# -------------------------------------------------------------------------
@@ -355,9 +354,81 @@
"""
self.main_window.hide()
+# =============================================================================
+# Window class
+# =============================================================================
+class MainWindow(qt.QMainWindow):
+ """
+ A forms main window
+ """
+ # -------------------------------------------------------------------------
+ # Constructor
+ # -------------------------------------------------------------------------
+
+ def __init__(self, ui_form):
+
+ self.ui_form = ui_form
+ self._closing_ = False
+ qt.QMainWindow.__init__(self)
+
+
+ # -------------------------------------------------------------------------
+ # Close of a form
+ # -------------------------------------------------------------------------
+
+ def close(self, *args):
+ """
+ Only close the form if @I{_closing_} is set to True, otherwise pass the
+ close request back to the bound GFForm instance.
+ """
+
+ if self._closing_:
+ return qt.QMainWindow.close(self, *args)
+ else:
+ self.ui_form._form.close()
+ return False
+
+
# =============================================================================
+# A dialog type form
+# =============================================================================
+
+class Dialog(qt.QDialog):
+ """
+ Qt-Widget for dialog style forms
+ """
+
+ # -------------------------------------------------------------------------
+ # Constructor
+ # -------------------------------------------------------------------------
+
+ def __init__(self, ui_form):
+
+ self.ui_form = ui_form
+ self._closing_ = False
+ qt.QDialog.__init__(self)
+
+
+ # -------------------------------------------------------------------------
+ # Close a dialog
+ # -------------------------------------------------------------------------
+
+ def close(self, *args):
+ """
+ Only close the form if @I{_closing_} is set to True, otherwise pass the
+ close request back to the bound GFForm instance.
+ """
+
+ if self._closing_:
+ return qt.QDialog.close(self, *args)
+ else:
+ self.ui_form._form.close()
+ return False
+
+
+# =============================================================================
# Configuration
# =============================================================================
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8939 - in trunk/gnue-forms/src/uidrivers/qt3: . widgets,
johannes <=