Пример #1
0
void SinglePlayerView::onDataError( int code, const QString& description )
{
	showMsg( description );
	emit gameOver();
	QTimer::singleShot( 10, this, SLOT( hideLoading() ) );
	qDebug() << "Loading error" << code << ":" << description;
}
Пример #2
0
void SinglePlayerView::onDataSuccess()
{
	QTimer::singleShot( 10, this, SLOT( hideLoading() ) );
	isloading = false;
	emit levelLoaded();
	qDebug() << "Data loading success";
}
Пример #3
0
Playlist::Playlist(PlaylistWidget::ListTypes listType, QString title, quint64 hash, QObject *parent) :
    QObject(parent)
{
    m_listType = listType;
    m_sTitle = title;
    m_bCustomTitle = false;

    m_Settings = Settings::instance();
    connect(m_Settings, SIGNAL(changed()), SLOT(onSettingsChanged()));

    m_bLoadingState = false;
    m_bShuffleList = m_Settings->getValue("player/shuffle").toInt() > 1 ? true : false;

    m_LastTrack = 0;

    m_bLoadMeta = false;
    m_bUseMeta = false;

    m_bTitleByContent = m_Settings->getValue("playlist/tabs_by_content").toBool();

    m_Auth = Auth::instance();
    connect(m_Auth, SIGNAL(authComplete()), SLOT(update()));


    // Set hash
    if(hash == 0) {
        QDateTime *time = new QDateTime(QDateTime::currentDateTime());
        m_Hash = time->toMSecsSinceEpoch();
        m_bNewly = true;
    } else {
        m_Hash = hash;
        m_bNewly = false;
    }

    // Create playlist widget
    m_listWidget = new PlaylistWidget(m_listType);
    connect(this, SIGNAL(trackAdded()), m_listWidget, SLOT(trackAdded()));
    connect(m_listWidget, SIGNAL(trackActivate(Track*)), SLOT(trackActivate(Track*)));

    // Connect key events
    connect(m_listWidget, SIGNAL(skQueue()), SLOT(addToQueue()));
    connect(m_listWidget, SIGNAL(skRemove()), SLOT(removeTrack()));
    connect(m_listWidget, SIGNAL(skDownload()), SLOT(downloadTrack()));

    // Create object of parser
    m_Parser = new Parser(this);
    connect(m_Parser, SIGNAL(newTrack(Track*)), SLOT(addTrack(Track*)));
    connect(m_Parser, SIGNAL(busy()), SLOT(parserBusy()));
    connect(m_Parser, SIGNAL(free()), SLOT(parserFree()));
    connect(m_Parser, SIGNAL(savePlaylist()), SLOT(save()));
    connect(m_Parser, SIGNAL(busy()), m_listWidget, SLOT(showLoading()));
    connect(m_Parser, SIGNAL(free()), m_listWidget, SLOT(hideLoading()));

    // Create actions parser
    m_vkActions = VkActions::instance();
    connect(m_vkActions, SIGNAL(message(QString,QString)), SIGNAL(message(QString,QString)));

    switch(m_listType) {
        case PlaylistWidget::Search:
            connect(m_listWidget, SIGNAL(searchChanged(QString)), SLOT(searchChanged(QString)));
            connect(m_listWidget, SIGNAL(loadMore()), m_Parser, SLOT(loadMoreResults()));
        break;
        case PlaylistWidget::AudioLib:
            connect(m_listWidget->friendsList(), SIGNAL(friendSelected(QString,QString,QString)), SLOT(librarySelected(QString,QString,QString)));
            connect(m_listWidget, SIGNAL(refresh()), SLOT(refresh()));
        break;
        case PlaylistWidget::Suggestions:
            connect(m_listWidget, SIGNAL(loadMore()), m_Parser, SLOT(loadMoreResults()));
            connect(m_listWidget, SIGNAL(refresh()), SLOT(refresh()));
        break;
        case PlaylistWidget::DbSearch:
            connect(m_listWidget, SIGNAL(searchChanged(QString)), SLOT(searchChanged(QString)));
            connect(m_listWidget, SIGNAL(newTrack(Track*)), SLOT(addTrack(Track*)));
            connect(m_listWidget, SIGNAL(clearList()), SLOT(clearList()));
        break;
    }

    m_Model = new QStandardItemModel(this);

    m_ProxyModel = new QSortFilterProxyModel(this);
    m_ProxyModel->setSourceModel(m_Model);
    m_ProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
    m_ProxyModel->setFilterKeyColumn(2);

    m_listWidget->setModel(m_ProxyModel);

    connect(m_listWidget, SIGNAL(listSearchChanged(QString)), SLOT(setListSearch(QString)));

    createMenus();

    load();

    if(type() == PlaylistWidget::AudioLib &&
       m_bNewly &&
       m_Settings->getValue("playlist/autoload_library").toBool()
       )
        librarySelected(m_Auth->vkId(), "0", tr("My Library"));

    // Actions on newly created plalylists
    if(m_bNewly) {
        switch(m_listType) {
            case PlaylistWidget::Search:
                m_listWidget->focusOnSearch();
            break;
            case PlaylistWidget::AudioLib:
            if(m_Settings->getValue("playlist/autoload_library").toBool())
                librarySelected(m_Auth->vkId(), "0", tr("My Library"));
            break;
            case PlaylistWidget::Suggestions:
                refresh();
            break;
            case PlaylistWidget::DbSearch:
                // Unused
            break;
        }
    }
}