def __init__(self): super().__init__() self.setMinimumSize(400, 300) self.setWindowTitle('QtAwesome Icon Browser') qtawesome._instance() fontMaps = qtawesome._resource['iconic'].charmap iconNames = [] for fontCollection, fontData in fontMaps.items(): for iconName in fontData: iconNames.append('%s.%s' % (fontCollection, iconName)) self._filterTimer = QtCore.QTimer(self) self._filterTimer.setSingleShot(True) self._filterTimer.setInterval(AUTO_SEARCH_TIMEOUT) self._filterTimer.timeout.connect(self._updateFilter) model = IconModel(self.palette().color(QtGui.QPalette.Text)) model.setStringList(sorted(iconNames)) self._proxyModel = QtCore.QSortFilterProxyModel() self._proxyModel.setSourceModel(model) self._proxyModel.setFilterCaseSensitivity(QtCore.Qt.CaseInsensitive) self._listView = IconListView(self) self._listView.setUniformItemSizes(True) self._listView.setViewMode(QtWidgets.QListView.IconMode) self._listView.setModel(self._proxyModel) self._listView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self._listView.doubleClicked.connect(self._copyIconText) self._lineEdit = QtWidgets.QLineEdit(self) self._lineEdit.setAlignment(QtCore.Qt.AlignCenter) self._lineEdit.textChanged.connect(self._triggerDelayedUpdate) self._lineEdit.returnPressed.connect(self._triggerImmediateUpdate) self._comboBox = QtWidgets.QComboBox(self) self._comboBox.setMinimumWidth(75) self._comboBox.currentIndexChanged.connect( self._triggerImmediateUpdate) self._comboBox.addItems([ALL_COLLECTIONS] + sorted(fontMaps.keys())) lyt = QtWidgets.QHBoxLayout() lyt.setContentsMargins(0, 0, 0, 0) lyt.addWidget(self._comboBox) lyt.addWidget(self._lineEdit) searchBarFrame = QtWidgets.QFrame(self) searchBarFrame.setLayout(lyt) self._copyButton = QtWidgets.QPushButton('Copy Name', self) self._copyButton.clicked.connect(self._copyIconText) lyt = QtWidgets.QVBoxLayout() lyt.addWidget(searchBarFrame) lyt.addWidget(self._listView) lyt.addWidget(self._copyButton) frame = QtWidgets.QFrame(self) frame.setLayout(lyt) self.setCentralWidget(frame) QtWidgets.QShortcut( QtGui.QKeySequence(QtCore.Qt.Key_Return), self, self._copyIconText, ) self._lineEdit.setFocus() geo = self.geometry() desktop = QtWidgets.QApplication.desktop() screen = desktop.screenNumber(desktop.cursor().pos()) centerPoint = desktop.screenGeometry(screen).center() geo.moveCenter(centerPoint) self.setGeometry(geo)
def __init__(self): super().__init__() self.setMinimumSize(400, 300) self.setWindowTitle('QtAwesome Icon Browser') qtawesome._instance() fontMaps = qtawesome._resource['iconic'].charmap iconNames = [] for fontCollection, fontData in fontMaps.items(): for iconName in fontData: iconNames.append('%s.%s' % (fontCollection, iconName)) self._filterTimer = QtCore.QTimer(self) self._filterTimer.setSingleShot(True) self._filterTimer.setInterval(AUTO_SEARCH_TIMEOUT) self._filterTimer.timeout.connect(self._updateFilter) model = IconModel() model.setStringList(sorted(iconNames)) self._proxyModel = QtCore.QSortFilterProxyModel() self._proxyModel.setSourceModel(model) self._proxyModel.setFilterCaseSensitivity(QtCore.Qt.CaseInsensitive) self._listView = IconListView(self) self._listView.setUniformItemSizes(True) self._listView.setViewMode(QtWidgets.QListView.IconMode) self._listView.setModel(self._proxyModel) self._listView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self._listView.doubleClicked.connect(self._copyIconText) self._listView.selectionModel().selectionChanged.connect(self._updateNameField) self._lineEdit = QtWidgets.QLineEdit(self) self._lineEdit.setAlignment(QtCore.Qt.AlignCenter) self._lineEdit.textChanged.connect(self._triggerDelayedUpdate) self._lineEdit.returnPressed.connect(self._triggerImmediateUpdate) self._comboBox = QtWidgets.QComboBox(self) self._comboBox.setMinimumWidth(75) self._comboBox.currentIndexChanged.connect(self._triggerImmediateUpdate) self._comboBox.addItems([ALL_COLLECTIONS] + sorted(fontMaps.keys())) lyt = QtWidgets.QHBoxLayout() lyt.setContentsMargins(0, 0, 0, 0) lyt.addWidget(self._comboBox) lyt.addWidget(self._lineEdit) self._combo_style = QtWidgets.QComboBox(self) self._combo_style.addItems([ qtawesome.styles.DEFAULT_DARK_PALETTE, qtawesome.styles.DEFAULT_LIGHT_PALETTE]) self._combo_style.currentTextChanged.connect(self._updateStyle) lyt.addWidget(self._combo_style) searchBarFrame = QtWidgets.QFrame(self) searchBarFrame.setLayout(lyt) self._nameField = QtWidgets.QLineEdit(self) self._nameField.setAlignment(QtCore.Qt.AlignCenter) self._nameField.setReadOnly(True) self._copyButton = QtWidgets.QPushButton('Copy Name', self) self._copyButton.clicked.connect(self._copyIconText) lyt = QtWidgets.QVBoxLayout() lyt.addWidget(searchBarFrame) lyt.addWidget(self._listView) lyt.addWidget(self._nameField) lyt.addWidget(self._copyButton) frame = QtWidgets.QFrame(self) frame.setLayout(lyt) self.setCentralWidget(frame) self.setTabOrder(self._comboBox, self._lineEdit) self.setTabOrder(self._lineEdit, self._combo_style) self.setTabOrder(self._combo_style, self._listView) self.setTabOrder(self._listView, self._nameField) self.setTabOrder(self._nameField, self._copyButton) self.setTabOrder(self._copyButton, self._comboBox) QtWidgets.QShortcut( QtGui.QKeySequence(QtCore.Qt.Key_Return), self, self._copyIconText, ) QtWidgets.QShortcut( QtGui.QKeySequence("Ctrl+F"), self, self._lineEdit.setFocus, ) self._lineEdit.setFocus() geo = self.geometry() # QApplication.desktop() has been removed in Qt 6. # Instead, QGuiApplication.screenAt(QPoint) is supported # in Qt 5.10 or later. try: screen = QtGui.QGuiApplication.screenAt(QtGui.QCursor.pos()) centerPoint = screen.geometry().center() except AttributeError: desktop = QtWidgets.QApplication.desktop() screen = desktop.screenNumber(desktop.cursor().pos()) centerPoint = desktop.screenGeometry(screen).center() geo.moveCenter(centerPoint) self.setGeometry(geo)
def __init__(self, *, main_window, parent=None): super().__init__(parent=parent) self.main = main_window self.setAttribute(Qt.WA_ShowWithoutActivating, True) self.setWindowFlag(Qt.FramelessWindowHint, True) self.setWindowFlag(Qt.WindowStaysOnTopHint, True) self.setWindowFlag(Qt.Popup, True) # Using SplashScreen and WindowDoesNotAcceptFocus to address issue when # running with OSX and XForwarding. Without the flag below it will make # the Dialog show its Title bar and appear over the search box which # makes the search useless. self.setWindowFlag(Qt.SplashScreen, True) self.setWindowFlag(Qt.WindowDoesNotAcceptFocus, True) # Using BypassWindowManagerHint to address issue when running with # linux. Without the flag below it will make the Dialog capture the # focus from the line edit and clear the search result display along # with the overlay. self.setWindowFlag(Qt.BypassWindowManagerHint, True) if hasattr(parent, 'key_pressed'): parent.key_pressed.connect(self._handle_search_keypress) # [match list] # [option frame] layout = QtWidgets.QVBoxLayout() self.match_list = SearchMatchList(self) self.models = {} # TODO: FIFO bounded dict self.setLayout(layout) layout.addWidget(self.match_list) self.proxy_model = QtCore.QSortFilterProxyModel() self.proxy_model.setSortRole(Qt.UserRole) self.proxy_model.setDynamicSortFilter(True) self.proxy_model.sort(0, Qt.DescendingOrder) self.match_list.setModel(self.proxy_model) # option frame: # [ grid screens happi ] option_frame = QtWidgets.QFrame() option_frame.setContentsMargins(0, 0, 0, 0) layout.addWidget(option_frame) option_layout = QtWidgets.QHBoxLayout() option_frame.setLayout(option_layout) self.option_grid = QtWidgets.QCheckBox('&Grid') self.option_screens = QtWidgets.QCheckBox('&Screens') self.option_happi = QtWidgets.QCheckBox('&Happi') self.refresh_button = QtWidgets.QPushButton('&Refresh') for w in (self.option_grid, self.option_screens, self.option_happi): option_layout.addWidget(w) w.setChecked(True) w.stateChanged.connect( lambda state: self._search_settings_changed()) option_layout.addWidget(self.refresh_button) def refresh_clicked(): self.search(self.text, force_update=True) self.refresh_button.clicked.connect(refresh_clicked)
def __init__(self): super().__init__() ui_file = os.path.join(os.path.dirname(__file__), 'cluster_status.ui') uic.loadUi(ui_file, self) self.partition_info = None self._unexpected_node_prefixes = [] q_output_format_delimiter = '#' # Cannot use "|" here, as this will # conflict with piping in custom commands. self.q_output_format_delimiter = q_output_format_delimiter q_output_format_list = [ '%A', '%i', '%P', '%q', '%j', '%u', '%t', '%M', '%L', '%D', '%C', '%R', '%S', '%V', '%Q' ] self.q_output_format = q_output_format_delimiter.join( q_output_format_list) self.model_q = TableModelQueue(q_output_format_list) self.proxy_model_q = QtCore.QSortFilterProxyModel() self.proxy_model_q.setSourceModel(self.model_q) self.proxy_model_q.setSortRole(Qt.UserRole) self.tableView_q.setModel(self.proxy_model_q) self.tableView_q.setSortingEnabled(True) self.tableView_q.setSelectionBehavior( QtWidgets.QAbstractItemView.SelectRows) self.tableWidget_load.verticalHeader().setVisible(False) self.tableWidget_load.resizeColumnsToContents() self.q_cmd_extra_args = {} for i in range(self.comboBox_q_cmd.count()): k = self.comboBox_q_cmd.itemText(i) self.q_cmd_extra_args[k] = '' x0, y0 = 100, 300 width, height = 1200, 700 ini_width_load_table = 500 self.setGeometry(x0, y0, width, height) # Adjust initial splitter ratio self.splitter.setSizes( [ini_width_load_table, width - ini_width_load_table]) # Change the initial selection for "scancel" type self.comboBox_scancel_type.setCurrentText('Only Selected') self.update_edit_q_cmd_suppl('All') self.pushButton_update_q.clicked.connect(self.update_q_table) self.pushButton_update_load.clicked.connect(self.update_load_table) self.pushButton_scancel.clicked.connect(self.scancel) self.lineEdit_q_cmd_suppl.textEdited.connect( self.update_q_cmd_extra_args) self.comboBox_q_cmd.currentTextChanged.connect( self.update_edit_q_cmd_suppl)