diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-08-20 17:14:02 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-08-20 18:25:17 (GMT) |
commit | b3dc968b7c424351bac87bfed42681bd0500d86c (patch) | |
tree | 1f3ec7ee8f8b3e9d3e274ba77684b8606dc96377 /Swift/QtUI | |
parent | 5fa4903a7c1c7a7733afdd1d6c4c5dcccec97b19 (diff) | |
download | swift-b3dc968b7c424351bac87bfed42681bd0500d86c.zip swift-b3dc968b7c424351bac87bfed42681bd0500d86c.tar.bz2 |
Don't bundle sounds.
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtSoundPlayer.cpp | 19 | ||||
-rw-r--r-- | Swift/QtUI/QtSoundPlayer.h | 11 | ||||
-rw-r--r-- | Swift/QtUI/QtSwift.cpp | 2 | ||||
-rw-r--r-- | Swift/QtUI/SConscript | 12 | ||||
-rw-r--r-- | Swift/QtUI/Swift.qrc | 1 |
5 files changed, 35 insertions, 10 deletions
diff --git a/Swift/QtUI/QtSoundPlayer.cpp b/Swift/QtUI/QtSoundPlayer.cpp index 94d2ea5..7fd6564 100644 --- a/Swift/QtUI/QtSoundPlayer.cpp +++ b/Swift/QtUI/QtSoundPlayer.cpp @@ -7,18 +7,31 @@ #include "QtSoundPlayer.h" #include <QSound> +#include <iostream> + +#include "Swiften/Application/ApplicationPathProvider.h" namespace Swift { -QtSoundPlayer::QtSoundPlayer() { +QtSoundPlayer::QtSoundPlayer(ApplicationPathProvider* applicationPathProvider) : applicationPathProvider(applicationPathProvider) { } void QtSoundPlayer::playSound(SoundEffect sound) { switch (sound) { - case MessageReceived: - QSound::play(":/sounds/message-received.wav"); + case MessageReceived: + playSound("/sounds/message-received.wav"); break; } } +void QtSoundPlayer::playSound(const String& soundResource) { + boost::filesystem::path resourcePath = applicationPathProvider->getResourcePath(soundResource); + if (boost::filesystem::exists(resourcePath)) { + QSound::play(resourcePath.string().c_str()); + } + else { + std::cerr << "Unable to find sound: " << soundResource << std::endl; + } +} + } diff --git a/Swift/QtUI/QtSoundPlayer.h b/Swift/QtUI/QtSoundPlayer.h index 89e2935..21ad8bb 100644 --- a/Swift/QtUI/QtSoundPlayer.h +++ b/Swift/QtUI/QtSoundPlayer.h @@ -11,11 +11,20 @@ #include <QObject> namespace Swift { + class ApplicationPathProvider; + class String; + class QtSoundPlayer : public QObject, public SoundPlayer { Q_OBJECT public: - QtSoundPlayer(); + QtSoundPlayer(ApplicationPathProvider* applicationPathProvider); void playSound(SoundEffect sound); + + private: + void playSound(const String& soundResource); + + private: + ApplicationPathProvider* applicationPathProvider; }; } diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp index ef02096..55bc112 100644 --- a/Swift/QtUI/QtSwift.cpp +++ b/Swift/QtUI/QtSwift.cpp @@ -80,7 +80,7 @@ QtSwift::QtSwift(po::variables_map options) : autoUpdater_(NULL) { applicationPathProvider_ = new PlatformApplicationPathProvider(SWIFT_APPLICATION_NAME); avatarStorage_ = new AvatarFileStorage(applicationPathProvider_->getAvatarDir()); chatWindowFactory_ = new QtChatWindowFactory(splitter_, settings_, tabs_); - soundPlayer_ = new QtSoundPlayer(); + soundPlayer_ = new QtSoundPlayer(applicationPathProvider_); if (splitter_) { splitter_->show(); } diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript index 6c30f42..0d043fb 100644 --- a/Swift/QtUI/SConscript +++ b/Swift/QtUI/SConscript @@ -127,11 +127,13 @@ myenv.Uic4("QtBookmarkDetailWindow.ui") myenv.Qrc("DefaultTheme.qrc") myenv.Qrc("Swift.qrc") +commonResources = ["../resources/sounds"] + if env["PLATFORM"] == "darwin" : frameworks = [] if env["HAVE_SPARKLE"] : frameworks.append(env["SPARKLE_FRAMEWORK"]) - app = myenv.AppBundle("Swift", version = myenv["SWIFT_VERSION"], resources = ["../resources/MacOSX/Swift.icns"], frameworks = frameworks) + app = myenv.AppBundle("Swift", version = myenv["SWIFT_VERSION"], resources = ["../resources/MacOSX/Swift.icns"] + commonResources, frameworks = frameworks) if env["DIST"] : myenv.Command(["Swift-${SWIFT_VERSION}.dmg"], [app], [ "$QTDIR/bin/macdeployqt $SOURCE -dmg", @@ -142,13 +144,15 @@ if env.get("SWIFT_INSTALLDIR", "") : env.Install(os.path.join(env["SWIFT_INSTALLDIR"], "bin"), swiftProgram) env.InstallAs(os.path.join(env["SWIFT_INSTALLDIR"], "share", "pixmaps", "swift.xpm"), "../resources/logo/logo-icon-32.xpm") env.Install(os.path.join(env["SWIFT_INSTALLDIR"], "share", "applications"), "../resources/swift.desktop") - + for resource in commonResources : + env.Install(os.path.join(env["SWIFT_INSTALLDIR"], "share", "swift"), resource) + if env["PLATFORM"] == "win32" : if env["DIST"] : myenv.WindowsBundle("Swift", resources = [ os.path.join(env["OPENSSL_DIR"], "bin", "ssleay32.dll"), - os.path.join(env["OPENSSL_DIR"], "bin", "libeay32.dll"), - ], + os.path.join(env["OPENSSL_DIR"], "bin", "libeay32.dll"), + ] + commonResources, qtimageformats = ["gif", "ico", "jpeg", "mng", "svg", "tiff"], qtlibs = ["QtCore4", "QtGui4", "QtNetwork4", "QtWebKit4", "QtXMLPatterns4", "phonon4"]) diff --git a/Swift/QtUI/Swift.qrc b/Swift/QtUI/Swift.qrc index b14569e..4da687c 100644 --- a/Swift/QtUI/Swift.qrc +++ b/Swift/QtUI/Swift.qrc @@ -13,7 +13,6 @@ <file alias="icons/avatar.png">../resources/icons/avatar.png</file> <file alias="icons/tray-standard.png">../resources/icons/tray-standard.png</file> <file alias="icons/new-chat.png">../resources/icons/new-chat.png</file> - <file alias="sounds/message-received.wav">../resources/sounds/message-received.wav</file> <file alias="COPYING">../../COPYING</file> </qresource> </RCC> |