예제 #1
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()
 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 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()
예제 #5
0
    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()