awesome-widgets/sources/awesomewidgets/graphicalitemhelper.h
arcan1s a3e7a84b92 drop another part of pornography in gi
more intuinitve configuration interface in graphicalitem. Improve code
for the future references (in case if new color type will be added).
Change X-AW-*Color values to ones with prefixes (added autoconversion
from old-version api)
2016-04-12 14:22:19 +03:00

61 lines
2.4 KiB
C++

/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets 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. *
* *
* awesome-widgets 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 awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef GRAPHICALITEMHELPER_H
#define GRAPHICALITEMHELPER_H
#include <QColor>
#include <QObject>
#include <QPen>
class QGraphicsScene;
class GraphicalItemHelper : public QObject
{
public:
explicit GraphicalItemHelper(QObject *parent = nullptr,
QGraphicsScene *scene = nullptr);
virtual ~GraphicalItemHelper();
// parameters
void setParameters(const QString active, const QString inactive,
const int width, const int height, const int count);
// paint methods
void paintCircle(const float &percent);
void paintGraph(const float &value);
void paintHorizontal(const float &percent);
void paintVertical(const float &percent);
// additional conversion methods
float getPercents(const float &value, const float &min, const float &max);
bool isColor(const QString &input);
QColor stringToColor(const QString &color);
private:
void storeValue(const float &value);
QGraphicsScene *m_scene = nullptr;
int m_count = 100;
QPen m_activePen;
QPen m_inactivePen;
int m_width = 100;
int m_height = 100;
// list of values which will be used to store data for graph type only
QList<float> m_values;
};
#endif /* GRAPHICALITEMHELPER_H */