void AssetsManager::update()
{
    if (!_localManifest->isLoaded())
    {
        CCLOG("AssetsManager : No local manifest file found error.\n");
        dispatchUpdateEvent(EventAssetsManager::EventCode::ERROR_NO_LOCAL_MANIFEST);
        return;
    }

    _waitToUpdate = true;

    switch (_updateState) {
        case State::UNCHECKED:
        {
            _updateState = State::PREDOWNLOAD_VERSION;
        }
        case State::PREDOWNLOAD_VERSION:
        {
            downloadVersion();
        }
            break;
        case State::VERSION_LOADED:
        {
            parseVersion();
        }
            break;
        case State::PREDOWNLOAD_MANIFEST:
        {
            downloadManifest();
        }
            break;
        case State::MANIFEST_LOADED:
        {
            parseManifest();
        }
            break;
        case State::FAIL_TO_UPDATE:
        case State::NEED_UPDATE:
        {
            // Manifest not loaded yet
            if (!_remoteManifest->isLoaded())
            {
                _waitToUpdate = true;
                _updateState = State::PREDOWNLOAD_MANIFEST;
                downloadManifest();
            }
            else
            {
                startUpdate();
            }
        }
            break;
        case State::UP_TO_DATE:
        case State::UPDATING:
            _waitToUpdate = false;
            break;
        default:
            break;
    }
}
void AssetsManager::checkUpdate()
{
    if (!_localManifest->isLoaded())
    {
        CCLOG("AssetsManager : No local manifest file found error.\n");
        dispatchUpdateEvent(EventAssetsManager::EventCode::ERROR_NO_LOCAL_MANIFEST);
        return;
    }

    switch (_updateState) {
        case State::UNCHECKED:
        case State::PREDOWNLOAD_VERSION:
        {
            downloadVersion();
        }
            break;
        case State::UP_TO_DATE:
        {
            dispatchUpdateEvent(EventAssetsManager::EventCode::ALREADY_UP_TO_DATE);
        }
            break;
        case State::FAIL_TO_UPDATE:
        case State::NEED_UPDATE:
        {
            dispatchUpdateEvent(EventAssetsManager::EventCode::NEW_VERSION_FOUND);
        }
            break;
        default:
            break;
    }
}
Exemple #3
0
void NPlayer::loadSettings()
{
	m_systemTray->setVisible(m_settings->value("TrayIcon").toBool());

#ifndef _N_NO_UPDATE_CHECK_
	if (m_settings->value("AutoCheckUpdates").toBool())
		downloadVersion();
#endif

	m_showCoverAction->setChecked(m_settings->value("ShowCoverArt").toBool());
	if (m_coverWidget)
		m_coverWidget->setEnabled(m_settings->value("ShowCoverArt").toBool());

	m_alwaysOnTopAction->setChecked(m_settings->value("AlwaysOnTop").toBool());
	m_playingOnTopAction->setChecked(m_settings->value("WhilePlayingOnTop").toBool());
	m_loopPlaylistAction->setChecked(m_settings->value("LoopPlaylist").toBool());
	m_nextFileEnableAction->setChecked(m_settings->value("LoadNext").toBool());

	QDir::SortFlag flag = (QDir::SortFlag)m_settings->value("LoadNextSort").toInt();
	if (flag == (QDir::Name))
		m_nextFileByNameAscdAction->setChecked(true);
	else if (flag == (QDir::Name | QDir::Reversed))
		m_nextFileByNameDescAction->setChecked(true);
	else if (flag == (QDir::Time | QDir::Reversed))
		m_nextFileByDateAscd->setChecked(true);
	else if (flag == (QDir::Time))
		m_nextFileByDateDesc->setChecked(true);
	else
		m_nextFileByNameAscdAction->setChecked(true);

	m_playbackEngine->setVolume(m_settings->value("Volume").toFloat());
}
Exemple #4
0
NPlayer::NPlayer()
{
	qsrand((uint)QTime::currentTime().msec());
	m_settings = NSettings::instance();

	NI18NLoader::init();

	m_playbackEngine = dynamic_cast<NPlaybackEngineInterface *>(NPluginLoader::getPlugin(N::PlaybackEngine));
	m_playbackEngine->setParent(this);

#ifndef _N_NO_SKINS_
	m_mainWindow = new NMainWindow(NSkinLoader::skinUiFormFile());
#else
	m_mainWindow = new NMainWindow();
#endif

	// loading skin script
	m_scriptEngine = new NScriptEngine(this);
#ifndef _N_NO_SKINS_
	QString scriptFileName(NSkinLoader::skinScriptFile());
#else
	QString scriptFileName(":skins/native/script.js");
#endif
	QFile scriptFile(scriptFileName);
	scriptFile.open(QIODevice::ReadOnly);
	m_scriptEngine->evaluate(scriptFile.readAll(), scriptFileName);
	scriptFile.close();
	QScriptValue skinProgram = m_scriptEngine->evaluate("Main").construct();

	m_aboutDialog = NULL;
	m_logDialog = new NLogDialog(m_mainWindow);
	m_preferencesDialog = new NPreferencesDialog(m_mainWindow);
	m_volumeSlider = qFindChild<NVolumeSlider *>(m_mainWindow, "volumeSlider");
	m_coverWidget = qFindChild<QWidget *>(m_mainWindow, "coverWidget");

	m_playlistWidget = qFindChild<NPlaylistWidget *>(m_mainWindow, "playlistWidget");
	if (QAbstractButton *repeatButton = qFindChild<QAbstractButton *>(m_mainWindow, "repeatButton"))
		repeatButton->setChecked(m_playlistWidget->repeatMode());

	m_trackInfoWidget = new NTrackInfoWidget();
	QVBoxLayout *trackInfoLayout = new QVBoxLayout;
	trackInfoLayout->setContentsMargins(0, 0, 0, 0);
	trackInfoLayout->addWidget(m_trackInfoWidget);
	m_waveformSlider = qFindChild<NWaveformSlider *>(m_mainWindow, "waveformSlider");
	m_waveformSlider->setLayout(trackInfoLayout);

#ifndef _N_NO_UPDATE_CHECK_
	m_versionDownloader = new QNetworkAccessManager(this);
	connect(m_versionDownloader, SIGNAL(finished(QNetworkReply *)), this, SLOT(on_versionDownloader_finished(QNetworkReply *)));
	connect(m_preferencesDialog, SIGNAL(versionRequested()), this, SLOT(downloadVersion()));
#endif

	createActions();
	loadSettings();
	connectSignals();

#ifdef Q_WS_WIN
	NW7TaskBar::instance()->setWindow(m_mainWindow);
	NW7TaskBar::instance()->setEnabled(NSettings::instance()->value("TaskbarProgress").toBool());
	connect(m_playbackEngine, SIGNAL(positionChanged(qreal)), NW7TaskBar::instance(), SLOT(setProgress(qreal)));
#endif

#ifdef Q_WS_MAC
	NMacDock::instance()->registerClickHandler();
	connect(NMacDock::instance(), SIGNAL(clicked()), m_mainWindow, SLOT(show()));
#endif

	m_mainWindow->setTitle(QCoreApplication::applicationName() + " " + QCoreApplication::applicationVersion());
	m_mainWindow->show();
	m_mainWindow->loadSettings();
	QResizeEvent e(m_mainWindow->size(), m_mainWindow->size());
	QCoreApplication::sendEvent(m_mainWindow, &e);

	skinProgram.property("afterShow").call(skinProgram);
}
void AssetsManagerEx::update()
{
    if (_updateEntry != UpdateEntry::NONE)
    {
        CCLOGERROR("AssetsManagerEx::update, updateEntry isn't NONE");
        return;
    }

    if (!_inited){
        CCLOG("AssetsManagerEx : Manifests uninited.\n");
        dispatchUpdateEvent(EventAssetsManagerEx::EventCode::ERROR_NO_LOCAL_MANIFEST);
        return;
    }
    if (!_localManifest->isLoaded())
    {
        CCLOG("AssetsManagerEx : No local manifest file found error.\n");
        dispatchUpdateEvent(EventAssetsManagerEx::EventCode::ERROR_NO_LOCAL_MANIFEST);
        return;
    }

    _updateEntry = UpdateEntry::DO_UPDATE;

    switch (_updateState) {
        case State::UNCHECKED:
        {
            _updateState = State::PREDOWNLOAD_VERSION;
        }
        case State::PREDOWNLOAD_VERSION:
        {
            downloadVersion();
        }
            break;
        case State::VERSION_LOADED:
        {
            parseVersion();
        }
            break;
        case State::PREDOWNLOAD_MANIFEST:
        {
            downloadManifest();
        }
            break;
        case State::MANIFEST_LOADED:
        {
            parseManifest();
        }
            break;
        case State::FAIL_TO_UPDATE:
        case State::NEED_UPDATE:
        {
            // Manifest not loaded yet
            if (!_remoteManifest->isLoaded())
            {
                _updateState = State::PREDOWNLOAD_MANIFEST;
                downloadManifest();
            }
            else
            {
                startUpdate();
            }
        }
            break;
        case State::UP_TO_DATE:
        case State::UPDATING:
        case State::UNZIPPING:
            _updateEntry = UpdateEntry::NONE;
            break;
        default:
            break;
    }
}