コード例 #1
0
ファイル: detailedit.cpp プロジェクト: kazcw/Moneychanger
void MTDetailEdit::onBalancesChangedFromBelow(QString qstrAcctID)
{
    m_PreSelected   = qstrAcctID;
    m_qstrCurrentID = qstrAcctID;

    emit balancesChanged();
}
コード例 #2
0
MTCompose::MTCompose(QWidget *parent) :
    QWidget(parent, Qt::Window),
    m_bSent(false),
    already_init(false),
    ui(new Ui::MTCompose)
{
    ui->setupUi(this);

    this->installEventFilter(this);

    connect(this, SIGNAL(balancesChanged()), this, SLOT(onBalancesChanged()));
}
コード例 #3
0
MTSendDlg::MTSendDlg(QWidget *parent) :
    QWidget(parent, Qt::Window),
    m_bSent(false),
    already_init(false),
    ui(new Ui::MTSendDlg)
{
    ui->setupUi(this);

    this->installEventFilter(this);

    connect(this, SIGNAL(balancesChanged()), this, SLOT(onBalancesChanged()));

    connect(this, SIGNAL(ShowContact(QString)), Moneychanger::It(), SLOT(mc_showcontact_slot(QString)));
    connect(this, SIGNAL(ShowAccount(QString)), Moneychanger::It(), SLOT(mc_show_account_slot(QString)));
}
コード例 #4
0
// ----------------------------------
//virtual
QWidget * MTAccountDetails::CreateCustomTab(int nTab)
{
    const int nCustomTabCount = this->GetCustomTabCount();
    // -----------------------------
    if ((nTab < 0) || (nTab >= nCustomTabCount))
        return NULL; // out of bounds.
    // -----------------------------
    QWidget * pReturnValue = NULL;
    // -----------------------------
    switch (nTab)
    {
    case 0: // "Cash Purse" tab
        if (NULL != m_pOwner)
        {
            if (m_pCashPurse)
            {
                m_pCashPurse->setParent(NULL);
                m_pCashPurse->disconnect();
                m_pCashPurse->deleteLater();

                m_pCashPurse = NULL;
            }
            m_pCashPurse = new MTCashPurse(NULL, *m_pOwner);
            pReturnValue = m_pCashPurse;
            pReturnValue->setContentsMargins(0, 0, 0, 0);

            connect(m_pCashPurse, SIGNAL(balancesChanged(QString)),
                    m_pOwner,     SLOT(onBalancesChangedFromBelow(QString)));
        }
        break;

    default:
        qDebug() << QString("Unexpected: MTAccountDetails::CreateCustomTab was called with bad index: %1").arg(nTab);
        return NULL;
    }
    // -----------------------------
    return pReturnValue;
}
コード例 #5
0
ファイル: senddlg.cpp プロジェクト: kazcw/Moneychanger
// ----------------------------------------------------------------------
bool MTSendDlg::sendFunds(QString memo, QString qstr_amount)
{
    QString & toNymId     = m_hisNymId;
    QString & fromAcctId  = m_myAcctId;
    // ----------------------------------------------------
    if (toNymId.isEmpty())
    {
        qDebug() << "Cannot send funds to an empty nym id, aborting.";
        return false;
    }
    // ----------------------------------------------------
    if (fromAcctId.isEmpty())
    {
        qDebug() << "Cannot send funds from an empty acct id, aborting.";
        return false;
    }
    // ----------------------------------------------------
    if (memo.isEmpty())
        memo = tr("From the desktop client. (Empty memo.)");
    // ----------------------------------------------------
    if (qstr_amount.isEmpty())
        qstr_amount = QString("0");
    // ----------------------------------------------------
    int64_t     amount = 0;
    std::string str_assetId(OTAPI_Wrap::GetAccountWallet_AssetTypeID(fromAcctId.toStdString()));

    if (!str_assetId.empty())
    {
        std::string str_amount(qstr_amount.toStdString());

        if (std::string::npos == str_amount.find(".")) // not found
            str_amount += '.';

        amount = OTAPI_Wrap::It()->StringToAmount(str_assetId, str_amount);
    }
    // ----------------------------------------------------
    if (amount <= 0)
    {
        qDebug() << "Cannot send a negative or zero amount.";
        return false;
    }
    // ----------------------------------------------------
    QString qstrPaymentType("");

    switch (ui->comboBox->currentIndex())
    {
    case (0): // Payment ("Cashier's Cheque")
        qstrPaymentType = tr("payment");
        m_bSent = sendCashierCheque(amount, toNymId, fromAcctId, memo);
        break;

    case (1): // Cheque
        qstrPaymentType = tr("cheque");
        m_bSent = sendCheque(amount, toNymId, fromAcctId, memo);
        break;

    case (2): // Cash
        qstrPaymentType = tr("cash");
        m_bSent = sendCash(amount, toNymId, fromAcctId, memo);
        break;

    default:  // ERROR
        qDebug() << "Error in MTSendDlg::sendFunds -- the comboBox has a bad index selected.";
        return false;
    }
    // ----------------------------------------------------
    if (!m_bSent)
    {
        qDebug() << "send funds: Failed.";
        QMessageBox::warning(this, tr("Failure"), QString("%1 %2.").arg(tr("Failure trying to send")).arg(qstrPaymentType));
    }
    else
    {
        qDebug() << "Success in send funds!";
        QMessageBox::information(this, tr("Success"), QString("%1 %2.").arg(tr("Success sending")).arg(qstrPaymentType));

        emit balancesChanged();
    }
    // ---------------------------------------------------------
    return m_bSent;
}
コード例 #6
0
void MTSendDlg::dialog()
{
/** Send Funds Dialog **/

    if (!already_init)
    {
        connect(this,               SIGNAL(balancesChanged()),
                Moneychanger::It(), SLOT  (onBalancesChanged()));
        // ---------------------------------------
        this->setWindowTitle(tr("Send Funds"));

        QString style_sheet = "QPushButton{border: none; border-style: outset; text-align:left; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #dadbde, stop: 1 #f6f7fa);}"
                "QPushButton:pressed {border: 1px solid black; text-align:left; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #dadbde, stop: 1 #f6f7fa); }"
                "QPushButton:hover {border: 1px solid black; text-align:left; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #dadbde, stop: 1 #f6f7fa); }";

        ui->fromButton->setStyleSheet(style_sheet);
        ui->toButton->setStyleSheet(style_sheet);

        // Here if there is pre-set data for the subject, contents, to, from, server, etc
        // then we set it here.
        //
        // -------------------------------------------
        std::string str_my_name;
        // -------------------------------------------
        if (!m_myAcctId.isEmpty()) // myAcct was provided.
        {
            MTNameLookupQT theLookup;

            str_my_name = theLookup.GetAcctName(m_myAcctId.toStdString());

            if (str_my_name.empty())
                str_my_name = m_myAcctId.toStdString();
        }
        // -------------------------------------------
        if (str_my_name.empty())
        {
            m_myAcctId = QString("");
            ui->fromButton->setText(tr("<Click to Select Account>"));
        }
        else
        {
            QString from_button_text = MTHome::FormDisplayLabelForAcctButton(m_myAcctId, QString::fromStdString(str_my_name));

            ui->fromButton->setText(from_button_text);
        }
        // -------------------------------------------


        // -------------------------------------------
        std::string str_his_name;
        // -------------------------------------------
        if (!m_hisNymId.isEmpty()) // hisNym was provided.
        {
            MTNameLookupQT theLookup;

            str_his_name = theLookup.GetNymName(m_hisNymId.toStdString());

            if (str_his_name.empty())
                str_his_name = m_hisNymId.toStdString();
        }
        // -------------------------------------------
        if (str_his_name.empty())
        {
            m_hisNymId = QString("");
            ui->toButton->setText(tr("<Click to choose Recipient>"));
        }
        else
            ui->toButton->setText(QString::fromStdString(str_his_name));
        // -------------------------------------------



        // -------------------------------------------
        if (!m_memo.isEmpty())
        {
            QString qstrTemp = m_memo;
            ui->memoEdit->setText(qstrTemp);
            // -----------------------
            this->setWindowTitle(tr("Send Funds | Memo: %1").arg(qstrTemp));
        }
        // -------------------------------------------



        // -------------------------------------------
        if (!m_amount.isEmpty())
        {
            QString qstrTemp = m_amount;
            ui->amountEdit->setText(m_amount);
        }
        // -------------------------------------------

        ui->toButton->setFocus();


        /** Flag Already Init **/
        already_init = true;
    }

    show();
}
コード例 #7
0
void MTSendDlg::on_sendButton_clicked()
{
    // Send funds and then close dialog. Use progress bar.
    // -----------------------------------------------------------------
    // To:
    if (m_hisNymId.isEmpty())
    {
        QMessageBox::warning(this, tr("No Recipient Selected"),
                             tr("Please choose a recipient for these funds, before sending."));
        return;
    }
    // -----------------------------------------------------------------
    // From:
    if (m_myAcctId.isEmpty())
    {
        QMessageBox::warning(this, tr("No Sender Account Selected"),
                             tr("Please choose an account where the funds will come out of."));
        return;
    }
    // -----------------------------------------------------------------
    // Memo:
    if (ui->memoEdit->text().isEmpty())
    {
        QMessageBox::StandardButton reply;

        reply = QMessageBox::question(this, "", tr("The memo is blank. Are you sure you want to send?"),
                                      QMessageBox::Yes|QMessageBox::No);
        if (reply == QMessageBox::No)
          return;
    }
    // -----------------------------------------------------------------
    // Amount:
    if (ui->amountEdit->text().isEmpty())
    {
        QMessageBox::warning(this, tr("Amount is Empty"),
                             tr("Please enter the amount you wish to send."));
        return;
    }
    // -----------------------------------------------------------------
    // Make sure I'm not sending to myself (since that will fail...)
    //
    std::string str_fromAcctId(m_myAcctId.toStdString());
    QString     qstr_fromNymId(QString::fromStdString(OTAPI_Wrap::It()->GetAccountWallet_NymID(str_fromAcctId)));

    if (m_hisNymId == qstr_fromNymId)
    {
        QMessageBox::warning(this, tr("Cannot Send To Yourself"),
                             tr("Sorry, but you cannot send to yourself. Please choose another recipient, or change the sending account."));
        return;
    }
    // -----------------------------------------------------------------

    on_amountEdit_editingFinished();

    // -----------------------------------------------------------------
    // TODO: We want an extra "ARE YOU SURE?" step to go right here, but likely it will
    // just be the passphrase dialog being FORCED to come up. But still, that means here
    // we'll have to set some kind of flag, probably, to force it to do that.
    //
    // NOTE: We'll want the "Are you sure" for the AMOUNT to display on that dialog.
    // (That is for security purposes.)
    //
    QMessageBox::StandardButton reply;

    reply = QMessageBox::question(this, "", QString("%1 '%2'<br/>%3").
                                  arg(tr("The amount is")).arg(ui->amountEdit->text()).arg(tr("Send?")),
                                  QMessageBox::Yes|QMessageBox::No);
    if (reply == QMessageBox::Yes)
    {
        // -----------------------------------------------------------------
        // Actually send the funds here.
        //
        QString memo   = ui->memoEdit  ->text();
        QString amount = ui->amountEdit->text();

        bool bSent = this->sendFunds(memo, amount);
        // -----------------------------------------------------------------
        if (bSent)
            emit balancesChanged();
        // -----------------------------------------------------------------
    }
}
コード例 #8
0
void MTCompose::on_sendButton_clicked()
{
    // Send message and then close dialog. Use progress bar.
    // -----------------------------------------------------------------
    if (m_recipientNymId.isEmpty())
    {
        QMessageBox::warning(this, tr("Message Has No Recipient"),
                             tr("Please choose a recipient for this message, before sending."));
        return;
    }
    // -----------------------------------------------------------------
    if (m_senderNymId.isEmpty())
    {
        QMessageBox::warning(this, tr("Message Has No Sender"),
                             tr("Please choose a sender for this message, before sending."));
        return;
    }
    // -----------------------------------------------------------------
    if (m_serverId.isEmpty())
    {
        QMessageBox::warning(this, tr("Message Has No Server"),
                             tr("Before sending, please choose a server for this message to be sent through."));
        return;
    }
    // -----------------------------------------------------------------
    if (ui->subjectEdit->text().isEmpty())
    {
        QMessageBox::StandardButton reply;

        reply = QMessageBox::question(this, "", tr("This message has a blank subject. Are you sure you want to send?"),
                                      QMessageBox::Yes|QMessageBox::No);
        if (reply == QMessageBox::No)
          return;
    }
    // -----------------------------------------------------------------
    if (ui->contentsEdit->toPlainText().isEmpty())
    {
        QMessageBox::StandardButton reply;

        reply = QMessageBox::question(this, "", tr("The message contents are blank. Are you sure you want to send?"),
                                      QMessageBox::Yes|QMessageBox::No);
        if (reply == QMessageBox::No)
          return;
    }
    // -----------------------------------------------------------------
    // Actually send the message here.
    //
    QString subject     = ui->subjectEdit->text();
    QString body        = ui->contentsEdit->toPlainText();
    QString fromNymId   = m_senderNymId;
    QString toNymId     = m_recipientNymId;
    QString atServerID  = m_serverId;

    bool bSent = this->sendMessage(body, fromNymId, toNymId, atServerID, subject);
    // -----------------------------------------------------------------
    if (!bSent)
        QMessageBox::warning(this, tr("Failed Sending Message"),
                             tr("Failed trying to send the message."));
    else
    {
        QMessageBox::StandardButton info_btn =
                QMessageBox::information(this, tr("Success"), tr("Success sending message."));
        // -----------------------------------------------------------------
        emit balancesChanged(); // So we'll see the sent message in the transaction history
        // -----------------------------------------------------------------
    }
    // -----------------------------------------------------------------
}
コード例 #9
0
void MTCompose::dialog()
{
/** Compose Dialog **/

    if (!already_init)
    {
        connect(this,               SIGNAL(balancesChanged()),
                Moneychanger::It(), SLOT  (onBalancesChanged()));
        // ---------------------------------------
        this->setWindowTitle(tr("Compose: (no subject)"));

        QString style_sheet = "QPushButton{border: none; border-style: outset; text-align:left; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #dadbde, stop: 1 #f6f7fa);}"
                "QPushButton:pressed {border: 1px solid black; text-align:left; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #dadbde, stop: 1 #f6f7fa); }"
                "QPushButton:hover {border: 1px solid black; text-align:left; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #dadbde, stop: 1 #f6f7fa); }";

        ui->fromButton->setStyleSheet(style_sheet);
        ui->toButton->setStyleSheet(style_sheet);
        ui->serverButton->setStyleSheet(style_sheet);

        // Here if there is pre-set data for the subject, contents, to, from, server, etc
        // then we set it here.
        //

        // Also, need ability to pre-set server since we might be replying
        // to a mail, or messaging based on a transaction, in which case
        // the server is already known and should be used.
        //
        // Also, we need ability to juggle the server setting.
        // For example, if we have known servers for the recipient,
        // we will try to see if our default server is one of those.
        // If so, we use that. Otherwise we see if ALL servers for
        // OUR Nym contain at least one match with the recipient, and
        // use the first one found.
        // Either way, the list we use will be filtered by both Nyms,
        // the above is only for setting the initial state.
        //
        // Otherwise, if a match cannot be found, the list will contain
        // ALL known servers, with the default server selected.
        //
        // When sending to a Nym on a particular server he's NOT known to be
        // on, a warning message should be displayed first.



        // Todo.

        // -------------------------------------------
        std::string str_sender_name;
        // -------------------------------------------
        if (!m_senderNymId.isEmpty()) // senderNym was provided.
        {
            MTNameLookupQT theLookup;

            str_sender_name = theLookup.GetNymName(m_senderNymId.toStdString());

            if (str_sender_name.empty())
                str_sender_name = m_senderNymId.toStdString();
        }
        // -------------------------------------------
        if (str_sender_name.empty())
        {
            m_senderNymId = QString("");
            ui->fromButton->setText(tr("<Click to choose Sender>"));
        }
        else
            ui->fromButton->setText(QString::fromStdString(str_sender_name));
        // -------------------------------------------


        // -------------------------------------------
        std::string str_recipient_name;
        // -------------------------------------------
        if (!m_recipientNymId.isEmpty()) // recipientNym was provided.
        {
            MTNameLookupQT theLookup;

            str_recipient_name = theLookup.GetNymName(m_recipientNymId.toStdString());

            if (str_recipient_name.empty())
                str_recipient_name = m_recipientNymId.toStdString();
        }
        // -------------------------------------------
        if (str_recipient_name.empty())
        {
            m_recipientNymId = QString("");
            ui->toButton->setText(tr("<Click to choose Recipient>"));
        }
        else
            ui->toButton->setText(QString::fromStdString(str_recipient_name));
        // -------------------------------------------


        // -------------------------------------------
        std::string str_server_name;
        // -------------------------------------------
        if (!m_serverId.isEmpty()) // serverID was provided.
        {
            str_server_name = OTAPI_Wrap::It()->GetServer_Name(m_serverId.toStdString());

            if (str_server_name.empty())
                str_server_name = m_serverId.toStdString();
        }
        // -------------------------------------------
        if (str_server_name.empty())
        {
            m_serverId = QString("");
            ui->serverButton->setText(tr("<Click to choose Server>"));
        }
        else
            ui->serverButton->setText(QString::fromStdString(str_server_name));
        // -------------------------------------------




        // -------------------------------------------
        if (!m_subject.isEmpty())
        {
            QString qstrRe = tr("re:");

            QString qstrSubjectLeft = m_subject.left(qstrRe.size());

            if (qstrSubjectLeft.toLower() != qstrRe)
            {
                QString strTemp = QString("%1 %2").arg(qstrRe).arg(m_subject);
                m_subject = strTemp;
            }
            // -----------------------
            QString qstrTempSubject = m_subject;

            ui->subjectEdit->setText(qstrTempSubject);
            // -----------------------
            this->setWindowTitle(QString("%1: %2").arg(tr("Compose")).arg(qstrTempSubject));
        }
        // -------------------------------------------


        ui->contentsEdit->setFocus();


        /** Flag Already Init **/
        already_init = true;
    }

}