forked from qt-creator/qt-creator
		
	TextEditor: Make automatic completion timeout configurable
Allow to configure the timeout in the range from 0 to 500ms. Task-number: QTCREATORBUG-13393 Change-Id: I3e421109db919ab0dd5d63b8cbb9339fce132dbb Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
This commit is contained in:
		@@ -64,6 +64,10 @@ QWidget *CompletionSettingsPage::widget()
 | 
			
		||||
        m_page = new Ui::CompletionSettingsPage;
 | 
			
		||||
        m_page->setupUi(m_widget);
 | 
			
		||||
 | 
			
		||||
        connect(m_page->completionTrigger,
 | 
			
		||||
                static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
 | 
			
		||||
                this, &CompletionSettingsPage::onCompletionTriggerChanged);
 | 
			
		||||
 | 
			
		||||
        const TextEditor::CompletionSettings &settings =
 | 
			
		||||
                TextEditor::TextEditorSettings::completionSettings();
 | 
			
		||||
 | 
			
		||||
@@ -95,6 +99,7 @@ QWidget *CompletionSettingsPage::widget()
 | 
			
		||||
 | 
			
		||||
        m_page->caseSensitivity->setCurrentIndex(caseSensitivityIndex);
 | 
			
		||||
        m_page->completionTrigger->setCurrentIndex(completionTriggerIndex);
 | 
			
		||||
        m_page->automaticProposalTimeoutSpinBox->setValue(settings.m_automaticProposalTimeoutInMs);
 | 
			
		||||
        m_page->autoInsertBrackets->setChecked(settings.m_autoInsertBrackets);
 | 
			
		||||
        m_page->surroundSelectedText->setChecked(settings.m_surroundingAutoBrackets);
 | 
			
		||||
        m_page->partiallyComplete->setChecked(settings.m_partiallyComplete);
 | 
			
		||||
@@ -115,6 +120,7 @@ void CompletionSettingsPage::apply()
 | 
			
		||||
    TextEditor::CompletionSettings settings;
 | 
			
		||||
    settings.m_caseSensitivity = caseSensitivity();
 | 
			
		||||
    settings.m_completionTrigger = completionTrigger();
 | 
			
		||||
    settings.m_automaticProposalTimeoutInMs = m_page->automaticProposalTimeoutSpinBox->value();
 | 
			
		||||
    settings.m_autoInsertBrackets = m_page->autoInsertBrackets->isChecked();
 | 
			
		||||
    settings.m_surroundingAutoBrackets = m_page->surroundSelectedText->isChecked();
 | 
			
		||||
    settings.m_partiallyComplete = m_page->partiallyComplete->isChecked();
 | 
			
		||||
@@ -158,6 +164,13 @@ TextEditor::CompletionTrigger CompletionSettingsPage::completionTrigger() const
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CompletionSettingsPage::onCompletionTriggerChanged()
 | 
			
		||||
{
 | 
			
		||||
    const bool enableTimeoutWidgets = completionTrigger() == TextEditor::AutomaticCompletion;
 | 
			
		||||
    m_page->automaticProposalTimeoutLabel->setEnabled(enableTimeoutWidgets);
 | 
			
		||||
    m_page->automaticProposalTimeoutSpinBox->setEnabled(enableTimeoutWidgets);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CompletionSettingsPage::finish()
 | 
			
		||||
{
 | 
			
		||||
    delete m_widget;
 | 
			
		||||
 
 | 
			
		||||
@@ -66,6 +66,8 @@ private:
 | 
			
		||||
    TextEditor::CaseSensitivity caseSensitivity() const;
 | 
			
		||||
    TextEditor::CompletionTrigger completionTrigger() const;
 | 
			
		||||
 | 
			
		||||
    void onCompletionTriggerChanged();
 | 
			
		||||
 | 
			
		||||
    bool requireCommentsSettingsUpdate() const;
 | 
			
		||||
 | 
			
		||||
    Ui::CompletionSettingsPage *m_page;
 | 
			
		||||
 
 | 
			
		||||
@@ -17,10 +17,10 @@
 | 
			
		||||
      <string>Behavior</string>
 | 
			
		||||
     </property>
 | 
			
		||||
     <layout class="QGridLayout" name="gridLayout">
 | 
			
		||||
      <item row="4" column="0">
 | 
			
		||||
       <layout class="QHBoxLayout" name="horizontalLayout">
 | 
			
		||||
      <item row="5" column="0">
 | 
			
		||||
       <layout class="QHBoxLayout" name="horizontalLayout_2">
 | 
			
		||||
        <item>
 | 
			
		||||
         <spacer name="horizontalSpacer_2">
 | 
			
		||||
         <spacer name="horizontalSpacer_4">
 | 
			
		||||
          <property name="orientation">
 | 
			
		||||
           <enum>Qt::Horizontal</enum>
 | 
			
		||||
          </property>
 | 
			
		||||
@@ -36,53 +36,17 @@
 | 
			
		||||
         </spacer>
 | 
			
		||||
        </item>
 | 
			
		||||
        <item>
 | 
			
		||||
         <widget class="QCheckBox" name="surroundSelectedText">
 | 
			
		||||
          <property name="toolTip">
 | 
			
		||||
           <string>When typing a matching character and there is a text selection, instead of removing the selection, surrounds it with the corresponding characters.</string>
 | 
			
		||||
         <widget class="QCheckBox" name="spaceAfterFunctionName">
 | 
			
		||||
          <property name="enabled">
 | 
			
		||||
           <bool>true</bool>
 | 
			
		||||
          </property>
 | 
			
		||||
          <property name="text">
 | 
			
		||||
           <string>Surround &text selections</string>
 | 
			
		||||
          </property>
 | 
			
		||||
          <property name="checked">
 | 
			
		||||
           <bool>true</bool>
 | 
			
		||||
           <string>Insert &space after function name</string>
 | 
			
		||||
          </property>
 | 
			
		||||
         </widget>
 | 
			
		||||
        </item>
 | 
			
		||||
       </layout>
 | 
			
		||||
      </item>
 | 
			
		||||
      <item row="0" column="2" colspan="2">
 | 
			
		||||
       <spacer name="horizontalSpacer">
 | 
			
		||||
        <property name="orientation">
 | 
			
		||||
         <enum>Qt::Horizontal</enum>
 | 
			
		||||
        </property>
 | 
			
		||||
        <property name="sizeHint" stdset="0">
 | 
			
		||||
         <size>
 | 
			
		||||
          <width>70</width>
 | 
			
		||||
          <height>24</height>
 | 
			
		||||
         </size>
 | 
			
		||||
        </property>
 | 
			
		||||
       </spacer>
 | 
			
		||||
      </item>
 | 
			
		||||
      <item row="1" column="0">
 | 
			
		||||
       <widget class="QLabel" name="completionTriggerLabel">
 | 
			
		||||
        <property name="text">
 | 
			
		||||
         <string>Activate completion:</string>
 | 
			
		||||
        </property>
 | 
			
		||||
       </widget>
 | 
			
		||||
      </item>
 | 
			
		||||
      <item row="1" column="3">
 | 
			
		||||
       <spacer name="horizontalSpacer_3">
 | 
			
		||||
        <property name="orientation">
 | 
			
		||||
         <enum>Qt::Horizontal</enum>
 | 
			
		||||
        </property>
 | 
			
		||||
        <property name="sizeHint" stdset="0">
 | 
			
		||||
         <size>
 | 
			
		||||
          <width>40</width>
 | 
			
		||||
          <height>24</height>
 | 
			
		||||
         </size>
 | 
			
		||||
        </property>
 | 
			
		||||
       </spacer>
 | 
			
		||||
      </item>
 | 
			
		||||
      <item row="0" column="0">
 | 
			
		||||
       <widget class="QLabel" name="caseSensitivityLabel">
 | 
			
		||||
        <property name="text">
 | 
			
		||||
@@ -118,6 +82,39 @@
 | 
			
		||||
        </item>
 | 
			
		||||
       </widget>
 | 
			
		||||
      </item>
 | 
			
		||||
      <item row="4" column="0">
 | 
			
		||||
       <layout class="QHBoxLayout" name="horizontalLayout">
 | 
			
		||||
        <item>
 | 
			
		||||
         <spacer name="horizontalSpacer_2">
 | 
			
		||||
          <property name="orientation">
 | 
			
		||||
           <enum>Qt::Horizontal</enum>
 | 
			
		||||
          </property>
 | 
			
		||||
          <property name="sizeType">
 | 
			
		||||
           <enum>QSizePolicy::Fixed</enum>
 | 
			
		||||
          </property>
 | 
			
		||||
          <property name="sizeHint" stdset="0">
 | 
			
		||||
           <size>
 | 
			
		||||
            <width>30</width>
 | 
			
		||||
            <height>20</height>
 | 
			
		||||
           </size>
 | 
			
		||||
          </property>
 | 
			
		||||
         </spacer>
 | 
			
		||||
        </item>
 | 
			
		||||
        <item>
 | 
			
		||||
         <widget class="QCheckBox" name="surroundSelectedText">
 | 
			
		||||
          <property name="toolTip">
 | 
			
		||||
           <string>When typing a matching character and there is a text selection, instead of removing the selection, surrounds it with the corresponding characters.</string>
 | 
			
		||||
          </property>
 | 
			
		||||
          <property name="text">
 | 
			
		||||
           <string>Surround &text selections</string>
 | 
			
		||||
          </property>
 | 
			
		||||
          <property name="checked">
 | 
			
		||||
           <bool>true</bool>
 | 
			
		||||
          </property>
 | 
			
		||||
         </widget>
 | 
			
		||||
        </item>
 | 
			
		||||
       </layout>
 | 
			
		||||
      </item>
 | 
			
		||||
      <item row="6" column="0">
 | 
			
		||||
       <widget class="QCheckBox" name="autoSplitStrings">
 | 
			
		||||
        <property name="toolTip">
 | 
			
		||||
@@ -130,6 +127,32 @@ In addition, Shift+Enter inserts an escape character at the cursor position and
 | 
			
		||||
        </property>
 | 
			
		||||
       </widget>
 | 
			
		||||
      </item>
 | 
			
		||||
      <item row="1" column="5">
 | 
			
		||||
       <spacer name="horizontalSpacer_3">
 | 
			
		||||
        <property name="orientation">
 | 
			
		||||
         <enum>Qt::Horizontal</enum>
 | 
			
		||||
        </property>
 | 
			
		||||
        <property name="sizeHint" stdset="0">
 | 
			
		||||
         <size>
 | 
			
		||||
          <width>40</width>
 | 
			
		||||
          <height>24</height>
 | 
			
		||||
         </size>
 | 
			
		||||
        </property>
 | 
			
		||||
       </spacer>
 | 
			
		||||
      </item>
 | 
			
		||||
      <item row="0" column="2" colspan="4">
 | 
			
		||||
       <spacer name="horizontalSpacer">
 | 
			
		||||
        <property name="orientation">
 | 
			
		||||
         <enum>Qt::Horizontal</enum>
 | 
			
		||||
        </property>
 | 
			
		||||
        <property name="sizeHint" stdset="0">
 | 
			
		||||
         <size>
 | 
			
		||||
          <width>70</width>
 | 
			
		||||
          <height>24</height>
 | 
			
		||||
         </size>
 | 
			
		||||
        </property>
 | 
			
		||||
       </spacer>
 | 
			
		||||
      </item>
 | 
			
		||||
      <item row="1" column="1" colspan="2">
 | 
			
		||||
       <widget class="QComboBox" name="completionTrigger">
 | 
			
		||||
        <item>
 | 
			
		||||
@@ -149,6 +172,13 @@ In addition, Shift+Enter inserts an escape character at the cursor position and
 | 
			
		||||
        </item>
 | 
			
		||||
       </widget>
 | 
			
		||||
      </item>
 | 
			
		||||
      <item row="1" column="3">
 | 
			
		||||
       <widget class="QLabel" name="automaticProposalTimeoutLabel">
 | 
			
		||||
        <property name="text">
 | 
			
		||||
         <string>Timeout in ms:</string>
 | 
			
		||||
        </property>
 | 
			
		||||
       </widget>
 | 
			
		||||
      </item>
 | 
			
		||||
      <item row="2" column="0">
 | 
			
		||||
       <widget class="QCheckBox" name="partiallyComplete">
 | 
			
		||||
        <property name="toolTip">
 | 
			
		||||
@@ -162,6 +192,13 @@ In addition, Shift+Enter inserts an escape character at the cursor position and
 | 
			
		||||
        </property>
 | 
			
		||||
       </widget>
 | 
			
		||||
      </item>
 | 
			
		||||
      <item row="1" column="0">
 | 
			
		||||
       <widget class="QLabel" name="completionTriggerLabel">
 | 
			
		||||
        <property name="text">
 | 
			
		||||
         <string>Activate completion:</string>
 | 
			
		||||
        </property>
 | 
			
		||||
       </widget>
 | 
			
		||||
      </item>
 | 
			
		||||
      <item row="3" column="0" colspan="2">
 | 
			
		||||
       <widget class="QCheckBox" name="autoInsertBrackets">
 | 
			
		||||
        <property name="toolTip">
 | 
			
		||||
@@ -175,35 +212,18 @@ In addition, Shift+Enter inserts an escape character at the cursor position and
 | 
			
		||||
        </property>
 | 
			
		||||
       </widget>
 | 
			
		||||
      </item>
 | 
			
		||||
      <item row="5" column="0">
 | 
			
		||||
       <layout class="QHBoxLayout" name="horizontalLayout_2">
 | 
			
		||||
        <item>
 | 
			
		||||
         <spacer name="horizontalSpacer_4">
 | 
			
		||||
          <property name="orientation">
 | 
			
		||||
           <enum>Qt::Horizontal</enum>
 | 
			
		||||
          </property>
 | 
			
		||||
          <property name="sizeType">
 | 
			
		||||
           <enum>QSizePolicy::Fixed</enum>
 | 
			
		||||
          </property>
 | 
			
		||||
          <property name="sizeHint" stdset="0">
 | 
			
		||||
           <size>
 | 
			
		||||
            <width>30</width>
 | 
			
		||||
            <height>20</height>
 | 
			
		||||
           </size>
 | 
			
		||||
          </property>
 | 
			
		||||
         </spacer>
 | 
			
		||||
        </item>
 | 
			
		||||
        <item>
 | 
			
		||||
         <widget class="QCheckBox" name="spaceAfterFunctionName">
 | 
			
		||||
          <property name="enabled">
 | 
			
		||||
           <bool>true</bool>
 | 
			
		||||
          </property>
 | 
			
		||||
          <property name="text">
 | 
			
		||||
           <string>Insert &space after function name</string>
 | 
			
		||||
          </property>
 | 
			
		||||
         </widget>
 | 
			
		||||
        </item>
 | 
			
		||||
       </layout>
 | 
			
		||||
      <item row="1" column="4">
 | 
			
		||||
       <widget class="QSpinBox" name="automaticProposalTimeoutSpinBox">
 | 
			
		||||
        <property name="maximum">
 | 
			
		||||
         <number>500</number>
 | 
			
		||||
        </property>
 | 
			
		||||
        <property name="singleStep">
 | 
			
		||||
         <number>50</number>
 | 
			
		||||
        </property>
 | 
			
		||||
        <property name="value">
 | 
			
		||||
         <number>400</number>
 | 
			
		||||
        </property>
 | 
			
		||||
       </widget>
 | 
			
		||||
      </item>
 | 
			
		||||
     </layout>
 | 
			
		||||
    </widget>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user