qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
notificationedgewidget.cpp
Go to the documentation of this file.
1 /*
2  Copyright © 2015-2019 by The qTox Project Contributors
3 
4  This file is part of qTox, a Qt-based graphical interface for Tox.
5 
6  qTox is libre software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  qTox is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with qTox. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "notificationedgewidget.h"
21 #include "style.h"
22 #include <QBoxLayout>
23 #include <QLabel>
24 
25 #include <QDebug>
26 
28  : QWidget(parent)
29 {
30  setAttribute(Qt::WA_StyledBackground); // Show background.
31  setStyleSheet(Style::getStylesheet("notificationEdge/notificationEdge.css"));
32  QHBoxLayout* layout = new QHBoxLayout(this);
33  layout->addStretch();
34 
35  textLabel = new QLabel(this);
36  textLabel->setMinimumHeight(textLabel->sizeHint().height()); // Prevent cut-off text.
37  layout->addWidget(textLabel);
38 
39  QLabel* arrowLabel = new QLabel(this);
40 
41  if (position == Top)
42  arrowLabel->setPixmap(QPixmap(Style::getImagePath("chatArea/scrollBarUpArrow.svg")));
43  else
44  arrowLabel->setPixmap(QPixmap(Style::getImagePath("chatArea/scrollBarDownArrow.svg")));
45 
46  layout->addWidget(arrowLabel);
47  layout->addStretch();
48 
49  setCursor(Qt::PointingHandCursor);
50 }
51 
53 {
54  textLabel->setText(tr("Unread message(s)", "", count));
55 }
56 
58 {
59  emit clicked();
60  QWidget::mousePressEvent(event);
61 }
NotificationEdgeWidget::Position
Position
Definition: notificationedgewidget.h:30
style.h
NotificationEdgeWidget::NotificationEdgeWidget
NotificationEdgeWidget(Position position, QWidget *parent=nullptr)
Definition: notificationedgewidget.cpp:27
NotificationEdgeWidget::textLabel
QLabel * textLabel
Definition: notificationedgewidget.h:46
notificationedgewidget.h
Style::getImagePath
static const QString getImagePath(const QString &filename)
Definition: style.cpp:182
NotificationEdgeWidget::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event) final
Definition: notificationedgewidget.cpp:57
NotificationEdgeWidget::updateNotificationCount
void updateNotificationCount(int count)
Definition: notificationedgewidget.cpp:52
NotificationEdgeWidget::Top
@ Top
Definition: notificationedgewidget.h:32
Style::getStylesheet
static const QString getStylesheet(const QString &filename, const QFont &baseFont=QFont())
Definition: style.cpp:165
NotificationEdgeWidget::clicked
void clicked()