diff --git a/src/gui/properties/speedwidget.cpp b/src/gui/properties/speedwidget.cpp index 6d1ee07da..92ce17bf1 100644 --- a/src/gui/properties/speedwidget.cpp +++ b/src/gui/properties/speedwidget.cpp @@ -31,8 +31,6 @@ #include #include #include -#include -#include #include #include @@ -44,6 +42,20 @@ #include "core/preferences.h" #include "core/utils/misc.h" +ComboBoxMenuButton::ComboBoxMenuButton(QWidget *parent, QMenu *menu) + : QComboBox(parent) + , m_menu(menu) +{ +} + +void ComboBoxMenuButton::showPopup() +{ + QPoint p = mapToGlobal(QPoint(0, height())); + m_menu->exec(p); + QComboBox::hidePopup(); +} + + SpeedWidget::SpeedWidget(PropertiesWidget *parent) : QWidget(parent) { @@ -63,11 +75,6 @@ SpeedWidget::SpeedWidget(PropertiesWidget *parent) connect(m_periodCombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(onPeriodChange(int))); - m_graphsButton = new QToolButton(); - m_graphsButton->setText(tr("Select Graphs")); - m_graphsButton->setPopupMode(QToolButton::InstantPopup); - m_graphsButton->setAutoExclusive(true); - m_graphsMenu = new QMenu(); m_graphsMenu->addAction(tr("Total Upload")); m_graphsMenu->addAction(tr("Total Download")); @@ -92,7 +99,8 @@ SpeedWidget::SpeedWidget(PropertiesWidget *parent) } connect(m_graphsSignalMapper, SIGNAL(mapped(int)), this, SLOT(onGraphChange(int))); - m_graphsButton->setMenu(m_graphsMenu); + m_graphsButton = new ComboBoxMenuButton(this, m_graphsMenu); + m_graphsButton->addItem(tr("Select Graphs")); m_hlayout->addWidget(m_periodLabel); m_hlayout->addWidget(m_periodCombobox); diff --git a/src/gui/properties/speedwidget.h b/src/gui/properties/speedwidget.h index 281efd569..c4d366819 100644 --- a/src/gui/properties/speedwidget.h +++ b/src/gui/properties/speedwidget.h @@ -30,6 +30,7 @@ #define SPEEDWIDGET_H #include +#include #include #include "speedplotview.h" @@ -37,12 +38,22 @@ class QVBoxLayout; class QHBoxLayout; class QLabel; -class QComboBox; -class QToolButton; class QMenu; class QSignalMapper; class PropertiesWidget; +class ComboBoxMenuButton : public QComboBox +{ + Q_OBJECT +public: + ComboBoxMenuButton(QWidget *parent, QMenu *menu); + virtual void showPopup(); + +private: + QMenu *m_menu; +}; + + class SpeedWidget : public QWidget { Q_OBJECT @@ -66,7 +77,7 @@ private: QComboBox *m_periodCombobox; SpeedPlotView *m_plot; - QToolButton *m_graphsButton; + ComboBoxMenuButton *m_graphsButton; QMenu *m_graphsMenu; QList m_graphsMenuActions; QSignalMapper *m_graphsSignalMapper;