/src/plugins/Input/wildmidi/

type='search' size='10' name='q' value=''/>
path: root/src/ui/playlist.cpp
blob: dd454df384307504a9dfae487ab992c7bd0d3487 (plain) (tree)

























                                                                             
                      

                 



                       
 





                             
 


                                 
                                  



                                    
 
                                                          







                      



                                         
                         
                                             
 
                                           

                       
                             

                                











                                                                         

                         

                                                       

                                   
                                                

                           





















                                                                                        








                            




                                      


                              





                                                                            

                            



                                                                          
                           
 



                                                                          
                           
 
                 







                                                                    
                                                                  

                                                                                

                           



                                                                        

                     



                                                                                       

                
                                       

                               
                                                                    
 



                                                                              
 


                                                                             
 


                                                                                 
 


                                                                             
 


                                                                              
 

                                                 
 
                                         
 




                                                                              
 


                                                                             
 


                                                                                 
 


                                                                             
 


                                                                              
 

                                                          
 
                                         

                               

                                                                                         

                                         
                                                            


                                                                                                       


                                                                                               

                 



                                                                    


                                 
                                                                 
                                                  






                                                               
                           


                                                   
                                  

                 

                                                              
                            

                                                                             

                                   

                                                                
                             

                                                                               
 

                                                                
                             

                                                                               
                                                   
 
                                               

 
                                          
 
                          
                      


                    
                                         
 


                                  

 
                                          

                   


                                                               
     
                                                                        
     

                                                                     
     
                                                                                 

     
                                                                             



                
                                            
 

                                          

                         
 

                                      
 
                                              
 



                                       
 

                                                
 

                                                      
 
                                    
 
                                               

                      
                                                              

                        
                                        



                         
                                              
 
                 
     












                                       
                                        
      

     
                                                
 
                                




                                     
                                              

                            


                                        


                    
                                           
 
                                                  
     
                                                 




                             
                 

                                     
                                   


        
                                                                      
                                         
                  
                                                                   







                              
                                                                  
                                     
              
                                           




                            
                                                              



                            
                                                              



                               
                                                                    



                             
                                                                

 
                                      



                           

                                                    
 

                                                



                                           
                                   
 


                                          
                                                         
                             
 
                                                 
     

                                                                          
                                                                                        


                                                   
     
 
 
                           
 



                               
 
                                     
 
                                                                



                                 
                                                                        

 
                                            
 
                                               

                 
/***************************************************************************
 *   Copyright (C) 2006 by Ilya Kotov                                      *
 *   forkotov02@hotmail.ru                                                 *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include <QPainter>
#include <QResizeEvent>
#include <QSettings>
#include <QMenu>
#include <QAction>
#include <QSignalMapper>
#include <QHBoxLayout>
#include <QCloseEvent>

#include "dock.h"
#include "playlist.h"
#include "skin.h"
#include "listwidget.h"
#include "button.h"

#include "playlisttitlebar.h"
#include "playlistslider.h"
#include "pixmapwidget.h"
#include "symboldisplay.h"
#include "playlistcontrol.h"
#include "keyboardmanager.h"

#include <qmmpui/playlistitem.h>
#include <qmmpui/playlistmodel.h>
#include <qmmpui/fileloader.h>
#include <qmmpui/generalhandler.h>
#include <qmmp/soundcore.h>

PlayList::PlayList (QWidget *parent)
        : QWidget (parent)
{
    setWindowFlags (Qt::Dialog | Qt::FramelessWindowHint);

    m_update = FALSE;
    m_resize = FALSE;
    m_anchor_row = -1;

    createMenus();


    resize (275,116);
    setMinimumSize (275,116);
    setBaseSize (275,116);
    m_listWidget = new ListWidget (this);
    m_listWidget->show();
    m_listWidget->setGeometry (12,20,243,58);

    m_plslider = new PlayListSlider (this);
    m_plslider->show();

    setSizeIncrement (25,29);
    m_skin = Skin::getPointer();

    m_buttonAdd = new Button (this,Skin::PL_BT_ADD,Skin::PL_BT_ADD);
    m_buttonAdd->move (11,86);
    m_buttonSub = new Button (this,Skin::PL_BT_SUB,Skin::PL_BT_SUB);
    m_buttonSub->move (40,86);
    m_selectButton  = new Button (this,Skin::PL_BT_SEL,Skin::PL_BT_SEL);
    m_selectButton->move (70,86);
    m_sortButton= new Button (this,Skin::PL_BT_SORT,Skin::PL_BT_SORT);
    m_sortButton->move (99,86);
    m_playlistButton = new Button (this,Skin::PL_BT_LST,Skin::PL_BT_LST);

    m_pl_control = new PlaylistControl (this);
    m_pl_control->move (0,0);
    m_pl_control->show();

    m_length_totalLength = new SymbolDisplay (this,14);
    m_length_totalLength->setAlignment (Qt::AlignLeft);
    m_length_totalLength -> show();

    m_current_time = new SymbolDisplay (this,6);
    m_current_time->show();

    m_keyboardManager = new KeyboardManager (this);

    connect (m_listWidget, SIGNAL (selectionChanged()), parent, SLOT (replay()));

    connect (m_plslider, SIGNAL (sliderMoved (int)), m_listWidget, SLOT (scroll (int)));
    connect (m_listWidget, SIGNAL (positionChanged (int, int)), m_plslider,
             SLOT (setPos (int, int)));
    connect (m_skin, SIGNAL (skinChanged()), this, SLOT (update()));
    connect (m_buttonAdd, SIGNAL (clicked()), SLOT (showAddMenu()));
    connect (m_buttonSub, SIGNAL (clicked()), SLOT (showSubMenu()));
    connect (m_selectButton, SIGNAL (clicked()), SLOT (showSelectMenu()));
    connect (m_sortButton, SIGNAL (clicked()), SLOT (showSortMenu()));
    connect (m_playlistButton, SIGNAL (clicked()), SLOT (showPlaylistMenu()));

    connect (m_pl_control, SIGNAL (nextClicked()), SIGNAL (next()));
    connect (m_pl_control, SIGNAL (previousClicked()), SIGNAL (prev()));
    connect (m_pl_control, SIGNAL (playClicked()), SIGNAL (play()));
    connect (m_pl_control, SIGNAL (pauseClicked()), SIGNAL (pause()));
    connect (m_pl_control, SIGNAL (stopClicked()), SIGNAL (stop()));
    connect (m_pl_control, SIGNAL (ejectClicked()), SIGNAL (eject()));
    m_titleBar = new PlayListTitleBar (this);
    m_titleBar->move (0,0);
    readSettings();
}


PlayList::~PlayList()
{}

void PlayList::createMenus()
{
    m_addMenu = new QMenu (this);
    m_subMenu = new QMenu (this);
    m_selectMenu = new QMenu (this);
    m_sortMenu = new QMenu (this);
    m_playlistMenu = new QMenu (this);
}

void PlayList::createActions()
{
    //add menu
    QAction *addFileAct = new QAction (tr ("&Add File"),this);
    addFileAct->setShortcut (tr ("F"));
    m_addMenu->addAction (addFileAct);
    connect (addFileAct, SIGNAL (triggered()), parent(), SLOT (addFile ()));
    m_actions << addFileAct;

    QAction *addDirAct = new QAction (tr ("&Add Directory"),this);
    addDirAct->setShortcut (tr ("D"));
    m_addMenu->addAction (addDirAct);
    connect (addDirAct, SIGNAL (triggered()), parent(), SLOT (addDir ()));
    m_actions << addDirAct;

    QAction *addUrlAct = new QAction (tr ("&Add Url"),this);
    addUrlAct->setShortcut (tr ("U"));
    m_addMenu->addAction (addUrlAct);
    connect (addUrlAct, SIGNAL (triggered()), parent(), SLOT (addUrl ()));
    m_actions << addUrlAct;

    //remove menu
    QAction *remSelAct = new QAction (tr ("&Remove Selected"),this);
    remSelAct->setShortcut (tr ("Del"));
    m_subMenu->addAction (remSelAct);
    connect (remSelAct, SIGNAL (triggered()),
             m_playListModel, SLOT (removeSelected ()));
    this->addAction (remSelAct);

    QAction *remAllAct = new QAction (tr ("&Remove All"),this);
    //remAllAct->setShortcut(tr("D")); FIXME: add correct shortcat
    m_subMenu->addAction (remAllAct);
    connect (remAllAct, SIGNAL (triggered()), m_playListModel, SLOT (clear ()));
    m_actions << remAllAct;

    QAction *remUnselAct = new QAction (tr ("&Remove Unselected"),this);
    m_subMenu->addAction (remUnselAct);
    connect (remUnselAct, SIGNAL (triggered()),
             m_playListModel, SLOT (removeUnselected ()));

    //listwidget menu
    QAction *detailsAct = new QAction (tr ("&View Track Details"),this);
    detailsAct->setShortcut (tr ("Alt+I"));
    m_listWidget->menu()->addAction (detailsAct);