mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-24 05:25:37 +00:00
Merge pull request #3644 from Chocobo1/graph_btn
Change "Select Graphs" from QToolButton to QComboBox
This commit is contained in:
commit
f81ffdb78e
@ -31,8 +31,6 @@
|
|||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QComboBox>
|
|
||||||
#include <QToolButton>
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QSignalMapper>
|
#include <QSignalMapper>
|
||||||
|
|
||||||
@ -44,6 +42,20 @@
|
|||||||
#include "core/preferences.h"
|
#include "core/preferences.h"
|
||||||
#include "core/utils/misc.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)
|
SpeedWidget::SpeedWidget(PropertiesWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
@ -63,11 +75,6 @@ SpeedWidget::SpeedWidget(PropertiesWidget *parent)
|
|||||||
|
|
||||||
connect(m_periodCombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(onPeriodChange(int)));
|
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 = new QMenu();
|
||||||
m_graphsMenu->addAction(tr("Total Upload"));
|
m_graphsMenu->addAction(tr("Total Upload"));
|
||||||
m_graphsMenu->addAction(tr("Total Download"));
|
m_graphsMenu->addAction(tr("Total Download"));
|
||||||
@ -92,7 +99,8 @@ SpeedWidget::SpeedWidget(PropertiesWidget *parent)
|
|||||||
}
|
}
|
||||||
connect(m_graphsSignalMapper, SIGNAL(mapped(int)), this, SLOT(onGraphChange(int)));
|
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_periodLabel);
|
||||||
m_hlayout->addWidget(m_periodCombobox);
|
m_hlayout->addWidget(m_periodCombobox);
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#define SPEEDWIDGET_H
|
#define SPEEDWIDGET_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QComboBox>
|
||||||
#include <QtConcurrentRun>
|
#include <QtConcurrentRun>
|
||||||
|
|
||||||
#include "speedplotview.h"
|
#include "speedplotview.h"
|
||||||
@ -37,12 +38,22 @@
|
|||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
class QHBoxLayout;
|
class QHBoxLayout;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QComboBox;
|
|
||||||
class QToolButton;
|
|
||||||
class QMenu;
|
class QMenu;
|
||||||
class QSignalMapper;
|
class QSignalMapper;
|
||||||
class PropertiesWidget;
|
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
|
class SpeedWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -66,7 +77,7 @@ private:
|
|||||||
QComboBox *m_periodCombobox;
|
QComboBox *m_periodCombobox;
|
||||||
SpeedPlotView *m_plot;
|
SpeedPlotView *m_plot;
|
||||||
|
|
||||||
QToolButton *m_graphsButton;
|
ComboBoxMenuButton *m_graphsButton;
|
||||||
QMenu *m_graphsMenu;
|
QMenu *m_graphsMenu;
|
||||||
QList<QAction *> m_graphsMenuActions;
|
QList<QAction *> m_graphsMenuActions;
|
||||||
QSignalMapper *m_graphsSignalMapper;
|
QSignalMapper *m_graphsSignalMapper;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user