mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-07 00:56:00 -05:00
Add option to disable filtering by typing in FilterComboBox
This commit is contained in:
@@ -7,9 +7,22 @@
|
||||
|
||||
namespace advss {
|
||||
|
||||
bool FilterComboBox::_filteringEnabled = false;
|
||||
|
||||
FilterComboBox::FilterComboBox(QWidget *parent, const QString &placehodler)
|
||||
: QComboBox(parent)
|
||||
{
|
||||
// If the filtering behaviour of the FilterComboBox is disabled it is
|
||||
// just a regular QComboBox with the option to set a placeholder so exit
|
||||
// the constructor early.
|
||||
|
||||
if (!_filteringEnabled) {
|
||||
if (!placehodler.isEmpty()) {
|
||||
setPlaceholderText(placehodler);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Allow edit for completer but don't add new entries on pressing enter
|
||||
setEditable(true);
|
||||
setInsertPolicy(InsertPolicy::NoInsert);
|
||||
@@ -31,6 +44,11 @@ FilterComboBox::FilterComboBox(QWidget *parent, const QString &placehodler)
|
||||
&FilterComboBox::TextChagned);
|
||||
}
|
||||
|
||||
void FilterComboBox::SetFilterBehaviourEnabled(bool value)
|
||||
{
|
||||
FilterComboBox::_filteringEnabled = value;
|
||||
}
|
||||
|
||||
void FilterComboBox::focusOutEvent(QFocusEvent *event)
|
||||
{
|
||||
// Reset on invalid selection
|
||||
|
||||
@@ -10,6 +10,7 @@ class FilterComboBox : public QComboBox {
|
||||
public:
|
||||
FilterComboBox(QWidget *parent = nullptr,
|
||||
const QString &placehodler = "");
|
||||
static void SetFilterBehaviourEnabled(bool);
|
||||
|
||||
protected:
|
||||
void focusOutEvent(QFocusEvent *event) override;
|
||||
@@ -20,6 +21,7 @@ private slots:
|
||||
|
||||
private:
|
||||
int _lastCompleterHighlightRow = -1;
|
||||
static bool _filteringEnabled;
|
||||
};
|
||||
|
||||
} // namespace advss
|
||||
|
||||
Reference in New Issue
Block a user