Example #1
0
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tDataSourcesDialog::ResetGlobal()
{
    QString sourceSelectionString;
    tPilotController* pPilotDevice = 0;
    
    if( tProductSettings::Instance().AutopilotAllowed() )
    {
        pPilotDevice = tGlobal<tPilotManager>::Instance()->GetActivePilotController();
    }

    bool resetAPFirst(false);
    if ( pPilotDevice != 0 && 
         pPilotDevice->GotHeartbeatFromPilotComputer() &&
         pPilotDevice->CommandInterfaceReady() && 
         pPilotDevice->GetCommandInterface()->GetMode() != tPilotCommandInterface::PILOT_MODE_STANDBY )
    {
        sourceSelectionString = tr("Autopilot must be in standby mode before performing a global reset.");
        resetAPFirst = true;
    }
    else
    {
        sourceSelectionString = tr("This will reset all source selections and all instances on all networked units. Are you sure you want to do this?");
    }

    if( confirmationDialog( tr("Global Reset Data Sources"), sourceSelectionString, resetAPFirst ) )
    {
        QTimer::singleShot( 0, m_pSourceSelection, SLOT(GlobalResetSourceSelections()) );
        m_pDataModel->Reset();
        OnItemSelectionChanged( m_pTreeView->currentIndex() ); // Update the SK's
    }
}
Example #2
0
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tDataSourcesDialog::AutoConfigure()
{
    if (confirmationDialog( tr("Auto Configure Data Sources"),
            tr("This will reselect or remove any invalid data source selections. All network devices should be connected and powered on. Are you sure you want to do this?")))
    {
        QTimer::singleShot( 0, m_pSourceSelection, SLOT(StartAutoSourceSelection()) );
    }
}
Example #3
0
void EnterVacationDialog::createEvents()
{
    const EventList events = createEventList( m_ui->startDate->date(),
                                              m_ui->endDate->date().addDays( 1 ),
                                              m_ui->hoursSpinBox->value() * 60 + m_ui->minutesSpinBox->value(),
                                              m_selectedTaskId );

    QDialog confirmationDialog( this );
    QVBoxLayout* layout = new QVBoxLayout( &confirmationDialog );

    QLabel* label = new QLabel( tr( "The following vacation events will be created." ) );
    label->setWordWrap( true );
    layout->addWidget( label );
    QTextBrowser* textBrowser = new QTextBrowser;
    layout->addWidget( textBrowser );
    QDialogButtonBox* box = new QDialogButtonBox;
    box->setStandardButtons( QDialogButtonBox::Ok|QDialogButtonBox::Cancel );
    box->button(QDialogButtonBox::Ok)->setText(tr("Create"));
    connect( box, SIGNAL(accepted()), &confirmationDialog, SLOT(accept()) );
    connect( box, SIGNAL(rejected()), &confirmationDialog, SLOT(reject()) );
    layout->addWidget( box );


    const QString startDate = m_ui->startDate->date().toString( Qt::TextDate );
    const QString endDate = m_ui->endDate->date().toString( Qt::TextDate );
    const Task task = DATAMODEL->getTask( m_selectedTaskId );

    const QString htmlStartDate = toHtmlEscaped( startDate );
    const QString htmlEndDate = toHtmlEscaped( endDate );
    const QString htmlTaskName = toHtmlEscaped( task.name() );

    QString html = "<html><body>";
    html += QString::fromLatin1("<h1>%1</h1>").arg( tr("Vacation"));
    html += QString::fromLatin1("<h3>%1</h3>").arg( tr("From %1 to %2").arg( htmlStartDate, htmlEndDate ) );
    html += QString::fromLatin1("<h4>%1</h4>").arg( tr("Task used: %1").arg( htmlTaskName ) );
    html += "<p>";
    Q_FOREACH ( const Event& event, events ) {
        const QDate eventStart = event.startDateTime().date();
        const QDate eventEnd = event.endDateTime().date();
        Q_ASSERT( eventStart == eventEnd );
        Q_UNUSED( eventEnd ) //release mode
        const QString shortDate = eventStart.toString( Qt::DefaultLocaleShortDate );
        const QString duration = formatDuration( event.startDateTime(), event.endDateTime() );

        const QString htmlShortDate = toHtmlEscaped( shortDate );
        const QString htmlDuration = toHtmlEscaped( duration );

        html += QString::fromLatin1("%1").arg( tr( "%1: %3", "short date, duration" ).arg( htmlShortDate, htmlDuration ) );
        html += "</p><p>";
    }
    html += "</p>";
    html += "</body></html>";
    textBrowser->setHtml( html );
    confirmationDialog.resize( 400, 600 );
    if ( confirmationDialog.exec() == QDialog::Accepted )
        m_events = events;
}
Example #4
0
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tDataSourcesDialog::ResetLocal()
{
    if(confirmationDialog( tr("Local Reset Data Sources"), 
        tr("This will revert all local source selections on this unit back to the global selection. Are you sure you want to do this?")))
    {
        m_pSourceSelection->LocalResetSourceSelections();
        m_pDataModel->RefreshModelData();
        OnItemSelectionChanged( m_pTreeView->currentIndex() ); // Update the SK's
    }
}
Example #5
0
void SendCoinsDialog::on_sendButton_clicked()
{
    if(!model || !model->getOptionsModel())
        return;

    QList<SendCoinsRecipient> recipients;
    bool valid = true;

    for(int i = 0; i < ui->entries->count(); ++i)
    {
        SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
        if(entry)
        {
            if(entry->validate())
            {
                recipients.append(entry->getValue());
            }
            else
            {
                valid = false;
            }
        }
    }

    if(!valid || recipients.isEmpty())
    {
        return;
    }

    fNewRecipientAllowed = false;
    WalletModel::UnlockContext ctx(model->requestUnlock());
    if(!ctx.isValid())
    {
        // Unlock wallet was cancelled
        fNewRecipientAllowed = true;
        return;
    }

    // prepare transaction for getting txFee earlier
    WalletModelTransaction currentTransaction(recipients);
    WalletModel::SendCoinsReturn prepareStatus;

    // Always use a CCoinControl instance, use the CoinControlDialog instance if CoinControl has been enabled
    CCoinControl ctrl;
    if (model->getOptionsModel()->getCoinControlFeatures())
        ctrl = *CoinControlDialog::coinControl();

    updateCoinControlState(ctrl);

    prepareStatus = model->prepareTransaction(currentTransaction, ctrl);

    // process prepareStatus and on error generate message shown to user
    processSendCoinsReturn(prepareStatus,
        BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee()));

    if(prepareStatus.status != WalletModel::OK) {
        fNewRecipientAllowed = true;
        return;
    }

    CAmount txFee = currentTransaction.getTransactionFee();

    // Format confirmation message
    QStringList formatted;
    for (const SendCoinsRecipient &rcp : currentTransaction.getRecipients())
    {
        // generate bold amount string with wallet name in case of multiwallet
        QString amount = "<b>" + BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount);
        if (model->isMultiwallet()) {
            amount.append(" <u>"+tr("from wallet %1").arg(GUIUtil::HtmlEscape(model->getWalletName()))+"</u> ");
        }
        amount.append("</b>");
        // generate monospace address string
        QString address = "<span style='font-family: monospace;'>" + rcp.address;
        address.append("</span>");

        QString recipientElement;

        if (!rcp.paymentRequest.IsInitialized()) // normal payment
        {
            if(rcp.label.length() > 0) // label with address
            {
                recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.label));
                recipientElement.append(QString(" (%1)").arg(address));
            }
            else // just address
            {
                recipientElement = tr("%1 to %2").arg(amount, address);
            }
        }
        else if(!rcp.authenticatedMerchant.isEmpty()) // authenticated payment request
        {
            recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.authenticatedMerchant));
        }
        else // unauthenticated payment request
        {
            recipientElement = tr("%1 to %2").arg(amount, address);
        }

        formatted.append(recipientElement);
    }

    QString questionString = tr("Are you sure you want to send?");
    questionString.append("<br /><br />%1");

    if(txFee > 0)
    {
        // append fee string if a fee is required
        questionString.append("<hr /><span style='color:#aa0000;'>");
        questionString.append(BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), txFee));
        questionString.append("</span> ");
        questionString.append(tr("added as transaction fee"));

        // append transaction size
        questionString.append(" (" + QString::number((double)currentTransaction.getTransactionSize() / 1000) + " kB)");
    }

    // add total amount in all subdivision units
    questionString.append("<hr />");
    CAmount totalAmount = currentTransaction.getTotalTransactionAmount() + txFee;
    QStringList alternativeUnits;
    for (BitcoinUnits::Unit u : BitcoinUnits::availableUnits())
    {
        if(u != model->getOptionsModel()->getDisplayUnit())
            alternativeUnits.append(BitcoinUnits::formatHtmlWithUnit(u, totalAmount));
    }
    questionString.append(tr("Total Amount %1")
        .arg(BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), totalAmount)));
    questionString.append(QString("<span style='font-size:10pt;font-weight:normal;'><br />(=%1)</span>")
        .arg(alternativeUnits.join(" " + tr("or") + "<br />")));

    questionString.append("<hr /><span>");
    if (ui->optInRBF->isChecked()) {
        questionString.append(tr("You can increase the fee later (signals Replace-By-Fee, BIP-125)."));
    } else {
        questionString.append(tr("Not signalling Replace-By-Fee, BIP-125."));
    }
    questionString.append("</span>");


    SendConfirmationDialog confirmationDialog(tr("Confirm send coins"),
        questionString.arg(formatted.join("<br />")), SEND_CONFIRM_DELAY, this);
    confirmationDialog.exec();
    QMessageBox::StandardButton retval = static_cast<QMessageBox::StandardButton>(confirmationDialog.result());

    if(retval != QMessageBox::Yes)
    {
        fNewRecipientAllowed = true;
        return;
    }

    // now send the prepared transaction
    WalletModel::SendCoinsReturn sendStatus = model->sendCoins(currentTransaction);
    // process sendStatus and on error generate message shown to user
    processSendCoinsReturn(sendStatus);

    if (sendStatus.status == WalletModel::OK)
    {
        accept();
        CoinControlDialog::coinControl()->UnSelectAll();
        coinControlUpdateLabels();
        Q_EMIT coinsSent(currentTransaction.getTransaction()->GetHash());
    }
    fNewRecipientAllowed = true;
}