@@ -238,13 +238,17 @@ def go_root(self, checked=False):
238238 Note: We need to expand and scroll the tree view here after setCurrentIndex
239239 just in case the directory has been loaded already.
240240 """
241+ if os .path .samefile (self .selection (), QDir .rootPath ()):
242+ return
241243 self .ui .comboBox_current_path .setCurrentIndex (- 1 )
242244 root_index = self .file_model .index (QDir .rootPath ())
243245 self .collapse_and_expand (root_index )
244246
245247 @Slot (bool , name = "go_home" )
246248 def go_home (self , checked = False ):
247249 """Slot for the 'Home' button. Scrolls the treeview to show and select the user's home directory."""
250+ if os .path .samefile (self .selection (), QDir .homePath ()):
251+ return
248252 self .ui .comboBox_current_path .setCurrentIndex (- 1 )
249253 home_index = self .file_model .index (QDir .homePath ())
250254 self .collapse_and_expand (home_index )
@@ -253,7 +257,7 @@ def go_home(self, checked=False):
253257 def go_documents (self , checked = False ):
254258 """Slot for the 'Documents' button. Scrolls the treeview to show and select the user's documents directory."""
255259 docs = QStandardPaths .writableLocation (QStandardPaths .StandardLocation .DocumentsLocation )
256- if not docs :
260+ if not docs or os . path . samefile ( self . selection (), docs ) :
257261 return
258262 self .ui .comboBox_current_path .setCurrentIndex (- 1 )
259263 docs_index = self .file_model .index (docs )
@@ -262,8 +266,8 @@ def go_documents(self, checked=False):
262266 @Slot (bool , name = "go_desktop" )
263267 def go_desktop (self , checked = False ):
264268 """Slot for the 'Desktop' button. Scrolls the treeview to show and select the user's desktop directory."""
265- desktop = QStandardPaths .writableLocation (QStandardPaths .StandardLocation .DesktopLocation ) # Return a list
266- if not desktop :
269+ desktop = QStandardPaths .writableLocation (QStandardPaths .StandardLocation .DesktopLocation )
270+ if not desktop or os . path . samefile ( self . selection (), desktop ) :
267271 return
268272 self .ui .comboBox_current_path .setCurrentIndex (- 1 )
269273 desktop_index = self .file_model .index (desktop )
0 commit comments