2017-09-16 16:20:10 +02:00
|
|
|
#include "qualitypopup.hpp"
|
2017-09-11 23:35:59 +02:00
|
|
|
|
|
|
|
#include <QProcess>
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
namespace widgets {
|
|
|
|
|
|
|
|
QualityPopup::QualityPopup(const QString &channel, const QString &path, QStringList options)
|
2018-01-14 21:55:36 +01:00
|
|
|
: BaseWindow()
|
2017-12-17 16:45:15 +01:00
|
|
|
, channel(channel)
|
2017-09-11 23:35:59 +02:00
|
|
|
, path(path)
|
|
|
|
{
|
|
|
|
this->ui.okButton.setText("OK");
|
|
|
|
this->ui.cancelButton.setText("Cancel");
|
|
|
|
|
2017-12-17 16:45:15 +01:00
|
|
|
QObject::connect(&this->ui.okButton, &QPushButton::clicked, this,
|
|
|
|
&QualityPopup::okButtonClicked);
|
2017-09-11 23:35:59 +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
|
|
|
|
|
|
|
this->ui.buttonBox.addButton(&this->ui.okButton, QDialogButtonBox::ButtonRole::AcceptRole);
|
|
|
|
this->ui.buttonBox.addButton(&this->ui.cancelButton, QDialogButtonBox::ButtonRole::RejectRole);
|
|
|
|
|
|
|
|
for (int i = 0; i < options.length(); ++i) {
|
|
|
|
this->ui.selector.addItem(options.at(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
this->ui.vbox.addWidget(&this->ui.selector);
|
|
|
|
this->ui.vbox.addWidget(&this->ui.buttonBox);
|
|
|
|
|
|
|
|
this->setLayout(&this->ui.vbox);
|
|
|
|
}
|
|
|
|
|
2017-12-17 16:45:15 +01:00
|
|
|
void QualityPopup::showDialog(const QString &channel, const QString &path, QStringList options)
|
|
|
|
{
|
2018-01-28 15:10:12 +01:00
|
|
|
QualityPopup *instance = new QualityPopup(channel, path, 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-01-28 15:10:12 +01:00
|
|
|
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
2018-01-28 18:05:01 +01:00
|
|
|
QProcess::startDetached(this->path, {"twitch.tv/" + this->channel,
|
|
|
|
this->ui.selector.currentText(), settings.streamlinkOpts});
|
2017-09-11 23:35:59 +02:00
|
|
|
this->close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QualityPopup::cancelButtonClicked()
|
|
|
|
{
|
|
|
|
this->close();
|
|
|
|
}
|
|
|
|
|
2017-12-17 16:45:15 +01:00
|
|
|
} // namespace widgets
|
|
|
|
} // namespace chatterino
|