mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
Tray is able to show Login Widget but Login Widget can't get cred from browser
This commit is contained in:
parent
be64b7f1c2
commit
a87b3fda7a
3 changed files with 45 additions and 69 deletions
|
|
@ -10,27 +10,19 @@ from pype.ftrack import credentials, login_dialog as login_dialog
|
|||
|
||||
# Validation if alredy logged into Ftrack
|
||||
class FtrackRunner:
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, main_parent=None, parent=None):
|
||||
|
||||
self.parent = parent
|
||||
self.parent.loginWidget = login_dialog.Login_Dialog_ui()
|
||||
self.loginWidget = login_dialog.Login_Dialog_ui()
|
||||
|
||||
# try:
|
||||
# self.validate()
|
||||
# except Exception as e:
|
||||
# print(e)
|
||||
|
||||
# self.setServer()
|
||||
self.validate()
|
||||
self.setServer()
|
||||
try:
|
||||
self.validate()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def showLoginWidget(self):
|
||||
# self.parent.loginWidget.exec_()
|
||||
|
||||
# self.parent.loginWidget.show()
|
||||
# self.parent.loginWidget.showMe()
|
||||
test = login_dialog.Login_Dialog_ui()
|
||||
test.show()
|
||||
del(test)
|
||||
|
||||
self.loginWidget.show()
|
||||
|
||||
def validate(self):
|
||||
validation = False
|
||||
|
|
@ -43,18 +35,18 @@ class FtrackRunner:
|
|||
)
|
||||
if validation is False:
|
||||
self.showLoginWidget()
|
||||
# login_dialog.run_login()
|
||||
else:
|
||||
self.showLoginWidget()
|
||||
# login_dialog.run_login()
|
||||
|
||||
except Exception as e:
|
||||
print("We are unable to connect to Ftrack")
|
||||
print(e)
|
||||
|
||||
validation = credentials._check_credentials()
|
||||
if not validation:
|
||||
print("We are unable to connect to Ftrack")
|
||||
sys.exit()
|
||||
if validation is True:
|
||||
print("You are connected to Ftrack")
|
||||
else:
|
||||
print("Please sign in")
|
||||
|
||||
def logout(self):
|
||||
credentials._clear_credentials()
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ class Login_Dialog_ui(QtWidgets.QWidget):
|
|||
|
||||
def __init__(self, parent=None):
|
||||
|
||||
super().__init__()
|
||||
super(Login_Dialog_ui, self).__init__(parent)
|
||||
|
||||
self.loginSignal.connect(self.loginWithCredentials)
|
||||
self._translate = QtCore.QCoreApplication.translate
|
||||
|
||||
|
|
@ -37,11 +38,6 @@ class Login_Dialog_ui(QtWidgets.QWidget):
|
|||
self.setLayout(self._main())
|
||||
self.setWindowTitle('FTrack Login')
|
||||
|
||||
# self.showMe()
|
||||
|
||||
def showMe(self):
|
||||
self.show()
|
||||
|
||||
def _main(self):
|
||||
self.main = QtWidgets.QVBoxLayout()
|
||||
self.main.setObjectName("main")
|
||||
|
|
@ -166,15 +162,15 @@ class Login_Dialog_ui(QtWidgets.QWidget):
|
|||
entity.setStyleSheet("border: 1px solid red;")
|
||||
|
||||
def enter_credentials(self):
|
||||
user = self.user_input.text().strip()
|
||||
api = self.api_input.text().strip()
|
||||
username = self.user_input.text().strip()
|
||||
apiKey = self.api_input.text().strip()
|
||||
msg = "You didn't enter "
|
||||
missing = []
|
||||
if user == "":
|
||||
if username == "":
|
||||
missing.append("Username")
|
||||
self._invalid_input(self.user_input)
|
||||
|
||||
if api == "":
|
||||
if apiKey == "":
|
||||
missing.append("API Key")
|
||||
self._invalid_input(self.api_input)
|
||||
|
||||
|
|
@ -182,7 +178,7 @@ class Login_Dialog_ui(QtWidgets.QWidget):
|
|||
self.setError("{0} {1}".format(msg, " and ".join(missing)))
|
||||
return
|
||||
|
||||
verification = credentials._check_credentials(user, api)
|
||||
verification = credentials._check_credentials(username, apiKey)
|
||||
|
||||
if verification:
|
||||
credentials._save_credentials(username, apiKey)
|
||||
|
|
@ -285,14 +281,9 @@ class Login_Dialog_ui(QtWidgets.QWidget):
|
|||
credentials._set_env(username, apiKey)
|
||||
self._close_widget()
|
||||
|
||||
def closeEvent(self, event):
|
||||
event.ignore()
|
||||
self._close_widget()
|
||||
|
||||
def _close_widget(self):
|
||||
# self.close()
|
||||
self.hide()
|
||||
|
||||
|
||||
def run_login():
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
ui = Login_Dialog_ui()
|
||||
ui.show()
|
||||
app.exec_()
|
||||
|
|
|
|||
|
|
@ -7,53 +7,46 @@ from app.vendor.Qt import QtCore, QtGui, QtWidgets
|
|||
|
||||
|
||||
class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
|
||||
def __init__(self, icon, parent=None):
|
||||
def __init__(self, parent=None):
|
||||
|
||||
icon = r'C:\Users\jakub.trllo\CODE\pype-setup\repos\avalon-launcher\launcher\res\icon\main.png'
|
||||
icon = QtGui.QIcon(icon)
|
||||
|
||||
QtWidgets.QSystemTrayIcon.__init__(self, icon, parent)
|
||||
|
||||
|
||||
# Store parent - QtWidgets.QMainWindow()
|
||||
self.parent = parent
|
||||
self.tray = QtWidgets.QSystemTrayIcon(icon, parent)
|
||||
self.tray.setToolTip("Avalon Launcher")
|
||||
|
||||
|
||||
self.menu = QtWidgets.QMenu(self.parent)
|
||||
# Setup menu in Tray
|
||||
self.menu = QtWidgets.QMenu()
|
||||
self.menu.setStyleSheet(style.load_stylesheet())
|
||||
|
||||
# TODO - Recognize that ftrack is used:
|
||||
self.ftrack = FtrackRunner(self)
|
||||
# Add ftrack menu (TODO - Recognize that ftrack is used!!!!!!)
|
||||
self.ftrack = FtrackRunner(self.parent, self)
|
||||
self.menu.addMenu(self.ftrack.trayMenu(self.menu))
|
||||
|
||||
# Add Exit action to menu
|
||||
aExit = QtWidgets.QAction("Exit", self)
|
||||
aExit.triggered.connect(self.exit)
|
||||
self.menu.addAction(aExit)
|
||||
|
||||
# Add menu to Context of SystemTrayIcon
|
||||
self.setContextMenu(self.menu)
|
||||
|
||||
# self.loginWidget = login_dialog.Login_Dialog_ui()
|
||||
# self.loginWidget.show()
|
||||
|
||||
def eventFilter(self, object, event):
|
||||
print(self, object, event)
|
||||
if event.type() == QtCore.QEvent.MouseButtonPress:
|
||||
print("You pressed the button")
|
||||
return True
|
||||
|
||||
if event == QtCore.QEvent.HoverMove:
|
||||
return True
|
||||
|
||||
def exit(self):
|
||||
QtCore.QCoreApplication.exit()
|
||||
|
||||
def _sys_tray(image):
|
||||
|
||||
def _sys_tray():
|
||||
# code source: https://stackoverflow.com/questions/893984/pyqt-show-menu-in-a-system-tray-application - add answer PyQt5
|
||||
#PyQt4 to PyQt5 version: https://stackoverflow.com/questions/20749819/pyqt5-failing-import-of-qtgui
|
||||
# app = QtWidgets.QApplication(sys.argv)
|
||||
app = QtWidgets.QApplication([])
|
||||
app.setQuitOnLastWindowClosed(True)
|
||||
w = QtWidgets.QWidget()
|
||||
trayIcon = SystemTrayIcon(QtGui.QIcon(image), w)
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
# app.setQuitOnLastWindowClosed(True)
|
||||
w = QtWidgets.QMainWindow()
|
||||
# w = QtWidgets.QWidget()
|
||||
trayIcon = SystemTrayIcon(w)
|
||||
trayIcon.show()
|
||||
sys.exit(app.exec_())
|
||||
|
||||
if (__name__ == ('__main__')):
|
||||
avalon_core_icon = r'C:\Users\jakub.trllo\CODE\pype-setup\repos\avalon-launcher\launcher\res\icon\main.png'
|
||||
_sys_tray(avalon_core_icon)
|
||||
_sys_tray()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue