aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autotests/kstandardshortcuttest.cpp7
-rw-r--r--autotests/kstandardshortcuttest.h1
-rw-r--r--src/gui/CMakeLists.txt2
-rw-r--r--src/gui/kstandardshortcut.cpp14
-rw-r--r--src/gui/kstandardshortcut.h14
5 files changed, 37 insertions, 1 deletions
diff --git a/autotests/kstandardshortcuttest.cpp b/autotests/kstandardshortcuttest.cpp
index 53a724f9..8c4df027 100644
--- a/autotests/kstandardshortcuttest.cpp
+++ b/autotests/kstandardshortcuttest.cpp
@@ -44,3 +44,10 @@ void KStandardShortcutTest::testFindStdAccel()
QCOMPARE(KStandardShortcut::find(QString("Ctrl+Shift+Alt+G")), KStandardShortcut::AccelNone);
}
+void KStandardShortcutTest::testFindByName()
+{
+ for (int i = KStandardShortcut::AccelNone + 1; i < KStandardShortcut::StandardShortcutCount; ++i) {
+ const auto id = static_cast<KStandardShortcut::StandardShortcut>(i);
+ QCOMPARE(id, KStandardShortcut::findByName(KStandardShortcut::name(id)));
+ }
+}
diff --git a/autotests/kstandardshortcuttest.h b/autotests/kstandardshortcuttest.h
index 3d186226..ae484458 100644
--- a/autotests/kstandardshortcuttest.h
+++ b/autotests/kstandardshortcuttest.h
@@ -19,6 +19,7 @@ private Q_SLOTS:
void testLabel();
void testShortcut();
void testFindStdAccel();
+ void testFindByName();
};
#endif
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
index 7c0c2f58..5a276f97 100644
--- a/src/gui/CMakeLists.txt
+++ b/src/gui/CMakeLists.txt
@@ -15,7 +15,7 @@ ecm_generate_export_header(KF5ConfigGui
GROUP_BASE_NAME KF
VERSION ${KF5_VERSION}
DEPRECATED_BASE_VERSION 0
- DEPRECATION_VERSIONS 5.11 5.39
+ DEPRECATION_VERSIONS 5.11 5.39 5.71
EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT}
)
diff --git a/src/gui/kstandardshortcut.cpp b/src/gui/kstandardshortcut.cpp
index 7d788919..825dfb8a 100644
--- a/src/gui/kstandardshortcut.cpp
+++ b/src/gui/kstandardshortcut.cpp
@@ -318,6 +318,8 @@ StandardShortcut find(const QKeySequence &seq)
return AccelNone;
}
+
+#if KCONFIGGUI_BUILD_DEPRECATED_SINCE(5, 71)
StandardShortcut find(const char *keyName)
{
for (const KStandardShortcutInfo &shortcutInfo : g_infoStandardShortcut) {
@@ -328,6 +330,18 @@ StandardShortcut find(const char *keyName)
return AccelNone;
}
+#endif
+
+StandardShortcut findByName(const QString &name)
+{
+
+ for (const KStandardShortcutInfo &shortcutInfo : g_infoStandardShortcut) {
+ if (QString::fromLatin1(shortcutInfo.name) == name) {
+ return shortcutInfo.id;
+ }
+ }
+ return AccelNone;
+}
QList<QKeySequence> hardcodedDefaultShortcut(StandardShortcut id)
{
diff --git a/src/gui/kstandardshortcut.h b/src/gui/kstandardshortcut.h
index 69feee61..cda9fe96 100644
--- a/src/gui/kstandardshortcut.h
+++ b/src/gui/kstandardshortcut.h
@@ -186,6 +186,7 @@ KCONFIGGUI_EXPORT QString whatsThis(StandardShortcut id);
*/
KCONFIGGUI_EXPORT StandardShortcut find(const QKeySequence &keySeq);
+#if KCONFIGGUI_ENABLE_DEPRECATED_SINCE(5, 71)
/**
* Return the StandardShortcut id of the standard accel action which
* has \a keyName as its name, or AccelNone if none of them do.
@@ -193,8 +194,21 @@ KCONFIGGUI_EXPORT StandardShortcut find(const QKeySequence &keySeq);
* @param keyName the key sequence to search
* @return the id of the standard accelerator, or AccelNone if there
* is none
+ * @deprecated since 5.71, use findByName(const QString &name) instead
*/
+KCONFIGGUI_DEPRECATED_VERSION(5, 71, "Use findByName(const QString &name) instead")
KCONFIGGUI_EXPORT StandardShortcut find(const char *keyName);
+#endif
+
+/**
+ * Return the StandardShortcut id of the standard accelerator action which
+ * has \p name as its name, or AccelNone if none of them do.
+ * @param name the name as returned by name(StandardShortcut id)
+ * @return the id of the standard accelerator with the given name or AccelNone
+ * if there is no such accelerator
+ * @since 5.71
+ */
+KCONFIGGUI_EXPORT StandardShortcut findByName(const QString &name);
/**
* Returns the hardcoded default shortcut for @p id.