Beispiel #1
0
    def __init__(self, parent, title, main_text, buttons, show_input=False):
        DialogContainer.__init__(self, parent)

        uic.loadUi(get_ui_file_path('buttonsdialog.ui'), self.dialog_widget)

        self.dialog_widget.setSizePolicy(QSizePolicy.Fixed,
                                         QSizePolicy.Expanding)

        self.dialog_widget.dialog_title_label.setText(title)

        self.dialog_widget.dialog_main_text_label.setText(main_text)
        self.dialog_widget.dialog_main_text_label.adjustSize()

        if not show_input:
            self.dialog_widget.dialog_input.setHidden(True)
        else:
            self.dialog_widget.dialog_input.returnPressed.connect(
                lambda: self.button_clicked.emit(0))

        hspacer_left = QSpacerItem(1, 1, QSizePolicy.Expanding,
                                   QSizePolicy.Fixed)
        self.dialog_widget.dialog_button_container.layout().addSpacerItem(
            hspacer_left)

        self.buttons = []
        for index in range(len(buttons)):
            self.create_button(index, *buttons[index])

        hspacer_right = QSpacerItem(1, 1, QSizePolicy.Expanding,
                                    QSizePolicy.Fixed)
        self.dialog_widget.dialog_button_container.layout().addSpacerItem(
            hspacer_right)

        self.window().escape_pressed.connect(self.close_dialog)
        self.on_main_window_resize()
Beispiel #2
0
    def __init__(self, parent, title, main_text, buttons, show_input=False):
        DialogContainer.__init__(self, parent)

        uic.loadUi(get_ui_file_path('buttonsdialog.ui'), self.dialog_widget)

        self.dialog_widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)

        self.dialog_widget.dialog_title_label.setText(title)

        self.dialog_widget.dialog_main_text_label.setText(main_text)
        self.dialog_widget.dialog_main_text_label.adjustSize()

        if not show_input:
            self.dialog_widget.dialog_input.setHidden(True)
        else:
            self.dialog_widget.dialog_input.returnPressed.connect(lambda: self.button_clicked.emit(0))

        hspacer_left = QSpacerItem(1, 1, QSizePolicy.Expanding, QSizePolicy.Fixed)
        self.dialog_widget.dialog_button_container.layout().addSpacerItem(hspacer_left)

        self.buttons = []
        for index in range(len(buttons)):
            self.create_button(index, *buttons[index])

        hspacer_right = QSpacerItem(1, 1, QSizePolicy.Expanding, QSizePolicy.Fixed)
        self.dialog_widget.dialog_button_container.layout().addSpacerItem(hspacer_right)

        self.window().escape_pressed.connect(self.close_dialog)
        self.on_main_window_resize()
Beispiel #3
0
    def __init__(self, parent, download_uri, torrent_name):
        DialogContainer.__init__(self, parent)

        self.download_uri = download_uri
        gui_settings = self.window().gui_settings

        uic.loadUi(get_ui_file_path('startdownloaddialog.ui'), self.dialog_widget)

        self.dialog_widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)

        self.dialog_widget.browse_dir_button.clicked.connect(self.on_browse_dir_clicked)
        self.dialog_widget.cancel_button.clicked.connect(lambda: self.button_clicked.emit(0))
        self.dialog_widget.download_button.clicked.connect(lambda: self.button_clicked.emit(1))

        if self.window().tribler_settings:
            self.dialog_widget.destination_input.setText(self.window().tribler_settings['downloadconfig']['saveas'])

        self.dialog_widget.torrent_name_label.setText(torrent_name)

        self.dialog_widget.safe_seed_checkbox.setChecked(get_gui_setting(gui_settings, "default_safeseeding_enabled",
                                                                         True, is_bool=True))
        self.dialog_widget.anon_download_checkbox.setChecked(get_gui_setting(gui_settings, "default_anonymity_enabled",
                                                                             True, is_bool=True))

        self.dialog_widget.safe_seed_checkbox.setEnabled(self.dialog_widget.anon_download_checkbox.isChecked())
        self.dialog_widget.anon_download_checkbox.stateChanged.connect(self.on_anon_download_state_changed)

        self.perform_files_request()
        self.dialog_widget.files_list_view.setHidden(True)
        self.dialog_widget.adjustSize()

        self.on_main_window_resize()
Beispiel #4
0
    def __init__(self, parent, is_ask, price_type, quantity_type):
        DialogContainer.__init__(self, parent)

        self.is_ask = is_ask
        self.price = -1
        self.price_type = price_type
        self.quantity = -1
        self.quantity_type = quantity_type

        uic.loadUi(get_ui_file_path('newmarketorderdialog.ui'),
                   self.dialog_widget)

        self.dialog_widget.setSizePolicy(QSizePolicy.Fixed,
                                         QSizePolicy.Expanding)
        self.dialog_widget.error_text_label.hide()

        if is_ask:
            self.dialog_widget.new_order_title_label.setText(
                'Sell %s for %s' % (quantity_type, price_type))
        else:
            self.dialog_widget.new_order_title_label.setText(
                'Buy %s for %s' % (quantity_type, price_type))

        self.dialog_widget.quantity_label.setText("Volume (%s):" %
                                                  quantity_type)
        self.dialog_widget.price_label.setText("Price per unit (%s):" %
                                               price_type)

        self.dialog_widget.create_button.clicked.connect(
            self.on_create_clicked)
        self.dialog_widget.cancel_button.clicked.connect(
            lambda: self.button_clicked.emit(0))

        self.update_window()
    def __init__(self, parent):
        DialogContainer.__init__(self, parent)

        uic.loadUi(get_ui_file_path('trustexplanation.ui'), self.dialog_widget)

        self.dialog_widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)
        self.dialog_widget.close_button.clicked.connect(self.close_dialog)

        self.update_window()
    def __init__(self, parent, bank_name, required_input):
        DialogContainer.__init__(self, parent)

        self.required_input = required_input

        uic.loadUi(get_ui_file_path('iom_input_dialog.ui'), self.dialog_widget)

        self.dialog_widget.cancel_button.clicked.connect(
            lambda: self.button_clicked.emit(0))
        self.dialog_widget.confirm_button.clicked.connect(
            lambda: self.button_clicked.emit(1))

        if 'error_text' in required_input:
            self.dialog_widget.error_text_label.setText(
                required_input['error_text'])
        else:
            self.dialog_widget.error_text_label.hide()

        if 'image' in required_input['additional_data']:
            qimg = QImage()
            qimg.loadFromData(
                b64decode(required_input['additional_data']['image']))
            image = QPixmap.fromImage(qimg)
            scene = QGraphicsScene(self.dialog_widget.img_graphics_view)
            scene.addPixmap(image)
            self.dialog_widget.img_graphics_view.setScene(scene)
        else:
            self.dialog_widget.img_graphics_view.hide()

        self.dialog_widget.iom_input_title_label.setText(bank_name)

        vlayout = QVBoxLayout()
        self.dialog_widget.user_input_container.setLayout(vlayout)

        self.input_widgets = {}

        for specific_input in self.required_input['required_fields']:
            label_widget = QLabel(self.dialog_widget.user_input_container)
            label_widget.setText(specific_input['text'] + ":")
            label_widget.show()
            vlayout.addWidget(label_widget)

            input_widget = QLineEdit(self.dialog_widget.user_input_container)
            input_widget.setPlaceholderText(specific_input['placeholder'])
            if specific_input['type'] == 'password':
                input_widget.setEchoMode(QLineEdit.Password)

            input_widget.show()
            vlayout.addWidget(input_widget)
            self.input_widgets[specific_input['name']] = input_widget

        self.dialog_widget.setSizePolicy(QSizePolicy.Fixed,
                                         QSizePolicy.Expanding)
        self.dialog_widget.adjustSize()

        self.on_main_window_resize()
Beispiel #7
0
    def __init__(self, parent):
        DialogContainer.__init__(self, parent)

        uic.loadUi(get_ui_file_path('trustexplanation.ui'), self.dialog_widget)

        self.dialog_widget.setSizePolicy(QSizePolicy.Fixed,
                                         QSizePolicy.Expanding)
        self.dialog_widget.close_button.clicked.connect(self.close_dialog)

        self.update_window()
Beispiel #8
0
    def __init__(self, parent, bank_name, required_input):
        DialogContainer.__init__(self, parent)

        self.required_input = required_input

        uic.loadUi(get_ui_file_path('iom_input_dialog.ui'), self.dialog_widget)

        self.dialog_widget.cancel_button.clicked.connect(lambda: self.button_clicked.emit(0))
        self.dialog_widget.confirm_button.clicked.connect(lambda: self.button_clicked.emit(1))

        if 'error_text' in required_input:
            self.dialog_widget.error_text_label.setText(required_input['error_text'])
        else:
            self.dialog_widget.error_text_label.hide()

        if 'image' in required_input['additional_data']:
            qimg = QImage()
            qimg.loadFromData(b64decode(required_input['additional_data']['image']))
            image = QPixmap.fromImage(qimg)
            scene = QGraphicsScene(self.dialog_widget.img_graphics_view)
            scene.addPixmap(image)
            self.dialog_widget.img_graphics_view.setScene(scene)
        else:
            self.dialog_widget.img_graphics_view.hide()

        self.dialog_widget.iom_input_title_label.setText(bank_name)

        vlayout = QVBoxLayout()
        self.dialog_widget.user_input_container.setLayout(vlayout)

        self.input_widgets = {}

        for specific_input in self.required_input['required_fields']:
            label_widget = QLabel(self.dialog_widget.user_input_container)
            label_widget.setText(specific_input['text'] + ":")
            label_widget.show()
            vlayout.addWidget(label_widget)

            input_widget = QLineEdit(self.dialog_widget.user_input_container)
            input_widget.setPlaceholderText(specific_input['placeholder'])
            if specific_input['type'] == 'password':
                input_widget.setEchoMode(QLineEdit.Password)

            input_widget.show()
            vlayout.addWidget(input_widget)
            self.input_widgets[specific_input['name']] = input_widget

        self.dialog_widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)
        self.dialog_widget.adjustSize()

        self.on_main_window_resize()
Beispiel #9
0
    def __init__(self, parent, is_ask, asset1_type, asset2_type, wallets):
        DialogContainer.__init__(self, parent)

        self.is_ask = is_ask
        self.price = 0.0
        self.price_type = asset2_type
        self.quantity = -1
        self.quantity_type = asset1_type
        self.wallets = wallets

        # These asset amount values are only set when the order has been verified on the GUI side
        self.asset1_amount = 0
        self.asset2_amount = 0

        uic.loadUi(get_ui_file_path('newmarketorderdialog.ui'),
                   self.dialog_widget)

        self.dialog_widget.setSizePolicy(QSizePolicy.Fixed,
                                         QSizePolicy.Expanding)
        self.dialog_widget.error_text_label.hide()

        if is_ask:
            self.dialog_widget.new_order_title_label.setText(
                'Sell %s for %s' % (asset1_type, asset2_type))
        else:
            self.dialog_widget.new_order_title_label.setText(
                'Buy %s for %s' % (asset1_type, asset2_type))

        self.dialog_widget.quantity_label.setText("Volume (%s):" % asset1_type)
        self.dialog_widget.price_label.setText("Price per unit (%s / %s):" %
                                               (asset2_type, asset1_type))

        self.dialog_widget.create_button.clicked.connect(
            self.on_create_clicked)
        self.dialog_widget.cancel_button.clicked.connect(
            lambda: self.button_clicked.emit(0))

        self.update_window()
    def __init__(self, parent, download_uri):
        DialogContainer.__init__(self, parent)

        torrent_name = download_uri
        if torrent_name.startswith('file:'):
            torrent_name = torrent_name[5:]
        elif torrent_name.startswith('magnet:'):
            torrent_name = unquote_plus(torrent_name)

        self.download_uri = download_uri
        self.has_metainfo = False
        gui_settings = self.window().gui_settings

        uic.loadUi(get_ui_file_path('startdownloaddialog.ui'),
                   self.dialog_widget)

        self.dialog_widget.setSizePolicy(QSizePolicy.Fixed,
                                         QSizePolicy.Expanding)

        self.dialog_widget.browse_dir_button.clicked.connect(
            self.on_browse_dir_clicked)
        self.dialog_widget.cancel_button.clicked.connect(
            lambda: self.button_clicked.emit(0))
        self.dialog_widget.download_button.clicked.connect(
            self.on_download_clicked)
        self.dialog_widget.select_all_files_button.clicked.connect(
            self.on_all_files_selected_clicked)
        self.dialog_widget.deselect_all_files_button.clicked.connect(
            self.on_all_files_deselected_clicked)

        self.dialog_widget.destination_input.setStyleSheet("""
        QComboBox {
            background-color: #444;
            border: none;
            color: #C0C0C0;
            padding: 4px;
        }
        QComboBox::drop-down {
            width: 20px;
            border: 1px solid #999;
            border-radius: 2px;
        }
        QComboBox QAbstractItemView {
            selection-background-color: #707070;
            color: #C0C0C0;
        }
        QComboBox::down-arrow {
            width: 12px;
            height: 12px;
            image: url('%s');
        }
        """ % get_image_path('down_arrow_input.png'))

        if self.window().tribler_settings:
            # Set the most recent download locations in the QComboBox
            current_settings = get_gui_setting(self.window().gui_settings,
                                               "recent_download_locations", "")
            if len(current_settings) > 0:
                recent_locations = [
                    url.decode('hex') for url in current_settings.split(",")
                ]
                self.dialog_widget.destination_input.addItems(recent_locations)
            else:
                self.dialog_widget.destination_input.setCurrentText(
                    self.window().tribler_settings['download_defaults']
                    ['saveas'])

        self.dialog_widget.torrent_name_label.setText(torrent_name)

        self.dialog_widget.anon_download_checkbox.stateChanged.connect(
            self.on_anon_download_state_changed)
        self.dialog_widget.anon_download_checkbox\
            .setChecked(self.window().tribler_settings['download_defaults']['anonymity_enabled'])
        self.dialog_widget.safe_seed_checkbox\
            .setChecked(self.window().tribler_settings['download_defaults']['safeseeding_enabled'])

        self.dialog_widget.safe_seed_checkbox.setEnabled(
            self.dialog_widget.anon_download_checkbox.isChecked())

        self.perform_files_request()
        self.dialog_widget.files_list_view.setHidden(True)
        self.dialog_widget.download_files_container.setHidden(True)
        self.dialog_widget.adjustSize()
        self.on_anon_download_state_changed(None)

        self.on_main_window_resize()
Beispiel #11
0
    def __init__(self, parent, download_uri):
        DialogContainer.__init__(self, parent)

        torrent_name = download_uri
        if torrent_name.startswith('file:'):
            torrent_name = torrent_name[5:]
        elif torrent_name.startswith('magnet:'):
            torrent_name = unquote_plus(torrent_name)

        self.download_uri = download_uri
        self.has_metainfo = False

        uic.loadUi(get_ui_file_path('startdownloaddialog.ui'), self.dialog_widget)

        self.dialog_widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)

        self.dialog_widget.browse_dir_button.clicked.connect(self.on_browse_dir_clicked)
        self.dialog_widget.cancel_button.clicked.connect(lambda: self.button_clicked.emit(0))
        self.dialog_widget.download_button.clicked.connect(self.on_download_clicked)
        self.dialog_widget.select_all_files_button.clicked.connect(self.on_all_files_selected_clicked)
        self.dialog_widget.deselect_all_files_button.clicked.connect(self.on_all_files_deselected_clicked)

        self.dialog_widget.destination_input.setStyleSheet("""
        QComboBox {
            background-color: #444;
            border: none;
            color: #C0C0C0;
            padding: 4px;
        }
        QComboBox::drop-down {
            width: 20px;
            border: 1px solid #999;
            border-radius: 2px;
        }
        QComboBox QAbstractItemView {
            selection-background-color: #707070;
            color: #C0C0C0;
        }
        QComboBox::down-arrow {
            width: 12px;
            height: 12px;
            image: url('%s');
        }
        """ % get_image_path('down_arrow_input.png'))

        if self.window().tribler_settings:
            # Set the most recent download locations in the QComboBox
            current_settings = get_gui_setting(self.window().gui_settings, "recent_download_locations", "")
            if len(current_settings) > 0:
                recent_locations = [url.decode('hex').decode('utf-8') for url in current_settings.split(",")]
                self.dialog_widget.destination_input.addItems(recent_locations)
            else:
                self.dialog_widget.destination_input.setCurrentText(
                    self.window().tribler_settings['download_defaults']['saveas'])

        self.dialog_widget.torrent_name_label.setText(torrent_name)

        self.dialog_widget.anon_download_checkbox.stateChanged.connect(self.on_anon_download_state_changed)
        self.dialog_widget.anon_download_checkbox\
            .setChecked(self.window().tribler_settings['download_defaults']['anonymity_enabled'])
        self.dialog_widget.safe_seed_checkbox\
            .setChecked(self.window().tribler_settings['download_defaults']['safeseeding_enabled'])

        self.dialog_widget.safe_seed_checkbox.setEnabled(self.dialog_widget.anon_download_checkbox.isChecked())

        self.perform_files_request()
        self.dialog_widget.files_list_view.setHidden(True)
        self.dialog_widget.download_files_container.setHidden(True)
        self.dialog_widget.adjustSize()
        self.on_anon_download_state_changed(None)

        self.on_main_window_resize()