Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Return as shortcut to connect/login buttons. #1939

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions mslib/msui/mscolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ def __init__(self, parent=None, mscolab=None):

# connect login, adduser, connect buttons
self.connectBtn.clicked.connect(self.connect_handler)
self.disconnectBtn.clicked.connect(self.disconnect_handler)
self.disconnectBtn.hide()
self.loginBtn.clicked.connect(self.login_handler)
self.addUserBtn.clicked.connect(lambda: self.stackedWidget.setCurrentWidget(self.newuserPage))

Expand Down Expand Up @@ -183,9 +185,9 @@ def page_switched(self, index):
self.newConfirmPasswordLe.setText("")

if index == 1:
self.connectBtn.setEnabled(False)
self.connectBtn.hide()
else:
self.connectBtn.setEnabled(True)
self.connectBtn.show()

def set_status(self, _type="Error", msg=""):
if _type == "Error":
Expand All @@ -210,6 +212,8 @@ def add_mscolab_urls(self):

def enable_login_btn(self):
self.loginBtn.setEnabled(self.loginEmailLe.text() != "" and self.loginPasswordLe.text() != "")
self.loginBtn.setAutoDefault(True)
self.loginBtn.setFocus()

def connect_handler(self):
try:
Expand Down Expand Up @@ -255,12 +259,8 @@ def connect_handler(self):
self.enable_login_btn()

# Change connect button text and connect disconnect handler
self.connectBtn.setText('Disconnect')
try:
self.connectBtn.clicked.disconnect(self.connect_handler)
except TypeError:
pass
self.connectBtn.clicked.connect(self.disconnect_handler)
self.connectBtn.hide()
self.disconnectBtn.show()
else:
logging.error("Error %s", r)
self.set_status("Error", "Some unexpected error occurred. Please try again.")
Expand Down Expand Up @@ -295,9 +295,8 @@ def disconnect_handler(self):
self.mscolab_server_url = None
self.auth = None

self.connectBtn.setText('Connect')
self.connectBtn.clicked.disconnect(self.disconnect_handler)
self.connectBtn.clicked.connect(self.connect_handler)
self.connectBtn.show()
self.disconnectBtn.hide()
self.set_status("Info", 'Disconnected from server.')

def login_handler(self):
Expand Down
8 changes: 7 additions & 1 deletion mslib/msui/qt5/ui_mscolab_connect_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class Ui_MSColabConnectDialog(object):
def setupUi(self, MSColabConnectDialog):
MSColabConnectDialog.setObjectName("MSColabConnectDialog")
MSColabConnectDialog.resize(478, 255)
MSColabConnectDialog.resize(478, 271)
self.verticalLayout = QtWidgets.QVBoxLayout(MSColabConnectDialog)
self.verticalLayout.setContentsMargins(12, 10, 10, 10)
self.verticalLayout.setSpacing(5)
Expand All @@ -32,6 +32,9 @@ def setupUi(self, MSColabConnectDialog):
self.connectBtn.setAutoDefault(False)
self.connectBtn.setObjectName("connectBtn")
self.horizontalLayout_2.addWidget(self.connectBtn)
self.disconnectBtn = QtWidgets.QPushButton(MSColabConnectDialog)
self.disconnectBtn.setObjectName("disconnectBtn")
self.horizontalLayout_2.addWidget(self.disconnectBtn)
self.horizontalLayout_2.setStretch(1, 1)
self.verticalLayout.addLayout(self.horizontalLayout_2)
self.line = QtWidgets.QFrame(MSColabConnectDialog)
Expand Down Expand Up @@ -181,10 +184,13 @@ def retranslateUi(self, MSColabConnectDialog):
self.urlCb.setToolTip(_translate("MSColabConnectDialog", "Enter Mscolab Server URL"))
self.connectBtn.setToolTip(_translate("MSColabConnectDialog", "Connect to entered URL"))
self.connectBtn.setText(_translate("MSColabConnectDialog", "Connect"))
self.connectBtn.setShortcut(_translate("MSColabConnectDialog", "Return"))
self.disconnectBtn.setText(_translate("MSColabConnectDialog", "Disconnect"))
self.addUserBtn.setToolTip(_translate("MSColabConnectDialog", "Add new user to the server"))
self.addUserBtn.setText(_translate("MSColabConnectDialog", "Add user"))
self.loginBtn.setToolTip(_translate("MSColabConnectDialog", "Login using entered credentials"))
self.loginBtn.setText(_translate("MSColabConnectDialog", "Login"))
self.loginBtn.setShortcut(_translate("MSColabConnectDialog", "Return"))
self.loginPasswordLe.setPlaceholderText(_translate("MSColabConnectDialog", "Password"))
self.loginEmailLe.setPlaceholderText(_translate("MSColabConnectDialog", "Email ID"))
self.clickNewUserLabel.setText(_translate("MSColabConnectDialog", "Click here if new user"))
Expand Down
17 changes: 15 additions & 2 deletions mslib/msui/ui/ui_mscolab_connect_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>478</width>
<height>255</height>
<height>271</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -30,7 +30,7 @@
<number>10</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1,0">
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1,0,0">
<item>
<widget class="QLabel" name="urlLabel">
<property name="text">
Expand All @@ -56,11 +56,21 @@
<property name="text">
<string>Connect</string>
</property>
<property name="shortcut">
<string>Return</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="disconnectBtn">
<property name="text">
<string>Disconnect</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down Expand Up @@ -110,6 +120,9 @@
<property name="text">
<string>Login</string>
</property>
<property name="shortcut">
<string>Return</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
Expand Down
2 changes: 1 addition & 1 deletion tests/_test_msui/test_mscolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_connect_success(self, mockbox, mockset):
def test_disconnect(self):
self._connect_to_mscolab()
assert self.window.mscolab_server_url is not None
QtTest.QTest.mouseClick(self.window.connectBtn, QtCore.Qt.LeftButton)
QtTest.QTest.mouseClick(self.window.disconnectBtn, QtCore.Qt.LeftButton)
assert self.window.mscolab_server_url is None
# set ui_name_winodw default
assert self.main_window.usernameLabel.text() == 'User'
Expand Down