Ejemplo n.º 1
0
void SettingsDialog::accept()
{
    SettingsManager* settings = SettingsManager::instance();

    const QAbstractButton* regionBtn = ui->regionBtnGrp->checkedButton();
    if (regionBtn == ui->ntscURB)
        settings->setDefaultRegion(Region::NTSCU);
    else if (regionBtn == ui->ntscKRB)
        settings->setDefaultRegion(Region::NTSCK);
    else if (regionBtn == ui->ntscJRB)
        settings->setDefaultRegion(Region::NTSCJ);
    else if (regionBtn == ui->palRB)
        settings->setDefaultRegion(Region::PAL);

    if (ui->ntscUNameLE->isModified() && !ui->ntscUNameLE->text().isEmpty())
        settings->setDefaultPlayerNameForRegion(Region::NTSCU, ui->ntscUNameLE->text());
    if (ui->ntscKNameLE->isModified() && !ui->ntscKNameLE->text().isEmpty())
        settings->setDefaultPlayerNameForRegion(Region::NTSCK, ui->ntscKNameLE->text());
    if (ui->ntscJNameLE->isModified() && !ui->ntscJNameLE->text().isEmpty())
        settings->setDefaultPlayerNameForRegion(Region::NTSCJ, ui->ntscJNameLE->text());
    if (ui->palNameLE->isModified() && !ui->palNameLE->text().isEmpty())
        settings->setDefaultPlayerNameForRegion(Region::PAL, ui->palNameLE->text());
    if (ui->updateUrlLineEdit->isModified() && !ui->updateUrlLineEdit->text().isEmpty())
        settings->setUpdateUrl(ui->updateUrlLineEdit->text());
    settings->setUpdateCheckOnStart(ui->checkOnStart->isChecked());
    SkipDatabaseWidget* sdw = qobject_cast<SkipDatabaseWidget*>(ui->skipDatabaseTab);
    sdw->saveDatabase();
    settings->saveSettings();
    QDialog::accept();
}
void PreferencesDialog::accept()
{
    if (m_ui->ngIDLineEdit->hasAcceptableInput() && m_ui->ngIDLineEdit->text().length() == 8)
    {
        quint32 id;
        bool ok;
        id = m_ui->ngIDLineEdit->text().toInt(&ok, 16);
        if (ok)
            WiiKeys::instance()->setNGID(id);
    }
    if (m_ui->ngKeyIDLineEdit->hasAcceptableInput() && m_ui->ngKeyIDLineEdit->text().length() == 8)
    {
        quint32 id;
        bool ok;
        id = m_ui->ngKeyIDLineEdit->text().toInt(&ok, 16);
        if (ok)
            WiiKeys::instance()->setNGKeyID(id);
    }
    if (m_ui->ngSigPt1LineEdit->hasAcceptableInput() && m_ui->ngSigPt2LineEdit->hasAcceptableInput() &&
        m_ui->ngSigPt1LineEdit->text().length() == 60 && m_ui->ngSigPt1LineEdit->text().length() == 60)
    {
        QByteArray ngSig = QByteArray::fromHex(m_ui->ngSigPt1LineEdit->text().toAscii());
        ngSig.append(QByteArray::fromHex(m_ui->ngSigPt2LineEdit->text().toAscii()));
        WiiKeys::instance()->setNGSig(ngSig);
    }

    if (m_ui->ngPrivLineEdit->hasAcceptableInput() && m_ui->ngPrivLineEdit->text().length() == 60)
    {
        QByteArray ngPriv = QByteArray::fromHex(m_ui->ngPrivLineEdit->text().toAscii());
        WiiKeys::instance()->setNGPriv(ngPriv);
    }
    if (m_ui->macAddrLineEdit->hasAcceptableInput() && m_ui->macAddrLineEdit->text().length() == 12)
    {
        QByteArray macAddr = QByteArray::fromHex(m_ui->macAddrLineEdit->text().toAscii());
        WiiKeys::instance()->setMacAddr(macAddr);
    }

    SettingsManager* settings = SettingsManager::instance();

    QString regionBtn = m_ui->regionBtnGrp->checkedButton()->objectName();
    settings->setDefaultRegion(regionBtn == "ntscURB" ? SettingsManager::NTSCU :
                              (regionBtn == "ntscJRB" ? SettingsManager::NTSCJ :
                               SettingsManager::PAL));

    if (m_ui->ntscUNameLE->isModified() && !m_ui->ntscUNameLE->text().isEmpty())
        settings->setDefaultPlayerNameForRegion(SettingsManager::NTSCU, m_ui->ntscUNameLE->text());
    if (m_ui->ntscJNameLE->isModified() && !m_ui->ntscJNameLE->text().isEmpty())
        settings->setDefaultPlayerNameForRegion(SettingsManager::NTSCJ, m_ui->ntscJNameLE->text());
    if (m_ui->palNameLE->isModified() && !m_ui->palNameLE->text().isEmpty())
        settings->setDefaultPlayerNameForRegion(SettingsManager::PAL, m_ui->palNameLE->text());

    QDialog::accept();
}