#include "cycleupdater.h" #include "settingsrepository.h" #include #include "singalizer.h" void CycleUpdater::emitHandler(){ if (m_storage.isValid() && m_storage.isReady()) { // quint64 total = m_storage.bytesTotal(); // quint64 available = m_storage.bytesAvailable(); QStorageInfo info(tomPath); quint64 total = info.bytesTotal(); quint64 available = info.bytesAvailable(); emit updateStorageInfo(static_cast(available), static_cast(total)); if (available < SettingsRepository::instance().memoryLimitMinBytes()) { emit Signalizer::get().reachedLimitAvailibleMemortSize(); } } else { emit incorrectPath(); } } void CycleUpdater::start() { while (m_isRunning && m_isRunning->load()) { QString newPath = SettingsRepository::instance().defaultProjectDirectory(); if (newPath != m_oldPath) { m_oldPath = newPath; if (QDir::isAbsolutePath(m_oldPath)) { tomPath = getRootVolumeFromString(m_oldPath); } else { tomPath = getRootVolumeFromString(QDir::currentPath()); } if (!tomPath.isEmpty()) { m_storage.setPath(tomPath); emitHandler(); } else { emit incorrectPath(); } }else{ emitHandler(); } std::this_thread::sleep_for(std::chrono::milliseconds(1000)); // безопаснее, чем std::this_thread::sleep_for в Qt } }