mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
libs: drop non-operation background feature of KSignalPlotter
SVG_SUPPORT was never defined, must've been some experimental feature Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
651cf894e7
commit
6dba30b201
5 changed files with 8 additions and 95 deletions
|
@ -778,12 +778,6 @@ bool FancyPlotter::restoreSettings( QDomElement &element )
|
||||||
mPlotter->setShowHorizontalLines( element.attribute( "hLines", "1" ).toUInt() );
|
mPlotter->setShowHorizontalLines( element.attribute( "hLines", "1" ).toUInt() );
|
||||||
mPlotter->setStackGraph( element.attribute("stacked", "0").toInt());
|
mPlotter->setStackGraph( element.attribute("stacked", "0").toInt());
|
||||||
|
|
||||||
QString filename = element.attribute( "svgBackground");
|
|
||||||
if (!filename.isEmpty() && filename[0] == '/') {
|
|
||||||
KStandardDirs* kstd = KGlobal::dirs();
|
|
||||||
filename = kstd->findResource( "data", "ksysguard/" + filename);
|
|
||||||
}
|
|
||||||
mPlotter->setSvgBackground( filename );
|
|
||||||
if(version >= 1) {
|
if(version >= 1) {
|
||||||
mPlotter->setShowAxis( element.attribute( "labels", "1" ).toUInt() );
|
mPlotter->setShowAxis( element.attribute( "labels", "1" ).toUInt() );
|
||||||
uint fontsize = element.attribute( "fontSize", "0").toUInt();
|
uint fontsize = element.attribute( "fontSize", "0").toUInt();
|
||||||
|
@ -850,7 +844,6 @@ bool FancyPlotter::saveSettings( QDomDocument &doc, QDomElement &element)
|
||||||
|
|
||||||
element.setAttribute( "hLines", mPlotter->showHorizontalLines() );
|
element.setAttribute( "hLines", mPlotter->showHorizontalLines() );
|
||||||
|
|
||||||
element.setAttribute( "svgBackground", mPlotter->svgBackground() );
|
|
||||||
element.setAttribute( "stacked", mPlotter->stackGraph() );
|
element.setAttribute( "stacked", mPlotter->stackGraph() );
|
||||||
|
|
||||||
element.setAttribute( "version", 1 );
|
element.setAttribute( "version", 1 );
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
<!DOCTYPE KSysGuardWorkSheet>
|
<!DOCTYPE KSysGuardWorkSheet>
|
||||||
<WorkSheet title="System Load" interval="1.0" locked="1" rows="3" columns="1" >
|
<WorkSheet title="System Load" interval="1.0" locked="1" rows="3" columns="1" >
|
||||||
<host port="-1" command="ksysguardd" shell="" name="localhost" />
|
<host port="-1" command="ksysguardd" shell="" name="localhost" />
|
||||||
<display title="CPU History" svgBackground="widgets/plot-background" autoRange="0" class="FancyPlotter" column="0" row="0" version="1">
|
<display title="CPU History" autoRange="0" class="FancyPlotter" column="0" row="0" version="1">
|
||||||
<beam sensorType="float" hostName="localhost" regexpSensorName="cpu/cpu.*/TotalLoad" color="0xffff8000,0xffe20800" />
|
<beam sensorType="float" hostName="localhost" regexpSensorName="cpu/cpu.*/TotalLoad" color="0xffff8000,0xffe20800" />
|
||||||
</display>
|
</display>
|
||||||
<display title="Memory and Swap History" svgBackground="widgets/plot-background" autoRange="0" class="FancyPlotter" column="0" row="1" version="1" >
|
<display title="Memory and Swap History" autoRange="0" class="FancyPlotter" column="0" row="1" version="1" >
|
||||||
<beam summationName="Memory" sensorName="mem/physical/application" sensorType="integer" hostName="localhost" color="0xffc000c0" />
|
<beam summationName="Memory" sensorName="mem/physical/application" sensorType="integer" hostName="localhost" color="0xffc000c0" />
|
||||||
<beam summationName="Swap" sensorName="mem/swap/used" sensorType="integer" hostName="localhost" color="0xff00c000" />
|
<beam summationName="Swap" sensorName="mem/swap/used" sensorType="integer" hostName="localhost" color="0xff00c000" />
|
||||||
</display>
|
</display>
|
||||||
<display title="Network History" svgBackground="widgets/plot-background" autoRange="1" class="FancyPlotter" column="0" row="2" version="1" min="0" max="20" manualRange="1">
|
<display title="Network History" autoRange="1" class="FancyPlotter" column="0" row="2" version="1" min="0" max="20" manualRange="1">
|
||||||
<beam sensorType="float" hostName="localhost" summationName="Receiving" regexpSensorName="network/interfaces/(?!lo|bridge|usbus|bond).*/receiver/data" color="0xB3A52D" />
|
<beam sensorType="float" hostName="localhost" summationName="Receiving" regexpSensorName="network/interfaces/(?!lo|bridge|usbus|bond).*/receiver/data" color="0xB3A52D" />
|
||||||
<beam sensorType="float" hostName="localhost" summationName="Sending" regexpSensorName="network/interfaces/(?!lo|bridge|usbus|bond).*/transmitter/data" color="0x844798" />
|
<beam sensorType="float" hostName="localhost" summationName="Sending" regexpSensorName="network/interfaces/(?!lo|bridge|usbus|bond).*/transmitter/data" color="0x844798" />
|
||||||
</display>
|
</display>
|
||||||
|
|
|
@ -37,11 +37,6 @@
|
||||||
#include <cmath> //For floor, ceil, log10 etc for calculating ranges
|
#include <cmath> //For floor, ceil, log10 etc for calculating ranges
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#ifdef SVG_SUPPORT
|
|
||||||
#include <plasma/svg.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#define VERTICAL_LINE_OFFSET 1
|
#define VERTICAL_LINE_OFFSET 1
|
||||||
//Never store less 1000 samples if not visible. This is kinda arbituary
|
//Never store less 1000 samples if not visible. This is kinda arbituary
|
||||||
#define NUM_SAMPLES_WHEN_INVISIBLE ((uint)1000)
|
#define NUM_SAMPLES_WHEN_INVISIBLE ((uint)1000)
|
||||||
|
@ -311,27 +306,6 @@ bool KSignalPlotter::showAxis() const
|
||||||
return d->mShowAxis;
|
return d->mShowAxis;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString KSignalPlotter::svgBackground() const {
|
|
||||||
return d->mSvgFilename;
|
|
||||||
}
|
|
||||||
void KSignalPlotter::setSvgBackground( const QString &filename )
|
|
||||||
{
|
|
||||||
if(d->mSvgFilename == filename) return;
|
|
||||||
d->mSvgFilename = filename;
|
|
||||||
#ifdef SVG_SUPPORT
|
|
||||||
if(filename.isEmpty()) {
|
|
||||||
delete d->mSvgRenderer;
|
|
||||||
d->mSvgRenderer = NULL;
|
|
||||||
} else {
|
|
||||||
if(!d->mSvgRenderer)
|
|
||||||
d->mSvgRenderer = new Plasma::Svg(this);
|
|
||||||
d->mSvgRenderer->setImagePath(d->mSvgFilename);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
d->mBackgroundImage = QPixmap();
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void KSignalPlotter::setMaxAxisTextWidth(int axisTextWidth)
|
void KSignalPlotter::setMaxAxisTextWidth(int axisTextWidth)
|
||||||
{
|
{
|
||||||
if(d->mAxisTextWidth == axisTextWidth) return;
|
if(d->mAxisTextWidth == axisTextWidth) return;
|
||||||
|
@ -606,15 +580,6 @@ void GraphWidget::paintEvent( QPaintEvent*)
|
||||||
|
|
||||||
void KSignalPlotterPrivate::drawWidget(QPainter *p, const QRect &boundingBox)
|
void KSignalPlotterPrivate::drawWidget(QPainter *p, const QRect &boundingBox)
|
||||||
{
|
{
|
||||||
#ifdef SVG_SUPPORT
|
|
||||||
if(!mSvgFilename.isEmpty()) {
|
|
||||||
if(mBackgroundImage.isNull() || mBackgroundImage.height() != boundingBox.height() || mBackgroundImage.width() != boundingBox.width()) { //recreate on resize etc
|
|
||||||
updateSvgBackground(boundingBox);
|
|
||||||
}
|
|
||||||
p->drawPixmap(boundingBox, mBackgroundImage);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( mScrollableImage.isNull() )
|
if( mScrollableImage.isNull() )
|
||||||
redrawScrollableImage();
|
redrawScrollableImage();
|
||||||
|
|
||||||
|
@ -642,12 +607,7 @@ void KSignalPlotterPrivate::drawWidget(QPainter *p, const QRect &boundingBox)
|
||||||
void KSignalPlotterPrivate::drawBackground(QPainter *p, const QRect &boundingBox) const
|
void KSignalPlotterPrivate::drawBackground(QPainter *p, const QRect &boundingBox) const
|
||||||
{
|
{
|
||||||
p->setRenderHint(QPainter::Antialiasing, false);
|
p->setRenderHint(QPainter::Antialiasing, false);
|
||||||
#ifdef SVG_SUPPORT
|
p->fillRect(boundingBox, q->palette().brush(QPalette::Base));
|
||||||
if(!mSvgFilename.isEmpty()) //our background is an svg, so don't paint over the top of it
|
|
||||||
p->fillRect(boundingBox, Qt::transparent);
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
p->fillRect(boundingBox, q->palette().brush(QPalette::Base));
|
|
||||||
|
|
||||||
if ( mShowHorizontalLines )
|
if ( mShowHorizontalLines )
|
||||||
drawHorizontalLines(p, boundingBox.adjusted(0,0,1,0));
|
drawHorizontalLines(p, boundingBox.adjusted(0,0,1,0));
|
||||||
|
@ -662,6 +622,7 @@ bool KSignalPlotter::thinFrame() const
|
||||||
{
|
{
|
||||||
return d->mShowThinFrame;
|
return d->mShowThinFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KSignalPlotter::setThinFrame(bool thinFrame)
|
void KSignalPlotter::setThinFrame(bool thinFrame)
|
||||||
{
|
{
|
||||||
if(thinFrame == d->mShowThinFrame)
|
if(thinFrame == d->mShowThinFrame)
|
||||||
|
@ -671,21 +632,6 @@ void KSignalPlotter::setThinFrame(bool thinFrame)
|
||||||
update(); //Trigger a repaint
|
update(); //Trigger a repaint
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SVG_SUPPORT
|
|
||||||
void KSignalPlotterPrivate::updateSvgBackground(const QRect &boundingBox)
|
|
||||||
{
|
|
||||||
Q_ASSERT(!mSvgFilename.isEmpty());
|
|
||||||
Q_ASSERT(boundingBox.isNull());
|
|
||||||
mBackgroundImage = QPixmap(boundingBox.width(), boundingBox.height());
|
|
||||||
Q_ASSERT(!mBackgroundImage.isNull());
|
|
||||||
QPainter pCache(&mBackgroundImage);
|
|
||||||
pCache.fill( q->palette().color(QPalette::Base) );
|
|
||||||
|
|
||||||
svgRenderer->resize(boundingBox.size());
|
|
||||||
svgRenderer->paint(&pCache, 0, 0);
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
void KSignalPlotterPrivate::redrawScrollableImage()
|
void KSignalPlotterPrivate::redrawScrollableImage()
|
||||||
{
|
{
|
||||||
//Align width of bounding box to the size of the horizontal scale
|
//Align width of bounding box to the size of the horizontal scale
|
||||||
|
|
|
@ -44,7 +44,6 @@ Q_DECLARE_METATYPE(KLocalizedString)
|
||||||
* Features include:
|
* Features include:
|
||||||
* \li Points are joined by a bezier curve.
|
* \li Points are joined by a bezier curve.
|
||||||
* \li Lines are anti-aliased
|
* \li Lines are anti-aliased
|
||||||
* \li Background can be set as a specified SVG
|
|
||||||
* \li The lines can be reordered
|
* \li The lines can be reordered
|
||||||
* \li Uses as little memory and CPU as possible
|
* \li Uses as little memory and CPU as possible
|
||||||
* \li Graph can be smoothed using the formula (value * 2 + last_value)/3
|
* \li Graph can be smoothed using the formula (value * 2 + last_value)/3
|
||||||
|
@ -80,7 +79,6 @@ class KDE_EXPORT KSignalPlotter : public QWidget
|
||||||
Q_PROPERTY(bool verticalLinesScroll READ verticalLinesScroll WRITE setVerticalLinesScroll)
|
Q_PROPERTY(bool verticalLinesScroll READ verticalLinesScroll WRITE setVerticalLinesScroll)
|
||||||
Q_PROPERTY(uint verticalLinesDistance READ verticalLinesDistance WRITE setVerticalLinesDistance)
|
Q_PROPERTY(uint verticalLinesDistance READ verticalLinesDistance WRITE setVerticalLinesDistance)
|
||||||
Q_PROPERTY(bool showAxis READ showAxis WRITE setShowAxis)
|
Q_PROPERTY(bool showAxis READ showAxis WRITE setShowAxis)
|
||||||
Q_PROPERTY(QString svgBackground READ svgBackground WRITE setSvgBackground)
|
|
||||||
Q_PROPERTY(bool thinFrame READ thinFrame WRITE setThinFrame)
|
Q_PROPERTY(bool thinFrame READ thinFrame WRITE setThinFrame)
|
||||||
Q_PROPERTY(int maxAxisTextWidth READ maxAxisTextWidth WRITE setMaxAxisTextWidth)
|
Q_PROPERTY(int maxAxisTextWidth READ maxAxisTextWidth WRITE setMaxAxisTextWidth)
|
||||||
Q_PROPERTY(bool smoothGraph READ smoothGraph WRITE setSmoothGraph)
|
Q_PROPERTY(bool smoothGraph READ smoothGraph WRITE setSmoothGraph)
|
||||||
|
@ -353,14 +351,6 @@ class KDE_EXPORT KSignalPlotter : public QWidget
|
||||||
* \sa setShowAxis(), axisFont(), axisFontColor(), maxAxisTextWidth() */
|
* \sa setShowAxis(), axisFont(), axisFontColor(), maxAxisTextWidth() */
|
||||||
bool showAxis() const;
|
bool showAxis() const;
|
||||||
|
|
||||||
/** \brief Set the filename of the SVG background.
|
|
||||||
*
|
|
||||||
* Set to empty (default) to disable again. */
|
|
||||||
void setSvgBackground( const QString &filename );
|
|
||||||
|
|
||||||
/** \brief The filename of the SVG background. */
|
|
||||||
QString svgBackground() const;
|
|
||||||
|
|
||||||
/** \brief Return the last value that we have for the given beam index.
|
/** \brief Return the last value that we have for the given beam index.
|
||||||
*
|
*
|
||||||
* \return last value, or 0 if not known. */
|
* \return last value, or 0 if not known. */
|
||||||
|
|
|
@ -24,20 +24,9 @@
|
||||||
|
|
||||||
//#define USE_QIMAGE
|
//#define USE_QIMAGE
|
||||||
|
|
||||||
// SVG support causes it to crash at the moment :(
|
|
||||||
//#define SVG_SUPPORT
|
|
||||||
// Use a seperate child widget to draw the graph in
|
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QtGui/qevent.h>
|
#include <QtGui/qevent.h>
|
||||||
|
|
||||||
#ifdef SVG_SUPPORT
|
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
class SVG;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class GraphWidget;
|
class GraphWidget;
|
||||||
class KSignalPlotter;
|
class KSignalPlotter;
|
||||||
|
|
||||||
|
@ -65,17 +54,12 @@ public:
|
||||||
/** Return the given value as a string, with the given precision */
|
/** Return the given value as a string, with the given precision */
|
||||||
QString scaledValueAsString( qreal value, int precision) const;
|
QString scaledValueAsString( qreal value, int precision) const;
|
||||||
void addSample( const QList<qreal>& sampleBuf );
|
void addSample( const QList<qreal>& sampleBuf );
|
||||||
#ifdef SVG_SUPPORT
|
|
||||||
void updateSvgBackground(const QRect &boundingBox);
|
|
||||||
Plasma::SVG* mSvgRenderer;
|
|
||||||
#endif
|
|
||||||
QString mSvgFilename;
|
|
||||||
|
|
||||||
QPixmap mBackgroundImage; ///A cache of the background of the widget. Contains the SVG or just white background with lines
|
QPixmap mBackgroundImage; ///A cache of the background of the widget. Contains just white background with lines
|
||||||
#ifdef USE_QIMAGE
|
#ifdef USE_QIMAGE
|
||||||
QImage mScrollableImage; ///The scrollable image for the widget. Contains the SVG lines
|
QImage mScrollableImage; ///The scrollable image for the widget. Contains the lines
|
||||||
#else
|
#else
|
||||||
QPixmap mScrollableImage; ///The scrollable image for the widget. Contains the SVG lines
|
QPixmap mScrollableImage; ///The scrollable image for the widget. Contains the lines
|
||||||
#endif
|
#endif
|
||||||
int mScrollOffset; ///The scrollable image is, well, scrolled in a wrap-around window. mScrollOffset determines where the left hand side of the mScrollableImage should be drawn relative to the right hand side of view. 0 <= mScrollOffset < mScrollableImage.width()
|
int mScrollOffset; ///The scrollable image is, well, scrolled in a wrap-around window. mScrollOffset determines where the left hand side of the mScrollableImage should be drawn relative to the right hand side of view. 0 <= mScrollOffset < mScrollableImage.width()
|
||||||
qreal mMinValue; ///The minimum value (unscaled) currently being displayed
|
qreal mMinValue; ///The minimum value (unscaled) currently being displayed
|
||||||
|
|
Loading…
Add table
Reference in a new issue