Quarts/Quartz/cycleupdater.cpp
Станислав Хозяенок 35b85f7489 Предрелизная версия
2025-07-01 10:26:51 +07:00

52 lines
1.5 KiB
C++

#include "cycleupdater.h"
#include "settingsrepository.h"
#include <thread>
#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<double>(available), static_cast<double>(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
}
}