mirror-chatterino2/src/widgets/dialogs/NotificationPopup.cpp

49 lines
1.2 KiB
C++
Raw Normal View History

2018-06-26 14:09:39 +02:00
#include "NotificationPopup.hpp"
2018-05-23 22:27:29 +02:00
2018-06-26 14:09:39 +02:00
#include "widgets/helper/ChannelView.hpp"
2018-05-23 22:27:29 +02:00
#include <QApplication>
#include <QDesktopWidget>
#include <QScreen>
namespace chatterino {
NotificationPopup::NotificationPopup()
2018-06-06 10:46:23 +02:00
: BaseWindow((QWidget *)nullptr, BaseWindow::Frameless)
2018-05-23 22:27:29 +02:00
, channel(std::make_shared<Channel>("notifications", Channel::None))
{
this->channelView = new ChannelView(this);
auto *layout = new QVBoxLayout(this);
this->setLayout(layout);
layout->addWidget(this->channelView);
this->channelView->setChannel(this->channel);
this->setScaleIndependantSize(300, 150);
}
void NotificationPopup::updatePosition()
{
Location location = BottomRight;
QDesktopWidget *desktop = QApplication::desktop();
const QRect rect = desktop->availableGeometry();
switch (location) {
case BottomRight: {
this->move(rect.right() - this->width(), rect.bottom() - this->height());
} break;
}
}
void NotificationPopup::addMessage(MessagePtr msg)
2018-05-23 22:27:29 +02:00
{
this->channel->addMessage(msg);
// QTimer::singleShot(5000, this, [this, msg] { this->channel->remove });
}
} // namespace chatterino