fix 22896: add character set selection for guitar pro import
This commit is contained in:
parent
2f916a235e
commit
7917a380ca
6 changed files with 63 additions and 37 deletions
|
@ -41,6 +41,7 @@
|
|||
#include "libmscore/tremolobar.h"
|
||||
#include "libmscore/segment.h"
|
||||
#include "libmscore/rehearsalmark.h"
|
||||
#include "preferences.h"
|
||||
|
||||
namespace Ms {
|
||||
|
||||
|
@ -76,6 +77,7 @@ GuitarPro::GuitarPro(Score* s, int v)
|
|||
{
|
||||
score = s;
|
||||
version = v;
|
||||
_codec = QTextCodec::codecForName(preferences.importCharsetGP.toLatin1());
|
||||
}
|
||||
|
||||
GuitarPro::~GuitarPro()
|
||||
|
@ -142,7 +144,10 @@ QString GuitarPro::readPascalString(int n)
|
|||
read(s, l);
|
||||
s[l] = 0;
|
||||
skip(n - l);
|
||||
return QString(s);
|
||||
if(_codec)
|
||||
return _codec->toUnicode(s);
|
||||
else
|
||||
return QString(s);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -155,7 +160,10 @@ QString GuitarPro::readWordPascalString()
|
|||
char c[l+1];
|
||||
read(c, l);
|
||||
c[l] = 0;
|
||||
return QString::fromLocal8Bit(c);
|
||||
if(_codec)
|
||||
return _codec->toUnicode(c);
|
||||
else
|
||||
return QString::fromLocal8Bit(c);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -168,7 +176,10 @@ QString GuitarPro::readBytePascalString()
|
|||
char c[l+1];
|
||||
read(c, l);
|
||||
c[l] = 0;
|
||||
return QString::fromLocal8Bit(c);
|
||||
if(_codec)
|
||||
return _codec->toUnicode(c);
|
||||
else
|
||||
return QString::fromLocal8Bit(c);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -186,7 +197,10 @@ QString GuitarPro::readDelphiString()
|
|||
char c[l + 1];
|
||||
read(c, l);
|
||||
c[l] = 0;
|
||||
return QString::fromLatin1(c);
|
||||
if(_codec)
|
||||
return _codec->toUnicode(c);
|
||||
else
|
||||
return QString::fromLatin1(c);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
|
|
@ -74,6 +74,8 @@ class GuitarPro {
|
|||
QFile* f;
|
||||
int curPos;
|
||||
|
||||
QTextCodec* _codec;
|
||||
|
||||
void skip(qint64 len);
|
||||
void read(void* p, qint64 len);
|
||||
int readUChar();
|
||||
|
|
|
@ -2391,7 +2391,7 @@ Score::FileError importOve(Score* score, const QString& name) {
|
|||
|
||||
oveFile.close();
|
||||
|
||||
oveSong.setTextCodecName(preferences.importCharset);
|
||||
oveSong.setTextCodecName(preferences.importCharsetOve);
|
||||
oveLoader->setOve(&oveSong);
|
||||
oveLoader->setFileStream((unsigned char*) buffer.data(), buffer.size());
|
||||
bool result = oveLoader->load();
|
||||
|
|
|
@ -172,7 +172,8 @@ void Preferences::init()
|
|||
checkUpdateStartup = 0;
|
||||
|
||||
followSong = true;
|
||||
importCharset = "GBK";
|
||||
importCharsetOve = "GBK";
|
||||
importCharsetGP = "UTF-8";
|
||||
importStyleFile = "";
|
||||
shortestNote = MScore::division/4;
|
||||
|
||||
|
@ -313,7 +314,8 @@ void Preferences::write()
|
|||
s.setValue("defaultPlayDuration", MScore::defaultPlayDuration);
|
||||
s.setValue("importStyleFile", importStyleFile);
|
||||
s.setValue("shortestNote", shortestNote);
|
||||
s.setValue("importCharset", importCharset);
|
||||
s.setValue("importCharsetOve", importCharsetOve);
|
||||
s.setValue("importCharsetGP", importCharsetGP);
|
||||
s.setValue("warnPitchRange", MScore::warnPitchRange);
|
||||
s.setValue("followSong", followSong);
|
||||
|
||||
|
@ -453,7 +455,8 @@ void Preferences::read()
|
|||
MScore::defaultPlayDuration = s.value("defaultPlayDuration", MScore::defaultPlayDuration).toInt();
|
||||
importStyleFile = s.value("importStyleFile", importStyleFile).toString();
|
||||
shortestNote = s.value("shortestNote", shortestNote).toInt();
|
||||
importCharset = s.value("importCharset", importCharset).toString();
|
||||
importCharsetOve = s.value("importCharsetOve", importCharsetOve).toString();
|
||||
importCharsetGP = s.value("importCharsetGP", importCharsetGP).toString();
|
||||
MScore::warnPitchRange = s.value("warnPitchRange", MScore::warnPitchRange).toBool();
|
||||
followSong = s.value("followSong", followSong).toBool();
|
||||
|
||||
|
@ -947,14 +950,18 @@ void PreferenceDialog::updateValues()
|
|||
useImportBuildinStyle->setChecked(prefs.importStyleFile.isEmpty());
|
||||
useImportStyleFile->setChecked(!prefs.importStyleFile.isEmpty());
|
||||
|
||||
importCharsetList->clear();
|
||||
QList<QByteArray> charsets = QTextCodec::availableCodecs();
|
||||
qSort(charsets.begin(), charsets.end());
|
||||
int idx = 0;
|
||||
importCharsetListOve->clear();
|
||||
importCharsetListGP->clear();
|
||||
foreach (QByteArray charset, charsets) {
|
||||
importCharsetList->addItem(charset);
|
||||
if (charset == prefs.importCharset)
|
||||
importCharsetList->setCurrentIndex(idx);
|
||||
importCharsetListOve->addItem(charset);
|
||||
importCharsetListGP->addItem(charset);
|
||||
if (charset == prefs.importCharsetOve)
|
||||
importCharsetListOve->setCurrentIndex(idx);
|
||||
if (charset == prefs.importCharsetGP)
|
||||
importCharsetListGP->setCurrentIndex(idx);
|
||||
idx++;
|
||||
}
|
||||
|
||||
|
@ -1397,7 +1404,8 @@ void PreferenceDialog::apply()
|
|||
}
|
||||
prefs.shortestNote = ticks;
|
||||
|
||||
prefs.importCharset = importCharsetList->currentText();
|
||||
prefs.importCharsetOve = importCharsetListOve->currentText();
|
||||
prefs.importCharsetGP = importCharsetListGP->currentText();
|
||||
MScore::warnPitchRange = warnPitchRange->isChecked();
|
||||
|
||||
prefs.useOsc = oscServer->isChecked();
|
||||
|
|
|
@ -144,7 +144,8 @@ struct Preferences {
|
|||
int checkUpdateStartup;
|
||||
|
||||
bool followSong;
|
||||
QString importCharset;
|
||||
QString importCharsetOve;
|
||||
QString importCharsetGP;
|
||||
QString importStyleFile;
|
||||
int shortestNote; // for midi input
|
||||
MidiImportOperations midiImportOperations;
|
||||
|
|
|
@ -2361,34 +2361,35 @@
|
|||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_20">
|
||||
<property name="title">
|
||||
<string>Character Set used when import non-unicode strings. (For binary file import)</string>
|
||||
<string>Character set used when importing binary files</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_12">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_49">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Character Set:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="importCharsetList">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_49">
|
||||
<property name="text">
|
||||
<string>Overture import character set:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="importCharsetListOve"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_23">
|
||||
<property name="text">
|
||||
<string>Guitar Pro import character set:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="importCharsetListGP"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
Loading…
Reference in a new issue