Skip to content

Commit 330ee1f

Browse files
committed
feat: add camelCase conversion for key names
Added conditional compilation to support both original key name format and camelCase format for dde-daemon v25 compatibility Implemented qtifyName function to convert hyphenated names to camelCase by removing hyphens and capitalizing following letters Added ENABLE_DSS_SNIPE macro check to maintain backward compatibility while supporting new naming convention feat: 为键名添加驼峰命名转换支持 添加条件编译以同时支持原始键名格式和v25 dde-daemon所需的小驼峰格式 实现qtifyName函数,通过移除连字符并大写后续字母将连字符分隔的名称转换为 驼峰命名添加ENABLE_DSS_SNIPE宏检查,在支持新命名规范的同时保持向后兼容性 pms: BUG-292567
1 parent 2d779c1 commit 330ee1f

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

src/dde-lock/lockframe.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,12 @@ bool LockFrame::event(QEvent *event)
171171
}
172172

173173
if (keyValue != "") {
174+
#ifdef ENABLE_DSS_SNIPE
175+
// v25 dde-daemon接受小驼峰命名的name
176+
emit sendKeyValue(qtifyName(keyValue));
177+
#else
174178
emit sendKeyValue(keyValue);
179+
#endif
175180
}
176181
}
177182
return FullScreenBackground::event(event);

src/global_util/public_func.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,3 +356,21 @@ bool isSleepLock()
356356
return value.toBool();
357357
}
358358
#endif
359+
360+
QString qtifyName(const QString &name) {
361+
bool next_cap = false;
362+
QString result;
363+
364+
for (auto it = name.cbegin(); it != name.cend(); ++it) {
365+
if (*it == '-') {
366+
next_cap = true;
367+
} else if (next_cap) {
368+
result.append(it->toUpper());
369+
next_cap = false;
370+
} else {
371+
result.append(*it);
372+
}
373+
}
374+
375+
return result;
376+
}

src/global_util/public_func.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,10 @@ void configWebEngine();
8282
bool isSleepLock();
8383
#endif
8484

85+
/**
86+
* @brief convert 'some-key' to 'someKey'.
87+
*/
88+
89+
QString qtifyName(const QString &name);
90+
8591
#endif // PUBLIC_FUNC_H

0 commit comments

Comments
 (0)