diff --git a/retroshare-gui/src/gui/common/RSGraphWidget.h b/retroshare-gui/src/gui/common/RSGraphWidget.h
index 210402b12..e08a45eb9 100644
--- a/retroshare-gui/src/gui/common/RSGraphWidget.h
+++ b/retroshare-gui/src/gui/common/RSGraphWidget.h
@@ -180,7 +180,8 @@ public:
void setFiltering(bool b) ;
- void setFlags(uint32_t flag) { _flags |= flag ; }
+ uint32_t getFlags() const { return _flags ; }
+ void setFlags(uint32_t flag) { _flags |= flag ; }
void resetFlags(uint32_t flag) { _flags &= ~flag ; }
protected:
/** Overloaded QWidget::paintEvent() */
diff --git a/retroshare-gui/src/gui/images.qrc b/retroshare-gui/src/gui/images.qrc
index 248c5e1fd..af12479b5 100644
--- a/retroshare-gui/src/gui/images.qrc
+++ b/retroshare-gui/src/gui/images.qrc
@@ -181,6 +181,7 @@
images/go-bottom.png
images/graph-area.png
images/graph-line.png
+ images/graph-line-inverted.png
images/gpgp_key_generate.png
images/hide_toolbox_frame.png
images/hide_frame.png
diff --git a/retroshare-gui/src/gui/images/graph-line-inverted.png b/retroshare-gui/src/gui/images/graph-line-inverted.png
new file mode 100644
index 000000000..016fee678
Binary files /dev/null and b/retroshare-gui/src/gui/images/graph-line-inverted.png differ
diff --git a/retroshare-gui/src/gui/statistics/BWGraph.h b/retroshare-gui/src/gui/statistics/BWGraph.h
index 81330c68b..5edb10e71 100644
--- a/retroshare-gui/src/gui/statistics/BWGraph.h
+++ b/retroshare-gui/src/gui/statistics/BWGraph.h
@@ -48,7 +48,7 @@ public:
enum { SELECTOR_TYPE_FRIEND=0x00, SELECTOR_TYPE_SERVICE=0x01 };
enum { GRAPH_TYPE_SINGLE=0x00, GRAPH_TYPE_ALL=0x01, GRAPH_TYPE_SUM=0x02 };
enum { UNIT_KILOBYTES=0x00, UNIT_COUNT=0x01 };
- enum { DIRECTION_UP=0x00, DIRECTION_DOWN=0x01 };
+ enum { DIRECTION_UP=0x02, DIRECTION_DOWN=0x01 };
// re-derived from RSGraphSource
diff --git a/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.cpp b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.cpp
index d99a140fc..a4ac860e0 100644
--- a/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.cpp
+++ b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.cpp
@@ -19,11 +19,13 @@
* *
*******************************************************************************/
-#include
-#include
-#include
-#include
-#include
+#include "rshare.h"
+#include "control/bandwidthevent.h"
+#include "gui/statistics/BandwidthGraphWindow.h"
+#include "gui/common/FilesDefs.h"
+#include "util/misc.h"
+#include "retroshare-gui/RsAutoUpdatePage.h"
+#include "retroshare/rsconfig.h"
#include
#include
@@ -51,6 +53,12 @@
/* Images used in the graph style drop-down */
#define IMG_AREA_GRAPH ":/images/16x16/graph-area.png"
#define IMG_LINE_GRAPH ":/images/16x16/graph-line.png"
+#define IMG_SETTINGS ":/icons/system_128.png"
+#define IMG_CLEANUP ":/images/global_switch_off.png"
+#define IMG_SEND ":/images/go-up.png"
+#define IMG_RECEIVE ":/images/go-down.png"
+#define IMG_GRAPH_DARK ":/images/graph-line.png"
+#define IMG_GRAPH_LIGHT ":/images/graph-line-inverted.png"
/** Default constructor */
@@ -65,9 +73,6 @@ BandwidthGraph::BandwidthGraph(QWidget *parent, Qt::WindowFlags flags)
setShortcut("Ctrl+W", SLOT(close()));
#endif
- /* Bind events to actions */
- createActions();
-
/* Ask RetroShare core to notify us about bandwidth updates */
//_rsControl = RetroShare::rsControl();
//_rsControl->setEvent(REvents::Bandwidth, this, true);
@@ -77,7 +82,6 @@ BandwidthGraph::BandwidthGraph(QWidget *parent, Qt::WindowFlags flags)
/* Hide Bandwidth Graph Settings frame */
showSettingsFrame(false);
/* Load the previously saved settings */
- loadSettings();
/* Turn off opacity group on unsupported platforms */
#if defined(Q_OS_WIN)
@@ -88,18 +92,63 @@ BandwidthGraph::BandwidthGraph(QWidget *parent, Qt::WindowFlags flags)
#if defined(Q_OS_LINUX)
ui.frmOpacity->setVisible(false);
+ ui.chkAlwaysOnTop->setVisible(false);
+ ui.btnToggleSettings->setVisible(false); // this is only windows settings anyway
#endif
+
+ ui.btnToggleSettings->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_SETTINGS));
+ ui.btnToggleSettings->setText("");
+ ui.btnReset->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_CLEANUP));
+ ui.btnReset->setText("");
+ ui.chkSendRate->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_SEND));
+ ui.chkSendRate->setText("");
+ ui.chkReceiveRate->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_RECEIVE));
+ ui.chkReceiveRate->setText("");
+
+ ui.frmGraph->setToolTip("Use Ctrl+mouse wheel to change line width, Shift+wheel to time-filter the curve.");
+
+ loadSettings();
+
+ connect(ui.btnToggleSettings,SIGNAL(toggled(bool)),this,SLOT(showSettingsFrame(bool)));
+ connect(ui.btnReset, SIGNAL(clicked()), this, SLOT(reset()));
+ connect(ui.sldrOpacity, SIGNAL(valueChanged(int)), this, SLOT(setOpacity(int)));
+ connect(ui.btnGraphColor, SIGNAL(clicked()), this, SLOT(switchGraphColor()));
+ connect(ui.chkSendRate, SIGNAL(toggled(bool)), this, SLOT(toggleSendRate(bool)));
+ connect(ui.chkReceiveRate, SIGNAL(toggled(bool)), this, SLOT(toggleReceiveRate(bool)));
}
-/** Binds events to actions. */
-void
-BandwidthGraph::createActions()
+void BandwidthGraph::toggleSendRate(bool b)
{
- connect(ui.btnToggleSettings, SIGNAL(toggled(bool)), this, SLOT(showSettingsFrame(bool)));
- connect(ui.btnReset, SIGNAL(clicked()), this, SLOT(reset()));
- connect(ui.btnSaveSettings, SIGNAL(clicked()), this, SLOT(saveChanges()));
- connect(ui.btnCancelSettings, SIGNAL(clicked()), this, SLOT(cancelChanges()));
- connect(ui.sldrOpacity, SIGNAL(valueChanged(int)), this, SLOT(setOpacity(int)));
+ whileBlocking(ui.chkReceiveRate)->setChecked(!b);
+
+ if(b)
+ ui.frmGraph->setDirection(BWGraphSource::DIRECTION_UP) ;
+ else
+ ui.frmGraph->setDirection(BWGraphSource::DIRECTION_DOWN) ;
+}
+void BandwidthGraph::toggleReceiveRate(bool b)
+{
+ whileBlocking(ui.chkSendRate)->setChecked(!b);
+
+ if(b)
+ ui.frmGraph->setDirection(BWGraphSource::DIRECTION_DOWN) ;
+ else
+ ui.frmGraph->setDirection(BWGraphSource::DIRECTION_UP) ;
+}
+
+
+void BandwidthGraph::switchGraphColor()
+{
+ if(ui.frmGraph->getFlags() & RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE)
+ {
+ ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
+ ui.btnGraphColor->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_GRAPH_LIGHT));
+ }
+ else
+ {
+ ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
+ ui.btnGraphColor->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_GRAPH_DARK));
+ }
}
/** Loads the saved Bandwidth Graph settings. */
@@ -110,15 +159,6 @@ BandwidthGraph::loadSettings()
ui.sldrOpacity->setValue(getSetting(SETTING_OPACITY, DEFAULT_OPACITY).toInt());
setOpacity(ui.sldrOpacity->value());
- /* Set whether the window appears on top. */
- ui.chkAlwaysOnTop->setChecked(getSetting(SETTING_ALWAYS_ON_TOP, DEFAULT_ALWAYS_ON_TOP).toBool());
-
- if (ui.chkAlwaysOnTop->isChecked()) {
- setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
- } else {
- setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint);
- }
-
/* Set the line filter checkboxes accordingly */
uint filter = getSetting(SETTING_FILTER, DEFAULT_FILTER).toUInt();
ui.chkReceiveRate->setChecked(filter & BWGRAPH_LINE_RECV);
@@ -127,10 +167,10 @@ BandwidthGraph::loadSettings()
/* Set whether we are plotting bandwidth as area graphs or not */
int graphStyle = getSetting(SETTING_STYLE, DEFAULT_STYLE).toInt();
- if (graphStyle < 0 || graphStyle >= ui.cmbGraphStyle->count()) {
- graphStyle = DEFAULT_STYLE;
- }
- ui.cmbGraphStyle->setCurrentIndex(graphStyle);
+// if (graphStyle < 0 || graphStyle >= ui.cmbGraphStyle->count()) {
+// graphStyle = DEFAULT_STYLE;
+// }
+// ui.cmbGraphStyle->setCurrentIndex(graphStyle);
if(graphStyle==0)
ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN);
@@ -140,28 +180,37 @@ BandwidthGraph::loadSettings()
/* Set whether we are plotting bandwidth as area graphs or not */
int graphColor = getSetting(SETTING_GRAPHCOLOR, DEFAULT_GRAPHCOLOR).toInt();
- if (graphColor < 0 || graphColor >= ui.cmbGraphColor->count()) {
- graphColor = DEFAULT_GRAPHCOLOR;
- }
- ui.cmbGraphColor->setCurrentIndex(graphColor);
-
- if(graphColor==0)
+ if(graphColor>0)
+ {
ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
+ ui.btnGraphColor->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_GRAPH_DARK));
+ }
else
+ {
+ ui.btnGraphColor->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_GRAPH_LIGHT));
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 || defaultdirection >= ui.cmbDownUp->count()) {
- defaultdirection = DEFAULT_DIRECTION;
- }
- ui.cmbDownUp->setCurrentIndex(graphColor);
-
- if(defaultdirection==0)
- ui.frmGraph->setDirection(BWGraphSource::DIRECTION_UP) ;
- else
+ if(defaultdirection>0)
+ {
ui.frmGraph->setDirection(BWGraphSource::DIRECTION_DOWN) ;
+ whileBlocking(ui.chkSendRate)->setChecked(false);
+ whileBlocking(ui.chkReceiveRate)->setChecked(true);
+ }
+ else
+ {
+ ui.frmGraph->setDirection(BWGraphSource::DIRECTION_UP) ;
+ whileBlocking(ui.chkSendRate)->setChecked(true);
+ whileBlocking(ui.chkReceiveRate)->setChecked(false);
+ }
/* Default Settings for the Graph */
ui.frmGraph->setSelector(BWGraphSource::SELECTOR_TYPE_FRIEND,BWGraphSource::GRAPH_TYPE_SUM) ;
@@ -172,13 +221,11 @@ BandwidthGraph::loadSettings()
ui.frmGraph->setShowEntry(1,ui.chkSendRate->isChecked()) ;
}
-
-
/** Resets the log start time. */
void BandwidthGraph::reset()
{
/* Set to current time */
- ui.statusbar->showMessage(tr("Since:") + " " + QDateTime::currentDateTime() .toString(DATETIME_FMT));
+ ui.displayTime_LB->setText(tr("Since:") + " " + QDateTime::currentDateTime() .toString(DATETIME_FMT));
/* Reset the graph */
ui.frmGraph->resetGraph();
}
@@ -191,8 +238,8 @@ void BandwidthGraph::saveChanges()
/* Save the opacity and graph style */
saveSetting(SETTING_OPACITY, ui.sldrOpacity->value());
- saveSetting(SETTING_STYLE, ui.cmbGraphStyle->currentIndex());
- saveSetting(SETTING_GRAPHCOLOR, ui.cmbGraphColor->currentIndex());
+// saveSetting(SETTING_STYLE, ui.cmbGraphStyle->currentIndex());
+ saveSetting(SETTING_GRAPHCOLOR, ui.btnGraphColor->isChecked());
/* Save the Always On Top setting */
saveSetting(SETTING_ALWAYS_ON_TOP, ui.chkAlwaysOnTop->isChecked());
@@ -213,21 +260,22 @@ void BandwidthGraph::saveChanges()
/* Update the graph frame settings */
ui.frmGraph->setShowEntry(0,ui.chkReceiveRate->isChecked()) ;
ui.frmGraph->setShowEntry(1,ui.chkSendRate->isChecked()) ;
+ ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN);
- if(ui.cmbGraphStyle->currentIndex()==0)
- ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN);
- else
- ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN);
+// if(ui.cmbGraphStyle->currentIndex()==0)
+// ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN);
+// else
+// ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN);
- if(ui.cmbGraphColor->currentIndex()==0)
+ if(ui.btnGraphColor->isChecked()==0)
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) ;
+// 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. */
@@ -255,16 +303,16 @@ BandwidthGraph::showSettingsFrame(bool show)
if (show) {
/* Extend the bottom of the bandwidth graph and show the settings */
ui.frmSettings->setVisible(true);
- ui.btnToggleSettings->setChecked(true);
- ui.btnToggleSettings->setText(tr("Hide Settings"));
+// ui.btnToggleSettings->setChecked(true);
+// ui.btnToggleSettings->setText(tr("Hide Settings"));
/* 6 = vertical spacing between the settings frame and graph frame */
newSize.setHeight(newSize.height() + ui.frmSettings->height() + 6);
} else {
/* Shrink the height of the bandwidth graph and hide the settings */
ui.frmSettings->setVisible(false);
- ui.btnToggleSettings->setChecked(false);
- ui.btnToggleSettings->setText(tr("Show Settings"));
+// ui.btnToggleSettings->setChecked(false);
+// ui.btnToggleSettings->setText(tr("Show Settings"));
/* 6 = vertical spacing between the settings frame and graph frame */
newSize.setHeight(newSize.height() - ui.frmSettings->height() - 6);
diff --git a/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.h b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.h
index b1b4d9898..fb52d28b2 100644
--- a/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.h
+++ b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.h
@@ -51,6 +51,10 @@ public slots:
void showWindow();
private slots:
+ void switchGraphColor();
+ void toggleReceiveRate(bool b);
+ void toggleSendRate(bool b);
+
/** Called when settings button is toggled */
void showSettingsFrame(bool show);
/** Called when the settings button is toggled */
diff --git a/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.ui b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.ui
index 0bbf4dafe..56f1818f8 100644
--- a/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.ui
+++ b/retroshare-gui/src/gui/statistics/BandwidthGraphWindow.ui
@@ -6,8 +6,8 @@
0
0
- 418
- 305
+ 620
+ 432
@@ -18,8 +18,27 @@
:/images/logo/logo_16.png:/images/logo/logo_16.png
-
- -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 120
+ 80
+
+
+
+ Qt::NoContextMenu
+
+
+
+ -
6
@@ -36,6 +55,70 @@
0
+
-
+
+
+ PushButton
+
+
+ false
+
+
+
+ -
+
+
+ Qt::NoContextMenu
+
+
+
+
+
+ Qt::RightToLeft
+
+
+ Up
+
+
+ true
+
+
+ false
+
+
+
+ -
+
+
+ Qt::NoContextMenu
+
+
+
+
+
+ Qt::RightToLeft
+
+
+ Down
+
+
+ true
+
+
+ false
+
+
+
+ -
+
+
+ Clears the graph
+
+
+ Reset
+
+
+
-
@@ -60,15 +143,15 @@
-
-
+
- Reset
+ TextLabel
- -
+
-
@@ -97,166 +180,56 @@
QFrame::Raised
-
-
- 9
-
-
- 9
-
-
- 9
-
-
- 9
-
-
-
-
-
- 6
-
-
- 3
-
-
- 3
-
-
- 3
-
-
- 3
-
-
-
-
-
- Qt::NoContextMenu
-
-
-
-
-
- Qt::RightToLeft
-
-
- Receive Rate
-
-
- false
-
-
-
- -
-
-
- Qt::NoContextMenu
-
-
-
-
-
- Qt::RightToLeft
-
-
- Send Rate
-
-
- false
-
-
-
- -
-
-
- Qt::RightToLeft
-
-
- Always on Top
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 21
-
-
-
-
-
-
- -
-
-
- 1
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- Save
-
-
-
- -
-
-
- Cancel
-
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 21
- 20
-
-
-
-
- -
-
-
- 1
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
+
+
+
+ 1
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ 6
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+
+ -
+
+
+ Qt::NoContextMenu
+
+
+ QFrame::NoFrame
+
+
+ QFrame::Plain
+
+
- 6
+ 3
0
@@ -271,10 +244,47 @@
0
-
-
+
+
+ Qt::NoContextMenu
+
+
+ Changes the transparency of the Bandwidth Graph
+
+
+ 30
+
+
+ 100
+
+
+ 100
+
+
+ 100
+
+
+ false
+
Qt::Horizontal
+
+ false
+
+
+ QSlider::NoTicks
+
+
+ 10
+
+
+
+ -
+
+
+ Qt::Vertical
+
20
@@ -284,252 +294,111 @@
-
-
-
- Style
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
-
-
- -
-
-
-
-
-
-
-
- :/images/graph-line.png:/images/graph-line.png
-
+
+
+ Qt::Horizontal
+
+
+
+ 21
+ 0
+
+
+
-
-
-
-
-
-
- :/images/graph-area.png:/images/graph-area.png
-
-
-
-
- -
-
-
-
-
- Default
-
+
+
+
+ 25
+ 0
+
+
+
+ Qt::NoContextMenu
+
+
+ Qt::RightToLeft
+
+
+ 100
+
+
-
-
- Dark
-
-
-
-
- -
-
-
-
-
- Upload
-
+
+
+ Qt::NoContextMenu
+
+
+ % Opaque
+
+
-
-
- Download
-
+
+
+ Qt::Horizontal
+
+
+
+ 21
+ 0
+
+
+
-
+ -
+
+
+ Qt::RightToLeft
+
+
+ Always on Top
+
+
+
+
-
- -
-
-
- Qt::NoContextMenu
-
-
- QFrame::NoFrame
-
-
- QFrame::Plain
-
-
-
- 3
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- Qt::NoContextMenu
-
-
- Changes the transparency of the Bandwidth Graph
-
-
- 30
-
-
- 100
-
-
- 100
-
-
- 100
-
-
- false
-
-
- Qt::Horizontal
-
-
- false
-
-
- QSlider::NoTicks
-
-
- 10
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 20
-
-
-
-
- -
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 21
- 0
-
-
-
-
- -
-
-
-
- 25
- 0
-
-
-
- Qt::NoContextMenu
-
-
- Qt::RightToLeft
-
-
- 100
-
-
-
- -
-
-
- Qt::NoContextMenu
-
-
- % Opaque
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 21
- 0
-
-
-
-
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 21
- 20
-
-
-
-
-
-
-
-
-
- -
-
-
-
- 120
- 80
-
-
-
- Qt::NoContextMenu
-
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 21
+ 20
+
+
+
+
+
+
-