CuteLogger
Fast and simple logging solution for Qt based applications
settings.h
1/*
2 * Copyright (c) 2013-2024 Meltytech, LLC
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef SETTINGS_H
19#define SETTINGS_H
20
21#include <QKeySequence>
22#include <QObject>
23#include <QSettings>
24#include <QStringList>
25#include <QByteArray>
26#include <QThread>
27
28class ShotcutSettings : public QObject
29{
30 Q_OBJECT
31 Q_PROPERTY(bool timelineDragScrub READ timelineDragScrub WRITE setTimelineDragScrub NOTIFY
32 timelineDragScrubChanged)
33 Q_PROPERTY(bool timelineShowWaveforms READ timelineShowWaveforms WRITE setTimelineShowWaveforms
34 NOTIFY timelineShowWaveformsChanged)
35 Q_PROPERTY(bool timelineShowThumbnails READ timelineShowThumbnails WRITE setTimelineShowThumbnails
36 NOTIFY timelineShowThumbnailsChanged)
37 Q_PROPERTY(bool timelineRipple READ timelineRipple WRITE setTimelineRipple NOTIFY
38 timelineRippleChanged)
39 Q_PROPERTY(bool timelineRippleAllTracks READ timelineRippleAllTracks WRITE
40 setTimelineRippleAllTracks NOTIFY timelineRippleAllTracksChanged)
41 Q_PROPERTY(bool timelineRippleMarkers READ timelineRippleMarkers WRITE setTimelineRippleMarkers
42 NOTIFY timelineRippleMarkersChanged)
43 Q_PROPERTY(bool timelineSnap READ timelineSnap WRITE setTimelineSnap NOTIFY timelineSnapChanged)
44 Q_PROPERTY(bool timelineScrollZoom READ timelineScrollZoom WRITE setTimelineScrollZoom NOTIFY
45 timelineScrollZoomChanged)
46 Q_PROPERTY(bool timelineFramebufferWaveform READ timelineFramebufferWaveform WRITE
47 setTimelineFramebufferWaveform NOTIFY timelineFramebufferWaveformChanged)
48 Q_PROPERTY(QString openPath READ openPath WRITE setOpenPath NOTIFY openPathChanged)
49 Q_PROPERTY(QString savePath READ savePath WRITE setSavePath NOTIFY savePathChanged)
50 Q_PROPERTY(QString playlistThumbnails READ playlistThumbnails WRITE setPlaylistThumbnails NOTIFY
51 playlistThumbnailsChanged)
52 Q_PROPERTY(QString viewMode READ viewMode WRITE setViewMode NOTIFY viewModeChanged)
53 Q_PROPERTY(int playerAudioChannels READ playerAudioChannels NOTIFY playerAudioChannelsChanged)
54 Q_PROPERTY(bool playerGPU READ playerGPU NOTIFY playerGpuChanged)
55 Q_PROPERTY(double audioInDuration READ audioInDuration WRITE setAudioInDuration NOTIFY
56 audioInDurationChanged)
57 Q_PROPERTY(double audioOutDuration READ audioOutDuration WRITE setAudioOutDuration NOTIFY
58 audioOutDurationChanged)
59 Q_PROPERTY(double videoInDuration READ videoInDuration WRITE setVideoInDuration NOTIFY
60 videoInDurationChanged)
61 Q_PROPERTY(double videoOutDuration READ videoOutDuration WRITE setVideoOutDuration NOTIFY
62 videoOutDurationChanged)
63 Q_PROPERTY(bool smallIcons READ smallIcons WRITE setSmallIcons NOTIFY smallIconsChanged)
64 Q_PROPERTY(bool askOutputFilter READ askOutputFilter WRITE setAskOutputFilter NOTIFY
65 askOutputFilterChanged)
66 Q_PROPERTY(QString appDataLocation READ appDataLocation CONSTANT)
67 Q_PROPERTY(TimelineScrolling timelineScrolling READ timelineScrolling WRITE setTimelineScrolling
68 NOTIFY timelineScrollingChanged)
69 Q_ENUMS(TimelineScrolling)
70 Q_PROPERTY(bool timelineRectangleSelect READ timelineRectangleSelect WRITE
71 setTimelineRectangleSelect NOTIFY timelineRectangleSelectChanged)
72
73public:
74 static const qsizetype MaxPath {32767};
75 enum TimelineScrolling {
76 NoScrolling,
77 CenterPlayhead,
78 PageScrolling,
79 SmoothScrolling
80 };
81
82 static ShotcutSettings &singleton();
83 void log();
84
85 // general
86 QString language() const;
87 void setLanguage(const QString &);
88 double imageDuration() const;
89 void setImageDuration(double);
90 QString openPath() const;
91 void setOpenPath(const QString &);
92 QString savePath() const;
93 void setSavePath(const QString &);
94 QStringList recent() const;
95 void setRecent(const QStringList &);
96 QString theme() const;
97 void setTheme(const QString &);
98 QThread::Priority jobPriority() const;
99 void setJobPriority(const QString &);
100 bool showTitleBars() const;
101 void setShowTitleBars(bool);
102 bool showToolBar() const;
103 void setShowToolBar(bool);
104 bool textUnderIcons() const;
105 void setTextUnderIcons(bool);
106 bool smallIcons() const;
107 void setSmallIcons(bool);
108 QByteArray windowGeometry() const;
109 void setWindowGeometry(const QByteArray &);
110 QByteArray windowGeometryDefault() const;
111 void setWindowGeometryDefault(const QByteArray &);
112 QByteArray windowState() const;
113 void setWindowState(const QByteArray &);
114 QByteArray windowStateDefault() const;
115 void setWindowStateDefault(const QByteArray &);
116 QString viewMode() const;
117 void setViewMode(const QString &viewMode);
118 QString exportFrameSuffix() const;
119 void setExportFrameSuffix(const QString &suffix);
120 bool convertAdvanced() const;
121 void setConvertAdvanced(bool);
122
123 // encode
124 QString encodePath() const;
125 void setEncodePath(const QString &);
126 bool encodeFreeSpaceCheck() const;
127 void setEncodeFreeSpaceCheck(bool);
128 bool encodeUseHardware() const;
129 void setEncodeUseHardware(bool);
130 QStringList encodeHardware() const;
131 void setEncodeHardware(const QStringList &);
132 bool encodeAdvanced() const;
133 void setEncodeAdvanced(bool);
134 bool showConvertClipDialog() const;
135 void setShowConvertClipDialog(bool);
136 bool encodeParallelProcessing() const;
137 void setEncodeParallelProcessing(bool);
138
139 // player
140 int playerAudioChannels() const;
141 void setPlayerAudioChannels(int);
142 QString playerDeinterlacer() const;
143 void setPlayerDeinterlacer(const QString &);
144 QString playerExternal() const;
145 void setPlayerExternal(const QString &);
146 bool playerGPU() const;
147 void setPlayerGPU(bool);
148 bool playerWarnGPU() const;
149 QString playerInterpolation() const;
150 void setPlayerInterpolation(const QString &);
151 bool playerJACK() const;
152 void setPlayerJACK(bool);
153 int playerKeyerMode() const;
154 void setPlayerKeyerMode(int);
155 bool playerMuted() const;
156 void setPlayerMuted(bool);
157 QString playerProfile() const;
158 void setPlayerProfile(const QString &);
159 bool playerProgressive() const;
160 void setPlayerProgressive(bool);
161 bool playerRealtime() const;
162 void setPlayerRealtime(bool);
163 bool playerScrubAudio() const;
164 void setPlayerScrubAudio(bool);
165 int playerVolume() const;
166 void setPlayerVolume(int);
167 float playerZoom() const;
168 void setPlayerZoom(float);
169 int playerPreviewScale() const;
170 void setPlayerPreviewScale(int);
171 int playerVideoDelayMs() const;
172 void setPlayerVideoDelayMs(int);
173 double playerJumpSeconds() const;
174 void setPlayerJumpSeconds(double);
175 QString playerAudioDriver() const;
176 void setPlayerAudioDriver(const QString &s);
177
178 // playlist
179 QString playlistThumbnails() const;
180 void setPlaylistThumbnails(const QString &);
181 bool playlistAutoplay() const;
182 void setPlaylistAutoplay(bool);
183
184 // timeline
185 bool timelineDragScrub() const;
186 void setTimelineDragScrub(bool);
187 bool timelineShowWaveforms() const;
188 void setTimelineShowWaveforms(bool);
189 bool timelineShowThumbnails() const;
190 void setTimelineShowThumbnails(bool);
191 bool timelineRipple() const;
192 void setTimelineRipple(bool);
193 bool timelineRippleAllTracks() const;
194 void setTimelineRippleAllTracks(bool);
195 bool timelineRippleMarkers() const;
196 void setTimelineRippleMarkers(bool);
197 bool timelineSnap() const;
198 void setTimelineSnap(bool);
199 int timelineTrackHeight() const;
200 void setTimelineTrackHeight(int);
201 bool timelineScrollZoom() const;
202 void setTimelineScrollZoom(bool);
203 bool timelineFramebufferWaveform() const;
204 void setTimelineFramebufferWaveform(bool);
205 int audioReferenceTrack() const;
206 void setAudioReferenceTrack(int);
207 double audioReferenceSpeedRange() const;
208 void setAudioReferenceSpeedRange(double);
209 bool timelinePreviewTransition() const;
210 void setTimelinePreviewTransition(bool);
211 void setTimelineScrolling(TimelineScrolling value);
212 TimelineScrolling timelineScrolling() const;
213 bool timelineAutoAddTracks() const;
214 void setTimelineAutoAddTracks(bool);
215 bool timelineRectangleSelect() const;
216 void setTimelineRectangleSelect(bool);
217
218 // filter
219 QString filterFavorite(const QString &filterName);
220 void setFilterFavorite(const QString &filterName, const QString &value);
221 double audioInDuration() const;
222 void setAudioInDuration(double);
223 double audioOutDuration() const;
224 void setAudioOutDuration(double);
225 double videoInDuration() const;
226 void setVideoInDuration(double);
227 double videoOutDuration() const;
228 void setVideoOutDuration(double);
229 bool askOutputFilter() const;
230 void setAskOutputFilter(bool);
231
232 // scope
233 bool loudnessScopeShowMeter(const QString &meter) const;
234 void setLoudnessScopeShowMeter(const QString &meter, bool b);
235
236 // Markers
237 void setMarkerColor(const QColor &color);
238 QColor markerColor() const;
239 void setMarkersShowColumn(const QString &column, bool b);
240 bool markersShowColumn(const QString &column) const;
241 void setMarkerSort(int column, Qt::SortOrder order);
242 int getMarkerSortColumn();
243 Qt::SortOrder getMarkerSortOrder();
244
245 // general continued
246 int drawMethod() const;
247 void setDrawMethod(int);
248 bool noUpgrade() const;
249 void setNoUpgrade(bool value);
250 bool checkUpgradeAutomatic();
251 void setCheckUpgradeAutomatic(bool b);
252 bool askUpgradeAutomatic();
253 void setAskUpgradeAutomatic(bool b);
254
255 void sync();
256 QString appDataLocation() const;
257 static void setAppDataForSession(const QString &location);
258 void setAppDataLocally(const QString &location);
259
260 // layout
261 QStringList layouts() const;
262 bool setLayout(const QString &name, const QByteArray &geometry, const QByteArray &state);
263 QByteArray layoutGeometry(const QString &name);
264 QByteArray layoutState(const QString &name);
265 bool removeLayout(const QString &name);
266 int layoutMode() const;
267 void setLayoutMode(int mode = 0);
268
269 // general continued
270 bool clearRecent() const;
271 void setClearRecent(bool);
272 QString projectsFolder() const;
273 void setProjectsFolder(const QString &path);
274 QString audioInput() const;
275 void setAudioInput(const QString &name);
276 QString videoInput() const;
277 void setVideoInput(const QString &name);
278 QString glaxnimatePath() const;
279 void setGlaxnimatePath(const QString &path);
280 bool exportRangeMarkers() const;
281 void setExportRangeMarkers(bool);
282 int undoLimit() const;
283 bool warnLowMemory() const;
284 int backupPeriod() const;
285 void setBackupPeriod(int i);
286
287 // proxy
288 bool proxyEnabled() const;
289 void setProxyEnabled(bool);
290 QString proxyFolder() const;
291 void setProxyFolder(const QString &path);
292 bool proxyUseProjectFolder() const;
293 void setProxyUseProjectFolder(bool);
294 bool proxyUseHardware() const;
295 void setProxyUseHardware(bool);
296
297 // Shortcuts
298 void clearShortcuts(const QString &name);
299 void setShortcuts(const QString &name, const QList<QKeySequence> &shortcuts);
300 QList<QKeySequence> shortcuts(const QString &name);
301
302 // Slideshow
303 double slideshowClipDuration(double defaultClipDuration) const;
304 void setSlideshowClipDuration(double clipDuration);
305 int slideshowAspectConversion(int defaultAspectConversion) const;
306 void setSlideshowAspectConversion(int aspectConversion);
307 int slideshowZoomPercent(int defaultZoomPercent) const;
308 void setSlideshowZoomPercent(int zoomPercent);
309 double slideshowTransitionDuration(double defaultTransitionDuration) const;
310 void setSlideshowTransitionDuration(double transitionDuration);
311 int slideshowTransitionStyle(int defaultTransitionStyle) const;
312 void setSlideshowTransitionStyle(int transitionStyle);
313 int slideshowTransitionSoftness(int defaultTransitionSoftness) const;
314 void setSlideshowTransitionSoftness(int transitionSoftness);
315
316public slots:
317 void reset();
318
319signals:
320 void openPathChanged();
321 void savePathChanged();
322 void timelineDragScrubChanged();
323 void timelineShowWaveformsChanged();
324 void timelineShowThumbnailsChanged();
325 void timelineRippleChanged();
326 void timelineRippleAllTracksChanged();
327 void timelineRippleMarkersChanged();
328 void timelineSnapChanged();
329 void timelineScrollZoomChanged();
330 void timelineFramebufferWaveformChanged();
331 void playerAudioChannelsChanged(int);
332 void playerGpuChanged();
333 void audioInDurationChanged();
334 void audioOutDurationChanged();
335 void videoInDurationChanged();
336 void videoOutDurationChanged();
337 void playlistThumbnailsChanged();
338 void viewModeChanged();
339 void smallIconsChanged();
340 void askOutputFilterChanged();
341 void timelineScrollingChanged();
342 void timelineAutoAddTracksChanged();
343 void timelineRectangleSelectChanged();
344
345private:
346 explicit ShotcutSettings();
347 explicit ShotcutSettings(const QString &appDataLocation);
348 void migrateRecent();
349 void migrateLayout();
350
351 QSettings settings;
352 QString m_appDataLocation;
353 QSettings m_recent;
354};
355
356#define Settings ShotcutSettings::singleton()
357
358#endif // SETTINGS_H