1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

Start of System Health plugin. Only displays the mainboard components for now, does nothing more. Waiting for more info on system alarms before continuing. This gadget can in theory display alarms from any subsystem given the right SVG source file.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@593 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2010-05-05 16:09:37 +00:00 committed by edouard
parent db5c938d11
commit bb21f6c6b9
15 changed files with 954 additions and 0 deletions

View File

@ -0,0 +1,10 @@
<plugin name="SystemHealthGadget" version="1.0.0" compatVersion="1.0.0">
<vendor>The OpenPilot Project</vendor>
<copyright>(C)Edouard Lafargue</copyright>
<license>The GNU Public License (GPL) Version 3</license>
<description>Plugin displaying system health for various components</description>
<url>http://www.openpilot.org</url>
<dependencyList>
<dependency name="Core" version="1.0.0"/>
</dependencyList>
</plugin>

View File

@ -0,0 +1,20 @@
TEMPLATE = lib
TARGET = SystemHealthGadget
QT += svg
include(../../openpilotgcsplugin.pri)
include(../../plugins/coreplugin/coreplugin.pri)
include(../../libs/qwt/qwt.pri)
HEADERS += systemhealthplugin.h
HEADERS += systemhealthgadget.h
HEADERS += systemhealthgadgetwidget.h
HEADERS += systemhealthgadgetfactory.h
HEADERS += systemhealthgadgetconfiguration.h
HEADERS += systemhealthgadgetoptionspage.h
SOURCES += systemhealthplugin.cpp
SOURCES += systemhealthgadget.cpp
SOURCES += systemhealthgadgetfactory.cpp
SOURCES += systemhealthgadgetwidget.cpp
SOURCES += systemhealthgadgetconfiguration.cpp
SOURCES += systemhealthgadgetoptionspage.cpp
OTHER_FILES += SystemHealthGadget.pluginspec
FORMS += systemhealthgadgetoptionspage.ui

View File

@ -0,0 +1,52 @@
/**
******************************************************************************
*
* @file systemhealthgadget.cpp
* @author Edouard Lafargue Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup systemhealth
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "systemhealthgadget.h"
#include "systemhealthgadgetwidget.h"
#include "systemhealthgadgetconfiguration.h"
SystemHealthGadget::SystemHealthGadget(QString classId, SystemHealthGadgetWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent),
m_widget(widget)
{
}
SystemHealthGadget::~SystemHealthGadget()
{
}
/*
This is called when a configuration is loaded, and updates the plugin's settings.
Careful: the plugin is already drawn before the loadConfiguration method is called the
first time, so you have to be careful not to assume all the plugin values are initialized
the first time you use them
*/
void SystemHealthGadget::loadConfiguration(IUAVGadgetConfiguration* config)
{
SystemHealthGadgetConfiguration *m = qobject_cast<SystemHealthGadgetConfiguration*>(config);
m_widget->setSystemFile(m->getSystemFile()); // Triggers widget repaint
}

View File

@ -0,0 +1,56 @@
/**
******************************************************************************
*
* @file systemhealthgadget.h
* @author Edouard Lafargue Copyright (C) 2010.
* @brief System health gadget to display system alarms
* @see The GNU Public License (GPL) Version 3
* @defgroup systemhealth
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef SYSTEMHEALTHGADGET_H_
#define SYSTEMHEALTHGADGET_H_
#include <coreplugin/iuavgadget.h>
#include "systemhealthgadgetwidget.h"
class IUAVGadget;
class QWidget;
class QString;
class SystemHealthGadgetWidget;
using namespace Core;
class SystemHealthGadget : public Core::IUAVGadget
{
Q_OBJECT
public:
SystemHealthGadget(QString classId, SystemHealthGadgetWidget *widget, QWidget *parent = 0);
~SystemHealthGadget();
QWidget *widget() { return m_widget; }
void loadConfiguration(IUAVGadgetConfiguration* config);
private:
SystemHealthGadgetWidget *m_widget;
};
#endif // SYSTEMHEALTHGADGET_H_

View File

@ -0,0 +1,66 @@
/**
******************************************************************************
*
* @file systemhealthgadgetconfiguration.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief System Health Plugin Gadget configuration
* @see The GNU Public License (GPL) Version 3
* @defgroup systemhealth
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "systemhealthgadgetconfiguration.h"
#include <QtCore/QDataStream>
/**
* Loads a saved configuration or defaults if non exist.
*
*/
SystemHealthGadgetConfiguration::SystemHealthGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent) :
IUAVGadgetConfiguration(classId, parent),
systemFile("Unknown")
{
//if a saved configuration exists load it
if (state.count() > 0) {
QDataStream stream(state);
stream >> systemFile;
}
}
/**
* Clones a configuration.
*
*/
IUAVGadgetConfiguration *SystemHealthGadgetConfiguration::clone()
{
SystemHealthGadgetConfiguration *m = new SystemHealthGadgetConfiguration(this->classId());
m->systemFile=systemFile;
return m;
}
/**
* Saves a configuration.
*
*/
QByteArray SystemHealthGadgetConfiguration::saveState() const
{
QByteArray bytes;
QDataStream stream(&bytes, QIODevice::WriteOnly);
stream << systemFile;
return bytes;
}

View File

@ -0,0 +1,59 @@
/**
******************************************************************************
*
* @file systemhealthgadgetconfiguration.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief System Health Plugin Gadget configuration
* @see The GNU Public License (GPL) Version 3
* @defgroup systemhealth
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef SYSTEMHEALTHGADGETCONFIGURATION_H
#define SYSTEMHEALTHGADGETCONFIGURATION_H
#include <coreplugin/iuavgadgetconfiguration.h>
using namespace Core;
/* This is a generic system health gadget displaying
system alarms for one or more components.
*/
class SystemHealthGadgetConfiguration : public IUAVGadgetConfiguration
{
Q_OBJECT
public:
explicit SystemHealthGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0);
//set system health configuration functions
void setSystemFile(QString filename){systemFile=filename;}
//get dial configuration functions
QString getSystemFile() {return systemFile;}
QByteArray saveState() const;
IUAVGadgetConfiguration *clone();
private:
// systemFile contains the source SVG:
QString systemFile;
};
#endif // SYSTEMHEALTHGADGETCONFIGURATION_H

View File

@ -0,0 +1,60 @@
/**
******************************************************************************
*
* @file systemhealthgadgetfactory.cpp
* @author Edouard Lafargue Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup systemhealth
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "systemhealthgadgetfactory.h"
#include "systemhealthgadgetwidget.h"
#include "systemhealthgadget.h"
#include "systemhealthgadgetconfiguration.h"
#include "systemhealthgadgetoptionspage.h"
#include <coreplugin/iuavgadget.h>
SystemHealthGadgetFactory::SystemHealthGadgetFactory(QObject *parent) :
IUAVGadgetFactory(QString("SystemHealthGadget"),
tr("System Health Gadget"),
parent)
{
}
SystemHealthGadgetFactory::~SystemHealthGadgetFactory()
{
}
Core::IUAVGadget* SystemHealthGadgetFactory::createGadget(QWidget *parent)
{
SystemHealthGadgetWidget* gadgetWidget = new SystemHealthGadgetWidget(parent);
return new SystemHealthGadget(QString("SystemHealthGadget"), gadgetWidget, parent);
}
IUAVGadgetConfiguration *SystemHealthGadgetFactory::createConfiguration(const QByteArray &state)
{
return new SystemHealthGadgetConfiguration(QString("SystemHealthGadget"), state);
}
IOptionsPage *SystemHealthGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
{
return new SystemHealthGadgetOptionsPage(qobject_cast<SystemHealthGadgetConfiguration*>(config));
}

View File

@ -0,0 +1,52 @@
/**
******************************************************************************
*
* @file systemhealthgadgetfactory.h
* @author Edouard Lafargue Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup systemhealth
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef SYSTEMHEALTHGADGETFACTORY_H_
#define SYSTEMHEALTHGADGETFACTORY_H_
#include <coreplugin/iuavgadgetfactory.h>
namespace Core {
class IUAVGadget;
class IUAVGadgetFactory;
}
using namespace Core;
class SystemHealthGadgetFactory : public IUAVGadgetFactory
{
Q_OBJECT
public:
SystemHealthGadgetFactory(QObject *parent = 0);
~SystemHealthGadgetFactory();
Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
};
#endif // SYSTEMHEALTHGADGETFACTORY_H_

View File

@ -0,0 +1,93 @@
/**
******************************************************************************
*
* @file systemhealthgadgetoptionspage.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief System Health Plugin Gadget options page
* @see The GNU Public License (GPL) Version 3
* @defgroup systemhealth
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "systemhealthgadgetoptionspage.h"
#include "systemhealthgadgetconfiguration.h"
#include "ui_systemhealthgadgetoptionspage.h"
#include <QFileDialog>
#include <QtAlgorithms>
#include <QStringList>
SystemHealthGadgetOptionsPage::SystemHealthGadgetOptionsPage(SystemHealthGadgetConfiguration *config, QObject *parent) :
IOptionsPage(parent),
m_config(config)
{
}
//creates options page widget (uses the UI file)
QWidget *SystemHealthGadgetOptionsPage::createPage(QWidget *parent)
{
options_page = new Ui::SystemHealthGadgetOptionsPage();
//main widget
QWidget *optionsPageWidget = new QWidget;
//main layout
options_page->setupUi(optionsPageWidget);
// Restore the contents from the settings:
options_page->svgSourceFile->setText(m_config->getSystemFile());
connect(options_page->loadFile, SIGNAL(clicked()), this, SLOT(on_loadFile_clicked()));
return optionsPageWidget;
}
/**
* Called when the user presses apply or OK.
*
* Saves the current values
*
*/
void SystemHealthGadgetOptionsPage::apply()
{
m_config->setSystemFile(options_page->svgSourceFile->text());
}
/**
Opens an open file dialog.
*/
void SystemHealthGadgetOptionsPage::on_loadFile_clicked()
{
QFileDialog::Options options;
QString selectedFilter;
QString fileName = QFileDialog::getOpenFileName(qobject_cast<QWidget*>(this),
tr("QFileDialog::getOpenFileName()"),
options_page->svgSourceFile->text(),
tr("All Files (*);;SVG Files (*.svg)"),
&selectedFilter,
options);
if (!fileName.isEmpty()) options_page->svgSourceFile->setText(fileName);
}
void SystemHealthGadgetOptionsPage::finish()
{
}

View File

@ -0,0 +1,66 @@
/**
******************************************************************************
*
* @file systemhealthgadgetoptionspage.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief System Health Plugin Gadget options page
* @see The GNU Public License (GPL) Version 3
* @defgroup systemhealth
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef SYSTEMHEALTHGADGETOPTIONSPAGE_H
#define SYSTEMHEALTHGADGETOPTIONSPAGE_H
#include "coreplugin/dialogs/ioptionspage.h"
#include "QString"
#include <QStringList>
#include <QDebug>
namespace Core {
class IUAVGadgetConfiguration;
}
class SystemHealthGadgetConfiguration;
namespace Ui {
class SystemHealthGadgetOptionsPage;
}
using namespace Core;
class SystemHealthGadgetOptionsPage : public IOptionsPage
{
Q_OBJECT
public:
explicit SystemHealthGadgetOptionsPage(SystemHealthGadgetConfiguration *config, QObject *parent = 0);
QWidget *createPage(QWidget *parent);
void apply();
void finish();
private:
Ui::SystemHealthGadgetOptionsPage *options_page;
SystemHealthGadgetConfiguration *m_config;
private slots:
void on_loadFile_clicked();
};
#endif // SYSTEMHEALTHGADGETOPTIONSPAGE_H

View File

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SystemHealthGadgetOptionsPage</class>
<widget class="QWidget" name="SystemHealthGadgetOptionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>486</width>
<height>300</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>-1</x>
<y>-1</y>
<width>481</width>
<height>339</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0">
<property name="spacing">
<number>10</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Subsystem SVG:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="svgSourceFile"/>
</item>
<item>
<widget class="QPushButton" name="loadFile">
<property name="text">
<string>Load file...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,123 @@
/**
******************************************************************************
*
* @file systemhealthgadgetwidget.cpp
* @author Edouard Lafargue Copyright (C) 2010.
* @brief System Health widget, does the actual drawing
* @see The GNU Public License (GPL) Version 3
* @defgroup systemhealth
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "systemhealthgadgetwidget.h"
#include <iostream>
#include <QtGui/QFileDialog>
#include <QDebug>
SystemHealthGadgetWidget::SystemHealthGadgetWidget(QWidget *parent) : QGraphicsView(parent)
{
setMinimumSize(128,128);
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
setScene(new QGraphicsScene(this));
m_renderer = new QSvgRenderer();
background = new QGraphicsSvgItem();
foreground = new QGraphicsSvgItem();
paint();
// Test code for timer to move the index
testValue=0;
connect(&m_testTimer, SIGNAL(timeout()), this, SLOT(testRotate()));
m_testTimer.start(1000);
}
SystemHealthGadgetWidget::~SystemHealthGadgetWidget()
{
// Do nothing
}
void SystemHealthGadgetWidget::setSystemFile(QString dfn)
{
if (QFile::exists(dfn))
{
m_renderer->load(dfn);
if(m_renderer->isValid())
{
fgenabled = false;
background->setSharedRenderer(m_renderer);
background->setElementId("background");
if (m_renderer->elementExists("foreground")) {
foreground->setSharedRenderer(m_renderer);
foreground->setElementId("foreground");
fgenabled = true;
}
std::cout<<"Dial file loaded"<<std::endl;
QGraphicsScene *l_scene = scene();
l_scene->setSceneRect(background->boundingRect());
fitInView(background, Qt::KeepAspectRatio );
}
}
else
{ std::cout<<"no file: "<<std::endl; }
}
void SystemHealthGadgetWidget::paint()
{
QGraphicsScene *l_scene = scene();
l_scene->clear();
l_scene->addItem(background);
l_scene->addItem(foreground);
update();
}
void SystemHealthGadgetWidget::paintEvent(QPaintEvent *event)
{
// Skip painting until the dial file is loaded
if (! m_renderer->isValid()) {
std::cout<<"System file not loaded, not rendering"<<std::endl;
return;
}
QGraphicsView::paintEvent(event);
}
// This event enables the dial to be dynamically resized
// whenever the gadget is resized, taking advantage of the vector
// nature of SVG dials.
void SystemHealthGadgetWidget::resizeEvent(QResizeEvent *event)
{
fitInView(background, Qt::KeepAspectRatio );
}
// Test function for timer to rotate needles
void SystemHealthGadgetWidget::test()
{
testValue=0;
}

View File

@ -0,0 +1,76 @@
/**
******************************************************************************
*
* @file systemhealthgadgetwidget.h
* @author Edouard Lafargue Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup systemhealth
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef SYSTEMHEALTHGADGETWIDGET_H_
#define SYSTEMHEALTHGADGETWIDGET_H_
#include "systemhealthgadgetconfiguration.h"
#include <QGraphicsView>
#include <QtSvg/QSvgRenderer>
#include <QtSvg/QGraphicsSvgItem>
#include <QFile>
#include <QTimer>
class SystemHealthGadgetWidget : public QGraphicsView
{
Q_OBJECT
public:
SystemHealthGadgetWidget(QWidget *parent = 0);
~SystemHealthGadgetWidget();
void setSystemFile(QString dfn);
void setIndicator(QString indicator);
void paint();
protected:
void paintEvent(QPaintEvent *event);
void resizeEvent(QResizeEvent *event);
private:
private slots:
// Test function
void test();
private:
QSvgRenderer *m_renderer;
QGraphicsSvgItem *background;
QGraphicsSvgItem *foreground;
// Simple flag to skip rendering if the
bool fgenabled; // layer does not exist.
// Test variables
double testValue;
QTimer m_testTimer;
// End test variables
};
#endif /* SYSTEMHEALTHGADGETWIDGET_H_ */

View File

@ -0,0 +1,65 @@
/**
******************************************************************************
*
* @file systemhealthplugin.h
* @author Edouard Lafargue Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup systemhealth
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "systemhealthplugin.h"
#include "systemhealthgadgetfactory.h"
#include <QDebug>
#include <QtPlugin>
#include <QStringList>
#include <extensionsystem/pluginmanager.h>
SystemHealthPlugin::SystemHealthPlugin()
{
// Do nothing
}
SystemHealthPlugin::~SystemHealthPlugin()
{
// Do nothing
}
bool SystemHealthPlugin::initialize(const QStringList& args, QString *errMsg)
{
Q_UNUSED(args);
Q_UNUSED(errMsg);
mf = new SystemHealthGadgetFactory(this);
addAutoReleasedObject(mf);
return true;
}
void SystemHealthPlugin::extensionsInitialized()
{
// Do nothing
}
void SystemHealthPlugin::shutdown()
{
// Do nothing
}
Q_EXPORT_PLUGIN(SystemHealthPlugin)

View File

@ -0,0 +1,47 @@
/**
******************************************************************************
*
* @file systemhealthplugin.h
* @author Edouard Lafargue Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup systemhealth
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef SYSTEMHEALTHPLUGIN_H_
#define SYSTEMHEALTHPLUGIN_H_
#include <extensionsystem/iplugin.h>
class SystemHealthGadgetFactory;
class SystemHealthPlugin : public ExtensionSystem::IPlugin
{
public:
SystemHealthPlugin();
~SystemHealthPlugin();
void extensionsInitialized();
bool initialize(const QStringList & arguments, QString * errorString);
void shutdown();
private:
SystemHealthGadgetFactory *mf;
};
#endif /* SYSTEMHEALTHPLUGIN_H_ */