aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Input
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2013-04-28 10:36:58 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2013-04-28 10:36:58 +0000
commit83cfe6146a5fa7e0a310da94bc4e3c4f6370bd1c (patch)
treef9c88b6f670d10605bd5095743f6e54f5dfbaa19 /src/plugins/Input
parenta8ca945c11589553f6550d26c40d7d82f8f38421 (diff)
downloadqmmp-83cfe6146a5fa7e0a310da94bc4e3c4f6370bd1c.tar.gz
qmmp-83cfe6146a5fa7e0a310da94bc4e3c4f6370bd1c.tar.bz2
qmmp-83cfe6146a5fa7e0a310da94bc4e3c4f6370bd1c.zip
sid plugin: added settings dialog
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3422 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Input')
-rw-r--r--src/plugins/Input/sid/decoder_sid.cpp2
-rw-r--r--src/plugins/Input/sid/decodersidfactory.cpp6
-rw-r--r--src/plugins/Input/sid/settingsdialog.cpp79
-rw-r--r--src/plugins/Input/sid/settingsdialog.h46
-rw-r--r--src/plugins/Input/sid/settingsdialog.ui170
-rw-r--r--src/plugins/Input/sid/sid.pro9
-rw-r--r--src/plugins/Input/sid/sidhelper.cpp91
-rw-r--r--src/plugins/Input/sid/sidhelper.h48
8 files changed, 447 insertions, 4 deletions
diff --git a/src/plugins/Input/sid/decoder_sid.cpp b/src/plugins/Input/sid/decoder_sid.cpp
index 89e05feac..bd15965b9 100644
--- a/src/plugins/Input/sid/decoder_sid.cpp
+++ b/src/plugins/Input/sid/decoder_sid.cpp
@@ -24,6 +24,7 @@
#include <sidplayfp/sidbuilder.h>
#include <sidplayfp/SidConfig.h>
#include <sidplayfp/builders/residfp.h>
+#include <sidplayfp/builders/resid.h>
#include <sidplayfp/SidInfo.h>
#include <sidplayfp/SidTuneInfo.h>
#include <sidplayfp/SidDatabase.h>
@@ -92,6 +93,7 @@ bool DecoderSID::initialize()
cfg.samplingMethod = SidConfig::INTERPOLATE;
cfg.playback = SidConfig::STEREO;
cfg.sidEmulation = rs;
+ cfg.fastSampling = false;
if(!m_player->config(cfg))
{
diff --git a/src/plugins/Input/sid/decodersidfactory.cpp b/src/plugins/Input/sid/decodersidfactory.cpp
index 50aa92c7a..f0042032b 100644
--- a/src/plugins/Input/sid/decodersidfactory.cpp
+++ b/src/plugins/Input/sid/decodersidfactory.cpp
@@ -24,6 +24,7 @@
#include <sidplayfp/SidTuneInfo.h>
#include "decoder_sid.h"
#include "sidhelper.h"
+#include "settingsdialog.h"
#include "decodersidfactory.h"
// DecoderSIDFactory
@@ -56,7 +57,7 @@ const DecoderProperties DecoderSIDFactory::properties() const
//properties.contentType = ;
properties.shortName = "sid";
properties.hasAbout = true;
- properties.hasSettings = false;
+ properties.hasSettings = true;
properties.noInput = true;
properties.protocols << "sid";
return properties;
@@ -100,7 +101,8 @@ MetaDataModel* DecoderSIDFactory::createMetaDataModel(const QString &path, QObje
void DecoderSIDFactory::showSettings(QWidget *parent)
{
- Q_UNUSED(parent);
+ SettingsDialog *d = new SettingsDialog(parent);
+ d->show();
}
void DecoderSIDFactory::showAbout(QWidget *parent)
diff --git a/src/plugins/Input/sid/settingsdialog.cpp b/src/plugins/Input/sid/settingsdialog.cpp
new file mode 100644
index 000000000..78db867c6
--- /dev/null
+++ b/src/plugins/Input/sid/settingsdialog.cpp
@@ -0,0 +1,79 @@
+/***************************************************************************
+ * Copyright (C) 2013 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include <QSettings>
+#include <QFileInfo>
+#include <qmmp/qmmp.h>
+#include <sidplayfp/SidConfig.h>
+#include "settingsdialog.h"
+
+SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent)
+{
+ m_ui.setupUi(this);
+ setAttribute(Qt::WA_DeleteOnClose);
+
+ QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
+ settings.beginGroup("SID");
+
+ m_ui.useHVSCCheckBox->setChecked(settings.value("use_hvsc", false).toBool());
+ QString hvsc_default_path = QFileInfo(Qmmp::configFile()).absolutePath() + "/Songlengths.txt";
+ m_ui.hvscPathLineEdit->setText(settings.value("hvsc_path", hvsc_default_path).toString());
+
+ m_ui.sampleRateComboBox->addItem(tr("44100 Hz"), 44100);
+ m_ui.sampleRateComboBox->addItem(tr("48000 Hz"), 48000);
+ int i = m_ui.sampleRateComboBox->findData(settings.value("sample_rate", 44100).toInt());
+ m_ui.sampleRateComboBox->setCurrentIndex(i);
+
+ m_ui.emuComboBox->addItem("ReSID", "resid");
+ m_ui.emuComboBox->addItem("ReSIDfp", "residfp");
+ i = m_ui.emuComboBox->findData(settings.value("engine", "residfp").toString());
+ m_ui.emuComboBox->setCurrentIndex(i);
+
+ m_ui.fastResampligCheckBox->setChecked(settings.value("fast_resampling", false).toBool());
+
+ m_ui.resamplingComboBox->addItem("Interpolate", SidConfig::INTERPOLATE);
+ m_ui.resamplingComboBox->addItem("Resample interpolate", SidConfig::RESAMPLE_INTERPOLATE);
+ i = m_ui.resamplingComboBox->findData(settings.value("resampling_method", SidConfig::INTERPOLATE).toInt());
+ m_ui.resamplingComboBox->setCurrentIndex(i);
+
+ settings.endGroup();
+}
+
+SettingsDialog::~SettingsDialog()
+{
+}
+
+void SettingsDialog::accept()
+{
+ QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
+ settings.beginGroup("SID");
+ settings.setValue("use_hvsc", m_ui.useHVSCCheckBox->isChecked());
+ settings.setValue("hvsc_path", m_ui.hvscPathLineEdit->text());
+ int i = m_ui.sampleRateComboBox->currentIndex();
+ if(i >= 0)
+ settings.setValue("sample_rate", m_ui.sampleRateComboBox->itemData(i));
+ if((i = m_ui.emuComboBox->currentIndex()) >= 0)
+ settings.setValue("engine", m_ui.emuComboBox->itemData(i));
+ settings.setValue("fast_resampling", m_ui.fastResampligCheckBox->isChecked());
+ if((i = m_ui.resamplingComboBox->currentIndex()) >= 0)
+ settings.setValue("resampling_method", m_ui.resamplingComboBox->itemData(i));
+ settings.endGroup();
+ QDialog::accept();
+}
diff --git a/src/plugins/Input/sid/settingsdialog.h b/src/plugins/Input/sid/settingsdialog.h
new file mode 100644
index 000000000..c1a9ff2f0
--- /dev/null
+++ b/src/plugins/Input/sid/settingsdialog.h
@@ -0,0 +1,46 @@
+/***************************************************************************
+ * Copyright (C) 2013 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#ifndef SETTINGSDIALOG_H
+#define SETTINGSDIALOG_H
+
+#include <QDialog>
+
+#include "ui_settingsdialog.h"
+
+/**
+ @author Ilya Kotov <forkotov02@hotmail.ru>
+*/
+class SettingsDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ SettingsDialog(QWidget *parent = 0);
+
+ ~SettingsDialog();
+
+public slots:
+ virtual void accept();
+
+private:
+ Ui::SettingsDialog m_ui;
+
+};
+
+#endif
diff --git a/src/plugins/Input/sid/settingsdialog.ui b/src/plugins/Input/sid/settingsdialog.ui
new file mode 100644
index 000000000..735b36b52
--- /dev/null
+++ b/src/plugins/Input/sid/settingsdialog.ui
@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SettingsDialog</class>
+ <widget class="QDialog" name="SettingsDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>386</width>
+ <height>263</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>SID Plugin Settings</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <property name="leftMargin">
+ <number>6</number>
+ </property>
+ <property name="rightMargin">
+ <number>6</number>
+ </property>
+ <property name="bottomMargin">
+ <number>6</number>
+ </property>
+ <item row="2" column="1">
+ <widget class="QSpinBox" name="defaultLengthSpinBox">
+ <property name="minimum">
+ <number>5</number>
+ </property>
+ <property name="maximum">
+ <number>1000</number>
+ </property>
+ <property name="value">
+ <number>180</number>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="0" colspan="2">
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="0" colspan="2">
+ <widget class="QCheckBox" name="fastResampligCheckBox">
+ <property name="text">
+ <string>Fast resampling</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Sample rate:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>HVSC database file:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Resampling method:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QComboBox" name="sampleRateComboBox"/>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="hvscPathLineEdit">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Defaults song length, sec:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" colspan="2">
+ <widget class="QCheckBox" name="useHVSCCheckBox">
+ <property name="text">
+ <string>Enable HVSC song length database</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Emulation:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QComboBox" name="emuComboBox"/>
+ </item>
+ <item row="6" column="1">
+ <widget class="QComboBox" name="resamplingComboBox"/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>SettingsDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>220</x>
+ <y>229</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>103</x>
+ <y>160</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>SettingsDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>275</x>
+ <y>229</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>148</x>
+ <y>169</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>useHVSCCheckBox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>hvscPathLineEdit</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>188</x>
+ <y>24</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>186</x>
+ <y>47</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/src/plugins/Input/sid/sid.pro b/src/plugins/Input/sid/sid.pro
index 4d5e09c8f..efb47ca18 100644
--- a/src/plugins/Input/sid/sid.pro
+++ b/src/plugins/Input/sid/sid.pro
@@ -2,10 +2,12 @@ include(../../plugins.pri)
HEADERS += decodersidfactory.h \
decoder_sid.h \
- sidhelper.h
+ sidhelper.h \
+ settingsdialog.h
SOURCES += decoder_sid.cpp \
decodersidfactory.cpp \
- sidhelper.cpp
+ sidhelper.cpp \
+ settingsdialog.cpp
TARGET = $$PLUGINS_PREFIX/Input/sid
QMAKE_CLEAN = $$PLUGINS_PREFIX/Input/libsid.so
INCLUDEPATH += ../../../
@@ -44,3 +46,6 @@ win32 {
QMAKE_LIBDIR += ../../../../bin
LIBS += -lqmmp0 -lsidplayfp.dll
}
+
+FORMS += \
+ settingsdialog.ui
diff --git a/src/plugins/Input/sid/sidhelper.cpp b/src/plugins/Input/sid/sidhelper.cpp
new file mode 100644
index 000000000..bc6091d7d
--- /dev/null
+++ b/src/plugins/Input/sid/sidhelper.cpp
@@ -0,0 +1,91 @@
+/***************************************************************************
+ * Copyright (C) 2013 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include <QRegExp>
+#include <sidplayfp/SidDatabase.h>
+#include "sidhelper.h"
+
+SIDHelper::SIDHelper()
+{
+ m_tune = 0;
+ m_database.open("/home/user/.qmmp/Songlengths.txt");
+}
+
+SIDHelper::~SIDHelper()
+{
+ if(m_tune)
+ delete m_tune;
+ m_tune = 0;
+}
+
+SidTune *SIDHelper::load(const QString &url)
+{
+ if(m_tune)
+ {
+ delete m_tune;
+ m_tune = 0;
+ }
+ QString path = url;
+ int track = 1;
+ if(url.contains("://"))
+ {
+ path.remove("sid://");
+ path.remove(QRegExp("#\\d+$"));
+ track = url.section("#", -1).toInt();
+ }
+ m_tune = new SidTune(qPrintable(path));
+ m_tune->selectSong(track - 1);
+ m_path = path;
+ return m_tune;
+}
+
+QList <FileInfo*> SIDHelper::createPlayList(bool meta)
+{
+ QList <FileInfo*> list;
+ if(!m_tune || !m_tune->getInfo())
+ return list;
+ int count = m_tune->getInfo()->songs();
+
+ char md5[SidTune::MD5_LENGTH];
+ m_tune->createMD5(md5);
+
+ for(int i = 1; i <= count; ++i)
+ {
+ m_tune->selectSong(i+1);
+ FileInfo *info = new FileInfo();
+
+ if(meta)
+ {
+ const SidTuneInfo *tune_info = m_tune->getInfo();
+ info->setMetaData(Qmmp::TITLE, tune_info->infoString(0));
+ info->setMetaData(Qmmp::ARTIST, tune_info->infoString(1));
+ info->setMetaData(Qmmp::COMMENT, tune_info->commentString(0));
+ info->setMetaData(Qmmp::TRACK, i);
+ }
+ int length = m_database.length(md5, i);
+ if(length > -1)
+ info->setLength(length);
+
+ info->setPath("sid://" + m_path + QString("#%1").arg(i));
+ list << info;
+ }
+ return list;
+}
+
diff --git a/src/plugins/Input/sid/sidhelper.h b/src/plugins/Input/sid/sidhelper.h
new file mode 100644
index 000000000..c3640d0d8
--- /dev/null
+++ b/src/plugins/Input/sid/sidhelper.h
@@ -0,0 +1,48 @@
+/***************************************************************************
+ * Copyright (C) 2013 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#ifndef SIDHELPER_H
+#define SIDHELPER_H
+
+#include <QString>
+#include <QList>
+#include <sidplayfp/SidTune.h>
+#include <sidplayfp/SidTuneInfo.h>
+#include <sidplayfp/SidDatabase.h>
+#include <qmmp/fileinfo.h>
+
+/**
+ @author Ilya Kotov <forkotov02@hotmail.ru>
+*/
+class SIDHelper
+{
+public:
+ SIDHelper();
+ ~SIDHelper();
+ SidTune *load(const QString &url);
+ QList <FileInfo*> createPlayList(bool meta);
+
+private:
+ QString m_path;
+ SidTune *m_tune;
+ SidDatabase m_database;
+};
+
+#endif // SIDHELPER_H