|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2006 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the user specific project properties dialog. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtWidgets import QDialog |
|
11 |
|
12 from E5Gui.E5Application import e5App |
|
13 |
|
14 import Preferences |
|
15 |
|
16 from .Ui_UserPropertiesDialog import Ui_UserPropertiesDialog |
|
17 |
|
18 |
|
19 class UserPropertiesDialog(QDialog, Ui_UserPropertiesDialog): |
|
20 """ |
|
21 Class implementing the user specific project properties dialog. |
|
22 """ |
|
23 def __init__(self, project, parent=None, name=None): |
|
24 """ |
|
25 Constructor |
|
26 |
|
27 @param project reference to the project object |
|
28 @param parent parent widget of this dialog (QWidget) |
|
29 @param name name of this dialog (string) |
|
30 """ |
|
31 super().__init__(parent) |
|
32 if name: |
|
33 self.setObjectName(name) |
|
34 self.setupUi(self) |
|
35 |
|
36 self.project = project |
|
37 |
|
38 if self.project.pudata["VCSSTATUSMONITORINTERVAL"]: |
|
39 self.vcsStatusMonitorIntervalSpinBox.setValue( |
|
40 self.project.pudata["VCSSTATUSMONITORINTERVAL"]) |
|
41 else: |
|
42 self.vcsStatusMonitorIntervalSpinBox.setValue( |
|
43 Preferences.getVCS("StatusMonitorInterval")) |
|
44 |
|
45 enableVcsGroup = False |
|
46 if self.project.pdata["VCS"]: |
|
47 found = False |
|
48 for _indicator, vcsData in ( |
|
49 e5App().getObject("PluginManager") |
|
50 .getVcsSystemIndicators().items() |
|
51 ): |
|
52 for vcsSystem, _vcsSystemDisplay in vcsData: |
|
53 if vcsSystem == self.project.pdata["VCS"]: |
|
54 found = True |
|
55 break |
|
56 |
|
57 if found: |
|
58 for vcsSystem, vcsSystemDisplay in vcsData: |
|
59 self.vcsInterfaceCombo.addItem( |
|
60 vcsSystemDisplay, vcsSystem) |
|
61 enableVcsGroup = len(vcsData) > 1 |
|
62 break |
|
63 self.vcsGroup.setEnabled(enableVcsGroup) |
|
64 |
|
65 if self.vcsGroup.isEnabled(): |
|
66 if self.project.pudata["VCSOVERRIDE"]: |
|
67 vcsSystem = self.project.pudata["VCSOVERRIDE"] |
|
68 else: |
|
69 vcsSystem = self.project.pdata["VCS"] |
|
70 index = self.vcsInterfaceCombo.findData(vcsSystem) |
|
71 if index == -1: |
|
72 index = 0 |
|
73 self.vcsInterfaceCombo.setCurrentIndex(index) |
|
74 |
|
75 msh = self.minimumSizeHint() |
|
76 self.resize(max(self.width(), msh.width()), msh.height()) |
|
77 |
|
78 def storeData(self): |
|
79 """ |
|
80 Public method to store the entered/modified data. |
|
81 """ |
|
82 vcsStatusMonitorInterval = self.vcsStatusMonitorIntervalSpinBox.value() |
|
83 if ( |
|
84 vcsStatusMonitorInterval != |
|
85 Preferences.getVCS("StatusMonitorInterval") |
|
86 ): |
|
87 self.project.pudata["VCSSTATUSMONITORINTERVAL"] = ( |
|
88 vcsStatusMonitorInterval |
|
89 ) |
|
90 else: |
|
91 self.project.pudata["VCSSTATUSMONITORINTERVAL"] = 0 |
|
92 |
|
93 if self.vcsGroup.isEnabled(): |
|
94 vcsSystem = self.vcsInterfaceCombo.itemData( |
|
95 self.vcsInterfaceCombo.currentIndex()) |
|
96 if self.vcsInterfaceDefaultCheckBox.isChecked(): |
|
97 if vcsSystem != self.project.pdata["VCS"]: |
|
98 self.project.pdata["VCS"] = vcsSystem |
|
99 self.project.pudata["VCSOVERRIDE"] = "" |
|
100 self.project.setDirty(True) |
|
101 else: |
|
102 if vcsSystem != self.project.pdata["VCS"]: |
|
103 self.project.pudata["VCSOVERRIDE"] = vcsSystem |
|
104 else: |
|
105 self.project.pudata["VCSOVERRIDE"] = "" |