예제 #1
0
    def __init__(self, parent):
        super().__init__(parent)
        layout = QHBoxLayout(self)
        self.logo = QLabel()
        self.logo.setPixmap(load_image('header_logo.png'))

        self.user_state = QLabel(_("Signed out."))

        self.login = QPushButton(_('Sign in'))
        self.login.clicked.connect(self.on_login_clicked)

        self.logout = QPushButton(_('Sign out'))
        self.logout.clicked.connect(self.on_logout_clicked)
        self.logout.setVisible(False)

        self.refresh = QPushButton(_('Refresh'))
        self.refresh.clicked.connect(self.on_refresh_clicked)
        self.refresh.setVisible(False)

        layout.addWidget(self.logo)
        layout.addStretch()
        layout.addWidget(self.user_state)
        layout.addWidget(self.login)
        layout.addWidget(self.logout)
        layout.addWidget(self.refresh)
예제 #2
0
    def __init__(self,
                 source_db_object,
                 submission_db_object,
                 controller,
                 align="left"):
        """
        Given some text, an indication of alignment ('left' or 'right') and
        a reference to the controller, make something to display a file.

        Align is set to left by default because currently SecureDrop can only
        accept files from sources to journalists.
        """
        super().__init__()
        self.controller = controller
        self.source = source_db_object
        self.submission = submission_db_object
        layout = QHBoxLayout()
        icon = QLabel()
        icon.setPixmap(load_image('file.png'))
        if submission_db_object.is_downloaded:
            description = QLabel("Open")
        else:
            human_filesize = humanize_filesize(self.submission.size)
            description = QLabel("Download ({})".format(human_filesize))
        if align is not "left":
            # Float right...
            layout.addStretch(5)
        layout.addWidget(icon)
        layout.addWidget(description, 5)
        if align is "left":
            # Add space on right hand side...
            layout.addStretch(5)
        self.setLayout(layout)
예제 #3
0
    def __init__(self, source: Source, controller: Controller) -> None:
        super().__init__()

        layout = QVBoxLayout()
        self.setLayout(layout)
        layout.setContentsMargins(0, 0, 0, 0)

        self.source = source
        self.controller = controller

        self.text_edit = QTextEdit()

        self.send_button = QPushButton()
        self.send_button.clicked.connect(self.send_reply)
        self.send_button.setMaximumSize(40, 40)

        button_pixmap = load_image('send.png')
        button_icon = QIcon(button_pixmap)
        self.send_button.setIcon(button_icon)
        self.send_button.setIconSize(button_pixmap.rect().size())

        self.controller.authentication_state.connect(
            self._on_authentication_changed)
        self._on_authentication_changed(self.controller.is_authenticated)

        layout.addWidget(self.text_edit)
        layout.addWidget(self.send_button, 0, Qt.AlignRight)
예제 #4
0
    def __init__(self, source, controller):
        super().__init__()
        self.controller = controller
        self.source = source

        ellipsis_icon = load_image("ellipsis.svg")
        self.setIcon(QIcon(ellipsis_icon))

        self.menu = SourceMenu(self.source, self.controller)
        self.setMenu(self.menu)

        self.setPopupMode(QToolButton.InstantPopup)
예제 #5
0
 def __init__(self, text, align):
     """
     """
     super().__init__()
     layout = QHBoxLayout()
     icon = QLabel()
     icon.setPixmap(load_image('file.png'))
     description = QLabel(text)
     if align is not "left":
         # Float right...
         layout.addStretch(5)
     layout.addWidget(icon)
     layout.addWidget(description, 5)
     if align is "left":
         # Add space on right hand side...
         layout.addStretch(5)
     self.setLayout(layout)
예제 #6
0
    def update(self):
        icon = QLabel()
        icon.setPixmap(load_image('file.png'))

        if self.submission.is_downloaded:
            description = QLabel("Open")
        else:
            human_filesize = humanize_filesize(self.submission.size)
            description = QLabel("Download ({})".format(human_filesize))

        if self.align != "left":
            # Float right...
            self.layout.addStretch(5)

        self.layout.addWidget(icon)
        self.layout.addWidget(description, 5)

        if self.align == "left":
            # Add space on right hand side...
            self.layout.addStretch(5)