void MobileUiApplication::saveState(QSessionManager & manager) { //qDebug() << QString("saving session state to id %1").arg(manager.sessionId()); AccountId activeCore = Client::currentCoreAccount().accountId(); // FIXME store this! SessionSettings s(manager.sessionId()); s.setSessionAge(0); QtUi::mainWindow()->saveStateToSettings(s); }
void ClipboardServer::onSaveState(QSessionManager &sessionManager) { COPYQ_LOG("Got save state request from session manager."); QSettings settings(QSettings::IniFormat, QSettings::UserScope, "copyq", "copyq_no_session"); const auto sessionNameKey = "session_" + sessionManager.sessionId(); const auto sessionName = qApp->property("CopyQ_session_name").toString(); settings.setValue(sessionNameKey, sessionName); const QString lastSessionIdPrefix = "last_session_id_for_"; const auto lastSessionIdKey = lastSessionIdPrefix + sessionName; const auto lastSessionId = settings.value(lastSessionIdKey).toString(); const auto lastSessionNameKey = "session_" + lastSessionId; settings.setValue(lastSessionIdKey, sessionNameKey); // Remove no longer valid sessions from configuration. QSet<QString> validSessions; for (const QString &key : settings.childKeys()) { if ( key.startsWith(lastSessionIdPrefix) ) validSessions.insert( settings.value(key).toString() ); } for (const QString &key : settings.childKeys()) { if ( !key.startsWith(lastSessionIdPrefix) && !validSessions.contains(key) ) settings.remove(key); } }
void ClipboardServer::onSaveState(QSessionManager &sessionManager) { COPYQ_LOG("Got save state request from session manager."); QSettings settings(QSettings::IniFormat, QSettings::UserScope, "copyq", "copyq_no_session"); const auto sessionNameKey = "session_" + sessionManager.sessionId(); const auto sessionName = qApp->property("CopyQ_session_name").toString(); settings.setValue(sessionNameKey, sessionName); // Remove last session name from configuration. const auto lastSessionIdKey = "last_session_id_for_" + sessionName; const auto lastSessionId = settings.value(lastSessionIdKey).toString(); if ( !lastSessionId.isEmpty() ) { const auto lastSessionNameKey = "session_" + lastSessionId; settings.remove(lastSessionNameKey); } settings.setValue(lastSessionIdKey, sessionNameKey); }