1 #include "NotificationPopup.hpp"
2 
3 #include "common/Channel.hpp"
4 #include "messages/Message.hpp"
5 #include "widgets/helper/ChannelView.hpp"
6 
7 #include <QApplication>
8 #include <QDesktopWidget>
9 #include <QScreen>
10 
11 #include <QVBoxLayout>
12 
13 namespace chatterino {
14 
NotificationPopup()15 NotificationPopup::NotificationPopup()
16     : BaseWindow(BaseWindow::Frameless)
17     , channel_(std::make_shared<Channel>("notifications", Channel::Type::None))
18 
19 {
20     this->channelView_ = new ChannelView(this);
21 
22     auto *layout = new QVBoxLayout(this);
23     this->setLayout(layout);
24 
25     layout->addWidget(this->channelView_);
26 
27     this->channelView_->setChannel(this->channel_);
28     this->setScaleIndependantSize(300, 150);
29 }
30 
updatePosition()31 void NotificationPopup::updatePosition()
32 {
33     Location location = BottomRight;
34 
35     QDesktopWidget *desktop = QApplication::desktop();
36     const QRect rect = desktop->availableGeometry();
37 
38     switch (location)
39     {
40         case BottomRight: {
41             this->move(rect.right() - this->width(),
42                        rect.bottom() - this->height());
43         }
44         break;
45     }
46 }
47 
addMessage(MessagePtr msg)48 void NotificationPopup::addMessage(MessagePtr msg)
49 {
50     this->channel_->addMessage(std::move(msg));
51 
52     //    QTimer::singleShot(5000, this, [this, msg] { this->channel->remove });
53 }
54 
55 }  // namespace chatterino
56