From 776a9756241ff424457b5dd8c1592f1a7e0f2f11 Mon Sep 17 00:00:00 2001 From: fourtf Date: Wed, 17 Jan 2018 03:18:47 +0100 Subject: [PATCH] Fixes #232 opening streams in browser --- src/widgets/helper/splitheader.cpp | 2 +- src/widgets/split.cpp | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/widgets/helper/splitheader.cpp b/src/widgets/helper/splitheader.cpp index 63f35f010..06b8026c3 100644 --- a/src/widgets/helper/splitheader.cpp +++ b/src/widgets/helper/splitheader.cpp @@ -92,7 +92,7 @@ void SplitHeader::addDropdownItems(RippleEffectLabel *label) 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); - this->dropdownMenu.addAction("Open web popup player", this->split, &Split::doOpenPopupPlayer); + this->dropdownMenu.addAction("Open web player", this->split, &Split::doOpenPopupPlayer); 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/split.cpp b/src/widgets/split.cpp index 7fc208f3a..052f2fad4 100644 --- a/src/widgets/split.cpp +++ b/src/widgets/split.cpp @@ -3,6 +3,7 @@ #include "singletons/settingsmanager.hpp" #include "singletons/thememanager.hpp" #include "singletons/windowmanager.hpp" +#include "twitch/twitchchannel.hpp" #include "twitch/twitchmessagebuilder.hpp" #include "util/urlfetch.hpp" #include "widgets/helper/searchpopup.hpp" @@ -15,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -317,14 +319,22 @@ void Split::doClearChat() void Split::doOpenChannel() { - qDebug() << "[UNIMPLEMENTED] Open twitch.tv/" - << QString::fromStdString(this->channelName.getValue()); + SharedChannel _channel = this->channel; + twitch::TwitchChannel *tc = dynamic_cast(_channel.get()); + + if (tc != nullptr) { + QDesktopServices::openUrl("https://twitch.tv/" + tc->name); + } } void Split::doOpenPopupPlayer() { - qDebug() << "[UNIMPLEMENTED] Open twitch.tv/" - << QString::fromStdString(this->channelName.getValue()) << "/popout"; + SharedChannel _channel = this->channel; + twitch::TwitchChannel *tc = dynamic_cast(_channel.get()); + + if (tc != nullptr) { + QDesktopServices::openUrl("https://player.twitch.tv/?channel=" + tc->name); + } } void Split::doOpenStreamlink()