- Dual clock (primary/secondary time zone) with IANA picker, persisted in XML - AutoStartManager: macOS LaunchAgent (com.clouck.clock, RunAtLoad) - Tray icon: template image, light/dark adaptation, toggle + quit menu - ConfigManager: default path moved to QStandardPaths::AppConfigLocation - Qt Test suite (ConfigManager, AutoStartManager) wired into CTest - GitHub origin renamed to upstream; private Gitea repo as origin
69 lines
2.1 KiB
C++
69 lines
2.1 KiB
C++
#ifndef CONFIG_MANAGER_H
|
|
#define CONFIG_MANAGER_H
|
|
|
|
#include <QObject>
|
|
#include <QColor>
|
|
#include <QPoint>
|
|
#include <QSize>
|
|
#include <QString>
|
|
#include <QXmlStreamReader>
|
|
#include <QXmlStreamWriter>
|
|
|
|
class ConfigManager : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit ConfigManager(QObject *parent = nullptr);
|
|
|
|
static QString defaultSettingsPath();
|
|
|
|
// Load settings from XML file
|
|
bool loadSettings(const QString &filename = QString());
|
|
|
|
// Save settings to XML file
|
|
bool saveSettings(const QString &filename = QString());
|
|
|
|
// Getters
|
|
QColor fontColor() const { return m_fontColor; }
|
|
QColor backgroundColor() const { return m_backgroundColor; }
|
|
int fontSize() const { return m_fontSize; }
|
|
bool alwaysOnTop() const { return m_alwaysOnTop; }
|
|
QPoint windowPosition() const { return m_windowPosition; }
|
|
QSize windowSize() const { return m_windowSize; }
|
|
QString primaryTimeZoneId() const { return m_primaryTimeZoneId; }
|
|
QString secondaryTimeZoneId() const { return m_secondaryTimeZoneId; }
|
|
|
|
// Setters
|
|
void setFontColor(const QColor &color) { m_fontColor = color; }
|
|
void setBackgroundColor(const QColor &color) { m_backgroundColor = color; }
|
|
void setFontSize(int size) { m_fontSize = size; }
|
|
void setAlwaysOnTop(bool onTop) { m_alwaysOnTop = onTop; }
|
|
void setWindowPosition(const QPoint &pos) { m_windowPosition = pos; }
|
|
void setWindowSize(const QSize &size) { m_windowSize = size; }
|
|
void setPrimaryTimeZoneId(const QString &timeZoneId) { m_primaryTimeZoneId = timeZoneId; }
|
|
void setSecondaryTimeZoneId(const QString &timeZoneId) { m_secondaryTimeZoneId = timeZoneId; }
|
|
|
|
// Reset to default values
|
|
void resetToDefaults();
|
|
|
|
// Check if config file exists
|
|
bool configExists(const QString &filename = QString()) const;
|
|
|
|
private:
|
|
// Default values
|
|
void setDefaultValues();
|
|
|
|
// Settings data
|
|
QColor m_fontColor;
|
|
QColor m_backgroundColor;
|
|
int m_fontSize;
|
|
bool m_alwaysOnTop;
|
|
QPoint m_windowPosition;
|
|
QSize m_windowSize;
|
|
QString m_primaryTimeZoneId;
|
|
QString m_secondaryTimeZoneId;
|
|
};
|
|
|
|
#endif // CONFIG_MANAGER_H
|