ORE Studio 0.0.4
Loading...
Searching...
No Matches
LogoLabel.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2024-2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 * MA 02110-1301, USA.
19 *
20 */
21#ifndef ORES_QT_ABOUT_LOGOLABEL_HPP
22#define ORES_QT_ABOUT_LOGOLABEL_HPP
23
24#include <QLabel>
25#include <QPainter>
26
27namespace ores::qt {
28
29class LogoLabel final : public QLabel {
30public:
31 explicit LogoLabel(QWidget* parent = nullptr) : QLabel(parent) {}
32 void setTextOverlay(const QString& text) {
33 overlayText_ = text;
34 update();
35 }
36
37protected:
38 void paintEvent(QPaintEvent* event) override {
39 QLabel::paintEvent(event);
40
41 if (!overlayText_.isEmpty()) {
42 QPainter painter(this);
43 QFont font("Sans Serif", 6);
44 painter.setFont(font);
45 painter.setPen(Qt::white);
46
47 // Position text at bottom-left of the label
48 int x = 20;
49 int y = height() - 20;
50
51 painter.drawText(x, y, overlayText_);
52 }
53 }
54
55private:
56 QString overlayText_;
57};
58
59}
60
61#endif
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35