OSDN Git Service

Bump version.
[x264-launcher/x264-launcher.git] / src / model_preferences.h
index f7ebd3e..0526e91 100644 (file)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 // Simple x264 Launcher
-// Copyright (C) 2004-2013 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2020 LoRd_MuldeR <MuldeR2@GMX.de>
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
 
 #pragma once
 
+#include <QMutex>
+#include <QMutexLocker>
+
+///////////////////////////////////////////////////////////////////////////////
+
+#define PREFERENCES_MAKE_X(NAME, PREFIX, TYPE) \
+       public: \
+               inline TYPE get##NAME(void) const \
+               { \
+                       QMutexLocker lock(&m_mutex); \
+                       const TYPE value = m_##PREFIX##NAME; \
+                       return value; \
+               } \
+               inline void set##NAME(const TYPE PREFIX##NAME) \
+               { \
+                       QMutexLocker lock(&m_mutex); \
+                       m_##PREFIX##NAME = PREFIX##NAME; \
+               } \
+       protected: \
+               TYPE m_##PREFIX##NAME;
+
+#define PREFERENCES_MAKE_B(NAME) PREFERENCES_MAKE_X(NAME, b, bool)
+#define PREFERENCES_MAKE_I(NAME) PREFERENCES_MAKE_X(NAME, i, int)
+#define PREFERENCES_MAKE_U(NAME) PREFERENCES_MAKE_X(NAME, u, unsigned int)
+
+///////////////////////////////////////////////////////////////////////////////
+
 class PreferencesModel
 {
 public:
        PreferencesModel(void);
 
-       enum
-       {
-               X264_PRIORITY_ABOVENORMAL = 0,
-               X264_PRIORITY_NORMAL = 1,
-               X264_PRIORITY_BELOWNORMAL = 2,
-               X264_PRIORITY_IDLE = 3,
-       }
-       x264_priority_t;
+       PREFERENCES_MAKE_B(AutoRunNextJob)
+       PREFERENCES_MAKE_U(MaxRunningJobCount)
+       PREFERENCES_MAKE_B(Prefer64BitSource)
+       PREFERENCES_MAKE_B(SaveLogFiles)
+       PREFERENCES_MAKE_B(SaveToSourcePath)
+       PREFERENCES_MAKE_I(ProcessPriority)
+       PREFERENCES_MAKE_B(EnableSounds)
+       PREFERENCES_MAKE_B(DisableWarnings)
+       PREFERENCES_MAKE_B(NoUpdateReminder)
+       PREFERENCES_MAKE_B(AbortOnTimeout)
+       PREFERENCES_MAKE_B(SkipVersionTest)
+       PREFERENCES_MAKE_B(NoSystrayWarning)
+       PREFERENCES_MAKE_B(SaveQueueNoConfirm)
 
-       //Getter
-       bool autoRunNextJob(void) { return m_autoRunNextJob; }
-       unsigned int maxRunningJobCount(void) { return m_maxRunningJobCount; }
-       bool shutdownComputer(void) { return m_shutdownComputer; }
-       bool use10BitEncoding(void) { return m_use10BitEncoding; }
-       bool useAvisyth64Bit(void) { return m_useAvisyth64Bit; }
-       bool saveLogFiles(void) { return m_saveLogFiles; }
-       bool saveToSourcePath(void) { return m_saveToSourcePath; }
-       int processPriority(void) { return m_processPriority; }
-       bool enableSounds(void) { return m_enableSounds; }
-       bool disableWarnings(void) { return m_disableWarnings; }
-
-       //Setter
-       void setAutoRunNextJob(const bool autoRunNextJob) { m_autoRunNextJob = autoRunNextJob; }
-       void setMaxRunningJobCount(const unsigned int maxRunningJobCount) { m_maxRunningJobCount = maxRunningJobCount; }
-       void setShutdownComputer(const bool shutdownComputer) { m_shutdownComputer = shutdownComputer; }
-       void setUse10BitEncoding(const bool use10BitEncoding) { m_use10BitEncoding = use10BitEncoding; }
-       void setUseAvisyth64Bit(const bool useAvisyth64Bit) { m_useAvisyth64Bit = useAvisyth64Bit; }
-       void setSaveLogFiles(const bool saveLogFiles) { m_saveLogFiles = saveLogFiles; }
-       void setSaveToSourcePath(const bool saveToSourcePath) { m_saveToSourcePath = saveToSourcePath; }
-       void setProcessPriority(const int processPriority) { m_processPriority = processPriority; }
-       void setEnableSounds(const bool enableSounds) { m_enableSounds = enableSounds; }
-       void setDisableWarnings(const bool disableWarnings) { m_disableWarnings = disableWarnings; }
-
-       //Static
+public:
        static void initPreferences(PreferencesModel *preferences);
        static void loadPreferences(PreferencesModel *preferences);
        static void savePreferences(PreferencesModel *preferences);
 
 protected:
-       bool m_autoRunNextJob;
-       unsigned int m_maxRunningJobCount;
-       bool m_shutdownComputer;
-       bool m_use10BitEncoding;
-       bool m_useAvisyth64Bit;
-       bool m_saveLogFiles;
-       bool m_saveToSourcePath;
-       int m_processPriority;
-       bool m_enableSounds;
-       bool m_disableWarnings;
+       mutable QMutex m_mutex;
 };
+
+///////////////////////////////////////////////////////////////////////////////
+
+#undef PREFERENCES_MAKE_X
+#undef PREFERENCES_MAKE_B
+#undef PREFERENCES_MAKE_I
+#undef PREFERENCES_MAKE_U