matrixion/src/ui/InfoMessage.h

57 lines
1.3 KiB
C
Raw Normal View History

2021-03-05 02:35:15 +03:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <QColor>
#include <QDateTime>
#include <QWidget>
class InfoMessage : public QWidget
{
2021-09-18 01:22:33 +03:00
Q_OBJECT
2021-09-18 01:22:33 +03:00
Q_PROPERTY(QColor textColor WRITE setTextColor READ textColor)
Q_PROPERTY(QColor boxColor WRITE setBoxColor READ boxColor)
public:
2021-09-18 01:22:33 +03:00
explicit InfoMessage(QWidget *parent = nullptr);
InfoMessage(QString msg, QWidget *parent = nullptr);
2021-09-18 01:22:33 +03:00
void setTextColor(QColor color) { textColor_ = color; }
void setBoxColor(QColor color) { boxColor_ = color; }
void saveDatetime(QDateTime datetime) { datetime_ = datetime; }
2021-09-18 01:22:33 +03:00
QColor textColor() const { return textColor_; }
QColor boxColor() const { return boxColor_; }
QDateTime datetime() const { return datetime_; }
protected:
2021-09-18 01:22:33 +03:00
void paintEvent(QPaintEvent *event) override;
void initFont()
{
QFont f;
f.setWeight(QFont::Medium);
setFont(f);
}
2021-09-18 01:22:33 +03:00
int width_;
int height_;
2021-09-18 01:22:33 +03:00
QString msg_;
2021-09-18 01:22:33 +03:00
QDateTime datetime_;
2021-09-18 01:22:33 +03:00
QColor textColor_ = QColor("black");
QColor boxColor_ = QColor("white");
};
class DateSeparator : public InfoMessage
{
2021-09-18 01:22:33 +03:00
Q_OBJECT
public:
2021-09-18 01:22:33 +03:00
DateSeparator(QDateTime datetime, QWidget *parent = nullptr);
};