def add_parent_folder(self): row_idx = self.rowCount() self.insertRow(row_idx) items = [] p = Pixmap(":/icons/images/material/arrow_upward.svg") p.replace_color(QColor(0, 0, 0), QColor(0x99, 0x99, 0x99)) items.append(CustomTableItem(QIcon(p), "")) items.append(CustomTableItem(_("TEXT_FILE_TREE_PARENT_FOLDER"))) items.append(CustomTableItem()) items.append(CustomTableItem()) items.append(CustomTableItem()) for col, item in zip(Column, items): item.setData(NAME_DATA_INDEX, "") item.setData(TYPE_DATA_INDEX, FileType.ParentFolder) item.setData(UUID_DATA_INDEX, None) item.setFlags(Qt.ItemIsEnabled) self.setItem(row_idx, col, item)
def change_selection(self): selected = self.selectedItems() for item in self.previous_selection: if item.column() == Column.ICON: file_type = item.data(TYPE_DATA_INDEX) if file_type == FileType.ParentWorkspace or file_type == FileType.ParentFolder: p = Pixmap(":/icons/images/material/arrow_upward.svg") p.replace_color(QColor(0, 0, 0), QColor(0x99, 0x99, 0x99)) item.setIcon(QIcon(p)) elif file_type == FileType.File or file_type == FileType.Folder: item.switch_icon() for item in selected: if item.column() == Column.ICON: file_type = item.data(TYPE_DATA_INDEX) if file_type == FileType.ParentWorkspace or file_type == FileType.ParentFolder: p = Pixmap(":/icons/images/material/arrow_upward.svg") p.replace_color(QColor(0, 0, 0), QColor(255, 255, 255)) item.setIcon(QIcon(p)) elif file_type == FileType.File or file_type == FileType.Folder: item.switch_icon() self.previous_selection = selected
def set_status_update_failed(self): p = Pixmap(":/icons/images/material/sync_problem.svg") p.replace_color(QColor(0, 0, 0), QColor(0xF1, 0x96, 0x2B)) self.label_status.setPixmap(p) self.status_timer.start()
def set_status_updated(self): p = Pixmap(":/icons/images/material/done.svg") p.replace_color(QColor(0, 0, 0), QColor(0x8B, 0xC3, 0x4A)) self.label_status.setPixmap(p) self.status_timer.start()
def set_status_updating(self): p = Pixmap(":/icons/images/material/update.svg") p.replace_color(QColor(0, 0, 0), QColor(0x99, 0x99, 0x99)) self.label_status.setPixmap(p)
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()