X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fwidgets%2Fpopuptoolbutton.cpp;h=ff335a90e0acecde9d14fd52f0131aede820fcd7;hb=f32905530347e1020d5ce7959123cf797c9a4829;hp=ea3515c4981130696dc135b61748b510bbd90182;hpb=6a91973f74ee7360a82e107e8b2d708030498291;p=pulseview.git diff --git a/pv/widgets/popuptoolbutton.cpp b/pv/widgets/popuptoolbutton.cpp index ea3515c..ff335a9 100644 --- a/pv/widgets/popuptoolbutton.cpp +++ b/pv/widgets/popuptoolbutton.cpp @@ -18,35 +18,40 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "popuptoolbutton.h" +#include + +#include "popuptoolbutton.hpp" namespace pv { namespace widgets { PopupToolButton::PopupToolButton(QWidget *parent) : - QToolButton(parent) + QToolButton(parent), + popup_(nullptr) { connect(this, SIGNAL(clicked(bool)), this, SLOT(on_clicked(bool))); } Popup* PopupToolButton::popup() const { - return _popup; + return popup_; } void PopupToolButton::set_popup(Popup *popup) { assert(popup); - _popup = popup; + popup_ = popup; } void PopupToolButton::on_clicked(bool) { - if(!_popup) + if (!popup_) return; - _popup->set_position(mapToGlobal(rect().center()), Popup::Bottom); - _popup->show(); + const QRect r = rect(); + popup_->set_position(mapToGlobal(QPoint((r.left() + r.right()) / 2, + ((r.top() + r.bottom() * 3) / 4))), Popup::Bottom); + popup_->show(); } } // widgets