~ubuntu-branches/ubuntu/karmic/eric/karmic

« back to all changes in this revision

Viewing changes to eric/KdeQt/KQColorDialog.py

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2008-01-28 18:02:25 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080128180225-6nrox6yrworh2c4v
Tags: 4.0.4-1ubuntu1
* Add python-qt3 to build-depends becuase that's where Ubuntu puts 
  pyqtconfig
* Change maintainer to MOTU

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
Compatibility module to use the KDE Color Dialog instead of the Qt Color Dialog.
8
8
"""
9
9
 
 
10
import os
 
11
 
 
12
import Preferences
 
13
 
10
14
try:
11
 
    import os
12
 
    if os.getenv("e3nokde"):
13
 
        raise ImportError
14
 
        
15
 
    from kdeui import KColorDialog
16
 
    from qt import Qt, QColor
17
 
    
18
 
    def getColor(initial = Qt.white, parent = None, name = None):
19
 
        """
20
 
        Public function to pop up a modal dialog to select a color.
21
 
        
22
 
        @param initial initial color to select (QColor)
23
 
        @param parent parent widget of the dialog (QWidget)
24
 
        @param name name of the dialog (ignored)
25
 
        @return the selected color or the invalid color, if the
26
 
            canceled the dialog (QColor)
27
 
        """
28
 
        col = QColor(initial)
29
 
        res = KColorDialog.getColor(col, parent)
30
 
        if res == KColorDialog.Accepted:
31
 
            return col
32
 
        else:
33
 
            return QColor()
34
 
    
 
15
    raise ImportError
35
16
except (ImportError, RuntimeError):
36
 
    import qt
37
 
    getColor = qt.QColorDialog.getColor
 
17
    os.environ["e4nokde"] = "1"
 
18
    
 
19
from PyQt4.QtCore import Qt
 
20
from  PyQt4.QtGui import QColorDialog, QColor
 
21
 
 
22
__qtGetColor = QColorDialog.getColor
 
23
 
 
24
################################################################################
 
25
 
 
26
def getColor(initial = QColor(Qt.white), parent = None):
 
27
    """
 
28
    Public function to pop up a modal dialog to select a color.
 
29
    
 
30
    @param initial initial color to select (QColor)
 
31
    @param parent parent widget of the dialog (QWidget)
 
32
    @return the selected color or the invalid color, if the user
 
33
        canceled the dialog (QColor)
 
34
    """
 
35
    if Preferences.getUI("UseKDEDialogs") and not os.getenv("e4nokde"):
 
36
        return __kdeGetColor(initial, parent)
 
37
    else:
 
38
        return __qtGetColor(initial, parent)