Merge pull request #2254 from defnax/BW-graph

Set to show only the Sum for Download or Upload on BW Window
This commit is contained in:
defnax 2021-01-26 23:23:22 +01:00 committed by GitHub
commit 67d1265eb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 88 additions and 49 deletions

View File

@ -35,11 +35,13 @@
#define SETTING_ALWAYS_ON_TOP "AlwaysOnTop"
#define SETTING_STYLE "GraphStyle"
#define SETTING_GRAPHCOLOR "GraphColor"
#define SETTING_DIRECTION "Direction"
#define DEFAULT_FILTER (BWGRAPH_LINE_SEND|BWGRAPH_LINE_RECV)
#define DEFAULT_ALWAYS_ON_TOP false
#define DEFAULT_OPACITY 100
#define DEFAULT_STYLE LineGraph
#define DEFAULT_GRAPHCOLOR DefaultColor
#define DEFAULT_DIRECTION DefaultDirection
#define ADD_TO_FILTER(f,v,b) (f = ((b) ? ((f) | (v)) : ((f) & ~(v))))
@ -148,6 +150,23 @@ BandwidthGraph::loadSettings()
else
ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
/* Download & Upload */
int defaultdirection = getSetting(SETTING_DIRECTION, DEFAULT_DIRECTION).toInt();
if (defaultdirection < 0 || defaultdirection >= ui.cmbDownUp->count()) {
defaultdirection = DEFAULT_DIRECTION;
}
ui.cmbDownUp->setCurrentIndex(graphColor);
if(defaultdirection==0)
ui.frmGraph->setDirection(BWGraphSource::DIRECTION_UP) ;
else
ui.frmGraph->setDirection(BWGraphSource::DIRECTION_DOWN) ;
/* Default Settings for the Graph */
ui.frmGraph->setSelector(BWGraphSource::SELECTOR_TYPE_FRIEND,BWGraphSource::GRAPH_TYPE_SUM) ;
ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_LOG_SCALE_Y) ;
/* Set graph frame settings */
ui.frmGraph->setShowEntry(0,ui.chkReceiveRate->isChecked()) ;
ui.frmGraph->setShowEntry(1,ui.chkSendRate->isChecked()) ;
@ -204,6 +223,11 @@ void BandwidthGraph::saveChanges()
ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
else
ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
if(ui.cmbDownUp->currentIndex()==0)
ui.frmGraph->setDirection(BWGraphSource::DIRECTION_UP) ;
else
ui.frmGraph->setDirection(BWGraphSource::DIRECTION_DOWN) ;
/* A change in window flags causes the window to disappear, so make sure
* it's still visible. */

View File

@ -41,6 +41,7 @@ class BandwidthGraph : public RWindow
public:
enum { AreaGraph=0,LineGraph=1 } ;
enum { DefaultColor=0,DarkColor=1 } ;
enum { DefaultDirection=0,Download=1 } ;
/** Default constructor */
BandwidthGraph(QWidget *parent = 0, Qt::WindowFlags flags = 0);

View File

@ -78,13 +78,13 @@
</property>
<property name="minimumSize">
<size>
<width>400</width>
<width>450</width>
<height>82</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<width>450</width>
<height>82</height>
</size>
</property>
@ -190,7 +190,53 @@
</item>
</layout>
</item>
<item row="0" column="1" rowspan="2">
<item row="0" column="4" rowspan="2">
<layout class="QVBoxLayout" name="_7">
<property name="spacing">
<number>1</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="btnSaveSettings">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnCancelSettings">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="3">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>21</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1" rowspan="2" colspan="2">
<layout class="QVBoxLayout" name="_3">
<property name="spacing">
<number>1</number>
@ -280,6 +326,20 @@
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="cmbDownUp">
<item>
<property name="text">
<string>Upload</string>
</property>
</item>
<item>
<property name="text">
<string>Download</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
@ -451,52 +511,6 @@
</item>
</layout>
</item>
<item row="0" column="4" rowspan="2">
<layout class="QVBoxLayout" name="_7">
<property name="spacing">
<number>1</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="btnSaveSettings">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnCancelSettings">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="3">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>21</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>