-
Notifications
You must be signed in to change notification settings - Fork 0
/
TranslationProgress.cpp
33 lines (26 loc) · 1.24 KB
/
TranslationProgress.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "TranslationProgress.h"
#include <QCoreApplication>
#include <QDir>
QString TranslationProgress::getProgressFilePath() {
return QCoreApplication::applicationDirPath() + "/translation_progress.ini";
}
void TranslationProgress::saveProgress(const QString& inputPath, const QString& outputPath, const QString& lastFile) {
QSettings settings(getProgressFilePath(), QSettings::IniFormat);
settings.setValue("Progress/InputPath", inputPath);
settings.setValue("Progress/OutputPath", outputPath);
settings.setValue("Progress/LastFile", lastFile);
}
bool TranslationProgress::hasUnfinishedTask(const QString& inputPath, const QString& outputPath, QString& lastFile) {
QSettings settings(getProgressFilePath(), QSettings::IniFormat);
QString savedInputPath = settings.value("Progress/InputPath").toString();
QString savedOutputPath = settings.value("Progress/OutputPath").toString();
if (savedInputPath == inputPath && savedOutputPath == outputPath) {
lastFile = settings.value("Progress/LastFile").toString();
return !lastFile.isEmpty();
}
return false;
}
void TranslationProgress::clearProgress() {
QSettings settings(getProgressFilePath(), QSettings::IniFormat);
settings.clear();
}