Motiv
Marvelous OTF2 Traces Interactive Visualizer
Loading...
Searching...
No Matches
AppSettings.cpp
1/*
2 * Marvelous OTF2 Traces Interactive Visualizer (MOTIV)
3 * Copyright (C) 2023 Florian Gallrein, Björn Gehrke
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18#include "AppSettings.hpp"
19
20#define SET_AND_EMIT(key) \
21 settings.setValue(#key, key##_); \
22 Q_EMIT key##Changed(key##_);
23
24AppSettings::AppSettings() {
25 this->recentlyOpenedFiles_ = this->settings.value("recentlyOpenedFiles").toStringList();
26}
27
28const QStringList &AppSettings::recentlyOpenedFiles() const {
29 return recentlyOpenedFiles_;
30}
31
32void AppSettings::recentlyOpenedFilesPush(const QString &newFile) {
33 // Make sure most recent files are always at the back.
34 recentlyOpenedFiles_.removeAll(newFile);
35 recentlyOpenedFiles_.push_back(newFile);
36 SET_AND_EMIT(recentlyOpenedFiles)
37}
38
39void AppSettings::recentlyOpenedFilesRemove(const QString &filePath) {
40 recentlyOpenedFiles_.removeAll(filePath);
41 SET_AND_EMIT(recentlyOpenedFiles)
42}
43
45 this->recentlyOpenedFiles_.clear();
46 SET_AND_EMIT(recentlyOpenedFiles)
47}
void recentlyOpenedFilesRemove(const QString &filePath)
Removes a file from the recently opened files list.
Definition: AppSettings.cpp:39
void recentlyOpenedFilesClear()
Clears the recently opened files list.
Definition: AppSettings.cpp:44
void recentlyOpenedFilesPush(const QString &newFile)
Pushes a new file to the recently opened files list.
Definition: AppSettings.cpp:32
const QStringList & recentlyOpenedFiles() const
Returns the recently opened files.
Definition: AppSettings.cpp:28