Skip to content

Commit

Permalink
Remove Qt::escape() -> QString::toHtmlEscaped() compatibility layer
Browse files Browse the repository at this point in the history
  • Loading branch information
davidebeatrici committed Oct 10, 2019
1 parent 062fe26 commit eea435d
Show file tree
Hide file tree
Showing 22 changed files with 62 additions and 94 deletions.
17 changes: 0 additions & 17 deletions src/Qt4Compat.h

This file was deleted.

2 changes: 0 additions & 2 deletions src/Utils.h
Expand Up @@ -8,8 +8,6 @@
#ifndef MUMBLE_UTILS_H_
#define MUMBLE_UTILS_H_

#include "Qt4Compat.h"

#include <QtCore/QtGlobal>

#define iroundf(x) ( static_cast<int>(x) )
Expand Down
4 changes: 2 additions & 2 deletions src/mumble/ALSAAudio.cpp
Expand Up @@ -338,7 +338,7 @@ void ALSAAudioInput::run() {
snd_pcm_close(capture_handle);
capture_handle = NULL;
}
g.mw->msgBox(tr("Opening chosen ALSA Input failed: %1").arg(Qt::escape(QLatin1String(snd_strerror(err)))));
g.mw->msgBox(tr("Opening chosen ALSA Input failed: %1").arg(QString::fromLatin1(snd_strerror(err)).toHtmlEscaped()));
return;
}

Expand Down Expand Up @@ -476,7 +476,7 @@ void ALSAAudioOutput::run() {
snd_pcm_writei(pcm_handle, zerobuff, period_size);

if (! bOk) {
g.mw->msgBox(tr("Opening chosen ALSA Output failed: %1").arg(Qt::escape(QLatin1String(snd_strerror(err)))));
g.mw->msgBox(tr("Opening chosen ALSA Output failed: %1").arg(QString::fromLatin1(snd_strerror(err)).toHtmlEscaped()));
if (pcm_handle) {
snd_pcm_close(pcm_handle);
pcm_handle = NULL;
Expand Down
4 changes: 2 additions & 2 deletions src/mumble/ASIOInput.cpp
Expand Up @@ -256,7 +256,7 @@ void ASIOConfig::on_qpbQuery_clicked() {
char err[255];
iasio->getErrorMessage(err);
SleepEx(10, false);
QMessageBox::critical(this, QLatin1String("Mumble"), tr("ASIO Initialization failed: %1").arg(Qt::escape(QLatin1String(err))), QMessageBox::Ok, QMessageBox::NoButton);
QMessageBox::critical(this, QLatin1String("Mumble"), tr("ASIO Initialization failed: %1").arg(QString::fromLatin1(err).toHtmlEscaped()), QMessageBox::Ok, QMessageBox::NoButton);
}
iasio->Release();
} else {
Expand All @@ -281,7 +281,7 @@ void ASIOConfig::on_qpbConfig_clicked() {
char err[255];
iasio->getErrorMessage(err);
SleepEx(10, false);
QMessageBox::critical(this, QLatin1String("Mumble"), tr("ASIO Initialization failed: %1").arg(Qt::escape(QLatin1String(err))), QMessageBox::Ok, QMessageBox::NoButton);
QMessageBox::critical(this, QLatin1String("Mumble"), tr("ASIO Initialization failed: %1").arg(QString::fromLatin1(err).toHtmlEscaped()), QMessageBox::Ok, QMessageBox::NoButton);
}
iasio->Release();
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/mumble/About.cpp
Expand Up @@ -36,9 +36,9 @@ AboutDialog::AboutDialog(QWidget *p) : QDialog(p) {
QList<LicenseInfo> thirdPartyLicenses = License::thirdPartyLicenses();
foreach(LicenseInfo li, thirdPartyLicenses) {
qtb3rdPartyLicense->append(QString::fromLatin1("<h3>%1 (<a href=\"%2\">%2</a>)</h3><pre>%3</pre>")
.arg(Qt::escape(li.name))
.arg(Qt::escape(li.url))
.arg(Qt::escape(li.license)));
.arg(li.name.toHtmlEscaped())
.arg(li.url.toHtmlEscaped())
.arg(li.license.toHtmlEscaped()));
}

qtb3rdPartyLicense->moveCursor(QTextCursor::Start);
Expand Down
4 changes: 2 additions & 2 deletions src/mumble/AudioConfigDialog.cpp
Expand Up @@ -371,7 +371,7 @@ void AudioInputDialog::on_qcbSystem_currentIndexChanged(int) {

foreach(audioDevice d, ql) {
qcbDevice->addItem(d.first, d.second);
qcbDevice->setItemData(idx, Qt::escape(d.first), Qt::ToolTipRole);
qcbDevice->setItemData(idx, d.first.toHtmlEscaped(), Qt::ToolTipRole);
++idx;
}

Expand Down Expand Up @@ -524,7 +524,7 @@ void AudioOutputDialog::on_qcbSystem_currentIndexChanged(int) {

foreach(audioDevice d, ql) {
qcbDevice->addItem(d.first, d.second);
qcbDevice->setItemData(idx, Qt::escape(d.first), Qt::ToolTipRole);
qcbDevice->setItemData(idx, d.first.toHtmlEscaped(), Qt::ToolTipRole);
++idx;
}
bool canmute = aor->canMuteOthers();
Expand Down
2 changes: 1 addition & 1 deletion src/mumble/AudioOutputSample.cpp
Expand Up @@ -194,7 +194,7 @@ QString AudioOutputSample::browseForSndfile(QString defaultpath) {
if (sf == NULL) {
QMessageBox::critical(NULL,
tr("Invalid sound file"),
tr("The file '%1' cannot be used by Mumble. Please select a file with a compatible format and encoding.").arg(Qt::escape(file)));
tr("The file '%1' cannot be used by Mumble. Please select a file with a compatible format and encoding.").arg(file.toHtmlEscaped()));
return QString();
}
delete sf;
Expand Down
2 changes: 1 addition & 1 deletion src/mumble/Cert.cpp
Expand Up @@ -104,7 +104,7 @@ void CertView::setCert(const QList<QSslCertificate> &cert) {
qlSubjectEmail->setText(tr("(none)"));

if (qscCert.expiryDate() <= QDateTime::currentDateTime())
qlExpiry->setText(QString::fromLatin1("<font color=\"red\"><b>%1</b></font>").arg(Qt::escape(qscCert.expiryDate().toString(Qt::SystemLocaleDate))));
qlExpiry->setText(QString::fromLatin1("<font color=\"red\"><b>%1</b></font>").arg(qscCert.expiryDate().toString(Qt::SystemLocaleDate).toHtmlEscaped()));
else
qlExpiry->setText(qscCert.expiryDate().toString(Qt::SystemLocaleDate));

Expand Down
13 changes: 7 additions & 6 deletions src/mumble/ConnectDialog.cpp
Expand Up @@ -521,7 +521,8 @@ QVariant ServerItem::data(int column, int role) const {
} else if (role == Qt::ToolTipRole) {
QStringList qsl;
foreach(const ServerAddress &addr, qlAddresses) {
qsl << Qt::escape(addr.host.toString() + QLatin1String(":") + QString::number(static_cast<unsigned long>(addr.port)));
const QString qsAddress = addr.host.toString() + QLatin1String(":") + QString::number(static_cast<unsigned long>(addr.port));
qsl << qsAddress.toHtmlEscaped();
}

double ploss = 100.0;
Expand All @@ -532,18 +533,18 @@ QVariant ServerItem::data(int column, int role) const {
QString qs;
qs +=
QLatin1String("<table>") +
QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Servername"), Qt::escape(qsName)) +
QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Hostname"), Qt::escape(qsHostname));
QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Servername"), qsName.toHtmlEscaped()) +
QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Hostname"), qsHostname.toHtmlEscaped());

if (! qsBonjourHost.isEmpty())
qs += QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Bonjour name"), Qt::escape(qsBonjourHost));
qs += QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Bonjour name"), qsBonjourHost.toHtmlEscaped());

qs +=
QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Port")).arg(usPort) +
QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Addresses"), qsl.join(QLatin1String(", ")));

if (! qsUrl.isEmpty())
qs += QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Website"), Qt::escape(qsUrl));
qs += QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Website"), qsUrl.toHtmlEscaped());

if (uiSent > 0) {
qs += QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>").arg(ConnectDialog::tr("Packet loss"), QString::fromLatin1("%1% (%2/%3)").arg(ploss, 0, 'f', 1).arg(uiRecv).arg(uiSent));
Expand Down Expand Up @@ -723,7 +724,7 @@ QMimeData *ServerItem::toMimeData(const QString &name, const QString &host, unsi
mime->setUrls(urls);

mime->setText(qs);
mime->setHtml(QString::fromLatin1("<a href=\"%1\">%2</a>").arg(qs).arg(Qt::escape(name)));
mime->setHtml(QString::fromLatin1("<a href=\"%1\">%2</a>").arg(qs).arg(name.toHtmlEscaped()));

return mime;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mumble/Database.cpp
Expand Up @@ -100,7 +100,7 @@ Database::Database(const QString &dbname) {
QFileInfo fi(db.databaseName());

if (! fi.isWritable()) {
QMessageBox::critical(NULL, QLatin1String("Mumble"), tr("The database '%1' is read-only. Mumble cannot store server settings (i.e. SSL certificates) until you fix this problem.").arg(Qt::escape(fi.filePath())), QMessageBox::Ok | QMessageBox::Default, QMessageBox::NoButton);
QMessageBox::critical(NULL, QLatin1String("Mumble"), tr("The database '%1' is read-only. Mumble cannot store server settings (i.e. SSL certificates) until you fix this problem.").arg(fi.filePath().toHtmlEscaped()), QMessageBox::Ok | QMessageBox::Default, QMessageBox::NoButton);
qWarning("Database: Database is read-only");
}

Expand Down
2 changes: 1 addition & 1 deletion src/mumble/LCD.cpp
Expand Up @@ -88,7 +88,7 @@ LCDConfig::LCDConfig(Settings &st) : ConfigWidget(st) {
qtwi->setFlags(Qt::ItemIsEnabled |Qt::ItemIsUserCheckable);

qtwi->setText(0, d->name());
qtwi->setToolTip(0, Qt::escape(d->name()));
qtwi->setToolTip(0, d->name().toHtmlEscaped());

QSize lcdsize = d->size();
QString qsSize = QString::fromLatin1("%1x%2").arg(lcdsize.width()).arg(lcdsize.height());
Expand Down
8 changes: 4 additions & 4 deletions src/mumble/Log.cpp
Expand Up @@ -301,7 +301,7 @@ QString Log::msgColor(const QString &text, LogColorType t) {
}

QString Log::formatChannel(::Channel *c) {
return QString::fromLatin1("<a href='channelid://%1/%3' class='log-channel'>%2</a>").arg(c->iId).arg(Qt::escape(c->qsName)).arg(QString::fromLatin1(g.sh->qbaDigest.toBase64()));
return QString::fromLatin1("<a href='channelid://%1/%3' class='log-channel'>%2</a>").arg(c->iId).arg(c->qsName.toHtmlEscaped()).arg(QString::fromLatin1(g.sh->qbaDigest.toBase64()));
}

QString Log::formatClientUser(ClientUser *cu, LogColorType t, const QString &displayName) {
Expand All @@ -313,7 +313,7 @@ QString Log::formatClientUser(ClientUser *cu, LogColorType t, const QString &dis
}

if (cu) {
QString name = Qt::escape(displayName.isNull() ? cu->qsName : displayName);
QString name = (displayName.isNull() ? cu->qsName : displayName).toHtmlEscaped();
if (cu->qsHash.isEmpty()) {
return QString::fromLatin1("<a href='clientid://%2/%4' class='log-user log-%1'>%3</a>").arg(className).arg(cu->uiSession).arg(name).arg(QString::fromLatin1(g.sh->qbaDigest.toBase64()));
} else {
Expand Down Expand Up @@ -489,7 +489,7 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
if (qdDate != dt.date()) {
qdDate = dt.date();
tc.insertBlock();
tc.insertHtml(tr("[Date changed to %1]\n").arg(Qt::escape(qdDate.toString(Qt::DefaultLocaleShortDate))));
tc.insertHtml(tr("[Date changed to %1]\n").arg(qdDate.toString(Qt::DefaultLocaleShortDate).toHtmlEscaped()));
tc.movePosition(QTextCursor::End);
}

Expand All @@ -502,7 +502,7 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
} else if (! g.mw->qteLog->document()->isEmpty()) {
tc.insertBlock();
}
tc.insertHtml(Log::msgColor(QString::fromLatin1("[%1] ").arg(Qt::escape(dt.time().toString())), Log::Time));
tc.insertHtml(Log::msgColor(QString::fromLatin1("[%1] ").arg(dt.time().toString().toHtmlEscaped()), Log::Time));
validHtml(console, &tc);
tc.movePosition(QTextCursor::End);
g.mw->qteLog->setTextCursor(tc);
Expand Down

0 comments on commit eea435d

Please sign in to comment.