Commit 47f759e7 authored by Urs Fleisch's avatar Urs Fleisch
Browse files

QML: Script to show text encoding, [feature-requests#56].

parent 5597fbf2
......@@ -141,6 +141,8 @@ void UserActionsConfig::readFromConfig(ISettings* config)
UserActionsConfig::MenuCommand(QLatin1String("ReplayGain to SoundCheck"), QLatin1String("@qml %{qmlpath}/script/ReplayGain2SoundCheck.qml"), false, true));
m_contextMenuCommands.push_back(
UserActionsConfig::MenuCommand(QLatin1String("Resize Album Art"), QLatin1String("@qml %{qmlpath}/script/ResizeAlbumArt.qml"), false, true));
m_contextMenuCommands.push_back(
UserActionsConfig::MenuCommand(QLatin1String("Text Encoding ID3v1"), QLatin1String("@qml %{qmlpath}/script/ShowTextEncodingV1.qml"), false, true));
}
#endif
}
......
......@@ -324,7 +324,7 @@ public:
/**
* Apply configuration changes.
*/
void applyChangedConfiguration();
Q_INVOKABLE void applyChangedConfiguration();
/**
* Save settings to the configuration.
......
/**
* \file ShowTextEncodingV1.qml
* Helps to find the encoding of ID3v1 tags by showing the tags of the
* current file in all available character encodings.
*
* \b Project: Kid3
* \author Urs Fleisch
* \date 06 Mar 2015
*
* Copyright (C) 2015 Urs Fleisch
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import Kid3 1.0
Kid3Script {
onRun: {
// Apply the encoding by changing the configuration, applying the changes,
// and then force rereading the tags by deselecting and selecting the
// current file.
function applyEncoding(encNr) {
tagCfg.textEncodingV1Index = encNr
app.applyChangedConfiguration()
app.selectCurrentFile(false)
app.selectCurrentFile(true)
}
if (app.selectionInfo.tagFormatV1) {
var frameNames = ["title", "artist", "album", "comment"]
var tagCfg = configs.tagConfig()
var textEncodings = tagCfg.getTextEncodingV1Names()
var textEncodingV1Index = tagCfg.textEncodingV1Index
var maxEncLen = Math.max.apply(null, textEncodings.map(
function(s) { return s.length; }))
var i
for (var encNr = 0; encNr < textEncodings.length; ++encNr) {
applyEncoding(encNr)
var txt = textEncodings[encNr]
var numSpaces = maxEncLen - txt.length
txt += ":"
for (i = 0; i < numSpaces; ++i) {
txt += " "
}
for (i = 0; i < frameNames.length; ++i) {
if (i > 0) {
txt += " "
}
txt += app.getFrame(tagv1, frameNames[i])
}
console.log(txt)
}
applyEncoding(textEncodingV1Index)
app.applyChangedConfiguration()
}
Qt.quit()
}
}
......@@ -2,4 +2,5 @@ set (script_QML_SRCS
script/ReplayGain2SoundCheck.qml
script/ResizeAlbumArt.qml
script/QmlConsole.qml
script/ShowTextEncodingV1.qml
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment