Use QStringLiteral

This commit is contained in:
Jonas Kvinge
2024-04-09 23:20:26 +02:00
parent 3cfffa5fbb
commit 58944993b8
233 changed files with 3885 additions and 3885 deletions

View File

@@ -146,7 +146,7 @@ void OSDBase::ShowPlaying(const Song &song, const QUrl &cover_url, const QImage
else {
summary = song.PrettyTitle();
if (!song.artist().isEmpty()) {
summary = QString("%1 - %2").arg(song.artist(), summary);
summary = QStringLiteral("%1 - %2").arg(song.artist(), summary);
}
if (!song.album().isEmpty()) {
message_parts << song.album();
@@ -168,14 +168,14 @@ void OSDBase::ShowPlaying(const Song &song, const QUrl &cover_url, const QImage
#endif
}
QString message = message_parts.join(", ");
QString message = message_parts.join(QStringLiteral(", "));
if (html_escaped) message = message.toHtmlEscaped();
if (show_art_) {
ShowMessage(summary, message, "notification-audio-play", image);
ShowMessage(summary, message, QStringLiteral("notification-audio-play"), image);
}
else {
ShowMessage(summary, message, "notification-audio-play", QImage());
ShowMessage(summary, message, QStringLiteral("notification-audio-play"), QImage());
}
// Reload the saved settings if they were changed for preview
@@ -378,7 +378,7 @@ QString OSDBase::ReplaceMessage(const MessageType type, const QString &message,
#endif
bool html_escaped = false;
QString newline = "";
QString newline = QLatin1String("");
// We need different strings depending on notification type
switch (behaviour_) {
@@ -391,12 +391,12 @@ QString OSDBase::ReplaceMessage(const MessageType type, const QString &message,
switch (type) {
case MessageType::Summary:{
html_escaped = false;
newline = "";
newline = QLatin1String("");
break;
}
case MessageType::Message: {
html_escaped = true;
newline = "<br />";
newline = QStringLiteral("<br />");
break;
}
}
@@ -411,12 +411,12 @@ QString OSDBase::ReplaceMessage(const MessageType type, const QString &message,
case Behaviour::TrayPopup:
qLog(Debug) << "New line not supported by this notification type.";
html_escaped = false;
newline = "";
newline = QLatin1String("");
break;
case Behaviour::Disabled: // When notifications are disabled, we force the PrettyOSD
case Behaviour::Pretty:
html_escaped = true;
newline = "<br />";
newline = QStringLiteral("<br />");
break;
}

View File

@@ -87,7 +87,7 @@ class OSDBase : public QObject {
Message
};
void ShowPlaying(const Song &song, const QUrl &cover_url, const QImage &image, const bool preview = false);
void ShowMessage(const QString &summary, const QString &message = QString(), const QString &icon = "strawberry", const QImage &image = QImage());
void ShowMessage(const QString &summary, const QString &message = QString(), const QString &icon = QStringLiteral("strawberry"), const QImage &image = QImage());
QString ReplaceMessage(const MessageType type, const QString &message, const Song &song);
virtual void ShowMessageNative(const QString &summary, const QString &message, const QString &icon = QString(), const QImage &image = QImage());

View File

@@ -145,21 +145,21 @@ void OSDDBus::ShowMessageNative(const QString &summary, const QString &message,
QVariantMap hints;
QString summary_stripped = summary;
summary_stripped = summary_stripped.remove(QRegularExpression("[&\"<>]")).simplified();
summary_stripped = summary_stripped.remove(QRegularExpression(QStringLiteral("[&\"<>]"))).simplified();
if (!image.isNull()) {
if (version_ >= QVersionNumber(1, 2)) {
hints["image-data"] = QVariant(image);
hints[QStringLiteral("image-data")] = QVariant(image);
}
else if (version_ >= QVersionNumber(1, 1)) {
hints["image_data"] = QVariant(image);
hints[QStringLiteral("image_data")] = QVariant(image);
}
else {
hints["icon_data"] = QVariant(image);
hints[QStringLiteral("icon_data")] = QVariant(image);
}
}
hints["transient"] = QVariant(true);
hints[QStringLiteral("transient")] = QVariant(true);
quint64 id = 0;
if (last_notification_time_.secsTo(QDateTime::currentDateTime()) * 1000 < timeout_msec()) {

View File

@@ -133,14 +133,14 @@ OSDPretty::OSDPretty(Mode mode, QWidget *parent)
QObject::connect(fader_, &QTimeLine::finished, this, &OSDPretty::FaderFinished);
// Load the show edges and corners
QImage shadow_edge(":/pictures/osd_shadow_edge.png");
QImage shadow_corner(":/pictures/osd_shadow_corner.png");
QImage shadow_edge(QStringLiteral(":/pictures/osd_shadow_edge.png"));
QImage shadow_corner(QStringLiteral(":/pictures/osd_shadow_corner.png"));
for (int i = 0; i < 4; ++i) {
QTransform rotation = QTransform().rotate(90 * i);
shadow_edge_[i] = QPixmap::fromImage(shadow_edge.transformed(rotation));
shadow_corner_[i] = QPixmap::fromImage(shadow_corner.transformed(rotation));
}
background_ = QPixmap(":/pictures/osd_background.png");
background_ = QPixmap(QStringLiteral(":/pictures/osd_background.png"));
// Set the margins to allow for the drop shadow
QBoxLayout *l = qobject_cast<QBoxLayout*>(layout());