def on_login(self): access_key = self.access_key_lie.text().strip() secret_key = self.secret_key_lie.text().strip() if access_key == '' or secret_key == '': HaocUtils.show_message_box( self, "Please complete the necessary information!") return login_data_state = SCloudUtils.login_cloud(access_key, secret_key) if login_data_state.state != SCloudUtils.ResultDataState.SUCCESS: if login_data_state.state == SCloudUtils.ResultDataState.ACCESS_KEY_ERROR: HaocUtils.show_message_box(self, "AccessKey is not exist!") return elif login_data_state.state == SCloudUtils.ResultDataState.SECRET_KEY_ERROR: HaocUtils.show_message_box(self, "SecretKey is incorrect") return elif login_data_state.state == SCloudUtils.ResultDataState.BAD_NETWORK: HaocUtils.show_message_box( self, "Bad Network or something wrong ,fix your network problem and try again!" ) return else: HaocUtils.show_message_box(self, "Unknown error!") return # Login success else: user_name = None data_state = SCloudUtils.get_user_name() if data_state.state != SCloudUtils.ResultDataState.SUCCESS: # If there is no name make one if data_state.state == SCloudUtils.ResultDataState.TARGET_NOT_FOUND: make_name_w = MakeNameWidget(self) # make_name_w.setParent(self, QtCore.Qt.Dialog) make_name_w.setWindowFlags(QtCore.Qt.Dialog) if make_name_w.exec_(): user_name = make_name_w.get_name().strip() else: return else: HaocUtils.show_message_box( self, "Bad Network or something wrong ,fix your network problem and try again!" ) # Already has a name just get it else: user_name = data_state.data data = HaocUtils.Config(access_key, secret_key, user_name) data.save() asset_manage_widget = AssetMangeWidget(user_name) asset_manage_widget.setStyleSheet(self.styleSheet()) asset_manage_widget.move(self.pos()) asset_manage_widget.show() HaocEventFilter.HaocEventF.installHaocEventF() HaocUtils.is_login = True self.close()
def on_logout(self): data = HaocUtils.Config() data.save() HaocEventFilter.HaocEventF.uninstallHaocEventF() HaocUtils.is_login = False self.close()