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:
Ivailo Monev 2024-05-24 16:43:28 +03:00
parent 651cf894e7
commit 6dba30b201
5 changed files with 8 additions and 95 deletions

View file

@ -778,12 +778,6 @@ bool FancyPlotter::restoreSettings( QDomElement &element )
mPlotter->setShowHorizontalLines( element.attribute( "hLines", "1" ).toUInt() );
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) {
mPlotter->setShowAxis( element.attribute( "labels", "1" ).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( "svgBackground", mPlotter->svgBackground() );
element.setAttribute( "stacked", mPlotter->stackGraph() );
element.setAttribute( "version", 1 );

View file

@ -2,14 +2,14 @@
<!DOCTYPE KSysGuardWorkSheet>
<WorkSheet title="System Load" interval="1.0" locked="1" rows="3" columns="1" >
<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" />
</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="Swap" sensorName="mem/swap/used" sensorType="integer" hostName="localhost" color="0xff00c000" />
</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="Sending" regexpSensorName="network/interfaces/(?!lo|bridge|usbus|bond).*/transmitter/data" color="0x844798" />
</display>

View file

@ -37,11 +37,6 @@
#include <cmath> //For floor, ceil, log10 etc for calculating ranges
#include <limits>
#ifdef SVG_SUPPORT
#include <plasma/svg.h>
#endif
#define VERTICAL_LINE_OFFSET 1
//Never store less 1000 samples if not visible. This is kinda arbituary
#define NUM_SAMPLES_WHEN_INVISIBLE ((uint)1000)
@ -311,27 +306,6 @@ bool KSignalPlotter::showAxis() const
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)
{
if(d->mAxisTextWidth == axisTextWidth) return;
@ -606,15 +580,6 @@ void GraphWidget::paintEvent( QPaintEvent*)
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() )
redrawScrollableImage();
@ -642,11 +607,6 @@ void KSignalPlotterPrivate::drawWidget(QPainter *p, const QRect &boundingBox)
void KSignalPlotterPrivate::drawBackground(QPainter *p, const QRect &boundingBox) const
{
p->setRenderHint(QPainter::Antialiasing, false);
#ifdef SVG_SUPPORT
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 )
@ -662,6 +622,7 @@ bool KSignalPlotter::thinFrame() const
{
return d->mShowThinFrame;
}
void KSignalPlotter::setThinFrame(bool thinFrame)
{
if(thinFrame == d->mShowThinFrame)
@ -671,21 +632,6 @@ void KSignalPlotter::setThinFrame(bool thinFrame)
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()
{
//Align width of bounding box to the size of the horizontal scale

View file

@ -44,7 +44,6 @@ Q_DECLARE_METATYPE(KLocalizedString)
* Features include:
* \li Points are joined by a bezier curve.
* \li Lines are anti-aliased
* \li Background can be set as a specified SVG
* \li The lines can be reordered
* \li Uses as little memory and CPU as possible
* \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(uint verticalLinesDistance READ verticalLinesDistance WRITE setVerticalLinesDistance)
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(int maxAxisTextWidth READ maxAxisTextWidth WRITE setMaxAxisTextWidth)
Q_PROPERTY(bool smoothGraph READ smoothGraph WRITE setSmoothGraph)
@ -353,14 +351,6 @@ class KDE_EXPORT KSignalPlotter : public QWidget
* \sa setShowAxis(), axisFont(), axisFontColor(), maxAxisTextWidth() */
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.
*
* \return last value, or 0 if not known. */

View file

@ -24,20 +24,9 @@
//#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 <QtGui/qevent.h>
#ifdef SVG_SUPPORT
namespace Plasma
{
class SVG;
}
#endif
class GraphWidget;
class KSignalPlotter;
@ -65,17 +54,12 @@ public:
/** Return the given value as a string, with the given precision */
QString scaledValueAsString( qreal value, int precision) const;
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
QImage mScrollableImage; ///The scrollable image for the widget. Contains the SVG lines
QImage mScrollableImage; ///The scrollable image for the widget. Contains the lines
#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
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