Changeset 481

Show
Ignore:
Timestamp:
09/16/08 13:06:57 (5 years ago)
Author:
wolke
Message:

audiofilbrowser next step

Location:
branches/audiofilebrowser/gui/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/audiofilebrowser/gui/src/AudioFileBrowser/AudioFileBrowser.cpp

    r480 r481  
    3030#include <hydrogen/Preferences.h> 
    3131#include <hydrogen/hydrogen.h> 
     32#include <hydrogen/sample.h> 
    3233 
    3334#include "../widgets/Button.h" 
     
    6263        model->setSorting(QDir::DirsFirst |QDir::Name); 
    6364        QModelIndex index = model->index(QDir::currentPath()); 
    64  
     65         
     66        m_pPlayBtn->setEnabled( false ); 
    6567 
    6668 
     
    6971        tree->setModel(model); 
    7072        tree->resize(799, 310); 
     73        tree->header()->resizeSection ( 0, 405 ); 
    7174        tree->setRootIndex(model->index(QDir::homePath())); 
    7275 
    73  
    74  
    75         lastUsedDir = "";        
    76         m_pselectedFile = lastUsedDir; 
     76        m_psamplefilename = "";  
     77        m_pselectedFile = ""; 
    7778 
    7879        connect(tree, SIGNAL(clicked(const QModelIndex&)), SLOT(clicked(const QModelIndex&))); 
     
    8990void AudioFileBrowser::clicked(const QModelIndex& index) 
    9091{ 
     92 
     93        QString path = model->filePath(index); 
     94        filelineedit->setText(path); 
    9195        if ( model->isDir(index)) 
    9296                 return; 
    93         QString path = model->filePath(index); 
    94         QString message = "File: " + path; 
    95         namelabel->setText(message); 
     97 
     98        QString name = path.section( '/', -1 );  
     99        name = name.left('.'); 
     100 
     101        QString message = "Name: " + name; 
     102        filelineedit->setText(path); 
     103 
     104//      QString fileinfo = model->fileInfo(index); 
     105 
    96106        if      ( 
    97107                ( path.endsWith( ".wav" ) ) || 
     
    104114                ( path.endsWith( ".FLAC" ) ) 
    105115                ) { 
    106                  
    107                         m_pselectedFile = path; 
    108                 }else 
    109                 { 
    110                         m_pselectedFile = ""; 
     116 
     117                        Sample *pNewSample = Sample::load( path ); 
     118                        if (pNewSample) { 
     119                                m_pNBytesLable->setText( trUtf8( "Size: %1 bytes" ).arg( pNewSample->get_size() ) ); 
     120                                m_pSamplerateLable->setText( trUtf8( "Samplerate: %1" ).arg( pNewSample->get_sample_rate() ) ); 
     121                                m_pLengthLable->setText( trUtf8( "Samplelength: %1 s" ).arg( pNewSample->get_n_frames() / pNewSample->get_sample_rate() ) ); 
     122 
     123                                delete pNewSample; 
     124                                m_pPlayBtn->setEnabled( true ); 
     125                                m_psamplefilename = path; 
     126                        }                
     127                        m_pNameLabel->setText(message);                  
     128                }else{ 
     129                        m_pNameLabel->setText( trUtf8( "Name:")); 
     130                        m_pNBytesLable->setText( trUtf8( "Size:" ) ); 
     131                        m_pSamplerateLable->setText( trUtf8( "Samplerate:" ) ); 
     132                        m_pLengthLable->setText( trUtf8( "Samplelength:" ) ); 
     133                        m_pPlayBtn->setEnabled( false ); 
     134                        m_psamplefilename = ""; 
    111135                } 
    112136} 
    113137 
     138 
     139void AudioFileBrowser::on_m_pPlayBtn_clicked() 
     140{ 
     141} 
    114142 
    115143void AudioFileBrowser::on_cancelBTN_clicked() 
     
    122150void AudioFileBrowser::on_openBTN_clicked() 
    123151{ 
     152        if      ( 
     153                ( ( filelineedit->text().endsWith( ".wav" ) ) || 
     154                ( filelineedit->text().endsWith( ".WAV" ) ) || 
     155                ( filelineedit->text().endsWith( ".au" ) ) || 
     156                ( filelineedit->text().endsWith( ".AU" ) ) || 
     157                ( filelineedit->text().endsWith( ".aiff" ) ) || 
     158                ( filelineedit->text().endsWith( ".AIFF" ) ) || 
     159                ( filelineedit->text().endsWith( ".flac" ) ) || 
     160                ( filelineedit->text().endsWith( ".FLAC" ) ) ) && 
     161                ( QFile( filelineedit->text() ).exists() == true ) 
     162                ) {              
     163                        m_pselectedFile = filelineedit->text(); 
     164                         
     165                }else 
     166                { 
     167                        m_pselectedFile = ""; 
     168                } 
    124169        accept(); 
    125170} 
  • branches/audiofilebrowser/gui/src/AudioFileBrowser/AudioFileBrowser.h

    r480 r481  
    5555                void on_openBTN_clicked(); 
    5656                void clicked(const QModelIndex& index); 
     57                void on_m_pPlayBtn_clicked(); 
    5758 
    5859        private: 
    5960                InstrumentEditor* m_pInstrumentEditor; 
    60                 QString lastUsedDir; 
     61                QString m_psamplefilename; 
    6162                QString m_pselectedFile; 
    6263                QDirModel *model; 
  • branches/audiofilebrowser/gui/src/AudioFileBrowser/AudioFileBrowser_UI.ui

    r480 r481  
    5757    <enum>QFrame::Raised</enum> 
    5858   </property> 
    59    <widget class="QLabel" name="namelabel" > 
     59   <widget class="QLabel" name="m_pNameLabel" > 
    6060    <property name="geometry" > 
    6161     <rect> 
     
    7070    </property> 
    7171   </widget> 
    72    <widget class="QLabel" name="lenghtlabel" > 
     72   <widget class="QLabel" name="m_pSamplerateLable" > 
    7373    <property name="geometry" > 
    7474     <rect> 
     
    8080    </property> 
    8181    <property name="text" > 
    82      <string>Length:</string> 
     82     <string>Samplerate:</string> 
    8383    </property> 
    8484   </widget> 
    85    <widget class="QLabel" name="sampleratelabel" > 
     85   <widget class="QLabel" name="m_pNBytesLable" > 
    8686    <property name="geometry" > 
    8787     <rect> 
     
    9393    </property> 
    9494    <property name="text" > 
    95      <string>Samplerate:</string> 
     95     <string>Size:</string> 
    9696    </property> 
    9797   </widget> 
    98    <widget class="QLabel" name="sampledepthlabel" > 
     98   <widget class="QLabel" name="m_pLengthLable" > 
    9999    <property name="geometry" > 
    100100     <rect> 
     
    106106    </property> 
    107107    <property name="text" > 
    108      <string>Sampledepht:</string> 
     108     <string>Length:</string> 
    109109    </property> 
    110110   </widget> 
     
    123123   </property> 
    124124  </widget> 
    125   <widget class="QPushButton" name="listenBTN" > 
     125  <widget class="QPushButton" name="m_pPlayBtn" > 
    126126   <property name="geometry" > 
    127127    <rect> 
    128128     <x>360</x> 
    129129     <y>460</y> 
    130      <width>75</width> 
     130     <width>91</width> 
    131131     <height>26</height> 
    132132    </rect> 
    133133   </property> 
    134134   <property name="text" > 
    135     <string>Listen</string> 
     135    <string>Play Sample</string> 
    136136   </property> 
    137137  </widget> 
  • branches/audiofilebrowser/gui/src/InstrumentEditor/InstrumentEditor.cpp

    r480 r481  
    486486 
    487487        Hydrogen *engine = Hydrogen::get_instance(); 
    488         MainForm *pMainForm = HydrogenApp::getInstance()->getMainForm(); 
     488//      MainForm *pMainForm = HydrogenApp::getInstance()->getMainForm(); 
    489489 
    490490