mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
added streamview widget
This commit is contained in:
parent
702d4b2eec
commit
de3a490257
199
chatterino.pro
199
chatterino.pro
|
@ -4,54 +4,87 @@
|
||||||
#
|
#
|
||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
|
|
||||||
QT += core gui network multimedia svg
|
message(----)
|
||||||
CONFIG += communi
|
|
||||||
COMMUNI += core model util
|
|
||||||
CONFIG += c++14
|
|
||||||
PRECOMPILED_HEADER = precompiled_header.hpp
|
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
QT += widgets core gui network multimedia svg
|
||||||
|
CONFIG += communi
|
||||||
|
COMMUNI += core model util
|
||||||
|
CONFIG += c++14
|
||||||
|
INCLUDEPATH += src/
|
||||||
|
TARGET = chatterino
|
||||||
|
TEMPLATE = app
|
||||||
|
DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
|
PRECOMPILED_HEADER = src/precompiled_header.hpp
|
||||||
|
CONFIG += precompile_header
|
||||||
|
|
||||||
# Include ourself
|
# Icons
|
||||||
INCLUDEPATH += src/
|
macx:ICON = resources/images/chatterino2.icns
|
||||||
|
win32:RC_FILE = resources/windows.rc
|
||||||
|
|
||||||
TARGET = chatterino
|
# Submodules
|
||||||
TEMPLATE = app
|
include(dependencies/rapidjson.pri)
|
||||||
|
include(dependencies/settings.pri)
|
||||||
|
include(dependencies/signals.pri)
|
||||||
|
include(dependencies/humanize.pri)
|
||||||
|
include(dependencies/fmt.pri)
|
||||||
|
DEFINES += IRC_NAMESPACE=Communi
|
||||||
|
include(dependencies/libcommuni.pri)
|
||||||
|
|
||||||
DEFINES += QT_DEPRECATED_WARNINGS
|
# Optional feature: QtWebEngine
|
||||||
|
exists ($(QTDIR)/include/QtWebEngine/QtWebEngine) {
|
||||||
# Define warning flags for Chatterino
|
message(Using QWebEngine)
|
||||||
win32-msvc* {
|
QT += webenginewidgets
|
||||||
QMAKE_CXXFLAGS_WARN_ON = /W4
|
DEFINES += "USEWEBENGINE"
|
||||||
# 4714 - function marked as __forceinline not inlined
|
|
||||||
# 4996 - occurs when the compiler encounters a function or variable that is marked as deprecated.
|
|
||||||
# These functions may have a different preferred name, may be insecure or have
|
|
||||||
# a more secure variant, or may be obsolete.
|
|
||||||
# 4505 - unreferenced local version has been removed
|
|
||||||
# 4127 - conditional expression is constant
|
|
||||||
# 4503 - decorated name length exceeded, name was truncated
|
|
||||||
# 4100 - unreferences formal parameter
|
|
||||||
QMAKE_CXXFLAGS_WARN_ON += /wd4714
|
|
||||||
QMAKE_CXXFLAGS_WARN_ON += /wd4996
|
|
||||||
QMAKE_CXXFLAGS_WARN_ON += /wd4505
|
|
||||||
QMAKE_CXXFLAGS_WARN_ON += /wd4127
|
|
||||||
QMAKE_CXXFLAGS_WARN_ON += /wd4503
|
|
||||||
QMAKE_CXXFLAGS_WARN_ON += /wd4100
|
|
||||||
|
|
||||||
} else {
|
|
||||||
QMAKE_CXXFLAGS_WARN_ON = -Wall
|
|
||||||
QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-function
|
|
||||||
QMAKE_CXXFLAGS_WARN_ON += -Wno-switch
|
|
||||||
QMAKE_CXXFLAGS_WARN_ON += -Wno-deprecated-declarations
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# do not use windows min/max macros
|
# Include boost
|
||||||
win32 {
|
win32 {
|
||||||
DEFINES += NOMINMAX
|
isEmpty(BOOST_DIRECTORY) {
|
||||||
|
message(Using default boost directory C:\\local\\boost\\)
|
||||||
|
BOOST_DIRECTORY = C:\local\boost\
|
||||||
|
}
|
||||||
|
|
||||||
|
INCLUDEPATH += $$BOOST_DIRECTORY
|
||||||
}
|
}
|
||||||
|
|
||||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
win32 {
|
||||||
|
LIBS += -luser32
|
||||||
|
}
|
||||||
|
|
||||||
|
# OSX include directory
|
||||||
|
macx {
|
||||||
|
INCLUDEPATH += /usr/local/include
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optional dependency on Windows SDK 7
|
||||||
|
!contains(QMAKE_TARGET.arch, x86_64) {
|
||||||
|
win32:exists(C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\Windows.h) {
|
||||||
|
LIBS += -L"C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib" \
|
||||||
|
-ldwmapi
|
||||||
|
|
||||||
|
DEFINES += "USEWINSDK"
|
||||||
|
message(Using Windows SDK 7)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optional dependency on Windows SDK 10
|
||||||
|
contains(QMAKE_TARGET.arch, x86_64) {
|
||||||
|
WIN_SDK_VERSION = $$(WindowsSDKVersion)
|
||||||
|
!isEmpty(WIN_SDK_VERSION) {
|
||||||
|
!equals(WIN_SDK_VERSION, "\\") {
|
||||||
|
DEFINES += "USEWINSDK"
|
||||||
|
message(Using Windows SDK 10)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
werr {
|
||||||
|
QMAKE_CXXFLAGS += -Werror
|
||||||
|
|
||||||
|
message("Enabling error on warning")
|
||||||
|
}
|
||||||
|
|
||||||
|
# src
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
src/main.cpp \
|
src/main.cpp \
|
||||||
src/application.cpp \
|
src/application.cpp \
|
||||||
|
@ -128,10 +161,11 @@ SOURCES += \
|
||||||
src/widgets/settingspages/moderationpage.cpp \
|
src/widgets/settingspages/moderationpage.cpp \
|
||||||
src/widgets/settingspages/logspage.cpp \
|
src/widgets/settingspages/logspage.cpp \
|
||||||
src/widgets/basewindow.cpp \
|
src/widgets/basewindow.cpp \
|
||||||
src/singletons/helper/moderationaction.cpp
|
src/singletons/helper/moderationaction.cpp \
|
||||||
|
src/widgets/streamview.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/precompiled_headers.hpp \
|
src/precompiled_header.hpp \
|
||||||
src/asyncexec.hpp \
|
src/asyncexec.hpp \
|
||||||
src/channel.hpp \
|
src/channel.hpp \
|
||||||
src/util/concurrentmap.hpp \
|
src/util/concurrentmap.hpp \
|
||||||
|
@ -196,7 +230,6 @@ HEADERS += \
|
||||||
src/widgets/accountswitchpopupwidget.hpp \
|
src/widgets/accountswitchpopupwidget.hpp \
|
||||||
src/const.hpp \
|
src/const.hpp \
|
||||||
src/widgets/tooltipwidget.hpp \
|
src/widgets/tooltipwidget.hpp \
|
||||||
src/precompiled_headers.hpp \
|
|
||||||
src/singletons/thememanager.hpp \
|
src/singletons/thememanager.hpp \
|
||||||
src/twitch/twitchaccountmanager.hpp \
|
src/twitch/twitchaccountmanager.hpp \
|
||||||
src/singletons/helper/completionmodel.hpp \
|
src/singletons/helper/completionmodel.hpp \
|
||||||
|
@ -228,69 +261,49 @@ HEADERS += \
|
||||||
src/widgets/settingspages/moderationpage.hpp \
|
src/widgets/settingspages/moderationpage.hpp \
|
||||||
src/widgets/settingspages/logspage.hpp \
|
src/widgets/settingspages/logspage.hpp \
|
||||||
src/widgets/basewindow.hpp \
|
src/widgets/basewindow.hpp \
|
||||||
src/singletons/helper/moderationaction.hpp
|
src/singletons/helper/moderationaction.hpp \
|
||||||
|
src/widgets/streamview.hpp
|
||||||
|
|
||||||
PRECOMPILED_HEADER =
|
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
resources/resources.qrc
|
resources/resources.qrc
|
||||||
|
|
||||||
DISTFILES +=
|
DISTFILES +=
|
||||||
|
|
||||||
# Include boost
|
FORMS += \
|
||||||
win32 {
|
forms/accountpopupform.ui
|
||||||
isEmpty(BOOST_DIRECTORY) {
|
|
||||||
message(Using default boost directory C:\\local\\boost\\)
|
|
||||||
BOOST_DIRECTORY = C:\local\boost\
|
|
||||||
}
|
|
||||||
|
|
||||||
INCLUDEPATH += $$BOOST_DIRECTORY
|
# Define warning flags for Chatterino
|
||||||
|
win32-msvc* {
|
||||||
|
QMAKE_CXXFLAGS_WARN_ON = /W4
|
||||||
|
# 4714 - function marked as __forceinline not inlined
|
||||||
|
# 4996 - occurs when the compiler encounters a function or variable that is marked as deprecated.
|
||||||
|
# These functions may have a different preferred name, may be insecure or have
|
||||||
|
# a more secure variant, or may be obsolete.
|
||||||
|
# 4505 - unreferenced local version has been removed
|
||||||
|
# 4127 - conditional expression is constant
|
||||||
|
# 4503 - decorated name length exceeded, name was truncated
|
||||||
|
# 4100 - unreferences formal parameter
|
||||||
|
QMAKE_CXXFLAGS_WARN_ON += /wd4714
|
||||||
|
QMAKE_CXXFLAGS_WARN_ON += /wd4996
|
||||||
|
QMAKE_CXXFLAGS_WARN_ON += /wd4505
|
||||||
|
QMAKE_CXXFLAGS_WARN_ON += /wd4127
|
||||||
|
QMAKE_CXXFLAGS_WARN_ON += /wd4503
|
||||||
|
QMAKE_CXXFLAGS_WARN_ON += /wd4100
|
||||||
|
|
||||||
|
} else {
|
||||||
|
QMAKE_CXXFLAGS_WARN_ON = -Wall
|
||||||
|
QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-function
|
||||||
|
QMAKE_CXXFLAGS_WARN_ON += -Wno-switch
|
||||||
|
QMAKE_CXXFLAGS_WARN_ON += -Wno-deprecated-declarations
|
||||||
}
|
}
|
||||||
|
|
||||||
win32 {
|
# do not use windows min/max macros
|
||||||
LIBS += -luser32
|
#win32 {
|
||||||
LIBS += -lgdi32
|
# DEFINES += NOMINMAX
|
||||||
}
|
#}
|
||||||
|
|
||||||
# Optional dependency on windows sdk 7.1
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
!contains(QMAKE_TARGET.arch, x86_64) {
|
|
||||||
win32:exists(C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\Windows.h) {
|
|
||||||
LIBS += -L"C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib" \
|
|
||||||
-ldwmapi \
|
|
||||||
-lgdi32
|
|
||||||
|
|
||||||
DEFINES += "USEWINSDK"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
win32::exists(C:\fourtf) {
|
win32::exists(C:\fourtf) {
|
||||||
DEFINES += "OHHEYITSFOURTF"
|
DEFINES += "OHHEYITSFOURTF"
|
||||||
}
|
}
|
||||||
|
|
||||||
macx {
|
|
||||||
INCLUDEPATH += /usr/local/include
|
|
||||||
}
|
|
||||||
|
|
||||||
FORMS += \
|
|
||||||
forms/accountpopupform.ui
|
|
||||||
|
|
||||||
werr {
|
|
||||||
QMAKE_CXXFLAGS += -Werror
|
|
||||||
|
|
||||||
message("Enabling error on warning")
|
|
||||||
}
|
|
||||||
|
|
||||||
# External dependencies
|
|
||||||
include(dependencies/rapidjson.pri)
|
|
||||||
include(dependencies/settings.pri)
|
|
||||||
include(dependencies/signals.pri)
|
|
||||||
include(dependencies/humanize.pri)
|
|
||||||
include(dependencies/fmt.pri)
|
|
||||||
DEFINES += IRC_NAMESPACE=Communi
|
|
||||||
include(dependencies/libcommuni.pri)
|
|
||||||
|
|
||||||
|
|
||||||
#ICONs
|
|
||||||
macx:ICON = resources/images/chatterino2.icns
|
|
||||||
win32:RC_FILE = resources/windows.rc
|
|
||||||
|
|
BIN
docs/imember.png
Normal file
BIN
docs/imember.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
|
@ -17,7 +17,7 @@ int main(int argc, char *argv[])
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true);
|
QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true);
|
||||||
#endif
|
#endif
|
||||||
QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL, true);
|
// QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL, true);
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
// Install native event handler for hidpi on windows
|
// Install native event handler for hidpi on windows
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#ifdef __cplusplus
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
#include <irccommand.h>
|
#include <irccommand.h>
|
||||||
#include <ircconnection.h>
|
#include <ircconnection.h>
|
||||||
|
@ -154,3 +155,4 @@
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#endif
|
|
@ -45,19 +45,19 @@ FontManager &FontManager::getInstance()
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFont &FontManager::getFont(Type type, float scale)
|
QFont &FontManager::getFont(FontManager::Type type, float scale)
|
||||||
{
|
{
|
||||||
// return this->currentFont.getFont(type);
|
// return this->currentFont.getFont(type);
|
||||||
return this->getCurrentFont(scale).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->currentFont.getFontMetrics(type);
|
||||||
return this->getCurrentFont(scale).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) {
|
switch (type) {
|
||||||
case Tiny:
|
case Tiny:
|
||||||
|
|
|
@ -63,7 +63,7 @@ private:
|
||||||
struct Font {
|
struct Font {
|
||||||
Font() = delete;
|
Font() = delete;
|
||||||
|
|
||||||
explicit Font(const char *fontFamilyName, int mediumSize)
|
Font(const char *fontFamilyName, int mediumSize)
|
||||||
: tiny(QFont("Monospace", 8))
|
: tiny(QFont("Monospace", 8))
|
||||||
, small(QFont(fontFamilyName, mediumSize - 4))
|
, small(QFont(fontFamilyName, mediumSize - 4))
|
||||||
, mediumSmall(QFont(fontFamilyName, mediumSize - 2))
|
, mediumSmall(QFont(fontFamilyName, mediumSize - 2))
|
||||||
|
|
|
@ -13,6 +13,10 @@
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
#ifdef USEWEBENGINE
|
||||||
|
#include "widgets/streamview.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
|
@ -87,10 +91,24 @@ void SplitHeader::addDropdownItems(RippleEffectButton *label)
|
||||||
this->dropdownMenu.addAction("Popup", this->split, &Split::doPopup);
|
this->dropdownMenu.addAction("Popup", this->split, &Split::doPopup);
|
||||||
this->dropdownMenu.addAction("Open viewer list", this->split, &Split::doOpenViewerList);
|
this->dropdownMenu.addAction("Open viewer list", this->split, &Split::doOpenViewerList);
|
||||||
this->dropdownMenu.addSeparator();
|
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("Change channel", this->split, &Split::doChangeChannel, QKeySequence(tr("Ctrl+R")));
|
||||||
this->dropdownMenu.addAction("Clear chat", this->split, &Split::doClearChat);
|
this->dropdownMenu.addAction("Clear chat", this->split, &Split::doClearChat);
|
||||||
this->dropdownMenu.addAction("Open in web browser", this->split, &Split::doOpenChannel);
|
this->dropdownMenu.addAction("Open in web browser", this->split, &Split::doOpenChannel);
|
||||||
|
#ifndef USEWEBENGINE
|
||||||
this->dropdownMenu.addAction("Open web player", this->split, &Split::doOpenPopupPlayer);
|
this->dropdownMenu.addAction("Open web player", this->split, &Split::doOpenPopupPlayer);
|
||||||
|
#endif
|
||||||
this->dropdownMenu.addAction("Open in Streamlink", this->split, &Split::doOpenStreamlink);
|
this->dropdownMenu.addAction("Open in Streamlink", this->split, &Split::doOpenStreamlink);
|
||||||
this->dropdownMenu.addSeparator();
|
this->dropdownMenu.addSeparator();
|
||||||
this->dropdownMenu.addAction("Reload channel emotes", this, SLOT(menuReloadChannelEmotes()));
|
this->dropdownMenu.addAction("Reload channel emotes", this, SLOT(menuReloadChannelEmotes()));
|
||||||
|
|
34
src/widgets/streamview.cpp
Normal file
34
src/widgets/streamview.cpp
Normal file
|
@ -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
|
22
src/widgets/streamview.hpp
Normal file
22
src/widgets/streamview.hpp
Normal file
|
@ -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
|
Loading…
Reference in a new issue