예제 #1
0
void SettingsDialog::apply(void) {
  SettingsManager* manager = SettingsManager::settingsManager();
  manager->setImagesEnabled(_imagesCheckBox->isChecked());
  manager->setJavascriptEnabled(_javascriptCheckBox->isChecked());
  manager->setJavaEnabled(_javaCheckBox->isChecked());
  manager->setPluginsEnabled(_pluginsCheckBox->isChecked());
  manager->setPrivateBrowsingEnabled(_privateBrowsingCheckBox->isChecked());
  manager->setMaximumCacheSize(_cacheSizeSpinBox->value() * 1024 * 1024);
  
  int index = _historyExpirationComboBox->currentIndex();
  int days = _historyExpirationComboBox->itemData(index).toInt();
  manager->setHistoryExpirationDays(days);

  QString path;
  if(_downloadCheckBox->isChecked()) {
    path = _downloadLineEdit->text();
  } else {
    path = "";
  }
  manager->setDownloadPath(path);
  manager->setSansFontFamily(_sansFontComboBox->currentFont().family());
  manager->setSerifFontFamily(_serifFontComboBox->currentFont().family());
  manager->setMonoFontFamily(_monoFontComboBox->currentFont().family());
  manager->setStandardFontSize(_standardFontSpinBox->value());
  manager->setMonoFontSize(_monoFontSpinBox->value());
}
void SettingsDialog::save()
{
    SettingsManager * manager = SettingsManager::settingsManager();
    HistoryManager * historyManager = HistoryManager::historyManager();
    DownloadManager * downloadManager = DownloadManager::downloadManager();
    NetworkAccessManager * networkAccessManager = NetworkAccessManager::networkAccessManager();
    TabManager * tabManager = TabManager::tabManager();
    manager->setImagesEnabled(m_imagesCheckBox->isChecked());
    manager->setJavascriptEnabled(m_javascriptCheckBox->isChecked());
    manager->setJavaEnabled(m_javaCheckBox->isChecked());
    manager->setPluginsEnabled(m_pluginsCheckBox->isChecked());
    manager->setSansFontFamily(m_sansFontComboBox->currentFont().family());
    manager->setSerifFontFamily(m_serifFontComboBox->currentFont().family());
    manager->setMonoFontFamily(m_monoFontComboBox->currentFont().family());
    manager->setStandardFontSize(m_standardFontSpinBox->value());
    manager->setMonoFontSize(m_monoFontSpinBox->value());
    historyManager->setPrivateBrowsingEnabled(m_privateBrowsingCheckBox->isChecked());
    int index = m_historyExpirationComboBox->currentIndex();
    int days = m_historyExpirationComboBox->itemData(index).toInt();
    historyManager->setExpirationDays(days);
    QString path;
    if(m_downloadCheckBox->isChecked())
    {
        path = m_downloadLineEdit->text();
    }
    else
    {
        path = "";
    }
    downloadManager->setStandardPath(path);
    networkAccessManager->setCacheSize(m_cacheSizeSpinBox->value() * 1024 * 1024);
    QUrl url;
    if(!m_proxyLineEdit->text().isEmpty())
    {
        url.setHost(m_proxyLineEdit->text());
        url.setPort(m_proxySpinBox->value());
    }
    networkAccessManager->setProxy(url);
    tabManager->setAddTabPolicy(TabManager::AddTabPolicy(m_addTabPolicyComboBox->currentIndex()));
}