Compare literal strings using QLatin1StringView instead of QStringLiteral

QStringLiteral will need to allocate a new string and convert the
literal to utf-16. QLatin1StringView is the suggested alternative as it
doesn't need any of that.

Signed-off-by: Victoria Fischer <victoria.fischer@mbition.io>
wilder/Plasma/6.3
Aleix Pol Gonzalez 1 year ago
parent eb95a083c2
commit 1910e24e46
  1. 6
      src/backends/drm/drm_backend.cpp
  2. 2
      src/helpers/killer/killer.cpp
  3. 2
      src/kcms/common/effectsmodel.cpp
  4. 2
      src/kcms/decoration/kwin-applywindowdecoration.cpp
  5. 10
      src/kcms/screenedges/main.cpp
  6. 10
      src/kcms/screenedges/touch.cpp
  7. 6
      src/keyboard_layout_switching.cpp
  8. 84
      src/options.cpp
  9. 8
      src/plugins/kdecorations/aurorae/src/lib/themeconfig.cpp
  10. 6
      src/plugins/kdecorations/aurorae/themes/plastik/code/plastikbutton.cpp
  11. 4
      src/plugins/kpackage/effect/effect.cpp
  12. 8
      src/plugins/windowview/windowvieweffect.cpp
  13. 4
      src/screenedge.cpp
  14. 2
      src/scripting/scriptedeffect.cpp
  15. 4
      src/tabletmodemanager.cpp
  16. 4
      src/tiles/tilemanager.cpp
  17. 2
      src/useractions.cpp
  18. 2
      src/window.cpp

@ -153,7 +153,7 @@ void DrmBackend::handleUdevEvent()
}
}
if (device->action() == QStringLiteral("add")) {
if (device->action() == QLatin1StringView("add")) {
DrmGpu *gpu = findGpu(device->devNum());
if (gpu) {
qCWarning(KWIN_DRM) << "Received unexpected add udev event for:" << device->devNode();
@ -162,7 +162,7 @@ void DrmBackend::handleUdevEvent()
if (addGpu(device->devNode())) {
updateOutputs();
}
} else if (device->action() == QStringLiteral("remove")) {
} else if (device->action() == QLatin1StringView("remove")) {
DrmGpu *gpu = findGpu(device->devNum());
if (gpu) {
if (primaryGpu() == gpu) {
@ -174,7 +174,7 @@ void DrmBackend::handleUdevEvent()
updateOutputs();
}
}
} else if (device->action() == QStringLiteral("change")) {
} else if (device->action() == QLatin1StringView("change")) {
DrmGpu *gpu = findGpu(device->devNum());
if (!gpu) {
gpu = addGpu(device->devNode());

@ -187,7 +187,7 @@ int main(int argc, char *argv[])
fprintf(stdout, "%s\n", qPrintable(i18n("This helper utility is not supposed to be called directly.")));
parser.showHelp(1);
}
bool isLocal = hostname == QStringLiteral("localhost");
bool isLocal = hostname == QLatin1StringView("localhost");
const auto service = KService::serviceByDesktopName(appname);
if (service) {

@ -299,7 +299,7 @@ void EffectsModel::loadJavascriptEffects(const KConfigGroup &kwinConfig)
effect.internal = plugin.value(QStringLiteral("X-KWin-Internal"), false);
if (const QString configModule = plugin.value(QStringLiteral("X-KDE-ConfigModule")); !configModule.isEmpty()) {
if (configModule == QStringLiteral("kcm_kwin4_genericscripted")) {
if (configModule == QLatin1StringView("kcm_kwin4_genericscripted")) {
const QString xmlFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("kwin/effects/") + plugin.pluginId() + QLatin1String("/contents/config/main.xml"));
const QString uiFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("kwin/effects/") + plugin.pluginId() + QLatin1String("/contents/ui/config.ui"));
if (QFileInfo::exists(xmlFile) && QFileInfo::exists(uiFile)) {

@ -55,7 +55,7 @@ int main(int argc, char **argv)
// Since this is the name of a directory, let's do a bit of checking to see
// if we know enough about it to deduce that this is, in fact, a theme.
QStringList splitTheme = requestedTheme.split(QStringLiteral("/"), Qt::SkipEmptyParts);
if (splitTheme.count() > 3 && splitTheme[splitTheme.count() - 3] == QStringLiteral("aurorae") && splitTheme[splitTheme.count() - 2] == QStringLiteral("themes")) {
if (splitTheme.count() > 3 && splitTheme[splitTheme.count() - 3] == QLatin1StringView("aurorae") && splitTheme[splitTheme.count() - 2] == QLatin1StringView("themes")) {
// We think this is an aurorae theme, but let's just make a little more certain...
QString file(QStringLiteral("aurorae/themes/%1/metadata.desktop").arg(splitTheme.last()));
QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, file);

@ -362,19 +362,19 @@ void KWinScreenEdgesConfig::monitorShowEvent()
ElectricBorderAction KWinScreenEdgesConfig::electricBorderActionFromString(const QString &string)
{
QString lowerName = string.toLower();
if (lowerName == QStringLiteral("showdesktop")) {
if (lowerName == QLatin1StringView("showdesktop")) {
return ElectricActionShowDesktop;
}
if (lowerName == QStringLiteral("lockscreen")) {
if (lowerName == QLatin1StringView("lockscreen")) {
return ElectricActionLockScreen;
}
if (lowerName == QStringLiteral("krunner")) {
if (lowerName == QLatin1StringView("krunner")) {
return ElectricActionKRunner;
}
if (lowerName == QStringLiteral("activitymanager")) {
if (lowerName == QLatin1StringView("activitymanager")) {
return ElectricActionActivityManager;
}
if (lowerName == QStringLiteral("applicationlauncher")) {
if (lowerName == QLatin1StringView("applicationlauncher")) {
return ElectricActionApplicationLauncher;
}
return ElectricActionNone;

@ -303,19 +303,19 @@ void KWinScreenEdgesConfig::monitorShowEvent()
ElectricBorderAction KWinScreenEdgesConfig::electricBorderActionFromString(const QString &string)
{
QString lowerName = string.toLower();
if (lowerName == QStringLiteral("showdesktop")) {
if (lowerName == QLatin1StringView("showdesktop")) {
return ElectricActionShowDesktop;
}
if (lowerName == QStringLiteral("lockscreen")) {
if (lowerName == QLatin1StringView("lockscreen")) {
return ElectricActionLockScreen;
}
if (lowerName == QStringLiteral("krunner")) {
if (lowerName == QLatin1StringView("krunner")) {
return ElectricActionKRunner;
}
if (lowerName == QStringLiteral("activitymanager")) {
if (lowerName == QLatin1StringView("activitymanager")) {
return ElectricActionActivityManager;
}
if (lowerName == QStringLiteral("applicationlauncher")) {
if (lowerName == QLatin1StringView("applicationlauncher")) {
return ElectricActionApplicationLauncher;
}
return ElectricActionNone;

@ -43,13 +43,13 @@ void Policy::setLayout(uint index)
std::unique_ptr<Policy> Policy::create(Xkb *xkb, KeyboardLayout *layout, const KConfigGroup &config, const QString &policy)
{
if (policy.toLower() == QStringLiteral("desktop")) {
if (policy.toLower() == QLatin1StringView("desktop")) {
return std::make_unique<VirtualDesktopPolicy>(xkb, layout, config);
}
if (policy.toLower() == QStringLiteral("window")) {
if (policy.toLower() == QLatin1StringView("window")) {
return std::make_unique<WindowPolicy>(xkb, layout);
}
if (policy.toLower() == QStringLiteral("winclass")) {
if (policy.toLower() == QLatin1StringView("winclass")) {
return std::make_unique<ApplicationPolicy>(xkb, layout, config);
}
return std::make_unique<GlobalPolicy>(xkb, layout, config);

@ -706,7 +706,7 @@ void Options::loadConfig()
config = KConfigGroup(m_settings->config(), QStringLiteral("MouseBindings"));
// TODO: add properties for missing options
CmdTitlebarWheel = mouseWheelCommand(config.readEntry("CommandTitlebarWheel", "Nothing"));
CmdAllModKey = (config.readEntry("CommandAllKey", "Meta") == QStringLiteral("Meta")) ? Qt::Key_Meta : Qt::Key_Alt;
CmdAllModKey = (config.readEntry("CommandAllKey", "Meta") == QLatin1StringView("Meta")) ? Qt::Key_Meta : Qt::Key_Alt;
CmdAllWheel = mouseWheelCommand(config.readEntry("CommandAllWheel", "Nothing"));
setCommandActiveTitlebar1(mouseCommand(config.readEntry("CommandActiveTitlebar1", "Raise"), true));
setCommandActiveTitlebar2(mouseCommand(config.readEntry("CommandActiveTitlebar2", "Nothing"), true));
@ -802,9 +802,9 @@ void Options::loadConfig()
}
};
auto keyToInterface = [](const QString &key) {
if (key == QStringLiteral("glx")) {
if (key == QLatin1StringView("glx")) {
return GlxPlatformInterface;
} else if (key == QStringLiteral("egl")) {
} else if (key == QLatin1StringView("egl")) {
return EglPlatformInterface;
}
return defaultGlPlatformInterface();
@ -853,27 +853,27 @@ void Options::syncFromKcfgc()
// may not be able to move it back, unless they know about Meta+LMB)
Options::WindowOperation Options::windowOperation(const QString &name, bool restricted)
{
if (name == QStringLiteral("Move")) {
if (name == QLatin1StringView("Move")) {
return restricted ? MoveOp : UnrestrictedMoveOp;
} else if (name == QStringLiteral("Resize")) {
} else if (name == QLatin1StringView("Resize")) {
return restricted ? ResizeOp : UnrestrictedResizeOp;
} else if (name == QStringLiteral("Maximize")) {
} else if (name == QLatin1StringView("Maximize")) {
return MaximizeOp;
} else if (name == QStringLiteral("Minimize")) {
} else if (name == QLatin1StringView("Minimize")) {
return MinimizeOp;
} else if (name == QStringLiteral("Close")) {
} else if (name == QLatin1StringView("Close")) {
return CloseOp;
} else if (name == QStringLiteral("OnAllDesktops")) {
} else if (name == QLatin1StringView("OnAllDesktops")) {
return OnAllDesktopsOp;
} else if (name == QStringLiteral("Shade")) {
} else if (name == QLatin1StringView("Shade")) {
return ShadeOp;
} else if (name == QStringLiteral("Operations")) {
} else if (name == QLatin1StringView("Operations")) {
return OperationsOp;
} else if (name == QStringLiteral("Maximize (vertical only)")) {
} else if (name == QLatin1StringView("Maximize (vertical only)")) {
return VMaximizeOp;
} else if (name == QStringLiteral("Maximize (horizontal only)")) {
} else if (name == QLatin1StringView("Maximize (horizontal only)")) {
return HMaximizeOp;
} else if (name == QStringLiteral("Lower")) {
} else if (name == QLatin1StringView("Lower")) {
return LowerOp;
}
return NoOp;
@ -882,67 +882,67 @@ Options::WindowOperation Options::windowOperation(const QString &name, bool rest
Options::MouseCommand Options::mouseCommand(const QString &name, bool restricted)
{
QString lowerName = name.toLower();
if (lowerName == QStringLiteral("raise")) {
if (lowerName == QLatin1StringView("raise")) {
return MouseRaise;
}
if (lowerName == QStringLiteral("lower")) {
if (lowerName == QLatin1StringView("lower")) {
return MouseLower;
}
if (lowerName == QStringLiteral("operations menu")) {
if (lowerName == QLatin1StringView("operations menu")) {
return MouseOperationsMenu;
}
if (lowerName == QStringLiteral("toggle raise and lower")) {
if (lowerName == QLatin1StringView("toggle raise and lower")) {
return MouseToggleRaiseAndLower;
}
if (lowerName == QStringLiteral("activate and raise")) {
if (lowerName == QLatin1StringView("activate and raise")) {
return MouseActivateAndRaise;
}
if (lowerName == QStringLiteral("activate and lower")) {
if (lowerName == QLatin1StringView("activate and lower")) {
return MouseActivateAndLower;
}
if (lowerName == QStringLiteral("activate")) {
if (lowerName == QLatin1StringView("activate")) {
return MouseActivate;
}
if (lowerName == QStringLiteral("activate, raise and pass click")) {
if (lowerName == QLatin1StringView("activate, raise and pass click")) {
return MouseActivateRaiseAndPassClick;
}
if (lowerName == QStringLiteral("activate and pass click")) {
if (lowerName == QLatin1StringView("activate and pass click")) {
return MouseActivateAndPassClick;
}
if (lowerName == QStringLiteral("scroll")) {
if (lowerName == QLatin1StringView("scroll")) {
return MouseNothing;
}
if (lowerName == QStringLiteral("activate and scroll")) {
if (lowerName == QLatin1StringView("activate and scroll")) {
return MouseActivateAndPassClick;
}
if (lowerName == QStringLiteral("activate, raise and scroll")) {
if (lowerName == QLatin1StringView("activate, raise and scroll")) {
return MouseActivateRaiseAndPassClick;
}
if (lowerName == QStringLiteral("activate, raise and move")) {
if (lowerName == QLatin1StringView("activate, raise and move")) {
return restricted ? MouseActivateRaiseAndMove : MouseActivateRaiseAndUnrestrictedMove;
}
if (lowerName == QStringLiteral("move")) {
if (lowerName == QLatin1StringView("move")) {
return restricted ? MouseMove : MouseUnrestrictedMove;
}
if (lowerName == QStringLiteral("resize")) {
if (lowerName == QLatin1StringView("resize")) {
return restricted ? MouseResize : MouseUnrestrictedResize;
}
if (lowerName == QStringLiteral("shade")) {
if (lowerName == QLatin1StringView("shade")) {
return MouseShade;
}
if (lowerName == QStringLiteral("minimize")) {
if (lowerName == QLatin1StringView("minimize")) {
return MouseMinimize;
}
if (lowerName == QStringLiteral("close")) {
if (lowerName == QLatin1StringView("close")) {
return MouseClose;
}
if (lowerName == QStringLiteral("increase opacity")) {
if (lowerName == QLatin1StringView("increase opacity")) {
return MouseOpacityMore;
}
if (lowerName == QStringLiteral("decrease opacity")) {
if (lowerName == QLatin1StringView("decrease opacity")) {
return MouseOpacityLess;
}
if (lowerName == QStringLiteral("nothing")) {
if (lowerName == QLatin1StringView("nothing")) {
return MouseNothing;
}
return MouseNothing;
@ -951,25 +951,25 @@ Options::MouseCommand Options::mouseCommand(const QString &name, bool restricted
Options::MouseWheelCommand Options::mouseWheelCommand(const QString &name)
{
QString lowerName = name.toLower();
if (lowerName == QStringLiteral("raise/lower")) {
if (lowerName == QLatin1StringView("raise/lower")) {
return MouseWheelRaiseLower;
}
if (lowerName == QStringLiteral("shade/unshade")) {
if (lowerName == QLatin1StringView("shade/unshade")) {
return MouseWheelShadeUnshade;
}
if (lowerName == QStringLiteral("maximize/restore")) {
if (lowerName == QLatin1StringView("maximize/restore")) {
return MouseWheelMaximizeRestore;
}
if (lowerName == QStringLiteral("above/below")) {
if (lowerName == QLatin1StringView("above/below")) {
return MouseWheelAboveBelow;
}
if (lowerName == QStringLiteral("previous/next desktop")) {
if (lowerName == QLatin1StringView("previous/next desktop")) {
return MouseWheelPreviousNextDesktop;
}
if (lowerName == QStringLiteral("change opacity")) {
if (lowerName == QLatin1StringView("change opacity")) {
return MouseWheelChangeOpacity;
}
if (lowerName == QStringLiteral("nothing")) {
if (lowerName == QLatin1StringView("nothing")) {
return MouseWheelNothing;
}
return MouseWheelNothing;

@ -91,17 +91,17 @@ void ThemeConfig::load(const KConfig &conf)
m_haloActive = general.readEntry("HaloActive", defaultHaloActive());
m_haloInactive = general.readEntry("HaloInactive", defaultHaloInactive());
QString alignment = (general.readEntry("TitleAlignment", "Left")).toLower();
if (alignment == QStringLiteral("left")) {
if (alignment == QLatin1StringView("left")) {
m_alignment = Qt::AlignLeft;
} else if (alignment == QStringLiteral("center")) {
} else if (alignment == QLatin1StringView("center")) {
m_alignment = Qt::AlignHCenter;
} else {
m_alignment = Qt::AlignRight;
}
alignment = (general.readEntry("TitleVerticalAlignment", "Center")).toLower();
if (alignment == QStringLiteral("top")) {
if (alignment == QLatin1StringView("top")) {
m_verticalAlignment = Qt::AlignTop;
} else if (alignment == QStringLiteral("center")) {
} else if (alignment == QLatin1StringView("center")) {
m_verticalAlignment = Qt::AlignVCenter;
} else {
m_verticalAlignment = Qt::AlignBottom;

@ -35,13 +35,13 @@ QPixmap PlastikButtonProvider::requestPixmap(const QString &id, QSize *size, con
bool active = false;
bool toggled = false;
bool shadow = false;
if (idParts.length() > 1 && idParts.at(1) == QStringLiteral("true")) {
if (idParts.length() > 1 && idParts.at(1) == QLatin1StringView("true")) {
active = true;
}
if (idParts.length() > 2 && idParts.at(2) == QStringLiteral("true")) {
if (idParts.length() > 2 && idParts.at(2) == QLatin1StringView("true")) {
toggled = true;
}
if (idParts.length() > 3 && idParts.at(3) == QStringLiteral("true")) {
if (idParts.length() > 3 && idParts.at(3) == QLatin1StringView("true")) {
shadow = true;
}
ButtonIcon button;

@ -35,10 +35,10 @@ public:
}
const QString api = package->metadata().value(QStringLiteral("X-Plasma-API"));
if (api == QStringLiteral("javascript")) {
if (api == QLatin1StringView("javascript")) {
package->addFileDefinition("mainscript", QStringLiteral("code/main.js"));
package->setRequired("mainscript", true);
} else if (api == QStringLiteral("declarativescript")) {
} else if (api == QLatin1StringView("declarativescript")) {
package->addFileDefinition("mainscript", QStringLiteral("ui/main.qml"));
package->setRequired("mainscript", true);
}

@ -81,16 +81,16 @@ WindowViewEffect::WindowViewEffect()
});
connect(KGlobalAccel::self(), &KGlobalAccel::globalShortcutChanged, this, [this](QAction *action, const QKeySequence &seq) {
if (action->objectName() == QStringLiteral("Expose")) {
if (action->objectName() == QLatin1StringView("Expose")) {
m_shortcut.clear();
m_shortcut.append(seq);
} else if (action->objectName() == QStringLiteral("ExposeAll")) {
} else if (action->objectName() == QLatin1StringView("ExposeAll")) {
m_shortcutAll.clear();
m_shortcutAll.append(seq);
} else if (action->objectName() == QStringLiteral("ExposeClass")) {
} else if (action->objectName() == QLatin1StringView("ExposeClass")) {
m_shortcutClass.clear();
m_shortcutClass.append(seq);
} else if (action->objectName() == QStringLiteral("ExposeClassCurrentDesktop")) {
} else if (action->objectName() == QLatin1StringView("ExposeClassCurrentDesktop")) {
m_shortcutClassCurrentDesktop.clear();
m_shortcutClassCurrentDesktop.append(seq);
}

@ -821,9 +821,9 @@ void ScreenEdges::init()
static ElectricBorderAction electricBorderAction(const QString &name)
{
QString lowerName = name.toLower();
if (lowerName == QStringLiteral("showdesktop")) {
if (lowerName == QLatin1StringView("showdesktop")) {
return ElectricActionShowDesktop;
} else if (lowerName == QStringLiteral("lockscreen")) {
} else if (lowerName == QLatin1StringView("lockscreen")) {
return ElectricActionLockScreen;
} else if (lowerName == QLatin1String("krunner")) {
return ElectricActionKRunner;

@ -309,7 +309,7 @@ bool ScriptedEffect::isActiveFullScreenEffect() const
QList<int> ScriptedEffect::touchEdgesForAction(const QString &action) const
{
QList<int> ret;
if (m_exclusiveCategory == QStringLiteral("show-desktop") && action == QStringLiteral("show-desktop")) {
if (m_exclusiveCategory == QLatin1StringView("show-desktop") && action == QLatin1StringView("show-desktop")) {
for (const auto b : {ElectricTop, ElectricRight, ElectricBottom, ElectricLeft}) {
if (workspace()->screenEdges()->actionForTouchBorder(b) == ElectricActionShowDesktop) {
ret.append(b);

@ -142,12 +142,12 @@ void KWin::TabletModeManager::refreshSettings()
KConfigGroup cg = kwinSettings->group(QStringLiteral("Input"));
const QString tabletModeConfig = cg.readPathEntry("TabletMode", QStringLiteral("auto"));
const bool oldEffectiveTabletMode = effectiveTabletMode();
if (tabletModeConfig == QStringLiteral("on")) {
if (tabletModeConfig == QLatin1StringView("on")) {
m_configuredMode = ConfiguredMode::On;
if (!m_detecting) {
Q_EMIT tabletModeAvailableChanged(true);
}
} else if (tabletModeConfig == QStringLiteral("off")) {
} else if (tabletModeConfig == QLatin1StringView("off")) {
m_configuredMode = ConfiguredMode::Off;
} else {
m_configuredMode = ConfiguredMode::Auto;

@ -135,9 +135,9 @@ TileModel *TileManager::model() const
Tile::LayoutDirection strToLayoutDirection(const QString &dir)
{
if (dir == QStringLiteral("horizontal")) {
if (dir == QLatin1StringView("horizontal")) {
return Tile::LayoutDirection::Horizontal;
} else if (dir == QStringLiteral("vertical")) {
} else if (dir == QLatin1StringView("vertical")) {
return Tile::LayoutDirection::Vertical;
} else {
return Tile::LayoutDirection::Floating;

@ -158,7 +158,7 @@ void UserActionsMenu::helperDialog(const QString &message)
const auto shortcuts = KGlobalAccel::self()->shortcut(action);
return QStringLiteral("%1 (%2)").arg(action->text(), shortcuts.isEmpty() ? QString() : shortcuts.first().toString(QKeySequence::NativeText));
};
if (message == QStringLiteral("noborderaltf3")) {
if (message == QLatin1StringView("noborderaltf3")) {
args << QStringLiteral("--msgbox") << i18n("You have selected to show a window without its border.\n"
"Without the border, you will not be able to enable the border "
"again using the mouse: use the window operations menu instead, "

@ -1068,7 +1068,7 @@ void Window::ensurePalette()
m_palette = s_defaultPalette;
}
if (m_colorScheme == QStringLiteral("kdeglobals")) {
if (m_colorScheme == QLatin1StringView("kdeglobals")) {
s_defaultPalette = m_palette;
}
} else {

Loading…
Cancel
Save