BibleTime
btversekeymenu.cpp
Go to the documentation of this file.
1 /*********
2 *
3 * In the name of the Father, and of the Son, and of the Holy Spirit.
4 *
5 * This file is part of BibleTime's source code, https://bibletime.info/
6 *
7 * Copyright 1999-2021 by the BibleTime developers.
8 * The BibleTime source code is licensed under the GNU General Public License
9 * version 2.0.
10 *
11 **********/
12 
13 #include "btversekeymenu.h"
14 
15 #include <QMenu>
16 #include <QTimerEvent>
17 #include "../../../util/btconnect.h"
18 
19 
21  : QMenu(parent)
22  , m_timerId(0)
23  , m_firstClickLock(true)
24 {
25  BT_CONNECT(this, &QMenu::aboutToShow,
26  [this] {
27  m_firstClickLock = true;
28  if (m_timerId) {
29  killTimer(m_timerId);
30  m_timerId = 0;
31  }
32  m_timerId = startTimer(300);
33  });
34 }
35 
36 void BtVerseKeyMenu::timerEvent(QTimerEvent* e) {
37  if (e->timerId() == m_timerId) {
38  if (m_timerId) {
39  killTimer(m_timerId);
40  m_timerId = 0;
41  }
42  m_firstClickLock = false;
43  }
44  else {
45  QMenu::timerEvent(e);
46  }
47 }
48 
49 void BtVerseKeyMenu::mouseReleaseEvent(QMouseEvent* e) {
50  if (m_firstClickLock) return;
51  QMenu::mouseReleaseEvent(e);
52 }
#define BT_CONNECT(...)
Definition: btconnect.h:20
void timerEvent(QTimerEvent *event) override
BtVerseKeyMenu(QWidget *parent)
void mouseReleaseEvent(QMouseEvent *event) override