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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.2 KiB
C++
Raw Normal View History

2018-06-26 14:09:39 +02:00
#include "NotificationPopup.hpp"
#include "common/Channel.hpp"
#include "messages/Message.hpp"
2018-06-26 14:09:39 +02:00
#include "widgets/helper/ChannelView.hpp"
2018-05-23 22:27:29 +02:00
#include <QApplication>
#include <QScreen>
#include <QVBoxLayout>
2018-05-23 22:27:29 +02:00
namespace chatterino {
2018-05-23 22:27:29 +02:00
NotificationPopup::NotificationPopup()
: BaseWindow({BaseWindow::Frameless, BaseWindow::DisableLayoutSave})
2018-07-06 19:23:47 +02:00
, channel_(std::make_shared<Channel>("notifications", Channel::Type::None))
2018-05-23 22:27:29 +02:00
{
2018-07-06 19:23:47 +02:00
this->channelView_ = new ChannelView(this);
2018-05-23 22:27:29 +02:00
auto *layout = new QVBoxLayout(this);
this->setLayout(layout);
2018-07-06 19:23:47 +02:00
layout->addWidget(this->channelView_);
2018-07-06 19:23:47 +02:00
this->channelView_->setChannel(this->channel_);
2018-05-23 22:27:29 +02:00
this->setScaleIndependantSize(300, 150);
}
2018-05-23 22:27:29 +02:00
void NotificationPopup::updatePosition()
{
Location location = BottomRight;
const QRect rect = QGuiApplication::primaryScreen()->availableGeometry();
2018-05-23 22:27:29 +02:00
switch (location)
{
2019-09-26 00:51:05 +02:00
case BottomRight: {
2018-05-23 22:27:29 +02:00
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(std::move(msg));
2018-05-23 22:27:29 +02:00
// QTimer::singleShot(5000, this, [this, msg] { this->channel->remove });
}
2018-05-23 22:27:29 +02:00
} // namespace chatterino