File: statusbar.cpp

package info (click to toggle)
tipp10 3.3.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,984 kB
  • sloc: cpp: 8,343; xml: 70; ansic: 60; makefile: 11
file content (102 lines) | stat: -rw-r--r-- 2,456 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
Copyright (c) 2006-2009, Tom Thielicke IT Solutions

SPDX-License-Identifier: GPL-2.0-only
*/

/****************************************************************
**
** Implementation of the StatusBar class
** File name: statusbar.cpp
**
****************************************************************/

#include <QColor>
#include <QFont>
#include <QPainter>

#include "def/defines.h"
#include "errormessage.h"
#include "statusbar.h"

StatusBar::StatusBar(QWidget* parent)
    : QWidget(parent)
    , txtLeftLeft("")
    , txtLeft("")
    , txtCenter("")
    , txtRight("")
    , txtRightRight("")
{
    // Load background image
    if (!background.load(":/img/statusbg.png")) {
        // Error message
        ErrorMessage* errorMessage = new ErrorMessage(this);
        errorMessage->showMessage(Error::status_pic,
            ErrorMessage::Type::Warning, ErrorMessage::Cancel::Operation);
    }

    setFixedSize(610, 30);

    setAttribute(Qt::WA_NoSystemBackground);
}

void StatusBar::setText(QString leftleft, QString left, QString center,
    QString right, QString rightright)
{
    txtLeftLeft = leftleft;
    txtLeft = left;
    txtCenter = center;
    txtRight = right;
    txtRightRight = rightright;
    repaint();
}

void StatusBar::setLeftLeftText(QString txt)
{
    txtLeftLeft = txt;
    repaint();
}

void StatusBar::setLeftText(QString txt)
{
    txtLeft = txt;
    repaint();
}

void StatusBar::setCenterText(QString txt)
{
    txtCenter = txt;
    repaint();
}

void StatusBar::setRightText(QString txt)
{
    txtRight = txt;
    repaint();
}

void StatusBar::setRightRightText(QString txt)
{
    txtRightRight = txt;
    repaint();
}

void StatusBar::paintEvent([[maybe_unused]] QPaintEvent* pevent)
{
    QPainter painter(this);
    // Draw backgorund image
    painter.drawPixmap(0, 0, background);
    painter.setFont(QFont(t10::font_standard, t10::font_size_status));
    painter.setPen(QColor(40, 40, 40));
    painter.drawText(
        190, 7, 230, 14, Qt::AlignCenter | Qt::AlignVCenter, txtCenter);
    painter.setPen(QColor(120, 120, 120));
    painter.drawText(
        10, 7, 80, 14, Qt::AlignCenter | Qt::AlignVCenter, txtLeftLeft);
    painter.drawText(
        100, 7, 80, 14, Qt::AlignCenter | Qt::AlignVCenter, txtLeft);
    painter.drawText(
        430, 7, 80, 14, Qt::AlignCenter | Qt::AlignVCenter, txtRight);
    painter.drawText(
        520, 7, 80, 14, Qt::AlignCenter | Qt::AlignVCenter, txtRightRight);
}