Quarts/Quartz/cycleupdater.cpp

37 lines
1.2 KiB
C++

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