Browse Source

Merge pull request #3644 from Chocobo1/graph_btn

Change "Select Graphs" from QToolButton to QComboBox
adaptive-webui-19844
sledgehammer999 9 years ago
parent
commit
f81ffdb78e
  1. 24
      src/gui/properties/speedwidget.cpp
  2. 17
      src/gui/properties/speedwidget.h

24
src/gui/properties/speedwidget.cpp

@ -31,8 +31,6 @@ @@ -31,8 +31,6 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QComboBox>
#include <QToolButton>
#include <QMenu>
#include <QSignalMapper>
@ -44,6 +42,20 @@ @@ -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) @@ -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) @@ -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);

17
src/gui/properties/speedwidget.h

@ -30,6 +30,7 @@ @@ -30,6 +30,7 @@
#define SPEEDWIDGET_H
#include <QWidget>
#include <QComboBox>
#include <QtConcurrentRun>
#include "speedplotview.h"
@ -37,12 +38,22 @@ @@ -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: @@ -66,7 +77,7 @@ private:
QComboBox *m_periodCombobox;
SpeedPlotView *m_plot;
QToolButton *m_graphsButton;
ComboBoxMenuButton *m_graphsButton;
QMenu *m_graphsMenu;
QList<QAction *> m_graphsMenuActions;
QSignalMapper *m_graphsSignalMapper;

Loading…
Cancel
Save