-
Notifications
You must be signed in to change notification settings - Fork 0
/
decoderxmdxfactory.cpp
101 lines (88 loc) · 2.64 KB
/
decoderxmdxfactory.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include "decoderxmdxfactory.h"
#include "xmdxhelper.h"
#include "decoder_xmdx.h"
#include <QMessageBox>
bool DecoderXMDXFactory::canDecode(QIODevice *input) const
{
const QFile * const file = qobject_cast<QFile*>(input);
if(!file)
{
return false;
}
XMDXHelper helper(file->fileName());
return helper.initialize();
}
DecoderProperties DecoderXMDXFactory::properties() const
{
DecoderProperties properties;
properties.name = tr("XMDX Plugin");
properties.shortName = "xmdx";
properties.filters << "*.mdx" << "*.pdx" << "*.m" << "*.mub" << "*.muc" << "*.vgs" << "*.bgm" << "*.mml";
properties.description = "XMDX Game Audio File";
properties.protocols << "file";
properties.noInput = true;
properties.hasAbout = true;
return properties;
}
Decoder *DecoderXMDXFactory::create(const QString &path, QIODevice *input)
{
Q_UNUSED(input);
return new DecoderXMDX(path);
}
QList<TrackInfo*> DecoderXMDXFactory::createPlayList(const QString &path, TrackInfo::Parts parts, QStringList *)
{
TrackInfo *info = new TrackInfo(path);
if(parts == TrackInfo::Parts())
{
return QList<TrackInfo*>() << info;
}
XMDXHelper helper(path);
if(!helper.initialize())
{
delete info;
return QList<TrackInfo*>();
}
if(parts & TrackInfo::MetaData)
{
info->setValue(Qmmp::TITLE, helper.title());
info->setValue(Qmmp::ARTIST, helper.author());
}
if(parts & TrackInfo::Properties)
{
info->setValue(Qmmp::BITRATE, helper.bitrate());
info->setValue(Qmmp::SAMPLERATE, helper.sampleRate());
info->setValue(Qmmp::CHANNELS, helper.channels());
info->setValue(Qmmp::BITS_PER_SAMPLE, helper.depth());
info->setValue(Qmmp::FORMAT_NAME, "XMDX");
info->setDuration(helper.totalTime());
}
return QList<TrackInfo*>() << info;
}
MetaDataModel* DecoderXMDXFactory::createMetaDataModel(const QString &path, bool readOnly)
{
Q_UNUSED(path);
Q_UNUSED(readOnly);
return nullptr;
}
#if (QMMP_VERSION_INT < 0x10700) || (0x20000 <= QMMP_VERSION_INT && QMMP_VERSION_INT < 0x20200)
void DecoderXMDXFactory::showSettings(QWidget *parent)
{
Q_UNUSED(parent);
}
#else
QDialog *DecoderXMDXFactory::createSettings(QWidget *parent)
{
Q_UNUSED(parent);
return nullptr;
}
#endif
void DecoderXMDXFactory::showAbout(QWidget *parent)
{
QMessageBox::about(parent, tr("About XMDX Reader Plugin"),
tr("Qmmp XMDX Reader Plugin") + "\n" +
tr("Written by: Greedysky <greedysky@163.com>"));
}
QString DecoderXMDXFactory::translation() const
{
return QString();
}