Exemple #1
0
 def __init__(self, is_synced, is_confined, pixmap, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.source = pixmap
     if not IconTableItem.CONFINED_ICON:
         IconTableItem.CONFINED_ICON = Pixmap(":/icons/images/material/block.svg")
         IconTableItem.CONFINED_ICON.replace_color(QColor(0, 0, 0), QColor(0xBB, 0xBB, 0xBB))
     if not IconTableItem.SYNCED_ICON:
         IconTableItem.SYNCED_ICON = Pixmap(":/icons/images/material/check.svg")
         IconTableItem.SYNCED_ICON.replace_color(QColor(0, 0, 0), QColor(50, 168, 82))
     if not IconTableItem.UNSYNCED_ICON:
         IconTableItem.UNSYNCED_ICON = Pixmap(":/icons/images/material/cached.svg")
         IconTableItem.UNSYNCED_ICON.replace_color(QColor(0, 0, 0), QColor(219, 20, 20))
     self._is_synced = is_synced
     self._is_confined = is_confined
     self.switch_icon()
Exemple #2
0
    def add_parent_workspace(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_WORKSPACE")))
        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.ParentWorkspace)
            item.setData(UUID_DATA_INDEX, None)
            item.setFlags(Qt.ItemIsEnabled)
            self.setItem(row_idx, col, item)
Exemple #3
0
 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
Exemple #4
0
 def _draw_pixmap(self, source, selected, synced, confined):
     color = QColor(0x99, 0x99, 0x99)
     if confined:
         color = QColor(0xDD, 0xDD, 0xDD)
         if selected:
             color = QColor(0xAA, 0xAA, 0xAA)
     elif selected:
         color = QColor(0x33, 0x33, 0x33)
     p = Pixmap(source)
     if p.isNull():
         return
     p = Pixmap(p.scaled(120, 120, Qt.KeepAspectRatio))
     p.replace_color(QColor(0, 0, 0), color)
     painter = QPainter(p)
     if confined:
         painter.drawPixmap(p.width() - 90, 0, 100, 100, IconTableItem.CONFINED_ICON)
     elif synced:
         painter.drawPixmap(p.width() - 90, 0, 100, 100, IconTableItem.SYNCED_ICON)
     else:
         painter.drawPixmap(p.width() - 90, 0, 100, 100, IconTableItem.UNSYNCED_ICON)
     painter.end()
     return p
 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(3000)
 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(3000)
 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)
Exemple #8
0
    def __init__(self,
                 client,
                 jobs_ctx,
                 event_bus,
                 systray_notification,
                 action_addr=None,
                 **kwargs):
        super().__init__(**kwargs)
        self.setupUi(self)

        self.jobs_ctx = jobs_ctx
        self.client = client
        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(ClientEvent.FS_ENTRY_SYNCED,
                               self._on_vlobs_updated_trio)
        self.event_bus.connect(ClientEvent.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()
        change_password_act = menu.addAction(
            _("ACTION_DEVICE_MENU_CHANGE_PASSWORD"))
        change_password_act.triggered.connect(self.change_password)
        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.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.client,
                                        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.client,
                                        self.jobs_ctx,
                                        self.event_bus,
                                        parent=self)
        self.widget_central.layout().insertWidget(0, self.users_widget)

        self.devices_widget = DevicesWidget(self.client,
                                            self.jobs_ctx,
                                            self.event_bus,
                                            parent=self)
        self.widget_central.layout().insertWidget(0, self.devices_widget)

        self._on_connection_state_changed(self.client.backend_status,
                                          self.client.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()