Skip to content

Commit

Permalink
Merge pull request #1 from dicene/edbee-lib_autocompletetoggle
Browse files Browse the repository at this point in the history
Adds toggle for disabling Autocomplete from automatically popping up.
  • Loading branch information
vadi2 authored Aug 13, 2019
2 parents ea68876 + 0b8c749 commit e8e1a71
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
15 changes: 15 additions & 0 deletions edbee-lib/edbee/models/texteditorconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,21 @@ void TextEditorConfig::setShowWhitespaceMode(const QString& str)
}
}

/// Sets whether autocomplete comes up automatically, or only manually(manual trigger isn't implemented yet)
/// @see TextEditorConfig::autocompleteAutoShow
void TextEditorConfig::setAutocompleteAutoShow(bool enable)
{
if( autocompleteAutoShow_ != enable ) {
autocompleteAutoShow_ = enable;
notifyChange();
}
}

/// Show autocomplete automatically, or only manually(manual isn't implemented yet)
bool TextEditorConfig::autocompleteAutoShow() const
{
return autocompleteAutoShow_;
}

/// This internal method is used to notify the listener that a change has happend
/// Thi smethod only emits a signal if there's no config group change busy
Expand Down
5 changes: 5 additions & 0 deletions edbee-lib/edbee/models/texteditorconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ Q_OBJECT
void setShowWhitespaceMode( int mode );
void setShowWhitespaceMode( const QString& str );

bool autocompleteAutoShow() const;
void setAutocompleteAutoShow( bool enable );


signals:
void configChanged();
Expand Down Expand Up @@ -120,6 +123,8 @@ Q_OBJECT

bool scrollPastEnd_; ///< Should the last line of the document be scrollable to the top of the window
int showWhitespaceMode_; ///< The current whitespace mode to make

bool autocompleteAutoShow_; ///< Show autocomplete automatically, or only when manually triggered
};

} // edbee
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,11 @@ void TextEditorAutoCompleteComponent::updateList()
TextDocument* doc = controller()->textDocument();
TextRange range = controller()->textSelection()->range(0);

if (!isVisible() && !doc->config()->autocompleteAutoShow())
{
return;
}

// when the character after
if(!shouldDisplayAutoComplete(range, currentWord_)) {
menuRef_->close();
Expand Down

0 comments on commit e8e1a71

Please sign in to comment.