added streamview widget

This commit is contained in:
fourtf 2018-01-19 14:48:17 +01:00
parent 702d4b2eec
commit de3a490257
9 changed files with 187 additions and 98 deletions

View file

@ -4,54 +4,87 @@
#
#-------------------------------------------------
QT += core gui network multimedia svg
message(----)
QT += widgets core gui network multimedia svg
CONFIG += communi
COMMUNI += core model util
CONFIG += c++14
PRECOMPILED_HEADER = precompiled_header.hpp
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
# Include ourself
INCLUDEPATH += src/
TARGET = chatterino
TEMPLATE = app
DEFINES += QT_DEPRECATED_WARNINGS
PRECOMPILED_HEADER = src/precompiled_header.hpp
CONFIG += precompile_header
# 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
# Icons
macx:ICON = resources/images/chatterino2.icns
win32:RC_FILE = resources/windows.rc
} 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
# Submodules
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)
# Optional feature: QtWebEngine
exists ($(QTDIR)/include/QtWebEngine/QtWebEngine) {
message(Using QWebEngine)
QT += webenginewidgets
DEFINES += "USEWEBENGINE"
}
# do not use windows min/max macros
# Include boost
win32 {
DEFINES += NOMINMAX
isEmpty(BOOST_DIRECTORY) {
message(Using default boost directory C:\\local\\boost\\)
BOOST_DIRECTORY = C:\local\boost\
}
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
INCLUDEPATH += $$BOOST_DIRECTORY
}
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 += \
src/main.cpp \
src/application.cpp \
@ -128,10 +161,11 @@ SOURCES += \
src/widgets/settingspages/moderationpage.cpp \
src/widgets/settingspages/logspage.cpp \
src/widgets/basewindow.cpp \
src/singletons/helper/moderationaction.cpp
src/singletons/helper/moderationaction.cpp \
src/widgets/streamview.cpp
HEADERS += \
src/precompiled_headers.hpp \
src/precompiled_header.hpp \
src/asyncexec.hpp \
src/channel.hpp \
src/util/concurrentmap.hpp \
@ -196,7 +230,6 @@ HEADERS += \
src/widgets/accountswitchpopupwidget.hpp \
src/const.hpp \
src/widgets/tooltipwidget.hpp \
src/precompiled_headers.hpp \
src/singletons/thememanager.hpp \
src/twitch/twitchaccountmanager.hpp \
src/singletons/helper/completionmodel.hpp \
@ -228,69 +261,49 @@ HEADERS += \
src/widgets/settingspages/moderationpage.hpp \
src/widgets/settingspages/logspage.hpp \
src/widgets/basewindow.hpp \
src/singletons/helper/moderationaction.hpp
PRECOMPILED_HEADER =
src/singletons/helper/moderationaction.hpp \
src/widgets/streamview.hpp
RESOURCES += \
resources/resources.qrc
DISTFILES +=
# Include boost
win32 {
isEmpty(BOOST_DIRECTORY) {
message(Using default boost directory C:\\local\\boost\\)
BOOST_DIRECTORY = C:\local\boost\
FORMS += \
forms/accountpopupform.ui
# 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
}
INCLUDEPATH += $$BOOST_DIRECTORY
}
# do not use windows min/max macros
#win32 {
# DEFINES += NOMINMAX
#}
win32 {
LIBS += -luser32
LIBS += -lgdi32
}
# Optional dependency on windows sdk 7.1
!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"
}
}
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
win32::exists(C:\fourtf) {
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View file

@ -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

View file

@ -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

View file

@ -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:

View file

@ -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))

View file

@ -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()));

View 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

View 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