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
189
chatterino.pro
189
chatterino.pro
|
@ -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\
|
||||
}
|
||||
|
||||
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 += \
|
||||
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
|
||||
|
||||
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 {
|
||||
LIBS += -luser32
|
||||
LIBS += -lgdi32
|
||||
}
|
||||
# do not use windows min/max macros
|
||||
#win32 {
|
||||
# DEFINES += NOMINMAX
|
||||
#}
|
||||
|
||||
# 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
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
|
||||
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()));
|
||||
|
|
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