mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
56 lines
1.3 KiB
C++
56 lines
1.3 KiB
C++
#include "NotificationPopup.hpp"
|
|
|
|
#include "common/Channel.hpp"
|
|
#include "messages/Message.hpp"
|
|
#include "widgets/helper/ChannelView.hpp"
|
|
|
|
#include <QApplication>
|
|
#include <QDesktopWidget>
|
|
#include <QScreen>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
namespace chatterino {
|
|
|
|
NotificationPopup::NotificationPopup()
|
|
: BaseWindow(BaseWindow::Frameless)
|
|
, channel_(std::make_shared<Channel>("notifications", Channel::Type::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)
|
|
{
|
|
this->channel_->addMessage(std::move(msg));
|
|
|
|
// QTimer::singleShot(5000, this, [this, msg] { this->channel->remove });
|
|
}
|
|
|
|
} // namespace chatterino
|