BibleTime
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
Functions
a
b
c
d
e
f
g
h
i
l
m
n
p
q
r
s
t
v
Variables
a
b
c
d
g
h
i
k
l
m
p
r
s
u
Typedefs
Enumerations
Enumerator
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
~
Functions
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
~
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Typedefs
Enumerations
Enumerator
a
b
c
d
e
f
g
h
i
l
m
n
p
r
s
t
u
w
Properties
Related Symbols
Files
File List
File Members
All
a
b
c
e
f
h
i
j
k
l
m
o
p
r
s
t
u
w
Functions
b
c
f
i
j
l
m
o
p
r
t
Variables
Typedefs
Enumerations
Enumerator
Macros
a
b
c
i
l
m
r
s
t
u
w
src
frontend
displaywindow
bttoolbarpopupaction.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-2025 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 "
bttoolbarpopupaction.h
"
14
15
#include <QEvent>
16
#include <QMenu>
17
#include <QToolButton>
18
#include "../../util/btconnect.h"
19
20
21
namespace
{
22
23
class
BtToolButton
:
public
QToolButton
{
24
public
:
25
BtToolButton
(
QWidget
*parent =
nullptr
)
26
:
QToolButton
(parent) {}
25
BtToolButton
(
QWidget
*parent =
nullptr
) {
…
}
27
private
:
28
void
nextCheckState
()
override
{}
29
};
23
class
BtToolButton
:
public
QToolButton
{
…
};
30
31
}
// anonymous namespace
21
namespace
{
…
}
32
33
34
// This class provides a toolbar widget that has a icon plus a right side down arrow
35
// The icon is typically set to a back or forward arrow and the down arrow has a popup
36
// menu when clicked. The menu is typicallly populated with history actions.
37
BtToolBarPopupAction::BtToolBarPopupAction
(QIcon
const
& icon,
38
QString
const
& text,
39
QObject
* parent)
40
:
QWidgetAction
(parent)
41
, m_menu(std::make_unique<
QMenu
>())
42
, m_icon(icon)
43
, m_text(text)
44
{ setText(text); }
37
BtToolBarPopupAction::BtToolBarPopupAction
(QIcon
const
& icon, {
…
}
45
46
BtToolBarPopupAction::~BtToolBarPopupAction
() =
default
;
47
48
// return the QMenu object so a popup menu can be constructed
49
QMenu
*
BtToolBarPopupAction::popupMenu
()
const
{
return
m_menu
.get(); }
50
51
QWidget
*
BtToolBarPopupAction::createWidget
(
QWidget
* parent) {
52
auto
*
const
button =
new
BtToolButton(parent);
53
setIcon(
m_icon
);
54
setToolTip(
m_text
);
55
button->setDefaultAction(
this
);
56
button->setPopupMode(QToolButton::MenuButtonPopup);
57
button->setMenu(
m_menu
.get());
58
BT_CONNECT
(button, &BtToolButton::pressed,
59
this
/* Meeded */
, [
this
] { Q_EMIT triggered(); });
60
return
button;
61
}
51
QWidget
*
BtToolBarPopupAction::createWidget
(
QWidget
* parent) {
…
}
62
63
// Function to catch the Shortcut event and emit the triggered signal
64
bool
BtToolBarPopupAction::event
(QEvent *event) {
65
if
(
event
->type() == QEvent::Shortcut) {
66
Q_EMIT triggered();
67
return
true
;
68
}
69
return
QWidgetAction::event(
event
);
70
}
64
bool
BtToolBarPopupAction::event
(QEvent *event) {
…
}
BT_CONNECT
#define BT_CONNECT(...)
Definition
btconnect.h:20
bttoolbarpopupaction.h
BtToolBarPopupAction::m_text
QString m_text
Definition
bttoolbarpopupaction.h:47
BtToolBarPopupAction::createWidget
QWidget * createWidget(QWidget *parent) override
Definition
bttoolbarpopupaction.cpp:51
BtToolBarPopupAction::~BtToolBarPopupAction
~BtToolBarPopupAction() override
BtToolBarPopupAction::popupMenu
QMenu * popupMenu() const
Definition
bttoolbarpopupaction.cpp:49
BtToolBarPopupAction::BtToolBarPopupAction
BtToolBarPopupAction(const QIcon &icon, const QString &text, QObject *parent)
Definition
bttoolbarpopupaction.cpp:37
BtToolBarPopupAction::event
bool event(QEvent *e) override
Definition
bttoolbarpopupaction.cpp:64
BtToolBarPopupAction::m_menu
std::unique_ptr< QMenu > const m_menu
Definition
bttoolbarpopupaction.h:45
BtToolBarPopupAction::m_icon
QIcon m_icon
Definition
bttoolbarpopupaction.h:46
QMenu
QObject
QToolButton
QWidgetAction
QWidget
anonymous_namespace{bttoolbarpopupaction.cpp}::BtToolButton
Definition
bttoolbarpopupaction.cpp:23
anonymous_namespace{bttoolbarpopupaction.cpp}::BtToolButton::nextCheckState
void nextCheckState() override
Definition
bttoolbarpopupaction.cpp:28
anonymous_namespace{bttoolbarpopupaction.cpp}::BtToolButton::BtToolButton
BtToolButton(QWidget *parent=nullptr)
Definition
bttoolbarpopupaction.cpp:25
Generated by
1.9.8