From f2cfda2a54780868dfe0af7bd652fcd4906547da Mon Sep 17 00:00:00 2001
From: tpearson
Date: Mon, 1 Mar 2010 19:09:31 +0000
Subject: Added KDE3 version of SoundKonverter
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/soundkonverter@1097614 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
---
src/Makefile.am | 58 +
src/amarokscript/Makefile.am | 3 +
src/amarokscript/README | 43 +
src/amarokscript/soundKonverter.rb | 296 ++++
src/audiocd_extract_with_soundkonverter.desktop | 11 +
src/cddb.cpp | 669 ++++++++
src/cddb.h | 79 +
src/cdmanager.cpp | 190 +++
src/cdmanager.h | 95 ++
src/cdopener.cpp | 781 ++++++++++
src/cdopener.h | 139 ++
src/combobutton.cpp | 114 ++
src/combobutton.h | 110 ++
src/config.cpp | 1516 ++++++++++++++++++
src/config.h | 354 +++++
src/configbackendspage.cpp | 493 ++++++
src/configbackendspage.h | 81 +
src/configdialog.cpp | 174 +++
src/configdialog.h | 79 +
src/configenvironmentpage.cpp | 223 +++
src/configenvironmentpage.h | 62 +
src/configgeneralpage.cpp | 323 ++++
src/configgeneralpage.h | 69 +
src/configpagebase.cpp | 20 +
src/configpagebase.h | 38 +
src/configpluginspage.cpp | 639 ++++++++
src/configpluginspage.h | 82 +
src/conversionoptions.cpp | 86 ++
src/conversionoptions.h | 65 +
src/convert.cpp | 1615 ++++++++++++++++++++
src/convert.h | 281 ++++
src/cuesheeteditor.cpp | 325 ++++
src/cuesheeteditor.h | 50 +
src/dcopinterface.h | 58 +
src/dirdialog.cpp | 154 ++
src/dirdialog.h | 65 +
src/filelist.cpp | 1445 ++++++++++++++++++
src/filelist.h | 235 +++
src/hi16-app-soundkonverter.png | Bin 0 -> 782 bytes
src/hi16-app-soundkonverter_replaygain.png | Bin 0 -> 855 bytes
src/hi22-app-soundkonverter.png | Bin 0 -> 1200 bytes
src/hi22-app-soundkonverter_replaygain.png | Bin 0 -> 1313 bytes
src/hi32-app-soundkonverter.png | Bin 0 -> 2101 bytes
src/hi32-app-soundkonverter_replaygain.png | Bin 0 -> 2023 bytes
src/hi48-app-soundkonverter.png | Bin 0 -> 3976 bytes
src/hi48-app-soundkonverter_replaygain.png | Bin 0 -> 3676 bytes
src/hi64-app-soundkonverter.png | Bin 0 -> 6144 bytes
src/hi64-app-soundkonverter_replaygain.png | Bin 0 -> 5759 bytes
src/logger.cpp | 149 ++
src/logger.h | 100 ++
src/logviewer.cpp | 204 +++
src/logviewer.h | 111 ++
src/main.cpp | 75 +
src/metadata/Makefile.am | 37 +
src/metadata/aac/Makefile.am | 12 +
src/metadata/aac/aacfiletyperesolver.cpp | 38 +
src/metadata/aac/aacfiletyperesolver.h | 36 +
src/metadata/ape/Makefile.am | 6 +
.../ape/taglib_monkeysaudiofiletyperesolver.cpp | 21 +
.../ape/taglib_monkeysaudiofiletyperesolver.h | 19 +
src/metadata/asf/Makefile.am | 20 +
src/metadata/asf/asfattribute.cpp | 304 ++++
src/metadata/asf/asfattribute.h | 176 +++
src/metadata/asf/asffile.cpp | 547 +++++++
src/metadata/asf/asffile.h | 114 ++
src/metadata/asf/asfproperties.cpp | 95 ++
src/metadata/asf/asfproperties.h | 69 +
src/metadata/asf/asftag.cpp | 202 +++
src/metadata/asf/asftag.h | 181 +++
src/metadata/asf/taglib_asffiletyperesolver.cpp | 47 +
src/metadata/asf/taglib_asffiletyperesolver.h | 42 +
src/metadata/audible/Makefile.am | 17 +
src/metadata/audible/audibleproperties.cpp | 86 ++
src/metadata/audible/audibleproperties.h | 85 ++
src/metadata/audible/audibletag.cpp | 163 ++
src/metadata/audible/audibletag.h | 185 +++
src/metadata/audible/taglib_audiblefile.cpp | 121 ++
src/metadata/audible/taglib_audiblefile.h | 93 ++
.../audible/taglib_audiblefiletyperesolver.cpp | 44 +
.../audible/taglib_audiblefiletyperesolver.h | 36 +
src/metadata/m4a/Makefile.am | 84 +
src/metadata/m4a/boxfactory.cpp | 150 ++
src/metadata/m4a/boxfactory.h | 45 +
src/metadata/m4a/itunesalbbox.cpp | 89 ++
src/metadata/m4a/itunesalbbox.h | 50 +
src/metadata/m4a/itunesartbox.cpp | 89 ++
src/metadata/m4a/itunesartbox.h | 50 +
src/metadata/m4a/itunescmtbox.cpp | 89 ++
src/metadata/m4a/itunescmtbox.h | 50 +
src/metadata/m4a/itunescvrbox.cpp | 89 ++
src/metadata/m4a/itunescvrbox.h | 50 +
src/metadata/m4a/itunesdatabox.cpp | 63 +
src/metadata/m4a/itunesdatabox.h | 53 +
src/metadata/m4a/itunesdaybox.cpp | 89 ++
src/metadata/m4a/itunesdaybox.h | 50 +
src/metadata/m4a/itunesdiskbox.cpp | 93 ++
src/metadata/m4a/itunesdiskbox.h | 50 +
src/metadata/m4a/itunesgenbox.cpp | 89 ++
src/metadata/m4a/itunesgenbox.h | 50 +
src/metadata/m4a/itunesgrpbox.cpp | 89 ++
src/metadata/m4a/itunesgrpbox.h | 50 +
src/metadata/m4a/itunesnambox.cpp | 89 ++
src/metadata/m4a/itunesnambox.h | 50 +
src/metadata/m4a/itunestmpobox.cpp | 93 ++
src/metadata/m4a/itunestmpobox.h | 50 +
src/metadata/m4a/itunestrknbox.cpp | 93 ++
src/metadata/m4a/itunestrknbox.h | 50 +
src/metadata/m4a/ituneswrtbox.cpp | 89 ++
src/metadata/m4a/ituneswrtbox.h | 50 +
src/metadata/m4a/mp4audioproperties.cpp | 75 +
src/metadata/m4a/mp4audioproperties.h | 73 +
src/metadata/m4a/mp4audiosampleentry.cpp | 146 ++
src/metadata/m4a/mp4audiosampleentry.h | 57 +
src/metadata/m4a/mp4file.cpp | 377 +++++
src/metadata/m4a/mp4file.h | 169 ++
src/metadata/m4a/mp4fourcc.cpp | 84 +
src/metadata/m4a/mp4fourcc.h | 63 +
src/metadata/m4a/mp4hdlrbox.cpp | 75 +
src/metadata/m4a/mp4hdlrbox.h | 53 +
src/metadata/m4a/mp4ilstbox.cpp | 97 ++
src/metadata/m4a/mp4ilstbox.h | 49 +
src/metadata/m4a/mp4isobox.cpp | 76 +
src/metadata/m4a/mp4isobox.h | 67 +
src/metadata/m4a/mp4isofullbox.cpp | 67 +
src/metadata/m4a/mp4isofullbox.h | 57 +
src/metadata/m4a/mp4itunestag.cpp | 197 +++
src/metadata/m4a/mp4itunestag.h | 95 ++
src/metadata/m4a/mp4mdiabox.cpp | 111 ++
src/metadata/m4a/mp4mdiabox.h | 49 +
src/metadata/m4a/mp4metabox.cpp | 86 ++
src/metadata/m4a/mp4metabox.h | 49 +
src/metadata/m4a/mp4minfbox.cpp | 104 ++
src/metadata/m4a/mp4minfbox.h | 51 +
src/metadata/m4a/mp4moovbox.cpp | 86 ++
src/metadata/m4a/mp4moovbox.h | 49 +
src/metadata/m4a/mp4mvhdbox.cpp | 140 ++
src/metadata/m4a/mp4mvhdbox.h | 65 +
src/metadata/m4a/mp4propsproxy.cpp | 89 ++
src/metadata/m4a/mp4propsproxy.h | 65 +
src/metadata/m4a/mp4sampleentry.cpp | 59 +
src/metadata/m4a/mp4sampleentry.h | 54 +
src/metadata/m4a/mp4skipbox.cpp | 50 +
src/metadata/m4a/mp4skipbox.h | 50 +
src/metadata/m4a/mp4stblbox.cpp | 105 ++
src/metadata/m4a/mp4stblbox.h | 51 +
src/metadata/m4a/mp4stsdbox.cpp | 91 ++
src/metadata/m4a/mp4stsdbox.h | 51 +
src/metadata/m4a/mp4tagsproxy.cpp | 168 ++
src/metadata/m4a/mp4tagsproxy.h | 99 ++
src/metadata/m4a/mp4trakbox.cpp | 86 ++
src/metadata/m4a/mp4trakbox.h | 49 +
src/metadata/m4a/mp4udtabox.cpp | 95 ++
src/metadata/m4a/mp4udtabox.h | 49 +
src/metadata/m4a/taglib_mp4filetyperesolver.cpp | 42 +
src/metadata/m4a/taglib_mp4filetyperesolver.h | 36 +
src/metadata/mp4/Makefile.am | 18 +
src/metadata/optimfrog/Makefile.am | 6 +
.../optimfrog/taglib_optimfrogfiletyperesolver.cpp | 21 +
.../optimfrog/taglib_optimfrogfiletyperesolver.h | 19 +
src/metadata/rmff/Makefile.am | 15 +
src/metadata/rmff/rmff.cpp | 998 ++++++++++++
src/metadata/rmff/rmff.h | 348 +++++
src/metadata/rmff/taglib_realmediafile.cpp | 213 +++
src/metadata/rmff/taglib_realmediafile.h | 133 ++
.../rmff/taglib_realmediafiletyperesolver.cpp | 53 +
.../rmff/taglib_realmediafiletyperesolver.h | 39 +
src/metadata/speex/Makefile.am | 16 +
src/metadata/speex/speexfile.cpp | 111 ++
src/metadata/speex/speexfile.h | 93 ++
src/metadata/speex/speexproperties.cpp | 171 +++
src/metadata/speex/speexproperties.h | 83 +
.../speex/taglib_speexfiletyperesolver.cpp | 44 +
src/metadata/speex/taglib_speexfiletyperesolver.h | 36 +
src/metadata/tagengine.cpp | 419 +++++
src/metadata/tagengine.h | 79 +
src/metadata/tplugins.cpp | 151 ++
src/metadata/tplugins.h | 27 +
src/metadata/trueaudio/Makefile.am | 16 +
src/metadata/trueaudio/combinedtag.h | 171 +++
.../trueaudio/taglib_trueaudiofiletyperesolver.cpp | 44 +
.../trueaudio/taglib_trueaudiofiletyperesolver.h | 36 +
src/metadata/trueaudio/ttafile.cpp | 307 ++++
src/metadata/trueaudio/ttafile.h | 178 +++
src/metadata/trueaudio/ttaproperties.cpp | 134 ++
src/metadata/trueaudio/ttaproperties.h | 86 ++
src/metadata/wav/Makefile.am | 15 +
src/metadata/wav/wavfile.cpp | 115 ++
src/metadata/wav/wavfile.h | 92 ++
src/metadata/wav/wavfiletyperesolver.cpp | 44 +
src/metadata/wav/wavfiletyperesolver.h | 36 +
src/metadata/wav/wavproperties.cpp | 108 ++
src/metadata/wav/wavproperties.h | 85 ++
src/metadata/wavpack/Makefile.am | 16 +
src/metadata/wavpack/combinedtag.h | 171 +++
.../wavpack/taglib_wavpackfiletyperesolver.cpp | 44 +
.../wavpack/taglib_wavpackfiletyperesolver.h | 36 +
src/metadata/wavpack/wvfile.cpp | 311 ++++
src/metadata/wavpack/wvfile.h | 160 ++
src/metadata/wavpack/wvproperties.cpp | 141 ++
src/metadata/wavpack/wvproperties.h | 86 ++
src/options.cpp | 273 ++++
src/options.h | 123 ++
src/optionsdetailed.cpp | 911 +++++++++++
src/optionsdetailed.h | 145 ++
src/optionseditor.cpp | 729 +++++++++
src/optionseditor.h | 146 ++
src/optionsrequester.cpp | 98 ++
src/optionsrequester.h | 54 +
src/optionssimple.cpp | 574 +++++++
src/optionssimple.h | 107 ++
src/outputdirectory.cpp | 571 +++++++
src/outputdirectory.h | 92 ++
src/paranoia.cpp | 257 ++++
src/paranoia.h | 59 +
src/pics/Makefile.am | 7 +
src/pics/ledgreen.png | Bin 0 -> 544 bytes
src/pics/ledgreen_legend.png | Bin 0 -> 533 bytes
src/pics/ledred.png | Bin 0 -> 522 bytes
src/pics/ledred_legend.png | Bin 0 -> 515 bytes
src/pics/ledyellow.png | Bin 0 -> 514 bytes
src/pics/ledyellow_legend.png | Bin 0 -> 509 bytes
src/pluginloader/Makefile.am | 9 +
src/pluginloader/convertpluginloader.cpp | 265 ++++
src/pluginloader/convertpluginloader.h | 190 +++
src/pluginloader/formatinfoloader.cpp | 88 ++
src/pluginloader/formatinfoloader.h | 67 +
src/pluginloader/pluginloaderbase.cpp | 17 +
src/pluginloader/pluginloaderbase.h | 86 ++
src/pluginloader/replaygainpluginloader.cpp | 116 ++
src/pluginloader/replaygainpluginloader.h | 89 ++
src/pluginloader/ripperpluginloader.cpp | 111 ++
src/pluginloader/ripperpluginloader.h | 84 +
src/plugins/Makefile.am | 5 +
src/plugins/format_infos/3gp.xml | 4 +
src/plugins/format_infos/Makefile.am | 5 +
src/plugins/format_infos/aac.xml | 4 +
src/plugins/format_infos/ac3.xml | 4 +
src/plugins/format_infos/aiff.xml | 4 +
src/plugins/format_infos/amr.xml | 4 +
src/plugins/format_infos/ape.xml | 4 +
src/plugins/format_infos/au.xml | 4 +
src/plugins/format_infos/avi.xml | 4 +
src/plugins/format_infos/bonk.xml | 4 +
src/plugins/format_infos/flac.xml | 4 +
src/plugins/format_infos/la.xml | 4 +
src/plugins/format_infos/m4a.xml | 4 +
src/plugins/format_infos/mid.xml | 4 +
src/plugins/format_infos/mod.xml | 4 +
src/plugins/format_infos/mp2.xml | 4 +
src/plugins/format_infos/mp3.xml | 4 +
src/plugins/format_infos/mpc.xml | 4 +
src/plugins/format_infos/ofc.xml | 4 +
src/plugins/format_infos/ofr.xml | 4 +
src/plugins/format_infos/ofs.xml | 4 +
src/plugins/format_infos/ogg.xml | 4 +
src/plugins/format_infos/pac.xml | 4 +
src/plugins/format_infos/qt.xml | 4 +
src/plugins/format_infos/ra.xml | 4 +
src/plugins/format_infos/shn.xml | 4 +
src/plugins/format_infos/spx.xml | 4 +
src/plugins/format_infos/tta.xml | 4 +
src/plugins/format_infos/wma.xml | 4 +
src/plugins/format_infos/wv.xml | 4 +
src/plugins/format_infos/wvc.xml | 4 +
src/plugins/mime_types/Makefile.am | 11 +
src/plugins/mime_types/amr.soundkonverter.desktop | 8 +
.../mime_types/x-ape.soundkonverter.desktop | 8 +
.../mime_types/x-bonk.soundkonverter.desktop | 8 +
.../mime_types/x-flv.soundkonverter.desktop | 8 +
src/plugins/mime_types/x-la.soundkonverter.desktop | 8 +
.../mime_types/x-ofc.soundkonverter.desktop | 8 +
.../mime_types/x-ofr.soundkonverter.desktop | 8 +
.../mime_types/x-ofs.soundkonverter.desktop | 8 +
.../mime_types/x-pac.soundkonverter.desktop | 8 +
.../mime_types/x-shorten.soundkonverter.desktop | 8 +
.../mime_types/x-tta.soundkonverter.desktop | 8 +
.../x-wavpack-correction.soundkonverter.desktop | 8 +
.../mime_types/x-wavpack.soundkonverter.desktop | 8 +
.../plugins/110.oggvorbis.soundkonverter.xml | 18 +
src/plugins/plugins/120.lame.soundkonverter.xml | 22 +
src/plugins/plugins/122.twolame.soundkonverter.xml | 15 +
src/plugins/plugins/123.toolame.soundkonverter.xml | 15 +
src/plugins/plugins/125.gogo.soundkonverter.xml | 18 +
src/plugins/plugins/127.faac.soundkonverter.xml | 15 +
.../plugins/130.musepack.soundkonverter.xml | 11 +
src/plugins/plugins/132.aften.soundkonverter.xml | 13 +
src/plugins/plugins/135.flac.soundkonverter.xml | 11 +
src/plugins/plugins/136.flake.soundkonverter.xml | 8 +
src/plugins/plugins/137.mac.soundkonverter.xml | 10 +
src/plugins/plugins/140.mplayer.soundkonverter.xml | 5 +
src/plugins/plugins/145.ffmpeg.soundkonverter.xml | 16 +
.../plugins/146.ffmpeg-lossless.soundkonverter.xml | 10 +
src/plugins/plugins/150.shorten.soundkonverter.xml | 9 +
src/plugins/plugins/151.tta.soundkonverter.xml | 8 +
src/plugins/plugins/153.bonk.soundkonverter.xml | 12 +
.../plugins/155.optimfrog.soundkonverter.xml | 11 +
.../156.optimfrog-dualstream.soundkonverter.xml | 15 +
src/plugins/plugins/158.wavpack.soundkonverter.xml | 11 +
src/plugins/plugins/160.lac.soundkonverter.xml | 9 +
src/plugins/plugins/165.lpac.soundkonverter.xml | 9 +
src/plugins/plugins/170.speex.soundkonverter.xml | 16 +
.../plugins/180.timidity.soundkonverter.xml | 5 +
src/plugins/plugins/190.sox.soundkonverter.xml | 8 +
.../plugins/210.vorbisgain.soundkonverter.xml | 5 +
src/plugins/plugins/220.mp3gain.soundkonverter.xml | 5 +
src/plugins/plugins/225.aacgain.soundkonverter.xml | 5 +
.../plugins/230.replaygain.soundkonverter.xml | 5 +
.../plugins/240.metaflac.soundkonverter.xml | 5 +
src/plugins/plugins/250.wvgain.soundkonverter.xml | 5 +
.../plugins/310.cdda2wav.soundkonverter.xml | 7 +
.../plugins/320.cdparanoia.soundkonverter.xml | 7 +
src/plugins/plugins/Makefile.am | 14 +
src/plugins/rohling/Makefile.am | 6 +
src/progressindicator.cpp | 144 ++
src/progressindicator.h | 61 +
src/replaygain.cpp | 96 ++
src/replaygain.h | 58 +
src/replaygainfilelist.cpp | 1262 +++++++++++++++
src/replaygainfilelist.h | 242 +++
src/replaygainscanner.cpp | 233 +++
src/replaygainscanner.h | 77 +
src/soundkonverter.cpp | 780 ++++++++++
src/soundkonverter.desktop | 15 +
src/soundkonverter.h | 206 +++
src/soundkonverterapp.cpp | 133 ++
src/soundkonverterapp.h | 37 +
src/soundkonverterui.rc | 40 +
src/userscript.sh | 22 +
328 files changed, 35394 insertions(+)
create mode 100644 src/Makefile.am
create mode 100755 src/amarokscript/Makefile.am
create mode 100644 src/amarokscript/README
create mode 100755 src/amarokscript/soundKonverter.rb
create mode 100755 src/audiocd_extract_with_soundkonverter.desktop
create mode 100755 src/cddb.cpp
create mode 100755 src/cddb.h
create mode 100755 src/cdmanager.cpp
create mode 100755 src/cdmanager.h
create mode 100755 src/cdopener.cpp
create mode 100755 src/cdopener.h
create mode 100755 src/combobutton.cpp
create mode 100755 src/combobutton.h
create mode 100755 src/config.cpp
create mode 100755 src/config.h
create mode 100755 src/configbackendspage.cpp
create mode 100755 src/configbackendspage.h
create mode 100755 src/configdialog.cpp
create mode 100755 src/configdialog.h
create mode 100755 src/configenvironmentpage.cpp
create mode 100755 src/configenvironmentpage.h
create mode 100755 src/configgeneralpage.cpp
create mode 100755 src/configgeneralpage.h
create mode 100755 src/configpagebase.cpp
create mode 100755 src/configpagebase.h
create mode 100755 src/configpluginspage.cpp
create mode 100755 src/configpluginspage.h
create mode 100755 src/conversionoptions.cpp
create mode 100755 src/conversionoptions.h
create mode 100755 src/convert.cpp
create mode 100755 src/convert.h
create mode 100755 src/cuesheeteditor.cpp
create mode 100755 src/cuesheeteditor.h
create mode 100755 src/dcopinterface.h
create mode 100755 src/dirdialog.cpp
create mode 100755 src/dirdialog.h
create mode 100755 src/filelist.cpp
create mode 100755 src/filelist.h
create mode 100755 src/hi16-app-soundkonverter.png
create mode 100755 src/hi16-app-soundkonverter_replaygain.png
create mode 100755 src/hi22-app-soundkonverter.png
create mode 100755 src/hi22-app-soundkonverter_replaygain.png
create mode 100755 src/hi32-app-soundkonverter.png
create mode 100755 src/hi32-app-soundkonverter_replaygain.png
create mode 100755 src/hi48-app-soundkonverter.png
create mode 100755 src/hi48-app-soundkonverter_replaygain.png
create mode 100755 src/hi64-app-soundkonverter.png
create mode 100755 src/hi64-app-soundkonverter_replaygain.png
create mode 100755 src/logger.cpp
create mode 100755 src/logger.h
create mode 100755 src/logviewer.cpp
create mode 100755 src/logviewer.h
create mode 100755 src/main.cpp
create mode 100644 src/metadata/Makefile.am
create mode 100644 src/metadata/aac/Makefile.am
create mode 100644 src/metadata/aac/aacfiletyperesolver.cpp
create mode 100644 src/metadata/aac/aacfiletyperesolver.h
create mode 100755 src/metadata/ape/Makefile.am
create mode 100755 src/metadata/ape/taglib_monkeysaudiofiletyperesolver.cpp
create mode 100755 src/metadata/ape/taglib_monkeysaudiofiletyperesolver.h
create mode 100644 src/metadata/asf/Makefile.am
create mode 100644 src/metadata/asf/asfattribute.cpp
create mode 100644 src/metadata/asf/asfattribute.h
create mode 100644 src/metadata/asf/asffile.cpp
create mode 100644 src/metadata/asf/asffile.h
create mode 100644 src/metadata/asf/asfproperties.cpp
create mode 100644 src/metadata/asf/asfproperties.h
create mode 100644 src/metadata/asf/asftag.cpp
create mode 100644 src/metadata/asf/asftag.h
create mode 100644 src/metadata/asf/taglib_asffiletyperesolver.cpp
create mode 100644 src/metadata/asf/taglib_asffiletyperesolver.h
create mode 100644 src/metadata/audible/Makefile.am
create mode 100644 src/metadata/audible/audibleproperties.cpp
create mode 100644 src/metadata/audible/audibleproperties.h
create mode 100644 src/metadata/audible/audibletag.cpp
create mode 100644 src/metadata/audible/audibletag.h
create mode 100644 src/metadata/audible/taglib_audiblefile.cpp
create mode 100644 src/metadata/audible/taglib_audiblefile.h
create mode 100644 src/metadata/audible/taglib_audiblefiletyperesolver.cpp
create mode 100644 src/metadata/audible/taglib_audiblefiletyperesolver.h
create mode 100644 src/metadata/m4a/Makefile.am
create mode 100644 src/metadata/m4a/boxfactory.cpp
create mode 100644 src/metadata/m4a/boxfactory.h
create mode 100644 src/metadata/m4a/itunesalbbox.cpp
create mode 100644 src/metadata/m4a/itunesalbbox.h
create mode 100644 src/metadata/m4a/itunesartbox.cpp
create mode 100644 src/metadata/m4a/itunesartbox.h
create mode 100644 src/metadata/m4a/itunescmtbox.cpp
create mode 100644 src/metadata/m4a/itunescmtbox.h
create mode 100644 src/metadata/m4a/itunescvrbox.cpp
create mode 100644 src/metadata/m4a/itunescvrbox.h
create mode 100644 src/metadata/m4a/itunesdatabox.cpp
create mode 100644 src/metadata/m4a/itunesdatabox.h
create mode 100644 src/metadata/m4a/itunesdaybox.cpp
create mode 100644 src/metadata/m4a/itunesdaybox.h
create mode 100644 src/metadata/m4a/itunesdiskbox.cpp
create mode 100644 src/metadata/m4a/itunesdiskbox.h
create mode 100644 src/metadata/m4a/itunesgenbox.cpp
create mode 100644 src/metadata/m4a/itunesgenbox.h
create mode 100644 src/metadata/m4a/itunesgrpbox.cpp
create mode 100644 src/metadata/m4a/itunesgrpbox.h
create mode 100644 src/metadata/m4a/itunesnambox.cpp
create mode 100644 src/metadata/m4a/itunesnambox.h
create mode 100644 src/metadata/m4a/itunestmpobox.cpp
create mode 100644 src/metadata/m4a/itunestmpobox.h
create mode 100644 src/metadata/m4a/itunestrknbox.cpp
create mode 100644 src/metadata/m4a/itunestrknbox.h
create mode 100644 src/metadata/m4a/ituneswrtbox.cpp
create mode 100644 src/metadata/m4a/ituneswrtbox.h
create mode 100644 src/metadata/m4a/mp4audioproperties.cpp
create mode 100644 src/metadata/m4a/mp4audioproperties.h
create mode 100644 src/metadata/m4a/mp4audiosampleentry.cpp
create mode 100644 src/metadata/m4a/mp4audiosampleentry.h
create mode 100644 src/metadata/m4a/mp4file.cpp
create mode 100644 src/metadata/m4a/mp4file.h
create mode 100644 src/metadata/m4a/mp4fourcc.cpp
create mode 100644 src/metadata/m4a/mp4fourcc.h
create mode 100644 src/metadata/m4a/mp4hdlrbox.cpp
create mode 100644 src/metadata/m4a/mp4hdlrbox.h
create mode 100644 src/metadata/m4a/mp4ilstbox.cpp
create mode 100644 src/metadata/m4a/mp4ilstbox.h
create mode 100644 src/metadata/m4a/mp4isobox.cpp
create mode 100644 src/metadata/m4a/mp4isobox.h
create mode 100644 src/metadata/m4a/mp4isofullbox.cpp
create mode 100644 src/metadata/m4a/mp4isofullbox.h
create mode 100644 src/metadata/m4a/mp4itunestag.cpp
create mode 100644 src/metadata/m4a/mp4itunestag.h
create mode 100644 src/metadata/m4a/mp4mdiabox.cpp
create mode 100644 src/metadata/m4a/mp4mdiabox.h
create mode 100644 src/metadata/m4a/mp4metabox.cpp
create mode 100644 src/metadata/m4a/mp4metabox.h
create mode 100644 src/metadata/m4a/mp4minfbox.cpp
create mode 100644 src/metadata/m4a/mp4minfbox.h
create mode 100644 src/metadata/m4a/mp4moovbox.cpp
create mode 100644 src/metadata/m4a/mp4moovbox.h
create mode 100644 src/metadata/m4a/mp4mvhdbox.cpp
create mode 100644 src/metadata/m4a/mp4mvhdbox.h
create mode 100644 src/metadata/m4a/mp4propsproxy.cpp
create mode 100644 src/metadata/m4a/mp4propsproxy.h
create mode 100644 src/metadata/m4a/mp4sampleentry.cpp
create mode 100644 src/metadata/m4a/mp4sampleentry.h
create mode 100644 src/metadata/m4a/mp4skipbox.cpp
create mode 100644 src/metadata/m4a/mp4skipbox.h
create mode 100644 src/metadata/m4a/mp4stblbox.cpp
create mode 100644 src/metadata/m4a/mp4stblbox.h
create mode 100644 src/metadata/m4a/mp4stsdbox.cpp
create mode 100644 src/metadata/m4a/mp4stsdbox.h
create mode 100644 src/metadata/m4a/mp4tagsproxy.cpp
create mode 100644 src/metadata/m4a/mp4tagsproxy.h
create mode 100644 src/metadata/m4a/mp4trakbox.cpp
create mode 100644 src/metadata/m4a/mp4trakbox.h
create mode 100644 src/metadata/m4a/mp4udtabox.cpp
create mode 100644 src/metadata/m4a/mp4udtabox.h
create mode 100644 src/metadata/m4a/taglib_mp4filetyperesolver.cpp
create mode 100644 src/metadata/m4a/taglib_mp4filetyperesolver.h
create mode 100644 src/metadata/mp4/Makefile.am
create mode 100755 src/metadata/optimfrog/Makefile.am
create mode 100755 src/metadata/optimfrog/taglib_optimfrogfiletyperesolver.cpp
create mode 100755 src/metadata/optimfrog/taglib_optimfrogfiletyperesolver.h
create mode 100644 src/metadata/rmff/Makefile.am
create mode 100644 src/metadata/rmff/rmff.cpp
create mode 100644 src/metadata/rmff/rmff.h
create mode 100644 src/metadata/rmff/taglib_realmediafile.cpp
create mode 100644 src/metadata/rmff/taglib_realmediafile.h
create mode 100644 src/metadata/rmff/taglib_realmediafiletyperesolver.cpp
create mode 100644 src/metadata/rmff/taglib_realmediafiletyperesolver.h
create mode 100644 src/metadata/speex/Makefile.am
create mode 100644 src/metadata/speex/speexfile.cpp
create mode 100644 src/metadata/speex/speexfile.h
create mode 100644 src/metadata/speex/speexproperties.cpp
create mode 100644 src/metadata/speex/speexproperties.h
create mode 100644 src/metadata/speex/taglib_speexfiletyperesolver.cpp
create mode 100644 src/metadata/speex/taglib_speexfiletyperesolver.h
create mode 100755 src/metadata/tagengine.cpp
create mode 100755 src/metadata/tagengine.h
create mode 100755 src/metadata/tplugins.cpp
create mode 100755 src/metadata/tplugins.h
create mode 100644 src/metadata/trueaudio/Makefile.am
create mode 100644 src/metadata/trueaudio/combinedtag.h
create mode 100644 src/metadata/trueaudio/taglib_trueaudiofiletyperesolver.cpp
create mode 100644 src/metadata/trueaudio/taglib_trueaudiofiletyperesolver.h
create mode 100644 src/metadata/trueaudio/ttafile.cpp
create mode 100644 src/metadata/trueaudio/ttafile.h
create mode 100644 src/metadata/trueaudio/ttaproperties.cpp
create mode 100644 src/metadata/trueaudio/ttaproperties.h
create mode 100644 src/metadata/wav/Makefile.am
create mode 100644 src/metadata/wav/wavfile.cpp
create mode 100644 src/metadata/wav/wavfile.h
create mode 100644 src/metadata/wav/wavfiletyperesolver.cpp
create mode 100644 src/metadata/wav/wavfiletyperesolver.h
create mode 100644 src/metadata/wav/wavproperties.cpp
create mode 100644 src/metadata/wav/wavproperties.h
create mode 100644 src/metadata/wavpack/Makefile.am
create mode 100644 src/metadata/wavpack/combinedtag.h
create mode 100644 src/metadata/wavpack/taglib_wavpackfiletyperesolver.cpp
create mode 100644 src/metadata/wavpack/taglib_wavpackfiletyperesolver.h
create mode 100644 src/metadata/wavpack/wvfile.cpp
create mode 100644 src/metadata/wavpack/wvfile.h
create mode 100644 src/metadata/wavpack/wvproperties.cpp
create mode 100644 src/metadata/wavpack/wvproperties.h
create mode 100755 src/options.cpp
create mode 100755 src/options.h
create mode 100755 src/optionsdetailed.cpp
create mode 100755 src/optionsdetailed.h
create mode 100755 src/optionseditor.cpp
create mode 100755 src/optionseditor.h
create mode 100755 src/optionsrequester.cpp
create mode 100755 src/optionsrequester.h
create mode 100755 src/optionssimple.cpp
create mode 100755 src/optionssimple.h
create mode 100755 src/outputdirectory.cpp
create mode 100755 src/outputdirectory.h
create mode 100755 src/paranoia.cpp
create mode 100755 src/paranoia.h
create mode 100755 src/pics/Makefile.am
create mode 100755 src/pics/ledgreen.png
create mode 100755 src/pics/ledgreen_legend.png
create mode 100755 src/pics/ledred.png
create mode 100755 src/pics/ledred_legend.png
create mode 100755 src/pics/ledyellow.png
create mode 100755 src/pics/ledyellow_legend.png
create mode 100755 src/pluginloader/Makefile.am
create mode 100755 src/pluginloader/convertpluginloader.cpp
create mode 100755 src/pluginloader/convertpluginloader.h
create mode 100755 src/pluginloader/formatinfoloader.cpp
create mode 100755 src/pluginloader/formatinfoloader.h
create mode 100755 src/pluginloader/pluginloaderbase.cpp
create mode 100755 src/pluginloader/pluginloaderbase.h
create mode 100755 src/pluginloader/replaygainpluginloader.cpp
create mode 100755 src/pluginloader/replaygainpluginloader.h
create mode 100755 src/pluginloader/ripperpluginloader.cpp
create mode 100755 src/pluginloader/ripperpluginloader.h
create mode 100755 src/plugins/Makefile.am
create mode 100755 src/plugins/format_infos/3gp.xml
create mode 100644 src/plugins/format_infos/Makefile.am
create mode 100755 src/plugins/format_infos/aac.xml
create mode 100755 src/plugins/format_infos/ac3.xml
create mode 100644 src/plugins/format_infos/aiff.xml
create mode 100755 src/plugins/format_infos/amr.xml
create mode 100755 src/plugins/format_infos/ape.xml
create mode 100755 src/plugins/format_infos/au.xml
create mode 100755 src/plugins/format_infos/avi.xml
create mode 100755 src/plugins/format_infos/bonk.xml
create mode 100755 src/plugins/format_infos/flac.xml
create mode 100755 src/plugins/format_infos/la.xml
create mode 100755 src/plugins/format_infos/m4a.xml
create mode 100755 src/plugins/format_infos/mid.xml
create mode 100755 src/plugins/format_infos/mod.xml
create mode 100755 src/plugins/format_infos/mp2.xml
create mode 100755 src/plugins/format_infos/mp3.xml
create mode 100755 src/plugins/format_infos/mpc.xml
create mode 100755 src/plugins/format_infos/ofc.xml
create mode 100755 src/plugins/format_infos/ofr.xml
create mode 100755 src/plugins/format_infos/ofs.xml
create mode 100755 src/plugins/format_infos/ogg.xml
create mode 100755 src/plugins/format_infos/pac.xml
create mode 100755 src/plugins/format_infos/qt.xml
create mode 100755 src/plugins/format_infos/ra.xml
create mode 100755 src/plugins/format_infos/shn.xml
create mode 100755 src/plugins/format_infos/spx.xml
create mode 100755 src/plugins/format_infos/tta.xml
create mode 100755 src/plugins/format_infos/wma.xml
create mode 100755 src/plugins/format_infos/wv.xml
create mode 100755 src/plugins/format_infos/wvc.xml
create mode 100755 src/plugins/mime_types/Makefile.am
create mode 100755 src/plugins/mime_types/amr.soundkonverter.desktop
create mode 100755 src/plugins/mime_types/x-ape.soundkonverter.desktop
create mode 100755 src/plugins/mime_types/x-bonk.soundkonverter.desktop
create mode 100755 src/plugins/mime_types/x-flv.soundkonverter.desktop
create mode 100755 src/plugins/mime_types/x-la.soundkonverter.desktop
create mode 100755 src/plugins/mime_types/x-ofc.soundkonverter.desktop
create mode 100755 src/plugins/mime_types/x-ofr.soundkonverter.desktop
create mode 100755 src/plugins/mime_types/x-ofs.soundkonverter.desktop
create mode 100755 src/plugins/mime_types/x-pac.soundkonverter.desktop
create mode 100755 src/plugins/mime_types/x-shorten.soundkonverter.desktop
create mode 100755 src/plugins/mime_types/x-tta.soundkonverter.desktop
create mode 100755 src/plugins/mime_types/x-wavpack-correction.soundkonverter.desktop
create mode 100755 src/plugins/mime_types/x-wavpack.soundkonverter.desktop
create mode 100755 src/plugins/plugins/110.oggvorbis.soundkonverter.xml
create mode 100755 src/plugins/plugins/120.lame.soundkonverter.xml
create mode 100755 src/plugins/plugins/122.twolame.soundkonverter.xml
create mode 100755 src/plugins/plugins/123.toolame.soundkonverter.xml
create mode 100755 src/plugins/plugins/125.gogo.soundkonverter.xml
create mode 100755 src/plugins/plugins/127.faac.soundkonverter.xml
create mode 100755 src/plugins/plugins/130.musepack.soundkonverter.xml
create mode 100755 src/plugins/plugins/132.aften.soundkonverter.xml
create mode 100755 src/plugins/plugins/135.flac.soundkonverter.xml
create mode 100755 src/plugins/plugins/136.flake.soundkonverter.xml
create mode 100755 src/plugins/plugins/137.mac.soundkonverter.xml
create mode 100755 src/plugins/plugins/140.mplayer.soundkonverter.xml
create mode 100755 src/plugins/plugins/145.ffmpeg.soundkonverter.xml
create mode 100755 src/plugins/plugins/146.ffmpeg-lossless.soundkonverter.xml
create mode 100755 src/plugins/plugins/150.shorten.soundkonverter.xml
create mode 100755 src/plugins/plugins/151.tta.soundkonverter.xml
create mode 100755 src/plugins/plugins/153.bonk.soundkonverter.xml
create mode 100755 src/plugins/plugins/155.optimfrog.soundkonverter.xml
create mode 100755 src/plugins/plugins/156.optimfrog-dualstream.soundkonverter.xml
create mode 100755 src/plugins/plugins/158.wavpack.soundkonverter.xml
create mode 100755 src/plugins/plugins/160.lac.soundkonverter.xml
create mode 100755 src/plugins/plugins/165.lpac.soundkonverter.xml
create mode 100755 src/plugins/plugins/170.speex.soundkonverter.xml
create mode 100755 src/plugins/plugins/180.timidity.soundkonverter.xml
create mode 100644 src/plugins/plugins/190.sox.soundkonverter.xml
create mode 100755 src/plugins/plugins/210.vorbisgain.soundkonverter.xml
create mode 100755 src/plugins/plugins/220.mp3gain.soundkonverter.xml
create mode 100755 src/plugins/plugins/225.aacgain.soundkonverter.xml
create mode 100755 src/plugins/plugins/230.replaygain.soundkonverter.xml
create mode 100755 src/plugins/plugins/240.metaflac.soundkonverter.xml
create mode 100755 src/plugins/plugins/250.wvgain.soundkonverter.xml
create mode 100755 src/plugins/plugins/310.cdda2wav.soundkonverter.xml
create mode 100755 src/plugins/plugins/320.cdparanoia.soundkonverter.xml
create mode 100644 src/plugins/plugins/Makefile.am
create mode 100755 src/plugins/rohling/Makefile.am
create mode 100755 src/progressindicator.cpp
create mode 100755 src/progressindicator.h
create mode 100755 src/replaygain.cpp
create mode 100755 src/replaygain.h
create mode 100755 src/replaygainfilelist.cpp
create mode 100755 src/replaygainfilelist.h
create mode 100755 src/replaygainscanner.cpp
create mode 100755 src/replaygainscanner.h
create mode 100755 src/soundkonverter.cpp
create mode 100755 src/soundkonverter.desktop
create mode 100755 src/soundkonverter.h
create mode 100755 src/soundkonverterapp.cpp
create mode 100755 src/soundkonverterapp.h
create mode 100755 src/soundkonverterui.rc
create mode 100755 src/userscript.sh
(limited to 'src')
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..c758fb3
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,58 @@
+# set the include path for X, qt and KDE
+INCLUDES = $(all_includes) -I$(top_srcdir)/src/metadata/ \
+ -I$(top_srcdir)/src/pluginloader/
+
+# these are the headers for your project
+noinst_HEADERS = cdmanager.h cdopener.h combobutton.h config.h \
+ configbackendspage.h configdialog.h configenvironmentpage.h configgeneralpage.h \
+ configpagebase.h configpluginspage.h conversionoptions.h convert.h cuesheeteditor.h \
+ dcopinterface.h dirdialog.h filelist.h logger.h logviewer.h options.h optionsdetailed.h \
+ optionseditor.h optionsrequester.h optionssimple.h outputdirectory.h \
+ progressindicator.h replaygain.h replaygainfilelist.h replaygainscanner.h soundkonverter.h \
+ soundkonverterapp.h
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+messages: rc.cpp
+ $(EXTRACTRC) `find . -name \*.ui -o -name \*.rc` > rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/soundkonverter.pot
+
+KDE_ICON = AUTO
+
+#########################################################################
+# APPLICATION SECTION
+#########################################################################
+# this is the program that gets installed. it's name is used for all
+# of the other Makefile.am variables
+bin_PROGRAMS = soundkonverter
+
+# the application source, library search path, and link libraries
+soundkonverter_SOURCES = cddb.cpp cdmanager.cpp cdopener.cpp combobutton.cpp \
+ config.cpp configbackendspage.cpp configdialog.cpp configenvironmentpage.cpp \
+ configgeneralpage.cpp configpagebase.cpp configpluginspage.cpp conversionoptions.cpp \
+ convert.cpp cuesheeteditor.cpp dcopinterface.skel dirdialog.cpp filelist.cpp \
+ logger.cpp logviewer.cpp main.cpp options.cpp optionsdetailed.cpp \
+ optionseditor.cpp optionsrequester.cpp optionssimple.cpp outputdirectory.cpp paranoia.cpp \
+ progressindicator.cpp replaygain.cpp replaygainfilelist.cpp replaygainscanner.cpp \
+ soundkonverter.cpp soundkonverterapp.cpp
+soundkonverter_LDFLAGS = $(KDE_RPATH) $(all_libraries)
+soundkonverter_LDADD = $(LIB_KDEUI) $(LIB_KFILE) metadata/libmetadata.la \
+ pluginloader/libpluginloader.la -lcdda_interface -lcdda_paranoia
+
+xdg_apps_DATA = soundkonverter.desktop
+
+# this is where the shell's XML-GUI resource file goes
+shellrcdir = $(kde_datadir)/soundkonverter
+shellrc_DATA = soundkonverterui.rc
+
+SUBDIRS = amarokscript metadata pics pluginloader plugins
+soundkonverter_DEPENDENCIES = metadata/libmetadata.la \
+ pluginloader/libpluginloader.la
+amarokscriptsdir = $(kde_datadir)/amarok/scripts
+servicemenusdir = $(kde_datadir)/konqueror/servicemenus
+servicemenus_DATA = audiocd_extract_with_soundkonverter.desktop
+amarokscriptdir = $(kde_datadir)/soundkonverter/amarokscript
+bin_SCRIPTS = userscript.sh
+userscriptdir = $(kde_datadir)/soundkonverter
+userscript_SCRIPTS = userscript.sh
diff --git a/src/amarokscript/Makefile.am b/src/amarokscript/Makefile.am
new file mode 100755
index 0000000..b8049a7
--- /dev/null
+++ b/src/amarokscript/Makefile.am
@@ -0,0 +1,3 @@
+amarokscriptdir = $(kde_datadir)/soundkonverter/amarokscript
+amarokscript_DATA = README \
+ soundKonverter.rb
diff --git a/src/amarokscript/README b/src/amarokscript/README
new file mode 100644
index 0000000..1186231
--- /dev/null
+++ b/src/amarokscript/README
@@ -0,0 +1,43 @@
+soundKonverter amaroK-Script (v0.3.8)
+
+
+About:
+This script only adds a context menu for easily accesssing the soundKonverter tool.
This version was designed to work with soundKonverter 0.2.80+
With soundKonverter you can convert audio files into another audio format. And you can add/remove the ReplayGain tag to/from audio files.
+
+
+
+Usage:
+Just run this script and click on one or multiple files in your playlist with the right mouse button. Select soundKonverter and your desired action. After that soundKonverter should start (if you have installed it). Look into the handbook of soundKonverter for further information.
+
+
+
+Dependencies:
+
+- amaroK 1.4.0
+- Ruby 1.6
+- soundKonverter 0.2.80+
+
+
+
+
+ChangeLog:
+Version 0.1:
+
+Version 0.2.80:
+
+
+
+
+License:
+GNU General Public License V2
+
+
+
+Author:
+Daniel Faust (daniel@kaligames.de)
+
+
diff --git a/src/amarokscript/soundKonverter.rb b/src/amarokscript/soundKonverter.rb
new file mode 100755
index 0000000..144c0c8
--- /dev/null
+++ b/src/amarokscript/soundKonverter.rb
@@ -0,0 +1,296 @@
+#!/usr/bin/env ruby
+#
+# amaroK-Script for integrating soundKonverter into amaroK
+#
+# (c) 2005 Daniel Faust
+# License: GNU General Public License V2
+
+
+# FIXME after adding some files to soundkonverter, it is impossible to repeat that, until soundkonverter gets closed.
+
+# FIXME don't open files on every request. load options on startup and save on exit!
+
+#`dcop amarok playlist addMedia KURL`
+#`dcop amarok playlist addMediaList KURL::List`
+#`dcop amarok collection scanCollectionChanges`
+
+
+require "uri"
+
+begin
+ require "Qt"
+rescue LoadError
+ error = 'Qt Ruby bindings are required for this script.'
+ `dcop amarok playlist popupMessage "soundKonverter: #{error}"`
+ exit
+end
+
+class MainWidget < Qt::Dialog
+
+slots 'accept()'
+
+def initialize(parent = nil, name = nil)
+ super
+
+ box = Qt::VBoxLayout.new( self, 11, 6 );
+
+ lTitle = Qt::Label.new('soundKonverter plugin settings', self)
+ box.addWidget( lTitle )
+ lTitle.setAlignment(Qt::AlignCenter)
+ font = Qt::Font.new()
+ font.setPixelSize(18)
+ font.setBold(true)
+ lTitle.setFont(font)
+
+ box.addSpacing( 5 )
+
+ mediaDeviceBox = Qt::GroupBox.new( 1, Qt::Vertical, "Options for transfering to media devices", self )
+ box.addWidget( mediaDeviceBox )
+ mediaDeviceBox.layout().setSpacing( 6 )
+ mediaDeviceBox.layout().setMargin( 6 )
+ Qt::Label.new('Profile for lossy conversion:', mediaDeviceBox)
+ @cTranscodeProfile = Qt::ComboBox.new(mediaDeviceBox)
+ @cTranscodeProfile.insertItem("Very low")
+ @cTranscodeProfile.insertItem("Low")
+ @cTranscodeProfile.insertItem("Medium")
+ @cTranscodeProfile.insertItem("High")
+ @cTranscodeProfile.insertItem("Very high")
+ @cTranscodeProfile.setCurrentItem( 1 )
+
+# box.addSpacing( 5 )
+#
+# rippingBox = Qt::GroupBox.new( 2, Qt::Horizontal, "Use pre-defined options for CD ripping", self )
+# box.addWidget( rippingBox )
+# rippingBox.layout().setSpacing( 6 )
+# rippingBox.layout().setMargin( 6 )
+# rippingBox.setCheckable( true )
+# rippingBox.setEnabled( false )
+#
+# profileBox = Qt::HBoxLayout.new( rippingBox, 6 );
+# lRippingProfile = Qt::Label.new('Profile:', rippingBox)
+# profileBox.addWidget( lRippingProfile )
+# @cRippingProfile = Qt::ComboBox.new(rippingBox)
+# profileBox.addWidget( @cRippingProfile )
+# @cRippingProfile.insertItem("Very low")
+# @cRippingProfile.insertItem("Low")
+# @cRippingProfile.insertItem("Medium")
+# @cRippingProfile.insertItem("High")
+# @cRippingProfile.insertItem("Very high")
+# @cRippingProfile.insertItem("Lossless")
+# @cRippingProfile.insertItem("Last used")
+# @cRippingProfile.setCurrentItem(3)
+# lRippingFormat = Qt::Label.new('Format:', rippingBox)
+# profileBox.addWidget( lRippingFormat )
+# @cRippingFormat = Qt::ComboBox.new(rippingBox)
+# profileBox.addWidget( @cRippingFormat )
+# @cRippingFormat.insertItem("ogg")
+# @cRippingFormat.insertItem("mp3")
+# @cRippingFormat.insertItem("flac")
+# directoryBox = Qt::HBoxLayout.new( rippingBox, 6 );
+# lRippingDirectory = Qt::Label.new('Directory:', rippingBox)
+# directoryBox.addWidget( lRippingDirectory )
+# @cRippingDirectory = Qt::ComboBox.new(rippingBox)
+# directoryBox.addWidget( @cRippingDirectory )
+# @cRippingDirectory.setEditable(true)
+# @cRippingDirectory.insertItem("/home/daniel/soundKonverter/%b/%d - %n - %t")
+# @cRippingDirectory.insertItem("Last used")
+
+ box.addSpacing( 5 )
+
+ buttonsBox = Qt::HBoxLayout.new(box)
+ buttonsBox.setSpacing(6)
+ buttonsBox.addStretch()
+ okPushButton = Qt::PushButton.new( self, "ok" )
+ buttonsBox.addWidget( okPushButton )
+ okPushButton.setText( "OK" )
+ okPushButton.setDefault( true )
+
+ connect( okPushButton, SIGNAL( 'clicked()' ),
+ self, SLOT( 'accept()' )
+ )
+
+ cancelPushButton = Qt::PushButton.new( self, "cancel" )
+ buttonsBox.addWidget( cancelPushButton )
+ cancelPushButton.setText( "Cancel" )
+ cancelPushButton.setAccel( Qt::KeySequence.new(Key_Escape) )
+
+ connect( cancelPushButton, SIGNAL( 'clicked()' ),
+ self, SLOT( 'reject()' )
+ )
+
+ file = Qt::File.new( File.dirname( File.expand_path( __FILE__ ) ) + "/config" )
+ if file.open( Qt::IO_ReadOnly )
+ ts = Qt::TextStream.new( file )
+ content = ''
+ ts >> content
+ if content == 'Very_low'
+ @cTranscodeProfile.setCurrentItem( 0 )
+ elsif content == 'Low'
+ @cTranscodeProfile.setCurrentItem( 1 )
+ elsif content == 'Medium'
+ @cTranscodeProfile.setCurrentItem( 2 )
+ elsif content == 'High'
+ @cTranscodeProfile.setCurrentItem( 3 )
+ elsif content == 'Very_high'
+ @cTranscodeProfile.setCurrentItem( 4 )
+ end
+ file.close()
+ end
+
+# file = Qt::File.new( File.dirname( File.expand_path( __FILE__ ) ) + "/profiles" )
+# if file.open( Qt::IO_ReadOnly )
+# ts = Qt::TextStream.new( file )
+# while !ts.eof()
+# content = ''
+# ts >> content
+# @cProfile.insertItem( content )
+# ts >> content
+# end
+#
+# file.close()
+# end
+end
+
+
+def accept()
+ file = Qt::File.new( File.dirname( File.expand_path( __FILE__ ) ) + "/config" )
+ if file.open( Qt::IO_WriteOnly )
+ ts = Qt::TextStream.new( file )
+ if @cTranscodeProfile.currentText() == 'Very low'
+ content = 'Very_low'
+ elsif @cTranscodeProfile.currentText() == 'Low'
+ content = 'Low'
+ elsif @cTranscodeProfile.currentText() == 'Medium'
+ content = 'Medium'
+ elsif @cTranscodeProfile.currentText() == 'High'
+ content = 'High'
+ elsif @cTranscodeProfile.currentText() == 'Very high'
+ content = 'Very_high'
+ end
+ ts << content + "\n"
+ file.close()
+ end
+
+ super
+end
+
+end
+
+
+MenuItemName1 = "soundKonverter \"Convert selected files\""
+MenuItemName2 = "soundKonverter \"Add Replay Gain to selected files\""
+MenuItemName3 = "soundKonverter \"Rip and play audio CD\""
+
+
+def cleanup()
+ `dcop amarok script removeCustomMenuItem #{MenuItemName1}`
+ `dcop amarok script removeCustomMenuItem #{MenuItemName2}`
+ `dcop amarok script removeCustomMenuItem #{MenuItemName3}`
+end
+
+
+trap( "SIGTERM" ) { cleanup() }
+
+`dcop amarok script addCustomMenuItem #{MenuItemName1}`
+`dcop amarok script addCustomMenuItem #{MenuItemName2}`
+`dcop amarok script addCustomMenuItem #{MenuItemName3}`
+
+loop do
+ message = gets().chomp()
+ command = /[A-Za-z]*/.match( message ).to_s()
+
+ case command
+ when "configure"
+ app = Qt::Application.new(ARGV)
+ widget = MainWidget.new
+ app.setMainWidget(widget)
+ widget.show()
+ app.exec()
+
+ when "transcode"
+ args = message.split()
+ filename = args[1]
+ #uri = URI.parse( args[1] )
+ #filename = URI.unescape( uri.path() )
+ filetype = args[2]
+ profile = ''
+
+ file = Qt::File.new( File.dirname( File.expand_path( __FILE__ ) ) + "/formats" )
+ if file.open( Qt::IO_ReadOnly )
+ ts = Qt::TextStream.new( file )
+ while !ts.eof()
+ mode = ''
+ formats = ''
+ ts >> mode
+ ts >> formats
+ if formats.split(',').include?( filetype )
+ profile = mode
+ end
+ end
+ file.close()
+ end
+
+ if profile == ''
+ file = Qt::File.new( File.dirname( File.expand_path( __FILE__ ) ) + "/config" )
+ if file.open( Qt::IO_ReadOnly )
+ ts = Qt::TextStream.new( file )
+ content = ''
+ ts >> content
+ if content == 'Very_low'
+ profile = 'Very low'
+ elsif content == 'Low'
+ profile = 'Low'
+ elsif content == 'Medium'
+ profile = 'Medium'
+ elsif content == 'High'
+ profile = 'High'
+ elsif content == 'Very_high'
+ profile = 'Very high'
+ end
+ file.close()
+ else
+ profile = 'Low'
+ end
+ end
+
+ `dcop amarok playlist shortStatusMessage "starting soundKonverter in background"`
+ `soundkonverter --invisible --profile '#{profile}' --format '#{filetype}' --output '/tmp' --command "dcop amarok mediabrowser transcodingFinished %u file://%o" '#{filename}'`
+
+ when "customMenuClicked"
+ if message.include?( "Convert selected files" )
+ args = message.split()
+ # Remove the command args
+ 5.times() { args.delete_at( 0 ) }
+
+ # Iterate over all selected files
+ files = ''
+ args.each() do |arg|
+ uri = URI.parse( arg )
+ file = URI.unescape( uri.path() )
+ files += ' "'+file+'"'
+ end
+ `dcop amarok playlist shortStatusMessage "starting soundKonverter"`
+ `soundkonverter #{files}`
+ end
+ if message.include?( "Add Replay Gain to selected files" )
+ args = message.split()
+ # Remove the command args
+ 8.times() { args.delete_at( 0 ) }
+
+ files = ''
+ args.each() do |arg|
+ uri = URI.parse( arg )
+ file = URI.unescape( uri.path() )
+ files += ' "'+file+'"'
+ end
+ `dcop amarok playlist shortStatusMessage "starting soundKonverter"`
+ `soundkonverter --replaygain #{files}`
+ end
+ if message.include?( "Rip and play audio CD" )
+ `dcop amarok playlist popupMessage "Select all tracks to rip and press 'Start' in order to start ripping.\nThe tracks will be added to the playlist, when they are ready."`
+ #`dcop amarok playlist shortStatusMessage "starting soundKonverter"`
+ `soundkonverter --invisible --rip auto --command "dcop amarok playlist addMedia %o"`
+ end
+ end
+end
+
diff --git a/src/audiocd_extract_with_soundkonverter.desktop b/src/audiocd_extract_with_soundkonverter.desktop
new file mode 100755
index 0000000..a6d4120
--- /dev/null
+++ b/src/audiocd_extract_with_soundkonverter.desktop
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Actions=ExtractSoundKonverter
+ServiceTypes=media/audiocd
+Icon=soundkonverter
+X-KDE-Priority=TopLevel
+
+[Desktop Action ExtractSoundKonverter]
+Exec=soundkonverter --rip %u
+Icon=soundkonverter
+Name=Extract with soundKonverter
+Name[de]=Mit soundKonverter auslesen
diff --git a/src/cddb.cpp b/src/cddb.cpp
new file mode 100755
index 0000000..58ebde7
--- /dev/null
+++ b/src/cddb.cpp
@@ -0,0 +1,669 @@
+/*
+ Copyright (C) 2000 Michael Matz
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include
+#ifdef HAVE_SYS_TIME_H
+#include
+#endif
+#include
+#ifdef HAVE_SYS_SOCKET_H
+#include
+#endif
+#ifdef HAVE_SYS_SELECT_H
+#include
+#endif
+#include
+#include
+#include
+#include
+#include
+//#include
+#include
+// #include
+//#include
+#include
+#include
+#include
+#include
+
+#include "cddb.h"
+#include "cddb.moc"
+
+// FIXME //kdDebug
+
+CDDB::CDDB()
+ : ks(0), port(80), remote(false), save_local(false)
+{
+ QString s = QDir::homeDirPath()+"/.cddb";
+ cddb_dirs +=s;
+}
+
+
+
+CDDB::~CDDB()
+{
+ deinit();
+}
+
+
+
+bool
+CDDB::set_server(const char *hostname, unsigned short int _port)
+{
+ if (ks)
+ {
+ if (h_name == hostname && port == _port)
+ return true;
+ deinit();
+ }
+ remote = (hostname != 0) && (*hostname != 0);
+ //kdDebug(7101) << "CDDB: set_server, host=" << hostname << "port=" << _port << endl;
+ if (remote)
+ {
+ ks = new KExtendedSocket(hostname, _port);
+ if (ks->connect() < 0)
+ {
+ //kdDebug(7101) << "CDDB: Can't connect!" << endl;
+ delete ks;
+ ks = 0;
+ return false;
+ }
+
+ h_name = hostname;
+ port = _port;
+ QCString r;
+ readLine(r); // the server greeting
+ writeLine("cddb hello kde-user blubb kio_audiocd 0.4");
+ readLine(r);
+ }
+ return true;
+}
+
+
+
+bool
+CDDB::deinit()
+{
+ if (ks)
+ {
+ writeLine("quit");
+ QCString r;
+ readLine(r);
+ ks->close();
+ }
+ h_name.resize(0);
+ port = 0;
+ remote = false;
+ ks = 0;
+ return true;
+}
+
+
+
+bool
+CDDB::readLine(QCString& ret)
+{
+ int read_length = 0;
+ char small_b[128];
+ //fd_set set;
+
+ ret.resize(0);
+ while (read_length < 40000)
+ {
+ // Look for a \n in buf
+ int ni = buf.find('\n');
+ if (ni >= 0)
+ {
+ // Nice, so return this substring (without the \n),
+ // and truncate buf accordingly
+ ret = buf.left(ni);
+ if (ret.length() && ret[ret.length()-1] == '\r')
+ ret.resize(ret.length());
+ buf.remove(0, ni+1);
+ //kdDebug(7101) << "CDDB: got `" << ret << "'" << endl;
+ return true;
+ }
+
+ // Try to refill the buffer
+ ks->waitForMore(60 * 1000);
+ ssize_t l = ks->readBlock(small_b, sizeof(small_b)-1);
+ if (l <= 0)
+ {
+ // l==0 normally means fd got closed, but we really need a lineend
+ return false;
+ }
+ small_b[l] = 0;
+ read_length += l;
+ buf += small_b;
+ }
+ return false;
+}
+
+
+
+bool
+CDDB::writeLine(const QCString& line)
+{
+ const char *b = line.data();
+ int l = line.length();
+ //kdDebug(7101) << "CDDB: send `" << line << "'" << endl;
+ while (l)
+ {
+ ssize_t wl = ks->writeBlock(b, l);
+ if (wl < 0 && errno != EINTR)
+ return false;
+ if (wl < 0)
+ wl = 0;
+ l -= wl;
+ b += wl;
+ }
+ l = line.length();
+ if (l && line.data()[l-1] != '\n')
+ {
+ char c = '\n';
+ ssize_t wl;
+ do {
+ wl = ks->writeBlock(&c, 1);
+ } while (wl <= 0 && errno == EINTR);
+ if (wl<=0 && errno != EINTR)
+ return false;
+ }
+ return true;
+}
+
+
+
+unsigned int
+CDDB::get_discid(QValueList& track_ofs)
+{
+ unsigned int id = 0;
+ int num_tracks = track_ofs.count() - 2;
+
+ // the last two track_ofs[] are disc begin and disc end
+
+ for (int i = num_tracks - 1; i >= 0; i--)
+ {
+ int n = track_ofs[i];
+ n /= 75;
+ while (n > 0)
+ {
+ id += n % 10;
+ n /= 10;
+ }
+ }
+ unsigned int l = track_ofs[num_tracks + 1];
+ l -= track_ofs[num_tracks];
+ l /= 75;
+ id = ((id % 255) << 24) | (l << 8) | num_tracks;
+ return id;
+}
+
+
+
+static int
+get_code (const QCString &s)
+{
+ bool ok;
+ int code = s.left(3).toInt(&ok);
+ if (!ok)
+ code = -1;
+ return code;
+}
+
+
+
+static void
+parse_query_resp (const QCString& _r, QCString& catg, QCString& d_id, QCString& title)
+{
+ QCString r = _r.stripWhiteSpace();
+ int i = r.find(' ');
+ if (i)
+ {
+ catg = r.left(i).stripWhiteSpace();
+ r.remove(0, i+1);
+ r = r.stripWhiteSpace();
+ }
+ i = r.find(' ');
+ if (i)
+ {
+ d_id = r.left(i).stripWhiteSpace();
+ r.remove(0, i+1);
+ r = r.stripWhiteSpace();
+ }
+ title = r;
+}
+
+
+
+QString
+CDDB::track(int i) const
+{
+ if (i < 0 || i >= int(m_names.count()))
+ return QString();
+ return m_names[i].utf8();
+}
+
+
+
+
+QString
+CDDB::artist(int i) const
+{
+ if (i < 0 || i >= int(m_artists.count()))
+ return QString();
+ return m_artists[i].utf8();
+}
+
+
+
+bool
+CDDB::parse_read_resp(QTextStream *stream, QTextStream *write_stream)
+{
+ /* Note, that m_names and m_title should be empty */
+ QCString end = ".";
+
+ m_disc = 0;
+ m_year = 0;
+ m_genre = "";
+
+ /* Fill table, so we can index it below. */
+ for (int i = 0; i < m_tracks; i++)
+ {
+ m_names.append("");
+ m_artists.append("");
+ }
+ while (1)
+ {
+ QCString r;
+ if (stream)
+ {
+ if (stream->atEnd())
+ break;
+ r = stream->readLine().latin1();
+ }
+ else
+ {
+ if (!readLine(r))
+ return false;
+ }
+ /* Normally the "." is not saved into the local files, but be
+ tolerant about this. */
+ if (r == end)
+ break;
+ if (write_stream)
+ *write_stream << r << endl;
+ r = r.stripWhiteSpace();
+ if (r.isEmpty() || r[0] == '#')
+ continue;
+ if (r.left(7) == "DTITLE=")
+ {
+ r.remove(0, 7);
+ m_title += QString::fromLocal8Bit(r.stripWhiteSpace());
+ }
+ else if (r.left(6) == "TTITLE")
+ {
+ r.remove(0, 6);
+ int e = r.find('=');
+ if (e)
+ {
+ bool ok;
+ int i = r.left(e).toInt(&ok);
+ if (ok && i >= 0 && i < m_tracks)
+ {
+ r.remove(0, e+1);
+ m_names[i] += QString::fromLocal8Bit(r);
+ }
+ }
+ }
+ else if (r.left(6) == "DYEAR=")
+ {
+ r.remove(0, 6);
+ QString year = QString::fromLocal8Bit(r.stripWhiteSpace());
+ m_year = year.toInt();
+ //kdDebug(7101) << "CDDB: found Year: " << QString().sprintf("%04i",m_year) << endl;
+ }
+ else if (r.left(7) == "DGENRE=")
+ {
+ r.remove(0, 7);
+ m_genre = QString::fromLocal8Bit(r.stripWhiteSpace());
+ //kdDebug(7101) << "CDDB: found Genre: " << m_genre << endl;
+ }
+ }
+
+ /* XXX We should canonicalize the strings ("\n" --> '\n' e.g.) */
+
+ int si = m_title.find(" / ");
+ if (si > 0)
+ {
+ m_artist = m_title.left(si).stripWhiteSpace();
+ m_title.remove(0, si+3);
+ m_title = m_title.stripWhiteSpace();
+ }
+
+ si = m_title.find(" - CD");
+ if (si > 0)
+ {
+ QString disc = m_title.right(m_title.length()-(si+5)).stripWhiteSpace();
+ m_disc = disc.toInt();
+ //kdDebug(7101) << "CDDB: found Disc: " << disc << endl;
+ m_title = m_title.left(si).stripWhiteSpace();
+ }
+
+ if (m_title.isEmpty())
+ m_title = i18n("No Title");
+ /*else
+ m_title.replace(QRegExp("/"), "%2f");*/
+ if (m_artist.isEmpty())
+ m_artist = i18n("Unknown");
+ /*else
+ m_artist.replace(QRegExp("/"), "%2f");*/
+
+ //kdDebug(7101) << "CDDB: found Title: `" << m_title << "'" << endl;
+ for (int i = 0; i < m_tracks; i++)
+ {
+ if (m_names[i].isEmpty())
+ m_names[i] += i18n("Track %1").arg(i);
+ //m_names[i].replace(QRegExp("/"), "%2f");
+ si = m_names[i].find(" - ");
+ if (si < 0)
+ {
+ si = m_names[i].find(" / ");
+ }
+ if (si > 0)
+ {
+ m_artists[i] = m_names[i].left(si).stripWhiteSpace();
+ m_names[i].remove(0, si+3);
+ m_names[i] = m_names[i].stripWhiteSpace();
+ }
+ else
+ {
+ m_artists[i] = m_artist;
+ }
+ //kdDebug(7101) << "CDDB: found Track " << i+1 << ": `" << m_names[i] << "'" << endl;
+ }
+ return true;
+}
+
+
+
+void
+CDDB::add_cddb_dirs(const QStringList& list)
+{
+ QString s = QDir::homeDirPath()+"/.cddb";
+
+ cddb_dirs = list;
+ if (cddb_dirs.isEmpty())
+ cddb_dirs += s;
+}
+
+
+
+/* Locates and opens the local file corresponding to that discid.
+ Returns TRUE, if file is found and ready for reading.
+ Returns FALSE, if file isn't found. In this case ret_file is initialized
+ with a QFile which resides in the first cddb_dir, and has a temp name
+ (the ID + getpid()). You can open it for writing. */
+bool
+CDDB::searchLocal(unsigned int id, QFile *ret_file)
+{
+ QDir dir;
+ QString filename;
+ filename = QString("%1").arg(id, 0, 16).rightJustify(8, '0');
+ QStringList::ConstIterator it;
+ for (it = cddb_dirs.begin(); it != cddb_dirs.end(); ++it)
+ {
+ dir.setPath(*it);
+ if (!dir.exists())
+ continue;
+ /* First look in dir directly. */
+ ret_file->setName (*it + "/" + filename);
+ if (ret_file->exists() && ret_file->open(IO_ReadOnly))
+ return true;
+ /* And then in the subdirs of dir (representing the categories normally).
+ */
+ const QFileInfoList *subdirs = dir.entryInfoList (QDir::Dirs);
+ QFileInfoListIterator fiit(*subdirs);
+ QFileInfo *fi;
+ while ((fi = fiit.current()) != 0)
+ {
+ ret_file->setName (*it + "/" + fi->fileName() + "/" + filename);
+ if (ret_file->exists() && ret_file->open(IO_ReadOnly))
+ return true;
+ ++fiit;
+ }
+ }
+ QString pid;
+ pid.setNum(::getpid());
+ ret_file->setName (cddb_dirs[0] + "/" + filename + "." + pid);
+ /* Try to create the save location. */
+ dir.setPath(cddb_dirs[0]);
+ if (save_local && !dir.exists())
+ {
+ //dir = QDir::current();
+ dir.mkdir(cddb_dirs[0]);
+ }
+ return false;
+}
+
+
+
+bool
+CDDB::queryCD(QValueList& track_ofs)
+{
+ int num_tracks = track_ofs.count() - 2;
+ if (num_tracks < 1)
+ return false;
+ unsigned int id = get_discid(track_ofs);
+ QFile file;
+ bool local;
+
+ /* Already read this ID. */
+ if (id == m_discid)
+ return true;
+
+ emit cddbMessage(i18n("Searching local cddb entry ..."));
+ qApp->processEvents();
+
+ /* First look for a local file. */
+ local = searchLocal (id, &file);
+ /* If we have no local file, and no remote connection, barf. */
+ if (!local && (!remote || ks == 0))
+ return false;
+
+ m_tracks = num_tracks;
+ m_title = "";
+ m_artist = "";
+ m_names.clear();
+ m_discid = id;
+ if (local)
+ {
+ QTextStream stream(&file);
+ /* XXX Hmm, what encoding is used by CDDB files? local? Unicode?
+ Nothing? */
+ //stream.setEncoding(QTextStream::Locale);
+ parse_read_resp(&stream, 0);
+ file.close();
+ return true;
+ }
+
+ emit cddbMessage(i18n("Searching remote cddb entry ..."));
+ qApp->processEvents();
+
+ /* Remote CDDB query. */
+ unsigned int length = track_ofs[num_tracks+1] - track_ofs[num_tracks];
+ QCString q;
+ q.sprintf("cddb query %08x %d", id, num_tracks);
+ QCString num;
+ for (int i = 0; i < num_tracks; i++)
+ q += " " + num.setNum(track_ofs[i]);
+ q += " " + num.setNum(length / 75);
+ if (!writeLine(q))
+ return false;
+ QCString r;
+ if (!readLine(r))
+ return false;
+ r = r.stripWhiteSpace();
+ int code = get_code(r);
+ if (code == 200)
+ {
+ QCString catg, d_id, title;
+ QDir dir;
+ QCString s, pid;
+
+ emit cddbMessage(i18n("Found exact match cddb entry ..."));
+ qApp->processEvents();
+
+ /* an exact match */
+ r.remove(0, 3);
+ parse_query_resp(r, catg, d_id, title);
+ //kdDebug(7101) << "CDDB: found exact CD: category=" << catg << " DiscId=" << d_id << " Title=`" << title << "'" << endl;
+ q = "cddb read " + catg + " " + d_id;
+ if (!writeLine(q))
+ return false;
+ if (!readLine(r))
+ return false;
+ r = r.stripWhiteSpace();
+ code = get_code(r);
+ if (code != 210)
+ return false;
+
+ pid.setNum(::getpid());
+ s = cddb_dirs[0].latin1();
+ //s = s + "/" +catg; // xine seems to not search in local subdirs
+ dir.setPath( s );
+ if ( !dir.exists() ) dir.mkdir( s );
+ s = s+"/"+ d_id;
+ file.setName( s );
+
+ if (save_local && file.open(IO_WriteOnly))
+ {
+ //kdDebug(7101) << "CDDB: file name to save =" << file.name() << endl;
+ QTextStream stream(&file);
+ if (!parse_read_resp(0, &stream))
+ {
+ file.remove();
+ return false;
+ }
+ file.close();
+ /*QString newname (file.name());
+ newname.truncate(newname.findRev('.'));
+ if (QDir::current().rename(file.name(), newname)) {
+ //kdDebug(7101) << "CDDB: rename failed" << endl;
+ file.remove();
+ } */
+ }
+ else if (!parse_read_resp(0, 0))
+ return false;
+ }
+ else if (code == 211)
+ {
+ // Found some close matches. We'll read the query response and ask the user
+ // which one should be fetched from the server.
+ QCString end = ".";
+ QCString catg, d_id, title;
+ QDir dir;
+ QCString s, pid, first_match;
+ QStringList disc_ids;
+
+ /* some close matches */
+ //XXX may be try to find marker based on r
+ emit cddbMessage(i18n("Found close cddb entry ..."));
+ qApp->processEvents();
+
+ int i=0;
+ while (1)
+ {
+ if (!readLine(r))
+ return false;
+ r = r.stripWhiteSpace();
+ if (r == end)
+ break;
+ disc_ids.append(r);
+ if (i == 0)
+ first_match = r;
+ i++;
+ }
+
+ bool ok = false;
+
+ // We don't want to be thinking too much, do we?
+// QApplication::restoreOverrideCursor();
+
+ // Oh, mylord, which match should I serve you?
+ QString _answer = KInputDialog::getItem(i18n("CDDB Matches"), i18n("Several close CDDB entries found. Choose one:"),
+ disc_ids, 0, false, &ok );
+ QCString answer = _answer.utf8();
+
+ if (ok){ // Get user selected match
+ parse_query_resp(answer, catg, d_id, title);
+ }
+ else{ // Get first match
+ parse_query_resp(first_match, catg, d_id, title);
+ }
+
+ // Now we can continue thinking...
+// QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) );
+
+ /*kdDebug(7101) << "CDDB: found close CD: category=" << catg << " DiscId="
+ << d_id << " Title=`" << title << "'" << endl;*/
+
+ // ... and forth we go as usual
+
+ q = "cddb read " + catg + " " + d_id;
+ if (!writeLine(q))
+ return false;
+ if (!readLine(r))
+ return false;
+ r = r.stripWhiteSpace();
+ code = get_code(r);
+ if (code != 210)
+ return false;
+
+ pid.setNum(::getpid());
+ s = cddb_dirs[0].latin1();
+ dir.setPath( s );
+ if ( !dir.exists() ) dir.mkdir( s );
+ s = s+"/"+ d_id;
+ file.setName( s );
+
+ if (save_local && file.open(IO_WriteOnly))
+ {
+ //kdDebug(7101) << "CDDB: file name to save =" << file.name() << endl;
+ QTextStream stream(&file);
+ if (!parse_read_resp(0, &stream))
+ {
+ file.remove();
+ return false;
+ }
+ file.close();
+ }
+ else if (!parse_read_resp(0, 0))
+ return false;
+
+ }
+ else
+ {
+ /* 202 - no match found
+ 403 - Database entry corrupt
+ 409 - no handshake */
+ //kdDebug(7101) << "CDDB: query returned code " << code << endl;
+ return false;
+ }
+
+ return true;
+}
diff --git a/src/cddb.h b/src/cddb.h
new file mode 100755
index 0000000..62c38a7
--- /dev/null
+++ b/src/cddb.h
@@ -0,0 +1,79 @@
+/*
+ Copyright (C) 2000 Michael Matz
+ Modified 2006 Daniel Faust , thx Michael
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef CDDB_H
+#define CDDB_H
+
+#include
+#include
+#include
+#include
+
+class QFile;
+class QTextStream;
+class KExtendedSocket;
+
+class CDDB : public QObject
+{
+ Q_OBJECT
+public:
+ CDDB();
+ ~CDDB();
+ bool set_server(const char *hostname = 0, unsigned short int port = 0);
+ void add_cddb_dirs(const QStringList& list);
+ void save_cddb (bool save) { save_local = save; }
+ unsigned int get_discid(QValueList& track_ofs);
+ bool queryCD(QValueList& track_ofs);
+ QString title() const { return m_title.utf8(); }
+ QString artist(int i) const;
+ int trackCount() const { return m_tracks; }
+ QString track(int i) const;
+ int disc() const { return m_disc; }
+ QString genre() const { return m_genre.utf8(); }
+ int year() const { return m_year; }
+
+private:
+ bool readLine(QCString& s);
+ bool writeLine(const QCString& s);
+ bool deinit();
+ bool parse_read_resp(QTextStream*, QTextStream*);
+ bool searchLocal(unsigned int id, QFile *ret_file);
+ KExtendedSocket *ks;
+ QCString h_name;
+ unsigned short int port;
+ bool remote;
+ bool save_local;
+ QStringList cddb_dirs;
+ QCString buf;
+ unsigned int m_discid;
+
+ int m_tracks;
+ int m_disc;
+ int m_year;
+ QString m_genre;
+ QString m_title;
+ QString m_artist;
+ QStringList m_artists;
+ QStringList m_names;
+
+signals:
+ void cddbMessage( QString );
+};
+
+#endif // CDDB_H
diff --git a/src/cdmanager.cpp b/src/cdmanager.cpp
new file mode 100755
index 0000000..cd9dd27
--- /dev/null
+++ b/src/cdmanager.cpp
@@ -0,0 +1,190 @@
+
+#include "cdmanager.h"
+#include "paranoia.h"
+#include "cddb.h"
+#include "conversionoptions.h"
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+
+// ### soundkonverter 0.4 implement reading of milliseconds/frames
+
+// TODO implement reading of cd data
+
+CDDevice::CDDevice( const QString& _device )
+{
+ QStringList s;
+ bool init = false;
+ QValueList qvl;
+ int i;
+ QStringList dcopList, devList;
+ bool ok = false;
+
+ tags.clear();
+
+ if( !_device.isEmpty() )
+ s.append( _device );
+ else {
+ DCOPRef mediamanager( "kded", "mediamanager" );
+ DCOPReply reply = mediamanager.call( "fullList()" );
+ if( reply.isValid() ) {
+ dcopList = reply;
+ i = 0;
+ while( i < (int)dcopList.count() ) {
+ if( dcopList[i+10] == "media/audiocd" ) {
+ devList.append( dcopList[i+5] );
+ }
+ i += 13;
+ }
+ if( devList.count() > 1 ) {
+ QString choice = KInputDialog::getItem( i18n("Audio CD"), i18n("Several audio CDs found. Choose one:"), devList, 0, false, &ok );
+ if( ok ) s.append( choice );
+ else s.append( 0 ); // TODO if canceled, the cd opener should close, not use the first item
+ }
+ else if( devList.count()==1 ) {
+ s.append( devList[0] );
+ }
+ else {
+ s.append( "/dev/cdrom" );
+ s.append( "/dev/dvd" );
+ }
+ }
+ else {
+ s.append( "/dev/cdrom" );
+ s.append( "/dev/dvd" );
+ }
+ }
+
+ para = new Paranoia();
+ for( i = 0; i < (int)s.count(); i++ ) {
+ if( init = para->init(s[i]) ) {
+ device = s[i];
+ break;
+ }
+ }
+ if( init ) {
+ trackCount = para->getTracks();
+ timeCount = para->trackTime( -1 );
+ for( i = 0; i < para->getTracks(); i++) {
+ qvl.append( para->trackFirstSector(i+1) + 150 );
+ }
+ qvl.append( para->discFirstSector() );
+ qvl.append( para->discLastSector() );
+ CDDB* cddb = new CDDB();
+ cddb->save_cddb( true );
+ if( cddb->queryCD(qvl) ) {
+ for( i = 0; i < para->getTracks(); i++ ) {
+ tags += new TagData( cddb->artist(i), "", cddb->title(), cddb->track(i), cddb->genre(), "",
+ i+1, cddb->disc(), cddb->year(), para->trackTime(i) );
+ }
+ }
+ else {
+ cddb->set_server( "freedb.freedb.org", 8880 );
+ if( cddb->queryCD(qvl) ) {
+ for( i = 0; i < para->getTracks(); i++ ) {
+ tags += new TagData( cddb->artist(i), "", cddb->title(), cddb->track(i), cddb->genre(), "",
+ i+1, cddb->disc(), cddb->year(), para->trackTime(i) );
+ }
+ }
+ else {
+ for( i = 0; i < para->getTracks(); i++ ) {
+ tags += new TagData( i18n("Unknown"), "", i18n("Unknown"), i18n("Unknown"), "", "", i+1, 1, 0, para->trackTime(i) );
+ }
+ }
+ }
+ delete cddb;
+ }
+ else {
+ KMessageBox::information( 0, i18n("No audio CD found."), i18n("Warning") );
+ device = "";
+ delete para;
+ para = 0;
+ }
+}
+
+CDDevice::~CDDevice()
+{}
+
+
+CDManager::CDManager()
+{}
+
+CDManager::~CDManager()
+{
+ while( cdDevices.count() > 0 ) delete cdDevices.first();
+}
+
+QString CDManager::newCDDevice( const QString& device )
+{
+ CDDevice* cdDevice = new CDDevice( device );
+
+ for( QValueList::Iterator it = cdDevices.begin(); it != cdDevices.end(); ++it ) {
+ if( (*it)->device = cdDevice->device ) {
+ cdDevices.remove( *it );
+ delete (*it);
+ break;
+ }
+ }
+
+ cdDevices += cdDevice;
+ return cdDevice->device;
+}
+
+QValueList CDManager::getTrackList( const QString& device )
+{
+ for( QValueList::Iterator it = cdDevices.begin(); it != cdDevices.end(); ++it ) {
+ if( (*it)->device = device ) return (*it)->tags;
+ }
+
+ QValueList list;
+ return list;
+}
+
+TagData* CDManager::getTags( const QString& device, int track )
+{
+ for( QValueList::Iterator it = cdDevices.begin(); it != cdDevices.end(); ++it ) {
+ if( (*it)->device = device ) {
+ if( track > 0 ) {
+ QValueList::Iterator tag = (*it)->tags.at( track - 1 );
+ return (*tag);
+ }
+ else {
+ return (*it)->discTags;
+ }
+ }
+ }
+
+ return 0;
+}
+
+int CDManager::getTrackCount( const QString& device )
+{
+ for( QValueList::Iterator it = cdDevices.begin(); it != cdDevices.end(); ++it ) {
+ if( (*it)->device = device ) return (*it)->trackCount;
+ }
+
+ return 0;
+}
+
+int CDManager::getTimeCount( const QString& device )
+{
+ for( QValueList::Iterator it = cdDevices.begin(); it != cdDevices.end(); ++it ) {
+ if( (*it)->device = device ) return (*it)->timeCount;
+ }
+
+ return 0;
+}
+
+void CDManager::setDiscTags( const QString& device, TagData* tags )
+{
+ for( QValueList::Iterator it = cdDevices.begin(); it != cdDevices.end(); ++it ) {
+ if( (*it)->device = device ) (*it)->discTags = tags;
+ }
+}
+
diff --git a/src/cdmanager.h b/src/cdmanager.h
new file mode 100755
index 0000000..9af80c8
--- /dev/null
+++ b/src/cdmanager.h
@@ -0,0 +1,95 @@
+
+
+#ifndef CDMANAGER_H
+#define CDMANAGER_H
+
+#include "tagengine.h"
+
+#include
+
+class ConversionOptions;
+class Paranoia;
+
+/**
+ * @short All data needed for a cd device
+ * @author Daniel Faust
+ * @version 0.3
+ */
+class CDDevice
+{
+public:
+ /**
+ * Constructor
+ */
+ CDDevice( const QString& _device="" );
+
+ /**
+ * Destructor
+ */
+ virtual ~CDDevice();
+
+ QString device;
+ Paranoia* para;
+ QValueList tags;
+ TagData* discTags;
+ int trackCount;
+ int timeCount;
+};
+
+/**
+ * @short The CD manager
+ * @author Daniel Faust
+ * @version 0.3
+ */
+class CDManager : public QObject
+{
+ Q_OBJECT
+public:
+ /**
+ * Constructor
+ */
+ CDManager();
+
+ /**
+ * Destructor
+ */
+ virtual ~CDManager();
+
+ /**
+ * Create a new CDDevice entry in cdDevices. Use @param device or auto search for an audio cd
+ * Return the used device (usefull, if auto searching was used)
+ */
+ QString newCDDevice( const QString& device="" );
+
+ /**
+ * Return a list of all tracks on the cd in drive @param device
+ */
+ QValueList getTrackList( const QString& device );
+
+ /**
+ * Return the tags of the track @param track on the cd in drive @param device
+ */
+ TagData* getTags( const QString& device, int track );
+
+ /**
+ * Set the tags of the cd in drive @param device
+ */
+ void setDiscTags( const QString& device, TagData* tags );
+
+ /**
+ * Return the sum of all tracks of the cd in drive @param device
+ */
+ int getTrackCount( const QString& device );
+
+ /**
+ * Return the complete length of the cd in drive @param device
+ */
+ int getTimeCount( const QString& device );
+
+private:
+ /** a list of all devices */
+ QValueList cdDevices;
+
+};
+
+#endif // CDMANAGER_H
diff --git a/src/cdopener.cpp b/src/cdopener.cpp
new file mode 100755
index 0000000..acabbc8
--- /dev/null
+++ b/src/cdopener.cpp
@@ -0,0 +1,781 @@
+
+#include "cdopener.h"
+#include "cdmanager.h"
+#include "tagengine.h"
+#include "config.h"
+#include "ripperpluginloader.h"
+#include "combobutton.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+// ### soundkonverter 0.4: implement cd info text
+
+CDOpener::CDOpener( Config* _config, CDManager* _cdManager, TagEngine* _tagEngine, const QString& _device, QWidget* parent, const char* name, /*Mode default_mode, const QString& default_text,*/ bool modal, WFlags f )
+ : KDialog( parent, name, modal, f )
+{
+ cdManager = _cdManager;
+ tagEngine = _tagEngine;
+ config = _config;
+
+ // create an icon loader object for loading icons
+ KIconLoader* iconLoader = new KIconLoader();
+
+ // let the dialog look nice
+ setCaption( i18n("Add CD tracks") );
+ setIcon( iconLoader->loadIcon("cdaudio_unmount",KIcon::Small) );
+
+ // the grid for all widgets in the dialog
+ QGridLayout* gridLayout = new QGridLayout( this, 1, 1, 11, 6, "gridLayout" );
+
+ // the grid for the artist and album input
+ QGridLayout* topGridLayout = new QGridLayout( this, 1, 1, 0, 6, "topGridLayout" );
+ gridLayout->addLayout( topGridLayout, 0, 0 );
+
+ // set up the first row at the top
+ QLabel* lArtistLabel = new QLabel( i18n("Artist:"), this, "lArtistLabel" );
+ topGridLayout->addWidget( lArtistLabel, 0, 0 );
+ cArtist = new KComboBox( true, this, "cArtist" );
+ topGridLayout->addWidget( cArtist, 0, 1 );
+ cArtist->setMinimumWidth( 200 );
+ cArtist->insertItem( i18n("Various Artists") );
+ cArtist->setCurrentText( "" );
+ connect( cArtist, SIGNAL(textChanged(const QString&)),
+ this, SLOT(artistChanged(const QString&))
+ );
+ // add a horizontal box layout for the composer
+ QHBoxLayout* artistBox = new QHBoxLayout( -1, "artistBox" );
+ topGridLayout->addLayout( artistBox, 0, 3 );
+ // and fill it up
+ QLabel* lComposerLabel = new QLabel( i18n("Composer:"), this, "lComposerLabel" );
+ lComposerLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
+ topGridLayout->addWidget( lComposerLabel, 0, 2 );
+ cComposer = new KComboBox( true, this, "cComposer" );
+ artistBox->addWidget( cComposer );
+ cComposer->insertItem( i18n("Various Composer") );
+ cComposer->setCurrentText( "" );
+ //cComposer->setSizePolicy( QSizePolicy::Maximum );
+ connect( cComposer, SIGNAL(textChanged(const QString&)),
+ this, SLOT(composerChanged(const QString&))
+ );
+ //artistBox->addStretch();
+ artistBox->addSpacing( 130 );
+// pCDDB = new KPushButton( iconLoader->loadIcon("cdaudio_unmount",KIcon::Small), i18n("Request CDDB"), this, "pCDDB" );
+// topGridLayout->addWidget( pCDDB, 0, 8 );
+
+ // set up the second row at the top
+ QLabel* lAlbumLabel = new QLabel( i18n("Album:"), this, "lAlbumLabel" );
+ topGridLayout->addWidget( lAlbumLabel, 1, 0 );
+ lAlbum = new KLineEdit( this, "lAlbum" );
+ topGridLayout->addWidget( lAlbum, 1, 1 );
+ // add a horizontal box layout for the disc number, year and genre
+ QHBoxLayout* albumBox = new QHBoxLayout( -1, "albumBox" );
+ topGridLayout->addLayout( albumBox, 1, 3 );
+ // and fill it up
+ QLabel* lDiscLabel = new QLabel( i18n("Disc No.:"), this, "lDiscLabel" );
+ lDiscLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
+ topGridLayout->addWidget( lDiscLabel, 1, 2 );
+ iDisc = new KIntSpinBox( 1, 99, 1, 1, 10, this, "iDisc" );
+ albumBox->addWidget( iDisc );
+ QLabel* lYearLabel = new QLabel( i18n("Year:"), this, "lYearLabel" );
+ albumBox->addWidget( lYearLabel );
+ iYear = new KIntSpinBox( 0, 99999, 1, QDate::currentDate().year(), 10, this, "iYear" );
+ albumBox->addWidget( iYear );
+ QLabel* lGenreLabel = new QLabel( i18n("Genre:"), this, "lGenreLabel" );
+ albumBox->addWidget( lGenreLabel );
+ cGenre = new KComboBox( true, this, "cGenre" );
+ cGenre->insertStringList( tagEngine->genreList );
+ cGenre->setCurrentText( "" );
+ KCompletion* cGenreCompletion = cGenre->completionObject();
+ cGenreCompletion->insertItems( tagEngine->genreList );
+ cGenreCompletion->setIgnoreCase( true );
+ albumBox->addWidget( cGenre );
+
+ // generate the list view for the tracks
+ trackList = new KListView( this, "trackList" );
+ gridLayout->addWidget( trackList, 1, 0 );
+ // and fill in the headers
+ trackList->addColumn( i18n("Track") );
+ trackList->addColumn( i18n("Artist"), 0 );
+ trackList->addColumn( i18n("Composer"), 0 );
+ trackList->addColumn( i18n("Title") );
+ trackList->addColumn( i18n("Time") );
+ trackList->setSelectionMode( QListView::Extended );
+ trackList->setAllColumnsShowFocus( true );
+ trackList->setResizeMode( QListView::LastColumn );
+ connect( trackList, SIGNAL(selectionChanged()),
+ this, SLOT(trackChanged())
+ );
+ connect( trackList, SIGNAL(doubleClicked(QListViewItem*,const QPoint&,int)),
+ this, SLOT(addClicked())
+ );
+ gridLayout->setRowStretch( 1, 1 );
+
+ // create the box at the bottom for editing the tags
+ tagGroupBox = new QGroupBox( i18n("No track selected"), this, "tagGroupBox" );
+ gridLayout->addWidget( tagGroupBox, 2, 0 );
+ tagGroupBox->setColumnLayout( 0, Qt::Vertical );
+ tagGroupBox->layout()->setSpacing( 6 );
+ tagGroupBox->layout()->setMargin( 6 );
+ QGridLayout* tagGridLayout = new QGridLayout( tagGroupBox->layout(), 1, 1, -1, "tagGridLayout" );
+
+ // add the up and down buttons
+ pTrackUp = new KPushButton( " ", tagGroupBox, "pTrackUp" );
+ pTrackUp->setPixmap( iconLoader->loadIcon("up",KIcon::Toolbar) );
+ pTrackUp->setAutoRepeat( true );
+ connect( pTrackUp, SIGNAL(clicked()),
+ this, SLOT(trackUpPressed())
+ );
+ tagGridLayout->addWidget( pTrackUp, 0, 0 );
+ pTrackDown = new KPushButton( " ", tagGroupBox, "pTrackDown" );
+ pTrackDown->setPixmap( iconLoader->loadIcon("down",KIcon::Toolbar) );
+ pTrackDown->setAutoRepeat( true );
+ connect( pTrackDown, SIGNAL(clicked()),
+ this, SLOT(trackDownPressed())
+ );
+ tagGridLayout->addWidget( pTrackDown, 1, 0 );
+
+ // add the inputs
+ // add a horizontal box layout for the title
+ QHBoxLayout* trackTitleBox = new QHBoxLayout( -1, "trackTitleBox" );
+ tagGridLayout->addLayout( trackTitleBox, 0, 2 );
+ // and fill it up
+ QLabel *lTrackTitleLabel = new QLabel( i18n("Title:"), tagGroupBox, "lTrackTitleLabel" );
+ tagGridLayout->addWidget( lTrackTitleLabel, 0, 1 );
+ lTrackTitle = new KLineEdit( tagGroupBox, "lTrackTitle" );
+ trackTitleBox->addWidget( lTrackTitle );
+ connect( lTrackTitle, SIGNAL(textChanged(const QString&)),
+ this, SLOT(trackTitleChanged(const QString&))
+ );
+ pTrackTitleEdit = new KPushButton( " ", tagGroupBox, "pTrackTitleEdit" );
+ pTrackTitleEdit->setPixmap( iconLoader->loadIcon("kwrite",KIcon::Small) );
+ pTrackTitleEdit->setFixedSize( lTrackTitle->sizeHint().height(), lTrackTitle->sizeHint().height() );
+ pTrackTitleEdit->hide();
+ trackTitleBox->addWidget( pTrackTitleEdit );
+ connect( pTrackTitleEdit, SIGNAL(clicked()),
+ this, SLOT(editTrackTitleClicked())
+ );
+ // add a horizontal box layout for the composer
+ QHBoxLayout* trackArtistBox = new QHBoxLayout( -1, "trackArtistBox" );
+ tagGridLayout->addLayout( trackArtistBox, 1, 2 );
+ // and fill it up
+ QLabel* lTrackArtistLabel = new QLabel( i18n("Artist:"), tagGroupBox, "lTrackArtistLabel" );
+ tagGridLayout->addWidget( lTrackArtistLabel, 1, 1 );
+ lTrackArtist = new KLineEdit( tagGroupBox, "lTrackArtist" );
+ trackArtistBox->addWidget( lTrackArtist );
+ connect( lTrackArtist, SIGNAL(textChanged(const QString&)),
+ this, SLOT(trackArtistChanged(const QString&))
+ );
+ pTrackArtistEdit = new KPushButton( " ", tagGroupBox, "pTrackArtistEdit" );
+ pTrackArtistEdit->setPixmap( iconLoader->loadIcon("kwrite",KIcon::Small) );
+ pTrackArtistEdit->setFixedSize( lTrackArtist->sizeHint().height(), lTrackArtist->sizeHint().height() );
+ pTrackArtistEdit->hide();
+ trackArtistBox->addWidget( pTrackArtistEdit );
+ connect( pTrackArtistEdit, SIGNAL(clicked()),
+ this, SLOT(editTrackArtistClicked())
+ );
+ QLabel* lTrackComposerLabel = new QLabel( i18n("Composer:"), tagGroupBox, "lTrackComposerLabel" );
+ trackArtistBox->addWidget( lTrackComposerLabel );
+ lTrackComposer = new KLineEdit( tagGroupBox, "lTrackComposer" );
+ trackArtistBox->addWidget( lTrackComposer );
+ connect( lTrackComposer, SIGNAL(textChanged(const QString&)),
+ this, SLOT(trackComposerChanged(const QString&))
+ );
+ pTrackComposerEdit = new KPushButton( " ", tagGroupBox, "pTrackComposerEdit" );
+ pTrackComposerEdit->setPixmap( iconLoader->loadIcon("kwrite",KIcon::Small) );
+ pTrackComposerEdit->setFixedSize( lTrackComposer->sizeHint().height(), lTrackComposer->sizeHint().height() );
+ pTrackComposerEdit->hide();
+ trackArtistBox->addWidget( pTrackComposerEdit );
+ connect( pTrackComposerEdit, SIGNAL(clicked()),
+ this, SLOT(editTrackComposerClicked())
+ );
+ // add a horizontal box layout for the comment
+ QHBoxLayout* trackCommentBox = new QHBoxLayout( -1, "trackCommentBox" );
+ tagGridLayout->addLayout( trackCommentBox, 2, 2 );
+ // and fill it up
+ QLabel* lTrackCommentLabel = new QLabel( i18n("Comment:"), tagGroupBox, "lTrackCommentLabel" );
+ tagGridLayout->addWidget( lTrackCommentLabel, 2, 1 );
+ tTrackComment = new KTextEdit( tagGroupBox, "tTrackComment" );
+ trackCommentBox->addWidget( tTrackComment );
+ tTrackComment->setFixedHeight( 65 );
+ connect( tTrackComment, SIGNAL(textChanged()),
+ this, SLOT(trackCommentChanged())
+ );
+ pTrackCommentEdit = new KPushButton( " ", tagGroupBox, "pTrackCommentEdit" );
+ pTrackCommentEdit->setPixmap( iconLoader->loadIcon("kwrite",KIcon::Small) );
+ pTrackCommentEdit->setFixedSize( lTrackTitle->sizeHint().height(), lTrackTitle->sizeHint().height() );
+ pTrackCommentEdit->hide();
+ trackCommentBox->addWidget( pTrackCommentEdit );
+ connect( pTrackCommentEdit, SIGNAL(clicked()),
+ this, SLOT(editTrackCommentClicked())
+ );
+
+ // draw a horizontal line
+ QFrame* lineFrame = new QFrame( this, "lineFrame" );
+ lineFrame->setFrameShape( QFrame::HLine );
+ lineFrame->setFrameShadow( QFrame::Sunken );
+ lineFrame->setFrameShape( QFrame::HLine );
+ gridLayout->addWidget( lineFrame, 3, 0 );
+ gridLayout->setRowSpacing( 3, 16 );
+
+ // add a horizontal box layout for the control elements
+ QHBoxLayout* controlBox = new QHBoxLayout( -1, "controlBox" );
+ gridLayout->addLayout( controlBox, 4, 0 );
+
+ // add the control elements
+ pSaveCue = new KPushButton( iconLoader->loadIcon("filesave",KIcon::Small), i18n("Save cuesheet ..."), this, "pSaveCue" );
+ controlBox->addWidget( pSaveCue );
+ connect( pSaveCue, SIGNAL(clicked()),
+ this, SLOT(saveCuesheetClicked())
+ );
+ controlBox->addStretch();
+
+ cAdd = new ComboButton( this, "cAdd" );
+ cAdd->insertItem( iconLoader->loadIcon("fileopen",KIcon::Small),i18n("Add all tracks") );
+ cAdd->insertItem( iconLoader->loadIcon("fileopen",KIcon::Small),i18n("Add selected tracks") );
+ RipperPlugin* plugin = config->getCurrentRipper();
+ if( plugin != 0 && plugin->rip.full_disc.enabled ) cAdd->insertItem( iconLoader->loadIcon("cdaudio_unmount",KIcon::Small),i18n("Add full CD as one file") );
+ //cAdd->setSizeMode( ComboButton::Min );
+ controlBox->addWidget( cAdd );
+ connect( cAdd, SIGNAL(clicked(int)),
+ this, SLOT(addClicked(int))
+ );
+ pCancel = new KPushButton( iconLoader->loadIcon("cancel",KIcon::Small), i18n("Cancel"), this, "pCancel" );
+ controlBox->addWidget( pCancel );
+ connect( pCancel, SIGNAL(clicked()),
+ this, SLOT(reject())
+ );
+
+ // delete the icon loader object
+ delete iconLoader;
+
+ bool various_artists = false;
+ bool various_composer = false;
+ QString artist = "";
+ QString composer = "";
+ QString album = "";
+ int disc = 0;
+ int year = 0;
+ QString genre = "";
+
+ device = cdManager->newCDDevice( _device );
+ // don't execute the dialog, if no audio cd was found
+ noCD = device.isEmpty();
+
+ QValueList tags = cdManager->getTrackList( device );
+ for( QValueList::Iterator it = tags.begin(); it != tags.end(); ++it ) {
+ if( artist == "" ) artist = (*it)->artist;
+ else if( artist != (*it)->artist ) various_artists = true;
+
+ if( composer == "" ) composer = (*it)->composer;
+ else if( composer != (*it)->composer ) various_composer = true;
+
+ if( album == "" ) album = (*it)->album;
+ if( disc == 0 ) disc = (*it)->disc;
+ if( year == 0 ) year = (*it)->year;
+ if( genre == "" ) genre = (*it)->genre;
+
+ new KListViewItem( trackList, QString().sprintf("%02i",(*it)->track), (*it)->artist, (*it)->composer, (*it)->title, QString().sprintf("%i:%02i",(*it)->length/60,(*it)->length%60) );
+ }
+ trackList->setSorting( -1 );
+
+ // fill in the cd information
+ if( various_artists ) cArtist->setCurrentItem( 0 );
+ else cArtist->setCurrentText( artist );
+ artistChanged( cArtist->currentText() );
+
+ if( various_composer ) cComposer->setCurrentItem( 0 );
+ else cComposer->setCurrentText( composer );
+ composerChanged( cComposer->currentText() );
+
+ lAlbum->setText( album );
+ if( disc != 0 ) iDisc->setValue( disc );
+ if( year != 0 ) iYear->setValue( year );
+ cGenre->setCurrentText( genre );
+
+ //trackList->setCurrentItem( trackList->firstChild() );
+ trackList->setSelected( trackList->firstChild(), true );
+
+ pTrackUp->setEnabled( false );
+ if( trackList->firstChild() != 0 ) {
+ if( trackList->firstChild()->itemBelow() != 0 ) {
+ pTrackDown->setEnabled( true );
+ }
+ else {
+ pTrackDown->setEnabled( false );
+ }
+ }
+ else {
+ pTrackDown->setEnabled( false );
+ }
+}
+
+CDOpener::~CDOpener()
+{}
+
+int CDOpener::columnByName( const QString& name )
+{
+ for( int i = 0; i < trackList->columns(); ++i ) {
+ if( trackList->columnText( i ) == name ) return i;
+ }
+ return -1;
+}
+
+void CDOpener::trackUpPressed()
+{
+ QListViewItem* item = selectedItems.first()->itemAbove();
+
+ if( item != 0 ) {
+ item->setSelected( true );
+ trackList->repaintItem( item );
+ trackList->ensureItemVisible( item );
+ }
+ else {
+ return; // NULL pointer (cannot be)
+ }
+
+ for( QValueList::Iterator it = selectedItems.begin(); it != selectedItems.end(); ++it ) {
+ (*it)->setSelected( false );
+ trackList->repaintItem( *it );
+ }
+
+ if( item->itemAbove() == 0 ) {
+ pTrackUp->setEnabled( false );
+ }
+
+ pTrackDown->setEnabled( true );
+
+ trackChanged();
+}
+
+void CDOpener::trackDownPressed()
+{
+ QListViewItem* item = selectedItems.last()->itemBelow();
+
+ if( item != 0 ) {
+ item->setSelected( true );
+ trackList->repaintItem( item );
+ trackList->ensureItemVisible( item );
+ }
+ else {
+ return; // NULL pointer (cannot be)
+ }
+
+ for( QValueList::Iterator it = selectedItems.begin(); it != selectedItems.end(); ++it ) {
+ (*it)->setSelected( false );
+ trackList->repaintItem( *it );
+ }
+
+ pTrackUp->setEnabled( true );
+
+ if( item->itemBelow() == 0 ) {
+ pTrackDown->setEnabled( false );
+ }
+
+ trackChanged();
+}
+
+void CDOpener::trackChanged()
+{
+ // NOTE if no track is selected soundkonverter could use the current item as default item (like qlistview does)
+ int i = 0;
+
+ // rebuild the list of the selected tracks
+ selectedTracks.clear();
+ selectedItems.clear();
+ for( QListViewItem *item = trackList->firstChild(); item != NULL; item = item->nextSibling() ) {
+ i++;
+ if( item->isSelected() ) {
+ selectedTracks.append( i );
+ selectedItems.append( item );
+ }
+ }
+
+ // insert the new values
+ if( selectedTracks.count() < 1 ) {
+ pTrackUp->setEnabled( false );
+ pTrackDown->setEnabled( false );
+
+ lTrackTitle->setEnabled( false );
+ lTrackTitle->setText( "" );
+ pTrackTitleEdit->hide();
+ lTrackArtist->setEnabled( false );
+ lTrackArtist->setText( "" );
+ pTrackArtistEdit->hide();
+ lTrackComposer->setEnabled( false );
+ lTrackComposer->setText( "" );
+ pTrackComposerEdit->hide();
+ tTrackComment->setEnabled( false );
+ tTrackComment->setReadOnly( true );
+ tTrackComment->setText( "" );
+ pTrackCommentEdit->hide();
+
+ return;
+ }
+ else if( selectedTracks.count() > 1 ) {
+ if( selectedItems.first()->itemAbove() != 0 ) pTrackUp->setEnabled( true );
+ else pTrackUp->setEnabled( false );
+
+ if( selectedItems.last()->itemBelow() != 0 ) pTrackDown->setEnabled( true );
+ else pTrackDown->setEnabled( false );
+
+ QString trackListString = "";
+ if( selectedTracks.count() == trackList->childCount() ) {
+ trackListString = i18n("All tracks");
+ }
+ else {
+ trackListString = i18n("Tracks") + QString().sprintf(" %02i",selectedTracks.first());
+ QValueList::Iterator track = selectedTracks.begin();
+ track++;
+ for( ; track != selectedTracks.end(); ++track ) {
+ trackListString += QString().sprintf(", %02i",*track);
+ }
+ }
+ tagGroupBox->setTitle( trackListString );
+
+ QString title = cdManager->getTags( device, selectedTracks.first() )->title;
+ bool equalTitles = true;
+ QString artist = cdManager->getTags( device, selectedTracks.first() )->artist;
+ bool equalArtists = true;
+ QString composer = cdManager->getTags( device, selectedTracks.first() )->composer;
+ bool equalComposers = true;
+ QString comment = cdManager->getTags( device, selectedTracks.first() )->comment;
+ bool equalComments = true;
+ for( QValueList::Iterator track = selectedTracks.begin(); track != selectedTracks.end(); ++track ) {
+ TagData* tags = cdManager->getTags( device, *track );
+
+ if( title != tags->title ) equalTitles = false;
+ if( artist != tags->artist ) equalArtists = false;
+ if( composer != tags->composer ) equalComposers = false;
+ if( comment != tags->comment ) equalComments = false;
+ }
+
+ if( equalTitles ) {
+ lTrackTitle->setEnabled( true );
+ lTrackTitle->setText( title );
+ pTrackTitleEdit->hide();
+ }
+ else {
+ lTrackTitle->setEnabled( false );
+ lTrackTitle->setText( "" );
+ pTrackTitleEdit->show();
+ }
+
+ if( cArtist->currentText() == i18n("Various Artists") && equalArtists ) {
+ lTrackArtist->setEnabled( true );
+ lTrackArtist->setText( artist );
+ pTrackArtistEdit->hide();
+ }
+ else if( cArtist->currentText() == i18n("Various Artists") ) {
+ lTrackArtist->setEnabled( false );
+ lTrackArtist->setText( "" );
+ pTrackArtistEdit->show();
+ }
+ else {
+ lTrackArtist->setEnabled( false );
+ lTrackArtist->setText( cArtist->currentText() );
+ pTrackArtistEdit->hide();
+ }
+
+ if( cComposer->currentText() == i18n("Various Composer") && equalComposers ) {
+ lTrackComposer->setEnabled( true );
+ lTrackComposer->setText( composer );
+ pTrackComposerEdit->hide();
+ }
+ else if( cComposer->currentText() == i18n("Various Composer") ) {
+ lTrackComposer->setEnabled( false );
+ lTrackComposer->setText( "" );
+ pTrackComposerEdit->show();
+ }
+ else {
+ lTrackComposer->setEnabled( false );
+ lTrackComposer->setText( cComposer->currentText() );
+ pTrackComposerEdit->hide();
+ }
+
+ if( equalComments ) {
+ tTrackComment->setEnabled( true );
+ tTrackComment->setReadOnly( false );
+ tTrackComment->setText( comment );
+ pTrackCommentEdit->hide();
+ }
+ else {
+ tTrackComment->setEnabled( false );
+ tTrackComment->setReadOnly( true );
+ tTrackComment->setText( "" );
+ pTrackCommentEdit->show();
+ }
+ }
+ else {
+ if( selectedItems.first()->itemAbove() != 0 ) pTrackUp->setEnabled( true );
+ else pTrackUp->setEnabled( false );
+
+ if( selectedItems.first()->itemBelow() != 0 ) pTrackDown->setEnabled( true );
+ else pTrackDown->setEnabled( false );
+
+ tagGroupBox->setTitle( i18n("Track") + QString().sprintf(" %02i",selectedTracks.first()) );
+
+ TagData* tags = cdManager->getTags( device, selectedTracks.first() );
+ lTrackTitle->setEnabled( true );
+ lTrackTitle->setText( tags->title );
+ pTrackTitleEdit->hide();
+ if( cArtist->currentText() == i18n("Various Artists") ) {
+ lTrackArtist->setEnabled( true );
+ lTrackArtist->setText( tags->artist );
+ pTrackArtistEdit->hide();
+ }
+ else {
+ lTrackArtist->setEnabled( false );
+ lTrackArtist->setText( cArtist->currentText() );
+ pTrackArtistEdit->hide();
+ }
+ if( cComposer->currentText() == i18n("Various Composer") ) {
+ lTrackComposer->setEnabled( true );
+ lTrackComposer->setText( tags->composer );
+ pTrackComposerEdit->hide();
+ }
+ else {
+ lTrackComposer->setEnabled( false );
+ lTrackComposer->setText( cComposer->currentText() );
+ pTrackComposerEdit->hide();
+ }
+ tTrackComment->setEnabled( true );
+ tTrackComment->setReadOnly( false );
+ tTrackComment->setText( tags->comment );
+ pTrackCommentEdit->hide();
+ }
+}
+
+void CDOpener::artistChanged( const QString& text )
+{
+ if( text == i18n("Various Artists") ) {
+ trackList->adjustColumn( columnByName( i18n("Artist") ) );
+ }
+ else {
+ trackList->setColumnWidth( columnByName( i18n("Artist") ), 0 );
+ }
+
+ trackChanged();
+}
+
+void CDOpener::composerChanged( const QString& text )
+{
+ if( text == i18n("Various Composer") ) {
+ trackList->adjustColumn( columnByName( i18n("Composer") ) );
+ }
+ else {
+ trackList->setColumnWidth( columnByName( i18n("Composer") ), 0 );
+ }
+
+ trackChanged();
+}
+
+void CDOpener::trackTitleChanged( const QString& text )
+{
+ if( !lTrackTitle->isEnabled() ) return;
+
+ for( QValueList::Iterator it = selectedItems.begin(); it != selectedItems.end(); ++it ) {
+ (*it)->setText( columnByName( i18n("Title") ), text );
+ }
+ for( QValueList::Iterator it = selectedTracks.begin(); it != selectedTracks.end(); ++it ) {
+ TagData* tags = cdManager->getTags( device, *it );
+ tags->title = text;
+ }
+}
+
+void CDOpener::trackArtistChanged( const QString& text )
+{
+ if( !lTrackArtist->isEnabled() ) return;
+
+ for( QValueList::Iterator it = selectedItems.begin(); it != selectedItems.end(); ++it ) {
+ (*it)->setText( columnByName( i18n("Artist") ), text );
+ }
+ for( QValueList::Iterator it = selectedTracks.begin(); it != selectedTracks.end(); ++it ) {
+ TagData* tags = cdManager->getTags( device, *it );
+ tags->artist = text;
+ }
+}
+
+void CDOpener::trackComposerChanged( const QString& text )
+{
+ if( !lTrackComposer->isEnabled() ) return;
+
+ for( QValueList::Iterator it = selectedItems.begin(); it != selectedItems.end(); ++it ) {
+ (*it)->setText( columnByName( i18n("Composer") ), text );
+ }
+ for( QValueList::Iterator it = selectedTracks.begin(); it != selectedTracks.end(); ++it ) {
+ TagData* tags = cdManager->getTags( device, *it );
+ tags->composer = text;
+ }
+}
+
+void CDOpener::trackCommentChanged()
+{
+ QString text = tTrackComment->text();
+
+ if( !tTrackComment->isEnabled() ) return;
+
+ for( QValueList::Iterator it = selectedTracks.begin(); it != selectedTracks.end(); ++it ) {
+ TagData* tags = cdManager->getTags( device, *it );
+ tags->comment = text;
+ }
+}
+
+void CDOpener::editTrackTitleClicked()
+{
+ lTrackTitle->setEnabled( true );
+ lTrackTitle->setFocus();
+ pTrackTitleEdit->hide();
+ trackTitleChanged( lTrackTitle->text() );
+}
+
+void CDOpener::editTrackArtistClicked()
+{
+ lTrackArtist->setEnabled( true );
+ lTrackArtist->setFocus();
+ pTrackArtistEdit->hide();
+ trackArtistChanged( lTrackArtist->text() );
+}
+
+void CDOpener::editTrackComposerClicked()
+{
+ lTrackComposer->setEnabled( true );
+ lTrackComposer->setFocus();
+ pTrackComposerEdit->hide();
+ trackComposerChanged( lTrackComposer->text() );
+}
+
+void CDOpener::editTrackCommentClicked()
+{
+ tTrackComment->setEnabled( true );
+ tTrackComment->setReadOnly( false );
+ tTrackComment->setFocus();
+ pTrackCommentEdit->hide();
+ trackCommentChanged();
+}
+
+void CDOpener::addClicked( int index )
+{
+ if( index == 0 )
+ {
+ QValueList allTracks;
+
+ // TODO save all options (album artist, disc, genre, etc.)
+ for( int it = 1; it <= cdManager->getTrackCount(device); ++it ) {
+ TagData* tags = cdManager->getTags( device, it );
+ if( cArtist->currentText() != i18n("Various Artists") ) tags->artist = cArtist->currentText();
+ if( cComposer->currentText() != i18n("Various Composer") ) tags->composer = cComposer->currentText();
+ tags->album = lAlbum->text();
+ tags->disc = iDisc->value();
+ tags->year = iYear->value();
+ tags->genre = cGenre->currentText();
+ allTracks += it;
+ }
+ emit addTracks( device, allTracks );
+ }
+ else if( index == 1 )
+ {
+ // TODO save all options (album artist, disc, genre, etc.)
+ for( QValueList::Iterator it = selectedTracks.begin(); it != selectedTracks.end(); ++it ) {
+ TagData* tags = cdManager->getTags( device, *it );
+ if( cArtist->currentText() != i18n("Various Artists") ) tags->artist = cArtist->currentText();
+ if( cComposer->currentText() != i18n("Various Composer") ) tags->composer = cComposer->currentText();
+ tags->album = lAlbum->text();
+ tags->disc = iDisc->value();
+ tags->year = iYear->value();
+ tags->genre = cGenre->currentText();
+ }
+ emit addTracks( device, selectedTracks );
+ }
+ else
+ {
+ // TODO save all options (album artist, disc, genre, etc.)
+ cdManager->setDiscTags( device,
+ new TagData( cArtist->currentText(), cComposer->currentText(),
+ lAlbum->text(), /*cArtist->currentText() + " - " + */lAlbum->text(),
+ cGenre->currentText(), "",
+ 1, iDisc->value(), iYear->value(),
+ cdManager->getTimeCount(device) ) );
+ emit addDisc( device );
+ }
+ accept();
+}
+
+// void CDOpener::addAsOneTrackClicked()
+// {
+// // TODO save all options (album artist, disc, genre, etc.)
+// cdManager->setDiscTags( device,
+// new TagData( cArtist->currentText(), cComposer->currentText(),
+// lAlbum->text(), /*cArtist->currentText() + " - " + */lAlbum->text(),
+// cGenre->currentText(), "",
+// 1, iDisc->value(), iYear->value(),
+// cdManager->getTimeCount(device) ) );
+//
+// emit addDisc( device );
+// accept();
+// }
+
+void CDOpener::saveCuesheetClicked()
+{
+ QString filename = KFileDialog::getSaveFileName( QDir::homeDirPath(), "*.cue" );
+ if( filename.isEmpty() ) return;
+
+ QFile cueFile( filename );
+ if( cueFile.exists() ) {
+ int ret = KMessageBox::questionYesNo( this,
+ i18n("A file with this name already exists.\n\nDo you want to overwrite the existing one?"),
+ i18n("File already exists") );
+ if( ret == KMessageBox::No ) return;
+ }
+ if( !cueFile.open( IO_WriteOnly ) ) return;
+
+ QString content;
+
+ content.append( "TITLE \"" + lAlbum->text() + "\"\n" );
+ content.append( "PERFORMER \"" + cArtist->currentText() + "\"\n" );
+ content.append( "FILE \"\" MP3\n" );
+
+ int INDEX = 0;
+ bool addFrames = false;
+ QValueList tags = cdManager->getTrackList( device );
+ for( QValueList::Iterator it = tags.begin(); it != tags.end(); ++it ) {
+ content.append( QString().sprintf(" TRACK %02i AUDIO\n",(*it)->track ) );
+ content.append( " TITLE \"" + (*it)->title + "\"\n" );
+ content.append( " PERFORMER \"" + (*it)->artist + "\"\n" );
+ if( addFrames ) {
+ content.append( QString().sprintf(" INDEX 01 %02i:%02i:37\n",INDEX/60,INDEX%60) );
+ INDEX++;
+ addFrames = false;
+ }
+ else {
+ content.append( QString().sprintf(" INDEX 01 %02i:%02i:00\n",INDEX/60,INDEX%60) );
+ addFrames = true;
+ }
+
+ INDEX += (*it)->length;
+ }
+
+ QTextStream ts( &cueFile );
+ ts << content;
+
+ cueFile.close();
+}
+
+
+
diff --git a/src/cdopener.h b/src/cdopener.h
new file mode 100755
index 0000000..09e941a
--- /dev/null
+++ b/src/cdopener.h
@@ -0,0 +1,139 @@
+
+
+#ifndef CDOPENER_H
+#define CDOPENER_H
+
+#include
+
+class CDManager;
+class TagEngine;
+class Config;
+class ComboButton;
+class KListView;
+class KPushButton;
+class KLineEdit;
+class KComboBox;
+class KIntSpinBox;
+class KTextEdit;
+class QGroupBox;
+class QListViewItem;
+
+/**
+ * @short Shows a dialog for selecting files from a CD
+ * @author Daniel Faust
+ * @version 0.3
+ */
+class CDOpener : public KDialog
+{
+ Q_OBJECT
+public:
+// enum Mode {
+// all_tracks,
+// selected_tracks,
+// full_cd
+// };
+
+ /**
+ * Constructor
+ * @param parent The parent widget
+ * @param name The name of the file list
+ * @p modal Sets whether the dialog is modal or not
+ * @p f Some flags
+ */
+ CDOpener( Config*, CDManager*, TagEngine*, const QString &device, QWidget *parent = 0, const char *name = 0, /*Mode default_mode = all_tracks, const QString& default_text = "",*/ bool modal = true, WFlags f = 0 );
+
+ /**
+ * Destructor
+ */
+ virtual ~CDOpener();
+
+ /** true if no CD was found (don't execute the dialog) */
+ bool noCD;
+
+private:
+ /** A list of all tracks on the CD */
+ KListView *trackList;
+
+ /** A combobox for entering the artist or selecting VA of the whole CD */
+ KComboBox *cArtist;
+ /** A combobox for entering the composer or selecting VC of the whole CD */
+ KComboBox *cComposer;
+ /** A lineedit for entering the album name */
+ KLineEdit *lAlbum;
+ /** A spinbox for entering or selecting the disc number */
+ KIntSpinBox *iDisc;
+ /** A spinbox for entering or selecting the year of the album */
+ KIntSpinBox *iYear;
+ /** A combobox for entering or selecting the genre of the album */
+ KComboBox *cGenre;
+
+ /** Request CDDB information */
+// KPushButton *pCDDB;
+
+ /** The groupbox shows the selected track numbers */
+ QGroupBox *tagGroupBox;
+
+ /** Set the focus of the tag editor to the track over it */
+ KPushButton *pTrackUp;
+ /** Set the focus of the tag editor to the track under it */
+ KPushButton *pTrackDown;
+
+ /** A lineedit for entering the title of track */
+ KLineEdit *lTrackTitle;
+ KPushButton *pTrackTitleEdit;
+ /** A lineedit for entering the artist of a track */
+ KLineEdit *lTrackArtist;
+ KPushButton *pTrackArtistEdit;
+ /** A lineedit for entering the composer of a track */
+ KLineEdit *lTrackComposer;
+ KPushButton *pTrackComposerEdit;
+ /** A textedit for entering a comment for a track */
+ KTextEdit *tTrackComment;
+ KPushButton *pTrackCommentEdit;
+
+ /** Save the tag information to a cue file */
+ KPushButton *pSaveCue;
+ //** Add whole CD as one track and quit the dialog */
+ //KPushButton *pAddAsOneTrack;
+ //** Add selected tracks to the file list and quit the dialog */
+ //KPushButton *pAdd;
+ ComboButton* cAdd;
+ /** Quit the dialog */
+ KPushButton *pCancel;
+
+ CDManager* cdManager;
+ TagEngine* tagEngine;
+ Config* config;
+
+ QString device;
+
+ QValueList selectedTracks;
+ QValueList selectedItems;
+
+ int columnByName( const QString& name );
+
+private slots:
+ void trackChanged();
+ void trackUpPressed();
+ void trackDownPressed();
+ void artistChanged( const QString& text );
+ void composerChanged( const QString& text );
+ void trackTitleChanged( const QString& text );
+ void trackArtistChanged( const QString& text );
+ void trackComposerChanged( const QString& text );
+ void trackCommentChanged();
+ void editTrackTitleClicked();
+ void editTrackArtistClicked();
+ void editTrackComposerClicked();
+ void editTrackCommentClicked();
+ void addClicked( int index = 1 );
+// void addAsOneTrackClicked();
+ void saveCuesheetClicked();
+
+signals:
+ void addTracks( const QString& device, QValueList );
+ void addDisc( const QString& device );
+ //void openCuesheetEditor( const QString& content );
+};
+
+#endif // CDOPENER_H
diff --git a/src/combobutton.cpp b/src/combobutton.cpp
new file mode 100755
index 0000000..ff5d758
--- /dev/null
+++ b/src/combobutton.cpp
@@ -0,0 +1,114 @@
+
+#include "combobutton.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+ComboButton::ComboButton( QWidget *parent, const char *name )
+ : QWidget( parent, name )
+{
+ m_increaseHeight = 0;
+
+ QGridLayout *grid = new QGridLayout( this, 1, 1 );
+
+ m_box = new KComboBox(this);
+ grid->addWidget(m_box,0,0);
+
+ connect( m_box, SIGNAL(activated(int)),
+ this, SLOT(boxActivated(int))
+ );
+
+ m_button = new KPushButton( QString::null, this, "pushbutton" );
+ grid->addWidget( m_button, 0, 0 );
+
+ connect( m_button, SIGNAL(clicked()),
+ this, SLOT(buttonClicked())
+ );
+
+ m_sizeMode = Max;
+
+ balanceSize();
+}
+
+ComboButton::~ComboButton()
+{
+}
+
+void ComboButton::balanceSize()
+{
+ int width;
+
+ if( m_sizeMode == Max )
+ width = m_box->sizeHint().width()-17;
+ else
+ width = m_button->sizeHint().width();
+
+ int height = ( m_box->sizeHint().height() > m_button->sizeHint().height() ) ? m_box->sizeHint().height() : m_button->sizeHint().height();
+
+ m_box->setFixedSize( width+17, height+m_increaseHeight );
+ m_button->setFixedSize( width, height+m_increaseHeight );
+}
+
+void ComboButton::repaintButton()
+{
+ m_button->setText( m_box->currentText() );
+ if(m_box->pixmap( m_box->currentItem()) )
+ m_button->setIconSet( *m_box->pixmap(m_box->currentItem()) );
+ balanceSize();
+}
+
+void ComboButton::insertItem( const QString &text, int index )
+{
+ m_box->insertItem( text, index );
+ repaintButton();
+}
+
+void ComboButton::insertItem( const QPixmap &pixmap, const QString &text, int index )
+{
+ m_box->insertItem( pixmap, text, index );
+ repaintButton();
+}
+
+void ComboButton::increaseHeight( int height )
+{
+ m_increaseHeight = height;
+ balanceSize();
+}
+
+void ComboButton::boxActivated( int index )
+{
+ repaintButton();
+ emit clicked( index );
+}
+
+void ComboButton::buttonClicked()
+{
+ emit clicked( m_box->currentItem() );
+}
+
+void ComboButton::setSizeMode( int mode )
+{
+ m_sizeMode = mode;
+ balanceSize();
+}
+
+int ComboButton::sizeMode()
+{
+ return m_sizeMode;
+}
+
+void ComboButton::setFont( const QFont& font )
+{
+ m_button->setFont( font );
+ m_box->setFont( font );
+}
+
+QFont ComboButton::font()
+{
+ return m_button->font();
+}
+
diff --git a/src/combobutton.h b/src/combobutton.h
new file mode 100755
index 0000000..3f07199
--- /dev/null
+++ b/src/combobutton.h
@@ -0,0 +1,110 @@
+
+
+#ifndef COMBOBUTTON_H
+#define COMBOBUTTON_H
+
+#include
+
+class QString;
+class QPixmap;
+class KPushButton;
+class KComboBox;
+
+/**
+ * @short ComboButton
+ * @author Daniel Faust
+ * @version 0.3
+ */
+class ComboButton : public QWidget
+{
+ Q_OBJECT
+public:
+ enum SizeMode {
+ Min, Max
+ };
+
+ /**
+ * Constructor
+ * @param parent The parent widget
+ * @param name The name of the file list
+ */
+ ComboButton( QWidget *parent, const char *name = 0 );
+
+ /**
+ * Destructor
+ */
+ virtual ~ComboButton();
+
+ /**
+ * Insert a new item with @p text at position @p index
+ */
+ void insertItem( const QString &text, int index = -1 );
+ /**
+ * Insert a new item with an icon @p pixmap and @p text at position @p index
+ */
+ void insertItem( const QPixmap &pixmap, const QString &text, int index = -1 );
+
+ /**
+ * Increase the combobutton's height by @p height
+ */
+ void increaseHeight( int height );
+
+ /**
+ * Sets m_sizeMode to @p mode
+ */
+ void setSizeMode( int mode );
+
+ /**
+ * Returns the m_sizeMode
+ */
+ int sizeMode();
+
+ /**
+ * Sets the font of the combobutton
+ */
+ void setFont( const QFont& font );
+
+ /**
+ * Returns the font of the button
+ */
+ QFont font();
+
+private:
+ /** A pointer to the button */
+ KPushButton *m_button;
+ /** A pointer to the combobox */
+ KComboBox *m_box;
+
+ int m_increaseHeight;
+
+ /** The actual size mode */
+ int m_sizeMode;
+
+ /** Recalculate the size of the combobutton */
+ void balanceSize();
+ /** The button gets a new label, etc. */
+ void repaintButton();
+
+//public slots:
+ //void setCurrentItem(const QString &item, bool insert=false, int index=-1);
+ //void setCurrentItem(int index);
+
+private slots:
+ /**
+ * Is called when the user selects an item from the popdown menu of the combobox
+ */
+ void boxActivated( int index );
+ /**
+ * Is called when the user clicks the button
+ */
+ void buttonClicked();
+
+signals:
+ /**
+ * The signal clicked is emitted, when the user selects an item
+ */
+ void clicked( int index );
+
+};
+
+#endif // COMBOBUTTON_H
diff --git a/src/config.cpp b/src/config.cpp
new file mode 100755
index 0000000..b8b1904
--- /dev/null
+++ b/src/config.cpp
@@ -0,0 +1,1516 @@
+
+#include "config.h"
+#include "logger.h"
+#include "convertpluginloader.h"
+#include "replaygainpluginloader.h"
+#include "ripperpluginloader.h"
+#include "options.h"
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+// NOTE currently only the possibilities of a file format are respected,
+// the possibilities of the current encoder are ignored
+// - seems to be fixed
+
+FormatItem::FormatItem()
+{
+ // reset everything
+ mime_types.clear();
+ size = 0;
+ compressionType = FormatInfo::lossy;
+ compressionLevel = 0;
+ internalReplayGain = false;
+ encoders.clear();
+ decoders.clear();
+ replaygains.clear();
+ //repairers.clear();
+ encoder = 0;
+ decoder = 0;
+ replaygain = 0;
+ //repairer = 0;
+}
+
+FormatItem::~FormatItem()
+{}
+
+
+Config::Config( Logger* _logger )
+{
+ logger = _logger;
+
+ currentRipper = 0; // this seems to be unnecessary
+}
+
+Config::~Config()
+{}
+
+void Config::read()
+{
+ loadPlugins();
+ readProfiles();
+
+ KConfig *conf = kapp->config();
+ QStringList listDefaults;
+ int intDefault;
+ bool boolDefault;
+ QString ripper;
+ QString encoder;
+ QString decoder;
+ QString replaygain;
+ int rank;
+
+ conf->setGroup( "General" ) ;
+ data.app.configVersion = conf->readNumEntry( "configVersion", 0 );
+
+/* if( configVersion == 0 ) {
+ conf->setGroup( "Interface" );
+ data.general.updateDelay = conf->readNumEntry( "pauseMS", 500 );
+ data.general.startTab = conf->readNumEntry( "startTab", 0 );
+ data.general.showToolBar = conf->readBoolEntry( "showToolBar", false );
+
+ conf->setGroup( "Backends" );
+ listDefaults.clear();
+ QString datadir = locateLocal( "data", "soundkonverter/bin/" );
+ datadir.remove( datadir.length() - 1, 1 );
+ listDefaults.append( datadir );
+ listDefaults.append( QDir::homeDirPath() + "/bin" );
+ listDefaults.append( "/usr/local/bin" );
+ listDefaults.append( "/usr/bin" );
+ data.environment.directories = conf->readListEntry( "directories", listDefaults );
+ listDefaults.clear();
+ data.environment.foundPrograms = conf->readListEntry( "programs", listDefaults );
+
+ conf->setGroup( "Misc" );
+ //configVersion = conf->readNumEntry( "configVersion", 0 );
+ data.general.askForNewOptions = conf->readBoolEntry( "askForNewOptions", true );
+
+ return;
+ }*/
+
+ conf->setGroup( "General" ) ;
+ //configVersion = conf->readNumEntry( "configVersion", 0 );
+ data.general.startTab = conf->readNumEntry( "startTab", 0 );
+ data.general.lastTab = conf->readNumEntry( "lastTab", 0 );
+ data.general.defaultProfile = conf->readEntry( "defaultProfile", i18n("Last used") );
+ data.general.defaultFormat = conf->readEntry( "defaultFormat", i18n("Last used") );
+// data.general.defaultOutputDirectory = conf->readEntry( "defaultOutputDirectory", QDir::homeDirPath() + "/soundKonverter/%b/%d - %n - %a - %t" );
+ data.general.specifyOutputDirectory = conf->readEntry( "specifyOutputDirectory", QDir::homeDirPath() + "/soundKonverter" );
+ data.general.metaDataOutputDirectory = conf->readEntry( "metaDataOutputDirectory", QDir::homeDirPath() + "/soundKonverter/%b/%d - %n - %a - %t" );
+ data.general.copyStructureOutputDirectory = conf->readEntry( "copyStructureOutputDirectory", QDir::homeDirPath() + "/soundKonverter" );
+ data.general.useVFATNames = conf->readBoolEntry( "useVFATNames", true );
+ data.general.conflictHandling = conf->readNumEntry( "conflictHandling", 0 );
+ data.general.priority = conf->readNumEntry( "priority", 10 );
+ data.general.numFiles = conf->readNumEntry( "numFiles", 3 );
+ data.general.updateDelay = conf->readNumEntry( "updateDelay", 500 );
+ data.general.askForNewOptions = conf->readBoolEntry( "askForNewOptions", true );
+ data.general.executeUserScript = conf->readBoolEntry( "executeUserScript", false );
+ data.general.showToolBar = conf->readBoolEntry( "showToolBar", false );
+
+ conf->setGroup( "Plugins" );
+ data.plugins.checkForUpdates = conf->readBoolEntry( "checkForUpdates", false );
+
+ conf->setGroup( "Environment" );
+ listDefaults.clear();
+ QString datadir = locateLocal( "data", "soundkonverter/bin/" );
+ datadir.remove( datadir.length() - 1, 1 );
+ listDefaults.append( datadir );
+ listDefaults.append( QDir::homeDirPath() + "/bin" );
+ listDefaults.append( "/usr/local/bin" );
+ listDefaults.append( "/usr/bin" );
+ data.environment.directories = conf->readListEntry( "directories", listDefaults );
+ listDefaults.clear();
+ data.environment.foundPrograms = conf->readListEntry( "foundPrograms", listDefaults );
+
+ conf->setGroup( "Ripper" );
+ ripper = conf->readEntry( "ripper", "kio_audiocd" );
+
+ if( ripper == "kio_audiocd" ) rank = 10000;
+ else rank = 60; // kio_audiocd ranking
+ currentRipper = 0; // this is a valid ripper (kio_audiocd)
+ for( QValueList::Iterator b = rippers.begin(); b != rippers.end(); ++b ) {
+ binaries[ (*b)->rip.bin ] = "";
+ if( (*b)->rip.rank > rank ) {
+ rank = (*b)->rip.rank;
+ currentRipper = (*b);
+ }
+ if( (*b)->rip.bin == ripper ) {
+ rank = 10000; // should be high enough to overbid the other plugins
+ currentRipper = (*b);
+ }
+ }
+
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it )
+ {
+ for( QValueList::Iterator b = (*it).encoders.begin(); b != (*it).encoders.end(); ++b ) {
+ binaries[ (*b)->enc.bin ] = "";
+ }
+
+ for( QValueList::Iterator b = (*it).decoders.begin(); b != (*it).decoders.end(); ++b ) {
+ binaries[ (*b)->dec.bin ] = "";
+ }
+
+ for( QValueList::Iterator b = (*it).replaygains.begin(); b != (*it).replaygains.end(); ++b ) {
+ binaries[ (*b)->replaygain.bin ] = "";
+ }
+
+ for( QMap::Iterator b = binaries.begin(); b != binaries.end(); ++b ) {
+ for( QStringList::Iterator c = data.environment.directories.begin(); c != data.environment.directories.end(); ++c )
+ {
+ if( b.data() == "" && QFile::exists((*c) + "/" + b.key()) ) {
+ b.data() = (*c) + "/" + b.key();
+ }
+ }
+ }
+ QStringList foundPrograms;
+ for( QMap::Iterator b = binaries.begin(); b != binaries.end(); ++b ) {
+ if( b.data() != "" ) {
+ foundPrograms.append( b.data() );
+ }
+ }
+ if( foundPrograms != data.environment.foundPrograms ) {
+ backendsChanged = true;
+ }
+ else {
+ backendsChanged = false;
+ }
+ }
+
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it )
+ {
+ conf->setGroup( (*it).mime_types.first() );
+ encoder = conf->readEntry( "encoder" );
+ decoder = conf->readEntry( "decoder" );
+ replaygain = conf->readEntry( "replaygain" );
+
+ (*it).encoder = 0;
+ (*it).decoder = 0;
+ (*it).replaygain = 0;
+
+ rank = 0;
+ for( QValueList::Iterator b = (*it).encoders.begin(); b != (*it).encoders.end(); ++b ) {
+ if( (*b)->enc.rank > rank && binaries[(*b)->enc.bin] != "" ) {
+ rank = (*b)->enc.rank;
+ (*it).encoder = (*b);
+ }
+ if( (*b)->enc.bin == encoder && binaries[(*b)->enc.bin] != "" ) {
+ rank = 10000; // should be high enougth to overbid the other plugins
+ (*it).encoder = (*b);
+ }
+ }
+
+ rank = 0;
+ for( QValueList::Iterator b = (*it).decoders.begin(); b != (*it).decoders.end(); ++b ) {
+ if( (*b)->dec.rank > rank && binaries[(*b)->dec.bin] != "" ) {
+ rank = (*b)->dec.rank;
+ (*it).decoder = (*b);
+ }
+ if( (*b)->dec.bin == decoder && binaries[(*b)->dec.bin] != "" ) {
+ rank = 10000; // should be high enougth to overbid the other plugins
+ (*it).decoder = (*b);
+ }
+ }
+
+ rank = 0;
+ for( QValueList::Iterator b = (*it).replaygains.begin(); b != (*it).replaygains.end(); ++b ) {
+ if( (*b)->replaygain.rank > rank && binaries[(*b)->replaygain.bin] != "" ) {
+ rank = (*b)->replaygain.rank;
+ (*it).replaygain = (*b);
+ }
+ if( (*b)->replaygain.bin == replaygain && binaries[(*b)->replaygain.bin] != "" ) {
+ rank = 10000; // should be high enougth to overbid the other plugins
+ (*it).replaygain = (*b);
+ }
+ }
+
+ if( (*it).encoder != 0 && (*it).encoder->enc.strength.enabled ) {
+ if( (*it).encoder->enc.strength.range_max >= (*it).encoder->enc.strength.range_min )
+ intDefault = (*it).encoder->enc.strength.default_value / (*it).encoder->enc.strength.step;
+ else
+ intDefault = ( (*it).encoder->enc.strength.range_min - (*it).encoder->enc.strength.default_value ) / (*it).encoder->enc.strength.step;
+ }
+ else {
+ intDefault = 0;
+ }
+ (*it).compressionLevel = conf->readNumEntry( "compressionLevel", intDefault );
+
+ if( (*it).encoder != 0 && (*it).encoder->enc.replaygain.enabled ) {
+ if( (*it).replaygain != 0 && (*it).replaygain->replaygain.rank > (*it).encoder->enc.replaygain.rank ) {
+ boolDefault = false;
+ }
+ else {
+ boolDefault = true;
+ }
+ }
+ else {
+ boolDefault = false;
+ }
+ (*it).internalReplayGain = conf->readBoolEntry( "internalReplayGain", boolDefault );
+ }
+}
+
+void Config::write( bool sync )
+{
+ QTime time;
+ time.start();
+
+ writeProfiles();
+ writeServiceMenu();
+ writeAmarokScript();
+
+ KConfig *conf = kapp->config();
+
+ conf->setGroup( "Ripper" );
+ conf->writeEntry( "ripper", (currentRipper)?currentRipper->rip.bin:"kio_audiocd" );
+
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it )
+ {
+ conf->setGroup( (*it).mime_types.first() );
+ if( (*it).encoder ) conf->writeEntry( "encoder", (*it).encoder->enc.bin );
+ if( (*it).decoder ) conf->writeEntry( "decoder", (*it).decoder->dec.bin );
+ if( (*it).replaygain ) conf->writeEntry( "replaygain", (*it).replaygain->replaygain.bin );
+ conf->writeEntry( "compressionLevel", (*it).compressionLevel );
+ conf->writeEntry( "internalReplayGain", (*it).internalReplayGain );
+ }
+
+ conf->setGroup( "General" ) ;
+ conf->writeEntry( "configVersion", 300 );
+ conf->writeEntry( "startTab", data.general.startTab );
+ conf->writeEntry( "lastTab", data.general.lastTab );
+ conf->writeEntry( "defaultProfile", data.general.defaultProfile );
+ conf->writeEntry( "defaultFormat", data.general.defaultFormat );
+// conf->writeEntry( "defaultOutputDirectory", data.general.defaultOutputDirectory );
+ conf->writeEntry( "specifyOutputDirectory", data.general.specifyOutputDirectory );
+ conf->writeEntry( "metaDataOutputDirectory", data.general.metaDataOutputDirectory );
+ conf->writeEntry( "copyStructureOutputDirectory", data.general.copyStructureOutputDirectory );
+ conf->writeEntry( "useVFATNames", data.general.useVFATNames );
+ conf->writeEntry( "conflictHandling", data.general.conflictHandling );
+ conf->writeEntry( "priority", data.general.priority );
+ conf->writeEntry( "numFiles", data.general.numFiles );
+ conf->writeEntry( "updateDelay", data.general.updateDelay );
+ conf->writeEntry( "askForNewOptions", data.general.askForNewOptions );
+ conf->writeEntry( "executeUserScript", data.general.executeUserScript );
+ conf->writeEntry( "showToolBar", data.general.showToolBar );
+
+ conf->setGroup( "Plugins" );
+ conf->writeEntry( "checkForUpdates", data.plugins.checkForUpdates );
+
+ conf->setGroup( "Environment" );
+ conf->writeEntry( "directories", data.environment.directories );
+ data.environment.foundPrograms.clear();
+ for( QMap::Iterator b = binaries.begin(); b != binaries.end(); ++b ) {
+ if( b.data() != "" ) {
+ data.environment.foundPrograms.append( b.data() );
+ }
+ }
+ conf->writeEntry( "foundPrograms", data.environment.foundPrograms );
+
+ if( sync ) conf->sync();
+
+ emit configChanged();
+
+ logger->log( 1000, "wrote preferences: " + QString::number(time.elapsed()) );
+}
+
+void Config::readProfiles()
+{
+ int version;
+ QString name;
+ ConversionOptions options;
+
+ QDomDocument domTree;
+ QFile opmlFile( locateLocal("data","soundkonverter/profiles.xml") );
+ if( !opmlFile.open( IO_ReadOnly ) ) return;
+ if( !domTree.setContent( &opmlFile ) ) return;
+ opmlFile.close();
+
+ QDomElement root = domTree.documentElement();
+ if( root.attribute("type") != "profiles" ) return;
+ QDomNode node, sub1Node, sub2Node;
+ node = root.firstChild();
+
+ while( !node.isNull() ) {
+ if( node.isElement() && node.nodeName() == "info" ) {
+
+ version = node.toElement().attribute("version").toInt();
+
+ }
+ else if( node.isElement() && node.nodeName() == "profile" ) {
+
+ name = node.toElement().attribute("name");
+
+ sub1Node = node.toElement().firstChild();
+ while( !sub1Node.isNull() ) {
+ if( sub1Node.isElement() && sub1Node.nodeName() == "encodingOptions" ) {
+// TODO clean up
+ options.encodingOptions.sFormat = sub1Node.toElement().attribute("sFormat");
+ options.encodingOptions.sQualityMode = sub1Node.toElement().attribute("sQualityMode");
+ options.encodingOptions.iQuality = sub1Node.toElement().attribute("iQuality").toInt();
+ options.encodingOptions.sBitrateMode = sub1Node.toElement().attribute("sBitrateMode");
+ options.encodingOptions.bBitrateRange = sub1Node.toElement().attribute("bBitrateRange").toInt();
+ options.encodingOptions.iMinBitrate = sub1Node.toElement().attribute("iMinBitrate").toInt();
+ options.encodingOptions.iMaxBitrate = sub1Node.toElement().attribute("iMaxBitrate").toInt();
+
+ sub2Node = sub1Node.toElement().firstChild();
+ while( !sub2Node.isNull() ) {
+ if( sub2Node.isElement() && sub2Node.nodeName() == "samplingRate" ) {
+
+ options.encodingOptions.samplingRate.bEnabled = sub2Node.toElement().attribute("bEnabled").toInt();
+ options.encodingOptions.samplingRate.iSamplingRate = sub2Node.toElement().attribute("iSamplingRate").toInt();
+
+ }
+ else if( sub2Node.isElement() && sub2Node.nodeName() == "channels" ) {
+
+ options.encodingOptions.channels.bEnabled = sub2Node.toElement().attribute("bEnabled").toInt();
+ options.encodingOptions.channels.sChannels = sub2Node.toElement().attribute("sChannels");
+
+ }
+ else if( sub2Node.isElement() && sub2Node.nodeName() == "replaygain" ) {
+
+ options.encodingOptions.replaygain.bEnabled = sub2Node.toElement().attribute("bEnabled").toInt();
+
+ }
+ sub2Node = sub2Node.nextSibling();
+ }
+
+ options.encodingOptions.sInOutFiles = sub1Node.toElement().attribute("sInOutFiles");
+
+ }
+ else if( sub1Node.isElement() && sub1Node.nodeName() == "outputOptions" ) {
+
+ options.outputOptions.mode = (OutputDirectory::Mode)sub1Node.toElement().attribute("mode").toInt();
+ options.outputOptions.directory = sub1Node.toElement().attribute("directory");
+
+ }
+ sub1Node = sub1Node.nextSibling();
+ }
+ ProfileData profileData;
+ profileData.name = name;
+ profileData.options = options;
+ profiles += profileData;
+ }
+ node = node.nextSibling();
+ }
+}
+
+void Config::writeProfiles()
+{
+ QDomDocument domTree;
+ QDomElement root = domTree.createElement( "soundkonverter" );
+ root.setAttribute( "type", "profiles" );
+ domTree.appendChild( root );
+
+ QDomElement info = domTree.createElement( "info" );
+ info.setAttribute( "version", "300" );
+ root.appendChild( info );
+
+ for( QValueList::Iterator it = profiles.begin(); it != profiles.end(); ++it ) {
+ QDomElement profile = domTree.createElement( "profile" );
+ profile.setAttribute( "name", (*it).name );
+
+ QDomElement encodingOptions = domTree.createElement( "encodingOptions" );
+
+ encodingOptions.setAttribute( "sFormat", (*it).options.encodingOptions.sFormat );
+ encodingOptions.setAttribute( "sQualityMode", (*it).options.encodingOptions.sQualityMode );
+ encodingOptions.setAttribute( "iQuality", (*it).options.encodingOptions.iQuality );
+ encodingOptions.setAttribute( "sBitrateMode", (*it).options.encodingOptions.sBitrateMode );
+ encodingOptions.setAttribute( "bBitrateRange", (*it).options.encodingOptions.bBitrateRange );
+ encodingOptions.setAttribute( "iMinBitrate", (*it).options.encodingOptions.iMinBitrate );
+ encodingOptions.setAttribute( "iMaxBitrate", (*it).options.encodingOptions.iMaxBitrate );
+
+ QDomElement samplingRate = domTree.createElement( "samplingRate" );
+
+ samplingRate.setAttribute( "bEnabled", (*it).options.encodingOptions.samplingRate.bEnabled );
+ samplingRate.setAttribute( "iSamplingRate", (*it).options.encodingOptions.samplingRate.iSamplingRate );
+
+ encodingOptions.appendChild( samplingRate );
+
+ QDomElement channels = domTree.createElement( "channels" );
+
+ channels.setAttribute( "bEnabled", (*it).options.encodingOptions.channels.bEnabled );
+ channels.setAttribute( "sChannels", (*it).options.encodingOptions.channels.sChannels );
+
+ encodingOptions.appendChild( channels );
+
+ QDomElement replaygain = domTree.createElement( "replaygain" );
+
+ replaygain.setAttribute( "bEnabled", (*it).options.encodingOptions.replaygain.bEnabled );
+
+ encodingOptions.appendChild( replaygain );
+
+ encodingOptions.setAttribute( "sInOutFiles", (*it).options.encodingOptions.sInOutFiles );
+
+ profile.appendChild( encodingOptions );
+
+ QDomElement outputOptions = domTree.createElement( "outputOptions" );
+
+ outputOptions.setAttribute( "mode", int((*it).options.outputOptions.mode) );
+ outputOptions.setAttribute( "directory", (*it).options.outputOptions.directory );
+
+ profile.appendChild( outputOptions );
+
+ root.appendChild( profile );
+ }
+
+ QFile opmlFile( locateLocal("data","soundkonverter/profiles.xml") );
+ if( !opmlFile.open( IO_WriteOnly ) ) return;
+
+ QTextStream ts( &opmlFile );
+ ts << domTree.toString();
+
+ opmlFile.close();
+}
+
+void Config::writeServiceMenu()
+{
+ int num;
+ QString content;
+ QFile file;
+
+ num = 0;
+ content = "";
+ content += "[Desktop Entry]\n";
+ content += "ServiceTypes=";
+
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) {
+// if( (*it).encoder != 0 && binaries[(*it).encoder->enc.bin] != "" && (*it).mime_types.first() != "application/octet-stream" ) {
+// if( !(*it).encoder->enc.lossy.enabled && !(*it).encoder->enc.lossless.enabled && !(*it).encoder->enc.hybrid.enabled ) continue;
+// for( QStringList::Iterator b = (*it).mime_types.begin(); b != (*it).mime_types.end(); ++b ) {
+// content += (*b) + ",";
+// num++;
+// }
+// }
+ if( (*it).decoder != 0 && binaries[(*it).decoder->dec.bin] != "" && (*it).mime_types.first() != "application/octet-stream" ) {
+ for( QStringList::Iterator b = (*it).mime_types.begin(); b != (*it).mime_types.end(); ++b ) {
+ content += (*b) + ",";
+ num++;
+ }
+ }
+ }
+
+ if( num != 0 )
+ {
+ content += "audio/x-wav";
+
+ content += "\n";
+ content += "Icon=soundkonverter\n";
+ content += "Actions=ConvertWithSoundkonverter\n\n";
+
+ content += "[Desktop Action ConvertWithSoundkonverter]\n";
+ content += "Name="+i18n("Convert with soundKonverter ...")+"\n";
+ content += "Icon=soundkonverter\n";
+ content += "Exec=soundkonverter %F\n";
+
+ file.setName( locateLocal("data","konqueror/servicemenus/")+"convert_with_soundkonverter.desktop" );
+ if ( file.open( IO_WriteOnly ) ) {
+ QTextStream stream( &file );
+ stream << content;
+ file.close();
+ }
+ }
+
+ num = 0;
+ content = "";
+ content += "[Desktop Entry]\n";
+ content += "ServiceTypes=";
+
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) {
+ if( (*it).replaygain != 0 && binaries[(*it).replaygain->replaygain.bin] != "" && (*it).mime_types.first() != "application/octet-stream" ) {
+ for( QStringList::Iterator b = (*it).mime_types.begin(); b != (*it).mime_types.end(); ++b ) {
+ content += (*b) + ",";
+ num++;
+ }
+ }
+ }
+
+ if( num != 0 )
+ {
+ content = content.left(content.length()-1);
+
+ content += "\n";
+ content += "Icon=soundkonverter_replaygain\n";
+ content += "Actions=AddReplayGainWithSoundkonverter\n\n";
+
+ content += "[Desktop Action AddReplayGainWithSoundkonverter]\n";
+ content += "Name="+i18n("Add Replay Gain with soundKonverter ...")+"\n";
+ content += "Icon=soundkonverter_replaygain\n";
+ content += "Exec=soundkonverter --replaygain %F\n";
+
+ file.setName( locateLocal("data","konqueror/servicemenus/")+"add_replaygain_with_soundkonverter.desktop" );
+ if( file.open(IO_WriteOnly) ) {
+ QTextStream st( &file );
+ st << content;
+ file.close();
+ }
+ }
+}
+
+void Config::writeAmarokScript()
+{
+ int num, num1, num2;
+ QString content, content1, content2;
+ QFile file;
+
+ num = 0;
+ content = "";
+ content += "name = soundKonverter\n";
+ content += "type = transcode\n\n";
+ content += "[Transcode]\n";
+ content += "target_formats = ";
+
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) {
+ if( (*it).encoder != 0 && binaries[(*it).encoder->enc.bin] != "" && (*it).mime_types.first() != "application/octet-stream" ) {
+ if( !(*it).encoder->enc.lossy.enabled && !(*it).encoder->enc.lossless.enabled && !(*it).encoder->enc.hybrid.enabled ) continue;
+ for( QStringList::Iterator b = (*it).extensions.begin(); b != (*it).extensions.end(); ++b ) {
+ if( content.find(" "+(*b).lower()+" ") == -1 ) content += (*b).lower() + " ";
+ num++;
+ }
+ }
+ }
+
+ if( num != 0 ) // TODO what is, if there are only decoders?
+ {
+ content += "wav";
+ content += "\n";
+
+ file.setName( locateLocal("data","amarok/scripts/soundKonverter/")+"soundKonverter.spec" );
+ if( file.open(IO_WriteOnly) ) {
+ QTextStream st( &file );
+ st << content;
+ file.close();
+ }
+ }
+
+ num1 = num2 = 0;
+ content = content1 = content2 = "";
+
+ // NOTE duplicate entries won't be shown to the user at any time, so they aren't filtered
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) {
+ if( (*it).encoder != 0 && binaries[(*it).encoder->enc.bin] != "" && (*it).mime_types.first() != "application/octet-stream" ) {
+ if( (*it).encoder->enc.lossless.enabled ) {
+ for( QStringList::Iterator b = (*it).extensions.begin(); b != (*it).extensions.end(); ++b ) {
+ if( content1.find(","+(*b).lower()+",") == -1 ) content1 += (*b).lower() + ","; // NOTE the first entry will be shown twice
+ num1++;
+ }
+ }
+ if( (*it).encoder->enc.hybrid.enabled ) {
+ for( QStringList::Iterator b = (*it).extensions.begin(); b != (*it).extensions.end(); ++b ) {
+ if( content2.find(","+(*b).lower()+",") == -1 ) content2 += (*b).lower() + ","; // NOTE the first entry will be shown twice
+ num2++;
+ }
+ }
+ }
+ }
+
+ if( num1 != 0 )
+ {
+ content1 = content1.left(content1.length()-1);
+ content += "Lossless";
+ content += "\n";
+ content += content1;
+ content += "\n";
+ }
+
+ if( num2 != 0 )
+ {
+ content2 = content2.left(content2.length()-1);
+ content += "Hybrid";
+ content += "\n";
+ content += content2;
+ content += "\n";
+ }
+
+ if( num1 != 0 || num2 != 0 )
+ {
+ file.setName( locateLocal("data","amarok/scripts/soundKonverter/")+"formats" );
+ if( file.open(IO_WriteOnly) ) {
+ QTextStream st( &file );
+ st << content;
+ file.close();
+ }
+ }
+
+ KStandardDirs* stdDirs = new KStandardDirs();
+ if( !QFile::exists(locateLocal("data","amarok/scripts/soundKonverter/soundKonverter.rb")) ) {
+ KIO::NetAccess::file_copy( stdDirs->findResource("data","soundkonverter/amarokscript/soundKonverter.rb"), locateLocal("data","amarok/scripts/soundKonverter/soundKonverter.rb"), 0755, true );
+ }
+ if( !QFile::exists(locateLocal("data","amarok/scripts/soundKonverter/README")) ) {
+ KIO::NetAccess::file_copy( stdDirs->findResource("data","soundkonverter/amarokscript/README"), locateLocal("data","amarok/scripts/soundKonverter/README"), -1, true );
+ }
+ delete stdDirs;
+}
+
+void Config::loadFileInfos()
+{}
+
+void Config::loadPlugins()
+{
+ // NOTE can be speeded up
+
+ //kdDebug() << "entering: `" << "Config::loadPlugins()" << "'" << endl;
+ logger->log( 1000, "entering: `Config::loadPlugins()'" );
+ QStringList list;
+ QDir dir;
+ QString correction_file_mime_type;
+
+ /** a map that holds the _identifier_ and the _version_ number of all plugins */
+ QMap pluginMap;
+
+ int version;
+ QString identifier;
+ int i;
+
+ ConvertPluginLoader* convertPluginLoader = new ConvertPluginLoader();
+ ReplayGainPluginLoader* replaygainPluginLoader = new ReplayGainPluginLoader();
+ RipperPluginLoader* ripperPluginLoader = new RipperPluginLoader();
+
+ KStandardDirs stddir;
+ QStringList directories = stddir.findDirs( "data", "soundkonverter/plugins/" );
+ for( QStringList::Iterator a = directories.begin(); a != directories.end(); ++a )
+ {
+ //kdDebug() << " searching directory: `" << *a << "'" << endl;
+ logger->log( 1000, " searching directory: `" + *a + "'" );
+ dir.setPath( *a );
+ list = dir.entryList( "*", QDir::All, QDir::Name );
+ for( QStringList::Iterator b = list.begin(); b != list.end(); ++b )
+ {
+ if( *b != "." && *b != ".." && (*b).right(19) == ".soundkonverter.xml" )
+ {
+ //kdDebug() << " found file: `" << *b << "'" << endl;
+ logger->log( 1000, " found file: `" + *b + "'" );
+ if( convertPluginLoader->verifyFile( QString(*a).append(*b) ) != -1 )
+ {
+ version = convertPluginLoader->verifyFile( QString(*a).append(*b) );
+ identifier = *b;
+ identifier.remove( identifier.length() - 19, 19 );
+ i = identifier.findRev( "-" );
+ identifier.remove( i, identifier.length() - i );
+// i = identifier.find( "." );
+// identifier.remove( 0, i + 1 );
+ if( !pluginMap.contains(identifier) ) {
+ PluginMapData data;
+ data.version = 0;
+ pluginMap.insert( identifier, data );
+ }
+ if( pluginMap[identifier].version < version )
+ {
+ pluginMap[identifier].version = version;
+ pluginMap[identifier].filename = QString(*a).append(*b);
+ pluginMap[identifier].type = "converter";
+ logger->log( 1000, " updating version for: `" + identifier + "'" );
+ }
+ }
+ else if( replaygainPluginLoader->verifyFile( QString(*a).append(*b) ) != -1 )
+ {
+ version = replaygainPluginLoader->verifyFile( QString(*a).append(*b) );
+ identifier = *b;
+ identifier.remove( identifier.length() - 19, 19 );
+ i = identifier.findRev( "-" );
+ identifier.remove( i, identifier.length() - i );
+// i = identifier.find( "." );
+// identifier.remove( 0, i + 1 );
+ if( !pluginMap.contains(identifier) ) {
+ PluginMapData data;
+ data.version = 0;
+ pluginMap.insert( identifier, data );
+ }
+ if( pluginMap[identifier].version < version )
+ {
+ pluginMap[identifier].version = version;
+ pluginMap[identifier].filename = QString(*a).append(*b);
+ pluginMap[identifier].type = "replaygain";
+ logger->log( 1000, " updating version for: `" + identifier + "'" );
+ }
+ }
+ else if( ripperPluginLoader->verifyFile( QString(*a).append(*b) ) != -1 )
+ {
+ version = ripperPluginLoader->verifyFile( QString(*a).append(*b) );
+ identifier = *b;
+ identifier.remove( identifier.length() - 19, 19 );
+ i = identifier.findRev( "-" );
+ identifier.remove( i, identifier.length() - i );
+// i = identifier.find( "." );
+// identifier.remove( 0, i + 1 );
+ if( !pluginMap.contains(identifier) ) {
+ PluginMapData data;
+ data.version = 0;
+ pluginMap.insert( identifier, data );
+ }
+ if( pluginMap[identifier].version < version )
+ {
+ pluginMap[identifier].version = version;
+ pluginMap[identifier].filename = QString(*a).append(*b);
+ pluginMap[identifier].type = "ripper";
+ logger->log( 1000, " updating version for: `" + identifier + "'" );
+ }
+ }
+ else
+ {
+ //kdDebug() << " file is invalid: `" << *b << "'" << endl;
+ logger->log( 1000, " file is invalid: `" + *b + "'" );
+ }
+ }
+ }
+ }
+
+ for( QMap::Iterator a = pluginMap.begin(); a != pluginMap.end(); ++a ) {
+ if( a.data().type == "converter" )
+ {
+ ConvertPlugin* plugin = convertPluginLoader->loadFile( a.data().filename );
+ if( plugin->info.version != -1 )
+ {
+ if( plugin->enc.hybrid.enabled )
+ {
+ correction_file_mime_type = plugin->enc.hybrid.correction_file_mime_type;
+ }
+ if( plugin->enc.enabled )
+ {
+ for( QStringList::Iterator b = plugin->enc.mime_types.begin(); b != plugin->enc.mime_types.end(); ++b )
+ {
+ //kdDebug() << " registering encoder for: `" << *b << "'" << endl;
+ logger->log( 1000, " registering encoder for: `" + *b + "'" );
+ registerFormatFeatures( *b, plugin, 0, 0, correction_file_mime_type );
+ }
+ }
+ if( plugin->dec.enabled )
+ {
+ for( QStringList::Iterator b = plugin->dec.mime_types.begin(); b != plugin->dec.mime_types.end(); ++b )
+ {
+ //kdDebug() << " registering decoder for: `" << *b << "'" << endl;
+ logger->log( 1000, " registering decoder for: `" + *b + "'" );
+ registerFormatFeatures( *b, 0, plugin, 0, correction_file_mime_type );
+ }
+ }
+ converters.append( plugin );
+ //kdDebug() << " plugin sucessfully loaded: `" << a.key() << "'" << endl;
+ logger->log( 1000, " plugin sucessfully loaded: `" + a.key() + "'" );
+ }
+ else
+ {
+ //kdError() << " failed to load Plugin: `" << a.key() << "'" << endl;
+ logger->log( 1000, " failed to load Plugin: `" + a.key() + "'" );
+ }
+ }
+ else if( a.data().type == "replaygain" )
+ {
+ ReplayGainPlugin* plugin = replaygainPluginLoader->loadFile( a.data().filename );
+ if( plugin->info.version != -1 )
+ {
+ for( QStringList::Iterator b = plugin->replaygain.mime_types.begin(); b != plugin->replaygain.mime_types.end(); ++b )
+ {
+ //kdDebug() << " registering replaygain for: `" << *b << "'" << endl;
+ logger->log( 1000, " registering replaygain for: `" + *b + "'" );
+ registerFormatFeatures( *b, 0, 0, plugin );
+ }
+ replaygains.append( plugin );
+ //kdDebug() << " plugin sucessfully loaded: `" << a.key() << "'" << endl;
+ logger->log( 1000, " plugin sucessfully loaded: `" + a.key() + "'" );
+ }
+ else
+ {
+ //kdError() << " failed to load Plugin: `" << a.key() << "'" << endl;
+ logger->log( 1000, " failed to load Plugin: `" + a.key() + "'" );
+ }
+ }
+ else if( a.data().type == "ripper" )
+ {
+ RipperPlugin* plugin = ripperPluginLoader->loadFile( a.data().filename );
+ if( plugin->info.version != -1 )
+ {
+ rippers.append( plugin );
+ //kdDebug() << " plugin sucessfully loaded: `" << a.key() << "'" << endl;
+ logger->log( 1000, " plugin sucessfully loaded: `" + a.key() + "'" );
+ }
+ else
+ {
+ //kdError() << " failed to load Plugin: `" << a.key() << "'" << endl;
+ logger->log( 1000, " failed to load Plugin: `" + a.key() + "'" );
+ }
+ }
+ }
+
+ delete convertPluginLoader;
+ delete replaygainPluginLoader;
+ delete ripperPluginLoader;
+
+ // NOTE in order to make a plugin working, there must be a format_infos file.
+
+ // TODO remove duplicate extensions
+
+ FormatInfoLoader* formatInfoLoader = new FormatInfoLoader();
+
+ //kdDebug() << " trying to open: `" << "soundkonverter/format_infos/"+language+"/" << "'" << endl;
+// logger->log( 1000, " trying to open: `soundkonverter/format_infos/" + language + "/'" );
+// directories = stddir.findDirs( "data", "soundkonverter/format_infos/"+language+"/" );
+// if( directories.isEmpty() ) directories = stddir.findDirs( "data", "soundkonverter/format_infos/en/" );
+ directories = stddir.findDirs( "data", "soundkonverter/format_infos/" );
+ for( QStringList::Iterator a = directories.begin(); a != directories.end(); ++a )
+ {
+ //kdDebug() << " searching directory: `" << *a << "'" << endl;
+ logger->log( 1000, " searching directory: `" + *a + "'" );
+ dir.setPath( *a );
+ list = dir.entryList( "*", QDir::All, QDir::Name );
+ for( QStringList::Iterator b = list.begin(); b != list.end(); ++b )
+ {
+ if( *b != "." && *b != ".." && (*b).right(4) == ".xml" )
+ {
+ //kdDebug() << " found file: `" << *b << "'" << endl;
+ logger->log( 1000, " found file: `" + *b + "'" );
+ if( formatInfoLoader->verifyFile( QString(*a).append(*b) ) )
+ {
+ FormatInfo* formatInfo = formatInfoLoader->loadFile( QString(*a).append(*b) );
+
+ for( QValueList::Iterator c = formats.begin(); c != formats.end(); ++c ) {
+ for( QStringList::Iterator d = formatInfo->mime_types.begin(); d != formatInfo->mime_types.end(); ++d ) {
+ if( (*c).mime_types.findIndex(*d) != -1 ) {
+ (*c).description = "" + formatInfo->description + "
";
+ (*c).description.replace("\\n","\n");
+ for( QStringList::Iterator d = formatInfo->urls.begin(); d != formatInfo->urls.end(); ++d ) {
+ (*c).description += "\n
" + (*d) + "
";
+ }
+ (*c).compressionType = formatInfo->compressionType;
+ (*c).size = formatInfo->size;
+ // add extensions for mime types
+ logger->log( 1000, " found mime type: `" + *d + "'" );
+ QStringList extensions = KMimeType::mimeType( *d )->patterns();
+ for( QStringList::Iterator c = extensions.begin(); c != extensions.end(); ++c ) {
+ (*c).remove( 0, 2 );
+ logger->log( 1000, " adding extension: `" + *c + "'" );
+ }
+ (*c).extensions += extensions;
+ // add extensions (from format file) HACK
+ extensions = formatInfo->extensions;
+ if( !extensions.isEmpty() ) {
+ logger->log( 1000, " found extensions..." );
+ for( QStringList::Iterator c = extensions.begin(); c != extensions.end(); ++c ) {
+ logger->log( 1000, " adding extension: `" + *c + "'" );
+ }
+ (*c).extensions += extensions;
+ }
+ // add extensions for correction file mime types
+ for( QStringList::Iterator d = (*c).correction_file_mime_types.begin(); d != (*c).correction_file_mime_types.end(); ++d ) {
+ logger->log( 1000, " found correction mime type: `" + *d + "'" );
+ QStringList extensions = KMimeType::mimeType( *d )->patterns();
+ for( QStringList::Iterator e = extensions.begin(); e != extensions.end(); ++e ) {
+ (*e).remove( 0, 2 );
+ logger->log( 1000, " adding correction extension: `" + *e + "'" );
+ (*c).correction_file_extensions += (*e);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ delete formatInfoLoader;
+}
+
+void Config::registerFormatFeatures( const QString &mime_type,
+ ConvertPlugin* encoder, ConvertPlugin* decoder,
+ ReplayGainPlugin* replaygain/*, RepairPlugin* repairer*/,
+ const QString &correction_file_mime_type )
+{
+ //kdDebug() << " entering: `" << "Config::registerFormatFeatures( ... )" << "'" << endl;
+ logger->log( 1000, " entering: `Config::registerFormatFeatures( ... )'" );
+
+ // iterate through all file formats and search for an existing one
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) {
+ if( (*it).mime_types.findIndex(mime_type) != -1 ) { // we found an existing entry for our file format
+ //kdDebug() << " found an existing entry: `" << mime_type << "'" << endl;
+ logger->log( 1000, " found an existing entry: `" + mime_type + "'" );
+
+ if( encoder != 0 ) (*it).encoders.append( encoder );
+// if( (*it).encoder == 0 && encoder != 0 ) (*it).encoder = encoder;
+// if( (*it).encoder != 0 && binaries[(*it).encoder.enc.bin] == "" )
+ if( decoder != 0 ) (*it).decoders.append( decoder );
+// if( (*it).decoder == 0 && decoder != 0 ) (*it).decoder = decoder;
+ if( replaygain != 0 ) (*it).replaygains.append( replaygain );
+// if( (*it).replaygain == 0 && replaygain != 0 ) (*it).replaygain = replaygain;
+ //if( repairer ) (*it).repairer.append( repairer );*/
+ if( !correction_file_mime_type.isEmpty() ) (*it).correction_file_mime_types.append( correction_file_mime_type );
+
+ // everything done, we can return!
+ return;
+ }
+ }
+ //kdDebug() << " creating a new entry: `" << mime_type << "'" << endl;
+ logger->log( 1000, " creating a new entry: `" + mime_type + "'" );
+
+ // well it seems, we haven't found an entry. create a new!
+ QValueList::Iterator newItem = formats.append( FormatItem() );
+ (*newItem).mime_types = mime_type;
+ if( encoder != 0 ) (*newItem).encoders.append( encoder );
+// if( encoder != 0 ) (*newItem).encoder = encoder;
+ if( decoder != 0 ) (*newItem).decoders.append( decoder );
+// if( decoder != 0 ) (*newItem).decoder = decoder;
+ if( replaygain != 0 ) (*newItem).replaygains.append( replaygain );
+// if( replaygain != 0 ) (*newItem).replaygain = replaygain;
+ //if( repairer ) (*newItem).repairer.append( repairer );
+ if( !correction_file_mime_type.isEmpty() ) (*newItem).correction_file_mime_types.append( correction_file_mime_type );
+
+}
+
+/*void Config::registerFileFormat( const QString &mime_type, const QString &option, const QString &value )
+{
+ // iterate through all file formats and search for an existing one
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) {
+ if( (*it).mime_types.findIndex(mime_type) != -1 ) { // we found an existing entry for our file format
+ if( option == "mime_type" ) (*it).mime_types.append( value );
+ //else if( option == "description" ) // TODO implement a qmap ?!
+ else if( option == "size" ) (*it).size = value.toInt();
+ else if( option == "compression_type" ) {
+ if( value == "lossy" ) (*it).compressionType = FormatInfo::lossy;
+ else if( value == "lossless" ) (*it).compressionType = FormatInfo::lossless;
+ else (*it).compressionType = FormatInfo::hybrid;
+ }
+
+ // everything done, we can return!
+ return;
+ }
+ }
+
+ // well it seems, we haven't found an entry. create a new!
+ QValueList::Iterator newItem = formats.append( FormatItem() );
+ if( option == "mime_type" ) (*newItem).mime_types.append( value );
+ //else if( option == "description" ) // TODO implement a qmap ?!
+ else if( option == "size" ) (*newItem).size = value.toInt();
+ else if( option == "compression_type" ) {
+ if( value == "lossy" ) (*newItem).compressionType = FormatInfo::lossy;
+ else if( value == "lossless" ) (*newItem).compressionType = FormatInfo::lossless;
+ else (*newItem).compressionType = FormatInfo::hybrid;
+ }
+}*/
+
+ConvertPlugin* Config::encoderForFormat( const QString &format )
+{
+ // iterate through all file formats and search for our format in mime_types and extensions
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) {
+ if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it
+ return (*it).encoder;
+ }
+ }
+
+ return 0;
+}
+
+ConvertPlugin* Config::decoderForFormat( const QString &format )
+{
+ // iterate through all file formats and search for our format in mime_types and extensions
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) {
+ if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it
+ return (*it).decoder;
+ }
+ }
+
+ return 0;
+}
+
+ReplayGainPlugin* Config::replaygainForFormat( const QString &format )
+{
+ // iterate through all file formats and search for our format in mime_types and extensions
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) {
+ if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it
+ return (*it).replaygain;
+ }
+ }
+
+ return 0;
+}
+
+FormatItem* Config::getFormatItem( const QString &format )
+{
+ // iterate through all file formats and search for our format in mime_types and extensions
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) {
+ if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it
+ return &(*it);
+ }
+ }
+
+ return 0;
+}
+
+// NOTE speed up the following 3 functions (cache the data) (use the extensions variable in FormatItem)
+// NOTE seems to be called too often ???
+QStringList Config::allFormats()
+{
+ QStringList list;
+
+ //kdDebug() << "entering: `" << "Config::allFormats()" << "'" << endl;
+ logger->log( 1000, "entering: `Config::allFormats()'" );
+
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) {
+ //kdDebug() << " mime type: `" << (*it).mime_types.first() << "'" << endl;
+ logger->log( 1000, " mime type: `" + (*it).mime_types.first() + "'" );
+ if( (*it).mime_types.first() != "application/octet-stream" ) {
+// QString extension = KMimeType::mimeType( (*it).mime_types.first() )->patterns().first().lower();
+// extension.remove( 0, 2 );
+ QString extension = (*it).extensions.first().lower();
+ //kdDebug() << " extension: `" << extension << "'" << endl;
+ logger->log( 1000, " extension: `" + extension + "'" );
+ if( !extension.isEmpty() && !list.contains(extension) ) {
+ list.append( extension );
+ //kdDebug() << " (added)" << endl;
+ logger->log( 1000, " (added)" );
+ }
+ }
+ }
+
+ return list;
+}
+
+QStringList Config::allEncodableFormats()
+{
+ QStringList list;
+
+ //kdDebug() << "entering: `" << "Config::allEncodableFormats()" << "'" << endl;
+ logger->log( 1000, "entering: `Config::allEncodableFormats()'" );
+
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) {
+ //kdDebug() << " mime type: `" << (*it).mime_types.first() << "'" << endl;
+ logger->log( 1000, " mime type: `" + (*it).mime_types.first() + "'" );
+ if( (*it).encoder != 0 && binaries[(*it).encoder->enc.bin] != "" && (*it).mime_types.first() != "application/octet-stream" ) {
+ if( !(*it).encoder->enc.lossy.enabled && !(*it).encoder->enc.lossless.enabled && !(*it).encoder->enc.hybrid.enabled ) continue;
+// QString extension = KMimeType::mimeType( (*it).mime_types.first() )->patterns().first().lower();
+// extension.remove( 0, 2 );
+ QString extension = (*it).extensions.first().lower();
+ //kdDebug() << " extension: `" << extension << "'" << endl;
+ logger->log( 1000, " extension: `" + extension + "'" );
+ if( !extension.isEmpty() && !list.contains(extension) ) {
+ list.append( extension );
+ //kdDebug() << " (added)" << endl;
+ logger->log( 1000, " (added)" );
+ }
+ }
+ }
+
+ return list;
+}
+
+QStringList Config::allLossyEncodableFormats()
+{
+ QStringList list;
+
+ //kdDebug() << "entering: `" << "Config::allLossyEncodableFormats()" << "'" << endl;
+// logger->log( 1000, "entering: `Config::allLossyEncodableFormats()'" );
+
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) {
+ //kdDebug() << " mime type: `" << (*it).mime_types.first() << "'" << endl;
+// logger->log( 1000, " mime type: `" + (*it).mime_types.first() + "'" );
+ if( (*it).encoder != 0 && binaries[(*it).encoder->enc.bin] != "" && (*it).encoder->enc.lossy.enabled && (*it).compressionType & FormatInfo::lossy && (*it).mime_types.first() != "application/octet-stream" ) {
+// QString extension = KMimeType::mimeType( (*it).mime_types.first() )->patterns().first().lower();
+// extension.remove( 0, 2 );
+ QString extension = (*it).extensions.first().lower();
+ //kdDebug() << " extension: `" << extension << "'" << endl;
+// logger->log( 1000, " extension: `" + extension + "'" );
+ if( !extension.isEmpty() && !list.contains(extension) ) {
+ list.append( extension );
+ //kdDebug() << " (added)" << endl;
+// logger->log( 1000, " (added)" );
+ }
+ }
+ }
+
+ return list;
+}
+
+QStringList Config::allLosslessEncodableFormats()
+{
+ QStringList list;
+
+ //kdDebug() << "entering: `" << "Config::allLosslessEncodableFormats()" << "'" << endl;
+ logger->log( 1000, "entering: `Config::allLosslessEncodableFormats()'" );
+
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) {
+ //kdDebug() << " mime type: `" << (*it).mime_types.first() << "'" << endl;
+ logger->log( 1000, " mime type: `" + (*it).mime_types.first() + "'" );
+ if( (*it).encoder != 0 && binaries[(*it).encoder->enc.bin] != "" && (*it).encoder->enc.lossless.enabled && (*it).compressionType & FormatInfo::lossless && (*it).mime_types.first() != "application/octet-stream" ) {
+// QString extension = KMimeType::mimeType( (*it).mime_types.first() )->patterns().first().lower();
+// extension.remove( 0, 2 );
+ QString extension = (*it).extensions.first().lower();
+ //kdDebug() << " extension: `" << extension << "'" << endl;
+ logger->log( 1000, " extension: `" + extension + "'" );
+ if( !extension.isEmpty() && !list.contains(extension) ) {
+ list.append( extension );
+ //kdDebug() << " (added)" << endl;
+ logger->log( 1000, " (added)" );
+ }
+ }
+ }
+
+ return list;
+}
+
+QStringList Config::allHybridEncodableFormats()
+{
+ QStringList list;
+
+ //kdDebug() << "entering: `" << "Config::allHybridEncodableFormats()" << "'" << endl;
+ logger->log( 1000, "entering: `Config::allHybridEncodableFormats()'" );
+
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) {
+ //kdDebug() << " mime type: `" << (*it).mime_types.first() << "'" << endl;
+ logger->log( 1000, " mime type: `" + (*it).mime_types.first() + "'" );
+ if( (*it).encoder != 0 && binaries[(*it).encoder->enc.bin] != "" && (*it).encoder->enc.hybrid.enabled && (*it).compressionType & FormatInfo::hybrid && (*it).mime_types.first() != "application/octet-stream" ) {
+// QString extension = KMimeType::mimeType( (*it).mime_types.first() )->patterns().first().lower();
+// extension.remove( 0, 2 );
+ QString extension = (*it).extensions.first().lower();
+ //kdDebug() << " extension: `" << extension << "'" << endl;
+ logger->log( 1000, " extension: `" + extension + "'" );
+ if( !extension.isEmpty() && !list.contains(extension) ) {
+ list.append( extension );
+ //kdDebug() << " (added)" << endl;
+ logger->log( 1000, " (added)" );
+ }
+ }
+ }
+
+ return list;
+}
+
+QString Config::getCorrectionExtension( const QString &format )
+{
+ // iterate through all file formats and search for our format
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) {
+ if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it
+ return (*it).correction_file_extensions.first();
+ }
+ }
+
+ return "";
+}
+
+QString Config::getFormatDescription( const QString &format ) // NOTE could be removed
+{
+ // iterate through all file formats and search for our format
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) {
+ if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it
+ return (*it).description;
+ }
+ }
+
+ return "";
+}
+
+void Config::addProfile( const QString &name, const ConversionOptions& profile )
+{
+ ProfileData profileData;
+ profileData.name = name;
+ profileData.options = profile;
+ profiles += profileData;
+ if( name != i18n("Last used") && name != "Last used" ) writeProfiles(); // will only be saved at app exit, when saving everything anyway
+ emit configChanged();
+}
+
+void Config::removeProfile( const QString &name )
+{
+ for( QValueList::Iterator it = profiles.begin(); it != profiles.end(); ++it ) {
+ if( (*it).name == name ) {
+ profiles.remove( it );
+ if( name != i18n("Last used") && name != "Last used" ) writeProfiles(); // will only be saved at app exit, when saving everything anyway
+ return;
+ }
+ }
+ emit configChanged();
+}
+
+ConversionOptions Config::getProfile( const QString &name )
+{
+ for( QValueList::Iterator it = profiles.begin(); it != profiles.end(); ++it ) {
+ if( /*(*it).name != i18n("Last used") &&*/ (*it).name == name ) {
+ return (*it).options;
+ }
+ }
+
+ ConversionOptions options;
+ options.encodingOptions.sFormat = "";
+ return options;
+}
+
+QString Config::getProfileName( const ConversionOptions& options )
+{
+ if( options.encodingOptions.sQualityMode == i18n("Lossless") ) {
+ return i18n("Lossless");
+ }
+
+ if( options.encodingOptions.sQualityMode == i18n("Hybrid") ) {
+ return i18n("Hybrid");
+ }
+
+ for( QValueList::Iterator it = profiles.begin(); it != profiles.end(); ++it ) {
+ if( (*it).name != i18n("Last used") && (*it).options.nearlyEqual( options ) ) {
+ return (*it).name;
+ }
+ }
+
+ ConvertPlugin* plugin = encoderForFormat( options.encodingOptions.sFormat );
+ if( plugin != 0 ) {
+ if( plugin->enc.lossy.quality.enabled ) {
+ if( options.encodingOptions.sQualityMode == i18n("Quality") && options.encodingOptions.iQuality == 20 &&
+ options.encodingOptions.bBitrateRange == false &&
+ options.encodingOptions.samplingRate.bEnabled == true && options.encodingOptions.samplingRate.iSamplingRate == 22050 &&
+ options.encodingOptions.channels.bEnabled == true && options.encodingOptions.channels.sChannels == i18n("Mono") &&
+ options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) {
+ return i18n("Very low");
+ }
+ if( options.encodingOptions.sQualityMode == i18n("Quality") && options.encodingOptions.iQuality == 30 &&
+ options.encodingOptions.bBitrateRange == false &&
+ options.encodingOptions.samplingRate.bEnabled == true && options.encodingOptions.samplingRate.iSamplingRate == 22050 &&
+ options.encodingOptions.channels.bEnabled == false &&
+ options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) {
+ return i18n("Low");
+ }
+ if( options.encodingOptions.sQualityMode == i18n("Quality") && options.encodingOptions.iQuality == 40 &&
+ options.encodingOptions.bBitrateRange == false &&
+ options.encodingOptions.samplingRate.bEnabled == false &&
+ options.encodingOptions.channels.bEnabled == false &&
+ options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) {
+ return i18n("Medium");
+ }
+ if( options.encodingOptions.sQualityMode == i18n("Quality") && options.encodingOptions.iQuality == 50 &&
+ options.encodingOptions.bBitrateRange == false &&
+ options.encodingOptions.samplingRate.bEnabled == false &&
+ options.encodingOptions.channels.bEnabled == false &&
+ options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) {
+ return i18n("High");
+ }
+ if( options.encodingOptions.sQualityMode == i18n("Quality") && options.encodingOptions.iQuality == 60 &&
+ options.encodingOptions.bBitrateRange == false &&
+ options.encodingOptions.samplingRate.bEnabled == false &&
+ options.encodingOptions.channels.bEnabled == false &&
+ options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) {
+ return i18n("Very high");
+ }
+ }
+ if( plugin->enc.lossy.bitrate.abr.enabled || plugin->enc.lossy.bitrate.cbr.enabled ) {
+ if( options.encodingOptions.sQualityMode == i18n("Bitrate") && options.encodingOptions.iQuality == 64 &&
+ options.encodingOptions.bBitrateRange == false &&
+ options.encodingOptions.samplingRate.bEnabled == true && options.encodingOptions.samplingRate.iSamplingRate == 22050 &&
+ options.encodingOptions.channels.bEnabled == true && options.encodingOptions.channels.sChannels == i18n("Mono") &&
+ options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) {
+ return i18n("Very low");
+ }
+ if( options.encodingOptions.sQualityMode == i18n("Bitrate") && options.encodingOptions.iQuality == 96 &&
+ options.encodingOptions.bBitrateRange == false &&
+ options.encodingOptions.samplingRate.bEnabled == true && options.encodingOptions.samplingRate.iSamplingRate == 22050 &&
+ options.encodingOptions.channels.bEnabled == false &&
+ options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) {
+ return i18n("Low");
+ }
+ if( options.encodingOptions.sQualityMode == i18n("Bitrate") && options.encodingOptions.iQuality == 192 &&
+ options.encodingOptions.bBitrateRange == false &&
+ options.encodingOptions.samplingRate.bEnabled == false &&
+ options.encodingOptions.channels.bEnabled == false &&
+ options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) {
+ return i18n("Medium");
+ }
+ if( options.encodingOptions.sQualityMode == i18n("Bitrate") && options.encodingOptions.iQuality == 240 &&
+ options.encodingOptions.bBitrateRange == false &&
+ options.encodingOptions.samplingRate.bEnabled == false &&
+ options.encodingOptions.channels.bEnabled == false &&
+ options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) {
+ return i18n("High");
+ }
+ if( options.encodingOptions.sQualityMode == i18n("Bitrate") && options.encodingOptions.iQuality == 320 &&
+ options.encodingOptions.bBitrateRange == false &&
+ options.encodingOptions.samplingRate.bEnabled == false &&
+ options.encodingOptions.channels.bEnabled == false &&
+ options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) {
+ return i18n("Very high");
+ }
+ }
+ /*{
+ if( options.encodingOptions.bBitrateRange == false &&
+ options.encodingOptions.samplingRate.bEnabled == true && options.encodingOptions.samplingRate.iSamplingRate == 22050 &&
+ options.encodingOptions.channels.bEnabled == true && options.encodingOptions.channels.sChannels == i18n("Mono") &&
+ options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) {
+ return i18n("Very low");
+ }
+ if( options.encodingOptions.bBitrateRange == false &&
+ options.encodingOptions.samplingRate.bEnabled == true && options.encodingOptions.samplingRate.iSamplingRate == 22050 &&
+ options.encodingOptions.channels.bEnabled == false &&
+ options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) {
+ return i18n("Low");
+ }
+ if( options.encodingOptions.bBitrateRange == false &&
+ options.encodingOptions.samplingRate.bEnabled == false &&
+ options.encodingOptions.channels.bEnabled == false &&
+ options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) {
+ return i18n("Medium");
+ }
+ if( options.encodingOptions.bBitrateRange == false &&
+ options.encodingOptions.samplingRate.bEnabled == false &&
+ options.encodingOptions.channels.bEnabled == false &&
+ options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) {
+ return i18n("High");
+ }
+ if( options.encodingOptions.bBitrateRange == false &&
+ options.encodingOptions.samplingRate.bEnabled == false &&
+ options.encodingOptions.channels.bEnabled == false &&
+ options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) {
+ return i18n("Very high");
+ }
+ }*/
+ }
+ return i18n("User defined");
+}
+
+QStringList Config::getAllProfiles()
+{
+ QStringList list;
+
+ for( QValueList::Iterator it = profiles.begin(); it != profiles.end(); ++it ) {
+ /*if( (*it).name != i18n("Last used") )*/ list += (*it).name;
+ }
+
+ return list;
+}
+
+bool Config::acceptFile( const QString& format )
+{
+ if( format == "audio/x-wav" || format == "wav" ) return true;
+
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) {
+ if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it
+ if( (*it).decoder != 0 ) return true;
+ }
+ }
+
+ return false;
+}
+
+bool Config::acceptReplayGainFile( const QString& format )
+{
+ for( QValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) {
+ if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it
+ if( (*it).replaygain != 0 ) return true;
+ }
+ }
+
+ return false;
+}
+
+QString Config::fileFilter( bool wav )
+{
+ QString filter1;
+ if( wav ) filter1 += "*.wav *.WAV *.Wav";
+ QString filter2;
+ if( wav ) filter2 += "\n*.wav *.WAV *.Wav|wav " + i18n("files") + " (*.wav)";
+ QString temp;
+
+ for( QValueList::Iterator a = formats.begin(); a != formats.end(); ++a ) {
+ if( (*a).decoder != 0 ) {
+ temp = "";
+ for( QStringList::Iterator b = (*a).extensions.begin(); b != (*a).extensions.end(); ++b ) {
+ filter1 += " *." + (*b);
+ if( !temp.contains(*b,false) ) temp += " *." + (*b).lower();
+ }
+ //temp.stripWhiteSpace(); // NOTE doesn't work
+ if( temp != "" && temp.length() < 80 ) {
+ temp.remove( 0, 1 );
+ temp = "\n" + temp + "|" + (*a).extensions.first() + " " + i18n("files") + " (" + temp + ")";
+ if( !filter2.contains(temp) ) { // HACK when unsing multiple mime types, there were too much entries
+ filter2 += temp;
+ }
+ }
+ else if( temp != "" ) {
+ temp.remove( 0, 1 );
+ temp = "\n" + temp + "|" + (*a).extensions.first() + " " + i18n("files");
+ if( !filter2.contains(temp) ) { // HACK when unsing multiple mime types, there were too much entries
+ filter2 += temp;
+ }
+ }
+ }
+ }
+
+ filter1.stripWhiteSpace();
+ filter2.stripWhiteSpace();
+
+ return filter1 + "|" + i18n("all supported formats") + "\n*.*|" + i18n("all formats") + filter2;
+}
+
+QStringList Config::fileTypes( bool wav )
+{
+ QStringList types;
+ if( wav ) types.append( "wav" );
+ QString temp;
+
+ for( QValueList::Iterator a = formats.begin(); a != formats.end(); ++a ) {
+ if( (*a).decoder != 0 ) {
+ temp = "";
+ for( QStringList::Iterator b = (*a).extensions.begin(); b != (*a).extensions.end(); ++b ) {
+ if( !temp.contains(*b,false) ) temp.append( (*b).lower() + ", " );
+ }
+ if( temp != "" ) {
+ temp = temp.left( temp.length() - 2 );
+ if( types.findIndex(temp) == -1 ) types.append( temp );
+ }
+ }
+ }
+
+ return types;
+}
+
+QString Config::replayGainFilter()
+{
+ QString filter1;
+ QString filter2;
+ QString temp;
+
+ for( QValueList::Iterator a = formats.begin(); a != formats.end(); ++a ) {
+ if( (*a).replaygain != 0 ) {
+ temp = "";
+ for( QStringList::Iterator b = (*a).extensions.begin(); b != (*a).extensions.end(); ++b ) {
+ filter1 += " *." + (*b);
+ if( !temp.contains(*b,false) ) temp += " *." + (*b).lower();
+ }
+ //temp.stripWhiteSpace(); // NOTE doesn't work
+ if( temp != "" && temp.length() < 80 ) {
+ temp.remove( 0, 1 );
+ filter2 += "\n" + temp + "|" + (*a).extensions.first() + " " + i18n("files") + " (" + temp + ")";
+ }
+ else if( temp != "" ) {
+ temp.remove( 0, 1 );
+ filter2 += "\n" + temp + "|" + (*a).extensions.first() + " " + i18n("files");
+ }
+ }
+ }
+
+ filter1.stripWhiteSpace();
+ filter2.stripWhiteSpace();
+
+ return filter1 + "|" + i18n("all supported formats") + "\n*.*|" + i18n("all formats") + filter2;
+}
+
+QStringList Config::replayGainFileTypes()
+{
+ QStringList types;
+ QString temp;
+
+ for( QValueList::Iterator a = formats.begin(); a != formats.end(); ++a ) {
+ if( (*a).replaygain != 0 ) {
+ temp = "";
+ for( QStringList::Iterator b = (*a).extensions.begin(); b != (*a).extensions.end(); ++b ) {
+ if( !temp.contains(*b,false) ) temp.append( (*b).lower() + ", " );
+ }
+ if( temp != "" ) {
+ temp = temp.left( temp.length() - 2 );
+ if( types.findIndex(temp) == -1 ) types.append( temp );
+ }
+ }
+ }
+
+ return types;
+}
+
+
diff --git a/src/config.h b/src/config.h
new file mode 100755
index 0000000..130ddf9
--- /dev/null
+++ b/src/config.h
@@ -0,0 +1,354 @@
+
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#include "formatinfoloader.h"
+#include "conversionoptions.h"
+
+#include
+#include
+#include
+#include
+
+class Logger;
+class ConvertPlugin;
+//class ConvertPluginLoader;
+class ReplayGainPlugin;
+//class ReplayGainPluginLoader;
+class RipperPlugin;
+struct ProfileData;
+
+
+/**
+ * @short Format items for the format list
+ * @author Daniel Faust
+ * @version 0.3
+ */
+class FormatItem
+{
+public:
+ /**
+ * Constructor
+ */
+ FormatItem();
+
+ /**
+ * Destructor
+ */
+ virtual ~FormatItem();
+
+ QStringList mime_types;
+ QStringList extensions; // for easy use
+ QStringList correction_file_mime_types;
+ QStringList correction_file_extensions; // for easy use
+ QString description;
+ FormatInfo::CompressionType compressionType;
+ int compressionLevel; // the value from the config dialog
+ bool internalReplayGain;
+ int size;
+ QValueList encoders;
+ QValueList decoders;
+ QValueList replaygains;
+ //QValueList repairers;
+ ConvertPlugin* encoder;
+ ConvertPlugin* decoder;
+ ReplayGainPlugin* replaygain;
+ //RepairerPlugin* repairer;
+};
+
+
+/**
+ * @short Configuration class
+ * @author Daniel Faust
+ * @version 0.3
+ */
+class Config : public QObject
+{
+ Q_OBJECT
+public:
+ /**
+ * Constructor
+ */
+ Config( Logger* );
+
+ /**
+ * Destructor
+ */
+ virtual ~Config();
+
+ /**
+ * Read the preferences from the configuration file
+ */
+ void read();
+
+ /**
+ * Write the preferences to the configuration file
+ */
+ void write( bool sync = true );
+
+ /**
+ * Read the profiles from the profiles file
+ */
+ void readProfiles();
+
+ /**
+ * Write the profiles to the profiles file
+ */
+ void writeProfiles();
+
+ /**
+ * Get the encoder for a given file format (mime type or extension)
+ */
+ ConvertPlugin* encoderForFormat( const QString &format );
+
+ /**
+ * Get the decoder for a given file format (mime type or extension)
+ */
+ ConvertPlugin* decoderForFormat( const QString &format );
+
+ /**
+ * Get the decoder for a given file format (mime type or extension)
+ */
+ ReplayGainPlugin* replaygainForFormat( const QString &format );
+
+ /**
+ * Get the format information for a given file format (mime type or extension)
+ */
+ FormatItem* getFormatItem( const QString &format );
+
+ /**
+ * Get the current ripper
+ */
+ RipperPlugin* getCurrentRipper() { return currentRipper; }
+
+ /**
+ * Set the current ripper
+ */
+ void setCurrentRipper( RipperPlugin* ripper ) { currentRipper = ripper; }
+
+ /**
+ * Returns a list of all loaded rippers
+ */
+ QValueList allRippers() { return rippers; }
+
+ /**
+ * Returns a list of all loaded converters
+ */
+ QValueList allConverters() { return converters; }
+
+ /**
+ * Returns a list of all loaded replaygains
+ */
+ QValueList allReplayGains() { return replaygains; }
+
+ /**
+ * Returns a list of all known file formats
+ */
+ QStringList allFormats();
+
+ /**
+ * Returns a list of all known encodeable file formats
+ */
+ QStringList allEncodableFormats();
+
+ /**
+ * Returns a list of all known lossy encodeable file formats
+ */
+ QStringList allLossyEncodableFormats();
+
+ /**
+ * Returns a list of all known lossless encodeable file formats
+ */
+ QStringList allLosslessEncodableFormats();
+
+ /**
+ * Returns a list of all known hybrid encodeable file formats
+ */
+ QStringList allHybridEncodableFormats();
+
+ /**
+ * Returns the extension of the correction file format for the given format
+ * If there is nor correction file format, the returned string is empty
+ */
+ QString getCorrectionExtension( const QString &format );
+
+ /**
+ * Returns a localized description for the given format
+ */
+ QString getFormatDescription( const QString &format );
+
+ /**
+ * Add a new profile
+ */
+ void addProfile( const QString &name, const ConversionOptions& profile );
+
+ /**
+ * Remove a new profile
+ */
+ void removeProfile( const QString &name );
+
+ /**
+ * Returns the conversion options for a profile
+ */
+ ConversionOptions getProfile( const QString &name );
+
+ /**
+ * Returns the name of the profile with conversion options @p options
+ */
+ QString getProfileName( const ConversionOptions& options );
+
+ /**
+ * Returns a list of all user defined profiles
+ */
+ QStringList getAllProfiles();
+
+ /**
+ * Returns true if the @p file can be added to the conversion list (can be decoded)
+ */
+ bool acceptFile( const QString& format );
+
+ /**
+ * Returns true if the @p file can be added to the replay gain tool
+ */
+ bool acceptReplayGainFile( const QString& format );
+
+ /**
+ * Returns a file filter suitable for the file open dialog
+ */
+ QString fileFilter( bool wav = true );
+
+ /**
+ * Returns a string list of supported file formats
+ */
+ QStringList fileTypes( bool wav = true );
+
+ /**
+ * Returns a file filter suitable for the file open dialog for the replay gain scanner
+ */
+ QString replayGainFilter();
+
+ /**
+ * Returns a string list of Replay Gain supported file formats
+ */
+ QStringList replayGainFileTypes();
+
+ struct Data {
+ struct General {
+ int startTab;
+ int lastTab;
+ QString defaultProfile;
+ QString defaultFormat;
+// QString defaultOutputDirectory;
+ QString specifyOutputDirectory;
+ QString metaDataOutputDirectory;
+ QString copyStructureOutputDirectory;
+ int priority;
+ bool useVFATNames;
+ int conflictHandling;
+ int numFiles;
+ int updateDelay;
+ bool askForNewOptions;
+ bool executeUserScript;
+ bool showToolBar;
+ } general;
+ struct Plugins {
+ bool checkForUpdates;
+ } plugins;
+ struct Environment {
+ QStringList directories;
+ QStringList foundPrograms;
+ } environment;
+ struct App {
+ int configVersion;
+ } app;
+ } data;
+
+ bool onlinePluginsChanged;
+ bool backendsChanged;
+
+ QMap binaries;
+
+private:
+ struct PluginMapData {
+ int version;
+ QString filename;
+ QString type;
+ };
+
+ Logger* logger;
+
+ /** holds all known formats */
+ QValueList formats;
+
+ /** holds all known rippers */
+ QValueList rippers;
+ RipperPlugin* currentRipper;
+
+ /** holds all known converters */
+ QValueList converters;
+ /** holds all known replaygain apps */
+ QValueList replaygains;
+ /* holds all known file repairing apps */
+// QValueList repairer;
+
+ //ConvertPluginLoader* convertPluginLoader;
+ //ReplayGainPluginLoader* replaygainPluginLoader;
+
+ /** holds all user defined profiles */
+ QValueList profiles;
+
+ /**
+ * Load the files with the file infos (format descriptions, file size, etc.)
+ */
+ void loadFileInfos();
+
+ /**
+ * Load all plugins that can be found
+ */
+ void loadPlugins();
+
+ /**
+ * A plugin wants to register it's features for a file format
+ * @p binary The binary name of the app that wants to register it's features
+ * @p extension The file name extension for that is wants to register
+ * @p features The features of the app for that extension
+ */
+ void registerFormatFeatures( const QString &mime_type,
+ ConvertPlugin* encoder = 0, ConvertPlugin* decoder = 0,
+ ReplayGainPlugin* replaygain = 0/*, RepairPlugin* repairer = 0*/,
+ const QString &correction_file_mime_type = QString::null );
+
+ /**
+ * Generate the service menu
+ */
+ void writeServiceMenu();
+
+ /**
+ * Copy the amarok script
+ */
+ void writeAmarokScript();
+
+ /*
+ * We have new inforamtion for a file format
+ * @p extension The file name extension for that is wants to register
+ * @p newSynonym Register a new synonym for this file format?
+ * @p newMimeType Register a new mime type for this file format?
+ * @p newDescription Register a new description for this file format?
+ * @p newSize Register a new size for this file format for calculating the progress?
+ */
+ /*void registerFileFormat( const QString &extension, const QString &newSynonym = QString::null,
+ const QString &newMimeType = QString::null,
+ const QString &newDescription = QString::null,
+ int newSize = 0, FormatInfo::CompressionType newCompressionType = FormatInfo::lossy );*/
+ //void registerFileFormat( const QString &mime_type, const QString &option, const QString &value );
+ // NOTE this function is obsolete.
+ // after loading all plugins and creating all neccessary file format items,
+ // sk will search for format info files and update the items.
+
+signals:
+ void configChanged();
+
+};
+
+#endif // CONFIG_H
diff --git a/src/configbackendspage.cpp b/src/configbackendspage.cpp
new file mode 100755
index 0000000..d7b1589
--- /dev/null
+++ b/src/configbackendspage.cpp
@@ -0,0 +1,493 @@
+
+#include "configbackendspage.h"
+#include "convertpluginloader.h"
+#include "replaygainpluginloader.h"
+#include "ripperpluginloader.h"
+#include "config.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+
+ConfigBackendsPage::ConfigBackendsPage( Config* _config, QMap* _binaries, QWidget* parent, const char *name )
+ : ConfigPageBase( parent, name )
+{
+ config = _config;
+ binaries = _binaries;
+
+ grid = new QGridLayout( parent );
+ scrollView = new KScrollView( parent, "scrollView" );
+ scrollView->setResizePolicy( QScrollView::AutoOneFit );
+ grid->addWidget( scrollView, 0, 0 );
+ box = new QVBox( scrollView->viewport() );
+ box->setMargin( 11 );
+ box->setSpacing( 6 );
+ scrollView->addChild( box );
+
+ QHBox* legendBox = new QHBox( box );
+ legendBox->setMargin( 0 );
+ legendBox->setSpacing( 6 );
+ KStandardDirs* stdDirs = new KStandardDirs();
+ QLabel* lLegendLabel = new QLabel( i18n("Legend")+":", legendBox, "lLegendLabel" );
+ QLabel* lLegendGreen = new QLabel( "", legendBox, "lLegendGreen" );
+ lLegendGreen->setPixmap( QPixmap(stdDirs->findResource("data","soundkonverter/pics/ledgreen_legend.png")) );
+ QLabel* lLegendFull = new QLabel( i18n("Full support"), legendBox, "lLegendFull" );
+ QLabel* lLegendYellow = new QLabel("",legendBox,"lLegendYellow");
+ lLegendYellow->setPixmap( QPixmap(stdDirs->findResource("data","soundkonverter/pics/ledyellow_legend.png")) );
+ QLabel* lLegendMost = new QLabel( i18n("Most supported"), legendBox, "lLegendMost" );
+ QLabel* lLegendRed = new QLabel( "", legendBox, "lLegendRed" );
+ lLegendRed->setPixmap( QPixmap(stdDirs->findResource("data","soundkonverter/pics/ledred_legend.png")) );
+ QLabel* lLegendBasic = new QLabel( i18n("Basic support"), legendBox, "lLegendBasic" );
+ legendBox->setStretchFactor( lLegendLabel, 1 );
+
+ QGroupBox* ripperGroup = new QGroupBox( 1, Qt::Vertical, box, "ripperGroup" );
+ ripperGroup->layout()->setSpacing( 6 );
+ ripperGroup->layout()->setMargin( 6 );
+ QLabel* lRipper = new QLabel( i18n("CD Ripper")+":", ripperGroup, "lRipper" );
+ cRipper = new KComboBox( ripperGroup, "cRipper" );
+ connect( cRipper, SIGNAL(activated(int)),
+ this, SLOT(cfgChanged())
+ );
+
+ delete stdDirs;
+
+ rebuild();
+}
+
+ConfigBackendsPage::~ConfigBackendsPage()
+{}
+
+void ConfigBackendsPage::resetDefaults()
+{
+ int i;
+ int item;
+ int rank;
+
+ i = 1;
+ rank = 60;
+ item = 0;
+ QValueList rippers = config->allRippers();
+ for( QValueList::Iterator it = rippers.begin(); it != rippers.end(); ++it )
+ {
+ if( (*it)->rip.rank > rank ) {
+ rank = (*it)->rip.rank;
+ item = i;
+ }
+ i++;
+ }
+ cRipper->setCurrentItem( item );
+
+ for( QValueList::Iterator a = formatOptions.begin(); a != formatOptions.end(); ++a )
+ {
+ FormatItem* formatItem = config->getFormatItem( (*a).format );
+ if( formatItem == 0 ) continue;
+
+ i = item = rank = 0;
+ for( QValueList::Iterator b = formatItem->encoders.begin(); b != formatItem->encoders.end(); ++b ) {
+ if( (*b)->enc.rank > rank ) {
+ rank = (*b)->enc.rank;
+ item = i;
+ }
+ i++;
+ }
+ (*a).cEncoder->setCurrentItem( item );
+
+ i = item = rank = 0;
+ for( QValueList::Iterator b = formatItem->decoders.begin(); b != formatItem->decoders.end(); ++b ) {
+ if( (*b)->dec.rank > rank ) {
+ rank = (*b)->dec.rank;
+ item = i;
+ }
+ i++;
+ }
+ (*a).cDecoder->setCurrentItem( item );
+
+ i = item = rank = 0;
+ for( QValueList::Iterator b = formatItem->replaygains.begin(); b != formatItem->replaygains.end(); ++b ) {
+ if( (*b)->replaygain.rank > rank ) {
+ rank = (*b)->replaygain.rank;
+ item = i;
+ }
+ i++;
+ }
+ (*a).cReplayGain->setCurrentItem( item );
+ }
+
+ encoderChanged();
+
+ for( QValueList::Iterator a = formatOptions.begin(); a != formatOptions.end(); ++a )
+ {
+ FormatItem* formatItem = config->getFormatItem( (*a).format );
+ if( formatItem == 0 ) continue;
+
+ QString encoder = (*a).cEncoder->currentText();
+
+ (*a).cInternalReplayGain->setChecked( false );
+
+ for( QValueList::Iterator b = formatItem->encoders.begin(); b != formatItem->encoders.end(); ++b ) {
+ if( (*b)->enc.bin == encoder && (*b)->enc.strength.enabled ) {
+ if( (*b)->enc.strength.range_max >= (*b)->enc.strength.range_min )
+ (*a).sStrength->setValue( (*b)->enc.strength.default_value / (*b)->enc.strength.step );
+ else
+ (*a).sStrength->setValue( ( (*b)->enc.strength.range_min - (*b)->enc.strength.default_value ) / (*b)->enc.strength.step );
+ }
+ if( (*b)->enc.bin == encoder && (*b)->enc.replaygain.enabled ) {
+ if( formatItem->replaygain != 0 && formatItem->replaygain->replaygain.rank > (*b)->enc.replaygain.rank ) {
+ (*a).cInternalReplayGain->setChecked( false );
+ }
+ else {
+ (*a).cInternalReplayGain->setChecked( true );
+ }
+ }
+ }
+ }
+
+ strengthChanged();
+ cfgChanged();
+}
+
+void ConfigBackendsPage::saveSettings()
+{
+ config->setCurrentRipper( 0 );
+ QValueList rippers = config->allRippers();
+ for( QValueList::Iterator it = rippers.begin(); it != rippers.end(); ++it )
+ {
+ if( (*it)->rip.bin == cRipper->currentText() ) {
+ config->setCurrentRipper( *it );
+ }
+ }
+
+ for( QValueList::Iterator a = formatOptions.begin(); a != formatOptions.end(); ++a )
+ {
+ FormatItem* formatItem = config->getFormatItem( (*a).format );
+ if( formatItem == 0 ) continue;
+
+ for( QValueList::Iterator b = formatItem->encoders.begin(); b != formatItem->encoders.end(); ++b ) {
+ if( (*b)->enc.bin == (*a).cEncoder->currentText() ) {
+ formatItem->encoder = (*b);
+ if( (*b)->enc.strength.enabled ) {
+ formatItem->compressionLevel = (*a).sStrength->value();
+ }
+ if( (*b)->enc.replaygain.enabled ) {
+ formatItem->internalReplayGain = (*a).cInternalReplayGain->isChecked();
+ }
+ }
+ }
+
+ for( QValueList::Iterator b = formatItem->decoders.begin(); b != formatItem->decoders.end(); ++b ) {
+ if( (*b)->dec.bin == (*a).cDecoder->currentText() ) {
+ formatItem->decoder = (*b);
+ }
+ }
+
+ for( QValueList::Iterator b = formatItem->replaygains.begin(); b != formatItem->replaygains.end(); ++b ) {
+ if( (*b)->replaygain.bin == (*a).cReplayGain->currentText() ) {
+ formatItem->replaygain = (*b);
+ }
+ }
+ }
+}
+
+void ConfigBackendsPage::rebuild()
+{
+ for( QValueList::Iterator it = formatOptions.begin(); it != formatOptions.end(); ++it )
+ {
+ delete (*it).lEncoder;
+ disconnect( (*it).cEncoder, SIGNAL(activated(int)), 0, 0 );
+ delete (*it).cEncoder;
+ delete (*it).lStrength;
+ disconnect( (*it).sStrength,SIGNAL(valueChanged(int)), 0, 0 );
+ delete (*it).sStrength;
+ delete (*it).lStrengthDisplay;
+ delete (*it).lDecoder;
+ disconnect( (*it).cDecoder, SIGNAL(activated(int)), 0, 0 );
+ delete (*it).cDecoder;
+ delete (*it).lReplayGain;
+ disconnect( (*it).cReplayGain, SIGNAL(activated(int)), 0, 0 );
+ delete (*it).cReplayGain;
+ disconnect( (*it).cInternalReplayGain, SIGNAL(toggled(bool)), 0, 0 );
+ delete (*it).cInternalReplayGain;
+ delete (*it).grid;
+ delete (*it).group;
+ }
+
+ formatOptions.clear();
+
+ // TODO show all extensions
+
+ QStringList formats = config->allFormats();
+
+ for( QStringList::Iterator it = formats.begin(); it != formats.end(); ++it )
+ {
+ FormatOptions options;
+ options.format = *it;
+
+ FormatItem *formatItem = config->getFormatItem( options.format );
+ QString title;
+ if( formatItem ) {
+ for( QStringList::Iterator at = formatItem->extensions.begin(); at != formatItem->extensions.end(); ++at ) {
+ if( !title.contains((*at).lower()) ) title += (*at).lower() + ", ";
+ }
+ title = title.left( title.length() - 2 );
+/* title += " [";
+ for( QStringList::Iterator bt = formatItem->mime_types.begin(); bt != formatItem->mime_types.end(); ++bt ) {
+ if( !title.contains((*bt).lower()) ) title += (*bt).lower() + ", ";
+ }
+ title = title.left( title.length() - 2 ) + "]";*/
+ }
+ else {
+ title = options.format;
+ }
+
+ options.group = new QGroupBox( title, box, options.format );
+ options.group->setColumnLayout( 0, Qt::Vertical );
+ options.group->layout()->setSpacing( 6 );
+ options.group->layout()->setMargin( 6 );
+ options.group->show();
+ options.grid = new QGridLayout( options.group->layout() );
+
+ options.lEncoder = new QLabel( i18n("Encoder")+":", options.group, options.format );
+ options.lEncoder->show();
+ options.grid->addWidget( options.lEncoder, 0, 0 );
+ options.cEncoder = new KComboBox( options.group, options.format );
+ options.cEncoder->show();
+ connect( options.cEncoder, SIGNAL(activated(int)),
+ this, SLOT(cfgChanged())
+ );
+ connect( options.cEncoder, SIGNAL(activated(int)),
+ this, SLOT(encoderChanged())
+ );
+ options.grid->addWidget( options.cEncoder, 0, 1 );
+
+ options.lStrength = new QLabel( i18n("Strength")+":", options.group, options.format );
+ options.lStrength->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
+ options.lStrength->show();
+ options.grid->addWidget( options.lStrength, 0, 2 );
+ options.sStrength = new QSlider( Qt::Horizontal, options.group, options.format );
+ options.sStrength->setTickmarks( QSlider::Below );
+ options.sStrength->show();
+ QToolTip::add( options.sStrength, i18n("Set the compression strength:\n\nLeft = fast conversion\nRight = good resultant file") );
+ options.grid->addWidget( options.sStrength, 0, 3 );
+ connect( options.sStrength, SIGNAL(valueChanged(int)),
+ this, SLOT(cfgChanged())
+ );
+ connect( options.sStrength, SIGNAL(valueChanged(int)),
+ this, SLOT(strengthChanged())
+ );
+
+ options.lDecoder = new QLabel( i18n("Decoder")+":", options.group, options.format );
+ options.lDecoder->show();
+ options.grid->addWidget( options.lDecoder, 1, 0 );
+ options.cDecoder = new KComboBox( options.group, options.format );
+ options.cDecoder->show();
+ options.grid->addWidget( options.cDecoder, 1, 1 );
+ connect( options.cDecoder, SIGNAL(activated(int)),
+ this, SLOT(cfgChanged())
+ );
+ options.lStrengthDisplay = new QLabel( "", options.group, options.format );
+ options.lStrengthDisplay->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
+ options.lStrengthDisplay->setEnabled( false );
+ options.grid->addWidget( options.lStrengthDisplay, 1, 3 );
+
+ options.lReplayGain = new QLabel( i18n("Replay Gain")+":", options.group, options.format );
+ options.lReplayGain->show();
+ options.grid->addWidget( options.lReplayGain, 2, 0 );
+ options.cReplayGain = new KComboBox( options.group, options.format );
+ options.cReplayGain->show();
+ options.grid->addWidget( options.cReplayGain, 2, 1 );
+ connect( options.cReplayGain, SIGNAL(activated(int)),
+ this, SLOT(cfgChanged())
+ );
+ options.cInternalReplayGain = new QCheckBox( i18n("Use internal Replay Gain"), options.group, options.format );
+ QToolTip::add( options.cInternalReplayGain, i18n("Use the internal Replay Gain calculator of the encoder") );
+ options.grid->addWidget( options.cInternalReplayGain, 2, 3 );
+ connect( options.cInternalReplayGain, SIGNAL(toggled(bool)),
+ this, SLOT(cfgChanged())
+ );
+
+ options.grid->setColStretch( 0, 0 );
+ options.grid->setColStretch( 1, 1 );
+ options.grid->setColStretch( 2, 1 );
+ options.grid->setColStretch( 3, 1 );
+
+ formatOptions.append( options );
+ }
+
+ refill();
+}
+
+void ConfigBackendsPage::refill()
+{
+ KStandardDirs* stdDirs = new KStandardDirs();
+ int i, item;
+
+ cRipper->clear();
+ i = item = 0;
+ cRipper->insertItem( QPixmap(stdDirs->findResource("data","soundkonverter/pics/ledyellow.png")), i18n("KDE audio CD protocol") );
+ i++;
+ QValueList rippers = config->allRippers();
+ for( QValueList::Iterator it = rippers.begin(); it != rippers.end(); ++it )
+ {
+ if( (*binaries)[(*it)->rip.bin] == "" ) continue;
+
+ if( (*it)->rip.rank >= 70 ) cRipper->insertItem( QPixmap(stdDirs->findResource("data","soundkonverter/pics/ledgreen.png")), (*it)->rip.bin );
+ else if( (*it)->rip.rank >= 40 ) cRipper->insertItem( QPixmap(stdDirs->findResource("data","soundkonverter/pics/ledyellow.png")), (*it)->rip.bin );
+ else cRipper->insertItem( QPixmap(stdDirs->findResource("data","soundkonverter/pics/ledred.png")), (*it)->rip.bin );
+ if( (*it) == config->getCurrentRipper() ) item = i;
+ i++;
+ }
+ cRipper->setCurrentItem( item );
+
+ for( QValueList::Iterator a = formatOptions.begin(); a != formatOptions.end(); ++a )
+ {
+ FormatItem* formatItem = config->getFormatItem( (*a).format );
+ (*a).cEncoder->clear();
+ (*a).cDecoder->clear();
+ (*a).cReplayGain->clear();
+ if( formatItem == 0 ) continue;
+
+ i = item = 0;
+ for( QValueList::Iterator b = formatItem->encoders.begin(); b != formatItem->encoders.end(); ++b ) {
+ if( (*binaries)[(*b)->enc.bin] == "" ) continue;
+
+ if( (*b)->enc.rank >= 70 ) (*a).cEncoder->insertItem( QPixmap(stdDirs->findResource("data","soundkonverter/pics/ledgreen.png")), (*b)->enc.bin );
+ else if( (*b)->enc.rank >= 40 ) (*a).cEncoder->insertItem( QPixmap(stdDirs->findResource("data","soundkonverter/pics/ledyellow.png")), (*b)->enc.bin );
+ else (*a).cEncoder->insertItem( QPixmap(stdDirs->findResource("data","soundkonverter/pics/ledred.png")), (*b)->enc.bin );
+ if( (*b) == formatItem->encoder ) item = i;
+ i++;
+ }
+ (*a).cEncoder->setCurrentItem( item );
+
+ i = item = 0;
+ for( QValueList::Iterator b = formatItem->decoders.begin(); b != formatItem->decoders.end(); ++b ) {
+ if( (*binaries)[(*b)->dec.bin] == "" ) continue;
+
+ if( (*b)->dec.rank >= 70 ) (*a).cDecoder->insertItem( QPixmap(stdDirs->findResource("data","soundkonverter/pics/ledgreen.png")), (*b)->dec.bin );
+ else if( (*b)->dec.rank >= 40 ) (*a).cDecoder->insertItem( QPixmap(stdDirs->findResource("data","soundkonverter/pics/ledyellow.png")), (*b)->dec.bin );
+ else (*a).cDecoder->insertItem( QPixmap(stdDirs->findResource("data","soundkonverter/pics/ledred.png")), (*b)->dec.bin );
+ if( (*b) == formatItem->decoder ) item = i;
+ i++;
+ }
+ (*a).cDecoder->setCurrentItem( item );
+
+ i = item = 0;
+ for( QValueList::Iterator b = formatItem->replaygains.begin(); b != formatItem->replaygains.end(); ++b ) {
+ if( (*binaries)[(*b)->replaygain.bin] == "" ) continue;
+
+ if( (*b)->replaygain.rank >= 70 ) (*a).cReplayGain->insertItem( QPixmap(stdDirs->findResource("data","soundkonverter/pics/ledgreen.png")), (*b)->replaygain.bin );
+ else if( (*b)->replaygain.rank >= 40 ) (*a).cReplayGain->insertItem( QPixmap(stdDirs->findResource("data","soundkonverter/pics/ledyellow.png")), (*b)->replaygain.bin );
+ else (*a).cReplayGain->insertItem( QPixmap(stdDirs->findResource("data","soundkonverter/pics/ledred.png")), (*b)->replaygain.bin );
+ if( (*b) == formatItem->replaygain ) item = i;
+ i++;
+ }
+ (*a).cReplayGain->setCurrentItem( item );
+ }
+
+ delete stdDirs;
+
+ encoderChanged();
+}
+
+void ConfigBackendsPage::encoderChanged()
+{
+ bool recalc;
+
+ for( QValueList::Iterator a = formatOptions.begin(); a != formatOptions.end(); ++a )
+ {
+ FormatItem* formatItem = config->getFormatItem( (*a).format );
+ (*a).lStrength->hide();
+ (*a).sStrength->hide();
+ (*a).lStrengthDisplay->hide();
+ (*a).cInternalReplayGain->hide();
+ if( formatItem == 0 ) continue;
+
+ QString encoder = (*a).cEncoder->currentText();
+
+ for( QValueList::Iterator b = formatItem->encoders.begin(); b != formatItem->encoders.end(); ++b ) {
+ if( QObject::sender() && (*a).format == QObject::sender()->name() ) recalc = true;
+ else if( !QObject::sender() ) recalc = true;
+ else recalc = false;
+ if( (*b)->enc.bin == encoder && (*b)->enc.strength.enabled ) {
+ (*a).lStrength->show();
+ if( (*b)->enc.strength.range_max >= (*b)->enc.strength.range_min ) {
+ (*a).sStrength->setMinValue( (int)((*b)->enc.strength.range_min/(*b)->enc.strength.step) );
+ (*a).sStrength->setMaxValue( (int)((*b)->enc.strength.range_max/(*b)->enc.strength.step) );
+ }
+ else {
+ (*a).sStrength->setMinValue( (int)((*b)->enc.strength.range_max/(*b)->enc.strength.step) );
+ (*a).sStrength->setMaxValue( (int)((*b)->enc.strength.range_min/(*b)->enc.strength.step) );
+ }
+ (*a).sStrength->setPageStep( 1 );
+ if( QObject::sender() && (*a).format == QObject::sender()->name() ) {
+ if( (*b)->enc.strength.range_max >= (*b)->enc.strength.range_min )
+ (*a).sStrength->setValue( (*b)->enc.strength.default_value / (*b)->enc.strength.step );
+ else
+ (*a).sStrength->setValue( ( (*b)->enc.strength.range_min - (*b)->enc.strength.default_value ) / (*b)->enc.strength.step );
+ }
+ else if( !QObject::sender() ) {
+ (*a).sStrength->setValue( formatItem->compressionLevel );
+ }
+ (*a).sStrength->show();
+ (*a).lStrengthDisplay->show();
+ }
+ if( (*b)->enc.bin == encoder && (*b)->enc.replaygain.enabled ) {
+ (*a).cInternalReplayGain->show();
+ if( recalc ) (*a).cInternalReplayGain->setChecked( formatItem->internalReplayGain );
+ }
+ }
+ }
+
+ strengthChanged();
+}
+
+void ConfigBackendsPage::strengthChanged()
+{
+ for( QValueList::Iterator a = formatOptions.begin(); a != formatOptions.end(); ++a )
+ {
+ FormatItem* formatItem = config->getFormatItem( (*a).format );
+ if( formatItem == 0 ) continue;
+
+ QString encoder = (*a).cEncoder->currentText();
+
+ for( QValueList::Iterator b = formatItem->encoders.begin(); b != formatItem->encoders.end(); ++b ) {
+ if( (*b)->enc.bin == encoder && (*b)->enc.strength.enabled ) {
+ QString strength = (*b)->enc.strength.param;
+ int compressionLevel = (*a).sStrength->value();
+ if( (*b)->enc.strength.profiles.empty() ) {
+ if( (*b)->enc.strength.step < 1 ) {
+ if( (*b)->enc.strength.range_max >= (*b)->enc.strength.range_min )
+ strength.replace( "%c", QString::number( compressionLevel * (*b)->enc.strength.step ) );
+ else
+ strength.replace( "%c", QString::number( (*b)->enc.strength.range_min - compressionLevel * (*b)->enc.strength.step ) );
+ }
+ else {
+ if( (*b)->enc.strength.range_max >= (*b)->enc.strength.range_min )
+ strength.replace( "%c", QString::number( (int)(compressionLevel * (*b)->enc.strength.step) ) );
+ else
+ strength.replace( "%c", QString::number( (int)((*b)->enc.strength.range_min - compressionLevel * (*b)->enc.strength.step) ) );
+ }
+ if( (*b)->enc.strength.separator != '.' ) strength.replace( QChar('.'), (*b)->enc.strength.separator );
+ }
+ else {
+ QStringList::Iterator it = (*b)->enc.strength.profiles.at( (int)compressionLevel );
+ strength.replace( "%c", *it );
+ }
+ (*a).lStrengthDisplay->setText( "( \"" + strength + "\" )" );
+ }
+ }
+ }
+}
+
+
+
diff --git a/src/configbackendspage.h b/src/configbackendspage.h
new file mode 100755
index 0000000..27071f2
--- /dev/null
+++ b/src/configbackendspage.h
@@ -0,0 +1,81 @@
+
+
+#ifndef CONFIGBACKENDSPAGE_H
+#define CONFIGBACKENDSPAGE_H
+
+#include
+
+#include
+
+class Config;
+class KComboBox;
+class KScrollView;
+class QGroupBox;
+class QGridLayout;
+class QLabel;
+class QSlider;
+class QCheckBox;
+class QVBox;
+
+/**
+* @short The page for configuring the environment
+ * @author Daniel Faust
+ * @version 0.3
+ */
+class ConfigBackendsPage : public ConfigPageBase
+{
+ Q_OBJECT
+public:
+ /**
+ * Default Constructor
+ */
+ ConfigBackendsPage( Config*, QMap*, QWidget *parent=0, const char *name=0 );
+
+ /**
+ * Default Destructor
+ */
+ virtual ~ConfigBackendsPage();
+
+private:
+ struct FormatOptions
+ {
+ // TODO remove the string lists
+ QString format;
+ QGroupBox* group;
+ QGridLayout* grid;
+ QLabel* lEncoder;
+ KComboBox* cEncoder;
+ QLabel* lStrength;
+ QSlider* sStrength;
+ QLabel* lStrengthDisplay;
+ QLabel* lDecoder;
+ KComboBox* cDecoder;
+ QLabel* lReplayGain;
+ KComboBox* cReplayGain;
+ QCheckBox* cInternalReplayGain;
+ };
+
+ QValueList formatOptions;
+
+ QGridLayout* grid;
+ KScrollView* scrollView;
+ QVBox* box;
+
+ KComboBox* cRipper;
+
+ Config* config;
+
+ QMap* binaries;
+
+public slots:
+ void resetDefaults();
+ void saveSettings();
+ void rebuild();
+ void refill();
+ void encoderChanged();
+ void strengthChanged();
+
+};
+
+#endif // CONFIGBACKENDSPAGE_H
+
diff --git a/src/configdialog.cpp b/src/configdialog.cpp
new file mode 100755
index 0000000..3e58007
--- /dev/null
+++ b/src/configdialog.cpp
@@ -0,0 +1,174 @@
+
+
+#include "configdialog.h"
+
+#include "config.h"
+#include "configgeneralpage.h"
+#include "configpluginspage.h"
+#include "configenvironmentpage.h"
+#include "configbackendspage.h"
+
+/*#include "config_dialogue_interface.h"
+#include "config_dialogue_backend_plugins.h"
+#include "config_dialogue_backends.h"
+#include "config_dialogue_en_decoder.h"
+#include "config_dialogue_en_decoder_options.h"
+
+#include "tools.h"
+#include "backend_plugins.h"
+#include "replaygain_plugins.h"
+
+#include
+*/
+//#include
+#include
+#include
+#include
+
+ConfigDialog::ConfigDialog( Config* _config, QWidget *parent, const char *name, Page startPage )
+ : KDialogBase(
+ IconList,
+ i18n("Settings"),
+ Apply | Cancel | Default | Help | Ok,
+ Ok, // default button
+ parent,
+ name,
+ true, // modal
+ true // separator
+ )
+{
+ config = _config;
+
+ //resize( 600, 400 );
+
+ binaries = config->binaries;
+
+ connect( this, SIGNAL(applyClicked()),
+ this,SLOT(applyClickedSlot())
+ );
+ connect( this, SIGNAL(okClicked()),
+ this,SLOT(okClickedSlot())
+ );
+ connect( this, SIGNAL(defaultClicked()),
+ this,SLOT(defaultClickedSlot())
+ );
+
+ generalPage = addPage( i18n("General"), "misc" );
+ configGeneralPage = new ConfigGeneralPage( config, generalPage, "configGeneralPage" );
+ connect( configGeneralPage, SIGNAL(configChanged()),
+ this, SLOT(configChanged())
+ );
+ connect( this, SIGNAL(saveGeneral()),
+ configGeneralPage, SLOT(saveSettings())
+ );
+ connect( this, SIGNAL(resetGeneral()),
+ configGeneralPage, SLOT(resetDefaults())
+ );
+
+ pluginsPage = addPage( i18n("Plugins"), "connect_creating" );
+ configPluginsPage = new ConfigPluginsPage( config, pluginsPage, "configPluginsPage" );
+ connect( configPluginsPage, SIGNAL(configChanged()),
+ this, SLOT(configChanged())
+ );
+ connect( this, SIGNAL(savePlugins()),
+ configPluginsPage, SLOT(saveSettings())
+ );
+ connect( this, SIGNAL(resetPlugins()),
+ configPluginsPage, SLOT(resetDefaults())
+ );
+
+ environmentPage = addPage( i18n("Environment"), "filefind" );
+ configEnvironmentPage = new ConfigEnvironmentPage( config, &binaries, environmentPage, "configEnvironmentPage" );
+ connect( configEnvironmentPage, SIGNAL(configChanged()),
+ this, SLOT(configChanged())
+ );
+ connect( this, SIGNAL(saveEnvironment()),
+ configEnvironmentPage, SLOT(saveSettings())
+ );
+ connect( this, SIGNAL(resetEnvironment()),
+ configEnvironmentPage, SLOT(resetDefaults())
+ );
+
+ backendsPage = addPage( i18n("Backends"), "kcmsystem" );
+ configBackendsPage = new ConfigBackendsPage( config, &binaries, backendsPage, "configBackendsPage" );
+ connect( configBackendsPage, SIGNAL(configChanged()),
+ this, SLOT(configChanged())
+ );
+ connect( this, SIGNAL(saveBackends()),
+ configBackendsPage, SLOT(saveSettings())
+ );
+ connect( this, SIGNAL(resetBackends()),
+ configBackendsPage, SLOT(resetDefaults())
+ );
+ connect( configEnvironmentPage, SIGNAL(rebuildBackendsPage()),
+ configBackendsPage, SLOT(rebuild())
+ );
+
+ setConfigChanged( false );
+
+ showPage( startPage );
+}
+
+ConfigDialog::~ConfigDialog()
+{
+}
+
+QFrame *ConfigDialog::addPage(const QString &itemName, const QString &iconName)
+{
+ return KDialogBase::addPage( itemName, QString::null, MainBarIcon(iconName,32) );
+}
+
+void ConfigDialog::setConfigChanged( const bool value )
+{
+ actionButton( Apply )->setEnabled(value);
+}
+
+void ConfigDialog::configChanged()
+{
+ setConfigChanged( true );
+}
+
+void ConfigDialog::applyClickedSlot()
+{
+ okClickedSlot();
+ setConfigChanged( false );
+}
+
+void ConfigDialog::okClickedSlot()
+{
+ emit saveGeneral();
+ emit savePlugins();
+ emit saveEnvironment();
+ emit saveBackends();
+ config->write();
+}
+
+void ConfigDialog::defaultClickedSlot()
+{
+ int index = activePageIndex();
+ QStringList listDefaults;
+
+ if( index == -1 )
+ return;
+
+ if( index == pageIndex(generalPage) )
+ {
+ emit resetGeneral();
+ setConfigChanged( true );
+ }
+ else if( index == pageIndex(pluginsPage) )
+ {
+ emit resetPlugins();
+ setConfigChanged( true );
+ }
+ else if( index == pageIndex(environmentPage) )
+ {
+ emit resetEnvironment();
+ setConfigChanged( true );
+ }
+ else if( index == pageIndex(backendsPage) )
+ {
+ emit resetBackends();
+ setConfigChanged( true );
+ }
+}
diff --git a/src/configdialog.h b/src/configdialog.h
new file mode 100755
index 0000000..19d3d12
--- /dev/null
+++ b/src/configdialog.h
@@ -0,0 +1,79 @@
+
+
+#ifndef CONFIGDIALOG_H
+#define CONFIGDIALOG_H
+
+#include
+
+#include
+
+
+class Config;
+class ConfigGeneralPage;
+class ConfigPluginsPage;
+class ConfigEnvironmentPage;
+class ConfigBackendsPage;
+
+/**
+ * @short Config dialog
+ * @author Daniel Faust
+ * @version 0.3
+ */
+class ConfigDialog : public KDialogBase
+{
+ Q_OBJECT
+public:
+ enum Page {
+ GeneralPage,
+ PluginsPage,
+ EnvironmentPage,
+ BackendsPage
+ };
+
+ /**
+ * Constructor
+ */
+ ConfigDialog( Config*, QWidget *parent = 0, const char *name = 0, Page startPage = GeneralPage );
+
+ /**
+ * Destructor
+ */
+ virtual ~ConfigDialog();
+
+private:
+ QFrame* addPage( const QString &itemName, const QString &iconName );
+
+ QFrame* generalPage;
+ ConfigGeneralPage* configGeneralPage;
+ QFrame* pluginsPage;
+ ConfigPluginsPage* configPluginsPage;
+ QFrame* environmentPage;
+ ConfigEnvironmentPage* configEnvironmentPage;
+ QFrame* backendsPage;
+ ConfigBackendsPage* configBackendsPage;
+
+ void setConfigChanged( const bool );
+
+ Config* config;
+
+ QMap binaries;
+
+private slots:
+ void configChanged();
+ void okClickedSlot();
+ void applyClickedSlot();
+ void defaultClickedSlot();
+
+signals:
+ void saveGeneral();
+ void savePlugins();
+ void saveEnvironment();
+ void saveBackends();
+
+ void resetGeneral();
+ void resetPlugins();
+ void resetEnvironment();
+ void resetBackends();
+};
+
+#endif // CONFIGDIALOG_H
diff --git a/src/configenvironmentpage.cpp b/src/configenvironmentpage.cpp
new file mode 100755
index 0000000..26dbd5b
--- /dev/null
+++ b/src/configenvironmentpage.cpp
@@ -0,0 +1,223 @@
+
+#include "configenvironmentpage.h"
+
+#include "config.h"
+
+#include
+#include
+#include
+#include
+//#include
+//#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+
+ConfigEnvironmentPage::ConfigEnvironmentPage( Config* _config, QMap* _binaries, QWidget *parent, const char *name )
+ : ConfigPageBase( parent, name )
+{
+ config = _config;
+ binaries = _binaries;
+
+ // create an icon loader object for loading icons
+ KIconLoader* iconLoader = new KIconLoader();
+
+ QVBoxLayout* box = new QVBoxLayout( parent, 0, 6 );
+
+ QLabel* lDirectoriesLabel = new QLabel( i18n("Directories to be scanned")+":", parent, "lDirectoriesLabel" );
+ box->addWidget( lDirectoriesLabel );
+
+// KEditListBox* eDirectories = new KEditListBox( parent, "eDirectories" );
+// box->addWidget( eDirectories );
+
+ QHBoxLayout* directoriesBox = new QHBoxLayout( box );
+ lDirectories = new KListBox( parent, "lDirectories" );
+ lDirectories->insertStringList( config->data.environment.directories );
+ directoriesBox->addWidget( lDirectories );
+ connect( lDirectories, SIGNAL(highlighted(int)),
+ this, SLOT(directoriesSelectionChanged(int))
+ );
+
+ QVBoxLayout* directoriesMiddleBox = new QVBoxLayout( directoriesBox );
+ pDirUp = new KPushButton( "", parent, "pDirUp" );
+ pDirUp->setPixmap( iconLoader->loadIcon("up",KIcon::Toolbar) );
+ pDirUp->setEnabled( false );
+ QToolTip::add( pDirUp, i18n("Move selected directory one position up.\nThis effects which backend will be chosen, if there are several versions.") );
+ directoriesMiddleBox->addWidget( pDirUp );
+ connect( pDirUp, SIGNAL(clicked()),
+ this, SLOT(dirUp())
+ );
+
+ directoriesMiddleBox->addStretch();
+ pDirDown = new KPushButton( "", parent, "pDirDown" );
+ pDirDown->setPixmap( iconLoader->loadIcon("down",KIcon::Toolbar) );
+ pDirDown->setEnabled( false );
+ QToolTip::add( pDirDown, i18n("Move selected directory one position down.\nThis effects which backend will be chosen, if there are several versions.") );
+ directoriesMiddleBox->addWidget( pDirDown );
+ connect( pDirDown, SIGNAL(clicked()),
+ this, SLOT(dirDown())
+ );
+
+ QVBoxLayout* directoriesRightBox = new QVBoxLayout( directoriesBox );
+ pAddDirectory = new KPushButton( iconLoader->loadIcon("add",KIcon::Small), i18n("Add ..."), parent, "pAddDirectory" );
+ directoriesRightBox->addWidget( pAddDirectory );
+ connect( pAddDirectory, SIGNAL(clicked()),
+ this, SLOT(addDirectory())
+ );
+
+ pRemoveDirectory = new KPushButton( iconLoader->loadIcon("remove",KIcon::Small), i18n("Remove"), parent, "pRemoveDirectory" );
+ directoriesRightBox->addWidget( pRemoveDirectory );
+ pRemoveDirectory->setEnabled( false );
+ connect( pRemoveDirectory, SIGNAL(clicked()),
+ this, SLOT(removeDirectory())
+ );
+
+ directoriesRightBox->addStretch();
+
+ box->addSpacing( 5 );
+
+ QHBoxLayout* programsBox = new QHBoxLayout( box );
+
+ QVBoxLayout* foundProgramsBox = new QVBoxLayout( programsBox );
+ QLabel* lFoundProgramsLabel = new QLabel( i18n("Programs found")+":", parent, "lFoundProgramsLabel" );
+ foundProgramsBox->addWidget( lFoundProgramsLabel );
+ lFoundPrograms = new KListBox( parent, "lFoundPrograms" );
+ lFoundPrograms->setSelectionMode( QListBox::NoSelection );
+ foundProgramsBox->addWidget( lFoundPrograms );
+ //connect(lPrograms,SIGNAL(highlighted(int)),this,SLOT(programsSelectionChanged(int)));
+ programsBox->setStretchFactor( foundProgramsBox, 3 );
+
+ QVBoxLayout* notFoundProgramsBox = new QVBoxLayout( programsBox );
+ QLabel* lNotFoundProgramsLabel = new QLabel( i18n("Programs not found")+":", parent, "lNotFoundProgramsLabel" );
+ notFoundProgramsBox->addWidget( lNotFoundProgramsLabel );
+ lNotFoundPrograms = new KListBox( parent, "lNotFoundPrograms" );
+ lNotFoundPrograms->setSelectionMode( QListBox::NoSelection );
+ notFoundProgramsBox->addWidget( lNotFoundPrograms );
+ //connect(lPrograms,SIGNAL(highlighted(int)),this,SLOT(programsSelectionChanged(int)));
+ programsBox->setStretchFactor( notFoundProgramsBox, 2 );
+
+ for( QMap::Iterator it = config->binaries.begin(); it != config->binaries.end(); ++it ) {
+ if( it.data() != "" ) {
+ lFoundPrograms->insertItem( it.data() );
+ }
+ else {
+ lNotFoundPrograms->insertItem( it.key() );
+ }
+ }
+
+// box->addStretch();
+
+ // delete the icon loader object
+ delete iconLoader;
+}
+
+ConfigEnvironmentPage::~ConfigEnvironmentPage()
+{}
+
+void ConfigEnvironmentPage::resetDefaults()
+{
+ lDirectories->clear();
+ QString datadir = locateLocal( "data", "soundkonverter/bin/" );
+ datadir.remove( datadir.length() - 1, 1 );
+ lDirectories->insertItem( datadir );
+ lDirectories->insertItem( QDir::homeDirPath() + "/bin" );
+ lDirectories->insertItem( "/usr/local/bin" );
+ lDirectories->insertItem( "/usr/bin" );
+
+ refill();
+ cfgChanged();
+}
+
+void ConfigEnvironmentPage::saveSettings()
+{
+ config->data.environment.directories.clear();
+ for( uint i = 0; i < lDirectories->count(); i++ ) {
+ config->data.environment.directories.append( lDirectories->text(i) );
+ }
+
+ config->binaries = *binaries;
+}
+
+void ConfigEnvironmentPage::directoriesSelectionChanged( int index )
+{
+ pRemoveDirectory->setEnabled( true );
+ if( index != 0 ) pDirUp->setEnabled( true );
+ else pDirUp->setEnabled( false );
+ if( index != lDirectories->count() - 1 ) pDirDown->setEnabled( true );
+ else pDirDown->setEnabled( false );
+}
+
+void ConfigEnvironmentPage::dirUp()
+{
+ int index = lDirectories->currentItem();
+ if( index > 0 ) {
+ QString text = lDirectories->currentText();
+ lDirectories->removeItem( index );
+ lDirectories->insertItem( text, index - 1 );
+ lDirectories->setSelected( index - 1, true );
+ refill();
+ cfgChanged();
+ }
+}
+
+void ConfigEnvironmentPage::dirDown()
+{
+ int index = lDirectories->currentItem();
+ if( (uint)index < lDirectories->count() - 1 ) {
+ QString text = lDirectories->currentText();
+ lDirectories->removeItem( index );
+ lDirectories->insertItem( text, index + 1 );
+ lDirectories->setSelected( index + 1, true );
+ refill();
+ cfgChanged();
+ }
+}
+
+void ConfigEnvironmentPage::addDirectory()
+{
+ QString dirname = KFileDialog::getExistingDirectory( "/", 0 );
+ if( dirname != NULL ) {
+ lDirectories->insertItem( dirname );
+ refill();
+ cfgChanged();
+ }
+}
+
+void ConfigEnvironmentPage::removeDirectory()
+{
+ lDirectories->removeItem( lDirectories->currentItem() );
+ refill();
+ cfgChanged();
+}
+
+void ConfigEnvironmentPage::refill()
+{
+ for( QMap::Iterator it = binaries->begin(); it != binaries->end(); ++it ) {
+ it.data() = "";
+ for( uint i = 0; i < lDirectories->count(); i++ ) {
+ if( it.data() == "" && QFile::exists(lDirectories->text(i) + "/" + it.key()) ) {
+ it.data() = lDirectories->text(i) + "/" + it.key();
+ }
+ }
+ }
+
+ lFoundPrograms->clear();
+ lNotFoundPrograms->clear();
+ for( QMap::Iterator it = binaries->begin(); it != binaries->end(); ++it ) {
+ if( it.data() != "" ) {
+ lFoundPrograms->insertItem( it.data() );
+ }
+ else {
+ lNotFoundPrograms->insertItem( it.key() );
+ }
+ }
+
+ emit rebuildBackendsPage();
+}
+
+
diff --git a/src/configenvironmentpage.h b/src/configenvironmentpage.h
new file mode 100755
index 0000000..37b0c2e
--- /dev/null
+++ b/src/configenvironmentpage.h
@@ -0,0 +1,62 @@
+
+
+#ifndef CONFIGENVIRONMENTPAGE_H
+#define CONFIGENVIRONMENTPAGE_H
+
+#include
+
+class Config;
+class KPushButton;
+class KListBox;
+
+/**
+* @short The page for configuring the environment
+ * @author Daniel Faust
+ * @version 0.3
+ */
+class ConfigEnvironmentPage : public ConfigPageBase
+{
+ Q_OBJECT
+public:
+ /**
+ * Default Constructor
+ */
+ ConfigEnvironmentPage( Config*, QMap*, QWidget *parent=0, const char *name=0 );
+
+ /**
+ * Default Destructor
+ */
+ virtual ~ConfigEnvironmentPage();
+
+private:
+ KListBox* lDirectories;
+ KPushButton* pDirUp;
+ KPushButton* pDirDown;
+ KPushButton* pAddDirectory;
+ KPushButton* pRemoveDirectory;
+ KListBox* lFoundPrograms;
+ KListBox* lNotFoundPrograms;
+
+ Config* config;
+
+ QMap* binaries;
+
+public slots:
+ void resetDefaults();
+ void saveSettings();
+
+private slots:
+ void directoriesSelectionChanged( int );
+ void dirUp();
+ void dirDown();
+ void addDirectory();
+ void removeDirectory();
+ void refill();
+
+signals:
+ void rebuildBackendsPage();
+
+};
+
+#endif // CONFIGENVIRONMENTPAGE_H
+
diff --git a/src/configgeneralpage.cpp b/src/configgeneralpage.cpp
new file mode 100755
index 0000000..9408ffd
--- /dev/null
+++ b/src/configgeneralpage.cpp
@@ -0,0 +1,323 @@
+
+#include "configgeneralpage.h"
+
+#include "config.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include