From 5eb4c1722a9bc0b8e894c089fb3f0d4d9a31ef2b Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Wed, 9 Mar 2022 17:44:12 +0100 Subject: [PATCH] Port from I18N_NOOP to KLazyLocalizedString --- src/main.cpp | 4 +- src/tabbox/tabbox.cpp | 55 +++++++++--------- src/tabbox/tabbox.h | 3 +- src/useractions.cpp | 131 +++++++++++++++++++++--------------------- 4 files changed, 97 insertions(+), 96 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 5cb7af1c00..102186e866 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -196,14 +196,12 @@ bool Application::wasCrash() return crashes > 0; } -static const char description[] = I18N_NOOP("KDE window manager"); - void Application::createAboutData() { KAboutData aboutData(QStringLiteral(KWIN_NAME), // The program name used internally i18n("KWin"), // A displayable program name string QStringLiteral(KWIN_VERSION_STRING), // The program version string - i18n(description), // Short description of what the app does + i18n("KDE window manager"), // Short description of what the app does KAboutLicense::GPL, // The license this code is released under i18n("(c) 1999-2019, The KDE Developers")); // Copyright Statement diff --git a/src/tabbox/tabbox.cpp b/src/tabbox/tabbox.cpp index 48d7c4e1d0..07210aba9a 100644 --- a/src/tabbox/tabbox.cpp +++ b/src/tabbox/tabbox.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include // X11 #include @@ -511,30 +512,30 @@ void TabBox::handlerReady() } template -void TabBox::key(const char *actionName, Slot slot, const QKeySequence &shortcut) +void TabBox::key(const KLazyLocalizedString &actionName, Slot slot, const QKeySequence &shortcut) { QAction *a = new QAction(this); a->setProperty("componentName", QStringLiteral(KWIN_NAME)); - a->setObjectName(QString::fromUtf8(actionName)); - a->setText(i18n(actionName)); + a->setObjectName(QString::fromUtf8(actionName.untranslatedText())); + a->setText(actionName.toString()); KGlobalAccel::self()->setGlobalShortcut(a, QList() << shortcut); input()->registerShortcut(shortcut, a, TabBox::self(), slot); auto cuts = KGlobalAccel::self()->shortcut(a); globalShortcutChanged(a, cuts.isEmpty() ? QKeySequence() : cuts.first()); } -static const char s_windows[] = I18N_NOOP("Walk Through Windows"); -static const char s_windowsRev[] = I18N_NOOP("Walk Through Windows (Reverse)"); -static const char s_windowsAlt[] = I18N_NOOP("Walk Through Windows Alternative"); -static const char s_windowsAltRev[] = I18N_NOOP("Walk Through Windows Alternative (Reverse)"); -static const char s_app[] = I18N_NOOP("Walk Through Windows of Current Application"); -static const char s_appRev[] = I18N_NOOP("Walk Through Windows of Current Application (Reverse)"); -static const char s_appAlt[] = I18N_NOOP("Walk Through Windows of Current Application Alternative"); -static const char s_appAltRev[] = I18N_NOOP("Walk Through Windows of Current Application Alternative (Reverse)"); -static const char s_desktops[] = I18N_NOOP("Walk Through Desktops"); -static const char s_desktopsRev[] = I18N_NOOP("Walk Through Desktops (Reverse)"); -static const char s_desktopList[] = I18N_NOOP("Walk Through Desktop List"); -static const char s_desktopListRev[] = I18N_NOOP("Walk Through Desktop List (Reverse)"); +static constexpr const auto s_windows = kli18n("Walk Through Windows"); +static constexpr const auto s_windowsRev = kli18n("Walk Through Windows (Reverse)"); +static constexpr const auto s_windowsAlt = kli18n("Walk Through Windows Alternative"); +static constexpr const auto s_windowsAltRev = kli18n("Walk Through Windows Alternative (Reverse)"); +static constexpr const auto s_app = kli18n("Walk Through Windows of Current Application"); +static constexpr const auto s_appRev = kli18n("Walk Through Windows of Current Application (Reverse)"); +static constexpr const auto s_appAlt = kli18n("Walk Through Windows of Current Application Alternative"); +static constexpr const auto s_appAltRev = kli18n("Walk Through Windows of Current Application Alternative (Reverse)"); +static constexpr const auto s_desktops = kli18n("Walk Through Desktops"); +static constexpr const auto s_desktopsRev = kli18n("Walk Through Desktops (Reverse)"); +static constexpr const auto s_desktopList = kli18n("Walk Through Desktop List"); +static constexpr const auto s_desktopListRev = kli18n("Walk Through Desktop List (Reverse)"); void TabBox::initShortcuts() { @@ -556,29 +557,29 @@ void TabBox::initShortcuts() void TabBox::globalShortcutChanged(QAction *action, const QKeySequence &seq) { - if (qstrcmp(qPrintable(action->objectName()), s_windows) == 0) { + if (qstrcmp(qPrintable(action->objectName()), s_windows.untranslatedText()) == 0) { m_cutWalkThroughWindows = seq; - } else if (qstrcmp(qPrintable(action->objectName()), s_windowsRev) == 0) { + } else if (qstrcmp(qPrintable(action->objectName()), s_windowsRev.untranslatedText()) == 0) { m_cutWalkThroughWindowsReverse = seq; - } else if (qstrcmp(qPrintable(action->objectName()), s_app) == 0) { + } else if (qstrcmp(qPrintable(action->objectName()), s_app.untranslatedText()) == 0) { m_cutWalkThroughCurrentAppWindows = seq; - } else if (qstrcmp(qPrintable(action->objectName()), s_appRev) == 0) { + } else if (qstrcmp(qPrintable(action->objectName()), s_appRev.untranslatedText()) == 0) { m_cutWalkThroughCurrentAppWindowsReverse = seq; - } else if (qstrcmp(qPrintable(action->objectName()), s_windowsAlt) == 0) { + } else if (qstrcmp(qPrintable(action->objectName()), s_windowsAlt.untranslatedText()) == 0) { m_cutWalkThroughWindowsAlternative = seq; - } else if (qstrcmp(qPrintable(action->objectName()), s_windowsAltRev) == 0) { + } else if (qstrcmp(qPrintable(action->objectName()), s_windowsAltRev.untranslatedText()) == 0) { m_cutWalkThroughWindowsAlternativeReverse = seq; - } else if (qstrcmp(qPrintable(action->objectName()), s_appAlt) == 0) { + } else if (qstrcmp(qPrintable(action->objectName()), s_appAlt.untranslatedText()) == 0) { m_cutWalkThroughCurrentAppWindowsAlternative = seq; - } else if (qstrcmp(qPrintable(action->objectName()), s_appAltRev) == 0) { + } else if (qstrcmp(qPrintable(action->objectName()), s_appAltRev.untranslatedText()) == 0) { m_cutWalkThroughCurrentAppWindowsAlternativeReverse = seq; - } else if (qstrcmp(qPrintable(action->objectName()), s_desktops) == 0) { + } else if (qstrcmp(qPrintable(action->objectName()), s_desktops.untranslatedText()) == 0) { m_cutWalkThroughDesktops = seq; - } else if (qstrcmp(qPrintable(action->objectName()), s_desktopsRev) == 0) { + } else if (qstrcmp(qPrintable(action->objectName()), s_desktopsRev.untranslatedText()) == 0) { m_cutWalkThroughDesktopsReverse = seq; - } else if (qstrcmp(qPrintable(action->objectName()), s_desktopList) == 0) { + } else if (qstrcmp(qPrintable(action->objectName()), s_desktopList.untranslatedText()) == 0) { m_cutWalkThroughDesktopList = seq; - } else if (qstrcmp(qPrintable(action->objectName()), s_desktopListRev) == 0) { + } else if (qstrcmp(qPrintable(action->objectName()), s_desktopListRev.untranslatedText()) == 0) { m_cutWalkThroughDesktopListReverse = seq; } } diff --git a/src/tabbox/tabbox.h b/src/tabbox/tabbox.h index ca497fb200..5025b22419 100644 --- a/src/tabbox/tabbox.h +++ b/src/tabbox/tabbox.h @@ -19,6 +19,7 @@ #include "tabbox/tabboxhandler.h" class KConfigGroup; +class KLazyLocalizedString; class QAction; class QMouseEvent; class QKeyEvent; @@ -304,7 +305,7 @@ private: bool establishTabBoxGrab(); void removeTabBoxGrab(); template - void key(const char *actionName, Slot slot, const QKeySequence &shortcut = QKeySequence()); + void key(const KLazyLocalizedString &actionName, Slot slot, const QKeySequence &shortcut = QKeySequence()); void shadeActivate(AbstractClient *c); diff --git a/src/useractions.cpp b/src/useractions.cpp index 637bf8b0a0..f8eb3067db 100644 --- a/src/useractions.cpp +++ b/src/useractions.cpp @@ -49,6 +49,7 @@ #include #include +#include #include #include #include @@ -950,107 +951,107 @@ void Workspace::initShortcuts() // new DEF3 allows to pass data to the action, replacing the %1 argument in the name #define DEF2( name, descr, key, fnSlot ) \ - initShortcut(QStringLiteral(name), i18n(descr), key, &Workspace::fnSlot); + initShortcut(QStringLiteral(name), descr.toString(), key, &Workspace::fnSlot); #define DEF( name, key, fnSlot ) \ - initShortcut(QStringLiteral(name), i18n(name), key, &Workspace::fnSlot); + initShortcut(QString::fromUtf8(name.untranslatedText()), name.toString(), key, &Workspace::fnSlot); #define DEF3( name, key, fnSlot, value ) \ - initShortcut(QStringLiteral(name).arg(value), i18n(name, value), key, &Workspace::fnSlot, value); + initShortcut(QString::fromUtf8(name.untranslatedText()).arg(value), name.subs(value).toString(), key, &Workspace::fnSlot, value); #define DEF4( name, descr, key, functor ) \ - initShortcut(QStringLiteral(name), i18n(descr), key, functor); + initShortcut(QStringLiteral(name), descr.toString(), key, functor); #define DEF5( name, key, functor, value ) \ - initShortcut(QStringLiteral(name).arg(value), i18n(name, value), key, functor, value); + initShortcut(QString::fromUtf8(name.untranslatedText()).arg(value), name.subs(value).toString(), key, functor, value); #define DEF6( name, key, target, fnSlot ) \ - initShortcut(QStringLiteral(name), i18n(name), key, target, &fnSlot); + initShortcut(QString::fromUtf8(name.untranslatedText()), name.toString(), key, target, &fnSlot); - DEF(I18N_NOOP("Window Operations Menu"), + DEF(kli18n("Window Operations Menu"), Qt::ALT | Qt::Key_F3, slotWindowOperations); - DEF2("Window Close", I18N_NOOP("Close Window"), + DEF2("Window Close", kli18n("Close Window"), Qt::ALT | Qt::Key_F4, slotWindowClose); - DEF2("Window Maximize", I18N_NOOP("Maximize Window"), + DEF2("Window Maximize", kli18n("Maximize Window"), Qt::META | Qt::Key_PageUp, slotWindowMaximize); - DEF2("Window Maximize Vertical", I18N_NOOP("Maximize Window Vertically"), + DEF2("Window Maximize Vertical", kli18n("Maximize Window Vertically"), 0, slotWindowMaximizeVertical); - DEF2("Window Maximize Horizontal", I18N_NOOP("Maximize Window Horizontally"), + DEF2("Window Maximize Horizontal", kli18n("Maximize Window Horizontally"), 0, slotWindowMaximizeHorizontal); - DEF2("Window Minimize", I18N_NOOP("Minimize Window"), + DEF2("Window Minimize", kli18n("Minimize Window"), Qt::META | Qt::Key_PageDown, slotWindowMinimize); - DEF2("Window Shade", I18N_NOOP("Shade Window"), + DEF2("Window Shade", kli18n("Shade Window"), 0, slotWindowShade); - DEF2("Window Move", I18N_NOOP("Move Window"), + DEF2("Window Move", kli18n("Move Window"), 0, slotWindowMove); - DEF2("Window Resize", I18N_NOOP("Resize Window"), + DEF2("Window Resize", kli18n("Resize Window"), 0, slotWindowResize); - DEF2("Window Raise", I18N_NOOP("Raise Window"), + DEF2("Window Raise", kli18n("Raise Window"), 0, slotWindowRaise); - DEF2("Window Lower", I18N_NOOP("Lower Window"), + DEF2("Window Lower", kli18n("Lower Window"), 0, slotWindowLower); - DEF(I18N_NOOP("Toggle Window Raise/Lower"), + DEF(kli18n("Toggle Window Raise/Lower"), 0, slotWindowRaiseOrLower); - DEF2("Window Fullscreen", I18N_NOOP("Make Window Fullscreen"), + DEF2("Window Fullscreen", kli18n("Make Window Fullscreen"), 0, slotWindowFullScreen); - DEF2("Window No Border", I18N_NOOP("Hide Window Border"), + DEF2("Window No Border", kli18n("Hide Window Border"), 0, slotWindowNoBorder); - DEF2("Window Above Other Windows", I18N_NOOP("Keep Window Above Others"), + DEF2("Window Above Other Windows", kli18n("Keep Window Above Others"), 0, slotWindowAbove); - DEF2("Window Below Other Windows", I18N_NOOP("Keep Window Below Others"), + DEF2("Window Below Other Windows", kli18n("Keep Window Below Others"), 0, slotWindowBelow); - DEF(I18N_NOOP("Activate Window Demanding Attention"), + DEF(kli18n("Activate Window Demanding Attention"), Qt::CTRL | Qt::ALT | Qt::Key_A, slotActivateAttentionWindow); - DEF(I18N_NOOP("Setup Window Shortcut"), + DEF(kli18n("Setup Window Shortcut"), 0, slotSetupWindowShortcut); - DEF2("Window Move Center", I18N_NOOP("Move Window to the Center"), 0, + DEF2("Window Move Center", kli18n("Move Window to the Center"), 0, slotWindowCenter); - DEF2("Window Pack Right", I18N_NOOP("Move Window Right"), + DEF2("Window Pack Right", kli18n("Move Window Right"), 0, slotWindowMoveRight); - DEF2("Window Pack Left", I18N_NOOP("Move Window Left"), + DEF2("Window Pack Left", kli18n("Move Window Left"), 0, slotWindowMoveLeft); - DEF2("Window Pack Up", I18N_NOOP("Move Window Up"), + DEF2("Window Pack Up", kli18n("Move Window Up"), 0, slotWindowMoveUp); - DEF2("Window Pack Down", I18N_NOOP("Move Window Down"), + DEF2("Window Pack Down", kli18n("Move Window Down"), 0, slotWindowMoveDown); - DEF2("Window Grow Horizontal", I18N_NOOP("Expand Window Horizontally"), + DEF2("Window Grow Horizontal", kli18n("Expand Window Horizontally"), 0, slotWindowExpandHorizontal); - DEF2("Window Grow Vertical", I18N_NOOP("Expand Window Vertically"), + DEF2("Window Grow Vertical", kli18n("Expand Window Vertically"), 0, slotWindowExpandVertical); - DEF2("Window Shrink Horizontal", I18N_NOOP("Shrink Window Horizontally"), + DEF2("Window Shrink Horizontal", kli18n("Shrink Window Horizontally"), 0, slotWindowShrinkHorizontal); - DEF2("Window Shrink Vertical", I18N_NOOP("Shrink Window Vertically"), + DEF2("Window Shrink Vertical", kli18n("Shrink Window Vertically"), 0, slotWindowShrinkVertical); - DEF4("Window Quick Tile Left", I18N_NOOP("Quick Tile Window to the Left"), + DEF4("Window Quick Tile Left", kli18n("Quick Tile Window to the Left"), Qt::META | Qt::Key_Left, std::bind(&Workspace::quickTileWindow, this, QuickTileFlag::Left)); - DEF4("Window Quick Tile Right", I18N_NOOP("Quick Tile Window to the Right"), + DEF4("Window Quick Tile Right", kli18n("Quick Tile Window to the Right"), Qt::META | Qt::Key_Right, std::bind(&Workspace::quickTileWindow, this, QuickTileFlag::Right)); - DEF4("Window Quick Tile Top", I18N_NOOP("Quick Tile Window to the Top"), + DEF4("Window Quick Tile Top", kli18n("Quick Tile Window to the Top"), Qt::META | Qt::Key_Up, std::bind(&Workspace::quickTileWindow, this, QuickTileFlag::Top)); - DEF4("Window Quick Tile Bottom", I18N_NOOP("Quick Tile Window to the Bottom"), + DEF4("Window Quick Tile Bottom", kli18n("Quick Tile Window to the Bottom"), Qt::META | Qt::Key_Down, std::bind(&Workspace::quickTileWindow, this, QuickTileFlag::Bottom)); - DEF4("Window Quick Tile Top Left", I18N_NOOP("Quick Tile Window to the Top Left"), + DEF4("Window Quick Tile Top Left", kli18n("Quick Tile Window to the Top Left"), 0, std::bind(&Workspace::quickTileWindow, this, QuickTileFlag::Top | QuickTileFlag::Left)); - DEF4("Window Quick Tile Bottom Left", I18N_NOOP("Quick Tile Window to the Bottom Left"), + DEF4("Window Quick Tile Bottom Left", kli18n("Quick Tile Window to the Bottom Left"), 0, std::bind(&Workspace::quickTileWindow, this, QuickTileFlag::Bottom | QuickTileFlag::Left)); - DEF4("Window Quick Tile Top Right", I18N_NOOP("Quick Tile Window to the Top Right"), + DEF4("Window Quick Tile Top Right", kli18n("Quick Tile Window to the Top Right"), 0, std::bind(&Workspace::quickTileWindow, this, QuickTileFlag::Top | QuickTileFlag::Right)); - DEF4("Window Quick Tile Bottom Right", I18N_NOOP("Quick Tile Window to the Bottom Right"), + DEF4("Window Quick Tile Bottom Right", kli18n("Quick Tile Window to the Bottom Right"), 0, std::bind(&Workspace::quickTileWindow, this, QuickTileFlag::Bottom | QuickTileFlag::Right)); - DEF4("Switch Window Up", I18N_NOOP("Switch to Window Above"), + DEF4("Switch Window Up", kli18n("Switch to Window Above"), Qt::META | Qt::ALT | Qt::Key_Up, std::bind(static_cast(&Workspace::switchWindow), this, DirectionNorth)); - DEF4("Switch Window Down", I18N_NOOP("Switch to Window Below"), + DEF4("Switch Window Down", kli18n("Switch to Window Below"), Qt::META | Qt::ALT | Qt::Key_Down, std::bind(static_cast(&Workspace::switchWindow), this, DirectionSouth)); - DEF4("Switch Window Right", I18N_NOOP("Switch to Window to the Right"), + DEF4("Switch Window Right", kli18n("Switch to Window to the Right"), Qt::META | Qt::ALT | Qt::Key_Right, std::bind(static_cast(&Workspace::switchWindow), this, DirectionEast)); - DEF4("Switch Window Left", I18N_NOOP("Switch to Window to the Left"), + DEF4("Switch Window Left", kli18n("Switch to Window to the Left"), Qt::META | Qt::ALT | Qt::Key_Left, std::bind(static_cast(&Workspace::switchWindow), this, DirectionWest)); - DEF2("Increase Opacity", I18N_NOOP("Increase Opacity of Active Window by 5 %"), + DEF2("Increase Opacity", kli18n("Increase Opacity of Active Window by 5 %"), 0, slotIncreaseWindowOpacity); - DEF2("Decrease Opacity", I18N_NOOP("Decrease Opacity of Active Window by 5 %"), + DEF2("Decrease Opacity", kli18n("Decrease Opacity of Active Window by 5 %"), 0, slotLowerWindowOpacity); - DEF2("Window On All Desktops", I18N_NOOP("Keep Window on All Desktops"), + DEF2("Window On All Desktops", kli18n("Keep Window on All Desktops"), 0, slotWindowOnAllDesktops); VirtualDesktopManager *vds = VirtualDesktopManager::self(); @@ -1061,32 +1062,32 @@ void Workspace::initShortcuts() slotWindowToDesktop(desktops[i]); } }; - DEF5(I18N_NOOP("Window to Desktop %1"), 0, handler, i + 1); + DEF5(kli18n("Window to Desktop %1"), 0, handler, i + 1); } - DEF(I18N_NOOP("Window to Next Desktop"), 0, slotWindowToNextDesktop); - DEF(I18N_NOOP("Window to Previous Desktop"), 0, slotWindowToPreviousDesktop); - DEF(I18N_NOOP("Window One Desktop to the Right"), Qt::META | Qt::CTRL | Qt::SHIFT | Qt::Key_Right, slotWindowToDesktopRight); - DEF(I18N_NOOP("Window One Desktop to the Left"), Qt::META | Qt::CTRL | Qt::SHIFT | Qt::Key_Left, slotWindowToDesktopLeft); - DEF(I18N_NOOP("Window One Desktop Up"), Qt::META | Qt::CTRL | Qt::SHIFT | Qt::Key_Up, slotWindowToDesktopUp); - DEF(I18N_NOOP("Window One Desktop Down"), Qt::META | Qt::CTRL | Qt::SHIFT | Qt::Key_Down, slotWindowToDesktopDown); + DEF(kli18n("Window to Next Desktop"), 0, slotWindowToNextDesktop); + DEF(kli18n("Window to Previous Desktop"), 0, slotWindowToPreviousDesktop); + DEF(kli18n("Window One Desktop to the Right"), Qt::META | Qt::CTRL | Qt::SHIFT | Qt::Key_Right, slotWindowToDesktopRight); + DEF(kli18n("Window One Desktop to the Left"), Qt::META | Qt::CTRL | Qt::SHIFT | Qt::Key_Left, slotWindowToDesktopLeft); + DEF(kli18n("Window One Desktop Up"), Qt::META | Qt::CTRL | Qt::SHIFT | Qt::Key_Up, slotWindowToDesktopUp); + DEF(kli18n("Window One Desktop Down"), Qt::META | Qt::CTRL | Qt::SHIFT | Qt::Key_Down, slotWindowToDesktopDown); for (int i = 0; i < 8; ++i) { - DEF3(I18N_NOOP("Window to Screen %1"), 0, slotWindowToScreen, i); + DEF3(kli18n("Window to Screen %1"), 0, slotWindowToScreen, i); } - DEF(I18N_NOOP("Window to Next Screen"), Qt::META | Qt::SHIFT | Qt::Key_Right, slotWindowToNextScreen); - DEF(I18N_NOOP("Window to Previous Screen"), Qt::META | Qt::SHIFT | Qt::Key_Left, slotWindowToPrevScreen); - DEF(I18N_NOOP("Show Desktop"), Qt::META | Qt::Key_D, slotToggleShowDesktop); + DEF(kli18n("Window to Next Screen"), Qt::META | Qt::SHIFT | Qt::Key_Right, slotWindowToNextScreen); + DEF(kli18n("Window to Previous Screen"), Qt::META | Qt::SHIFT | Qt::Key_Left, slotWindowToPrevScreen); + DEF(kli18n("Show Desktop"), Qt::META | Qt::Key_D, slotToggleShowDesktop); for (int i = 0; i < 8; ++i) { - DEF3(I18N_NOOP("Switch to Screen %1"), 0, slotSwitchToScreen, i); + DEF3(kli18n("Switch to Screen %1"), 0, slotSwitchToScreen, i); } - DEF(I18N_NOOP("Switch to Next Screen"), 0, slotSwitchToNextScreen); - DEF(I18N_NOOP("Switch to Previous Screen"), 0, slotSwitchToPrevScreen); + DEF(kli18n("Switch to Next Screen"), 0, slotSwitchToNextScreen); + DEF(kli18n("Switch to Previous Screen"), 0, slotSwitchToPrevScreen); - DEF(I18N_NOOP("Kill Window"), Qt::CTRL | Qt::ALT | Qt::Key_Escape, slotKillWindow); - DEF6(I18N_NOOP("Suspend Compositing"), Qt::SHIFT | Qt::ALT | Qt::Key_F12, Compositor::self(), Compositor::toggleCompositing); - DEF6(I18N_NOOP("Invert Screen Colors"), 0, kwinApp()->platform(), Platform::invertScreen); + DEF(kli18n("Kill Window"), Qt::CTRL | Qt::ALT | Qt::Key_Escape, slotKillWindow); + DEF6(kli18n("Suspend Compositing"), Qt::SHIFT | Qt::ALT | Qt::Key_F12, Compositor::self(), Compositor::toggleCompositing); + DEF6(kli18n("Invert Screen Colors"), 0, kwinApp()->platform(), Platform::invertScreen); #undef DEF #undef DEF2