def update_progress(self, message): step = self.progressbar.value() + 1 self.progressbar.setValue(step) self.message.setText(message) if step == 2: # "Connecting to <nickname>..." self.icon_connection.setPixmap(Pixmap("lines_dotted.png", 128)) self.icon_server.setPixmap(Pixmap("cloud_storage.png", 220)) elif step == 5: # After await_ready() self.icon_connection.setPixmap(Pixmap("lines_solid.png", 128)) elif step == self.progressbar.maximum(): # "Done!" self.checkmark.setPixmap(Pixmap("green_checkmark.png", 32))
def reset(self): self.progressbar.setValue(0) self.message.setText("") self.finish_button.hide() self.checkmark.setPixmap(Pixmap("pixel.png", 32)) self.tor_label.hide() self.progressbar.setStyleSheet("")
def __init__(self, gateway, gui): super().__init__() self.gateway = gateway self.gui = gui self.state = 0 self.num_connected = 0 self.num_known = 0 self.available_space = 0 self.checkmark_icon = QLabel() self.checkmark_icon.setPixmap(Pixmap("checkmark.png", 20)) self.syncing_icon = QLabel() self.sync_movie = QMovie(resource("sync.gif")) self.sync_movie.setCacheMode(True) self.sync_movie.updated.connect( lambda: self.syncing_icon.setPixmap(self.sync_movie.currentPixmap( ).scaled(20, 20, Qt.KeepAspectRatio, Qt.SmoothTransformation))) self.status_label = QLabel() p = self.palette() dimmer_grey = BlendedColor(p.windowText().color(), p.window().color(), 0.6).name() self.status_label.setStyleSheet(f"QLabel {{ color: {dimmer_grey} }}") self.status_label.setFont(Font(10)) self.setStyleSheet("QToolButton { border: none }") # self.setStyleSheet(""" # QToolButton { color: dimgrey; border: none; } # QToolButton:hover { # background-color: #FAFAFA; # border: 1px solid grey; # border-radius: 2px; # } # """) self.tor_button = QToolButton() self.tor_button.setIconSize(QSize(20, 20)) self.tor_action = QAction( QIcon(resource("tor-onion.png")), "This connection is being routed through the Tor network", ) self.tor_button.setDefaultAction(self.tor_action) if not self.gateway.use_tor: self.tor_button.hide() preferences_button = QToolButton(self) preferences_button.setIcon(QIcon(resource("preferences.png"))) preferences_button.setIconSize(QSize(20, 20)) preferences_button.setMenu(Menu(self.gui, show_open_action=False)) preferences_button.setPopupMode(2) preferences_button.setStyleSheet( "QToolButton::menu-indicator { image: none }") layout = QGridLayout(self) left, _, right, bottom = layout.getContentsMargins() layout.setContentsMargins(left, 0, right, bottom - 2) layout.addWidget(self.checkmark_icon, 1, 1) layout.addWidget(self.syncing_icon, 1, 1) layout.addWidget(self.status_label, 1, 2) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 3) layout.addWidget(self.tor_button, 1, 4) layout.addWidget(preferences_button, 1, 6) self.gateway.monitor.total_sync_state_updated.connect( self.on_sync_state_updated) self.gateway.monitor.space_updated.connect(self.on_space_updated) self.gateway.monitor.nodes_updated.connect(self.on_nodes_updated) self.on_sync_state_updated(0)
def on_got_icon(self, path): self.mail_open_icon.setPixmap(Pixmap(path, 128)) self.mail_closed_icon.hide() self.mail_open_icon.show()
def __init__(self, gateway, gui, folder_names=None): super(InviteSenderDialog, self).__init__() self.gateway = gateway self.gui = gui self.folder_names = folder_names self.folder_names_humanized = humanized_list(folder_names, 'folders') self.settings = {} self.pending_invites = [] self.use_tor = self.gateway.use_tor self.setMinimumSize(500, 300) header_icon = QLabel(self) if self.folder_names: icon = QFileIconProvider().icon( QFileInfo( self.gateway.get_magic_folder_directory( self.folder_names[0]))) else: icon = QIcon(os.path.join(gateway.nodedir, 'icon')) if not icon.availableSizes(): icon = QIcon(resource('tahoe-lafs.png')) header_icon.setPixmap(icon.pixmap(50, 50)) header_text = QLabel(self) if self.folder_names: header_text.setText(self.folder_names_humanized) else: header_text.setText(self.gateway.name) header_text.setFont(Font(18)) header_text.setAlignment(Qt.AlignCenter) header_layout = QGridLayout() header_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 1) header_layout.addWidget(header_icon, 1, 2) header_layout.addWidget(header_text, 1, 3) header_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 4) self.subtext_label = QLabel(self) self.subtext_label.setFont(Font(10)) self.subtext_label.setStyleSheet("color: grey") self.subtext_label.setWordWrap(True) self.subtext_label.setAlignment(Qt.AlignCenter) self.noise_label = QLabel() font = Font(16) font.setFamily("Courier") font.setStyleHint(QFont.Monospace) self.noise_label.setFont(font) self.noise_label.setStyleSheet("color: grey") self.noise_timer = QTimer() self.noise_timer.timeout.connect( lambda: self.noise_label.setText(b58encode(os.urandom(16)))) self.noise_timer.start(75) self.code_label = QLabel() self.code_label.setFont(Font(18)) self.code_label.setTextInteractionFlags(Qt.TextSelectableByMouse) self.code_label.hide() self.box_title = QLabel(self) self.box_title.setAlignment(Qt.AlignCenter) self.box_title.setFont(Font(16)) self.box = QGroupBox() self.box.setAlignment(Qt.AlignCenter) self.box.setStyleSheet('QGroupBox {font-size: 16px}') self.copy_button = QToolButton() self.copy_button.setIcon(QIcon(resource('copy.png'))) self.copy_button.setToolTip("Copy to clipboard") self.copy_button.setStyleSheet('border: 0px; padding: 0px;') self.copy_button.hide() box_layout = QGridLayout(self.box) box_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 1) box_layout.addWidget(self.noise_label, 1, 2) box_layout.addWidget(self.code_label, 1, 3) box_layout.addWidget(self.copy_button, 1, 4) box_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 5) self.close_button = QPushButton("Close and cancel invite") self.close_button.setAutoDefault(False) self.checkmark = QLabel() self.checkmark.setPixmap(Pixmap('green_checkmark.png', 32)) self.checkmark.setAlignment(Qt.AlignCenter) self.checkmark.hide() self.tor_label = QLabel() self.tor_label.setToolTip( "This connection is being routed through the Tor network.") self.tor_label.setPixmap(Pixmap('tor-onion.png', 24)) self.tor_label.hide() self.progress_bar = QProgressBar() self.progress_bar.setMaximum(2) self.progress_bar.setTextVisible(False) self.progress_bar.hide() layout = QGridLayout(self) layout.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Expanding), 0, 0) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 1) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 2) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 3) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 4) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 5) layout.addLayout(header_layout, 1, 3) layout.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Expanding), 2, 1) layout.addWidget(self.box_title, 3, 2, 1, 3) layout.addWidget(self.checkmark, 3, 3) layout.addWidget(self.tor_label, 4, 1, 1, 1, Qt.AlignRight | Qt.AlignVCenter) layout.addWidget(self.box, 4, 2, 1, 3) layout.addWidget(self.progress_bar, 4, 2, 1, 3) layout.addWidget(self.subtext_label, 5, 2, 1, 3) layout.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Expanding), 6, 1) layout.addWidget(self.close_button, 7, 3) layout.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Expanding), 8, 1) self.copy_button.clicked.connect(self.on_copy_button_clicked) self.close_button.clicked.connect(self.close) self.set_box_title("Generating invite code...") self.subtext_label.setText("Creating folder invite(s)...\n\n") if self.use_tor: self.tor_label.show() self.progress_bar.setStyleSheet( 'QProgressBar::chunk {{ background-color: {}; }}'.format( TOR_PURPLE)) self.go() # XXX
def __init__(self, gateways): super(InviteReceiverDialog, self).__init__() self.gateways = gateways self.invite_receiver = None self.joined_folders = [] self.setMinimumSize(500, 300) self.mail_closed_icon = QLabel() self.mail_closed_icon.setAlignment(Qt.AlignCenter) self.mail_closed_icon.setPixmap(Pixmap('mail-envelope-closed.png', 128)) self.mail_open_icon = QLabel() self.mail_open_icon.setAlignment(Qt.AlignCenter) self.mail_open_icon.setPixmap(Pixmap('mail-envelope-open.png', 128)) self.folder_icon = QLabel() icon = QFileIconProvider().icon(QFileInfo(config_dir)) self.folder_icon.setPixmap(icon.pixmap(128, 128)) self.folder_icon.setAlignment(Qt.AlignCenter) self.invite_code_widget = InviteCodeWidget(self) self.invite_code_widget.lineedit.go.connect(self.go) # XXX self.tor_label = QLabel() self.tor_label.setToolTip( "This connection is being routed through the Tor network.") self.tor_label.setPixmap(Pixmap('tor-onion.png', 24)) self.checkmark = QLabel() self.checkmark.setAlignment(Qt.AlignCenter) self.checkmark.setPixmap(Pixmap('green_checkmark.png', 32)) self.progressbar = QProgressBar(self) self.progressbar.setValue(0) self.progressbar.setMaximum(6) # XXX self.progressbar.setTextVisible(False) self.message_label = QLabel(' ') self.message_label.setStyleSheet("color: grey") self.message_label.setAlignment(Qt.AlignCenter) self.error_label = QLabel() self.error_label.setStyleSheet("color: red") self.error_label.setAlignment(Qt.AlignCenter) self.close_button = QPushButton("Close") self.close_button.clicked.connect(self.close) layout = QGridLayout(self) layout.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Expanding), 0, 0) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 1) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 2) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 3) layout.addWidget(self.mail_closed_icon, 1, 2, 1, 3) layout.addWidget(self.mail_open_icon, 1, 2, 1, 3) layout.addWidget(self.folder_icon, 1, 2, 1, 3) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 4) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 5) layout.addWidget(self.invite_code_widget, 2, 2, 1, 3) layout.addWidget(self.checkmark, 2, 3, 1, 1) layout.addWidget(self.tor_label, 3, 1, 1, 1, Qt.AlignRight | Qt.AlignVCenter) layout.addWidget(self.progressbar, 3, 2, 1, 3) layout.addWidget(self.message_label, 5, 1, 1, 5) layout.addWidget(self.error_label, 5, 2, 1, 3) layout.addWidget(self.close_button, 6, 3) layout.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Expanding), 7, 1) self.reset()
def __init__(self, parent=None): super(WelcomeWidget, self).__init__() self.parent = parent application_settings = global_settings["application"] logo_icon = application_settings.get("logo_icon") if logo_icon: icon_file = logo_icon icon_size = 288 else: icon_file = application_settings.get("tray_icon") icon_size = 220 self.icon = QLabel() self.icon.setPixmap(Pixmap(icon_file, icon_size)) self.icon.setAlignment(Qt.AlignCenter) self.slogan = QLabel("<i>{}</i>".format( application_settings.get("description", ""))) self.slogan.setFont(Font(12)) p = self.palette() dimmer_grey = BlendedColor(p.windowText().color(), p.window().color()).name() self.slogan.setStyleSheet("color: {}".format(dimmer_grey)) self.slogan.setAlignment(Qt.AlignCenter) if logo_icon: self.slogan.hide() self.invite_code_widget = InviteCodeWidget(self) self.lineedit = self.invite_code_widget.lineedit self.connect_button = QPushButton("Connect") try: default_code = global_settings["connection"]["default"] except KeyError: default_code = "" grid_settings = load_settings_from_cheatcode(default_code) if grid_settings: self.invite_code_widget.hide() nickname = grid_settings.get("nickname") if nickname: font = Font(11) self.connect_button.setFont(font) self.connect_button.setFixedHeight(32) self.connect_button.setText(f"Connect to {nickname}") self.connect_button.clicked.connect( lambda: self.parent.go(default_code, grid_settings)) primary_color = grid_settings.get("color-1") if primary_color: self.connect_button.setStyleSheet( f"background: {primary_color}; color: white") else: self.connect_button.setStyleSheet( "background: green; color: white") else: self.connect_button.hide() self.message = QLabel() self.message.setStyleSheet("color: red") self.message.setAlignment(Qt.AlignCenter) self.message.hide() self.restore_link = QLabel() self.restore_link.setText("<a href>Restore from Recovery Key...</a>") self.restore_link.setFont(Font(9)) self.restore_link.setAlignment(Qt.AlignCenter) self.configure_link = QLabel() self.configure_link.setText("<a href>Manual configuration...</a>") self.configure_link.setFont(Font(9)) self.configure_link.setAlignment(Qt.AlignCenter) self.preferences_button = QPushButton() self.preferences_button.setIcon(QIcon(resource("preferences.png"))) self.preferences_button.setStyleSheet("border: 0px; padding: 0px;") self.preferences_button.setToolTip("Preferences...") self.preferences_button.setFocusPolicy(Qt.NoFocus) links_grid = QGridLayout() links_grid.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Expanding), 1, 1) links_grid.addWidget(self.restore_link, 2, 1) links_grid.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Expanding), 3, 1) links_grid.addWidget(self.configure_link, 4, 1) links_grid.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Expanding), 5, 1) prefs_layout = QGridLayout() prefs_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 1) prefs_layout.addWidget(self.preferences_button, 1, 2) layout = QGridLayout(self) layout.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Expanding), 0, 0) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 1) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 2) layout.addWidget(self.icon, 1, 3) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 4) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 5) layout.addWidget(self.slogan, 2, 3) layout.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Expanding), 3, 1) layout.addWidget(self.invite_code_widget, 4, 2, 1, 3) layout.addWidget(self.connect_button, 4, 2, 1, 3) layout.addWidget(self.message, 5, 3) layout.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Minimum), 6, 1) layout.addLayout(links_grid, 7, 3) layout.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Minimum), 8, 1) layout.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Expanding), 9, 1) layout.addLayout(prefs_layout, 10, 1, 1, 5)
def on_done(self, gateway): self.gateway = gateway self.progressbar.setValue(self.progressbar.maximum()) self.page_2.checkmark.setPixmap(Pixmap("green_checkmark.png", 32)) self.finish_button.show() self.finish_button_clicked() # TODO: Cleanup
def load_service_icon(self, filepath): self.page_2.icon_overlay.setPixmap(Pixmap(filepath, 100))
def __init__(self): super(ProgressBarWidget, self).__init__() self.icon_server = QLabel() self.icon_server.setPixmap(Pixmap("cloud.png", 220)) self.icon_server.setAlignment(Qt.AlignCenter) self.icon_overlay = QLabel() self.icon_overlay.setPixmap(Pixmap("pixel.png", 75)) self.icon_overlay.setAlignment(Qt.AlignHCenter) self.icon_connection = QLabel() self.icon_connection.setPixmap(Pixmap("wifi.png", 128)) self.icon_connection.setAlignment(Qt.AlignCenter) self.icon_client = QLabel() self.icon_client.setPixmap(Pixmap("laptop-with-icon.png", 128)) self.icon_client.setAlignment(Qt.AlignCenter) self.checkmark = QLabel() self.checkmark.setPixmap(Pixmap("pixel.png", 32)) self.checkmark.setAlignment(Qt.AlignCenter) self.tor_label = QLabel() self.tor_label.setToolTip( "This connection is being routed through the Tor network.") self.tor_label.setPixmap(Pixmap("tor-onion.png", 24)) self.tor_label.hide() self.progressbar = QProgressBar() self.progressbar.setMaximum(10) self.progressbar.setTextVisible(False) self.progressbar.setValue(0) self.message = QLabel() p = self.palette() dimmer_grey = BlendedColor(p.windowText().color(), p.window().color()).name() self.message.setStyleSheet("color: {}".format(dimmer_grey)) self.message.setAlignment(Qt.AlignCenter) self.finish_button = QPushButton("Finish") self.finish_button.hide() self.cancel_button = QToolButton() self.cancel_button.setIcon(QIcon(resource("close.png"))) self.cancel_button.setStyleSheet("border: 0px; padding: 0px;") layout = QGridLayout(self) layout.addWidget(self.cancel_button, 0, 5) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 1) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 2) layout.addWidget(self.icon_server, 1, 3) layout.addWidget(self.icon_overlay, 1, 3) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 4) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 5) layout.addWidget(self.icon_connection, 2, 3) layout.addWidget(self.icon_client, 3, 3) layout.addWidget(self.checkmark, 4, 3, 1, 1) layout.addWidget(self.tor_label, 5, 1, 1, 1, Qt.AlignRight) layout.addWidget(self.progressbar, 5, 2, 1, 3) layout.addWidget(self.message, 6, 3) layout.addWidget(self.finish_button, 6, 3) layout.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Expanding), 7, 1)
def __init__(self, parent=None): super(WelcomeWidget, self).__init__() self.parent = parent application_settings = global_settings['application'] logo_icon = application_settings.get('logo_icon') if logo_icon: icon_file = logo_icon icon_size = 288 else: icon_file = application_settings.get('tray_icon') icon_size = 220 self.icon = QLabel() self.icon.setPixmap(Pixmap(icon_file, icon_size)) self.icon.setAlignment(Qt.AlignCenter) self.slogan = QLabel("<i>{}</i>".format( application_settings.get('description', ''))) self.slogan.setFont(Font(12)) p = self.palette() dimmer_grey = BlendedColor(p.windowText().color(), p.window().color()).name() self.slogan.setStyleSheet("color: {}".format(dimmer_grey)) self.slogan.setAlignment(Qt.AlignCenter) if logo_icon: self.slogan.hide() self.invite_code_widget = InviteCodeWidget(self) self.lineedit = self.invite_code_widget.lineedit self.message = QLabel() self.message.setStyleSheet("color: red") self.message.setAlignment(Qt.AlignCenter) self.message.hide() self.restore_link = QLabel() self.restore_link.setText("<a href>Restore from Recovery Key...</a>") self.restore_link.setFont(Font(9)) self.restore_link.setAlignment(Qt.AlignCenter) self.configure_link = QLabel() self.configure_link.setText("<a href>Manual configuration...</a>") self.configure_link.setFont(Font(9)) self.configure_link.setAlignment(Qt.AlignCenter) self.preferences_button = QPushButton() self.preferences_button.setIcon(QIcon(resource('preferences.png'))) self.preferences_button.setStyleSheet('border: 0px; padding: 0px;') self.preferences_button.setToolTip("Preferences...") self.preferences_button.setFocusPolicy(Qt.NoFocus) links_grid = QGridLayout() links_grid.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Expanding), 1, 1) links_grid.addWidget(self.restore_link, 2, 1) links_grid.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Expanding), 3, 1) links_grid.addWidget(self.configure_link, 4, 1) links_grid.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Expanding), 5, 1) prefs_layout = QGridLayout() prefs_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 1) prefs_layout.addWidget(self.preferences_button, 1, 2) layout = QGridLayout(self) layout.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Expanding), 0, 0) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 1) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 2) layout.addWidget(self.icon, 1, 3) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 4) layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, 0), 1, 5) layout.addWidget(self.slogan, 2, 3) layout.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Expanding), 3, 1) layout.addWidget(self.invite_code_widget, 4, 2, 1, 3) layout.addWidget(self.message, 5, 3) layout.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Minimum), 6, 1) layout.addLayout(links_grid, 7, 3) layout.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Minimum), 8, 1) layout.addItem(QSpacerItem(0, 0, 0, QSizePolicy.Expanding), 9, 1) layout.addLayout(prefs_layout, 10, 1, 1, 5)