Skip to content

Commit

Permalink
refactor: replace non-empty QString constructors with QStringLiteral() (
Browse files Browse the repository at this point in the history
  • Loading branch information
Integral-Tech authored Nov 6, 2024
1 parent 8dffee6 commit 4b5516f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion qt5/platforminputcontext/fcitx4inputcontextproxy_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class Fcitx4InputContextProxyPrivate {
unsigned int>
reply(*createInputContextWatcher_);

QString path = QString("/inputcontext_%1").arg(reply.value());
QString path = QStringLiteral("/inputcontext_%1").arg(reply.value());
icproxy_ = new Fcitx4InputContextProxyImpl(improxy_->service(), path,
improxy_->connection(), q);
QObject::connect(icproxy_, &Fcitx4InputContextProxyImpl::CommitString,
Expand Down
8 changes: 4 additions & 4 deletions qt5/platforminputcontext/fcitx4watcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,29 +48,29 @@ int displayNumber() {

QString socketFile() {
QString filename =
QString("%1-%2")
QStringLiteral("%1-%2")
.arg(QString::fromLatin1(QDBusConnection::localMachineId()))
.arg(displayNumber());

QString home = QString::fromLocal8Bit(qgetenv("XDG_CONFIG_HOME"));
if (home.isEmpty()) {
home = QDir::homePath().append(QLatin1String("/.config"));
}
return QString("%1/fcitx/dbus/%2").arg(home).arg(filename);
return QStringLiteral("%1/fcitx/dbus/%2").arg(home).arg(filename);
}

namespace fcitx {

QString newUniqueConnectionName() {
static int idx = 0;
const auto newIdx = idx++;
return QString("_fcitx4_%1").arg(newIdx);
return QStringLiteral("_fcitx4_%1").arg(newIdx);
}

Fcitx4Watcher::Fcitx4Watcher(QDBusConnection sessionBus, QObject *parent)
: QObject(parent), connection_(nullptr), sessionBus_(sessionBus),
socketFile_(socketFile()),
serviceName_(QString("org.fcitx.Fcitx-%1").arg(displayNumber())),
serviceName_(QStringLiteral("org.fcitx.Fcitx-%1").arg(displayNumber())),
availability_(false), uniqueConnectionName_(newUniqueConnectionName()) {}

Fcitx4Watcher::~Fcitx4Watcher() {
Expand Down
11 changes: 6 additions & 5 deletions qt5/platforminputcontext/fcitxtheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ QColor readColor(const QSettings &settings, const QString &name,
} else if (colorString.size() == 9) {
// Qt accept "#AARRGGBB"
auto newColorString =
QString("#%1%2")
QStringLiteral("#%1%2")
.arg(colorString.mid(7, 2), colorString.mid(1, 6))
.toUpper();
color = QColor(newColorString);
Expand All @@ -55,13 +55,13 @@ void BackgroundImage::load(const QString &name, QSettings &settings) {
if (auto image = settings.value("Image").toString(); !image.isEmpty()) {
auto file = QStandardPaths::locate(
QStandardPaths::GenericDataLocation,
QString("fcitx5/themes/%1/%2").arg(name, image));
QStringLiteral("fcitx5/themes/%1/%2").arg(name, image));
image_.load(file);
}
if (auto image = settings.value("Overlay").toString(); !image.isEmpty()) {
auto file = QStandardPaths::locate(
QStandardPaths::GenericDataLocation,
QString("fcitx5/themes/%1/%2").arg(name, image));
QStringLiteral("fcitx5/themes/%1/%2").arg(name, image));
overlay_.load(file);
}

Expand Down Expand Up @@ -130,7 +130,7 @@ void ActionImage::load(const QString &name, QSettings &settings) {
if (auto image = settings.value("Image").toString(); !image.isEmpty()) {
auto file = QStandardPaths::locate(
QStandardPaths::GenericDataLocation,
QString("fcitx5/themes/%1/%2").arg(name, image));
QStringLiteral("fcitx5/themes/%1/%2").arg(name, image));
image_.load(file);
valid_ = !image_.isNull();
}
Expand Down Expand Up @@ -185,7 +185,8 @@ void FcitxTheme::themeChanged() {
if (!themeConfigPath_.isEmpty()) {
watcher_->removePath(themeConfigPath_);
}
auto themeConfig = QString("/fcitx5/themes/%1/theme.conf").arg(theme_);
auto themeConfig =
QStringLiteral("/fcitx5/themes/%1/theme.conf").arg(theme_);
themeConfigPath_ =
QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)
.append(themeConfig);
Expand Down

0 comments on commit 4b5516f

Please sign in to comment.