mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge pull request #2263 from csoler/v0.6-BugFixing_8
Attempt to improve BW graph
This commit is contained in:
commit
104facdfe2
@ -819,8 +819,7 @@ bool ftServer::ExtraFileAdd(std::string fname, const RsFileHash& hash, uint64_t
|
||||
bool ftServer::ExtraFileRemove(const RsFileHash& hash)
|
||||
{ return mFileDatabase->removeExtraFile(hash); }
|
||||
|
||||
bool ftServer::ExtraFileHash(
|
||||
std::string localpath, rstime_t period, TransferRequestFlags flags )
|
||||
bool ftServer::ExtraFileHash( std::string localpath, rstime_t period, TransferRequestFlags flags )
|
||||
{
|
||||
constexpr rstime_t uintmax = std::numeric_limits<uint32_t>::max();
|
||||
if(period > uintmax)
|
||||
|
@ -1045,6 +1045,8 @@ bool RsGxsNetTunnelService::receiveSearchRequest(unsigned char *search_request_d
|
||||
search_result_data_size = RsGxsNetTunnelSerializer().size(&search_result_item) ;
|
||||
search_result_data = (unsigned char*)rs_malloc(search_result_data_size) ;
|
||||
|
||||
delete item;
|
||||
|
||||
if(search_result_data == NULL)
|
||||
return false ;
|
||||
|
||||
@ -1082,10 +1084,12 @@ bool RsGxsNetTunnelService::receiveSearchRequest(unsigned char *search_request_d
|
||||
|
||||
RsGxsNetTunnelSerializer().serialise(&search_result_item,search_result_data,&search_result_data_size);
|
||||
|
||||
delete item;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
||||
delete item;
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
@ -390,7 +390,7 @@ void p3GxsReputation::cleanup()
|
||||
#ifdef DEBUG_REPUTATION
|
||||
std::cerr << " ID " << it->first << ": own is negative for more than " << mMaxPreventReloadBannedIds/86400 << " days. Reseting it!" << std::endl;
|
||||
#endif
|
||||
mChanged = true ;
|
||||
should_delete = true;
|
||||
}
|
||||
|
||||
// Delete slots with basically no information
|
||||
|
@ -99,6 +99,12 @@ public:
|
||||
SFDSortFilterProxyModel(RetroshareDirModel *dirModel, QObject *parent) : QSortFilterProxyModel(parent)
|
||||
{
|
||||
m_dirModel = dirModel;
|
||||
|
||||
// Mr.Alice: I removed this because it causes a crash for some obscur reason. Apparently when the model is changed, the proxy model cannot
|
||||
// deal with the change by itself. Should I call something specific? I've no idea. Removing this does not seem to cause any harm either.
|
||||
//Ghibli: set false because by default in qt5 is true and makes rs crash when sorting, all this decided by Cyril not me :D it works
|
||||
|
||||
setDynamicSortFilter(false);
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -193,12 +199,6 @@ SharedFilesDialog::SharedFilesDialog(bool remote_mode, QWidget *parent)
|
||||
flat_proxyModel->setFilterRole(RetroshareDirModel::FilterRole);
|
||||
flat_proxyModel->setFilterRegExp(QRegExp(QString(RETROSHARE_DIR_MODEL_FILTER_STRING))) ;
|
||||
|
||||
// Mr.Alice: I removed this because it causes a crash for some obscur reason. Apparently when the model is changed, the proxy model cannot
|
||||
// deal with the change by itself. Should I call something specific? I've no idea. Removing this does not seem to cause any harm either.
|
||||
//Ghibli: set false because by default in qt5 is true and makes rs crash when sorting, all this decided by Cyril not me :D it works
|
||||
tree_proxyModel->setDynamicSortFilter(false);
|
||||
flat_proxyModel->setDynamicSortFilter(false);
|
||||
|
||||
connect(ui.filterClearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
||||
connect(ui.filterStartButton, SIGNAL(clicked()), this, SLOT(startFilter()));
|
||||
connect(ui.filterPatternLineEdit, SIGNAL(returnPressed()), this, SLOT(startFilter()));
|
||||
|
@ -111,7 +111,10 @@ public:
|
||||
: QSortFilterProxyModel(parent)
|
||||
, m_header(header)
|
||||
, m_sortingEnabled(false), m_sortByState(false)
|
||||
, m_showOfflineNodes(true) {}
|
||||
, m_showOfflineNodes(true)
|
||||
{
|
||||
setDynamicSortFilter(false); // causes crashes when true.
|
||||
}
|
||||
|
||||
bool lessThan(const QModelIndex& left, const QModelIndex& right) const override
|
||||
{
|
||||
@ -184,7 +187,6 @@ NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,par
|
||||
|
||||
mProxyModel->setSourceModel(mModel);
|
||||
mProxyModel->setSortRole(RsFriendListModel::SortRole);
|
||||
mProxyModel->setDynamicSortFilter(false);
|
||||
mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
mProxyModel->setFilterRole(RsFriendListModel::FilterRole);
|
||||
mProxyModel->setFilterRegExp(QRegExp(RsFriendListModel::FilterString));
|
||||
|
@ -180,6 +180,7 @@ public:
|
||||
|
||||
void setFiltering(bool b) ;
|
||||
|
||||
uint32_t getFlags() const { return _flags ; }
|
||||
void setFlags(uint32_t flag) { _flags |= flag ; }
|
||||
void resetFlags(uint32_t flag) { _flags &= ~flag ; }
|
||||
protected:
|
||||
|
@ -64,7 +64,9 @@ class FSMSortFilterProxyModel : public QSortFilterProxyModel
|
||||
{
|
||||
public:
|
||||
FSMSortFilterProxyModel( QObject *parent) : QSortFilterProxyModel(parent)
|
||||
{}
|
||||
{
|
||||
setDynamicSortFilter(false); // essential to avoid random crashes
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const
|
||||
@ -201,7 +203,6 @@ RsCollectionDialog::RsCollectionDialog(const QString& collectionFileName
|
||||
connect(_dirModel, SIGNAL(directoryLoaded(QString)), this, SLOT(directoryLoaded(QString)));
|
||||
|
||||
_tree_proxyModel = new FSMSortFilterProxyModel(this);
|
||||
_tree_proxyModel->setDynamicSortFilter(true);
|
||||
_tree_proxyModel->setSourceModel(_dirModel);
|
||||
_tree_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
_tree_proxyModel->setSortRole(Qt::DisplayRole);
|
||||
|
@ -206,7 +206,10 @@ public:
|
||||
class ForumPostSortFilterProxyModel: public QSortFilterProxyModel
|
||||
{
|
||||
public:
|
||||
explicit ForumPostSortFilterProxyModel(const QHeaderView *header,QObject *parent = NULL): QSortFilterProxyModel(parent),m_header(header) {}
|
||||
explicit ForumPostSortFilterProxyModel(const QHeaderView *header,QObject *parent = NULL): QSortFilterProxyModel(parent),m_header(header)
|
||||
{
|
||||
setDynamicSortFilter(false); // causes crashes when true
|
||||
}
|
||||
|
||||
bool lessThan(const QModelIndex& left, const QModelIndex& right) const override
|
||||
{
|
||||
|
@ -181,6 +181,7 @@
|
||||
<file>images/go-bottom.png</file>
|
||||
<file>images/graph-area.png</file>
|
||||
<file>images/graph-line.png</file>
|
||||
<file>images/graph-line-inverted.png</file>
|
||||
<file>images/gpgp_key_generate.png</file>
|
||||
<file>images/hide_toolbox_frame.png</file>
|
||||
<file>images/hide_frame.png</file>
|
||||
|
BIN
retroshare-gui/src/gui/images/graph-line-inverted.png
Normal file
BIN
retroshare-gui/src/gui/images/graph-line-inverted.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
@ -98,7 +98,10 @@
|
||||
class MessageSortFilterProxyModel: public QSortFilterProxyModel
|
||||
{
|
||||
public:
|
||||
MessageSortFilterProxyModel(QObject *parent = NULL): QSortFilterProxyModel(parent), m_sortingEnabled(false) {}
|
||||
MessageSortFilterProxyModel(QObject *parent = NULL): QSortFilterProxyModel(parent), m_sortingEnabled(false)
|
||||
{
|
||||
setDynamicSortFilter(false); // causes crashes when true
|
||||
}
|
||||
|
||||
bool lessThan(const QModelIndex& left, const QModelIndex& right) const override
|
||||
{
|
||||
@ -145,7 +148,6 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
||||
mMessageProxyModel = new MessageSortFilterProxyModel(this);
|
||||
mMessageProxyModel->setSourceModel(mMessageModel);
|
||||
mMessageProxyModel->setSortRole(RsMessageModel::SortRole);
|
||||
mMessageProxyModel->setDynamicSortFilter(false);
|
||||
mMessageProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
mMessageProxyModel->setFilterRole(RsMessageModel::FilterRole);
|
||||
mMessageProxyModel->setFilterRegExp(QRegExp(RsMessageModel::FilterString));
|
||||
|
@ -80,11 +80,23 @@ void BWGraphSource::update()
|
||||
std::cerr << " visible service: " << std::dec << mVisibleServices.size() << std::endl;
|
||||
#endif
|
||||
|
||||
// now, convert data to current curve points.
|
||||
// Now, convert latest data measurement into points. convertTrafficToValues() returns
|
||||
// a map of values corresponding to the latest point in time, doing all the requested calculations
|
||||
// (sum over friends, sum over services, etc).
|
||||
//
|
||||
|
||||
std::map<std::string,float> vals ;
|
||||
|
||||
if(_current_direction == BWGraphSource::DIRECTION_UP)
|
||||
if(_current_direction == (DIRECTION_UP | DIRECTION_DOWN))
|
||||
{
|
||||
std::map<std::string,float> vals1,vals2 ;
|
||||
convertTrafficClueToValues(thc.out_rstcl,vals1) ;
|
||||
convertTrafficClueToValues(thc.in_rstcl,vals2) ;
|
||||
|
||||
for(auto it:vals1) vals[it.first + " (sent)"] = it.second;
|
||||
for(auto it:vals2) vals[it.first + " (received)"] = it.second;
|
||||
}
|
||||
else if(_current_direction & DIRECTION_UP)
|
||||
convertTrafficClueToValues(thc.out_rstcl,vals) ;
|
||||
else
|
||||
convertTrafficClueToValues(thc.in_rstcl,vals) ;
|
||||
@ -217,8 +229,6 @@ std::string BWGraphSource::makeSubItemName(uint16_t service_id,uint8_t sub_item_
|
||||
|
||||
void BWGraphSource::convertTrafficClueToValues(const std::list<RSTrafficClue>& lst,std::map<std::string,float>& vals) const
|
||||
{
|
||||
vals.clear() ;
|
||||
|
||||
switch(_friend_graph_type)
|
||||
{
|
||||
case GRAPH_TYPE_SINGLE:
|
||||
@ -555,7 +565,16 @@ void BWGraphSource::recomputeCurrentCurves()
|
||||
|
||||
std::set<std::string> unused_values = used_values_ref ;
|
||||
|
||||
if(_current_direction==DIRECTION_UP)
|
||||
if(_current_direction == (DIRECTION_UP | DIRECTION_DOWN))
|
||||
{
|
||||
std::map<std::string,float> vals1,vals2 ;
|
||||
convertTrafficClueToValues((*it).out_rstcl,vals1) ;
|
||||
convertTrafficClueToValues((*it).in_rstcl,vals2) ;
|
||||
|
||||
for(auto it:vals1) vals[it.first + " (sent)"] = it.second;
|
||||
for(auto it:vals2) vals[it.first + " (received)"] = it.second;
|
||||
}
|
||||
else if(_current_direction & DIRECTION_UP)
|
||||
convertTrafficClueToValues((*it).out_rstcl,vals) ;
|
||||
else
|
||||
convertTrafficClueToValues((*it).in_rstcl,vals) ;
|
||||
|
@ -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_DOWN=0x01,DIRECTION_UP=0x02 }; // can be combined using binary ops
|
||||
|
||||
// re-derived from RSGraphSource
|
||||
|
||||
@ -113,6 +113,8 @@ class BWGraph: public RSGraphWidget
|
||||
void setDirection(int dir) { _local_source->setDirection(dir); }
|
||||
void setUnit(int unit) { _local_source->setUnit(unit) ;}
|
||||
|
||||
int direction() const { return _local_source->direction(); }
|
||||
|
||||
const std::map<RsPeerId,std::string>& visibleFriends() const { return _local_source->visibleFriends(); }
|
||||
const std::set<uint16_t>& visibleServices() const { return _local_source->visibleServices(); }
|
||||
protected:
|
||||
|
@ -19,11 +19,13 @@
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#include <rshare.h>
|
||||
#include <control/bandwidthevent.h>
|
||||
#include <gui/statistics/BandwidthGraphWindow.h>
|
||||
#include <retroshare-gui/RsAutoUpdatePage.h>
|
||||
#include <retroshare/rsconfig.h>
|
||||
#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 <iomanip>
|
||||
#include <unistd.h>
|
||||
@ -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,61 @@ 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.btnGraphColor->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_GRAPH_LIGHT));
|
||||
ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
|
||||
|
||||
ui.frmGraph->setToolTip("Use Ctrl+mouse wheel to change line width, Shift+wheel to time-filter the curve.");
|
||||
ui.frmGraph->setDirection(BWGraphSource::DIRECTION_UP | BWGraphSource::DIRECTION_DOWN);
|
||||
|
||||
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)));
|
||||
ui.frmGraph->setShowEntry(0,b);
|
||||
saveSettings();
|
||||
}
|
||||
void BandwidthGraph::toggleReceiveRate(bool b)
|
||||
{
|
||||
ui.frmGraph->setShowEntry(1,b);
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
/** Loads the saved Bandwidth Graph settings. */
|
||||
@ -110,60 +157,29 @@ 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);
|
||||
ui.chkSendRate->setChecked(filter & BWGRAPH_LINE_SEND);
|
||||
|
||||
/* 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)
|
||||
ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN);
|
||||
else
|
||||
ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN);
|
||||
|
||||
/* 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)
|
||||
ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
|
||||
else
|
||||
if(graphColor>0)
|
||||
{
|
||||
ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
|
||||
ui.btnGraphColor->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_GRAPH_DARK));
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btnGraphColor->setIcon(FilesDefs::getIconFromQtResourcePath(IMG_GRAPH_LIGHT));
|
||||
ui.frmGraph->resetFlags(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) ;
|
||||
whileBlocking(ui.chkSendRate )->setChecked(bool(defaultdirection & BWGraphSource::DIRECTION_UP ));
|
||||
whileBlocking(ui.chkReceiveRate)->setChecked(bool(defaultdirection & BWGraphSource::DIRECTION_DOWN));
|
||||
|
||||
/* Default Settings for the Graph */
|
||||
ui.frmGraph->setDirection(BWGraphSource::DIRECTION_UP | BWGraphSource::DIRECTION_DOWN);
|
||||
|
||||
ui.frmGraph->setSelector(BWGraphSource::SELECTOR_TYPE_FRIEND,BWGraphSource::GRAPH_TYPE_SUM) ;
|
||||
ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_LOG_SCALE_Y) ;
|
||||
|
||||
@ -172,62 +188,46 @@ 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();
|
||||
}
|
||||
|
||||
/** Saves the Bandwidth Graph settings and adjusts the graph if necessary. */
|
||||
void BandwidthGraph::saveChanges()
|
||||
BandwidthGraph::~BandwidthGraph()
|
||||
{
|
||||
saveSettings();
|
||||
}
|
||||
/** Saves the Bandwidth Graph settings and adjusts the graph if necessary. */
|
||||
void BandwidthGraph::saveSettings()
|
||||
{
|
||||
/* Hide the settings frame and reset toggle button */
|
||||
showSettingsFrame(false);
|
||||
|
||||
/* 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_GRAPHCOLOR, ui.btnGraphColor->isChecked());
|
||||
|
||||
/* Save the Always On Top setting */
|
||||
saveSetting(SETTING_ALWAYS_ON_TOP, ui.chkAlwaysOnTop->isChecked());
|
||||
if (ui.chkAlwaysOnTop->isChecked()) {
|
||||
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
|
||||
} else {
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint);
|
||||
}
|
||||
setOpacity(ui.sldrOpacity->value());
|
||||
|
||||
/* Save the line filter values */
|
||||
uint filter = 0;
|
||||
ADD_TO_FILTER(filter, BWGRAPH_LINE_RECV, ui.chkReceiveRate->isChecked());
|
||||
ADD_TO_FILTER(filter, BWGRAPH_LINE_SEND, ui.chkSendRate->isChecked());
|
||||
saveSetting(SETTING_FILTER, filter);
|
||||
|
||||
saveSetting(SETTING_DIRECTION, ui.frmGraph->direction());
|
||||
|
||||
/* Update the graph frame settings */
|
||||
ui.frmGraph->setShowEntry(0,ui.chkReceiveRate->isChecked()) ;
|
||||
ui.frmGraph->setShowEntry(1,ui.chkSendRate->isChecked()) ;
|
||||
// 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.btnGraphColor->isChecked()==0)
|
||||
// ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
|
||||
// else
|
||||
// ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
|
||||
|
||||
if(ui.cmbGraphColor->currentIndex()==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 +255,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);
|
||||
|
@ -45,18 +45,21 @@ public:
|
||||
|
||||
/** Default constructor */
|
||||
BandwidthGraph(QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
||||
virtual ~BandwidthGraph();
|
||||
|
||||
public slots:
|
||||
/** Overloaded QWidget.show */
|
||||
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 */
|
||||
void setOpacity(int value);
|
||||
/** Called when the user saves settings */
|
||||
void saveChanges();
|
||||
/** Called when the user cancels changes settings */
|
||||
void cancelChanges();
|
||||
/** Called when the reset button is pressed */
|
||||
@ -67,6 +70,7 @@ private:
|
||||
void createActions();
|
||||
/** Loads the saved Bandwidth Graph settings */
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::BandwidthGraph ui;
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>418</width>
|
||||
<height>305</height>
|
||||
<width>620</width>
|
||||
<height>432</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -18,8 +18,27 @@
|
||||
<normaloff>:/images/logo/logo_16.png</normaloff>:/images/logo/logo_16.png</iconset>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="BWGraph" name="frmGraph" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="_8">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
@ -36,6 +55,70 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnGraphColor">
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="chkSendRate">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Up</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="chkReceiveRate">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Down</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnReset">
|
||||
<property name="toolTip">
|
||||
<string>Clears the graph</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnToggleSettings">
|
||||
<property name="text">
|
||||
@ -60,15 +143,15 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnReset">
|
||||
<widget class="QLabel" name="displayTime_LB">
|
||||
<property name="text">
|
||||
<string>Reset</string>
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item>
|
||||
<widget class="QFrame" name="frmSettings">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
@ -97,146 +180,7 @@
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<layout class="QVBoxLayout" name="_2">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkReceiveRate">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Receive Rate</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkSendRate">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Send Rate</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkAlwaysOnTop">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Always on Top</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</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>
|
||||
<item row="0" column="1" rowspan="2" colspan="2">
|
||||
<widget class="QWidget" name="">
|
||||
<layout class="QVBoxLayout" name="_3">
|
||||
<property name="spacing">
|
||||
<number>1</number>
|
||||
@ -270,76 +214,6 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cmbGraphStyle">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/graph-line.png</normaloff>:/images/graph-line.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/graph-area.png</normaloff>:/images/graph-area.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cmbGraphColor">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Default</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Dark</string>
|
||||
</property>
|
||||
</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>
|
||||
@ -491,6 +365,16 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkAlwaysOnTop">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Always on Top</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
@ -510,26 +394,11 @@
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="BWGraph" name="frmGraph" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
Loading…
Reference in New Issue
Block a user