mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: add height() member function to DiveTextItem
To layout the profile we need to determine the height of texts. Add versions for a DiveTextItem and a static function, which is passed the scale and dpr. The latter is used to setup items, where we do not necessarily have a text at creation time (e.g. the tankbar). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
7dd9b65df0
commit
8343691a38
2 changed files with 14 additions and 0 deletions
|
@ -75,6 +75,18 @@ QFont DiveTextItem::getFont(double dpr, double scale)
|
|||
return fnt;
|
||||
}
|
||||
|
||||
double DiveTextItem::fontHeight(double dpr, double scale)
|
||||
{
|
||||
QFont fnt = getFont(dpr, scale);
|
||||
QFontMetrics fm(fnt);
|
||||
return (double)fm.height();
|
||||
}
|
||||
|
||||
double DiveTextItem::height() const
|
||||
{
|
||||
return fontHeight(dpr, scale);
|
||||
}
|
||||
|
||||
void DiveTextItem::updateText()
|
||||
{
|
||||
if (internalText.isEmpty())
|
||||
|
|
|
@ -22,6 +22,8 @@ public:
|
|||
const QString &text();
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
static QFont getFont(double dpr, double scale);
|
||||
static double fontHeight(double dpr, double scale);
|
||||
double height() const;
|
||||
|
||||
private:
|
||||
void updateText();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue