本文整理汇总了C++中Preferences::getKeyCode方法的典型用法代码示例。如果您正苦于以下问题:C++ Preferences::getKeyCode方法的具体用法?C++ Preferences::getKeyCode怎么用?C++ Preferences::getKeyCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Preferences
的用法示例。
在下文中一共展示了Preferences::getKeyCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeKeyToFilename
QStringList writeKeyToFilename(const QString& filename, KeyFinder::key_t key, const Preferences & prefs) {
QString dataToWrite = prefs.getKeyCode(key);
QFile file(filename);
QString path = file.fileName().left(file.fileName().lastIndexOf("/") + 1);
QString extn = file.fileName().mid(file.fileName().lastIndexOf("."));
QString name = file.fileName().mid(file.fileName().lastIndexOf("/") + 1);
name = name.left(name.length() - extn.length());
QStringList written;
QString newName = prefs.newString(dataToWrite, name, METADATA_CHARLIMIT_FILENAME, prefs.getMetadataWriteFilename());
if (newName != "") {
name = newName;
}
if (file.rename(path + name + extn)) {
written << path << name << extn;
}
return written;
}
示例2: commandLineInterface
int commandLineInterface(int argc, char* argv[]){
QString filePath = "";
bool writeToTags = false;
for(int i = 1; i < argc; i++){
if(std::strcmp(argv[i], "-f") == 0 && i+1 < argc)
filePath = argv[++i];
else if (std::strcmp(argv[i], "-w") == 0)
writeToTags = true;
}
if(filePath.isEmpty())
return -1; // not a valid CLI attempt, launch GUI
Preferences prefs;
AsyncFileObject object(filePath, prefs, 0);
KeyFinderResultWrapper result = keyDetectionProcess(object);
if(!result.errorMessage.isEmpty()){
std::cerr << result.errorMessage.toLocal8Bit().constData();
return 1;
}
std::cout << prefs.getKeyCode(result.core.globalKeyEstimate).toLocal8Bit().constData();
if(writeToTags){
TagLibMetadata md(filePath);
QString written = md.writeKeyToMetadata(result.core.globalKeyEstimate,prefs);
if(written.isEmpty()){
std::cerr << "Could not write to tags" << std::endl;
return 2;
}
}
return 0;
}