mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
Can't for the life of me remember what I updated this time!
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2883 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
333d61192b
commit
70f1e4a3e9
@ -1,3 +1,30 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file widgetbar.cpp
|
||||
* @author Cathy Moss Copyright (C) 2011.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Configuration Plugin
|
||||
* @{
|
||||
* @brief A bar display widget
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 <QtGui>
|
||||
|
||||
@ -10,6 +37,8 @@
|
||||
m_minimum = 1000;
|
||||
m_value = 1500;
|
||||
|
||||
m_orientation = Qt::Vertical;
|
||||
|
||||
setBackgroundRole(QPalette::Base);
|
||||
setAutoFillBackground(true);
|
||||
}
|
||||
@ -46,8 +75,14 @@
|
||||
update();
|
||||
}
|
||||
|
||||
void WidgetBar::paintEvent(QPaintEvent * /* event */)
|
||||
{
|
||||
void WidgetBar::setOrientation(Qt::Orientation orientation)
|
||||
{
|
||||
m_orientation = orientation;
|
||||
update();
|
||||
}
|
||||
|
||||
void WidgetBar::paintEvent(QPaintEvent * /* event */)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing, false);
|
||||
|
||||
@ -56,13 +91,30 @@
|
||||
|
||||
float level = (float)(m_value - m_minimum) / range; // 0 to +1
|
||||
|
||||
int h = (int)((height() - 5) * level + 0.5f);
|
||||
|
||||
QRect rect;
|
||||
rect.setLeft(2);
|
||||
rect.setTop(height() - 3 - h);
|
||||
rect.setWidth(width() - 5);
|
||||
rect.setHeight(h);
|
||||
|
||||
switch (m_orientation)
|
||||
{
|
||||
case Qt::Horizontal:
|
||||
{
|
||||
int length = (int)((height() - 5) * level + 0.5f);
|
||||
rect.setLeft(2);
|
||||
rect.setTop(2);
|
||||
rect.setWidth(length);
|
||||
rect.setHeight(height() - 5);
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::Vertical:
|
||||
{
|
||||
int length = (int)((height() - 5) * level + 0.5f);
|
||||
rect.setLeft(2);
|
||||
rect.setTop(height() - 3 - length);
|
||||
rect.setWidth(width() - 5);
|
||||
rect.setHeight(length);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// background
|
||||
painter.setPen(QColor(160, 160, 160));
|
||||
|
@ -1,17 +1,52 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file widgetbar.h
|
||||
* @author Cathy Moss Copyright (C) 2011.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Configuration Plugin
|
||||
* @{
|
||||
* @brief A bar display widget
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 WIDGETBAR_H
|
||||
#define WIDGETBAR_H
|
||||
#ifndef WIDGETBAR_H
|
||||
#define WIDGETBAR_H
|
||||
|
||||
#include <QBrush>
|
||||
#include <QPen>
|
||||
#include <QPixmap>
|
||||
#include <QWidget>
|
||||
#include <QBrush>
|
||||
#include <QPen>
|
||||
#include <QPixmap>
|
||||
#include <QWidget>
|
||||
|
||||
class WidgetBar : public QWidget
|
||||
{
|
||||
QT_MODULE(Gui)
|
||||
|
||||
class WidgetBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Q_PROPERTY(int maximum READ maximum WRITE setMaximum)
|
||||
Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
|
||||
Q_PROPERTY(int value READ value WRITE setValue)
|
||||
|
||||
Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
|
||||
|
||||
public:
|
||||
WidgetBar(QWidget *parent = 0);
|
||||
|
||||
QSize minimumSizeHint() const;
|
||||
@ -25,13 +60,18 @@
|
||||
int minimum() { return m_minimum; }
|
||||
int value() { return m_value; }
|
||||
|
||||
protected:
|
||||
Qt::Orientation orientation() const { return m_orientation; }
|
||||
void setOrientation(Qt::Orientation orientation);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
private:
|
||||
private:
|
||||
int m_maximum;
|
||||
int m_minimum;
|
||||
int m_value;
|
||||
};
|
||||
|
||||
#endif
|
||||
Qt::Orientation m_orientation;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user