File indexing completed on 2024-05-12 16:23:32
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/presentation/frontends/qtfrontend/framepreferencesmenu.h" 0021 0022 #include "src/domain/domainfacade.h" 0023 #include "graphics/icons/close.xpm" 0024 #include "src/application/soundhandler.h" 0025 #include "src/presentation/frontends/qtfrontend/framebar/framebar.h" 0026 0027 #include <QToolTip> 0028 #include <QLabel> 0029 #include <QGridLayout> 0030 0031 0032 FramePreferencesMenu::FramePreferencesMenu( QWidget * parent, 0033 SoundHandler *soundHandler, const FrameBar* fb, const char * name ) 0034 : MenuFrame(parent, name), soundHandler(soundHandler), 0035 frameBar(fb) { 0036 soundsList = 0; 0037 soundsLabel = 0; 0038 closeButton = 0; 0039 addSoundButton = 0; 0040 removeSoundsButton = 0; 0041 changeNameButton = 0; 0042 grid = 0; 0043 0044 this->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); 0045 grid = new QGridLayout; 0046 grid->setContentsMargins(1, 1, 1, 1); 0047 grid->setSpacing(1); 0048 0049 addSoundButton = new QPushButton; 0050 addSoundButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 0051 addSoundButton->setFocusPolicy( Qt::NoFocus ); 0052 connect( addSoundButton, SIGNAL( clicked() ), soundHandler, SLOT( addSound() ) ); 0053 0054 removeSoundsButton = new QPushButton; 0055 removeSoundsButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 0056 removeSoundsButton->setFocusPolicy( Qt::NoFocus ); 0057 connect( removeSoundsButton, SIGNAL( clicked() ), soundHandler, SLOT( removeSound() ) ); 0058 0059 changeNameButton = new QPushButton; 0060 changeNameButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 0061 changeNameButton->setFocusPolicy( Qt::NoFocus ); 0062 connect( changeNameButton, SIGNAL( clicked() ), soundHandler, SLOT( setSoundName() ) ); 0063 0064 closeButton = new QPushButton; 0065 closeButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); 0066 closeButton->setIcon(QPixmap(closeicon)); 0067 closeButton->setFlat(true); 0068 connect(closeButton, SIGNAL(clicked()),this, SLOT(close()) ); 0069 0070 soundsLabel = new QLabel; 0071 soundsList = new QListWidget; 0072 0073 grid->addWidget( soundsLabel, 0, 1 ); 0074 grid->addWidget( addSoundButton, 1, 0 ); 0075 grid->addWidget( removeSoundsButton, 2, 0 ); 0076 grid->addWidget( changeNameButton, 3, 0 ); 0077 grid->addWidget( closeButton, 0, 2 ); 0078 0079 QVBoxLayout *layout = new QVBoxLayout; 0080 layout->addWidget(soundsList); 0081 grid->addLayout( layout, 1, 1, 3, 2); 0082 0083 grid->setColumnStretch(1, 1); 0084 setLayout(grid); 0085 soundHandler->setSoundsList(soundsList); 0086 } 0087 0088 0089 void FramePreferencesMenu::open() { 0090 soundsList->clear(); 0091 int activeFrame = frameBar->getActiveFrame(); 0092 int activeScene = frameBar->getActiveScene(); 0093 DomainFacade* facade = DomainFacade::getFacade(); 0094 int numSounds = facade->getNumberOfSounds(activeScene, 0095 activeFrame); 0096 for (int i = 0; i < numSounds; ++i) { 0097 const char* soundName = facade->getSoundName( 0098 activeScene, activeFrame, i); 0099 if (soundName) 0100 soundsList->addItem(new QListWidgetItem(soundName)); 0101 } 0102 show(); 0103 } 0104 0105 0106 void FramePreferencesMenu::close() 0107 { 0108 MenuFrame::close((QWidget*)parent()); 0109 } 0110 0111 0112 void FramePreferencesMenu::retranslateStrings() 0113 { 0114 addSoundButton->setText( tr("Add &sound")); 0115 removeSoundsButton->setText(tr("&Remove Sound")); 0116 changeNameButton->setText( tr("Change name")); 0117 soundsLabel->setText( tr("Sounds:")); 0118 0119 QString infoText = 0120 tr("<h4>Add sound</h4> " 0121 "<p>With this button you can <em>add sounds</em> to the selected frame.</p> " 0122 "<p>The sound will begin playing when this frame is shown and play " 0123 "until it is done.</p>"); 0124 addSoundButton->setToolTip(infoText); 0125 addSoundButton->setWhatsThis(infoText); 0126 0127 infoText = 0128 tr("<h4>Remove sound</h4> " 0129 "<p>With this button you can <em>remove</em> the selected sound from " 0130 "this frame.</p>"); 0131 removeSoundsButton->setToolTip(infoText); 0132 removeSoundsButton->setWhatsThis(infoText); 0133 0134 infoText = 0135 tr("<h4>Change name</h4> " 0136 "<p>With this button you can change the name of the selected sound. " 0137 "<BR>The name of the sound has no other effect than making it easier " 0138 "work with the animation.</p>"); 0139 changeNameButton->setToolTip(infoText); 0140 changeNameButton->setWhatsThis(infoText); 0141 0142 infoText = 0143 tr("<h4>Sounds</h4> " 0144 "<p>This list shows all the sounds connected to this frame.</p>" 0145 "<p>The sounds will begin playing when this frame is shown and play " 0146 "until they are done.</p>"); 0147 soundsLabel->setToolTip(infoText); 0148 soundsList->setWhatsThis(infoText); 0149 } 0150 0151 FramePreferencesMenu::~FramePreferencesMenu() { 0152 }