qBittorrent
speedwidget.h
Go to the documentation of this file.
1 /*
2  * Bittorrent Client using Qt and libtorrent.
3  * Copyright (C) 2015 Anton Lashkov <[email protected]>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  * In addition, as a special exception, the copyright holders give permission to
20  * link this program with the OpenSSL project's "OpenSSL" library (or with
21  * modified versions of it that use the same license as the "OpenSSL" library),
22  * and distribute the linked executables. You must obey the GNU General Public
23  * License in all respects for all of the code used other than "OpenSSL". If you
24  * modify file(s), you may extend this exception to your version of the file(s),
25  * but you are not obligated to do so. If you do not wish to do so, delete this
26  * exception statement from your version.
27  */
28 
29 #pragma once
30 
31 #include <QComboBox>
32 #include <QWidget>
33 
34 class QHBoxLayout;
35 class QLabel;
36 class QMenu;
37 class QVBoxLayout;
38 
39 class PropertiesWidget;
40 class SpeedPlotView;
41 
42 class ComboBoxMenuButton final : public QComboBox
43 {
44  Q_OBJECT
45 
46 public:
47  ComboBoxMenuButton(QWidget *parent, QMenu *menu);
48  void showPopup() override;
49 
50 private:
51  QMenu *m_menu;
52 };
53 
54 
55 class SpeedWidget : public QWidget
56 {
57  Q_OBJECT
58 
59 public:
60  explicit SpeedWidget(PropertiesWidget *parent);
61  ~SpeedWidget();
62 
63 private slots:
64  void onPeriodChange(int period);
65  void onGraphChange(int id);
66  void update();
67 
68 private:
69  void loadSettings();
70  void saveSettings() const;
71 
72  QVBoxLayout *m_layout;
73  QHBoxLayout *m_hlayout;
74  QLabel *m_periodLabel;
75  QComboBox *m_periodCombobox;
77 
79  QMenu *m_graphsMenu;
80  QList<QAction *> m_graphsMenuActions;
81 };
void showPopup() override
Definition: speedwidget.cpp:50
ComboBoxMenuButton(QWidget *parent, QMenu *menu)
Definition: speedwidget.cpp:44
QComboBox * m_periodCombobox
Definition: speedwidget.h:75
QList< QAction * > m_graphsMenuActions
Definition: speedwidget.h:80
SpeedPlotView * m_plot
Definition: speedwidget.h:76
QHBoxLayout * m_hlayout
Definition: speedwidget.h:73
void loadSettings()
QMenu * m_graphsMenu
Definition: speedwidget.h:79
SpeedWidget(PropertiesWidget *parent)
Definition: speedwidget.cpp:58
ComboBoxMenuButton * m_graphsButton
Definition: speedwidget.h:78
void onPeriodChange(int period)
QVBoxLayout * m_layout
Definition: speedwidget.h:72
QLabel * m_periodLabel
Definition: speedwidget.h:74
void onGraphChange(int id)
void saveSettings() const