blob: 907a779a722f78cd7a5bcd439ea0e6f10e0f0f5a (
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
/*********
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2009 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "bttoolbarpopupaction.h"
#include <QMenu>
#include <QToolButton>
#include <QAction>
// This class provides a toolbar widget that has a icon plus a right side down arrow
// The icon is typically set to a back or forward arrow and the down arrow has a popup
// menu when clicked. The menu is typicallly populated with history actions.
BtToolBarPopupAction::BtToolBarPopupAction(const QIcon& icon, const QString& text, QObject* parent)
: QWidgetAction(parent), m_icon(icon), m_text(text)
{
m_menu = new QMenu();
}
BtToolBarPopupAction::~BtToolBarPopupAction()
{
delete m_menu;
}
QMenu* BtToolBarPopupAction::popupMenu() const
{
return m_menu;
}
QWidget* BtToolBarPopupAction::createWidget(QWidget* parent)
{
m_button = new QToolButton(parent);
setIcon(m_icon);
setToolTip(m_text);
m_button->setDefaultAction(this);
m_button->setPopupMode(QToolButton::MenuButtonPopup);
m_button->setMenu(m_menu);
bool ok = connect(m_button, SIGNAL(pressed()), this, SLOT(buttonPressed()));
Q_ASSERT(ok);;
return m_button;
}
void BtToolBarPopupAction::buttonPressed()
{
emit triggered();
}
|