Skip to content

Commit

Permalink
improve combobox speed and autocompletion
Browse files Browse the repository at this point in the history
  • Loading branch information
garakmon committed Aug 7, 2019
1 parent e501a92 commit 5470ade
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
Makefile
porymap.pro.user
*.autosave
*.stash
Expand Down
2 changes: 1 addition & 1 deletion forms/tileseteditor.ui
Expand Up @@ -206,7 +206,7 @@
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QComboBox" name="comboBox_metatileBehaviors"/>
<widget class="NoScrollComboBox" name="comboBox_metatileBehaviors"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
Expand Down
11 changes: 11 additions & 0 deletions src/ui/noscrollcombobox.cpp
@@ -1,10 +1,21 @@
#include "noscrollcombobox.h"

#include <QCompleter>

NoScrollComboBox::NoScrollComboBox(QWidget *parent)
: QComboBox(parent)
{
// Don't let scrolling hijack focus.
setFocusPolicy(Qt::StrongFocus);

// Make speed a priority when loading comboboxes.
setMinimumContentsLength(20);// an arbitrary limit
setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);

// Allow items to be searched by any part of the word, displaying all matches.
setEditable(true);// can set to false manually when using
this->completer()->setCompletionMode(QCompleter::PopupCompletion);
this->completer()->setFilterMode(Qt::MatchContains);
}

void NoScrollComboBox::wheelEvent(QWheelEvent *event)
Expand Down

0 comments on commit 5470ade

Please sign in to comment.