def __init__(self, core_config, *args, **kwargs): super().__init__(*args, **kwargs) self.setupUi(self) self.menu = MenuWidget(parent=self) self.widget_menu.layout().addWidget(self.menu) self.mount_widget = MountWidget(parent=self) self.mount_widget.reset_taskbar.connect(self.reset_taskbar) self.widget_central.layout().insertWidget(0, self.mount_widget) self.users_widget = UsersWidget(parent=self) self.widget_central.layout().insertWidget(0, self.users_widget) self.devices_widget = DevicesWidget(parent=self) self.widget_central.layout().insertWidget(0, self.devices_widget) self.settings_widget = SettingsWidget(core_config=core_config, parent=self) self.widget_central.layout().insertWidget(0, self.settings_widget) self.notification_center = NotificationCenterWidget(parent=self) self.button_notif = TaskbarButton( icon_path=":/icons/images/icons/menu_settings.png") self.widget_notif.layout().addWidget(self.notification_center) self.notification_center.hide() effect = QGraphicsDropShadowEffect(self) effect.setColor(QColor(100, 100, 100)) effect.setBlurRadius(4) effect.setXOffset(-2) effect.setYOffset(2) self.widget_notif.setGraphicsEffect(effect) self.menu.button_files.clicked.connect(self.show_mount_widget) self.menu.button_users.clicked.connect(self.show_users_widget) self.menu.button_settings.clicked.connect(self.show_settings_widget) self.menu.button_devices.clicked.connect(self.show_devices_widget) self.menu.button_logout.clicked.connect(self.logout_requested.emit) self.button_notif.clicked.connect(self.show_notification_center) self.connection_state_changed.connect( self._on_connection_state_changed) self.notification_center.close_requested.connect( self.close_notification_center) # self.notification_center.add_notification( # "ERROR", "An error message to test how it looks like." # ) # self.notification_center.add_notification( # "WARNING", "Another message but this time its a warning." # ) # self.notification_center.add_notification( # "INFO", "An information message, because we gotta test them all." # ) # self.notification_center.add_notification( # "ERROR", # "And another error message, but this one will be a little bit longer just " # "to see if the GUI can handle it.", # ) self.reset()
def __init__(self, core, jobs_ctx, event_bus, **kwargs): super().__init__(**kwargs) self.setupUi(self) self.jobs_ctx = jobs_ctx self.core = core self.event_bus = event_bus self.menu = MenuWidget(parent=self) self.widget_menu.layout().addWidget(self.menu) for e in self.NOTIFICATION_EVENTS: self.event_bus.connect(e, self.handle_event) self.label_mountpoint.setText(str(self.core.config.mountpoint_base_dir)) self.label_mountpoint.clicked.connect(self.open_mountpoint) self.menu.organization = self.core.device.organization_addr.organization_id self.menu.username = self.core.device.user_id self.menu.device = self.core.device.device_name self.menu.organization_url = str(self.core.device.organization_addr) self.new_notification.connect(self.on_new_notification) self.menu.files_clicked.connect(self.show_mount_widget) self.menu.users_clicked.connect(self.show_users_widget) self.menu.devices_clicked.connect(self.show_devices_widget) self.menu.logout_clicked.connect(self.logout_requested.emit) self.connection_state_changed.connect(self._on_connection_state_changed) self.widget_title2.hide() self.widget_title3.hide() self.title2_icon.apply_style() self.title3_icon.apply_style() self.icon_mountpoint.apply_style() effect = QGraphicsDropShadowEffect(self) effect.setColor(QColor(100, 100, 100)) effect.setBlurRadius(4) effect.setXOffset(-2) effect.setYOffset(2) self.widget_notif.setGraphicsEffect(effect) self.mount_widget = MountWidget(self.core, self.jobs_ctx, self.event_bus, parent=self) self.widget_central.layout().insertWidget(0, self.mount_widget) self.mount_widget.folder_changed.connect(self._on_folder_changed) self.users_widget = UsersWidget(self.core, self.jobs_ctx, self.event_bus, parent=self) self.widget_central.layout().insertWidget(0, self.users_widget) self.devices_widget = DevicesWidget(self.core, self.jobs_ctx, self.event_bus, parent=self) self.widget_central.layout().insertWidget(0, self.devices_widget) self._on_connection_state_changed( self.core.backend_conn.status, self.core.backend_conn.status_exc ) self.show_mount_widget()
def __init__( self, core: LoggedCore, jobs_ctx: QtToTrioJobScheduler, event_bus: EventBus, systray_notification: pyqtBoundSignal, file_link_addr: Optional[BackendOrganizationFileLinkAddr] = None, parent: Optional[QWidget] = None, ): super().__init__(parent=parent) self.setupUi(self) self.jobs_ctx = jobs_ctx self.core = core self.event_bus = event_bus self.systray_notification = systray_notification self.last_notification = 0.0 self.desync_notified = False self.menu = MenuWidget(parent=self) self.widget_menu.layout().addWidget(self.menu) for e in self.NOTIFICATION_EVENTS: self.event_bus.connect(e, cast(EventCallback, self.handle_event)) self.event_bus.connect(CoreEvent.FS_ENTRY_SYNCED, self._on_vlobs_updated) self.event_bus.connect(CoreEvent.BACKEND_REALM_VLOBS_UPDATED, self._on_vlobs_updated) self.set_user_info() menu = QMenu() if self.core.device.is_admin and is_saas_addr(self.core.device.organization_addr): update_sub_act = menu.addAction(_("ACTION_UPDATE_SUBSCRIPTION")) update_sub_act.triggered.connect(self._on_update_subscription_clicked) copy_backend_addr_act = menu.addAction(_("ACTION_COPY_BACKEND_ADDR")) copy_backend_addr_act.triggered.connect(self._on_copy_backend_addr) menu.addSeparator() change_auth_act = menu.addAction(_("ACTION_DEVICE_MENU_CHANGE_AUTHENTICATION")) change_auth_act.triggered.connect(self.change_authentication) menu.addSeparator() log_out_act = menu.addAction(_("ACTION_LOG_OUT")) log_out_act.triggered.connect(self.logout_requested.emit) self.button_user.setMenu(menu) pix = Pixmap(":/icons/images/material/person.svg") pix.replace_color(QColor(0, 0, 0), QColor(0x00, 0x92, 0xFF)) self.button_user.setIcon(QIcon(pix)) self.button_user.clicked.connect(self._show_user_menu) self.new_notification.connect(self.on_new_notification) self.menu.button_enrollment.setVisible( self.core.device.is_admin and is_pki_enrollment_available() ) if self.core.device.is_outsider: self.menu.button_users.hide() self.menu.files_clicked.connect(self.show_mount_widget) self.menu.users_clicked.connect(self.show_users_widget) self.menu.devices_clicked.connect(self.show_devices_widget) self.menu.enrollment_clicked.connect(self.show_enrollment_widget) self.connection_state_changed.connect(self._on_connection_state_changed) self.navigation_bar_widget.clear() self.navigation_bar_widget.route_clicked.connect(self._on_route_clicked) effect = QGraphicsDropShadowEffect(self) effect.setColor(QColor(100, 100, 100)) effect.setBlurRadius(4) effect.setXOffset(-2) effect.setYOffset(2) self.widget_notif.setGraphicsEffect(effect) self.mount_widget = MountWidget(self.core, self.jobs_ctx, self.event_bus, parent=self) self.widget_central.layout().insertWidget(0, self.mount_widget) self.mount_widget.folder_changed.connect(self._on_folder_changed) self.organization_stats_success.connect(self._on_organization_stats_success) self.organization_stats_error.connect(self._on_organization_stats_error) self.users_widget = UsersWidget(self.core, self.jobs_ctx, self.event_bus, parent=self) self.users_widget.filter_shared_workspaces_request.connect(self.show_mount_widget) self.widget_central.layout().insertWidget(0, self.users_widget) self.devices_widget = DevicesWidget(self.core, self.jobs_ctx, self.event_bus, parent=self) self.widget_central.layout().insertWidget(0, self.devices_widget) self.enrollment_widget = EnrollmentWidget( self.core, self.jobs_ctx, self.event_bus, parent=self ) self.widget_central.layout().insertWidget(0, self.enrollment_widget) self._on_connection_state_changed( self.core.backend_status, self.core.backend_status_exc, allow_systray=False ) if file_link_addr is not None: try: self.go_to_file_link(file_link_addr) except GoToFileLinkBadWorkspaceIDError: show_error( self, _("TEXT_FILE_LINK_WORKSPACE_NOT_FOUND_organization").format( organization=file_link_addr.organization_id ), ) self.show_mount_widget() except GoToFileLinkPathDecryptionError: show_error(self, _("TEXT_INVALID_URL")) self.show_mount_widget() except GoToFileLinkBadOrganizationIDError: show_error( self, _("TEXT_FILE_LINK_NOT_IN_ORG_organization").format( organization=file_link_addr.organization_id ), ) self.show_mount_widget() else: self.show_mount_widget()
def __init__(self, core, jobs_ctx, event_bus, systray_notification, action_addr=None, **kwargs): super().__init__(**kwargs) self.setupUi(self) self.jobs_ctx = jobs_ctx self.core = core self.event_bus = event_bus self.systray_notification = systray_notification self.menu = MenuWidget(parent=self) self.widget_menu.layout().addWidget(self.menu) for e in self.NOTIFICATION_EVENTS: self.event_bus.connect(e, self.handle_event) self.event_bus.connect(CoreEvent.FS_ENTRY_SYNCED, self._on_vlobs_updated_trio) self.event_bus.connect(CoreEvent.BACKEND_REALM_VLOBS_UPDATED, self._on_vlobs_updated_trio) self.vlobs_updated_qt.connect(self._on_vlobs_updated_qt) self.organization_stats_timer = QTimer() self.organization_stats_timer.setInterval(self.RESET_TIMER_STATS) self.organization_stats_timer.setSingleShot(True) self.organization_stats_timer.timeout.connect( self._get_organization_stats) self.set_user_info() menu = QMenu() log_out_act = menu.addAction(_("ACTION_LOG_OUT")) log_out_act.triggered.connect(self.logout_requested.emit) self.button_user.setMenu(menu) pix = Pixmap(":/icons/images/material/person.svg") pix.replace_color(QColor(0, 0, 0), QColor(0x00, 0x92, 0xFF)) self.button_user.setIcon(QIcon(pix)) self.button_user.clicked.connect(self._show_user_menu) self.new_notification.connect(self.on_new_notification) self.menu.files_clicked.connect(self.show_mount_widget) self.menu.users_clicked.connect(self.show_users_widget) self.menu.devices_clicked.connect(self.show_devices_widget) self.connection_state_changed.connect( self._on_connection_state_changed) self.widget_title2.hide() self.icon_title3.hide() self.label_title3.setText("") self.icon_title3.apply_style() self.icon_title3.apply_style() effect = QGraphicsDropShadowEffect(self) effect.setColor(QColor(100, 100, 100)) effect.setBlurRadius(4) effect.setXOffset(-2) effect.setYOffset(2) self.widget_notif.setGraphicsEffect(effect) self.mount_widget = MountWidget(self.core, self.jobs_ctx, self.event_bus, parent=self) self.widget_central.layout().insertWidget(0, self.mount_widget) self.mount_widget.folder_changed.connect(self._on_folder_changed) self.organization_stats_success.connect( self._on_organization_stats_success) self.organization_stats_error.connect( self._on_organization_stats_error) self.users_widget = UsersWidget(self.core, self.jobs_ctx, self.event_bus, parent=self) self.users_widget.filter_shared_workspaces_request.connect( self.show_mount_widget) self.widget_central.layout().insertWidget(0, self.users_widget) self.devices_widget = DevicesWidget(self.core, self.jobs_ctx, self.event_bus, parent=self) self.widget_central.layout().insertWidget(0, self.devices_widget) self._on_connection_state_changed(self.core.backend_status, self.core.backend_status_exc, allow_systray=False) if action_addr is not None: try: self.go_to_file_link(action_addr.workspace_id, action_addr.path) except FSWorkspaceNotFoundError: show_error( self, _("TEXT_FILE_LINK_WORKSPACE_NOT_FOUND_organization"). format(organization=action_addr.organization_id), ) self.show_mount_widget() else: self.show_mount_widget()