summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2009-03-01 21:28:53 -0500
committerBen Boeckel <MathStuf@gmail.com>2009-03-01 21:28:53 -0500
commitc492d50d507e33daf4af4f76be91ce6c26331741 (patch)
tree9db2cc4bb39f66ca4a107e3618c0319633761ce2
parent695d0611219aece597f79ff4e866fa4a9c6a4949 (diff)
Use KIO in sound searching as well
-rw-r--r--sigmodr/widgets/SoundUI.cpp42
1 files changed, 37 insertions, 5 deletions
diff --git a/sigmodr/widgets/SoundUI.cpp b/sigmodr/widgets/SoundUI.cpp
index 891b0d07..a2980ffd 100644
--- a/sigmodr/widgets/SoundUI.cpp
+++ b/sigmodr/widgets/SoundUI.cpp
@@ -29,6 +29,7 @@
#include <KMessageBox>
#include <KPushButton>
#include <KUrl>
+#include <KIO/NetAccess>
// Phonon includes
#include <Phonon/AudioOutput>
@@ -123,13 +124,44 @@ void SoundUI::Private::nameChanged(const QString& name)
void SoundUI::Private::browse()
{
- QFile file(KFileDialog::getOpenFileName(KUrl("kfiledialog:///audio"), "audio/*|Audio files", NULL));
- if (file.open(QIODevice::ReadOnly))
+ KFileDialog* dialog = new KFileDialog(KUrl("kfiledialog:///audio"), "audio/*|Audio Files", NULL);
+ dialog->setCaption("Use Audio File");
+ dialog->setOperationMode(KFileDialog::Opening);
+ if (dialog->exec() == QDialog::Accepted)
{
- m_sound->setData(file.readAll());
- file.close();
- resetAudioData();
+ KUrl url = dialog->selectedFile();
+ if (url.isValid())
+ {
+ QString path;
+ bool load = true;
+ bool removeTempFile = false;
+ if (url.isLocalFile())
+ path = url.path();
+ else
+ {
+ if (KIO::NetAccess::download(url, path, NULL))
+ removeTempFile = true;
+ else
+ {
+ KMessageBox::error(NULL, KIO::NetAccess::lastErrorString(), "KIO Error");
+ load = false;
+ }
+ }
+ if (load)
+ {
+ QFile file(url.path());
+ file.open(QIODevice::ReadOnly);
+ m_sound->setData(file.readAll());
+ file.close();
+ resetAudioData();
+ }
+ if (removeTempFile)
+ KIO::NetAccess::removeTempFile(path);
+ }
+ else
+ KMessageBox::error(NULL, "The URL is not valid", "Malformed URL");
}
+ delete dialog;
}
void SoundUI::Private::stateChanged(Phonon::State newState)