2018-06-26 14:09:39 +02:00
|
|
|
#include "QualityPopup.hpp"
|
|
|
|
#include "debug/Log.hpp"
|
|
|
|
#include "util/StreamLink.hpp"
|
2017-09-11 23:35:59 +02:00
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
2018-03-24 14:13:04 +01:00
|
|
|
QualityPopup::QualityPopup(const QString &_channelName, QStringList options)
|
|
|
|
: channelName(_channelName)
|
2017-09-11 23:35:59 +02:00
|
|
|
{
|
2018-06-11 15:04:54 +02:00
|
|
|
this->ui_.okButton.setText("OK");
|
|
|
|
this->ui_.cancelButton.setText("Cancel");
|
2017-09-11 23:35:59 +02:00
|
|
|
|
2018-06-11 15:04:54 +02:00
|
|
|
QObject::connect(&this->ui_.okButton, &QPushButton::clicked, this,
|
2017-12-17 16:45:15 +01:00
|
|
|
&QualityPopup::okButtonClicked);
|
2018-06-11 15:04:54 +02:00
|
|
|
QObject::connect(&this->ui_.cancelButton, &QPushButton::clicked, this,
|
2017-12-17 16:45:15 +01:00
|
|
|
&QualityPopup::cancelButtonClicked);
|
2017-09-11 23:35:59 +02:00
|
|
|
|
2018-06-11 15:04:54 +02:00
|
|
|
this->ui_.buttonBox.addButton(&this->ui_.okButton, QDialogButtonBox::ButtonRole::AcceptRole);
|
2018-06-26 17:20:03 +02:00
|
|
|
this->ui_.buttonBox.addButton(&this->ui_.cancelButton,
|
|
|
|
QDialogButtonBox::ButtonRole::RejectRole);
|
2017-09-11 23:35:59 +02:00
|
|
|
|
2018-06-11 15:04:54 +02:00
|
|
|
this->ui_.selector.addItems(options);
|
2017-09-11 23:35:59 +02:00
|
|
|
|
2018-06-11 15:04:54 +02:00
|
|
|
this->ui_.vbox.addWidget(&this->ui_.selector);
|
|
|
|
this->ui_.vbox.addWidget(&this->ui_.buttonBox);
|
2017-09-11 23:35:59 +02:00
|
|
|
|
2018-06-11 15:04:54 +02:00
|
|
|
this->setLayout(&this->ui_.vbox);
|
2017-09-11 23:35:59 +02:00
|
|
|
}
|
|
|
|
|
2018-03-24 14:13:04 +01:00
|
|
|
void QualityPopup::showDialog(const QString &channelName, QStringList options)
|
2017-12-17 16:45:15 +01:00
|
|
|
{
|
2018-03-24 14:13:04 +01:00
|
|
|
QualityPopup *instance = new QualityPopup(channelName, options);
|
2017-09-11 23:35:59 +02:00
|
|
|
|
2018-01-28 18:05:01 +01:00
|
|
|
instance->setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
|
2017-09-11 23:35:59 +02:00
|
|
|
instance->show();
|
|
|
|
instance->activateWindow();
|
|
|
|
instance->raise();
|
|
|
|
instance->setFocus();
|
|
|
|
}
|
|
|
|
|
2017-12-17 16:45:15 +01:00
|
|
|
void QualityPopup::okButtonClicked()
|
|
|
|
{
|
2018-03-24 14:13:04 +01:00
|
|
|
QString channelURL = "twitch.tv/" + this->channelName;
|
|
|
|
|
|
|
|
try {
|
2018-06-26 17:06:17 +02:00
|
|
|
OpenStreamlink(channelURL, this->ui_.selector.currentText());
|
|
|
|
} catch (const Exception &ex) {
|
|
|
|
Log("Exception caught trying to open streamlink: {}", ex.what());
|
2018-03-24 14:13:04 +01:00
|
|
|
}
|
|
|
|
|
2017-09-11 23:35:59 +02:00
|
|
|
this->close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QualityPopup::cancelButtonClicked()
|
|
|
|
{
|
|
|
|
this->close();
|
|
|
|
}
|
|
|
|
|
2017-12-17 16:45:15 +01:00
|
|
|
} // namespace chatterino
|