-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.cpp
More file actions
54 lines (49 loc) · 1.34 KB
/
settings.cpp
File metadata and controls
54 lines (49 loc) · 1.34 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "settings.h"
/*!
* \brief Settings::Settings
*/
Settings::Settings() { InitSettings(); }
/*!
* \brief Settings::InitSettings
*/
void Settings::InitSettings() {
settings = new QSettings("config", QSettings::NativeFormat);
recent_files = new QStringList();
recent_count = 0;
}
/*!
* \brief Settings::LoadRecentFilesList
* \param action_list
*/
void Settings::LoadRecentFilesList(QList<QAction *> *action_list) {
recent_count = settings->value("Welding/Recent/Count", 0).toInt();
QString recent_file_temp = "";
for (int i = 0; i < recent_count; i++) {
recent_file_temp =
settings->value(QString::asprintf("Welding/Recent/File_%d", i), "")
.toString();
if (recent_file_temp.length() > 0) {
*recent_files << recent_file_temp;
action_list->append(new QAction(recent_file_temp));
}
}
}
/*!
* \brief Settings::AddNextFileName
* \param file_name
*/
void Settings::AddNextFileName(QString &file_name) {
*recent_files << file_name;
SaveRecentFilesList();
recent_count++;
settings->setValue("Welding/Recent/Count", recent_count);
}
/*!
* \brief Settings::SaveRecentFilesList
*/
void Settings::SaveRecentFilesList() {
for (int i = 0; i < recent_files->count(); i++) {
settings->setValue(QString::asprintf("Welding/Recent/File_%d", i),
recent_files->at(i));
}
}