mirror of
https://github.com/Lurkki14/tuxclocker.git
synced 2024-11-21 15:57:25 -06:00
add function to get cache file path
This commit is contained in:
parent
2ff1873de9
commit
b922186489
@ -129,8 +129,7 @@ QMenu *MainWindow::createTrayMenu() {
|
||||
}
|
||||
|
||||
void MainWindow::restoreGeometryFromCache(QWidget *widget) {
|
||||
auto cacheDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
|
||||
auto cacheFilePath = QString("%1/tuxclocker.conf").arg(cacheDir);
|
||||
auto cacheFilePath = Utils::cacheFilePath();
|
||||
|
||||
QSettings settings{cacheFilePath, QSettings::NativeFormat};
|
||||
widget->restoreGeometry(settings.value("geometry").toByteArray());
|
||||
@ -138,8 +137,7 @@ void MainWindow::restoreGeometryFromCache(QWidget *widget) {
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event) {
|
||||
// Save window geometry to user cache dir (XDG_CACHE_HOME on Linux)
|
||||
auto cacheDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
|
||||
auto cacheFilePath = QString("%1/tuxclocker.conf").arg(cacheDir);
|
||||
auto cacheFilePath = Utils::cacheFilePath();
|
||||
|
||||
QSettings settings{cacheFilePath, QSettings::NativeFormat};
|
||||
settings.setValue("geometry", saveGeometry());
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <functional>
|
||||
#include <QDebug>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
#include <Settings.hpp>
|
||||
|
||||
namespace Utils {
|
||||
@ -139,4 +140,9 @@ void writeAssignableSetting(SettingsData data, AssignableSetting setting) {
|
||||
settings.setValue(toSettingsPath(setting.assignablePath), setting.value);
|
||||
}
|
||||
|
||||
QString cacheFilePath() {
|
||||
auto cacheDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
|
||||
return QString("%1/tuxclocker.conf").arg(cacheDir);
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
|
@ -11,6 +11,9 @@ using ModelTraverseCallback =
|
||||
std::function<std::optional<QModelIndex>(QAbstractItemModel *, const QModelIndex &, int)>;
|
||||
using NodePath = QString;
|
||||
|
||||
// File path to save non-setting persistent data, eg. window geometry
|
||||
QString cacheFilePath();
|
||||
|
||||
// Conversion for saving in settings
|
||||
NodePath fromSettingsPath(QString);
|
||||
QString toSettingsPath(NodePath);
|
||||
|
Loading…
Reference in New Issue
Block a user