added streamview widget
This commit is contained in:
@@ -13,6 +13,10 @@
|
||||
#include <QMimeData>
|
||||
#include <QPainter>
|
||||
|
||||
#ifdef USEWEBENGINE
|
||||
#include "widgets/streamview.hpp"
|
||||
#endif
|
||||
|
||||
namespace chatterino {
|
||||
namespace widgets {
|
||||
|
||||
@@ -87,10 +91,24 @@ void SplitHeader::addDropdownItems(RippleEffectButton *label)
|
||||
this->dropdownMenu.addAction("Popup", this->split, &Split::doPopup);
|
||||
this->dropdownMenu.addAction("Open viewer list", this->split, &Split::doOpenViewerList);
|
||||
this->dropdownMenu.addSeparator();
|
||||
#ifdef USEWEBENGINE
|
||||
this->dropdownMenu.addAction("Start watching", this, [this]{
|
||||
SharedChannel _channel = this->split->getChannel();
|
||||
twitch::TwitchChannel *tc = dynamic_cast<twitch::TwitchChannel *>(_channel.get());
|
||||
|
||||
if (tc != nullptr) {
|
||||
StreamView *view = new StreamView(_channel, "https://player.twitch.tv/?channel=" + tc->name);
|
||||
view->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
view->show();
|
||||
}
|
||||
});
|
||||
#endif
|
||||
this->dropdownMenu.addAction("Change channel", this->split, &Split::doChangeChannel, QKeySequence(tr("Ctrl+R")));
|
||||
this->dropdownMenu.addAction("Clear chat", this->split, &Split::doClearChat);
|
||||
this->dropdownMenu.addAction("Open in web browser", this->split, &Split::doOpenChannel);
|
||||
#ifndef USEWEBENGINE
|
||||
this->dropdownMenu.addAction("Open web player", this->split, &Split::doOpenPopupPlayer);
|
||||
#endif
|
||||
this->dropdownMenu.addAction("Open in Streamlink", this->split, &Split::doOpenStreamlink);
|
||||
this->dropdownMenu.addSeparator();
|
||||
this->dropdownMenu.addAction("Reload channel emotes", this, SLOT(menuReloadChannelEmotes()));
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "streamview.hpp"
|
||||
|
||||
#include "channel.hpp"
|
||||
#include "util/helpers.hpp"
|
||||
#include "util/layoutcreator.hpp"
|
||||
#include "widgets/split.hpp"
|
||||
|
||||
#ifdef USEWEBENGINE
|
||||
#include <QtWebEngineWidgets>
|
||||
#endif
|
||||
|
||||
namespace chatterino {
|
||||
namespace widgets {
|
||||
StreamView::StreamView(SharedChannel channel, QUrl url)
|
||||
{
|
||||
util::LayoutCreator<StreamView> layoutCreator(this);
|
||||
|
||||
#ifdef USEWEBENGINE
|
||||
auto web = layoutCreator.emplace<QWebEngineView>(this).assign(&this->stream);
|
||||
web->setUrl(url);
|
||||
web->settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true);
|
||||
#endif
|
||||
|
||||
// QString uuid = CreateUUID();
|
||||
|
||||
auto chat = layoutCreator.emplace<ChannelView>();
|
||||
chat->setFixedWidth(300);
|
||||
chat->setChannel(channel);
|
||||
|
||||
this->layout()->setSpacing(0);
|
||||
this->layout()->setMargin(0);
|
||||
}
|
||||
} // namespace widgets
|
||||
} // namespace chatterino
|
||||
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <QUrl>
|
||||
#include <QWidget>
|
||||
#include <memory>
|
||||
|
||||
class QWebEngineView;
|
||||
|
||||
namespace chatterino {
|
||||
class Channel;
|
||||
|
||||
namespace widgets {
|
||||
class StreamView : public QWidget
|
||||
{
|
||||
public:
|
||||
StreamView(std::shared_ptr<Channel> channel, QUrl url);
|
||||
|
||||
private:
|
||||
QWebEngineView *stream;
|
||||
};
|
||||
} // namespace widgets
|
||||
} // namespace chatterino
|
||||
Reference in New Issue
Block a user