mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Change "Select Graphs" from QToolButton to QComboBox
This commit is contained in:
parent
331219dda8
commit
2997c0fd1e
@ -31,8 +31,6 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QComboBox>
|
||||
#include <QToolButton>
|
||||
#include <QMenu>
|
||||
#include <QSignalMapper>
|
||||
|
||||
@ -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);
|
||||
|
@ -30,6 +30,7 @@
|
||||
#define SPEEDWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QComboBox>
|
||||
#include <QtConcurrentRun>
|
||||
|
||||
#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<QAction *> m_graphsMenuActions;
|
||||
QSignalMapper *m_graphsSignalMapper;
|
||||
|
Loading…
Reference in New Issue
Block a user