1
# -*- coding: utf-8 -*-
3
# Copyright (c) 2006 - 2007 Detlev Offenbach <detlev@die-offenbachs.de>
7
Module implementing the Editor Colours configuration page.
10
from PyQt4.QtCore import pyqtSignature
11
from PyQt4.QtGui import QPixmap, QIcon, QColor
13
from KdeQt import KQColorDialog
15
from ConfigurationPageBase import ConfigurationPageBase
16
from Ui_EditorColoursPage import Ui_EditorColoursPage
20
class EditorColoursPage(ConfigurationPageBase, Ui_EditorColoursPage):
22
Class implementing the Editor Colours configuration page.
28
ConfigurationPageBase.__init__(self)
30
self.setObjectName("EditorColoursPage")
32
self.editorColours = {}
35
self.__initEditorColoursColour("CurrentMarker",
36
self.currentLineMarkerButton)
37
self.__initEditorColoursColour("ErrorMarker",
38
self.errorMarkerButton)
39
self.__initEditorColoursColour("MatchingBrace",
40
self.matchingBracesButton)
41
self.__initEditorColoursColour("MatchingBraceBack",
42
self.matchingBracesBackButton)
43
self.__initEditorColoursColour("NonmatchingBrace",
44
self.nonmatchingBracesButton)
45
self.__initEditorColoursColour("NonmatchingBraceBack",
46
self.nonmatchingBracesBackButton)
47
self.__initEditorColoursColour("CallTipsBackground",
48
self.calltipsBackgroundButton)
49
self.__initEditorColoursColour("CaretForeground",
50
self.caretForegroundButton)
51
self.__initEditorColoursColour("CaretLineBackground",
52
self.caretlineBackgroundButton)
53
self.__initEditorColoursColour("SelectionForeground",
54
self.selectionForegroundButton)
55
self.__initEditorColoursColour("SelectionBackground",
56
self.selectionBackgroundButton)
60
Public slot to save the Editor Colours configuration.
62
for key in self.editorColours.keys():
63
Preferences.setEditorColour(key, self.editorColours[key])
65
def __initEditorColoursColour(self, colourstr, button):
67
Private method to initialize the colour buttons.
69
@param colourstr Colour to be set. (string)
70
@param button Reference to a QButton to show the colour on.
72
colour = QColor(Preferences.getEditorColour(colourstr))
73
self.editorColours[colourstr] = colour
75
pm = QPixmap(size.width()/2, size.height()/2)
77
button.setIconSize(pm.size())
78
button.setIcon(QIcon(pm))
80
def __selectEditorColour(self, colourstr, button):
82
Private method used by the buttons selecting the marker colours.
84
@param colourstr Colour to be set. (string)
85
@param button Reference to a QButton to show the colour on.
87
colour = KQColorDialog.getColor(self.editorColours[colourstr])
89
self.editorColours[colourstr] = colour
90
size = button.iconSize()
91
pm = QPixmap(size.width(), size.height())
93
button.setIcon(QIcon(pm))
96
def on_currentLineMarkerButton_clicked(self):
98
Private slot to set the colour for the highlight of the current line.
100
self.__selectEditorColour("CurrentMarker",
101
self.currentLineMarkerButton)
104
def on_errorMarkerButton_clicked(self):
106
Private slot to set the colour for the highlight of the error line.
108
self.__selectEditorColour("ErrorMarker",
109
self.errorMarkerButton)
112
def on_matchingBracesButton_clicked(self):
114
Private slot to set the colour for highlighting matching braces.
116
self.__selectEditorColour("MatchingBrace",
117
self.matchingBracesButton)
120
def on_matchingBracesBackButton_clicked(self):
122
Private slot to set the background colour for highlighting matching braces.
124
self.__selectEditorColour("MatchingBraceBack",
125
self.matchingBracesBackButton)
128
def on_nonmatchingBracesButton_clicked(self):
130
Private slot to set the colour for highlighting nonmatching braces.
132
self.__selectEditorColour("NonmatchingBrace",
133
self.nonmatchingBracesButton)
136
def on_nonmatchingBracesBackButton_clicked(self):
138
Private slot to set the background colour for highlighting nonmatching braces.
140
self.__selectEditorColour("NonmatchingBraceBack",
141
self.nonmatchingBracesBackButton)
144
def on_calltipsBackgroundButton_clicked(self):
146
Private slot to set the background colour for calltips.
148
self.__selectEditorColour("CallTipsBackground",
149
self.calltipsBackgroundButton)
152
def on_caretForegroundButton_clicked(self):
154
Private slot to set the foreground colour of the caret.
156
self.__selectEditorColour("CaretForeground",
157
self.caretForegroundButton)
160
def on_caretlineBackgroundButton_clicked(self):
162
Private slot to set the background colour of the caretline.
164
self.__selectEditorColour("CaretLineBackground",
165
self.caretlineBackgroundButton)
168
def on_selectionForegroundButton_clicked(self):
170
Private slot to set the foreground colour of the selection.
172
self.__selectEditorColour("SelectionForeground",
173
self.selectionForegroundButton)
176
def on_selectionBackgroundButton_clicked(self):
178
Private slot to set the background colour of the selection.
180
self.__selectEditorColour("SelectionBackground",
181
self.selectionBackgroundButton)
185
Module function to create the configuration page.
187
@param dlg reference to the configuration dialog
189
page = EditorColoursPage()