// Track item of a list ListTrackItem::ListTrackItem(int index, QSpotifyTrack & track) : ListItem(index), m_track(track), m_offline(track.offlineStatus() == QSpotifyTrack::Yes), m_dimmed(getDimmed()) { connect(&m_track, SIGNAL(offlineStatusChanged()), this, SLOT(trackOfflineStatusChanged())); connect(QSpotifySession::instance(), SIGNAL(offlineModeChanged()), this, SLOT(offlineModeChanged())); }
void QSpotifySession::setOfflineMode(bool on, bool forced) { qDebug() << "QSpotifySession::setOfflineMode" << on << forced; if (m_offlineMode == on) return; m_offlineMode = on; if (m_offlineMode && m_currentTrack && !m_currentTrack->isAvailableOffline()) stop(); if (!forced) { settings.setValue("offlineMode", m_offlineMode); if (m_offlineMode) m_ignoreNextConnectionError = true; } m_forcedOfflineMode = forced && on; setConnectionRules(on ? m_connectionRules & ~AllowNetwork : m_connectionRules | AllowNetwork); emit offlineModeChanged(); }
void ClientPlugin::setOfflineMode( bool offlineMode ) { if( offlineMode != mOfflineMode ) { mOfflineMode = offlineMode; offlineModeChanged( mOfflineMode ); } }
void Settings::setOfflineMode(bool value) { #ifdef KAKTUS_LIGHT return; #else if (getOfflineMode() != value) { settings.setValue("offlinemode", value); emit offlineModeChanged(); } #endif }
QSpotifyPlaylistContainer::QSpotifyPlaylistContainer(sp_playlistcontainer *container) : QSpotifyObject(true) , m_updateEventPosted(false) { m_container = container; g_containerObjects.insert(container, this); m_callbacks = new sp_playlistcontainer_callbacks; m_callbacks->container_loaded = callback_container_loaded; m_callbacks->playlist_added = callback_playlist_added; m_callbacks->playlist_moved = callback_playlist_moved; m_callbacks->playlist_removed = callback_playlist_removed; sp_playlistcontainer_add_callbacks(m_container, m_callbacks, 0); connect(QSpotifySession::instance(), SIGNAL(offlineModeChanged()), this, SLOT(updatePlaylists())); metadataUpdated(); }
void QSpotifySession::init() { memset(&m_sp_callbacks, 0, sizeof(m_sp_callbacks)); m_sp_callbacks.logged_in = callback_logged_in; m_sp_callbacks.logged_out = callback_logged_out; m_sp_callbacks.metadata_updated = callback_metadata_updated; m_sp_callbacks.connection_error = callback_connection_error; m_sp_callbacks.notify_main_thread = callback_notify_main_thread; m_sp_callbacks.music_delivery = callback_music_delivery; m_sp_callbacks.play_token_lost = callback_play_token_lost; m_sp_callbacks.log_message = callback_log_message; m_sp_callbacks.end_of_track = callback_end_of_track; m_sp_callbacks.userinfo_updated = callback_userinfo_updated; m_sp_callbacks.offline_error = callback_offline_error; m_sp_callbacks.connectionstate_updated = callback_connectionstate_updated; m_sp_callbacks.scrobble_error = callback_scrobble_error; QString dpString = settings.value("dataPath").toString(); dataPath = (char *) calloc(strlen(dpString.toLatin1()) + 1, sizeof(char)); strcpy(dataPath, dpString.toLatin1()); memset(&m_sp_config, 0, sizeof(m_sp_config)); m_sp_config.api_version = SPOTIFY_API_VERSION; m_sp_config.cache_location = dataPath; m_sp_config.settings_location = dataPath; m_sp_config.application_key = g_appkey; m_sp_config.application_key_size = g_appkey_size; m_sp_config.user_agent = "CuteSpot"; m_sp_config.callbacks = &m_sp_callbacks; sp_error error = sp_session_create(&m_sp_config, &m_sp_session); if (error != SP_ERROR_OK) { fprintf(stderr, "failed to create session: %s\n", sp_error_message(error)); m_sp_session = nullptr; return; } Q_ASSERT(m_sp_session); sp_session_set_cache_size(m_sp_session, 0); // Remove stored login information from older version of MeeSpot if (settings.contains("username")) { settings.remove("username"); settings.remove("password"); } // Remove old volume information if (settings.contains("volume")) { settings.remove("volume"); } m_offlineMode = settings.value("offlineMode", false).toBool(); checkNetworkAccess(); StreamingQuality quality = StreamingQuality(settings.value("streamingQuality", int(LowQuality)).toInt()); setStreamingQuality(quality); StreamingQuality syncQuality = StreamingQuality(settings.value("syncQuality", int(HighQuality)).toInt()); setSyncQuality(syncQuality); bool syncMobile = settings.value("syncOverMobile", false).toBool(); setSyncOverMobile(syncMobile); QString storedLogin = getStoredLoginInformation(); if (!storedLogin.isEmpty()) { login(storedLogin); } bool shuffle = settings.value("shuffle", false).toBool(); setShuffle(shuffle); bool repeat = settings.value("repeat", false).toBool(); setRepeat(repeat); bool repeatOne = settings.value("repeatOne", false).toBool(); setRepeatOne(repeatOne); bool volumeNormalizeSet = settings.value("volumeNormalize", true).toBool(); setVolumeNormalize(volumeNormalizeSet); m_lfmLoggedIn = false; // Flush cache regularly as we might get killed by life cycle manager / OOM killer QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(flush())); timer->start(60000); connect(this, SIGNAL(offlineModeChanged()), m_playQueue, SLOT(onOfflineModeChanged())); new MPRISMediaPlayer(this); new MPRISMediaPlayerPlayer(this); QDBusConnection::sessionBus().registerObject(QString("/org/mpris/MediaPlayer2"), this, QDBusConnection::ExportAdaptors); QDBusConnection::sessionBus().registerService("org.mpris.MediaPlayer2.CuteSpot"); }
LauncherWindow::LauncherWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::LauncherWindow) { ui->setupUi(this); settings = Settings::instance(); logger = Logger::logger(); // Show welcome message QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont); ui->logDisplay->setFont(font); appendToLog( tr("Welcome to the ttyhlauncher.") ); QFile logoFile(":/resources/logo.txt"); if ( logoFile.open(QFile::ReadOnly | QFile::Text) ) { appendToLog( QTextStream(&logoFile).readAll() ); logoFile.close(); } else { log( tr("Can't open logo resource.") ); } // Setup menu connect(ui->runSettings, &QAction::triggered, this, &LauncherWindow::showSettingsDialog); connect(ui->changeSkin, &QAction::triggered, this, &LauncherWindow::showSkinLoadDialog); connect(ui->updateManager, &QAction::triggered, this, &LauncherWindow::showUpdateManagerDialog); connect(ui->bugReport, &QAction::triggered, this, &LauncherWindow::showFeedBackDialog); connect(ui->aboutLauncher, &QAction::triggered, this, &LauncherWindow::showAboutDialog); connect(ui->runStoreSettings, &QAction::triggered, this, &LauncherWindow::showStoreSettingsDialog); connect(ui->runStoreManage, &QAction::triggered, this, &LauncherWindow::showStoreManageDialog); connect(ui->runStoreInstall, &QAction::triggered, this, &LauncherWindow::showStoreInstallDialog); bool isOffline = settings->loadOfflineModeState(); ui->playOffline->setChecked(isOffline); offlineModeChanged(); connect(ui->playOffline, &QAction::triggered, this, &LauncherWindow::offlineModeChanged); bool isHideWindow = settings->loadHideWindowModeState(); ui->hideLauncher->setChecked(isHideWindow); connect(ui->hideLauncher, &QAction::triggered, this, &LauncherWindow::hideWindowModeChanged); bool isLoadNews = settings->loadNewsState(); ui->loadNews->setChecked(isLoadNews); connect(ui->loadNews, &QAction::triggered, this, &LauncherWindow::fetchNewsModeChanged); connect(&newsFetcher, &DataFetcher::finished, this, &LauncherWindow::newsFetched); if ( settings->loadNewsState() ) { newsFetcher.makeGet( QUrl(Settings::newsFeed) ); } // Setup form QString login = settings->loadLogin(); ui->nickEdit->setText(login); connect(ui->nickEdit, &QLineEdit::textChanged, settings, &Settings::saveLogin); bool isPassStored = settings->loadPassStoreState(); ui->savePassword->setChecked(isPassStored); if (isPassStored) { QString password = settings->loadPassword(); ui->passEdit->setText(password); } connect(ui->savePassword, &QCheckBox::clicked, settings, &Settings::savePassStoreState); QStringList clients = settings->getClientCaptions(); ui->clientCombo->addItems(clients); int currentClient = settings->loadActiveClientID(); ui->clientCombo->setCurrentIndex(currentClient); connect( ui->clientCombo, SIGNAL( activated(int) ), settings, SLOT( saveActiveClientID(int) ) ); // Setup window parameters QRect geometry = settings->loadWindowGeometry(); if (geometry.x() < 0) { QPoint scrCenter = QApplication::desktop()->screen()->rect().center(); QPoint winCenter = this->rect().center(); this->move(scrCenter - winCenter); } else { this->setGeometry(geometry); } if ( settings->loadMaximizedState() ) { this->showMaximized(); } // Other connect(ui->playButton, &QPushButton::clicked, this, &LauncherWindow::playButtonClicked); connect(logger, &Logger::lineAppended, this, &LauncherWindow::appendToLog); #ifdef Q_OS_WIN QString latest = settings->getlatestVersion(); if (Settings::launcherVersion != latest) { connect(this, &LauncherWindow::windowOpened, this, [=]() { QString msg = tr("New launcher version avialable: %1").arg(latest); SelfUpdateDialog *d = new SelfUpdateDialog(msg, this); d->exec(); delete d; }, Qt::QueuedConnection); } #endif if (ui->clientCombo->count() == 0) { connect(this, &LauncherWindow::windowOpened, this, [=]() { ui->playButton->setEnabled(false); showError(tr("No available clients!"), true); }, Qt::QueuedConnection); } }