summaryrefslogtreecommitdiff
path: root/ui/completioncombobox.h
blob: 1135d4e457cde0b8a3fab5ed433caf7ae11e5c2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once

#include "uitypes.h"
#include <QtGui/QKeyEvent>
#include <QtWidgets/QComboBox>

//! CompletionComboBox is a subclass of QComboBox intended to have a more
//! familiar user experience when working with auto-completion.
//!
//! Most notably, the <TAB> keypress is intercepted so that the tab key can be
//! used to cycle through completion options. This is similar the behavior found
//! in most text editors and IDEs.
//!
//! Additionally, the combo box is editable and uses case-sensitive matching,
//! popup-style completion, and a "no insert" policy by default.
class BINARYNINJAUIAPI CompletionComboBox : public QComboBox {
    Q_OBJECT

	bool m_forwardReturnEvents = true;

    //! Manually cycle the selected completion suggestion, forward by default.
    bool cycleCompletion(bool forward = true);

protected:
    bool event(QEvent* event) override;

public:
    CompletionComboBox(QWidget* parent = nullptr);

	void setForwardReturnEvents(bool forward) { m_forwardReturnEvents = forward; }

Q_SIGNALS:
    void enterPressed();
};