Commit fe48286e authored by Lasse Holmstedt's avatar Lasse Holmstedt
Browse files

Made Qt Quick Designer editor opening modal

If you're in Design mode, any new editors will open in design mode
as well. If you're in Edit mode, new editors will open in Edit mode.

Task-number: BAUHAUS-609
parent 71297db2
......@@ -57,7 +57,7 @@ const char * const QML_DESIGNER_SETTINGS_GROUP = "Designer";
const char * const QML_OPENDESIGNMODE_SETTINGS_KEY = "OpenDesignMode";
const char * const QML_ITEMSPACING_KEY = "ItemSpacing";
const char * const QML_SNAPMARGIN_KEY = "SnapMargin";
enum { QML_OPENDESIGNMODE_DEFAULT = 0 };
enum { QML_OPENDESIGNMODE_DEFAULT = 0 }; // 0 for text mode, 1 for design mode
namespace Internal {
enum { debug = 0 };
......
......@@ -38,8 +38,6 @@
using namespace QmlDesigner;
using namespace QmlDesigner::Internal;
enum EditModeCombo { EditModeDesign, EditModeEdit };
SettingsPageWidget::SettingsPageWidget(QWidget *parent) :
QWidget(parent)
{
......@@ -49,7 +47,6 @@ SettingsPageWidget::SettingsPageWidget(QWidget *parent) :
DesignerSettings SettingsPageWidget::settings() const
{
DesignerSettings ds;
ds.openDesignMode = m_ui.editorModeComboBox->currentIndex() == EditModeDesign;
ds.itemSpacing = m_ui.spinItemSpacing->value();
ds.snapMargin = m_ui.spinSnapMargin->value();
return ds;
......@@ -57,7 +54,6 @@ DesignerSettings SettingsPageWidget::settings() const
void SettingsPageWidget::setSettings(const DesignerSettings &s)
{
m_ui.editorModeComboBox->setCurrentIndex(s.openDesignMode ? EditModeDesign : EditModeEdit);
m_ui.spinItemSpacing->setValue(s.itemSpacing);
m_ui.spinSnapMargin->setValue(s.snapMargin);
}
......
......@@ -15,49 +15,6 @@
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Files</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="editorModeLabel">
<property name="text">
<string>Open file in:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="editorModeComboBox">
<item>
<property name="text">
<string>Design mode</string>
</property>
</item>
<item>
<property name="text">
<string>Edit mode</string>
</property>
</item>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Snapping</string>
......@@ -141,7 +98,7 @@
</layout>
</widget>
</item>
<item row="4" column="0">
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......
......@@ -595,16 +595,22 @@ static bool openInDesignMode()
}
if (!bauhausPresent)
return false;
// Query the bauhaus setting if it wants to be opened in Design mode.
const QString settingsKey = QLatin1String(QmlDesigner::Constants::QML_SETTINGS_GROUP)
+ QLatin1Char('/') + QLatin1String(QmlDesigner::Constants::QML_DESIGNER_SETTINGS_GROUP)
+ QLatin1Char('/') + QLatin1String(QmlDesigner::Constants::QML_OPENDESIGNMODE_SETTINGS_KEY);
const QVariant openDesignMode = Core::ICore::instance()->settings()->value(settingsKey);
return openDesignMode.isValid() ? openDesignMode.toBool() : bool(QmlDesigner::Constants::QML_OPENDESIGNMODE_DEFAULT);
return bool(QmlDesigner::Constants::QML_OPENDESIGNMODE_DEFAULT);
}
QString QmlJSEditorEditable::preferredMode() const
{
Core::ModeManager *modeManager = Core::ModeManager::instance();
if (modeManager->currentMode()->id() == Core::Constants::MODE_DESIGN
|| modeManager->currentMode()->id() == Core::Constants::MODE_EDIT)
{
return modeManager->currentMode()->id();
}
// if we are in other mode than edit or design, use the hard-coded default.
// because the editor opening decision is modal, it would be confusing to
// have the user also access to this failsafe setting.
if (editor()->mimeType() == QLatin1String(QmlJSEditor::Constants::QML_MIMETYPE)
&& openInDesignMode())
return QLatin1String(Core::Constants::MODE_DESIGN);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment