Kstars

fovwidget.cpp
1 /*
2  SPDX-FileCopyrightText: 2007 Jason Harris <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "fovwidget.h"
8 
9 #include "fov.h"
10 #include "dialogs/fovdialog.h"
11 
12 #include <QPainter>
13 #include <QPaintEvent>
14 
15 FOVWidget::FOVWidget(QWidget *parent) : QFrame(parent), m_FOV(nullptr)
16 {
17 }
18 
19 void FOVWidget::setFOV(FOV *f)
20 {
21  m_FOV = f;
22 }
23 
24 void FOVWidget::paintEvent(QPaintEvent *)
25 {
26  QPainter p;
27  p.begin(this);
29  p.fillRect(contentsRect(), QColor("black"));
30 
31  if (m_FOV && m_FOV->sizeX() > 0 && m_FOV->sizeY() > 0)
32  {
33  m_FOV->draw(p, 0.6 * contentsRect().width(), 0.6 * contentsRect().height());
34  QFont smallFont = p.font();
35  smallFont.setPointSize(p.font().pointSize() - 2);
36  p.setFont(smallFont);
37  // TODO: Check if decimal points in this are localized (eg: It should read 1,5 x 1,5 in German rather than 1.5 x 1.5)
39  i18nc("angular size in arcminutes", "%1 x %2 arcmin", QString::number(m_FOV->sizeX(), 'f', 1),
40  QString::number(m_FOV->sizeY(), 'f', 1)));
41  }
42 
43  p.end();
44 }
Definition: fov.h:27
AlignHCenter
QString number(int n, int base)
void setPointSize(int pointSize)
int pointSize() const const
void drawText(const QPointF &position, const QString &text)
void fillRect(const QRectF &rectangle, const QBrush &brush)
bool begin(QPaintDevice *device)
bool end()
const QFont & font() const const
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void setRenderHint(QPainter::RenderHint hint, bool on)
void setFont(const QFont &font)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:00:54 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.