Beispiel #1
0
void PlayListWidget::update(QString message)
{
    if (message.compare("PlayListUpdate") == 0) {
        setPlayList(MpdCommand::getInstance()->getPlaylist());
    }
    else if (message.compare("CurrentSongUpdate") == 0) {
        //Song *newCurrent = playList->getCurrentSong();

        //QList<const Song*> songs = playList->getSongs();
        //const Song *newCurrent = songs.at(2);

        songList->clearSelection();
        //songList->item(newCurrent->getPosition())->setSelected(true);
        //qDebug() << songList->item(3)->text();

        /*
          QList<QListWidgetItem *> findResult =
          songList->findItems(newCurrent->getFile(),Qt::MatchFlags());
          int size = findResult.count();
          for (int i=0; i < size; i++) {
          QListWidgetItem *matchItem = findResult.at(i);
          matchItem->setSelected(true);
          }
        */
    }
}
Beispiel #2
0
bool JukeboxDS::setPlayList( const char * pName, bool bSwitchNow /*= false*/ )
{
	int n = findPlayList( pName );
	if ( n >= 0 )
		return setPlayList( n, bSwitchNow );

	return false;
}
Beispiel #3
0
void PlayListWidget::init()
{
    songList = ui->songListWidget;
    setPlayList(MpdCommand::getInstance()->getPlaylist());
}
Beispiel #4
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    qDebug()<<QApplication::applicationVersion();
    music = new MusicControl;
    netCore = new NetWorker;
    settings = new QSettings(this);
    settingsWindow = new PrefWindow(this);
    settingsWindow->setWindowFlags(Qt::Dialog);
    ui->lineEdit->setPlaceholderText("Search here");
    ui->seekSlider->setRange(0,0);
    ui->repeatButton->hide();
    isUnity = false;

    ///tray icon setup
    QAction *next = new QAction(tr("Next"),this);
    QAction *restore = new QAction(tr("Show window"),this);
    QAction *prev = new QAction(tr("Previous"),this);
    QAction *playPause = new QAction(tr("Play/Pause"),this);
    QAction *close = new QAction(tr("Exit"),this);
    connect(next,SIGNAL(triggered()),music,SLOT(playNextSong()));
    connect(prev,SIGNAL(triggered()),music,SLOT(playPrevSong()));
    connect(playPause,SIGNAL(triggered()),music,SLOT(changeState()));
    connect(close,SIGNAL(triggered()),qApp,SLOT(quit()));
    connect(restore,SIGNAL(triggered()),this,SLOT(show()));
    QMenu *trayIconMenu = new QMenu(this);
    trayIconMenu->addAction(restore);
    trayIconMenu->addAction(next);
    trayIconMenu->addAction(prev);
    trayIconMenu->addAction(playPause);
    trayIconMenu->addAction(close);
    trayIcon = new QSystemTrayIcon(QIcon(":/icons/qvk.svg"));
    trayIcon->setContextMenu(trayIconMenu);
    connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,
            SLOT(trayHandler(QSystemTrayIcon::ActivationReason)));
    //trayIcon->setVisible(true);
    //trayIcon->show();


    ///table setting
    QStringList header;
    ui->musicWidget->setColumnCount(4);
    header <<"Artist"<<"Title"<<"Duration"<<"link";   //in case of unsuccesseful update....
    ui->musicWidget->hideColumn(3);
    ui->musicWidget->setHorizontalHeaderLabels(header);
    ui->musicWidget->verticalHeader()->setVisible(false);
    ui->musicWidget->setShowGrid(false);
    ui->musicWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    ui->musicWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
    ui->musicWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
    ui->musicWidget->setSelectionMode(QAbstractItemView::SingleSelection);

    ////////////////////////////////////////////////Creating actions
    QAction *login = new QAction(tr("Login"),this);
    QAction *About = new QAction(tr("About"),this);
    QAction *refrsh = new QAction(tr("Refresh"),this);
    QAction *showSettingsWindow = new QAction(tr("Settings"),this);
    connect(showSettingsWindow, SIGNAL(triggered()),settingsWindow,SLOT(show()));
    connect(refrsh,SIGNAL(triggered()), netCore, SLOT(getAudioList()));
    connect(login, SIGNAL(triggered()), netCore, SLOT(loginSlot()));
    connect(About, SIGNAL(triggered()), this, SLOT(about()));
    ////////////////////////////////////////////////Creating menu
    QMenu *gearButtonMenu = new QMenu("Options", ui->toolButton);
    gearButtonMenu->addAction(refrsh);
    gearButtonMenu->addAction(login);
    gearButtonMenu->addAction(showSettingsWindow);
    gearButtonMenu->addSeparator();
    gearButtonMenu->addAction(About);
    gearButtonMenu->addAction(close);
    ///////////////////////////////////////////////making menu button
    ui->toolButton->setMenu(gearButtonMenu);

    ///connection area
    connect(this,SIGNAL(setPlayingOrder(QList<QUrl>)),music,SLOT(setPlayList(QList<QUrl>)));
    connect(ui->volumeSlider,SIGNAL(valueChanged(int)),music,SLOT(volumeSliderSlot(int)));
    connect(ui->musicWidget,SIGNAL(cellDoubleClicked(int,int)),music,SLOT(playThatSong(int,int)));
    connect(ui->shuffButton,SIGNAL(toggled(bool)),music,SLOT(shuffleMode(bool)));
    connect(ui->nextButton,SIGNAL(clicked()),music,SLOT(playNextSong()));
    connect(music,SIGNAL(setIndexToUi(int,int)),this,SLOT(setSongUi(int,int)));
    connect(ui->prevButton,SIGNAL(clicked()),music,SLOT(playPrevSong()));
    connect(ui->tooglePlayingButton,SIGNAL(clicked()),music,SLOT(changeState()));
    connect(music,SIGNAL(setPlayingUi()),this,SLOT(setPlayingUi()));
    connect(music,SIGNAL(setPausedUi()),this,SLOT(setPausedUi()));
    connect(ui->seekSlider,SIGNAL(sliderMoved(int)),music,SLOT(setPosition(int)));
    connect(music,SIGNAL(newPosition(qint64)),this,SLOT(positionChanged(qint64)));
    connect(music,SIGNAL(newRange(qint64)),this,SLOT(durationChanged(qint64)));
    connect(ui->lineEdit,SIGNAL(textChanged(QString)),this,SLOT(currentSearch(QString)));
    connect(this,SIGNAL(loadToken(QString,QString)),netCore,SLOT(setToken(QString,QString)));
    connect(netCore,SIGNAL(audioListGet(QList<QUrl>)),music,SLOT(setPlayList(QList<QUrl>)));
    connect(ui->musicWidget,SIGNAL(cellClicked(int,int)),music,SLOT(setSelectedSong(int,int)));
    connect(ui->repeatButton,SIGNAL(clicked(bool)),music,SLOT(repeatMode(bool)));
    connect(netCore,SIGNAL(dataGot()),this,SLOT(setMusicTable()));
    connect(this,SIGNAL(setPrefWindowsHotkeysUi(bool,bool)),settingsWindow,SLOT(setUseHotkeysUi(bool,bool)));
    connect(this,SIGNAL(setMinToTray(bool)),settingsWindow,SLOT(setUseMinTray(bool)));
    connect(settingsWindow,SIGNAL(setNewSettings(bool,bool,bool,QString,bool)),
            this,SLOT(setNewSettings(bool,bool,bool,QString,bool)));
    ///connection area



    ///DBUS setting
#ifdef Q_OS_LINUX
    DBusMethods* demo = new DBusMethods();
    new DBusAdaptor(demo);
    new DBusAdaptor1(demo);

    QDBusConnection connection = QDBusConnection::sessionBus();
    bool ret = connection.registerService("org.mpris.MediaPlayer2.qvkplayer.mainwindow");
    ret = connection.registerObject("/org/mpris/MediaPlayer2", demo);
    connect(demo,SIGNAL(dbusNext()),ui->nextButton,SIGNAL(clicked()));
    connect(demo,SIGNAL(dbusPlayPause()),ui->tooglePlayingButton,SIGNAL(clicked()));
    connect(demo,SIGNAL(dbusPrev()),ui->prevButton,SIGNAL(clicked()));
    connect(demo,SIGNAL(dbusQuit()),qApp,SLOT(quit()));
    connect(demo,SIGNAL(dbusRaise()),this,SLOT(show()));
#endif

    ///DBUS setting



    ///CONFIG LOADING==================================
    this->loadSettings();
}