File indexing completed on 2024-04-21 15:38:42
0001 /*************************************************************************** 0002 * Copyright (C) 2005-2008 by Bjoern Erik Nilsen & Fredrik Berg Kjoelstad* 0003 * bjoern.nilsen@bjoernen.com & fredrikbk@hotmail.com * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 #include "src/application/soundhandler.h" 0021 0022 #include "src/domain/domainfacade.h" 0023 #include "src/presentation/frontends/qtfrontend/framebar/framebar.h" 0024 0025 #include <QFileDialog> 0026 #include <QInputDialog> 0027 0028 0029 SoundHandler::SoundHandler(QObject *parent, QStatusBar *sb, 0030 const FrameBar* fb, const char* homeDir, const char *name) 0031 : QObject(parent), statusBar(sb), frameBar(fb), homeDir(homeDir) { 0032 soundsList = NULL; 0033 setObjectName(name); 0034 } 0035 0036 0037 void SoundHandler::setSoundsList(QListWidget *soundsList) { 0038 this->soundsList = soundsList; 0039 } 0040 0041 0042 void SoundHandler::addSound() { 0043 QString file = QFileDialog:: 0044 getOpenFileName(0, tr("Choose sound file"), QString(homeDir), tr("Sounds (*.ogg)") ); 0045 if ( !file.isNull() ) { 0046 DomainFacade *facade = DomainFacade::getFacade(); 0047 int activeScene = frameBar->getActiveScene(); 0048 int activeFrame = frameBar->getActiveFrame(); 0049 facade->addSound( activeScene, activeFrame, 0050 file.toLocal8Bit().constData() ); 0051 } 0052 } 0053 0054 0055 void SoundHandler::removeSound() { 0056 int index = soundsList->currentRow(); 0057 if (index >= 0) { 0058 int scene = frameBar->getActiveScene(); 0059 int frame = frameBar->getActiveFrame(); 0060 DomainFacade::getFacade()->removeSound(scene, frame, index); 0061 } 0062 } 0063 0064 0065 void SoundHandler::setSoundName() 0066 { 0067 int index = soundsList->currentRow(); 0068 if (index >= 0) { 0069 bool ok = false; 0070 QString text = QInputDialog::getText(0, tr("Sound name"), 0071 tr("Enter the name of the sound:"), 0072 QLineEdit::Normal,QString(), &ok); 0073 if ( ok && !text.isEmpty() ) { 0074 int scene = frameBar->getActiveScene(); 0075 int frame = frameBar->getActiveFrame(); 0076 DomainFacade::getFacade()->setSoundName(scene, frame, 0077 index, text.toLocal8Bit().data() ); 0078 } 0079 } 0080 }