added warning state for mongo url input

This commit is contained in:
iLLiCiTiT 2021-04-28 12:06:06 +02:00
parent c104c26c74
commit fee3a2484e
2 changed files with 18 additions and 2 deletions

View file

@ -94,7 +94,11 @@ class MongoUrlInput(QtWidgets.QLineEdit):
def set_valid(self):
"""Set valid state on mongo url input."""
self.setProperty("state", "valid")
# self.ensurePolished()
self.style().polish(self)
def set_warning(self):
"""Set invalid state on mongo url input."""
self.setProperty("state", "warning")
self.style().polish(self)
def set_invalid(self):
@ -369,8 +373,14 @@ class InstallDialog(QtWidgets.QDialog):
self.reject()
def _on_mongo_url_change(self, new_value):
# Strip the value
new_value = new_value.strip()
# Store new mongo url to variable
self.mongo_url = new_value
if self.mongo_url_regex.match(new_value):
# Change style of input
if not new_value:
self._mongo_input.set_warning()
elif self.mongo_url_regex.match(new_value):
self._mongo_input.set_valid()
else:
self._mongo_input.set_invalid()

View file

@ -26,6 +26,12 @@ QLineEdit[state="invalid"] {
border: 1px solid rgb(64, 32, 32);
}
QLineEdit[state="warning"] {
background-color: rgb(32, 32, 19);
color: rgb(255, 190, 15);
border: 1px solid rgb(64, 64, 32);
}
QScrollBar:vertical {
border: 1px solid rgb(61, 115, 97);
background: #000;