diff --git a/chatterino.pro b/chatterino.pro index 0b82abad..d7adb85f 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -4,54 +4,87 @@ # #------------------------------------------------- -QT += core gui network multimedia svg -CONFIG += communi -COMMUNI += core model util -CONFIG += c++14 -PRECOMPILED_HEADER = precompiled_header.hpp +message(----) -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 -INCLUDEPATH += src/ +# Icons +macx:ICON = resources/images/chatterino2.icns +win32:RC_FILE = resources/windows.rc -TARGET = chatterino -TEMPLATE = app +# 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) -DEFINES += QT_DEPRECATED_WARNINGS - -# 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 +# 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 diff --git a/docs/imember.png b/docs/imember.png new file mode 100644 index 00000000..9c9f6c65 Binary files /dev/null and b/docs/imember.png differ diff --git a/src/main.cpp b/src/main.cpp index d2c93f38..a170c00e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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 diff --git a/src/precompiled_headers.hpp b/src/precompiled_header.hpp similarity index 95% rename from src/precompiled_headers.hpp rename to src/precompiled_header.hpp index a2776cb1..fc981efd 100644 --- a/src/precompiled_headers.hpp +++ b/src/precompiled_header.hpp @@ -1,3 +1,4 @@ +#ifdef __cplusplus #include #include #include @@ -154,3 +155,4 @@ #include #include #include +#endif diff --git a/src/singletons/fontmanager.cpp b/src/singletons/fontmanager.cpp index d464cdb4..a0c0d828 100644 --- a/src/singletons/fontmanager.cpp +++ b/src/singletons/fontmanager.cpp @@ -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: diff --git a/src/singletons/fontmanager.hpp b/src/singletons/fontmanager.hpp index 3f59c8d1..0f29116f 100644 --- a/src/singletons/fontmanager.hpp +++ b/src/singletons/fontmanager.hpp @@ -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)) diff --git a/src/widgets/helper/splitheader.cpp b/src/widgets/helper/splitheader.cpp index 9ef0463d..e43cea06 100644 --- a/src/widgets/helper/splitheader.cpp +++ b/src/widgets/helper/splitheader.cpp @@ -13,6 +13,10 @@ #include #include +#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(_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())); diff --git a/src/widgets/streamview.cpp b/src/widgets/streamview.cpp new file mode 100644 index 00000000..d3ffd041 --- /dev/null +++ b/src/widgets/streamview.cpp @@ -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 +#endif + +namespace chatterino { +namespace widgets { +StreamView::StreamView(SharedChannel channel, QUrl url) +{ + util::LayoutCreator layoutCreator(this); + +#ifdef USEWEBENGINE + auto web = layoutCreator.emplace(this).assign(&this->stream); + web->setUrl(url); + web->settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true); +#endif + + // QString uuid = CreateUUID(); + + auto chat = layoutCreator.emplace(); + chat->setFixedWidth(300); + chat->setChannel(channel); + + this->layout()->setSpacing(0); + this->layout()->setMargin(0); +} +} // namespace widgets +} // namespace chatterino diff --git a/src/widgets/streamview.hpp b/src/widgets/streamview.hpp new file mode 100644 index 00000000..7c80abec --- /dev/null +++ b/src/widgets/streamview.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include +#include +#include + +class QWebEngineView; + +namespace chatterino { +class Channel; + +namespace widgets { +class StreamView : public QWidget +{ +public: + StreamView(std::shared_ptr channel, QUrl url); + +private: + QWebEngineView *stream; +}; +} // namespace widgets +} // namespace chatterino