diff --git a/src/configeditor.cpp b/src/configeditor.cpp index 8d04f8a..d6caa00 100644 --- a/src/configeditor.cpp +++ b/src/configeditor.cpp @@ -15,7 +15,6 @@ * along with Subtivals. If not, see **/ #include -#include #include #include #include diff --git a/src/main.cpp b/src/main.cpp index 1ae2516..fa4b6b5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,11 +18,12 @@ #include #include #include -#include -#include #include #include #include +#include +#include +#include #include "configeditor.h" #include "mainwindow.h" @@ -31,13 +32,6 @@ #include "weblive.h" int main(int argc, char *argv[]) { - // Load Let's Encrypts issuer certificate (WebLive feature). - QFile file(":/ssl/lets-encrypt-r3.pem"); - file.open(QIODevice::ReadOnly); - const QByteArray bytes = file.readAll(); - const QSslCertificate certificate(bytes); - QSslSocket::addDefaultCaCertificate(certificate); - // Load settings from profile. QSettings::setDefaultFormat(QSettings::IniFormat); QCoreApplication::setOrganizationName("Subtivals"); @@ -63,23 +57,23 @@ int main(int argc, char *argv[]) { WebLive live; // Live - QObject::connect(w.player(), SIGNAL(on(Subtitle *)), &live, - SLOT(addSubtitle(Subtitle *))); - QObject::connect(w.player(), SIGNAL(off(Subtitle *)), &live, - SLOT(remSubtitle(Subtitle *))); + QObject::connect(w.player(), SIGNAL(on(Subtitle*)), &live, + SLOT(addSubtitle(Subtitle*))); + QObject::connect(w.player(), SIGNAL(off(Subtitle*)), &live, + SLOT(remSubtitle(Subtitle*))); QObject::connect(w.player(), SIGNAL(clear()), &live, SLOT(clearSubtitles()), Qt::DirectConnection); QObject::connect(w.configEditor(), SIGNAL(webliveEnabled(bool)), &live, SLOT(enable(bool))); - QObject::connect(&live, SIGNAL(connected(bool, QString)), w.configEditor(), - SLOT(webliveConnected(bool, QString))); + QObject::connect(&live, SIGNAL(connected(bool,QString)), w.configEditor(), + SLOT(webliveConnected(bool,QString))); w.configEditor()->enableWeblive(live.configured()); // Projection screen - QObject::connect(w.player(), SIGNAL(on(Subtitle *)), &f, - SLOT(addSubtitle(Subtitle *))); - QObject::connect(w.player(), SIGNAL(off(Subtitle *)), &f, - SLOT(remSubtitle(Subtitle *))); + QObject::connect(w.player(), SIGNAL(on(Subtitle*)), &f, + SLOT(addSubtitle(Subtitle*))); + QObject::connect(w.player(), SIGNAL(off(Subtitle*)), &f, + SLOT(remSubtitle(Subtitle*))); QObject::connect(w.player(), SIGNAL(clear()), &f, SLOT(clearSubtitles()), Qt::DirectConnection); QObject::connect(&w, SIGNAL(toggleHide(bool)), &f, SLOT(toggleHide(bool))); @@ -87,16 +81,16 @@ int main(int argc, char *argv[]) { SLOT(screenResizable(bool))); QObject::connect(&f, SIGNAL(geometryChanged(QRect)), w.configEditor(), SLOT(screenChanged(QRect))); - QObject::connect(w.configEditor(), SIGNAL(changeScreen(int, QRect)), &f, - SLOT(changeGeometry(int, QRect))); + QObject::connect(w.configEditor(), SIGNAL(changeScreen(int,QRect)), &f, + SLOT(changeGeometry(int,QRect))); QObject::connect(w.configEditor(), SIGNAL(hideDesktop(bool)), &f, SLOT(toggleHideDesktop(bool))); QObject::connect(w.configEditor(), SIGNAL(rotate(double)), &f, SLOT(rotate(double))); QObject::connect(w.configEditor(), SIGNAL(color(QColor)), &f, SLOT(color(QColor))); - QObject::connect(w.configEditor(), SIGNAL(outline(QColor, int)), &f, - SLOT(outline(QColor, int))); + QObject::connect(w.configEditor(), SIGNAL(outline(QColor,int)), &f, + SLOT(outline(QColor,int))); QObject::connect(w.configEditor(), SIGNAL(styleChanged()), &f, SLOT(repaint())); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index deb4002..5f05b34 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -14,25 +14,27 @@ * You should have received a copy of the GNU General Public License * along with Subtivals. If not, see **/ -#include -#include -#include -#include #include #include #include #include #include -#include +#include #include +#include #include #include #include #include #include +#include #include #include +#include +#include +#include + #include "configeditor.h" #include "mainwindow.h" @@ -41,6 +43,7 @@ #include "ui_mainwindow.h" #include "wizard.h" +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) /** * A small delegate class to allow rich text rendering in main table cells. */ @@ -102,6 +105,7 @@ class SubtitleDurationDelegate : public QStyledItemDelegate { painter->restore(); } }; +#endif MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), m_script(nullptr), @@ -113,12 +117,14 @@ MainWindow::MainWindow(QWidget *parent) m_scriptProperties(new QLabel(this)), m_countDown(new QLabel(this)) { ui->setupUi(this); m_defaultPalette = qApp->palette(); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) ui->tableWidget->setItemDelegateForColumn(COLUMN_START, new SubtitleDurationDelegate()); ui->tableWidget->setItemDelegateForColumn(COLUMN_END, new SubtitleDurationDelegate()); ui->tableWidget->setItemDelegateForColumn(COLUMN_TEXT, new SubtitleTextDelegate()); +#endif ui->tableWidget->hideColumn(COLUMN_COMMENTS); ui->tableWidget->installEventFilter(this); @@ -306,7 +312,7 @@ void MainWindow::showEvent(QShowEvent *) { resize(settings.value("size", size()).toSize()); // Place window at center, below black screen by default. - QRect screenGeom = qApp->desktop()->screenGeometry(); + QRect screenGeom = qApp->primaryScreen()->geometry(); int center = (screenGeom.width() - geometry().width()) / 2; int decorationHeight = style()->pixelMetric(QStyle::PM_TitleBarHeight); QPoint pos(center, DEFAULT_HEIGHT + decorationHeight); @@ -382,7 +388,6 @@ void MainWindow::actionOperatorPrintout() { } QTextStream out(&file); - out.setCodec("UTF-8"); out.setGenerateByteOrderMark(true); out << m_script->exportList(Script::CSV); file.close(); @@ -951,15 +956,15 @@ void MainWindow::subtitleChanged(QList p_currentSubtitles) { } void MainWindow::highlightSubtitles(qlonglong elapsed) { - QColor off = qApp->palette().color(QPalette::Base); - QColor on = qApp->palette().color(QPalette::Highlight).lighter(130); - QColor next = qApp->palette().color(QPalette::Highlight).lighter(170); + QBrush off = QBrush(qApp->palette().color(QPalette::Base)); + QBrush on = QBrush(qApp->palette().color(QPalette::Highlight).lighter(130)); + QBrush next = QBrush(qApp->palette().color(QPalette::Highlight).lighter(170)); // First reset all for (int row = 0; row < ui->tableWidget->rowCount(); row++) { for (int col = 0; col < ui->tableWidget->columnCount(); col++) { QTableWidgetItem *item = ui->tableWidget->item(row, col); - item->setBackgroundColor(off); + item->setBackground(off); QFont f = item->font(); f.setBold(false); item->setFont(f); @@ -974,7 +979,7 @@ void MainWindow::highlightSubtitles(qlonglong elapsed) { int row = m_tableMapping[e]; for (int col = 0; col < ui->tableWidget->columnCount(); col++) { QTableWidgetItem *item = ui->tableWidget->item(row, col); - item->setBackgroundColor(next); + item->setBackground(next); } } // Finally highlight current subtitles @@ -987,7 +992,7 @@ void MainWindow::highlightSubtitles(qlonglong elapsed) { f.setBold(true); item->setFont(f); } - item->setBackgroundColor(on); + item->setBackground(on); if (col == COLUMN_TEXT) item->setData(Qt::UserRole, !ui->actionHide->isChecked()); } @@ -1154,7 +1159,7 @@ void MainWindow::enableKnownFactors(bool p_state) { ui->knownFactors->setSizeAdjustPolicy(QComboBox::AdjustToContents); } else { ui->knownFactors->setSizeAdjustPolicy( - QComboBox::AdjustToMinimumContentsLength); + QComboBox::AdjustToMinimumContentsLengthWithIcon); } } diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 1d835cb..d8284a9 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -120,7 +120,7 @@ Common framerates conversions - QComboBox::AdjustToMinimumContentsLength + QComboBox::AdjustToMinimumContentsLengthWithIcon @@ -1204,6 +1204,7 @@ actionShowWizard() actionOperatorPrintout() actionJumpLongest() + actionAdvancedSettings() speedFactorChanged(double) knownFactorChosen(int) actionToggleDarkMode(bool) diff --git a/src/script.cpp b/src/script.cpp index 7b8bc05..9d81203 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -16,12 +16,12 @@ **/ #include #include -#include #include #include #include #include #include +#include #include "script.h" @@ -40,7 +40,7 @@ bool compareSubtitleStartTime(const Subtitle *s1, const Subtitle *s2) { QString sp2nbsp(const QString s) { // Replace multiple spaces between words by non breakable spaces - if (QRegExp("\\S\\s{2,}\\S").exactMatch(s)) { + if (QRegularExpression("\\S\\s{2,}\\S").match(s).hasMatch()) { return QString(s).replace(" ", " "); } return s; @@ -88,7 +88,7 @@ Script::Script(const QString &p_fileName, int p_charsRate, m_format = XML; loadFromXml(content.join("")); } - qSort(m_subtitles.begin(), m_subtitles.end(), compareSubtitleStartTime); + std::sort(m_subtitles.begin(), m_subtitles.end(), compareSubtitleStartTime); } Script::ScriptFormat Script::format() const { return m_format; } @@ -283,7 +283,7 @@ void Script::loadFromAss(QStringList content) { QString text = value.mid(p + 1); text = text.trimmed(); // New-lines : ignore at start - text = text.replace(QRegExp("^(\\\\[nN])+"), ""); + text = text.replace(QRegularExpression("^(\\\\[nN])+"), ""); // Transform the hints in the text into HTML: // Italic HTML-ification @@ -295,17 +295,18 @@ void Script::loadFromAss(QStringList content) { text = sp2nbsp(text); QList lines; - foreach (QString line, text.split(QRegExp("\\\\[nN]"))) { + foreach (QString line, text.split(QRegularExpression("\\\\[nN]"))) { // Absolute positioning int x = -1; int y = -1; //{\pos(x,y)} or {\pos(x)} in the beginning of the line - QRegExp rx("\\{\\\\pos\\((\\d+)(,(\\d+))?\\)\\}"); - if (rx.indexIn(line) >= 0) { - QStringList strpos = rx.capturedTexts(); - x = strpos[1].toInt(); - if (!strpos[3].isEmpty()) - y = strpos[3].toInt(); + QRegularExpression rx("\\{\\\\pos\\((\\d+)(,(\\d+))?\\)\\}"); + QRegularExpressionMatch match = rx.match(line); + if (match.hasMatch()) { + x = match.captured(1).toInt(); // Group 1: The first number (x) + if (!match.captured(3).isEmpty()) { + y = match.captured(3).toInt(); // Group 3: The second number (y) + } } // Color HTML-ification @@ -326,7 +327,7 @@ void Script::loadFromAss(QStringList content) { } // Drop others hints that cannot be translated in HTML - lines.append(SubtitleLine(line.replace(QRegExp("\\{.*\\}"), ""), + lines.append(SubtitleLine(line.replace(QRegularExpression("\\{.*\\}"), ""), QPoint(x, y))); } @@ -381,10 +382,10 @@ void Script::loadFromSrt(QStringList content) { int start = 0; int end = 0; foreach (QString line, content) { - if (section == SECTION_NONE && QRegExp("^[0-9]+$").exactMatch(line)) { + if (section == SECTION_NONE && QRegularExpression("^[0-9]+$").match(line).hasMatch()) { section = SECTION_INFOS; } else if (section == SECTION_INFOS) { - QStringList subparts = line.split(QRegExp("\\s+\\-\\->\\s+")); + QStringList subparts = line.split(QRegularExpression("\\s+\\-\\->\\s+")); start = QTime(0, 0, 0).msecsTo(QTime::fromString(subparts[0], "h:mm:ss,z")); end = QTime(0, 0, 0).msecsTo(QTime::fromString(subparts[1], "h:mm:ss,z")); @@ -434,13 +435,13 @@ void Script::loadFromTxt(QStringList content) { if (section == SECTION_NONE) { section = SECTION_EVENTS; - QRegExp times("^([0-9:]+) ([0-9:]+)"); - if (times.indexIn(line) >= 0) { - QStringList subparts = times.capturedTexts(); + QRegularExpression times("^([0-9:]+) ([0-9:]+)"); + QRegularExpressionMatch match = times.match(line); + if (match.hasMatch()) { start = - QTime(0, 0, 0).msecsTo(QTime::fromString(subparts[1], "h:mm:ss:z")); + QTime(0, 0, 0).msecsTo(QTime::fromString(match.captured(1), "h:mm:ss:z")); end = - QTime(0, 0, 0).msecsTo(QTime::fromString(subparts[2], "h:mm:ss:z")); + QTime(0, 0, 0).msecsTo(QTime::fromString(match.captured(2), "h:mm:ss:z")); continue; } } @@ -460,9 +461,9 @@ void Script::loadFromTxt(QStringList content) { comments = line.replace("#", ""); } else { // In TXT format : is equivalent to word - line = line.replace(QRegExp("<([^i/][^>]+)>"), "\\1"); + line = line.replace(QRegularExpression("<([^i/][^>]+)>"), "\\1"); // and *word* is equivalent to word - line = line.replace(QRegExp("\\*([^\\*]+)\\*"), "\\1"); + line = line.replace(QRegularExpression("\\*([^\\*]+)\\*"), "\\1"); line = sp2nbsp(line); text.append(line); } @@ -516,7 +517,7 @@ void Script::loadFromXml(QString content) { fontNode.toElement().attribute("Size", "DEFAULT_FONT_SIZE").toInt()); defaultFont.setUnderline( (fontNode.toElement().attribute("Underlined", "no") != "no")); - defaultColor.setNamedColor(QString("#%1").arg( + defaultColor = QColor::fromString(QString("#%1").arg( fontNode.toElement().attribute("Color", "FFFFFFFF"))); } diff --git a/src/shortcuteditor.cpp b/src/shortcuteditor.cpp index 8b7e455..5b99172 100644 --- a/src/shortcuteditor.cpp +++ b/src/shortcuteditor.cpp @@ -14,12 +14,12 @@ ShortcutEditor::ShortcutEditor(QWidget *parent) ui->tableActions->horizontalHeader()->setResizeMode(COLUMN_DESCRIPTION, QHeaderView::Stretch); #endif - connect(ui->tableActions, SIGNAL(itemPressed(QTableWidgetItem *)), this, - SLOT(recordAction(QTableWidgetItem *))); - connect(ui->tableActions, SIGNAL(itemChanged(QTableWidgetItem *)), this, - SLOT(validateAction(QTableWidgetItem *))); - connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton *)), this, - SLOT(onClicked(QAbstractButton *))); + connect(ui->tableActions, SIGNAL(itemPressed(QTableWidgetItem*)), this, + SLOT(recordAction(QTableWidgetItem*))); + connect(ui->tableActions, SIGNAL(itemChanged(QTableWidgetItem*)), this, + SLOT(validateAction(QTableWidgetItem*))); + connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, + SLOT(onClicked(QAbstractButton*))); } ShortcutEditor::~ShortcutEditor() { delete ui; } diff --git a/src/style.cpp b/src/style.cpp index cb4602a..f1514b7 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "script.h" #include "style.h" @@ -99,7 +100,7 @@ const QPoint Style::textAnchor(const QPoint &p_point, QPoint offset(0, 0); // Make sure text contains no HTML QString strip(p_text); - strip.remove(QRegExp("<[^>]*>")); + strip.remove(QRegularExpression("<[^>]*>")); // alignment becomes text anchor if (m_alignment & Qt::AlignVCenter) { offset.setY(m_metrics.height() / 2); @@ -107,9 +108,9 @@ const QPoint Style::textAnchor(const QPoint &p_point, offset.setY(m_metrics.height()); } if (m_alignment & Qt::AlignHCenter) { - offset.setX(-m_metrics.width(strip) / 2); + offset.setX(-m_metrics.boundingRect(strip).width() / 2); } else if (m_alignment & Qt::AlignRight) { - offset.setX(-m_metrics.width(strip)); + offset.setX(-m_metrics.boundingRect(strip).width()); } return p_point + offset; } diff --git a/src/style.h b/src/style.h index 42f6732..96e78e3 100644 --- a/src/style.h +++ b/src/style.h @@ -38,6 +38,9 @@ class Style : public QObject { explicit Style(const Style &p_oth, QObject *p_parent = nullptr); explicit Style(const Style &p_oth, const QFont &f, QObject *p_parent = nullptr); + // Disables copying + Style(const Style&) = delete; + const QString &name() const; void setName(const QString &p_name); const QFont &font() const; diff --git a/src/styleeditor.ui b/src/styleeditor.ui index 5420317..b52d43d 100644 --- a/src/styleeditor.ui +++ b/src/styleeditor.ui @@ -289,9 +289,9 @@ - styleSelected(int) apply() chooseColour() advancedConfig() + styleSelected() diff --git a/src/subtitle.cpp b/src/subtitle.cpp index a18edd6..5a7c1a6 100644 --- a/src/subtitle.cpp +++ b/src/subtitle.cpp @@ -15,7 +15,7 @@ * along with Subtivals. If not, see **/ #include - +#include #include "script.h" #include "subtitle.h" @@ -110,19 +110,21 @@ void Subtitle::setText(const QList p_lines) { foreach (SubtitleLine line, p_lines) { // Remove paired tags QString unpaired = line.text(); - unpaired = unpaired.replace(QRegExp("[^<]+($|)"), ""); - unpaired = unpaired.replace(QRegExp("[^<]+($|)"), ""); + unpaired = unpaired.replace(QRegularExpression("[^<]+($|)"), ""); + unpaired = unpaired.replace(QRegularExpression("[^<]+($|)"), ""); // Now unpaired has no paired tags anymore. // For all close tags, add an open tag at the beginning. // (Note: we don't bother repairing unclosed tag, // because it does not affect display) - QRegExp rx(""); int pos = 0; + QRegularExpression rx(""); + QRegularExpressionMatch match; QString lineText = line.text(); - while ((pos = rx.indexIn(unpaired, pos)) != -1) { - lineText = QString("<%1>").arg(rx.cap(1)) + lineText; - pos += rx.matchedLength(); + while ((match = rx.match(unpaired, pos)).hasMatch()) { + QString capturedTag = match.captured(1); // Captures the group (e.g., "b" or "i") + lineText = QString("<%1>").arg(capturedTag) + lineText; + pos = match.capturedEnd(); // Update position to continue matching } m_lines.append(SubtitleLine(lineText, line.position())); } @@ -134,10 +136,10 @@ void Subtitle::setText(const QList p_lines) { m_text = lines.join("
"); // Strip everything for character count m_pureText = lines.join(" "); - m_pureText = m_pureText.replace(QRegExp("]+>"), ""); + m_pureText = m_pureText.replace(QRegularExpression("]+>"), ""); // Keep bold and italic for displayed text m_prettyText = lines.join(" # "); - m_prettyText = m_prettyText.replace(QRegExp("]+>"), ""); + m_prettyText = m_prettyText.replace(QRegularExpression("]+>"), ""); } void Subtitle::setComments(const QString &p_comments) { diff --git a/src/subtitlesform.cpp b/src/subtitlesform.cpp index e99215c..2b9da40 100644 --- a/src/subtitlesform.cpp +++ b/src/subtitlesform.cpp @@ -14,11 +14,11 @@ * You should have received a copy of the GNU General Public License * along with Subtivals. If not, see **/ -#include #include #include #include #include +#include #include "style.h" #include "subtitlesform.h" @@ -63,8 +63,9 @@ void SubtitlesForm::toggleHide(bool state) { } void SubtitlesForm::toggleHideDesktop(bool state) { - m_hideDesktop = (state && QApplication::desktop()->screenCount() > 1 && - m_monitor != QApplication::desktop()->primaryScreen()); + int idxPrimary = QGuiApplication::screens().indexOf(QGuiApplication::primaryScreen()); + m_hideDesktop = (state && QGuiApplication::screens().length() > 1 && + m_monitor != idxPrimary); if (m_hideDesktop) setGeometry(m_screenGeom); else @@ -74,7 +75,7 @@ void SubtitlesForm::toggleHideDesktop(bool state) { void SubtitlesForm::changeGeometry(int monitor, const QRect &r) { m_monitor = monitor; - m_screenGeom = QApplication::desktop()->screenGeometry(monitor); + m_screenGeom = QGuiApplication::screens().at(monitor)->geometry(); // This is sent from UI, add screen geometry m_subtitlesGeom = QRect(m_screenGeom.x() + r.x(), @@ -125,7 +126,7 @@ void SubtitlesForm::paintEvent(QPaintEvent *) { } void SubtitlesForm::mousePressEvent(QMouseEvent *e) { - m_mouseOffset = e->globalPos() - geometry().topLeft(); + m_mouseOffset = e->globalPosition() - geometry().topLeft(); } void SubtitlesForm::mouseMoveEvent(QMouseEvent *e) { @@ -137,8 +138,8 @@ void SubtitlesForm::mouseMoveEvent(QMouseEvent *e) { // Simply move the window on mouse drag QRect current = geometry(); - QPoint moveTo = e->globalPos() - m_mouseOffset; - current.moveTopLeft(moveTo); + QPointF moveTo = e->globalPosition() - m_mouseOffset; + current.moveTopLeft(moveTo.toPoint()); changeGeometry(current); } @@ -154,9 +155,8 @@ void SubtitlesForm::wheelEvent(QWheelEvent *event) { int step = 24; if (event->modifiers().testFlag(Qt::ShiftModifier)) step = 60; - int factor = event->delta() / step; - if (event->orientation() == Qt::Horizontal || - event->modifiers().testFlag(Qt::ControlModifier)) { + int factor = event->angleDelta().y() / step; + if (event->modifiers().testFlag(Qt::ControlModifier)) { current.setHeight(current.height() + factor); } else { current.moveLeft(current.left() - factor / 2); // Keep centered diff --git a/src/subtitlesform.h b/src/subtitlesform.h index 2ba7098..a0e3ef5 100644 --- a/src/subtitlesform.h +++ b/src/subtitlesform.h @@ -61,7 +61,7 @@ public slots: Ui::SubtitlesForm *ui; QList m_currentSubtitles; bool m_visible; - QPoint m_mouseOffset; + QPointF m_mouseOffset; QRect m_screenGeom; QRect m_subtitlesGeom; bool m_hideDesktop; diff --git a/src/subtivals.pro b/src/subtivals.pro index cb5c53e..d549a13 100644 --- a/src/subtivals.pro +++ b/src/subtivals.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += core gui widgets websockets xml +QT += core core5compat gui widgets websockets xml TARGET = subtivals TEMPLATE = app diff --git a/src/weblive.cpp b/src/weblive.cpp index d22c4a4..2cf271a 100644 --- a/src/weblive.cpp +++ b/src/weblive.cpp @@ -2,6 +2,9 @@ #include #include #include +#include +#include +#include #include "style.h" #include "weblive.h" @@ -13,6 +16,17 @@ WebLive::WebLive(QObject *parent) : QObject(parent), m_configured(false), m_enabled(false) { + + // Load Let's Encrypts issuer certificate (WebLive feature). + QFile file(":/ssl/lets-encrypt-r3.pem"); + file.open(QIODevice::ReadOnly); + const QByteArray bytes = file.readAll(); + const QSslCertificate certificate(bytes); + + QSslConfiguration sslConfiguration(QSslConfiguration::defaultConfiguration()); + sslConfiguration.addCaCertificate(certificate); + m_webSocket.setSslConfiguration(sslConfiguration); + // Reload from settings QSettings settings; settings.beginGroup(QString("Weblive")); @@ -91,8 +105,9 @@ void WebLive::onError() { } QString WebLive::liveUrl() const { - QByteArray ba; - ba.append(QString("%1|%2").arg(m_server.toString()).arg(m_secret)); + QString urlSecret = QString("%1|%2").arg(m_server.toString()).arg(m_secret); + auto fromUtf8 = QStringEncoder(QStringEncoder::Utf8); + QByteArray ba = fromUtf8(urlSecret); QString key = ba.toBase64(); return QString("%1/#%2").arg(m_liveUrl.toString()).arg(key); }