diff options
author | Roberto C. Sanchez <roberto@connexer.com> | 2014-10-21 22:48:19 -0400 |
---|---|---|
committer | Roberto C. Sanchez <roberto@connexer.com> | 2014-10-21 22:48:19 -0400 |
commit | 1af3b165c9377702ca62a64112bc089a6f575c30 (patch) | |
tree | 4df9cca5543b2cab5ca56dbb1214d7d3b1f291e3 /src/frontend/displaywindow/bttoolbarpopupaction.cpp | |
parent | 5b5fd0dce407556f98ed8edee89dc830bf1437b1 (diff) |
Imported Upstream version 2.0~beta2
Diffstat (limited to 'src/frontend/displaywindow/bttoolbarpopupaction.cpp')
-rw-r--r-- | src/frontend/displaywindow/bttoolbarpopupaction.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/frontend/displaywindow/bttoolbarpopupaction.cpp b/src/frontend/displaywindow/bttoolbarpopupaction.cpp new file mode 100644 index 0000000..907a779 --- /dev/null +++ b/src/frontend/displaywindow/bttoolbarpopupaction.cpp @@ -0,0 +1,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(); +} + |