Example #1
0
void MainWindow::mkconnections()
{
    connect(bar,SIGNAL(closeClicked()),SLOT(close()));
    connect(bar,SIGNAL(maximizeClicked(bool)),SLOT(showWind(bool)));
    connect(bar,SIGNAL(hideClicked()),SLOT(showMinimized()));
    connect(playlists,SIGNAL(songAdded(QString,QString)),&library,SLOT(addSongInPlaylist(QString,QString)));
    connect(bar,SIGNAL(addFilePressed()),SLOT(addFiles()));
    connect(bar,SIGNAL(addFolderPressed()),SLOT(addFolder()));
    connect(&player,SIGNAL(inPlaylist(bool)),SLOT(changePlayerConnections(bool)));
    connect(&library,SIGNAL(newSong(Song)),table,SLOT(addSongInList(Song)));
    connect(&player,SIGNAL(positionChanged(qint64)),bar,SIGNAL(seekChanged(qint64)));
    connect(&player,SIGNAL(currentSongChanged(Song)),bar,SIGNAL(songChanged(Song)));
    connect(bar,SIGNAL(playClicked()),&player,SLOT(playpause()));
    connect(addFile,SIGNAL(triggered()),SLOT(addFiles()));
    connect(actionAddFolder,SIGNAL(triggered()),SLOT(addFolder()));
    connect(actionOuvrir,SIGNAL(triggered()),SLOT(openFile()));
    connect(bar,SIGNAL(volumeChanged(int)),&player,SLOT(setVolume(int)));
    connect(bar,SIGNAL(positionChanged(int)),&player,SLOT(setPosition(int)));
    connect(bar,SIGNAL(seekBarPressed()),&player,SLOT(pause()));
    connect(bar,SIGNAL(seekBarReleased()),&player,SLOT(play()));
    connect(&player,SIGNAL(playbackStateChanged(bool)),bar,SLOT(changeButton(bool)));
    connect(tree,SIGNAL(albumChosen(QString,QString)),table,SLOT(showSongsFrom(QString,QString)));
    connect(tree,SIGNAL(artistChosen(QString)),table,SLOT(showSongsBy(QString)));
    connect(&library,SIGNAL(libraryChanged(Library*)),tree,SLOT(updateTree(Library*)));
    connect(table,SIGNAL(newPlaylist(Song)),this,SLOT(mkPlaylist(Song)));
    connect(playlists,SIGNAL(playlistChosen(QString)),table,SLOT(showSongsIn(QString)));
    connect(table,SIGNAL(deleteSong(Song,bool)),&library,SLOT(deleteSong(Song,bool)));
    connect(bar,SIGNAL(newQuery(QString,int)),table,SLOT(setQuery(QString,int)));
    connect(bar,SIGNAL(newPlaybackMode(QMediaPlaylist::PlaybackMode)),&player,SLOT(setPlayBackMode(QMediaPlaylist::PlaybackMode)));
    connect(table,SIGNAL(songChosen(int)),&player,SLOT(play(int)));
    connect(table,SIGNAL(newSongList(SongList)),&player,SLOT(update(SongList)));
    connect(&player,SIGNAL(inPlaylist(bool)),bar,SLOT(enableNavigation(bool)));
    connect(bar,SIGNAL(miniLecteur()),&mLecteur,SLOT(show()));
    connect(bar,SIGNAL(miniLecteur()),SLOT(hide()));
    connect(&mLecteur,SIGNAL(windowedMode()),SLOT(show()));
    connect(&mLecteur,SIGNAL(positionChanged(int)),bar,SIGNAL(positionChanged(int)));
    connect(&mLecteur,SIGNAL(seekBarPressed()),bar,SIGNAL(seekBarPressed()));
    connect(&mLecteur,SIGNAL(seekBarReleased()),bar,SIGNAL(seekBarReleased()));
    connect(&mLecteur,SIGNAL(positionChanged(int)),bar,SIGNAL(positionChanged(int)));
    connect(&mLecteur,SIGNAL(playClicked()),bar,SIGNAL(playClicked()));
    connect(&mLecteur,SIGNAL(nextClicked()),bar,SIGNAL(nextClicked()));
    connect(&mLecteur,SIGNAL(previousClicked()),bar,SIGNAL(previousClicked()));
    connect(&mLecteur,SIGNAL(volumeChanged(int)),bar,SIGNAL(volumeChanged(int)));
    connect(&player,SIGNAL(currentSongChanged(Song)),&mLecteur,SLOT(setNewSong(Song)));
    connect(&player,SIGNAL(positionChanged(qint64)),&mLecteur,SLOT(setPosition(qint64)));
    connect(&player,SIGNAL(playbackStateChanged(bool)),&mLecteur,SLOT(changeButton(bool)));
    connect(&player,SIGNAL(indexChanged(int,int)),table,SLOT(setIconTo(int,int)));
    connect(table,SIGNAL(addFileTriggered()),SLOT(addFiles()));
    connect(table,SIGNAL(addFolderTriggered()),SLOT(addFolder()));

}
Example #2
0
PlayerWidget::PlayerWidget(QWidget *parent) : QWidget(parent), ui(new Ui::PlayerWidget()){
  ui->setupUi(this); //load the designer form
  PLAYER = new QMediaPlayer(this);
    PLAYER->setVolume(100);
    PLAYER->setNotifyInterval(1000); //1 second interval (just needs to be a rough estimate)
  PLAYLIST = new QMediaPlaylist(this);
    PLAYLIST->setPlaybackMode(QMediaPlaylist::Sequential);
    PLAYER->setPlaylist(PLAYLIST);
	
  configMenu = new QMenu(this);
    ui->tool_config->setMenu(configMenu);
  addMenu = new QMenu(this);
    ui->tool_add->setMenu(addMenu);
	
  updatinglists = false; //start off as false
	
  LoadIcons();
  playerStateChanged(); //update button visibility
  currentSongChanged();
  //Connect all the signals/slots
  //connect(infoTimer, SIGNAL(timeout()), this, SLOT(rotateTrackInfo()) );
  connect(PLAYER, SIGNAL(positionChanged(qint64)),this, SLOT(updateProgress(qint64)) );
  connect(PLAYER, SIGNAL(durationChanged(qint64)), this, SLOT(updateMaxProgress(qint64)) );
  connect(PLAYLIST, SIGNAL(mediaChanged(int, int)), this, SLOT(playlistChanged()) );
  connect(PLAYER, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(playerStateChanged()) );
  connect(PLAYLIST, SIGNAL(currentMediaChanged(const QMediaContent&)), this, SLOT(currentSongChanged()) );
  connect(ui->combo_playlist, SIGNAL(currentIndexChanged(int)), this, SLOT(userlistSelectionChanged()) );
  connect(ui->tool_play, SIGNAL(clicked()), this, SLOT(playClicked()) );
  connect(ui->tool_pause, SIGNAL(clicked()), this, SLOT(pauseClicked()) );
  connect(ui->tool_stop, SIGNAL(clicked()), this, SLOT(stopClicked()) );
  connect(ui->tool_next, SIGNAL(clicked()), this, SLOT(nextClicked()) );
  connect(ui->tool_prev, SIGNAL(clicked()), this, SLOT(prevClicked()) );
  
}
Example #3
0
PlayMusicWindow::PlayMusicWindow(QWidget *parent, PlaylistHandler *plh, API *api, CoverHelper *coverHelper, QMainWindow* mainWindow, Player *player) :
    QMainWindow(parent),
    ui(new Ui::PlayMusicWindow)
{
    timer = new QTimer(this);
    timer->setInterval(1000);
    timer->setSingleShot(true);
    currCurrentCover = "";
    nextCurrentCover = "";
    prevCurrentCover = "";
    connect(timer, SIGNAL(timeout()), this, SLOT(timerDone()));
    posSliderMoving = false;
    this->realMainWindow = mainWindow;
    this->plh = plh;
    this->api = api;
    this->player = player;
    this->apb = new AudioPlayerBridge(realMainWindow);
    this->coverHelper = coverHelper;
    int volume = player->getVolume();
    ui->setupUi(this);
    this->setWindowFlags(this->windowFlags() & ~(Qt::WindowFullscreenButtonHint));
    messageHandler = new MessageHandler(this);
    QRect geometry = QApplication::desktop()->screenGeometry();
    this->setGeometry((geometry.width() - this->width()) / 2, (geometry.height() - this->height()) / 2, this->width(), this->height());
    ui->sldVolume->setStyle(new MyVolumeStyle);
    ui->sldVolume->setValue(volume);
    ui->sldPosition->setStyle(new MyVolumeStyle);
    this->setAttribute(Qt::WA_QuitOnClose, false);
    this->setAttribute(Qt::WA_DeleteOnClose);
    this->setFixedSize(this->size());
    playlistsRefreshing = false;
    QWidget* shadowArray[] = {ui->lblPlayMusic, ui->lblPlayedPlaylist};
    int count = sizeof(shadowArray) / sizeof(QWidget*);
    for (int i = 0; i < count; i++) {
        QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect(shadowArray[i]);
        effect->setBlurRadius(1);
        effect->setColor(QColor("#bb6008"));
        effect->setOffset(0, 1);
        shadowArray[i]->setGraphicsEffect(effect);
    }

    QWidget* clickthruArray[] = {};
    count = sizeof(clickthruArray) / sizeof(QWidget*);
    for (int i = 0; i < count; i++) {
        clickthruArray[i]->setAttribute(Qt::WA_TransparentForMouseEvents);
    }
    connect(player, SIGNAL(playlistsChanged(std::vector<std::string>)), this, SLOT(playlistsChanged(std::vector<std::string>)));
    connect(player, SIGNAL(currentSongChanged()), this, SLOT(songsChanged()));
    connect(player, SIGNAL(songPositionChanged()), this, SLOT(onPositionChanged()));
    connect(player, SIGNAL(stateChanged()), this, SLOT(refreshPlayPause()));
    connect(coverHelper, SIGNAL(coverGotten(std::string)), this, SLOT(gotCover(std::string)), Qt::DirectConnection);
    connect(messageHandler, SIGNAL(addedMessage(Message*)), this, SLOT(addedMessage(Message*)));
    connect(messageHandler, SIGNAL(removedMessage(Message*)), this, SLOT(deletedMessage(Message*)));
    connect(player, SIGNAL(songFailed()), this, SLOT(songFailed()));
    playlistsChanged(plh->getPlaylists());
    songsChanged();
    refreshPlayPause();
    wasPlaying = player->isPlaying() || player->isPaused();
}
Example #4
0
LyricWidget::LyricWidget(QWidget *parent) :
    QWidget(parent), ui(new Ui_LyricWidget),
    animWidget(nullptr),
    firstShowing(false),
    lyricGetter(new LyricGetter(this)),
    isShowing(false), haveSearchedLyric(false), saveTick(0)
{
    ui->setupUi(this);
    ui->border->setText(QString("<font color='grey'>") + tr("无歌词") + QString("</font>"));
    ui->bg->lower();

    connect(&DoubanPlayer::getInstance(), SIGNAL(positionChanged(qint64)),
            this, SLOT(setTick(qint64)));
    connect(lyricGetter, &LyricGetter::gotLyric, [this] (const QLyricList& lyric) {
        this->setLyric(lyric);
    });
    connect(lyricGetter, &LyricGetter::gotLyricError, [this] (const QString&) {
        this->clear();
    });
    connect(&DoubanPlayer::getInstance(), SIGNAL(currentSongChanged(DoubanFMSong)),
            this, SLOT(setSong(DoubanFMSong)));
}