Add status bar stub.
[wallplayer.git] / src / controlpanel.cpp
blob667fc46319b37279bed8ced08c3805e50c81fa2d
2 #include "controlpanel.h"
3 #include "playerpanel.h"
6 ControlPanel::ControlPanel(QWidget* parent, PlayerPanel* playerPanel)
8 setParent(parent);
9 setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
11 m_playerPanel = playerPanel;
13 setStatus("Ready.");
14 m_layout.addWidget(&m_statusLabel);
16 QPushButton* addFileButton = new QPushButton("Add files...", this);
17 addFileButton->setToolTip("Add media files and playlists (*.txt)");
18 addFileButton->installEventFilter(m_playerPanel);
19 connect(addFileButton, SIGNAL(clicked()), this, SLOT(launchAddFileDialog()));
20 m_layout.addWidget(addFileButton);
22 QPushButton* addDirectoryButton = new QPushButton("Add directory...", this);
23 addDirectoryButton->setToolTip("Add a directory and all files in it and its subdirectories");
24 addDirectoryButton->setEnabled(false);
25 addDirectoryButton->installEventFilter(m_playerPanel);
26 m_layout.addWidget(addDirectoryButton);
28 m_shuffleButton = new QPushButton("Shuffle playlist", this);
29 m_shuffleButton->setToolTip("Shuffle the current playlist");
30 m_shuffleButton->setEnabled(false);
31 m_shuffleButton->installEventFilter(m_playerPanel);
32 connect(m_shuffleButton, SIGNAL(clicked()), this, SLOT(shufflePlaylist()));
33 m_layout.addWidget(m_shuffleButton);
35 m_playButton = new QPushButton("Play!", this);
36 m_playButton->setToolTip("Start playing the current playlist");
37 m_playButton->setEnabled(false);
38 m_playButton->installEventFilter(m_playerPanel);
39 connect(m_playButton, SIGNAL(clicked()), this, SLOT(startPlaying()));
40 m_layout.addWidget(m_playButton);
42 setLayout(&m_layout);
45 void ControlPanel::launchAddFileDialog ()
47 QStringList filenames = QFileDialog::getOpenFileNames(this, "Select one or more files to open");
49 m_playerPanel->queueFiles(filenames);
51 return;
54 void ControlPanel::shufflePlaylist()
56 m_playerPanel->shufflePlaylist();
57 setStatus(QString("Shuffled %1 files.").arg(m_playerPanel->playlistCount()));
60 void ControlPanel::startPlaying()
62 qDebug() << "starting play of" << m_playerPanel->playlist()[0];
64 setStatus("Initializing player...");
66 m_playerPanel->startPlayer();
68 return;