QVariant DesignerSettings::getValue(const QByteArray &key) { DesignerSettings settings = QmlDesignerPlugin::instance()->settings(); return settings.value(key); }
void SettingsPageWidget::setSettings(const DesignerSettings &settings) { m_ui.spinItemSpacing->setValue(settings.value( DesignerSettingsKey::ITEMSPACING).toInt()); m_ui.spinSnapMargin->setValue(settings.value( DesignerSettingsKey::CONTAINERPADDING).toInt()); m_ui.spinCanvasWidth->setValue(settings.value( DesignerSettingsKey::CANVASWIDTH).toInt()); m_ui.spinCanvasHeight->setValue(settings.value( DesignerSettingsKey::CANVASHEIGHT).toInt()); m_ui.designerWarningsCheckBox->setChecked(settings.value( DesignerSettingsKey::WARNING_FOR_FEATURES_IN_DESIGNER).toBool()); m_ui.designerWarningsInEditorCheckBox->setChecked(settings.value( DesignerSettingsKey::WARNING_FOR_DESIGNER_FEATURES_IN_EDITOR).toBool()); m_ui.designerShowDebuggerCheckBox->setChecked(settings.value( DesignerSettingsKey::SHOW_DEBUGVIEW).toBool()); m_ui.designerEnableDebuggerCheckBox->setChecked(settings.value( DesignerSettingsKey::ENABLE_DEBUGVIEW).toBool()); m_ui.useDefaultPuppetRadioButton->setChecked(settings.value( DesignerSettingsKey::USE_ONLY_FALLBACK_PUPPET).toBool()); m_ui.useQtRelatedPuppetRadioButton->setChecked(!settings.value( DesignerSettingsKey::USE_ONLY_FALLBACK_PUPPET).toBool()); m_ui.useQsTrFunctionRadioButton->setChecked(settings.value( DesignerSettingsKey::USE_QSTR_FUNCTION).toBool()); m_ui.useQsTrIdFunctionRadioButton->setChecked(!settings.value( DesignerSettingsKey::USE_QSTR_FUNCTION).toBool()); m_ui.styleLineEdit->setText(settings.value( DesignerSettingsKey::CONTROLS_STYLE).toString()); QString puppetFallbackDirectory = settings.value( DesignerSettingsKey::PUPPET_FALLBACK_DIRECTORY, PuppetCreator::defaultPuppetFallbackDirectory()).toString(); m_ui.fallbackPuppetPathLineEdit->setPath(puppetFallbackDirectory); QString puppetToplevelBuildDirectory = settings.value( DesignerSettingsKey::PUPPET_TOPLEVEL_BUILD_DIRECTORY, PuppetCreator::defaultPuppetToplevelBuildDirectory()).toString(); m_ui.puppetBuildPathLineEdit->setPath(puppetToplevelBuildDirectory); m_ui.forwardPuppetOutputComboBox->setCurrentText(settings.value( DesignerSettingsKey::FORWARD_PUPPET_OUTPUT).toString()); m_ui.debugPuppetComboBox->setCurrentText(settings.value( DesignerSettingsKey::DEBUG_PUPPET).toString()); m_ui.alwaysSaveSubcomponentsCheckBox->setChecked(settings.value( DesignerSettingsKey::ALWAYS_SAFE_IN_CRUMBLEBAR).toBool()); m_ui.showPropertyEditorWarningsCheckBox->setChecked(settings.value( DesignerSettingsKey::SHOW_PROPERTYEDITOR_WARNINGS).toBool()); m_ui.showWarnExceptionsCheckBox->setChecked(settings.value( DesignerSettingsKey::ENABLE_MODEL_EXCEPTION_OUTPUT).toBool()); }
DesignerSettings SettingsPageWidget::settings() const { DesignerSettings settings = QmlDesignerPlugin::instance()->settings(); settings.insert(DesignerSettingsKey::ITEMSPACING, m_ui.spinItemSpacing->value()); settings.insert(DesignerSettingsKey::CONTAINERPADDING, m_ui.spinSnapMargin->value()); settings.insert(DesignerSettingsKey::CANVASWIDTH, m_ui.spinCanvasWidth->value()); settings.insert(DesignerSettingsKey::CANVASHEIGHT, m_ui.spinCanvasHeight->value()); settings.insert(DesignerSettingsKey::ROOT_ELEMENT_INIT_WIDTH, m_ui.spinRootItemInitWidth->value()); settings.insert(DesignerSettingsKey::ROOT_ELEMENT_INIT_HEIGHT, m_ui.spinRootItemInitHeight->value()); settings.insert(DesignerSettingsKey::WARNING_FOR_FEATURES_IN_DESIGNER, m_ui.designerWarningsCheckBox->isChecked()); settings.insert(DesignerSettingsKey::WARNING_FOR_QML_FILES_INSTEAD_OF_UIQML_FILES, m_ui.designerWarningsUiQmlfiles->isChecked()); settings.insert(DesignerSettingsKey::WARNING_FOR_DESIGNER_FEATURES_IN_EDITOR, m_ui.designerWarningsInEditorCheckBox->isChecked()); settings.insert(DesignerSettingsKey::SHOW_DEBUGVIEW, m_ui.designerShowDebuggerCheckBox->isChecked()); settings.insert(DesignerSettingsKey::ENABLE_DEBUGVIEW, m_ui.designerEnableDebuggerCheckBox->isChecked()); settings.insert(DesignerSettingsKey::USE_ONLY_FALLBACK_PUPPET, m_ui.useDefaultPuppetRadioButton->isChecked()); int typeOfQsTrFunction; if (m_ui.useQsTrFunctionRadioButton->isChecked()) typeOfQsTrFunction = 0; else if (m_ui.useQsTrIdFunctionRadioButton->isChecked()) typeOfQsTrFunction = 1; else if (m_ui.useQsTranslateFunctionRadioButton->isChecked()) typeOfQsTrFunction = 2; else typeOfQsTrFunction = 0; settings.insert(DesignerSettingsKey::TYPE_OF_QSTR_FUNCTION, typeOfQsTrFunction); settings.insert(DesignerSettingsKey::CONTROLS_STYLE, m_ui.styleLineEdit->text()); settings.insert(DesignerSettingsKey::FORWARD_PUPPET_OUTPUT, m_ui.forwardPuppetOutputComboBox->currentText()); settings.insert(DesignerSettingsKey::DEBUG_PUPPET, m_ui.debugPuppetComboBox->currentText()); QString newFallbackPuppetPath = m_ui.fallbackPuppetPathLineEdit->path(); QTC_CHECK(PuppetCreator::defaultPuppetFallbackDirectory() == m_ui.fallbackPuppetPathLineEdit->lineEdit()->placeholderText()); if (newFallbackPuppetPath.isEmpty()) newFallbackPuppetPath = m_ui.fallbackPuppetPathLineEdit->lineEdit()->placeholderText(); QString oldFallbackPuppetPath = settings.value(DesignerSettingsKey::PUPPET_FALLBACK_DIRECTORY, PuppetCreator::defaultPuppetFallbackDirectory()).toString(); if (oldFallbackPuppetPath != newFallbackPuppetPath) { settings.insert(DesignerSettingsKey::PUPPET_FALLBACK_DIRECTORY, newFallbackPuppetPath); } if (!m_ui.puppetBuildPathLineEdit->path().isEmpty() && m_ui.puppetBuildPathLineEdit->path() != PuppetCreator::defaultPuppetToplevelBuildDirectory()) { settings.insert(DesignerSettingsKey::PUPPET_TOPLEVEL_BUILD_DIRECTORY, m_ui.puppetBuildPathLineEdit->path()); } settings.insert(DesignerSettingsKey::ALWAYS_SAFE_IN_CRUMBLEBAR, m_ui.alwaysSaveSubcomponentsCheckBox->isChecked()); settings.insert(DesignerSettingsKey::SHOW_PROPERTYEDITOR_WARNINGS, m_ui.showPropertyEditorWarningsCheckBox->isChecked()); settings.insert(DesignerSettingsKey::ENABLE_MODEL_EXCEPTION_OUTPUT, m_ui.showWarnExceptionsCheckBox->isChecked()); return settings; }