Updated copyright year.
[simple-x264-launcher.git] / src / model_preferences.h
blobb93ab4cd3433e8e86994e0bb596d5421822921c4
1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2023 LoRd_MuldeR <MuldeR2@GMX.de>
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 2 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.
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
22 #pragma once
24 #include <QMutex>
25 #include <QMutexLocker>
27 ///////////////////////////////////////////////////////////////////////////////
29 #define PREFERENCES_MAKE_X(NAME, PREFIX, TYPE) \
30 public: \
31 inline TYPE get##NAME(void) const \
32 { \
33 QMutexLocker lock(&m_mutex); \
34 const TYPE value = m_##PREFIX##NAME; \
35 return value; \
36 } \
37 inline void set##NAME(const TYPE PREFIX##NAME) \
38 { \
39 QMutexLocker lock(&m_mutex); \
40 m_##PREFIX##NAME = PREFIX##NAME; \
41 } \
42 protected: \
43 TYPE m_##PREFIX##NAME;
45 #define PREFERENCES_MAKE_B(NAME) PREFERENCES_MAKE_X(NAME, b, bool)
46 #define PREFERENCES_MAKE_I(NAME) PREFERENCES_MAKE_X(NAME, i, int)
47 #define PREFERENCES_MAKE_U(NAME) PREFERENCES_MAKE_X(NAME, u, unsigned int)
49 ///////////////////////////////////////////////////////////////////////////////
51 class PreferencesModel
53 public:
54 PreferencesModel(void);
56 PREFERENCES_MAKE_B(AutoRunNextJob)
57 PREFERENCES_MAKE_U(MaxRunningJobCount)
58 PREFERENCES_MAKE_B(Prefer64BitSource)
59 PREFERENCES_MAKE_B(SaveLogFiles)
60 PREFERENCES_MAKE_B(SaveToSourcePath)
61 PREFERENCES_MAKE_I(ProcessPriority)
62 PREFERENCES_MAKE_B(EnableSounds)
63 PREFERENCES_MAKE_B(DisableWarnings)
64 PREFERENCES_MAKE_B(NoUpdateReminder)
65 PREFERENCES_MAKE_B(AbortOnTimeout)
66 PREFERENCES_MAKE_B(SkipVersionTest)
67 PREFERENCES_MAKE_B(NoSystrayWarning)
68 PREFERENCES_MAKE_B(SaveQueueNoConfirm)
70 public:
71 static void initPreferences(PreferencesModel *preferences);
72 static void loadPreferences(PreferencesModel *preferences);
73 static void savePreferences(PreferencesModel *preferences);
75 protected:
76 mutable QMutex m_mutex;
79 ///////////////////////////////////////////////////////////////////////////////
81 #undef PREFERENCES_MAKE_X
82 #undef PREFERENCES_MAKE_B
83 #undef PREFERENCES_MAKE_I
84 #undef PREFERENCES_MAKE_U