|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2006 - 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the VCS configuration page. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtCore import pyqtSlot |
|
11 |
|
12 from ConfigurationPageBase import ConfigurationPageBase |
|
13 from Ui_VcsPage import Ui_VcsPage |
|
14 |
|
15 import Preferences |
|
16 |
|
17 class VcsPage(ConfigurationPageBase, Ui_VcsPage): |
|
18 """ |
|
19 Class implementing the VCS configuration page. |
|
20 """ |
|
21 def __init__(self): |
|
22 """ |
|
23 Constructor |
|
24 """ |
|
25 ConfigurationPageBase.__init__(self) |
|
26 self.setupUi(self) |
|
27 self.setObjectName("VcsPage") |
|
28 |
|
29 self.projectBrowserColours = {} |
|
30 |
|
31 # set initial values |
|
32 self.vcsAutoCloseCheckBox.setChecked(Preferences.getVCS("AutoClose")) |
|
33 self.vcsAutoSaveCheckBox.setChecked(Preferences.getVCS("AutoSaveFiles")) |
|
34 self.vcsAutoSaveProjectCheckBox.setChecked( |
|
35 Preferences.getVCS("AutoSaveProject")) |
|
36 self.vcsStatusMonitorIntervalSpinBox.setValue( |
|
37 Preferences.getVCS("StatusMonitorInterval")) |
|
38 self.vcsMonitorLocalStatusCheckBox.setChecked( |
|
39 Preferences.getVCS("MonitorLocalStatus")) |
|
40 self.autoUpdateCheckBox.setChecked( |
|
41 Preferences.getVCS("AutoUpdate")) |
|
42 |
|
43 self.projectBrowserColours["VcsAdded"] = \ |
|
44 self.initColour("VcsAdded", self.pbVcsAddedButton, |
|
45 Preferences.getProjectBrowserColour) |
|
46 self.projectBrowserColours["VcsConflict"] = \ |
|
47 self.initColour("VcsConflict", self.pbVcsConflictButton, |
|
48 Preferences.getProjectBrowserColour) |
|
49 self.projectBrowserColours["VcsModified"] = \ |
|
50 self.initColour("VcsModified", self.pbVcsModifiedButton, |
|
51 Preferences.getProjectBrowserColour) |
|
52 self.projectBrowserColours["VcsReplaced"] = \ |
|
53 self.initColour("VcsReplaced", self.pbVcsReplacedButton, |
|
54 Preferences.getProjectBrowserColour) |
|
55 self.projectBrowserColours["VcsUpdate"] = \ |
|
56 self.initColour("VcsUpdate", self.pbVcsUpdateButton, |
|
57 Preferences.getProjectBrowserColour) |
|
58 self.projectBrowserColours["VcsConflict"] = \ |
|
59 self.initColour("VcsConflict", self.pbVcsConflictButton, |
|
60 Preferences.getProjectBrowserColour) |
|
61 |
|
62 def save(self): |
|
63 """ |
|
64 Public slot to save the VCS configuration. |
|
65 """ |
|
66 Preferences.setVCS("AutoClose", |
|
67 int(self.vcsAutoCloseCheckBox.isChecked())) |
|
68 Preferences.setVCS("AutoSaveFiles", |
|
69 int(self.vcsAutoSaveCheckBox.isChecked())) |
|
70 Preferences.setVCS("AutoSaveProject", |
|
71 int(self.vcsAutoSaveProjectCheckBox.isChecked())) |
|
72 Preferences.setVCS("StatusMonitorInterval", |
|
73 self.vcsStatusMonitorIntervalSpinBox.value()) |
|
74 Preferences.setVCS("MonitorLocalStatus", |
|
75 int(self.vcsMonitorLocalStatusCheckBox.isChecked())) |
|
76 Preferences.setVCS("AutoUpdate", |
|
77 int(self.autoUpdateCheckBox.isChecked())) |
|
78 |
|
79 for key in self.projectBrowserColours.keys(): |
|
80 Preferences.setProjectBrowserColour(key, self.projectBrowserColours[key]) |
|
81 |
|
82 @pyqtSlot() |
|
83 def on_pbVcsAddedButton_clicked(self): |
|
84 """ |
|
85 Private slot to set the background colour for entries with VCS |
|
86 status "added". |
|
87 """ |
|
88 self.projectBrowserColours["VcsAdded"] = \ |
|
89 self.selectColour(self.pbVcsAddedButton, |
|
90 self.projectBrowserColours["VcsAdded"]) |
|
91 |
|
92 @pyqtSlot() |
|
93 def on_pbVcsConflictButton_clicked(self): |
|
94 """ |
|
95 Private slot to set the background colour for entries with VCS |
|
96 status "conflict". |
|
97 """ |
|
98 self.projectBrowserColours["VcsConflict"] = \ |
|
99 self.selectColour(self.pbVcsConflictButton, |
|
100 self.projectBrowserColours["VcsConflict"]) |
|
101 |
|
102 @pyqtSlot() |
|
103 def on_pbVcsModifiedButton_clicked(self): |
|
104 """ |
|
105 Private slot to set the background colour for entries with VCS |
|
106 status "modified". |
|
107 """ |
|
108 self.projectBrowserColours["VcsModified"] = \ |
|
109 self.selectColour(self.pbVcsModifiedButton, |
|
110 self.projectBrowserColours["VcsModified"]) |
|
111 |
|
112 @pyqtSlot() |
|
113 def on_pbVcsReplacedButton_clicked(self): |
|
114 """ |
|
115 Private slot to set the background colour for entries with VCS |
|
116 status "replaced". |
|
117 """ |
|
118 self.projectBrowserColours["VcsReplaced"] = \ |
|
119 self.selectColour(self.pbVcsReplacedButton, |
|
120 self.projectBrowserColours["VcsReplaced"]) |
|
121 |
|
122 @pyqtSlot() |
|
123 def on_pbVcsUpdateButton_clicked(self): |
|
124 """ |
|
125 Private slot to set the background colour for entries with VCS |
|
126 status "needs update". |
|
127 """ |
|
128 self.projectBrowserColours["VcsUpdate"] = \ |
|
129 self.selectColour(self.pbVcsUpdateButton, |
|
130 self.projectBrowserColours["VcsUpdate"]) |
|
131 |
|
132 def create(dlg): |
|
133 """ |
|
134 Module function to create the configuration page. |
|
135 |
|
136 @param dlg reference to the configuration dialog |
|
137 """ |
|
138 page = VcsPage() |
|
139 return page |