Skip to content

Commit

Permalink
#018 - Fixes after first testing (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
eryk918 authored Dec 11, 2022
1 parent 3e5f0ed commit 6bbdd94
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 137 deletions.
23 changes: 17 additions & 6 deletions CustomFileWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def __init__(self, parent=None):
self.parent = parent
self.setAcceptDrops(True)
self.acceptable_extensions = []
self.set_correct_placeholder_text()

@property
def dir_only(self) -> bool:
Expand All @@ -43,6 +44,16 @@ def suffixFilter(self) -> str:
def suffixFilter(self, value: str) -> None:
self.suffixFilter = value

def set_correct_placeholder_text(self) -> None:
if self.parent.mStorageMode == CustomFileWidget.GetMultipleFiles:
self.setPlaceholderText('Select files..')
elif self.parent.mStorageMode == CustomFileWidget.GetFile:
self.setPlaceholderText('Select file..')
elif self.parent.mStorageMode == CustomFileWidget.SaveFile:
self.setPlaceholderText('Save output file..')
else:
self.setPlaceholderText('Select directory..')

def set_filters(self, filters: str) -> None:
self.acceptable_extensions.clear()
if '*.*' in filters:
Expand Down Expand Up @@ -114,6 +125,12 @@ def __init__(self, parent=None, default_root=None, dialog_title=''):
super(CustomFileWidget, self).__init__(parent)
main_layout = QHBoxLayout()
main_layout.setContentsMargins(0, 0, 0, 0)
self._filePath = ''
self._defaultRoot = default_root
self._dialogTitle = dialog_title
self._filter = ''
self._options = QFileDialog.ShowDirsOnly
self._mStorageMode = CustomFileWidget.GetMultipleFiles
self.file_lineEdit = QgsFileDropEdit(self)
self.file_lineEdit.setDragEnabled(True)
self.file_lineEdit.setToolTip(
Expand All @@ -127,12 +144,6 @@ def __init__(self, parent=None, default_root=None, dialog_title=''):
self.browse_btn.clicked.connect(self.openFileDialog)
main_layout.addWidget(self.browse_btn)
self.setLayout(main_layout)
self._filePath = ''
self._defaultRoot = default_root
self._dialogTitle = dialog_title
self._filter = ''
self._options = QFileDialog.ShowDirsOnly
self._mStorageMode = CustomFileWidget.GetMultipleFiles

@property
def filePath(self) -> str:
Expand Down
Loading

0 comments on commit 6bbdd94

Please sign in to comment.