File: LazyFillComboBox.hpp

package info (click to toggle)
wsjtx-improved 3.0.0%2B250924%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 86,260 kB
  • sloc: cpp: 105,882; f90: 60,117; python: 27,241; ansic: 13,372; fortran: 2,382; makefile: 197; sh: 135
file content (54 lines) | stat: -rwxr-xr-x 1,020 bytes parent folder | download | duplicates (5)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef LAZY_FILL_COMBO_BOX_HPP__
#define LAZY_FILL_COMBO_BOX_HPP__

#include <QComboBox>

class QWidget;

//
// Class LazyFillComboBox
//
// QComboBox derivative that signals show and hide of the pop up list.
//
class LazyFillComboBox
  : public QComboBox
{
  Q_OBJECT

public:
  Q_SIGNAL void about_to_show_popup ();
  Q_SIGNAL void popup_hidden ();

  explicit LazyFillComboBox (QWidget * parent = nullptr)
    : QComboBox {parent}
  {
  }

#if QT_VERSION >= QT_VERSION_CHECK (5, 12, 0)
  void showPopup () override
  {
    Q_EMIT about_to_show_popup ();
    QComboBox::showPopup ();
  }

  void hidePopup () override
  {
    QComboBox::hidePopup ();
    Q_EMIT popup_hidden ();
  }
#else
  void mousePressEvent (QMouseEvent * e) override
  {
    Q_EMIT about_to_show_popup ();
    QComboBox::mousePressEvent (e);
  }

  void mouseReleaseEvent (QMouseEvent * e) override
  {
    QComboBox::mouseReleaseEvent (e);
    Q_EMIT popup_hidden ();
  }
#endif
};

#endif