/*
* Copyright (c) 2008 Sander Knopper (sander AT knopper DOT tk) and
* Roeland Douma (roeland AT rullzer DOT com)
*
* This file is part of QtMPC.
*
* QtMPC 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.
*
* QtMPC 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 QtMPC. If not, see .
*/
#include
#include
#include
#include
#include
#include
#include
#ifdef ENABLE_KDE_SUPPORT
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#endif
#include "lyrics.h"
#include "covers.h"
#include "mainwindow.h"
#include "musiclibraryitemsong.h"
#include "preferencesdialog.h"
#include "lib/mpdconnection.h"
#include "lib/mpdstats.h"
#include "lib/mpdstatus.h"
#include "lib/mpdparseutils.h"
#include "settings.h"
#include "updatedialog.h"
#include "config.h"
#include "musiclibraryitemalbum.h"
#include "folderpage.h"
#include "librarypage.h"
#include "lyricspage.h"
#include "playlistspage.h"
#include "fancytabwidget.h"
VolumeSliderEventHandler::VolumeSliderEventHandler(MainWindow *w)
: QObject(w), window(w)
{
}
bool VolumeSliderEventHandler::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::Wheel) {
int numDegrees = static_cast(event)->delta() / 8;
int numSteps = numDegrees / 15;
if (numSteps > 0) {
for (int i = 0; i < numSteps; ++i)
window->action_Increase_volume->trigger();
} else {
for (int i = 0; i > numSteps; --i)
window->action_Decrease_volume->trigger();
}
return true;
}
return QObject::eventFilter(obj, event);
}
VolumeControl::VolumeControl(QWidget *parent)
: QMenu(parent)
{
QFrame *w = new QFrame(this);
slider = new QSlider(w);
QLabel *increase = new QLabel(QLatin1String("+"), w);
QLabel *decrease = new QLabel(QLatin1String("-"), w);
increase->setAlignment(Qt::AlignHCenter);
decrease->setAlignment(Qt::AlignHCenter);
QVBoxLayout *l = new QVBoxLayout(w);
l->setMargin(3);
l->setSpacing(0);
l->addWidget(increase);
l->addWidget(slider);
l->addWidget(decrease);
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setMargin(0);
layout->addWidget(w);
connect(slider, SIGNAL(valueChanged(int)), SIGNAL(valueChanged(int)));
slider->setMinimumHeight(192);
slider->setMaximumHeight(192);
slider->setOrientation(Qt::Vertical);
slider->setMinimum(0);
slider->setMaximum(100);
slider->setPageStep(5);
adjustSize();
}
VolumeControl::~VolumeControl()
{
}
void VolumeControl::installSliderEventFilter(QObject *filter)
{
slider->installEventFilter(filter);
}
void VolumeControl::increaseVolume()
{
slider->triggerAction(QAbstractSlider::SliderPageStepAdd);
}
void VolumeControl::decreaseVolume()
{
slider->triggerAction(QAbstractSlider::SliderPageStepSub);
}
void VolumeControl::setValue(int v)
{
slider->setValue(v);
}
CoverEventHandler::CoverEventHandler(MainWindow *w)
: QObject(w), window(w)
{
}
bool CoverEventHandler::eventFilter(QObject *obj, QEvent *event)
{
switch(event->type()) {
case QEvent::MouseButtonPress:
if (Qt::LeftButton==static_cast(event)->button()) {
pressed=true;
}
break;
case QEvent::MouseButtonRelease:
if (pressed && Qt::LeftButton==static_cast(event)->button()) {
window->action_Show_playlist->trigger();
}
pressed=false;
break;
default:
break;
}
return QObject::eventFilter(obj, event);
}
#ifdef ENABLE_KDE_SUPPORT
MainWindow::MainWindow(QWidget *parent) : KXmlGuiWindow(parent),
#else
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),
#endif
lastState(MPDStatus::State_Inactive),
lastSongId(-1),
fetchStatsFactor(0),
nowPlayingFactor(0),
draggingPositionSlider(false)
{
loaded=0;
updateDialog = 0;
trayIcon = 0;
lyricsNeedUpdating=false;
#ifdef ENABLE_KDE_SUPPORT
QWidget *widget = new QWidget(this);
setupUi(widget);
setCentralWidget(widget);
#else
setupUi(this);
#endif
libraryPage = new LibraryPage(this);
folderPage = new FolderPage(this);
playlistsPage = new PlaylistsPage(this);
lyricsPage = new LyricsPage(this);
#ifdef ENABLE_KDE_SUPPORT
tabWidget->AddTab(libraryPage, QIcon::fromTheme("media-optical-audio"), i18n("Library"));
tabWidget->AddTab(folderPage, QIcon::fromTheme("inode-directory"), i18n("Folders"));
tabWidget->AddTab(playlistsPage, QIcon::fromTheme("view-media-playlist"), i18n("Playlists"));
tabWidget->AddTab(lyricsPage, QIcon::fromTheme("view-media-lyrics"), i18n("Lyrics"));
#else
tabWidget->AddTab(libraryPage, QIcon::fromTheme("media-optical-audio"), tr("Library"));
tabWidget->AddTab(folderPage, QIcon::fromTheme("inode-directory"), tr("Folders"));
tabWidget->AddTab(playlistsPage, QIcon::fromTheme("view-media-playlist"), tr("Playlists"));
tabWidget->AddTab(lyricsPage, QIcon::fromTheme("view-media-lyrics"), tr("Lyrics"));
#endif
tabWidget->SetMode(FancyTabWidget::Mode_LargeSidebar);
connect(tabWidget, SIGNAL(CurrentChanged(int)), this, SLOT(currentTabChanged(int)));
#ifdef ENABLE_KDE_SUPPORT
KStandardAction::quit(kapp, SLOT(quit()), actionCollection());
KStandardAction::preferences(this, SLOT(showPreferencesDialog()), actionCollection());
KAction *action_Update_database = actionCollection()->addAction("updatedatabase");
action_Update_database->setText(i18n("Update Database"));
action_Prev_track = actionCollection()->addAction("prevtrack");
action_Prev_track->setText(i18n("Previous Track"));
action_Prev_track->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Left));
action_Next_track = actionCollection()->addAction("nexttrack");
action_Next_track->setText(i18n("Next Track"));
action_Next_track->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Right));
action_Play_pause_track = actionCollection()->addAction("playpausetrack");
action_Play_pause_track->setText(i18n("Play/Pause"));
action_Play_pause_track->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_C));
action_Stop_track = actionCollection()->addAction("stoptrack");
action_Stop_track->setText(i18n("Stop"));
action_Stop_track->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_X));
action_Increase_volume = actionCollection()->addAction("increasevolume");
action_Increase_volume->setText(i18n("Increase Volume"));
action_Increase_volume->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Up));
action_Decrease_volume = actionCollection()->addAction("decreasevolume");
action_Decrease_volume->setText(i18n("Decrease Volume"));
action_Decrease_volume->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Down));
action_Add_to_playlist = actionCollection()->addAction("addtoplaylist");
action_Add_to_playlist->setText(i18n("Add To Playlist"));
action_Replace_playlist = actionCollection()->addAction("replaceplaylist");
action_Replace_playlist->setText(i18n("Replace Playlist"));
action_Load_playlist = actionCollection()->addAction("loadplaylist");
action_Load_playlist->setText(i18n("Load"));
action_Remove_playlist = actionCollection()->addAction("removeplaylist");
action_Remove_playlist->setText(i18n("Remove"));
action_Remove_from_playlist = actionCollection()->addAction("removefromplaylist");
action_Remove_from_playlist->setText(i18n("Remove"));
action_Remove_from_playlist->setShortcut(QKeySequence::Delete);
action_Copy_song_info = actionCollection()->addAction("copysonginfo");
action_Copy_song_info->setText(i18n("Copy Song Info"));
action_Crop_playlist = actionCollection()->addAction("cropplaylist");
action_Crop_playlist->setText(i18n("Crop"));
action_Shuffle_playlist = actionCollection()->addAction("shuffleplaylist");
action_Shuffle_playlist->setText(i18n("Shuffle"));
action_Rename_playlist = actionCollection()->addAction("renameplaylist");
action_Rename_playlist->setText(i18n("Rename"));
action_Save_playlist = actionCollection()->addAction("saveplaylist");
action_Save_playlist->setText(i18n("Save As"));
action_Clear_playlist = actionCollection()->addAction("clearplaylist");
action_Clear_playlist->setText(i18n("Clear"));
action_Show_playlist = actionCollection()->addAction("showplaylist");
action_Show_playlist->setText(i18n("Show Playlist"));
action_Random_playlist = actionCollection()->addAction("randomplaylist");
action_Random_playlist->setText(i18n("Random"));
action_Repeat_playlist = actionCollection()->addAction("repeatplaylist");
action_Repeat_playlist->setText(i18n("Repeat"));
action_Consume_playlist = actionCollection()->addAction("consumeplaylist");
action_Consume_playlist->setText(i18n("Consume"));
#else
action_Prev_track = new QAction(tr("Previous Track"), this);
action_Next_track = new QAction(tr("Next Track"), this);
action_Play_pause_track = new QAction(tr("Play/Pause"), this);
action_Stop_track = new QAction(tr("Stop"), this);
action_Increase_volume = new QAction(tr("Increase Volume"), this);
action_Decrease_volume = new QAction(tr("Decrease Volume"), this);
action_Add_to_playlist = new QAction(tr("Add To Playlist"), this);
action_Replace_playlist = new QAction(tr("Replace Playlist"), this);
action_Load_playlist = new QAction(tr("Load"), this);
action_Remove_playlist = new QAction(tr("Remove"), this);
action_Remove_from_playlist = new QAction(tr("Remove"), this);
action_Remove_from_playlist->setShortcut(QKeySequence::Delete);
action_Copy_song_info = new QAction(tr("Copy Song Info"), this);
action_Copy_song_info->setShortcuts(QKeySequence::Copy);
action_Crop_playlist = new QAction(tr("Crop"), this);
action_Shuffle_playlist = new QAction(tr("Shuffle"), this);
action_Rename_playlist = new QAction(tr("Rename"), this);
action_Save_playlist = new QAction(tr("Save As"), this);
action_Clear_playlist = new QAction(tr("Clear"), this);
action_Show_playlist = new QAction(tr("Show Playlist"), this);
action_Random_playlist = new QAction(tr("Random"), this);
action_Repeat_playlist = new QAction(tr("Repeat"), this);
action_Consume_playlist = new QAction(tr("Consume"), this);
#endif
setVisible(true);
// Setup event handler for volume adjustment
volumeSliderEventHandler = new VolumeSliderEventHandler(this);
coverEventHandler = new CoverEventHandler(this);
volumeControl = new VolumeControl(volumeButton);
volumeControl->installSliderEventFilter(volumeSliderEventHandler);
volumeButton->installEventFilter(volumeSliderEventHandler);
// KDE does this for us
//#ifndef ENABLE_KDE_SUPPORT
// setWindowIcon(QIcon(":/icons/icon.svg"));
//#endif
noCover = QIcon::fromTheme("media-optical-audio").pixmap(128, 128).scaled(coverWidget->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
coverWidget->setPixmap(noCover);
playbackPlay = QIcon::fromTheme("media-playback-start");
playbackPause = QIcon::fromTheme("media-playback-pause");
// #ifdef ENABLE_KDE_SUPPORT
// action_Random_playlist->setIcon(KIcon("media-random-tracks"));
// action_Repeat_playlist->setIcon(KIcon("media-repeat-playlist"));
// action_Consume_playlist->setIcon(KIcon("media-consume-playlist"));
// action_Add_to_playlist->setIcon(KIcon("media-track-add"));
// action_Replace_playlist->setIcon(KIcon("media-replace-playlist"));
// #else
// action_Random_playlist->setIcon(QIcon(":/icons/hi16-action-media-random-tracks.png"));
// action_Repeat_playlist->setIcon(QIcon(":/icons/hi16-action-media-repeat-playlist.png"));
// action_Consume_playlist->setIcon(QIcon(":/icons/hi16-action-media-consume-playlist.png"));
// action_Add_to_playlist->setIcon(QIcon(":/icons/hi16-action-media-track-add.png"));
// action_Replace_playlist->setIcon(QIcon(":/icons/hi16-action-media-replace-playlist.png"));
// #endif
action_Repeat_playlist->setIcon(QIcon::fromTheme("edit-redo"));
action_Random_playlist->setIcon(QIcon::fromTheme("roll"));
action_Consume_playlist->setIcon(QIcon::fromTheme("format-list-unordered"));
action_Add_to_playlist->setIcon(QIcon::fromTheme(Qt::RightToLeft==QApplication::layoutDirection() ? "arrow-left" : "arrow-right"));
action_Replace_playlist->setIcon(QIcon::fromTheme(Qt::RightToLeft==QApplication::layoutDirection() ? "arrow-left-double" : "arrow-right-double"));
action_Prev_track->setIcon(QIcon::fromTheme("media-skip-backward"));
action_Next_track->setIcon(QIcon::fromTheme("media-skip-forward"));
action_Play_pause_track->setIcon(playbackPlay);
action_Stop_track->setIcon(QIcon::fromTheme("media-playback-stop"));
action_Load_playlist->setIcon(QIcon::fromTheme("document-open"));
action_Remove_playlist->setIcon(QIcon::fromTheme("edit-delete"));
action_Remove_from_playlist->setIcon(QIcon::fromTheme("list-remove"));
action_Clear_playlist->setIcon(QIcon::fromTheme("edit-clear-list"));
action_Save_playlist->setIcon(QIcon::fromTheme("document-save-as"));
action_Clear_playlist->setIcon(QIcon::fromTheme("edit-clear-list"));
action_Show_playlist->setIcon(QIcon::fromTheme("view-media-playlist"));
action_Update_database->setIcon(QIcon::fromTheme("view-refresh"));
volumeButton->setIcon(QIcon::fromTheme("player-volume"));
connect(Lyrics::self(), SIGNAL(lyrics(const QString &, const QString &, const QString &)),
SLOT(lyrics(const QString &, const QString &, const QString &)));
connect(Covers::self(), SIGNAL(cover(const QString &, const QString &, const QImage &)),
SLOT(cover(const QString &, const QString &, const QImage &)));
connect(Covers::self(), SIGNAL(cover(const QString &, const QString &, const QImage &)),
&musicLibraryModel, SLOT(setCover(const QString &, const QString &, const QImage &)));
playPauseTrackButton->setDefaultAction(action_Play_pause_track);
stopTrackButton->setDefaultAction(action_Stop_track);
nextTrackButton->setDefaultAction(action_Next_track);
prevTrackButton->setDefaultAction(action_Prev_track);
libraryPage->addToPlaylist->setDefaultAction(action_Add_to_playlist);
libraryPage->replacePlaylist->setDefaultAction(action_Replace_playlist);
folderPage->addToPlaylist->setDefaultAction(action_Add_to_playlist);
folderPage->replacePlaylist->setDefaultAction(action_Replace_playlist);
savePlaylistPushButton->setDefaultAction(action_Save_playlist);
removeAllFromPlaylistPushButton->setDefaultAction(action_Clear_playlist);
removeFromPlaylistPushButton->setDefaultAction(action_Remove_from_playlist);
playlistsPage->addToPlaylist->setDefaultAction(action_Add_to_playlist);
playlistsPage->replacePlaylist->setDefaultAction(action_Load_playlist);
playlistsPage->removePlaylist->setDefaultAction(action_Remove_playlist);
randomPushButton->setDefaultAction(action_Random_playlist);
repeatPushButton->setDefaultAction(action_Repeat_playlist);
consumePushButton->setDefaultAction(action_Consume_playlist);
libraryPage->libraryUpdate->setDefaultAction(action_Update_database);
folderPage->libraryUpdate->setDefaultAction(action_Update_database);
playlistsPage->libraryUpdate->setDefaultAction(action_Update_database);
action_Show_playlist->setCheckable(true);
action_Random_playlist->setCheckable(true);
action_Repeat_playlist->setCheckable(true);
action_Consume_playlist->setCheckable(true);
libraryPage->addToPlaylist->setEnabled(false);
libraryPage->replacePlaylist->setEnabled(false);
folderPage->addToPlaylist->setEnabled(false);
folderPage->replacePlaylist->setEnabled(false);
playlistsPage->addToPlaylist->setEnabled(false);
playlistsPage->replacePlaylist->setEnabled(false);
playlistsPage->removePlaylist->setEnabled(false);
#ifdef ENABLE_KDE_SUPPORT
libraryPage->search->setPlaceholderText(i18n("Search library..."));
folderPage->search->setPlaceholderText(i18n("Search files..."));
searchPlaylistLineEdit->setPlaceholderText(i18n("Search playlist..."));
#else
libraryPage->search->setPlaceholderText(tr("Search library..."));
folderPage->search->setPlaceholderText(tr("Search files..."));
searchPlaylistLineEdit->setPlaceholderText(tr("Search playlist..."));
#endif
QList btns;
btns << prevTrackButton << stopTrackButton << playPauseTrackButton << nextTrackButton
<< libraryPage->addToPlaylist << libraryPage->replacePlaylist
<< folderPage->addToPlaylist << folderPage->replacePlaylist << playlistsPage->addToPlaylist
<< playlistsPage->replacePlaylist << playlistsPage->removePlaylist << repeatPushButton << randomPushButton
<< savePlaylistPushButton << removeAllFromPlaylistPushButton << removeFromPlaylistPushButton
<< consumePushButton << libraryPage->libraryUpdate << folderPage->libraryUpdate << playlistsPage->libraryUpdate << volumeButton;
foreach(QToolButton * b, btns) {
b->setAutoRaise(true);
}
#ifdef ENABLE_KDE_SUPPORT
trackLabel->setText(i18n("Stopped"));
#else
trackLabel->setText(tr("Stopped"));
#endif
artistLabel->setText("...");
playlistsProxyModel.setSourceModel(&playlistsModel);
playlistsPage->view->setModel(&playlistsProxyModel);
playlistsPage->view->sortByColumn(0, Qt::AscendingOrder);
playlistsPage->view->addAction(action_Add_to_playlist);
playlistsPage->view->addAction(action_Load_playlist);
playlistsPage->view->addAction(action_Remove_playlist);
playlistsPage->view->addAction(action_Rename_playlist);
libraryPage->view->setHeaderHidden(true);
folderPage->view->setHeaderHidden(true);
playlistsPage->view->setHeaderHidden(true);
action_Show_playlist->setChecked(Settings::self()->showPlaylist());
action_Random_playlist->setChecked(Settings::self()->randomPlaylist());
action_Repeat_playlist->setChecked(Settings::self()->repeatPlaylist());
action_Consume_playlist->setChecked(Settings::self()->consumePlaylist());
mpdDir=Settings::self()->mpdDir();
Lyrics::self()->setMpdDir(mpdDir);
Covers::self()->setMpdDir(mpdDir);
MusicLibraryItemAlbum::setCoverSize((MusicLibraryItemAlbum::CoverSize)Settings::self()->coverSize());
tabWidget->SetMode((FancyTabWidget::Mode)Settings::self()->sidebar());
if (setupTrayIcon() && Settings::self()->useSystemTray())
trayIcon->show();
// Start connection threads
MPDConnection::self()->start();
// Set connection data
MPDConnection::self()->setDetails(Settings::self()->connectionHost(), Settings::self()->connectionPort(), Settings::self()->connectionPasswd());
while (!MPDConnection::self()->connectToMPD()) {
if (!showPreferencesDialog())
exit(EXIT_FAILURE);
MPDConnection::self()->setDetails(Settings::self()->connectionHost(), Settings::self()->connectionPort(), Settings::self()->connectionPasswd());
qWarning("Retrying");
}
togglePlaylist();
setRandom();
setRepeat();
setConsume();
#ifdef ENABLE_KDE_SUPPORT
setupGUI(KXmlGuiWindow::Keys | KXmlGuiWindow::Save | KXmlGuiWindow::Create);
#else
QSize sz=Settings::self()->mainWindowSize();
if (!sz.isEmpty()) {
resize(sz);
}
#endif
coverWidget->installEventFilter(coverEventHandler);
libraryProxyModel.setSourceModel(&musicLibraryModel);
libraryPage->view->setModel(&libraryProxyModel);
libraryPage->view->addAction(action_Add_to_playlist);
libraryPage->view->addAction(action_Replace_playlist);
dirProxyModel.setSourceModel(&dirviewModel);
folderPage->view->setModel(&dirProxyModel);
folderPage->view->addAction(action_Add_to_playlist);
folderPage->view->addAction(action_Replace_playlist);
connect(&playlistsModel, SIGNAL(playlistLoaded()), this, SLOT(startPlayingSong()));
connect(&playlistModel, SIGNAL(filesAddedInPlaylist(const QStringList, const int, const int)), this,
SLOT(addFilenamesToPlaylist(const QStringList, const int, const int)));
connect(&playlistModel, SIGNAL(moveInPlaylist(const QList, const int, const int)), this,
SLOT(movePlaylistItems(const QList, const int, const int)));
connect(&playlistModel, SIGNAL(playListStatsUpdated()), this,
SLOT(updatePlayListStatus()));
playlistProxyModel.setSourceModel(&playlistModel);
playlistTableView->setModel(&playlistProxyModel);
playlistTableView->setAcceptDrops(true);
playlistTableView->setDropIndicatorShown(true);
playlistTableView->addAction(action_Remove_from_playlist);
playlistTableView->addAction(action_Clear_playlist);
playlistTableView->addAction(action_Crop_playlist);
playlistTableView->addAction(action_Shuffle_playlist);
playlistTableView->addAction(action_Copy_song_info);
connect(playlistTableView, SIGNAL(itemsSelected(bool)), SLOT(playlistItemsSelected(bool)));
setupPlaylistViewHeader();
setupPlaylistViewMenu();
connect(MPDConnection::self(), SIGNAL(statsUpdated()), this, SLOT(updateStats()));
connect(MPDConnection::self(), SIGNAL(statusUpdated()), this, SLOT(updateStatus()), Qt::DirectConnection);
connect(MPDConnection::self(), SIGNAL(playlistUpdated(const QList &)), this, SLOT(updatePlaylist(const QList &)));
connect(MPDConnection::self(), SIGNAL(currentSongUpdated(const Song &)), this, SLOT(updateCurrentSong(const Song &)));
connect(MPDConnection::self(), SIGNAL(mpdConnectionDied()), this, SLOT(mpdConnectionDied()));
connect(MPDConnection::self(), SIGNAL(musicLibraryUpdated(MusicLibraryItemRoot *, QDateTime)), &musicLibraryModel, SLOT(updateMusicLibrary(MusicLibraryItemRoot *, QDateTime)));
connect(MPDConnection::self(), SIGNAL(dirViewUpdated(DirViewItemRoot *)), &dirviewModel, SLOT(updateDirView(DirViewItemRoot *)));
#ifndef ENABLE_KDE_SUPPORT
connect(action_Quit, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(action_Preferences, SIGNAL(triggered(bool)), this, SLOT(showPreferencesDialog()));
connect(action_About, SIGNAL(triggered(bool)), this, SLOT(showAboutDialog()));
#endif
connect(action_Update_database, SIGNAL(triggered(bool)), this, SLOT(updateDb()));
connect(action_Prev_track, SIGNAL(triggered(bool)), this, SLOT(previousTrack()));
connect(action_Next_track, SIGNAL(triggered(bool)), this, SLOT(nextTrack()));
connect(action_Play_pause_track, SIGNAL(triggered(bool)), this, SLOT(playPauseTrack()));
connect(action_Stop_track, SIGNAL(triggered(bool)), this, SLOT(stopTrack()));
connect(volumeControl, SIGNAL(valueChanged(int)), SLOT(setVolume(int)));
connect(action_Increase_volume, SIGNAL(triggered(bool)), this, SLOT(increaseVolume()));
connect(action_Decrease_volume, SIGNAL(triggered(bool)), this, SLOT(decreaseVolume()));
connect(action_Increase_volume, SIGNAL(triggered(bool)), volumeControl, SLOT(increaseVolume()));
connect(action_Decrease_volume, SIGNAL(triggered(bool)), volumeControl, SLOT(decreaseVolume()));
connect(positionSlider, SIGNAL(sliderPressed()), this, SLOT(positionSliderPressed()));
connect(positionSlider, SIGNAL(sliderReleased()), this, SLOT(setPosition()));
connect(positionSlider, SIGNAL(sliderReleased()), this, SLOT(positionSliderReleased()));
connect(action_Random_playlist, SIGNAL(activated()), this, SLOT(setRandom()));
connect(action_Repeat_playlist, SIGNAL(activated()), this, SLOT(setRepeat()));
connect(action_Consume_playlist, SIGNAL(activated()), this, SLOT(setConsume()));
connect(libraryPage->search, SIGNAL(returnPressed()), this, SLOT(searchMusicLibrary()));
connect(libraryPage->search, SIGNAL(textChanged(const QString)), this, SLOT(searchMusicLibrary()));
connect(libraryPage->genreCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(searchMusicLibrary()));
connect(folderPage->search, SIGNAL(returnPressed()), this, SLOT(searchDirView()));
connect(folderPage->search, SIGNAL(textChanged(const QString)), this, SLOT(searchDirView()));
connect(searchPlaylistLineEdit, SIGNAL(returnPressed()), this, SLOT(searchPlaylist()));
connect(searchPlaylistLineEdit, SIGNAL(textChanged(const QString)), this, SLOT(searchPlaylist()));
connect(playlistTableView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(playlistItemActivated(const QModelIndex &)));
connect(libraryPage->view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(libraryItemActivated(const QModelIndex &)));
connect(folderPage->view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(dirViewItemActivated(const QModelIndex &)));
connect(action_Add_to_playlist, SIGNAL(activated()), this, SLOT(addToPlaylistItemActivated()));
connect(action_Replace_playlist, SIGNAL(activated()), this, SLOT(replacePlaylist()));
connect(action_Load_playlist, SIGNAL(activated()), this, SLOT(loadPlaylistPushButtonActivated()));
connect(action_Remove_playlist, SIGNAL(activated()), this, SLOT(removePlaylistPushButtonActivated()));
connect(action_Save_playlist, SIGNAL(activated()), this, SLOT(savePlaylistPushButtonActivated()));
connect(action_Remove_from_playlist, SIGNAL(activated()), this, SLOT(removeFromPlaylist()));
connect(action_Rename_playlist, SIGNAL(triggered()), this, SLOT(renamePlaylistActivated()));
connect(action_Clear_playlist, SIGNAL(activated()), this, SLOT(clearPlaylist()));
connect(action_Copy_song_info, SIGNAL(activated()), this, SLOT(copySongInfo()));
connect(action_Crop_playlist, SIGNAL(activated()), this, SLOT(cropPlaylist()));
connect(action_Shuffle_playlist, SIGNAL(activated()), MPDConnection::self(), SLOT(shuffle()));
connect(action_Show_playlist, SIGNAL(activated()), this, SLOT(togglePlaylist()));
connect(&elapsedTimer, SIGNAL(timeout()), this, SLOT(updatePositionSilder()));
connect(&musicLibraryModel, SIGNAL(updateGenres(const QStringList &)), this, SLOT(updateGenres(const QStringList &)));
connect(libraryPage->view, SIGNAL(itemsSelected(bool)), libraryPage->addToPlaylist, SLOT(setEnabled(bool)));
connect(libraryPage->view, SIGNAL(itemsSelected(bool)), libraryPage->replacePlaylist, SLOT(setEnabled(bool)));
connect(folderPage->view, SIGNAL(itemsSelected(bool)), folderPage->addToPlaylist, SLOT(setEnabled(bool)));
connect(folderPage->view, SIGNAL(itemsSelected(bool)), folderPage->replacePlaylist, SLOT(setEnabled(bool)));
connect(playlistsPage->view, SIGNAL(itemsSelected(bool)), playlistsPage->addToPlaylist, SLOT(setEnabled(bool)));
connect(playlistsPage->view, SIGNAL(itemsSelected(bool)), playlistsPage->replacePlaylist, SLOT(setEnabled(bool)));
connect(playlistsPage->view, SIGNAL(itemsSelected(bool)), playlistsPage->removePlaylist, SLOT(setEnabled(bool)));
connect(volumeButton, SIGNAL(clicked()), SLOT(showVolumeControl()));
connect(playlistsPage->addToPlaylist, SIGNAL(clicked(bool)), this, SLOT(addPlaylistToPlaylistPushButtonActivated()));
connect(playlistsPage->view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(playlistsViewItemDoubleClicked(const QModelIndex &)));
connect(MPDConnection::self(), SIGNAL(storedPlayListUpdated()), this, SLOT(updateStoredPlaylists()));
elapsedTimer.setInterval(1000);
splitter->restoreState(Settings::self()->splitterState());
connect(MPDConnection::self(), SIGNAL(outputsUpdated(const QList