• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

parley

  • sources
  • kde-4.12
  • kdeedu
  • parley
  • src
  • editor
audiowidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 
3  Copyright 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
4 
5  ***************************************************************************/
6 
7 /***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "audiowidget.h"
17 
18 #include <Phonon/MediaObject>
19 
20 #include <keduvocexpression.h>
21 
22 #include <KIcon>
23 #include <kdebug.h>
24 
25 using namespace Editor;
26 
27 AudioWidget::AudioWidget(QWidget *parent) : QWidget(parent)
28 {
29  setupUi(this);
30  m_currentTranslation = -1;
31  m_player = 0;
32 
33  connect(audioUrlRequester, SIGNAL(textChanged(const QString&)), SLOT(slotAudioFileChanged(const QString&)));
34  connect(playButton, SIGNAL(clicked()), SLOT(playAudio()));
35 // connect(recordButton, SIGNAL(clicked()), SLOT(recordAudio()));
36 
37  playButton->setEnabled(false);
38  playButton->setIcon(KIcon("media-playback-start"));
39  recordButton->setVisible(false);
40 // recordButton->setEnabled(false);
41 // recordButton->setIcon(KIcon("media-record"));
42  audioUrlRequester->setEnabled(false);
43 }
44 
45 void AudioWidget::setTranslation(KEduVocExpression* entry, int translation)
46 {
47  m_currentTranslation = translation;
48  m_entry = entry;
49 
50  if (m_entry) {
51  recordButton->setEnabled(true);
52  audioUrlRequester->setEnabled(true);
53  audioUrlRequester->setUrl(m_entry->translation(m_currentTranslation)->soundUrl().toLocalFile());
54  } else {
55  recordButton->setEnabled(false);
56  audioUrlRequester->setEnabled(false);
57  if (m_player) {
58  if (m_player->state() == Phonon::PlayingState) {
59  playButton->setEnabled(true);
60  } else {
61  playButton->setEnabled(false);
62  }
63  }
64  audioUrlRequester->clear();
65  }
66 }
67 
68 void AudioWidget::slotAudioFileChanged(const QString & url)
69 {
70  if (m_entry) {
71  m_entry->translation(m_currentTranslation)->setSoundUrl( KUrl(url) );
72  }
73  playButton->setEnabled(!url.isEmpty());
74 }
75 
76 void AudioWidget::playAudio()
77 {
78  KUrl soundFile = m_entry->translation(m_currentTranslation)->soundUrl();
79 
80  if (!m_player)
81  {
82  m_player = Phonon::createPlayer(Phonon::NotificationCategory, soundFile);
83  m_player->setParent(this);
84  connect(m_player, SIGNAL(finished()), SLOT(slotPlaybackFinished()));
85  } else {
86  if (m_player->state() == Phonon::PlayingState) {
87  m_player->stop();
88  slotPlaybackFinished();
89  return;
90  }
91  m_player->setCurrentSource(soundFile);
92  }
93  playButton->setIcon(KIcon("media-playback-stop"));
94  m_player->play();
95 }
96 
97 /*
98 void AudioWidget::recordAudio()
99 {
101 }
102 */
103 
104 void AudioWidget::slotPlaybackFinished()
105 {
106  playButton->setIcon(KIcon("media-playback-start"));
107  playButton->setEnabled(!audioUrlRequester->url().isEmpty());
108 }
109 
110 #include "audiowidget.moc"
QWidget
Editor::AudioWidget::setTranslation
void setTranslation(KEduVocExpression *entry, int translation)
Update the word.
Definition: audiowidget.cpp:45
Editor::AudioWidget::AudioWidget
AudioWidget(QWidget *parent=0)
Definition: audiowidget.cpp:27
audiowidget.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:42:05 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

parley

Skip menu "parley"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal