Revise string literal usage

This commit covers src/gui folder.
PR #16757.
This commit is contained in:
Chocobo1
2022-03-29 10:41:17 +08:00
committed by GitHub
parent 746fe7ba09
commit 75c93d72be
36 changed files with 275 additions and 280 deletions

View File

@@ -37,12 +37,13 @@
#include <QStyle>
#include <QStyledItemDelegate>
#include "base/global.h"
#include "gui/uithememanager.h"
#include "logmodel.h"
namespace
{
const QString SEPARATOR = QStringLiteral(" - ");
const QString SEPARATOR = u" - "_qs;
int horizontalAdvance(const QFontMetrics &fontMetrics, const QString &text)
{
@@ -51,8 +52,8 @@ namespace
QString logText(const QModelIndex &index)
{
return QString::fromLatin1("%1%2%3").arg(index.data(BaseLogModel::TimeRole).toString(), SEPARATOR
, index.data(BaseLogModel::MessageRole).toString());
return u"%1%2%3"_qs.arg(index.data(BaseLogModel::TimeRole).toString(), SEPARATOR
, index.data(BaseLogModel::MessageRole).toString());
}
class LogItemDelegate final : public QStyledItemDelegate

View File

@@ -73,7 +73,7 @@ QVariant BaseLogModel::Message::type() const
BaseLogModel::BaseLogModel(QObject *parent)
: QAbstractListModel(parent)
, m_messages(MAX_VISIBLE_MESSAGES)
, m_timeForeground(UIThemeManager::instance()->getColor(QLatin1String("Log.TimeStamp"), Qt::darkGray))
, m_timeForeground(UIThemeManager::instance()->getColor(u"Log.TimeStamp"_qs, Qt::darkGray))
{
}
@@ -142,10 +142,10 @@ LogMessageModel::LogMessageModel(QObject *parent)
: BaseLogModel(parent)
, m_foregroundForMessageTypes
{
{Log::NORMAL, UIThemeManager::instance()->getColor(QLatin1String("Log.Normal"), QApplication::palette().color(QPalette::WindowText))},
{Log::INFO, UIThemeManager::instance()->getColor(QLatin1String("Log.Info"), Qt::blue)},
{Log::WARNING, UIThemeManager::instance()->getColor(QLatin1String("Log.Warning"), QColor {255, 165, 0})}, // orange
{Log::CRITICAL, UIThemeManager::instance()->getColor(QLatin1String("Log.Critical"), Qt::red)}
{Log::NORMAL, UIThemeManager::instance()->getColor(u"Log.Normal"_qs, QApplication::palette().color(QPalette::WindowText))},
{Log::INFO, UIThemeManager::instance()->getColor(u"Log.Info"_qs, Qt::blue)},
{Log::WARNING, UIThemeManager::instance()->getColor(u"Log.Warning"_qs, QColor {255, 165, 0})}, // orange
{Log::CRITICAL, UIThemeManager::instance()->getColor(u"Log.Critical"_qs, Qt::red)}
}
{
for (const Log::Msg &msg : asConst(Logger::instance()->getMessages()))
@@ -164,7 +164,7 @@ void LogMessageModel::handleNewMessage(const Log::Msg &message)
LogPeerModel::LogPeerModel(QObject *parent)
: BaseLogModel(parent)
, m_bannedPeerForeground(UIThemeManager::instance()->getColor(QLatin1String("Log.BannedPeer"), Qt::red))
, m_bannedPeerForeground(UIThemeManager::instance()->getColor(u"Log.BannedPeer"_qs, Qt::red))
{
for (const Log::Peer &peer : asConst(Logger::instance()->getPeers()))
handleNewMessage(peer);