瀏覽代碼

BUG Fix:解决Add File 窗口首次打开地址栏不正确问题

mrh 3 年之前
父節點
當前提交
3ef7bc4fbc
共有 2 個文件被更改,包括 3 次插入15 次删除
  1. 3 4
      ui/AddFile.py
  2. 0 11
      ui/addressBar/addressbar.py

+ 3 - 4
ui/AddFile.py

@@ -21,11 +21,10 @@ class AddFileWindow(Ui_AddFileWindow, QDialog):
         self.file_suffix = ["Supported Files(%s)" % " ".join(['*'+str(s) for s in self.file_type]), "All files(*.*)"]
         self.path_obj = PathObject(path)
         
+        self.Combobox_FileType.addItems(self.file_suffix)
+        self.Combobox_FileType.currentIndexChanged.connect(lambda index:self.show_file_list())
         self.bnt_Apply.clicked.connect(self.apply)
         self.bnt_OK.clicked.connect(self.click_ok)
-        # Combobox 初始化完成后会自动调用一次 self.open_folder()
-        self.Combobox_FileType.currentIndexChanged.connect(lambda index:self.open_folder(path))
-        self.Combobox_FileType.addItems(self.file_suffix)
         self.init_file_browser(path)
         # 用于路径前进后退,目前用不上
         self.move(parent.x()+(parent.width()-self.width())/2 + self.width()*0.8,parent.y()+(parent.height()-self.height())/2)
@@ -40,6 +39,7 @@ class AddFileWindow(Ui_AddFileWindow, QDialog):
         self.address_bar.path_selected.connect(self.open_folder)
         self.address_bar.path_error.connect(lambda path: self.address_error_connect("No such file or directory", path.name))
         self.address_bar.listdir_error.connect(lambda path: self.address_error_connect("Permission denied", path.name))
+        self.address_bar.set_path(path)
         self.verticalLayout_3.insertWidget(0, self.address_bar)
 
     def path_select(self, path):
@@ -122,7 +122,6 @@ class AddFileWindow(Ui_AddFileWindow, QDialog):
             self.open_file(abs_path)
         # 这里不能用 elif os.path.isdir(abs_path) ,因为假如目录没有权限访问,即便它是个目录也会返回 False
         else:
-            print("set Path:", abs_path)
             self.address_bar.set_path(abs_path)
 
     def open_folder(self, dir):

+ 0 - 11
ui/addressBar/addressbar.py

@@ -129,7 +129,6 @@ class BreadcrumbsAddressBar(QtWidgets.QFrame):
 
         self.ignore_resize = False
         self.path_ = None
-        self.set_path(Path())
 
     @staticmethod
     def init_completer(edit_widget, model):
@@ -263,11 +262,6 @@ class BreadcrumbsAddressBar(QtWidgets.QFrame):
         elif event.key() in (Qt.Key_Return, Qt.Key_Enter):
             if self.set_path(self.line_address.text()):
                 self._show_address_field(False)
-        # elif event.text() == os.path.sep:  # FIXME: separator cannot be pasted
-        #     print('fill completer data here')
-        #     paths = [str(i) for i in
-        #              Path(self.line_address.text()).iterdir() if i.is_dir()]
-        #     self.completer.model().setStringList(paths)
         else:
             QtWidgets.QLineEdit.keyPressEvent(self.line_address, event)
 
@@ -289,11 +283,8 @@ class BreadcrumbsAddressBar(QtWidgets.QFrame):
 
     def _insert_crumb(self, path):
         btn = QtWidgets.QToolButton(self.crumbs_panel)
-        # btn.setContentsMargins(0,0,0,0)
         btn.setAutoRaise(True)
         btn.setPopupMode(btn.MenuButtonPopup)
-        # btn.setStyleSheet("*{}")
-        # btn.setStyle(self.style_crumbs)
         btn.mouseMoveEvent = self.crumb_mouse_move
         btn.setMouseTracking(True)
         if path.name:
@@ -316,8 +307,6 @@ class BreadcrumbsAddressBar(QtWidgets.QFrame):
         sp = btn.sizePolicy()
         sp.setVerticalPolicy(sp.Minimum)
         btn.setSizePolicy(sp)
-        # print(self._check_space_width(btn.minimumWidth()))
-        # print(btn.size(), btn.sizeHint(), btn.minimumSizeHint())
 
     def crumb_mouse_move(self, event):
         ...