void MTAccountDetails::on_pushButtonMakeDefault_clicked() { if ((NULL != m_pOwner) && !m_qstrID.isEmpty()) { std::string str_acct_name = OTAPI_Wrap::It()->GetAccountWallet_Name(m_qstrID.toStdString()); ui->pushButtonMakeDefault->setEnabled(false); // -------------------------------------------------- QString qstrAcctName = QString::fromStdString(str_acct_name); // -------------------------------------------------- emit DefaultAccountChanged(m_qstrID, qstrAcctName); } }
void MTDetailEdit::dialog(MTDetailEdit::DetailEditType theType, bool bIsModal/*=false*/) { if (m_bFirstRun) { m_bFirstRun = false; // ------------------------------------------- ui->tableWidget->setColumnCount(2); ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); // ------------------------------------------- ui->tableWidget->horizontalHeader()->resizeSection(0, 5); // ------------------------------------------- ui->tableWidget->horizontalHeader()->setStretchLastSection(true); ui->tableWidget->verticalHeader()->setDefaultSectionSize(60); ui->tableWidget->verticalHeader()->hide(); ui->tableWidget->horizontalHeader()->hide(); // ------------------------------------------- ui->tableWidget->setContentsMargins(10,0,0,0); // ------------------------------------------- ui->tableWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding); // ---------------------------------- m_pTabWidget = new QTabWidget; // ---------------------------------- m_pTabWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_pTabWidget->setContentsMargins(5, 5, 5, 5); // ---------------------------------- QWidget * pTab1 = new QWidget; // ---------------------------------- pTab1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); pTab1->setContentsMargins(5, 5, 5, 5); // ---------------------------------- m_pTabWidget->addTab(pTab1, tr("Details")); // ------------------------------------------- // Instantiate m_pDetailPane to one of various types. // m_Type = theType; switch (m_Type) { case MTDetailEdit::DetailEditTypeNym: m_pDetailPane = new MTNymDetails(this, *this); break; case MTDetailEdit::DetailEditTypeContact: m_pDetailPane = new MTContactDetails(this, *this); break; case MTDetailEdit::DetailEditTypeServer: m_pDetailPane = new MTServerDetails(this, *this); break; case MTDetailEdit::DetailEditTypeAsset: m_pDetailPane = new MTAssetDetails(this, *this); break; case MTDetailEdit::DetailEditTypeAccount: m_pDetailPane = new MTAccountDetails(this, *this); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(DefaultAccountChanged(QString, QString)), m_pMoneychanger, SLOT (setDefaultAccount(QString, QString))); // ------------------------------------------- // connect(m_pDetailPane, SIGNAL(cashBalanceChanged()), // m_pMoneychanger, SLOT (onCashBalanceChanged())); // // ------------------------------------------- // connect(m_pDetailPane, SIGNAL(acctBalanceChanged()), // m_pMoneychanger, SLOT (onAcctBalanceChanged())); // // ------------------------------------------- break; default: qDebug() << "MTDetailEdit::dialog: MTDetailEdit::DetailEditTypeError"; return; } // ------------------------------------------- m_pDetailPane->SetOwnerPointer(*this); // ------------------------------------------- m_pDetailLayout = new QVBoxLayout; m_pDetailLayout->addWidget(m_pDetailPane); m_pDetailPane ->setContentsMargins(1,1,1,1); m_pDetailLayout->setContentsMargins(1,1,1,1); // ---------------------------------- pTab1->setLayout(m_pDetailLayout); // ---------------------------------- int nCustomTabCount = m_pDetailPane->GetCustomTabCount(); if (nCustomTabCount > 0) { for (int ii = 0; ii < nCustomTabCount; ii++) { QWidget * pTab = m_pDetailPane->CreateCustomTab(ii); // ---------------------------------- if (NULL != pTab) { pTab->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); pTab->setContentsMargins(5, 5, 5, 5); QString qstrTabName = m_pDetailPane->GetCustomTabName(ii); m_pTabWidget->addTab(pTab, qstrTabName); } // ---------------------------------- } } // ----------------------------------------------- QGridLayout * pGridLayout = new QGridLayout; pGridLayout->addWidget(m_pTabWidget); pGridLayout->setContentsMargins(0,0,0,0); m_pTabWidget->setTabPosition(QTabWidget::South); // ---------------------------------- ui->widget->setContentsMargins(1,1,1,1); // ---------------------------------- ui->widget->setLayout(pGridLayout); // ---------------------------------- } // first run. // ------------------------------------------- RefreshRecords(); // ------------------------------------------- // if (m_map.size() < 1) // on_addButton_clicked(); // ------------------------------------------- if (bIsModal) { QDialog theDlg; theDlg.setWindowTitle(this->windowTitle()); // theDlg.installEventFilter(this); QVBoxLayout * pLayout = new QVBoxLayout; pLayout->addWidget(this); theDlg.setLayout(pLayout); theDlg.setWindowFlags(Qt::Tool); // A hack so it will show the close button. theDlg.exec(); pLayout->removeWidget(this); } else { this->installEventFilter(this); show(); setFocus(); } // ------------------------------------------- }
// This only does something the first time you run it. // void MTDetailEdit::FirstRun(MTDetailEdit::DetailEditType theType) { if (m_bFirstRun) { // ------------------------------------------- ui->comboBox->setHidden(true); // ------------------------------------------- ui->tableWidget->setColumnCount(2); ui->tableWidget->setSelectionMode (QAbstractItemView::SingleSelection); ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); // ------------------------------------------- ui->tableWidget->horizontalHeader()->resizeSection(0, 5); // ------------------------------------------- ui->tableWidget->horizontalHeader()->setStretchLastSection(true); ui->tableWidget->verticalHeader()->setDefaultSectionSize(60); ui->tableWidget->verticalHeader()->hide(); ui->tableWidget->horizontalHeader()->hide(); // ------------------------------------------- ui->tableWidget->setContentsMargins(10,0,0,0); // ------------------------------------------- ui->tableWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding); // ---------------------------------- m_pTabWidget = new QTabWidget; // ---------------------------------- m_pTabWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_pTabWidget->setContentsMargins(5, 5, 5, 5); // ---------------------------------- QWidget * pTab1 = new QWidget; // ---------------------------------- pTab1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); pTab1->setContentsMargins(5, 5, 5, 5); // ---------------------------------- QString qstrTab1Title = tr("Details"); m_pTabWidget->addTab(pTab1, qstrTab1Title); // ------------------------------------------- // Instantiate m_pDetailPane to one of various types. // m_Type = theType; switch (m_Type) { case MTDetailEdit::DetailEditTypeServer: m_pDetailPane = new MTServerDetails(this, *this); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(newServerAdded(QString)), Moneychanger::It(), SLOT (onNewServerAdded(QString))); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(newServerAdded(QString)), m_pDetailPane, SIGNAL(RefreshRecordsAndUpdateMenu())); // ------------------------------------------- break; case MTDetailEdit::DetailEditTypeAsset: m_pDetailPane = new MTAssetDetails(this, *this); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(newAssetAdded(QString)), Moneychanger::It(), SLOT (onNewAssetAdded(QString))); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(newAssetAdded(QString)), m_pDetailPane, SIGNAL(RefreshRecordsAndUpdateMenu())); // ------------------------------------------- // For new issuer accounts: (which are created on the assets page when a user registers the currency onto a server.) // ------------------------------------------- connect(m_pDetailPane, SIGNAL(newAccountAdded(QString)), Moneychanger::It(), SLOT (onNewAccountAdded(QString))); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(newAccountAdded(QString)), m_pDetailPane, SIGNAL(RefreshRecordsAndUpdateMenu())); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(newAccountAdded(QString)), m_pDetailPane, SIGNAL(ShowAccount(QString))); // ------------------------------------------- break; case MTDetailEdit::DetailEditTypeNym: m_pDetailPane = new MTNymDetails(this, *this); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(newNymAdded(QString)), Moneychanger::It(), SLOT (onNewNymAdded(QString))); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(newNymAdded(QString)), m_pDetailPane, SIGNAL(RefreshRecordsAndUpdateMenu())); // ------------------------------------------- break; case MTDetailEdit::DetailEditTypeContact: m_pDetailPane = new MTContactDetails (this, *this); break; case MTDetailEdit::DetailEditTypeCorporation: m_pDetailPane = new MTCorporationDetails(this, *this); break; case MTDetailEdit::DetailEditTypeTransport: m_pDetailPane = new TransportDetails (this, *this); break; case MTDetailEdit::DetailEditTypeAgreement: ui->comboBox->setHidden(false); m_pDetailPane = new MTAgreementDetails (this, *this); // ------------------------------------------- connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT (on_comboBox_currentIndexChanged(int))); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(runSmartContract(QString, QString, int32_t)), Moneychanger::It(), SLOT (onRunSmartContract(QString, QString, int32_t))); // ------------------------------------------- break; case MTDetailEdit::DetailEditTypeOffer: ui->comboBox->setHidden(false); m_pDetailPane = new MTOfferDetails(this, *this); // ------------------------------------------- connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT (on_comboBox_currentIndexChanged(int))); // ------------------------------------------- break; case MTDetailEdit::DetailEditTypeMarket: EnableAdd (false); EnableDelete(false); m_pDetailPane = new MTMarketDetails(this, *this); break; case MTDetailEdit::DetailEditTypeAccount: m_pDetailPane = new MTAccountDetails(this, *this); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(DefaultAccountChanged(QString, QString)), Moneychanger::It(), SLOT (setDefaultAccount(QString, QString))); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(SendFromAcct(QString)), Moneychanger::It(), SLOT (mc_send_from_acct(QString))); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(RequestToAcct(QString)), Moneychanger::It(), SLOT (mc_request_to_acct(QString))); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(newAccountAdded(QString)), Moneychanger::It(), SLOT (onNewAccountAdded(QString))); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(newAccountAdded(QString)), m_pDetailPane, SIGNAL(RefreshRecordsAndUpdateMenu())); // ------------------------------------------- break; default: qDebug() << "MTDetailEdit::dialog: MTDetailEdit::DetailEditTypeError"; return; } //switch // ------------------------------------------- connect(m_pDetailPane, SIGNAL(NeedToUpdateMenu()), Moneychanger::It(), SLOT (onNeedToUpdateMenu())); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(RefreshRecordsAndUpdateMenu()), Moneychanger::It(), SLOT (onNeedToUpdateMenu())); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(RefreshRecordsAndUpdateMenu()), this, SLOT (onRefreshRecords())); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(ShowAsset(QString)), Moneychanger::It(), SLOT (mc_show_asset_slot(QString))); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(ShowNym(QString)), Moneychanger::It(), SLOT (mc_show_nym_slot(QString))); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(ShowServer(QString)), Moneychanger::It(), SLOT (mc_show_server_slot(QString))); // ------------------------------------------- connect(m_pDetailPane, SIGNAL(ShowAccount(QString)), Moneychanger::It(), SLOT (mc_show_account_slot(QString))); // ------------------------------------------- m_pDetailPane->SetOwnerPointer(*this); m_pDetailPane->SetEditType(theType); // ------------------------------------------- m_pDetailLayout = new QVBoxLayout; m_pDetailLayout->addWidget(m_pDetailPane); m_pDetailPane ->setContentsMargins(1,1,1,1); m_pDetailLayout->setContentsMargins(1,1,1,1); // ---------------------------------- pTab1->setLayout(m_pDetailLayout); // ---------------------------------- int nCustomTabCount = m_pDetailPane->GetCustomTabCount(); if (nCustomTabCount > 0) { for (int ii = 0; ii < nCustomTabCount; ii++) { QWidget * pTab = m_pDetailPane->CreateCustomTab(ii); // ---------------------------------- if (NULL != pTab) { pTab->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); pTab->setContentsMargins(5, 5, 5, 5); QString qstrTabName = m_pDetailPane->GetCustomTabName(ii); m_pTabWidget->addTab(pTab, qstrTabName); } // ---------------------------------- } } // ----------------------------------------------- QGridLayout * pGridLayout = new QGridLayout; pGridLayout->addWidget(m_pTabWidget); pGridLayout->setContentsMargins(0,0,0,0); m_pTabWidget->setTabPosition(QTabWidget::South); // ---------------------------------- ui->widget->setContentsMargins(1,1,1,1); // ---------------------------------- ui->widget->setLayout(pGridLayout); // ---------------------------------- if (!m_bEnableAdd) ui->addButton->setVisible(false); // ---------------------------------- if (!m_bEnableDelete) ui->deleteButton->setVisible(false); // ---------------------------------- if (m_pDetailPane) m_pDetailPane->setVisible(false); m_pTabWidget->setVisible(false); // ---------------------------------- m_bFirstRun = false; } // first run. }