/
VolcanoByte
/
vbNotes
Обзор
Документация
Войти
/
VolcanoByte
/
vbNotes
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
sources/uFormSearch.py
84 строки
3 KB
Гаврилюк Евгений Геннадьевич
Added search window
23 мар 2026, 11:39
23 мар 2026, 11:39
42e3925
Код
Авторство
О чём код?
from PyQt6.QtCore import QByteArray from PyQt6.QtWidgets import QDialog, QCheckBox from formSearch import Ui_formSearch from uConsts import StoreConsts from uGlobal import store class FormSearch(QDialog, Ui_formSearch): def __init__(self, parent): super().__init__(parent) self.setupUi(self) self.btnOk.clicked.connect(self.accept) self.btnCancel.clicked.connect(self.reject) self.finished.connect(self.on_close) self.readSettings() self.cbxWhat.setCurrentText('') self.cbxWhat.setCurrentIndex(-1) self.cbxWhat.clearEditText() self.timer_id = self.startTimer(0) def timerEvent(self, event): """Обновляем состояние пунктов меню и кнопок""" isCheck = ( self.cbTitle.isChecked() or self.cbText.isChecked() or self.cbDescription.isChecked() ) self.btnOk.setEnabled(bool(self.cbxWhat.currentText()) and isCheck) @staticmethod def setChecked(obj: QCheckBox, name: str): value = store.value(name, False) obj.setChecked(type(value) == bool and value or value=='true') def readSettings(self): self.restoreGeometry(store.value( StoreConsts.SearchFormGeometry, QByteArray())) self.setChecked(self.cbTitle, StoreConsts.SearchTitle) self.setChecked(self.cbText, StoreConsts.SearchText) self.setChecked(self.cbDescription, StoreConsts.SearchDescription) self.readSearchHistory() def writeSettings(self): store.setValue(StoreConsts.SearchFormGeometry, self.saveGeometry()) if self.result(): store.setValue(StoreConsts.SearchTitle, self.cbTitle.isChecked()) store.setValue(StoreConsts.SearchText, self.cbText.isChecked()) store.setValue(StoreConsts.SearchDescription, self.cbDescription.isChecked()) self.writeSearchHistory() def writeSearchHistory(self): _item = self.cbxWhat.currentText() history = list() model = self.cbxWhat.model() for n in range(self.cbxWhat.count()): history.append(model.item(n).text()) if _item not in history: history.insert(0, _item) store.setValue(StoreConsts.SearchHistory, history) def readSearchHistory(self): history = store.value(StoreConsts.SearchHistory, None) if history: self.cbxWhat.addItems(history) def on_close(self): self.writeSettings()