diff --git a/client/ConnectionDialog.py b/client/ConnectionDialog.py index a521d15..adfd0a0 100644 --- a/client/ConnectionDialog.py +++ b/client/ConnectionDialog.py @@ -15,15 +15,17 @@ class Ui_ConnectionDialog(object): def setupUi(self, ConnectionDialog): ConnectionDialog.setObjectName("ConnectionDialog") ConnectionDialog.setWindowModality(QtCore.Qt.WindowModal) - ConnectionDialog.resize(665, 450) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Preferred) + ConnectionDialog.resize(665, 425) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(3) sizePolicy.setHeightForWidth(ConnectionDialog.sizePolicy().hasHeightForWidth()) ConnectionDialog.setSizePolicy(sizePolicy) - ConnectionDialog.setMinimumSize(QtCore.QSize(660, 450)) + ConnectionDialog.setMinimumSize(QtCore.QSize(660, 425)) self.gridLayout = QtWidgets.QGridLayout(ConnectionDialog) self.gridLayout.setObjectName("gridLayout") + spacerItem = QtWidgets.QSpacerItem(20, 3, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum) + self.gridLayout.addItem(spacerItem, 1, 0, 1, 1) self.server_connections_tab = QtWidgets.QTabWidget(ConnectionDialog) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(2) @@ -75,7 +77,28 @@ class Ui_ConnectionDialog(object): self.connection_groupbox.setMinimumSize(QtCore.QSize(0, 100)) self.connection_groupbox.setObjectName("connection_groupbox") self.gridLayout_4 = QtWidgets.QGridLayout(self.connection_groupbox) + self.gridLayout_4.setSizeConstraint(QtWidgets.QLayout.SetMaximumSize) + self.gridLayout_4.setContentsMargins(-1, -1, -1, 0) self.gridLayout_4.setObjectName("gridLayout_4") + self.nickname_layout = QtWidgets.QHBoxLayout() + self.nickname_layout.setObjectName("nickname_layout") + self.nickname_label = QtWidgets.QLabel(self.connection_groupbox) + self.nickname_label.setObjectName("nickname_label") + self.nickname_layout.addWidget(self.nickname_label) + self.nickname_input = QtWidgets.QLineEdit(self.connection_groupbox) + self.nickname_input.setObjectName("nickname_input") + self.nickname_layout.addWidget(self.nickname_input) + self.password_label = QtWidgets.QLabel(self.connection_groupbox) + self.password_label.setObjectName("password_label") + self.nickname_layout.addWidget(self.password_label) + self.password_input = QtWidgets.QLineEdit(self.connection_groupbox) + self.password_input.setEchoMode(QtWidgets.QLineEdit.PasswordEchoOnEdit) + self.password_input.setObjectName("password_input") + self.nickname_layout.addWidget(self.password_input) + self.remember_checkbox = QtWidgets.QCheckBox(self.connection_groupbox) + self.remember_checkbox.setObjectName("remember_checkbox") + self.nickname_layout.addWidget(self.remember_checkbox) + self.gridLayout_4.addLayout(self.nickname_layout, 1, 0, 1, 1) self.connect_layout = QtWidgets.QHBoxLayout() self.connect_layout.setObjectName("connect_layout") self.test_connection_button = QtWidgets.QPushButton(self.connection_groupbox) @@ -114,34 +137,15 @@ class Ui_ConnectionDialog(object): self.port_input.setObjectName("port_input") self.server_address_layout.addWidget(self.port_input) self.gridLayout_4.addLayout(self.server_address_layout, 0, 0, 1, 1) - self.nickname_layout = QtWidgets.QHBoxLayout() - self.nickname_layout.setObjectName("nickname_layout") - self.nickname_label = QtWidgets.QLabel(self.connection_groupbox) - self.nickname_label.setObjectName("nickname_label") - self.nickname_layout.addWidget(self.nickname_label) - self.nickname_input = QtWidgets.QLineEdit(self.connection_groupbox) - self.nickname_input.setObjectName("nickname_input") - self.nickname_layout.addWidget(self.nickname_input) - self.password_label = QtWidgets.QLabel(self.connection_groupbox) - self.password_label.setObjectName("password_label") - self.nickname_layout.addWidget(self.password_label) - self.password_input = QtWidgets.QLineEdit(self.connection_groupbox) - self.password_input.setEchoMode(QtWidgets.QLineEdit.PasswordEchoOnEdit) - self.password_input.setObjectName("password_input") - self.nickname_layout.addWidget(self.password_input) - self.remember_checkbox = QtWidgets.QCheckBox(self.connection_groupbox) - self.remember_checkbox.setObjectName("remember_checkbox") - self.nickname_layout.addWidget(self.remember_checkbox) - self.gridLayout_4.addLayout(self.nickname_layout, 1, 0, 1, 1) self.gridLayout.addWidget(self.connection_groupbox, 2, 0, 3, 1) - spacerItem = QtWidgets.QSpacerItem(20, 5, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum) - self.gridLayout.addItem(spacerItem, 1, 0, 1, 1) self.status_layout = QtWidgets.QHBoxLayout() self.status_layout.setObjectName("status_layout") - self.gridLayout.addLayout(self.status_layout, 5, 0, 1, 1) + self.gridLayout.addLayout(self.status_layout, 6, 0, 1, 1) + spacerItem1 = QtWidgets.QSpacerItem(20, 0, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.MinimumExpanding) + self.gridLayout.addItem(spacerItem1, 5, 0, 1, 1) self.retranslateUi(ConnectionDialog) - self.server_connections_tab.setCurrentIndex(1) + self.server_connections_tab.setCurrentIndex(0) QtCore.QMetaObject.connectSlotsByName(ConnectionDialog) def retranslateUi(self, ConnectionDialog): @@ -156,6 +160,14 @@ class Ui_ConnectionDialog(object): self.server_connections_tab.setTabText(self.server_connections_tab.indexOf(self.recent_tab), _translate("ConnectionDialog", "Recent")) self.connection_groupbox.setStatusTip(_translate("ConnectionDialog", "Edit your connection settings.")) self.connection_groupbox.setTitle(_translate("ConnectionDialog", "Connection Settings")) + self.nickname_label.setText(_translate("ConnectionDialog", "Nickname")) + self.nickname_input.setStatusTip(_translate("ConnectionDialog", "Your human identifier. Without a password, uniqueness is not ensured.")) + self.nickname_input.setPlaceholderText(_translate("ConnectionDialog", "Type your nickname here...")) + self.password_label.setText(_translate("ConnectionDialog", "Password")) + self.password_input.setStatusTip(_translate("ConnectionDialog", "A optional password for preserving your nickname with.")) + self.password_input.setPlaceholderText(_translate("ConnectionDialog", "Optional")) + self.remember_checkbox.setStatusTip(_translate("ConnectionDialog", "Remember this password in plaintext. Kept in Recent and/or Favorites.")) + self.remember_checkbox.setText(_translate("ConnectionDialog", "Remember")) self.test_connection_button.setStatusTip(_translate("ConnectionDialog", "Test your ability to connect to the server")) self.test_connection_button.setText(_translate("ConnectionDialog", "Test Connection")) self.connect_button.setStatusTip(_translate("ConnectionDialog", "Connect to the TCPChat server immediately")) @@ -166,11 +178,3 @@ class Ui_ConnectionDialog(object): self.port_label.setText(_translate("ConnectionDialog", "Port")) self.port_input.setStatusTip(_translate("ConnectionDialog", "The port number the server is running on.")) self.port_input.setPlaceholderText(_translate("ConnectionDialog", "5555")) - self.nickname_label.setText(_translate("ConnectionDialog", "Nickname")) - self.nickname_input.setStatusTip(_translate("ConnectionDialog", "Your human identifier. Without a password, uniqueness is not ensured.")) - self.nickname_input.setPlaceholderText(_translate("ConnectionDialog", "Type your nickname here...")) - self.password_label.setText(_translate("ConnectionDialog", "Password")) - self.password_input.setStatusTip(_translate("ConnectionDialog", "A optional password for preserving your nickname with.")) - self.password_input.setPlaceholderText(_translate("ConnectionDialog", "Optional")) - self.remember_checkbox.setStatusTip(_translate("ConnectionDialog", "Remember this password in plaintext. Kept in Recent and/or Favorites.")) - self.remember_checkbox.setText(_translate("ConnectionDialog", "Remember")) diff --git a/client/dialog.py b/client/dialog.py index d93eef6..0024e7a 100644 --- a/client/dialog.py +++ b/client/dialog.py @@ -3,7 +3,7 @@ from typing import Tuple from PyQt5 import QtCore, QtGui from PyQt5.QtCore import QEvent -from PyQt5.QtWidgets import QDialog, QStatusBar, QWidget +from PyQt5.QtWidgets import QDialog, QStatusBar, QWidget, QSpacerItem, QSizePolicy import constants from client.ConnectionDialog import Ui_ConnectionDialog @@ -48,9 +48,12 @@ class ConnectionDialog(QDialog, Ui_ConnectionDialog): super(ConnectionDialog, self).__init__(*args, **kwargs) self.setupUi(self) - if nickname: self.nickname_input.setText(nickname) - self.connect_button.setDisabled(True) + + if nickname: + self.nickname_input.setText(nickname) + self.validation() + self.server_address_input.textEdited.connect(self.validation) self.port_input.textEdited.connect(self.validation) self.nickname_input.textEdited.connect(self.validation) diff --git a/client/ui/ConnectionDialog.ui b/client/ui/ConnectionDialog.ui index 6f558f9..9e81c1a 100644 --- a/client/ui/ConnectionDialog.ui +++ b/client/ui/ConnectionDialog.ui @@ -10,11 +10,11 @@ 0 0 665 - 450 + 425 - + 0 3 @@ -22,13 +22,29 @@ 660 - 450 + 425 Connect to Server + + + + Qt::Vertical + + + QSizePolicy::Minimum + + + + 20 + 3 + + + + @@ -50,7 +66,7 @@ QTabWidget::Rounded - 1 + 0 @@ -163,6 +179,60 @@ Connection Settings + + QLayout::SetMaximumSize + + + + + + + Nickname + + + + + + + Your human identifier. Without a password, uniqueness is not ensured. + + + Type your nickname here... + + + + + + + Password + + + + + + + A optional password for preserving your nickname with. + + + QLineEdit::PasswordEchoOnEdit + + + Optional + + + + + + + Remember this password in plaintext. Kept in Recent and/or Favorites. + + + Remember + + + + + @@ -249,79 +319,28 @@ - - - - - - Nickname - - - - - - - Your human identifier. Without a password, uniqueness is not ensured. - - - Type your nickname here... - - - - - - - Password - - - - - - - A optional password for preserving your nickname with. - - - QLineEdit::PasswordEchoOnEdit - - - Optional - - - - - - - Remember this password in plaintext. Kept in Recent and/or Favorites. - - - Remember - - - - - - - + + + + + Qt::Vertical - QSizePolicy::Minimum + QSizePolicy::MinimumExpanding 20 - 5 + 0 - - -