src/eric7/Project/ProjectBrowser.py

branch
eric7
changeset 9647
e4c2ae118781
parent 9613
7154cc0373dd
child 9653
e67609152c5e
equal deleted inserted replaced
9646:ab5678db972f 9647:e4c2ae118781
9 9
10 import contextlib 10 import contextlib
11 11
12 from PyQt6.QtCore import Qt, pyqtSignal 12 from PyQt6.QtCore import Qt, pyqtSignal
13 from PyQt6.QtGui import QColor, QIcon 13 from PyQt6.QtGui import QColor, QIcon
14 from PyQt6.QtWidgets import QToolButton
14 15
15 from eric7 import Preferences 16 from eric7 import Preferences
16 from eric7.EricGui import EricPixmapCache 17 from eric7.EricGui import EricPixmapCache
17 from eric7.EricWidgets import EricMessageBox 18 from eric7.EricWidgets import EricMessageBox
18 from eric7.EricWidgets.EricLed import EricClickableLed 19 from eric7.EricWidgets.EricLed import EricClickableLed
102 103
103 self.setWindowIcon(EricPixmapCache.getIcon("eric")) 104 self.setWindowIcon(EricPixmapCache.getIcon("eric"))
104 105
105 self.setUsesScrollButtons(True) 106 self.setUsesScrollButtons(True)
106 107
107 self.vcsStatusIndicator = EricClickableLed(self)
108 self.setCornerWidget(self.vcsStatusIndicator, Qt.Corner.TopLeftCorner)
109 self.vcsStatusIndicator.clicked.connect(self.__vcsStatusIndicatorClicked)
110 self.vcsStatusColorNames = { 108 self.vcsStatusColorNames = {
111 "A": "VcsAdded", 109 "A": "VcsAdded",
112 "M": "VcsModified", 110 "M": "VcsModified",
113 "O": "VcsRemoved", 111 "O": "VcsRemoved",
114 "R": "VcsReplaced", 112 "R": "VcsReplaced",
122 "O": self.tr("files removed"), 120 "O": self.tr("files removed"),
123 "R": self.tr("files replaced"), 121 "R": self.tr("files replaced"),
124 "U": self.tr("update required"), 122 "U": self.tr("update required"),
125 "Z": self.tr("conflict"), 123 "Z": self.tr("conflict"),
126 } 124 }
125 self.vcsStatusIndicator = EricClickableLed(self)
126 self.vcsStatusIndicator.clicked.connect(self.__vcsStatusIndicatorClicked)
127 self.setCornerWidget(self.vcsStatusIndicator, Qt.Corner.TopLeftCorner)
128 self.vcsCheckStatusButton = QToolButton(self)
129 self.vcsCheckStatusButton.setIcon(EricPixmapCache.getIcon("reload"))
130 self.vcsCheckStatusButton.setToolTip(
131 self.tr("Press to check the current VCS status.")
132 )
133 self.vcsCheckStatusButton.clicked.connect(self.project.checkVCSStatus)
134 self.setCornerWidget(self.vcsCheckStatusButton, Qt.Corner.TopRightCorner)
127 self.__vcsStateChanged(" ") 135 self.__vcsStateChanged(" ")
128 136
129 self.__currentBrowsersList = [] 137 self.__currentBrowsersList = []
130 self.__browserRepository = {} 138 self.__browserRepository = {}
131 self.__fileFilterMapping = {} # redundant data store for speed reasons 139 self.__fileFilterMapping = {} # redundant data store for speed reasons
338 Private slot to handle the projectOpened signal. 346 Private slot to handle the projectOpened signal.
339 """ 347 """
340 self.__projectPropertiesChanged() 348 self.__projectPropertiesChanged()
341 self.setCurrentIndex(0) 349 self.setCurrentIndex(0)
342 self.__vcsStateChanged(" ") 350 self.__vcsStateChanged(" ")
351 self.vcsStatusIndicator.setVisible(self.project.isVcsControlled())
352 self.vcsCheckStatusButton.setVisible(self.project.isVcsControlled())
343 353
344 def __projectClosed(self): 354 def __projectClosed(self):
345 """ 355 """
346 Private slot to handle the projectClosed signal. 356 Private slot to handle the projectClosed signal.
347 """ 357 """
348 self.__projectPropertiesChanged() 358 self.__projectPropertiesChanged()
349 self.setCurrentIndex(0) 359 self.setCurrentIndex(0)
350 self.__setSourcesIcon() 360 self.__setSourcesIcon()
351 self.__vcsStateChanged(" ") 361 self.__vcsStateChanged(" ")
362 self.vcsStatusIndicator.setVisible(False)
363 self.vcsCheckStatusButton.setVisible(False)
352 364
353 def __newProject(self): 365 def __newProject(self):
354 """ 366 """
355 Private slot to handle the newProject signal. 367 Private slot to handle the newProject signal.
356 """ 368 """
429 441
430 def __vcsStateChanged(self, state): 442 def __vcsStateChanged(self, state):
431 """ 443 """
432 Private slot to handle a change in the vcs state. 444 Private slot to handle a change in the vcs state.
433 445
434 @param state new vcs state (string) 446 @param state new vcs state
435 """ 447 @type str
448 """
449 self.vcsStatusIndicator.setVisible(self.project.isVcsControlled())
450 self.vcsCheckStatusButton.setVisible(self.project.isVcsControlled())
451
436 self.currentVcsStatus = state 452 self.currentVcsStatus = state
437 if state == " " or state not in self.vcsStatusColorNames: 453 if state == " " or state not in self.vcsStatusColorNames:
438 self.vcsStatusIndicator.setColor(QColor(Qt.GlobalColor.lightGray)) 454 self.vcsStatusIndicator.setColor(QColor(Qt.GlobalColor.lightGray))
439 else: 455 else:
440 self.vcsStatusIndicator.setColor( 456 self.vcsStatusIndicator.setColor(

eric ide

mercurial