added streamview widget
This commit is contained in:
+1
-1
@@ -17,7 +17,7 @@ int main(int argc, char *argv[])
|
||||
#ifdef Q_OS_WIN32
|
||||
QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true);
|
||||
#endif
|
||||
QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL, true);
|
||||
// QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL, true);
|
||||
QApplication a(argc, argv);
|
||||
|
||||
// Install native event handler for hidpi on windows
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ifdef __cplusplus
|
||||
#include <fmt/format.h>
|
||||
#include <irccommand.h>
|
||||
#include <ircconnection.h>
|
||||
@@ -154,3 +155,4 @@
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
#endif
|
||||
@@ -45,19 +45,19 @@ FontManager &FontManager::getInstance()
|
||||
return instance;
|
||||
}
|
||||
|
||||
QFont &FontManager::getFont(Type type, float scale)
|
||||
QFont &FontManager::getFont(FontManager::Type type, float scale)
|
||||
{
|
||||
// return this->currentFont.getFont(type);
|
||||
return this->getCurrentFont(scale).getFont(type);
|
||||
}
|
||||
|
||||
QFontMetrics &FontManager::getFontMetrics(Type type, float scale)
|
||||
QFontMetrics &FontManager::getFontMetrics(FontManager::Type type, float scale)
|
||||
{
|
||||
// return this->currentFont.getFontMetrics(type);
|
||||
return this->getCurrentFont(scale).getFontMetrics(type);
|
||||
}
|
||||
|
||||
FontManager::FontData &FontManager::Font::getFontData(Type type)
|
||||
FontManager::FontData &FontManager::Font::getFontData(FontManager::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case Tiny:
|
||||
|
||||
@@ -63,7 +63,7 @@ private:
|
||||
struct Font {
|
||||
Font() = delete;
|
||||
|
||||
explicit Font(const char *fontFamilyName, int mediumSize)
|
||||
Font(const char *fontFamilyName, int mediumSize)
|
||||
: tiny(QFont("Monospace", 8))
|
||||
, small(QFont(fontFamilyName, mediumSize - 4))
|
||||
, mediumSmall(QFont(fontFamilyName, mediumSize - 2))
|
||||
|
||||
@@ -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