mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Simple streamlink support (#97)
* Simple streamlink support Relies on settings entry & loads best available quality by default.
This commit is contained in:
parent
63f85e9bee
commit
a6573e83e0
7 changed files with 39 additions and 1 deletions
|
@ -14,6 +14,7 @@ SettingsManager::SettingsManager()
|
|||
, showTimestamps("/appearance/messages/showTimestamps", true)
|
||||
, showTimestampSeconds("/appearance/messages/showTimestampSeconds", true)
|
||||
, showBadges("/appearance/messages/showBadges", true)
|
||||
, streamlinkPath("/behaviour/streamlinkPath", "")
|
||||
, selectedUser(_settingsItems, "selectedUser", "")
|
||||
, emoteScale(_settingsItems, "emoteScale", 1.0)
|
||||
, mouseScrollMultiplier(_settingsItems, "mouseScrollMultiplier", 1.0)
|
||||
|
|
|
@ -43,6 +43,8 @@ public:
|
|||
pajlada::Settings::Setting<bool> showTimestampSeconds;
|
||||
pajlada::Settings::Setting<bool> showBadges;
|
||||
|
||||
pajlada::Settings::Setting<std::string> streamlinkPath;
|
||||
|
||||
// Settings
|
||||
Setting<QString> selectedUser;
|
||||
Setting<float> emoteScale;
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include <QPainter>
|
||||
#include <QShortcut>
|
||||
#include <QVBoxLayout>
|
||||
#include <QFileInfo>
|
||||
#include <QProcess>
|
||||
#include <boost/signals2.hpp>
|
||||
|
||||
#include <functional>
|
||||
|
@ -270,5 +272,20 @@ void ChatWidget::doOpenPopupPlayer()
|
|||
<< QString::fromStdString(this->channelName.getValue()) << "/popout";
|
||||
}
|
||||
|
||||
void ChatWidget::doOpenStreamlink()
|
||||
{
|
||||
SettingsManager &settings = SettingsManager::getInstance();
|
||||
QString path = QString::fromStdString(settings.streamlinkPath.getValue());
|
||||
QFileInfo fileinfo = QFileInfo(path);
|
||||
// TODO(Confuseh): Add default checks for streamlink/livestreamer
|
||||
// TODO(Confuseh): Add quality switcher
|
||||
if (fileinfo.exists() && fileinfo.isExecutable()) {
|
||||
// works on leenux, idk whether it would work on whindows or mehOS
|
||||
QProcess::startDetached(path,
|
||||
QStringList({"twitch.tv/" + QString::fromStdString(this->channelName.getValue()),
|
||||
"best"}));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace widgets
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -63,7 +63,6 @@ protected:
|
|||
public:
|
||||
ChannelManager &channelManager;
|
||||
CompletionManager &completionManager;
|
||||
|
||||
private:
|
||||
void setChannel(std::shared_ptr<Channel> newChannel);
|
||||
void detachChannel();
|
||||
|
@ -109,6 +108,9 @@ public slots:
|
|||
|
||||
// Open popup player of twitch channel in default browser
|
||||
void doOpenPopupPlayer();
|
||||
|
||||
// Open twitch channel stream through streamlink
|
||||
void doOpenStreamlink();
|
||||
};
|
||||
|
||||
} // namespace widgets
|
||||
|
|
|
@ -50,6 +50,7 @@ ChatWidgetHeader::ChatWidgetHeader(ChatWidget *_chatWidget)
|
|||
this->leftMenu.addAction("Clear chat", this->chatWidget, &ChatWidget::doClearChat);
|
||||
this->leftMenu.addAction("Open channel", this->chatWidget, &ChatWidget::doOpenChannel);
|
||||
this->leftMenu.addAction("Open popup player", this->chatWidget, &ChatWidget::doOpenPopupPlayer);
|
||||
this->leftMenu.addAction("Open in Streamlink", this->chatWidget, &ChatWidget::doOpenStreamlink);
|
||||
this->leftMenu.addSeparator();
|
||||
this->leftMenu.addAction("Reload channel emotes", this, SLOT(menuReloadChannelEmotes()));
|
||||
this->leftMenu.addAction("Manual reconnect", this, SLOT(menuManualReconnect()));
|
||||
|
|
|
@ -312,6 +312,8 @@ void SettingsDialog::addTabs()
|
|||
auto scroll = new QSlider(Qt::Horizontal);
|
||||
form->addRow("Mouse scroll speed:", scroll);
|
||||
|
||||
form->addRow("Streamlink Path", createLineEdit(settings.streamlinkPath));
|
||||
|
||||
// v->addWidget(scroll);
|
||||
// v->addStretch(1);
|
||||
// vbox->addLayout(v);
|
||||
|
@ -583,6 +585,18 @@ QHBoxLayout *SettingsDialog::createCombobox(
|
|||
return box;
|
||||
}
|
||||
|
||||
QLineEdit *SettingsDialog::createLineEdit(pajlada::Settings::Setting<std::string> &setting)
|
||||
{
|
||||
auto widget = new QLineEdit(QString::fromStdString(setting.getValue()));
|
||||
|
||||
QObject::connect(widget, &QLineEdit::textChanged, this,
|
||||
[&setting](const QString &newValue) {
|
||||
setting = newValue.toStdString();
|
||||
});
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
void SettingsDialog::okButtonClicked()
|
||||
{
|
||||
this->close();
|
||||
|
|
|
@ -60,6 +60,7 @@ private:
|
|||
QHBoxLayout *createCombobox(const QString &title, pajlada::Settings::Setting<int> &setting,
|
||||
QStringList items,
|
||||
std::function<void(QString, pajlada::Settings::Setting<int> &)> cb);
|
||||
QLineEdit *createLineEdit(pajlada::Settings::Setting<std::string> &setting);
|
||||
|
||||
void okButtonClicked();
|
||||
void cancelButtonClicked();
|
||||
|
|
Loading…
Reference in a new issue