-
Notifications
You must be signed in to change notification settings - Fork 1
/
decoderadplugfactory.cpp
120 lines (107 loc) · 3.73 KB
/
decoderadplugfactory.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include "decoderadplugfactory.h"
#include "adplughelper.h"
#include "decoder_adplug.h"
#include "adplugmetadatamodel.h"
#include "settingsdialog.h"
#include <QMessageBox>
bool DecoderAdPlugFactory::canDecode(QIODevice *input) const
{
const QFile * const file = qobject_cast<QFile*>(input);
if(!file)
{
return false;
}
AdPlugHelper helper(file->fileName());
return helper.initialize();
}
DecoderProperties DecoderAdPlugFactory::properties() const
{
DecoderProperties properties;
properties.name = tr("AdPlug Plugin");
properties.shortName = "adplug";
properties.filters << "*.a2m" << "*.adl" << "*.adlib" << "*.agd" << "*.amd" << "*.as3m";
properties.filters << "*.bam" << "*.bmf";
properties.filters << "*.cff" << "*.cmf";
properties.filters << "*.d00" << "*.dfm" << "*.dmo" << "*.dro" << "*.dtm";
properties.filters << "*.got";
properties.filters << "*.ha2" << "*.hsc" << "*.hsq" << "*.hsp";
properties.filters << "*.imf" << "*.ims";
properties.filters << "*.jbm";
properties.filters << "*.laa" << "*.lds";
properties.filters << "*.m" << "*.mad" << "*.mdi" << "*.mkj" << "*.msc" << "*.mtk" << "*.mus";
properties.filters << "*.rac" << "*.rad" << "*.raw" << "*.rix";
properties.filters << "*.s3m" << "*.sa2" << "*.sat" << "*.sdb" << "*.sng" << "*.sop" << "*.sqx";
properties.filters << "*.xad" << "*.xms" << "*.xsm";
properties.filters << "*.vgm" << "*.vgz";
properties.filters << "*.wlf";
// pair suffix section
properties.filters << "*.ksm"; // (ksm, dat)
properties.filters << "*.rol"; // (rol, bnk)
properties.filters << "*.sci"; // (sci, name)
properties.description = "AdLib Sound File";
properties.protocols << "file";
properties.hasSettings = true;
properties.noInput = true;
properties.hasAbout = true;
return properties;
}
Decoder *DecoderAdPlugFactory::create(const QString &path, QIODevice *input)
{
Q_UNUSED(input);
return new DecoderAdPlug(path);
}
QList<TrackInfo*> DecoderAdPlugFactory::createPlayList(const QString &path, TrackInfo::Parts parts, QStringList *)
{
TrackInfo *info = new TrackInfo(path);
if(parts == TrackInfo::Parts())
{
return QList<TrackInfo*>() << info;
}
AdPlugHelper 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, "AdLib Sound");
info->setDuration(helper.totalTime());
}
return QList<TrackInfo*>() << info;
}
MetaDataModel *DecoderAdPlugFactory::createMetaDataModel(const QString &path, bool readOnly)
{
Q_UNUSED(readOnly);
return new AdPlugMetaDataModel(path);
}
#if (QMMP_VERSION_INT < 0x10700) || (0x20000 <= QMMP_VERSION_INT && QMMP_VERSION_INT < 0x20200)
void DecoderAdPlugFactory::showSettings(QWidget *parent)
{
(new SettingsDialog(parent))->show();
}
#else
QDialog *DecoderAdPlugFactory::createSettings(QWidget *parent)
{
return SettingsDialog(parent);
}
#endif
void DecoderAdPlugFactory::showAbout(QWidget *parent)
{
QMessageBox::about(parent, tr("About AdPlug Reader Plugin"),
tr("Qmmp AdPlug Reader Plugin") + "\n" +
tr("Written by: Greedysky <greedysky@163.com>"));
}
QString DecoderAdPlugFactory::translation() const
{
return QString();
}