/* * iDescriptor: A free and open-source idevice management tool. * * Copyright (C) 2025 Uncore * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ #ifndef SETTINGSMANAGER_H #define SETTINGSMANAGER_H #include #include #include #include #include #include #include class SettingsManager : public QObject { Q_OBJECT public: static SettingsManager *sharedInstance(); // Settings keys enum class Setting { DownloadPath, AutoCheckUpdates, AutoRaiseWindow, SwitchToNewDevice, UnmountiFuseOnExit, Theme, ConnectionTimeout }; static QString homePath(); // Existing methods QString devdiskimgpath() const; void clearKeys(const QString &keyPrefix); void saveFavoritePlace(const QString &path, const QString &alias, const QString &keyPrefix); void removeFavoritePlace(const QString &keyPrefix, const QString &path); QList> getFavoritePlaces(const QString &keyPrefix) const; void showSettingsDialog(); // Recently used locations void saveRecentLocation(double latitude, double longitude, const QString &name = QString()); QList getRecentLocations() const; void clearRecentLocations(); QString downloadPath() const; void setDownloadPath(const QString &path); QString mkDevDiskImgPath() const; bool autoCheckUpdates() const; void setAutoCheckUpdates(bool enabled); bool autoRaiseWindow() const; void setAutoRaiseWindow(bool enabled); bool switchToNewDevice() const; void setSwitchToNewDevice(bool enabled); #ifndef __APPLE__ bool unmountiFuseOnExit() const; void setUnmountiFuseOnExit(bool enabled); #endif bool useUnsecureBackend() const; void setUseUnsecureBackend(bool enabled); QString theme() const; void setTheme(const QString &theme); int connectionTimeout() const; void setConnectionTimeout(int seconds); bool showKeychainDialog() const; void setShowKeychainDialog(bool show); // Utility method for conditional execution void doIfEnabled(Setting setting, std::function action); // Reset to defaults void resetToDefaults(); signals: void favoritePlacesChanged(); void recentLocationsChanged(); private: QDialog *m_dialog; explicit SettingsManager(QObject *parent = nullptr); QSettings *m_settings; static const QString FAVORITE_PREFIX; }; #endif // SETTINGSMANAGER_H