def __init__(self, parent): super(QWidget, self).__init__(parent) self.parent = parent self.tree = ProposalsTreeWidget(parent) # Proposals that have been paid for but not submitted. self.unsubmitted_proposals = [] description = ''.join([ 'You can create a budget proposal below. ', 'Proposals require 5 AXE to create. ', 'Your proposal can be submitted once the collateral transaction has enough confirmations.' ]) description = QLabel(_(description)) description.setWordWrap(True) self.name_edit = QLineEdit() self.name_edit.setPlaceholderText(_('Name of your proposal')) self.url_edit = QLineEdit() self.url_edit.setPlaceholderText( _('URL that your proposal can be found at')) self.payments_count_edit = QSpinBox() self.payments_count_edit.setRange(1, 1000000) self.start_block_edit = QSpinBox() self.start_block_edit.setRange(0, 1000000) self.address_edit = QLineEdit() self.address_edit.setPlaceholderText( _('Address that will receive payments')) self.amount_edit = BTCAmountEdit(self.parent.get_decimal_point) self.create_proposal_button = QPushButton(_('Create Proposal')) self.create_proposal_button.clicked.connect(self.create_proposal) self.submit_ready_proposals_button = QPushButton( _('Submit Confirmed Proposals')) self.submit_ready_proposals_button.clicked.connect( self.submit_waiting_proposals) self.submit_ready_proposals_button.setEnabled(False) self.ready_proposals = QLabel() self.ready_proposals.setVisible(False) form = QFormLayout() form.addRow(_('Proposal Name:'), self.name_edit) form.addRow(_('Proposal URL:'), self.url_edit) form.addRow(_('Number of Payments:'), self.payments_count_edit) form.addRow(_('Starting Block:'), self.start_block_edit) form.addRow(_('Payment Address:'), self.address_edit) form.addRow(_('Monthly AXE Payment:'), self.amount_edit) vbox = QVBoxLayout() vbox.addWidget(self.tree) vbox.addWidget(description) vbox.addLayout(form) vbox.addLayout(util.Buttons(self.create_proposal_button)) vbox.addLayout( util.Buttons(self.ready_proposals, self.submit_ready_proposals_button)) self.setLayout(vbox)
def __init__(self, parent): super(MasternodeOutputsTab, self).__init__(parent) self.dialog = parent self.manager = parent.manager include_frozen_checkbox = QCheckBox(_('Include frozen addresses')) include_frozen_checkbox.setChecked(False) self.scan_outputs_button = QPushButton(_('Scan For Masternode Outputs')) def on_scan_outputs(): """Call scan_for_outputs() with whether to include frozen addresses.""" self.scan_for_outputs(include_frozen_checkbox.isChecked()) self.scan_outputs_button.clicked.connect(on_scan_outputs) self.status_edit = QLineEdit() self.status_edit.setReadOnly(True) self.valid_outputs_list = MasternodeOutputsWidget() self.valid_outputs_list.outputSelected.connect(self.set_output) self.collateral_edit = PrevOutWidget() self.collateral_edit.setReadOnly(True) self.mapper = QDataWidgetMapper() self.mapper.setSubmitPolicy(QDataWidgetMapper.ManualSubmit) self.mapper.setModel(self.dialog.masternodes_widget.proxy_model) model = self.dialog.masternodes_widget.model self.mapper.addMapping(self.collateral_edit, model.VIN, 'string') self.save_output_button = QPushButton(_('Save')) self.save_output_button.setEnabled(False) self.save_output_button.clicked.connect(self.save_output) vbox = QVBoxLayout() desc = ' '.join(['Use this tab to scan for and choose a collateral payment for your masternode.', 'A valid collateral payment is exactly 500000 $PAC.']) desc = QLabel(_(desc)) desc.setWordWrap(True) vbox.addWidget(desc) status_box = QHBoxLayout() status_box.setContentsMargins(0, 0, 0, 0) status_box.addWidget(QLabel(_('Status:'))) status_box.addWidget(self.status_edit, stretch=1) vbox.addLayout(status_box) valid_outputs_box = QVBoxLayout() valid_outputs_box.setContentsMargins(0, 0, 0, 0) valid_outputs_box.addWidget(QLabel(_('Masternode Outputs:'))) valid_outputs_box.addWidget(self.valid_outputs_list) #vbox.addLayout(util.Buttons(include_frozen_checkbox, self.scan_outputs_button)) vbox.addLayout(util.Buttons(self.scan_outputs_button)) vbox.addLayout(valid_outputs_box) vbox.addWidget(self.collateral_edit) vbox.addLayout(util.Buttons(self.save_output_button)) self.setLayout(vbox)
def create_layout(self): self.masternodes_widget = MasternodesWidget(self.manager) self.tabs = QTabWidget() self.tabs.addTab(self.create_view_masternode_tab(), _('View Masternode')) self.tabs.addTab(self.create_collateral_tab(), _('Choose Collateral')) self.tabs.addTab(self.create_sign_announce_tab(), _('Activate Masternode')) self.tabs.addTab(self.create_masternode_conf_tab(), _('Masternode.conf')) # Disabled until API is stable. # self.tabs.addTab(self.create_vote_tab(), _('Vote')) # Connect to the selection signal so we can update the widget mapper. self.masternodes_widget.view.selectionModel().selectionChanged.connect( self.on_view_selection_changed) bottom_buttons = util.Buttons(util.CloseButton(self)) vbox = QVBoxLayout() vbox.addWidget(QLabel(_('Masternodes:'))) vbox.addWidget(self.masternodes_widget, stretch=1) vbox.addWidget(self.tabs) vbox.addLayout(bottom_buttons) self.setLayout(vbox)
def __init__(self, main_widget, parent=None): super(ProposalEditor, self).__init__(parent) self.main_widget = main_widget self.name_edit = QLineEdit() self.url_edit = QLineEdit() self.start_block_edit = QLineEdit() self.end_block_edit = QLineEdit() self.amount_edit = QLineEdit() self.address_edit = QLineEdit() self.txid_edit = QLineEdit() for i in [ self.name_edit, self.url_edit, self.start_block_edit, self.end_block_edit, self.amount_edit, self.address_edit, self.txid_edit ]: i.setReadOnly(True) self.mapper = QDataWidgetMapper() self.mapper.setModel(self.main_widget.proxy_model) self.mapper.setSubmitPolicy(QDataWidgetMapper.ManualSubmit) self.mapper.addMapping(self.name_edit, ProposalsModel.NAME) self.mapper.addMapping(self.url_edit, ProposalsModel.URL) self.mapper.addMapping(self.start_block_edit, ProposalsModel.START_BLOCK) self.mapper.addMapping(self.end_block_edit, ProposalsModel.END_BLOCK) self.mapper.addMapping(self.amount_edit, ProposalsModel.AMOUNT) self.mapper.addMapping(self.address_edit, ProposalsModel.ADDRESS) self.mapper.addMapping(self.txid_edit, ProposalsModel.TXID) block_hbox = QHBoxLayout() block_hbox.addWidget(self.start_block_edit) block_hbox.addWidget(QLabel(' - ')) block_hbox.addWidget(self.end_block_edit) self.vote_combo = QComboBox() self.vote_combo.addItem(_('Yes')) self.vote_combo.addItem(_('No')) self.vote_button = QPushButton(_('Vote')) self.vote_button.clicked.connect(self.cast_vote) vote_hbox = util.Buttons(self.vote_combo, self.vote_button) form = QFormLayout() form.addRow(_('Name:'), self.name_edit) form.addRow(_('URL:'), self.url_edit) form.addRow(_('Blocks:'), block_hbox) form.addRow(_('Monthly Payment:'), self.amount_edit) form.addRow(_('Payment Address:'), self.address_edit) form.addRow(_('Fee TxID:'), self.txid_edit) form.addRow(_('Vote:'), vote_hbox) self.setLayout(form)
def create_view_masternode_tab(self): """Create the tab used to view masternodes.""" desc = ' '.join([ 'In this tab, you can view your masternodes and fill in required data about them.', 'The collateral payment for a masternode can be specified using the "Choose Collateral" tab.', ]) desc = QLabel(_(desc)) desc.setWordWrap(True) self.masternode_editor = editor = MasternodeEditor() model = self.masternodes_widget.proxy_model self.mapper = mapper = QDataWidgetMapper() editor.alias_edit.textChanged.connect(self.on_editor_alias_changed) mapper.setSubmitPolicy(QDataWidgetMapper.ManualSubmit) mapper.setModel(model) mapper.addMapping(editor.alias_edit, MasternodesModel.ALIAS) mapper.addMapping(editor.status_edit, MasternodesModel.STATUS) editor.vin_edit.setReadOnly(True) mapper.addMapping(editor.vin_edit, MasternodesModel.VIN, 'string') mapper.addMapping(editor.addr_edit, MasternodesModel.ADDR, 'string') mapper.addMapping(editor.delegate_key_edit, MasternodesModel.DELEGATE) mapper.addMapping(editor.protocol_version_edit, MasternodesModel.PROTOCOL_VERSION) self.save_new_masternode_button = QPushButton('Save As New Masternode') self.save_new_masternode_button.clicked.connect( lambda: self.save_current_masternode(as_new=True)) self.save_masternode_button = QPushButton(_('Save Masternode')) self.save_masternode_button.clicked.connect( self.save_current_masternode) self.delete_masternode_button = QPushButton(_('Delete Masternode')) self.delete_masternode_button.clicked.connect( self.delete_current_masternode) vbox = QVBoxLayout() vbox.addWidget(desc) vbox.addWidget(editor) vbox.addStretch(1) vbox.addLayout( util.Buttons(self.delete_masternode_button, self.save_new_masternode_button, self.save_masternode_button)) w = QWidget() w.setLayout(vbox) return w
def __init__(self, parent): super(SignAnnounceWidget, self).__init__(parent) self.dialog = parent self.manager = parent.manager # Displays the status of the masternode. self.status_edit = QLineEdit() self.status_edit.setReadOnly(True) self.alias_edit = QLineEdit() self.collateral_edit = PrevOutWidget() self.delegate_edit = QLineEdit() self.delegate_edit.setFont(QFont(util.MONOSPACE_FONT)) for i in [self.alias_edit, self.collateral_edit, self.delegate_edit]: i.setReadOnly(True) self.mapper = QDataWidgetMapper() self.mapper.setSubmitPolicy(QDataWidgetMapper.ManualSubmit) self.mapper.setModel(self.dialog.masternodes_widget.proxy_model) model = self.dialog.masternodes_widget.model self.mapper.addMapping(self.alias_edit, model.ALIAS) self.mapper.addMapping(self.collateral_edit, model.VIN, 'string') self.mapper.addMapping(self.delegate_edit, model.DELEGATE) self.sign_button = QPushButton(_('Activate Masternode')) self.sign_button.setEnabled(False) self.sign_button.clicked.connect(self.sign_announce) status_box = QHBoxLayout() status_box.setContentsMargins(0, 0, 0, 0) status_box.addWidget(QLabel(_('Status:'))) status_box.addWidget(self.status_edit, stretch=1) vbox = QVBoxLayout() vbox.addLayout(status_box) form = QFormLayout() form.addRow(_('Alias:'), self.alias_edit) form.addRow(_('Collateral MUE Output:'), self.collateral_edit) form.addRow(_('Masternode Private Key:'), self.delegate_edit) vbox.addLayout(form) vbox.addLayout(util.Buttons(self.sign_button)) self.setLayout(vbox)
def create_masternode_conf_tab(self): """Create the tab used to import masternode.conf files.""" desc = ' '.join([ 'You can use this form to import your masternode.conf file.', 'This file is usually located in the same directory that your wallet file is in.', 'If you just need to import your masternode\'s private key, use the regular process for importing a key.' ]) desc = QLabel(_(desc)) desc.setWordWrap(True) import_filename_edit = QLineEdit() import_filename_edit.setPlaceholderText( _('Enter the path to your masternode.conf')) import_select_file = QPushButton(_('Select File...')) hbox = QHBoxLayout() hbox.addWidget(import_filename_edit, stretch=1) hbox.addWidget(import_select_file) import_conf_button = QPushButton(_('Import')) vbox = QVBoxLayout() vbox.addWidget(desc) vbox.addLayout(hbox) vbox.addLayout(util.Buttons(import_conf_button)) vbox.addStretch(1) def select_import_file(): text = QFileDialog.getOpenFileName(None, _('Select a file to import'), '', '*.conf') if text: import_filename_edit.setText(text) import_select_file.clicked.connect(select_import_file) def do_import_file(): path = str(import_filename_edit.text()) self.import_masternode_conf(path) import_conf_button.clicked.connect(do_import_file) w = QWidget() w.setLayout(vbox) return w