camelot.camelot.view.workspace

Package camelot :: Package camelot :: Package view :: Module workspace |
[hide private]
[frames] | no frames]

# Source Code for Module camelot.camelot.view.workspace

     1  """This module provides a singleton workspace that can be used by views

     2  and widget to create new windows or raise existing ones"""
     3

     4  from PyQt4 import QtGui, QtCore
     5

     6  import logging
     7

     8  logger = logging.getLogger('camelot.view.workspace')
     9

    10 -class DesktopWorkspace(QtGui.QMdiArea):
    11 -  def __init__(self, *args):
    12      QtGui.QMdiArea.__init__(self, *args)
    13      self.setOption(QtGui.QMdiArea.DontMaximizeSubWindowOnActivation)
    14      self.setBackground(QtGui.QBrush(QtGui.QColor('white')))
    15      self.setActivationOrder(QtGui.QMdiArea.ActivationHistoryOrder)
    16

    17 -  def addSubWindow(self, widget, *args):
    18      subwindow = QtGui.QMdiArea.addSubWindow(self, widget, *args)
    19      if hasattr(widget, 'closeAfterValidation'):
    20        subwindow.connect(widget, widget.closeAfterValidation, subwindow, QtCore.SLOT("close()"))
    21

    22  _workspace_ = []
    23

    24 -def construct_workspace(*args, **kwargs):
    25    _workspace_.append(DesktopWorkspace(*args))
    26    return _workspace_[0]
    27

    28 -def get_workspace():
    29    return _workspace_[0]
    30