Exemplo n.º 1
0
void SettingsDialog::showEvent(QShowEvent*) {
  SettingsManager* manager = SettingsManager::settingsManager();
  _imagesCheckBox->setChecked(manager->isImagesEnabled());
  _javascriptCheckBox->setChecked(manager->isJavascriptEnabled());
  _javaCheckBox->setChecked(manager->isJavaEnabled());
  _pluginsCheckBox->setChecked(manager->isPluginsEnabled());
  _privateBrowsingCheckBox->setChecked(manager->isPrivateBrowsingEnabled());
  _cacheSizeSpinBox->setValue(manager->maximumCacheSize() / 1024 / 1024);
  _historyExpirationComboBox->setCurrentIndex(2);
  for(int i = 0; i < 8; i++) {
    if(_historyExpirationComboBox->itemData(i).toInt() == manager->historyExpirationDays()) {
      _historyExpirationComboBox->setCurrentIndex(i);
      break;
    }
  }

  QString path = manager->downloadPath();
  if(path.isEmpty()) {
    _downloadCheckBox->setChecked(false);
  } else {
    _downloadCheckBox->setChecked(true);
    _downloadLineEdit->setText(path);
  }
  _standardFontSpinBox->setValue(manager->standardFontSize());
  _monoFontSpinBox->setValue(manager->monoFontSize());
}
void SettingsDialog::load()
{
    SettingsManager * manager = SettingsManager::settingsManager();
    HistoryManager * historyManager = HistoryManager::historyManager();
    DownloadManager * downloadManager = DownloadManager::downloadManager();
    NetworkAccessManager * networkAccessManager = NetworkAccessManager::networkAccessManager();
    TabManager * tabManager = TabManager::tabManager();
    m_imagesCheckBox->setChecked(manager->isImagesEnabled());
    m_javascriptCheckBox->setChecked(manager->isJavascriptEnabled());
    m_javaCheckBox->setChecked(manager->isJavaEnabled());
    m_pluginsCheckBox->setChecked(manager->isPluginsEnabled());
    m_sansFontComboBox->setCurrentFont(QFont(manager->sansFontFamily()));
    m_serifFontComboBox->setCurrentFont(QFont(manager->serifFontFamily()));
    m_monoFontComboBox->setCurrentFont(QFont(manager->monoFontFamily()));
    m_standardFontSpinBox->setValue(manager->standardFontSize());
    m_monoFontSpinBox->setValue(manager->monoFontSize());
    m_privateBrowsingCheckBox->setChecked(historyManager->isPrivateBrowsingEnabled());
    m_historyExpirationComboBox->setCurrentIndex(2);
    for(int i = 0; i < 8; i++)
    {
        if(m_historyExpirationComboBox->itemData(i).toInt() ==
           historyManager->expirationDays())
        {
            m_historyExpirationComboBox->setCurrentIndex(i);
            break;
        }
    }
    QString path = downloadManager->standardPath();
    if(path.isEmpty())
    {
        m_downloadCheckBox->setChecked(false);
    }
    else
    {
        m_downloadCheckBox->setChecked(true);
        m_downloadLineEdit->setText(path);
    }
    m_cacheSizeSpinBox->setValue(networkAccessManager->cacheSize() / 1024 / 1024);
    QUrl url(networkAccessManager->proxy());
    if(!url.isEmpty())
    {
        m_proxyLineEdit->setText(url.host());
        m_proxySpinBox->setValue(url.port());
    }
    m_addTabPolicyComboBox->setCurrentIndex(tabManager->addTabPolicy() == TabManager::AddAfterLast ? 0 : 1);
}