display server version in ServerinfoDialog
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from gotify_tray.gotify.models import GotifyVersionModel
|
||||
from gotify_tray.tasks import VerifyServerInfoTask
|
||||
from PyQt6 import QtWidgets
|
||||
|
||||
from gotify_tray.tasks import VerifyServerInfoTask
|
||||
from .designs.widget_server import Ui_Dialog
|
||||
|
||||
|
||||
@@ -11,7 +12,9 @@ class ServerInfoDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.setWindowTitle("Server info")
|
||||
self.line_url.setText(url)
|
||||
self.line_token.setText(token)
|
||||
self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setDisabled(True)
|
||||
self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setDisabled(
|
||||
True
|
||||
)
|
||||
self.link_callbacks()
|
||||
|
||||
def test_server_info(self):
|
||||
@@ -25,7 +28,9 @@ class ServerInfoDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
return
|
||||
|
||||
self.pb_test.setDisabled(True)
|
||||
self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setDisabled(True)
|
||||
self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setDisabled(
|
||||
True
|
||||
)
|
||||
|
||||
self.task = VerifyServerInfoTask(url, client_token)
|
||||
self.task.success.connect(self.server_info_success)
|
||||
@@ -33,22 +38,35 @@ class ServerInfoDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.task.incorrect_url.connect(self.incorrect_url_callback)
|
||||
self.task.start()
|
||||
|
||||
def server_info_success(self):
|
||||
def server_info_success(self, version: GotifyVersionModel):
|
||||
self.pb_test.setEnabled(True)
|
||||
self.label_server_info.setText(f"Version: {version.version}")
|
||||
self.pb_test.setStyleSheet("background-color: rgba(0, 255, 0, 100);")
|
||||
self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setEnabled(True)
|
||||
self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setEnabled(
|
||||
True
|
||||
)
|
||||
|
||||
def incorrect_token_callback(self):
|
||||
def incorrect_token_callback(self, version: GotifyVersionModel):
|
||||
self.pb_test.setEnabled(True)
|
||||
self.label_server_info.setText(f"Version: {version.version}")
|
||||
self.pb_test.setStyleSheet("background-color: rgba(255, 0, 0, 100);")
|
||||
self.line_token.setStyleSheet("border: 1px solid red;")
|
||||
|
||||
def incorrect_url_callback(self):
|
||||
self.pb_test.setEnabled(True)
|
||||
self.label_server_info.clear()
|
||||
self.pb_test.setStyleSheet("background-color: rgba(255, 0, 0, 100);")
|
||||
self.line_url.setStyleSheet("border: 1px solid red;")
|
||||
|
||||
def link_callbacks(self):
|
||||
self.pb_test.clicked.connect(self.test_server_info)
|
||||
self.line_url.textChanged.connect(lambda: self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setDisabled(True))
|
||||
self.line_token.textChanged.connect(lambda: self.buttonBox.button(QtWidgets.QDialogButtonBox.StandardButton.Ok).setDisabled(True))
|
||||
self.line_url.textChanged.connect(
|
||||
lambda: self.buttonBox.button(
|
||||
QtWidgets.QDialogButtonBox.StandardButton.Ok
|
||||
).setDisabled(True)
|
||||
)
|
||||
self.line_token.textChanged.connect(
|
||||
lambda: self.buttonBox.button(
|
||||
QtWidgets.QDialogButtonBox.StandardButton.Ok
|
||||
).setDisabled(True)
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Form implementation generated from reading ui file 'gotify_tray/gui/designs\widget_server.ui'
|
||||
#
|
||||
# Created by: PyQt6 UI code generator 6.1.1
|
||||
# Created by: PyQt6 UI code generator 6.2.1
|
||||
#
|
||||
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
|
||||
# run again. Do not edit this file unless you know what you are doing.
|
||||
@@ -12,9 +12,16 @@ from PyQt6 import QtCore, QtGui, QtWidgets
|
||||
class Ui_Dialog(object):
|
||||
def setupUi(self, Dialog):
|
||||
Dialog.setObjectName("Dialog")
|
||||
Dialog.resize(300, 124)
|
||||
Dialog.resize(300, 130)
|
||||
self.gridLayout = QtWidgets.QGridLayout(Dialog)
|
||||
self.gridLayout.setObjectName("gridLayout")
|
||||
self.label_server_info = QtWidgets.QLabel(Dialog)
|
||||
self.label_server_info.setText("")
|
||||
self.label_server_info.setObjectName("label_server_info")
|
||||
self.gridLayout.addWidget(self.label_server_info, 1, 2, 1, 1)
|
||||
self.pb_test = QtWidgets.QPushButton(Dialog)
|
||||
self.pb_test.setObjectName("pb_test")
|
||||
self.gridLayout.addWidget(self.pb_test, 1, 4, 1, 1)
|
||||
self.formLayout = QtWidgets.QFormLayout()
|
||||
self.formLayout.setObjectName("formLayout")
|
||||
self.label = QtWidgets.QLabel(Dialog)
|
||||
@@ -29,29 +36,26 @@ class Ui_Dialog(object):
|
||||
self.line_token = QtWidgets.QLineEdit(Dialog)
|
||||
self.line_token.setObjectName("line_token")
|
||||
self.formLayout.setWidget(1, QtWidgets.QFormLayout.ItemRole.FieldRole, self.line_token)
|
||||
self.gridLayout.addLayout(self.formLayout, 0, 0, 1, 2)
|
||||
self.pb_test = QtWidgets.QPushButton(Dialog)
|
||||
self.pb_test.setObjectName("pb_test")
|
||||
self.gridLayout.addWidget(self.pb_test, 1, 1, 1, 1)
|
||||
self.gridLayout.addLayout(self.formLayout, 0, 1, 1, 4)
|
||||
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
|
||||
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok)
|
||||
self.buttonBox.setObjectName("buttonBox")
|
||||
self.gridLayout.addWidget(self.buttonBox, 2, 1, 1, 1)
|
||||
self.gridLayout.addWidget(self.buttonBox, 2, 4, 1, 1)
|
||||
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
self.gridLayout.addItem(spacerItem, 1, 0, 1, 1)
|
||||
self.gridLayout.addItem(spacerItem, 1, 3, 1, 1)
|
||||
|
||||
self.retranslateUi(Dialog)
|
||||
self.buttonBox.accepted.connect(Dialog.accept)
|
||||
self.buttonBox.rejected.connect(Dialog.reject)
|
||||
self.buttonBox.accepted.connect(Dialog.accept) # type: ignore
|
||||
self.buttonBox.rejected.connect(Dialog.reject) # type: ignore
|
||||
QtCore.QMetaObject.connectSlotsByName(Dialog)
|
||||
|
||||
def retranslateUi(self, Dialog):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
|
||||
self.pb_test.setText(_translate("Dialog", "Test"))
|
||||
self.label.setText(_translate("Dialog", "Server url:"))
|
||||
self.label_2.setText(_translate("Dialog", "Client token:"))
|
||||
self.pb_test.setText(_translate("Dialog", "Test"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -7,14 +7,21 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>300</width>
|
||||
<height>124</height>
|
||||
<height>130</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<item row="1" column="4">
|
||||
<widget class="QPushButton" name="pb_test">
|
||||
<property name="text">
|
||||
<string>Test</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="4">
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
@@ -38,14 +45,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="pb_test">
|
||||
<property name="text">
|
||||
<string>Test</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="2" column="4">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@@ -55,7 +55,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="1" column="3">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@@ -68,6 +68,13 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QLabel" name="label_server_info">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
||||
Reference in New Issue
Block a user