eric7/E5Gui/E5PathPicker.py

branch
eric7
changeset 8350
74a3b2a6a944
parent 8327
666c2b81cbb7
child 8351
7d13e08ddb3f
equal deleted inserted replaced
8348:f4775ae8f441 8350:74a3b2a6a944
9 9
10 import enum 10 import enum
11 import os 11 import os
12 12
13 from PyQt6.QtCore import pyqtSignal, Qt, QFileInfo, QCoreApplication, QDir 13 from PyQt6.QtCore import pyqtSignal, Qt, QFileInfo, QCoreApplication, QDir
14 from PyQt6.QtWidgets import QWidget, QHBoxLayout, QToolButton, QSizePolicy 14 from PyQt6.QtWidgets import (
15 QWidget, QHBoxLayout, QToolButton, QSizePolicy, QLineEdit, QComboBox
16 )
15 17
16 from . import E5FileDialog 18 from . import E5FileDialog
17 from .E5LineEdit import E5ClearableLineEdit
18 from .E5Completers import E5FileCompleter, E5DirCompleter 19 from .E5Completers import E5FileCompleter, E5DirCompleter
19 from .E5ComboBox import E5ClearableComboBox
20 20
21 import UI.PixmapCache 21 import UI.PixmapCache
22 22
23 23
24 class E5PathPickerModes(enum.Enum): 24 class E5PathPickerModes(enum.Enum):
84 self.__layout.setSpacing(0) 84 self.__layout.setSpacing(0)
85 self.__layout.setContentsMargins(0, 0, 0, 0) 85 self.__layout.setContentsMargins(0, 0, 0, 0)
86 self.setLayout(self.__layout) 86 self.setLayout(self.__layout)
87 87
88 if useLineEdit: 88 if useLineEdit:
89 self._editor = E5ClearableLineEdit( 89 self._editor = QLineEdit(
90 self, QCoreApplication.translate( 90 self, QCoreApplication.translate(
91 "E5PathPickerBase", "Enter Path Name")) 91 "E5PathPickerBase", "Enter Path Name"))
92 self._editor.setClearButtonEnabled(True)
92 else: 93 else:
93 self._editor = E5ClearableComboBox( 94 self._editor = QComboBox(self)
94 self, QCoreApplication.translate( 95 self._editor.setEditable(True)
96 self._editor.lineEdit().setPlaceholderText(
97 QCoreApplication.translate(
95 "E5PathPickerBase", "Enter Path Name")) 98 "E5PathPickerBase", "Enter Path Name"))
99 self._editor.lineEdit().setClearButtonEnabled(True)
96 100
97 self.__button = QToolButton(self) 101 self.__button = QToolButton(self)
98 self.__button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonIconOnly) 102 self.__button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonIconOnly)
99 self.__button.setIcon(UI.PixmapCache.getIcon("open")) 103 self.__button.setIcon(UI.PixmapCache.getIcon("open"))
100 104
153 else: 157 else:
154 self._completer = E5FileCompleter(self._editor) 158 self._completer = E5FileCompleter(self._editor)
155 159
156 # set inactive text 160 # set inactive text
157 if mode == E5PathPickerModes.OPEN_FILES_MODE: 161 if mode == E5PathPickerModes.OPEN_FILES_MODE:
158 self._editor.setInactiveText( 162 self._editor.setPlaceholderText(
159 self.tr("Enter Path Names separated by ';'")) 163 self.tr("Enter Path Names separated by ';'"))
160 else: 164 else:
161 self._editor.setInactiveText( 165 self._editor.setPlaceholderText(
162 self.tr("Enter Path Name")) 166 self.tr("Enter Path Name"))
163 self.__button.setEnabled(self.__mode != E5PathPickerModes.NO_MODE) 167 self.__button.setEnabled(self.__mode != E5PathPickerModes.NO_MODE)
164 168
165 def mode(self): 169 def mode(self):
166 """ 170 """

eric ide

mercurial