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 <framework/mlt_types.h>
22#include <QByteArray>
23#include <QKeySequence>
24#include <QObject>
25#include <QSettings>
26#include <QStringList>
27#include <QThread>
28
29class ShotcutSettings : public QObject
30{
31 Q_OBJECT
32 Q_PROPERTY(bool timelineDragScrub READ timelineDragScrub WRITE setTimelineDragScrub NOTIFY
33 timelineDragScrubChanged)
34 Q_PROPERTY(bool timelineShowWaveforms READ timelineShowWaveforms WRITE setTimelineShowWaveforms
35 NOTIFY timelineShowWaveformsChanged)
36 Q_PROPERTY(bool timelineShowThumbnails READ timelineShowThumbnails WRITE
37 setTimelineShowThumbnails NOTIFY timelineShowThumbnailsChanged)
38 Q_PROPERTY(bool timelineRipple READ timelineRipple WRITE setTimelineRipple NOTIFY
39 timelineRippleChanged)
40 Q_PROPERTY(bool timelineRippleAllTracks READ timelineRippleAllTracks WRITE
41 setTimelineRippleAllTracks NOTIFY timelineRippleAllTracksChanged)
42 Q_PROPERTY(bool timelineRippleMarkers READ timelineRippleMarkers WRITE setTimelineRippleMarkers
43 NOTIFY timelineRippleMarkersChanged)
44 Q_PROPERTY(bool timelineSnap READ timelineSnap WRITE setTimelineSnap NOTIFY timelineSnapChanged)
45 Q_PROPERTY(bool timelineScrollZoom READ timelineScrollZoom WRITE setTimelineScrollZoom NOTIFY
46 timelineScrollZoomChanged)
47 Q_PROPERTY(bool timelineFramebufferWaveform READ timelineFramebufferWaveform WRITE
48 setTimelineFramebufferWaveform NOTIFY timelineFramebufferWaveformChanged)
49 Q_PROPERTY(QString openPath READ openPath WRITE setOpenPath NOTIFY openPathChanged)
50 Q_PROPERTY(QString savePath READ savePath WRITE setSavePath NOTIFY savePathChanged)
51 Q_PROPERTY(QString playlistThumbnails READ playlistThumbnails WRITE setPlaylistThumbnails NOTIFY
52 playlistThumbnailsChanged)
53 Q_PROPERTY(QString viewMode READ viewMode WRITE setViewMode NOTIFY viewModeChanged)
54 Q_PROPERTY(int playerAudioChannels READ playerAudioChannels NOTIFY playerAudioChannelsChanged)
55 Q_PROPERTY(bool playerGPU READ playerGPU NOTIFY playerGpuChanged)
56 Q_PROPERTY(double audioInDuration READ audioInDuration WRITE setAudioInDuration NOTIFY
57 audioInDurationChanged)
58 Q_PROPERTY(double audioOutDuration READ audioOutDuration WRITE setAudioOutDuration NOTIFY
59 audioOutDurationChanged)
60 Q_PROPERTY(double videoInDuration READ videoInDuration WRITE setVideoInDuration NOTIFY
61 videoInDurationChanged)
62 Q_PROPERTY(double videoOutDuration READ videoOutDuration WRITE setVideoOutDuration NOTIFY
63 videoOutDurationChanged)
64 Q_PROPERTY(double audioInCurve READ audioInCurve WRITE setAudioInCurve NOTIFY audioInCurveChanged)
65 Q_PROPERTY(
66 double audioOutCurve READ audioOutCurve WRITE setAudioOutCurve NOTIFY audioOutCurveChanged)
67 Q_PROPERTY(bool smallIcons READ smallIcons WRITE setSmallIcons NOTIFY smallIconsChanged)
68 Q_PROPERTY(bool askOutputFilter READ askOutputFilter WRITE setAskOutputFilter NOTIFY
69 askOutputFilterChanged)
70 Q_PROPERTY(QString appDataLocation READ appDataLocation CONSTANT)
71 Q_PROPERTY(TimelineScrolling timelineScrolling READ timelineScrolling WRITE setTimelineScrolling
72 NOTIFY timelineScrollingChanged)
73 Q_ENUMS(TimelineScrolling)
74 Q_PROPERTY(bool timelineRectangleSelect READ timelineRectangleSelect WRITE
75 setTimelineRectangleSelect NOTIFY timelineRectangleSelectChanged)
76 Q_PROPERTY(bool keyframesDragScrub READ keyframesDragScrub WRITE setKeyframesDragScrub NOTIFY
77 keyframesDragScrubChanged)
78
79public:
80 static const qsizetype MaxPath{32767};
81 enum TimelineScrolling { NoScrolling, CenterPlayhead, PageScrolling, SmoothScrolling };
82
83 static ShotcutSettings &singleton();
84 void log();
85
86 // general
87 QString language() const;
88 void setLanguage(const QString &);
89 double imageDuration() const;
90 void setImageDuration(double);
91 QString openPath() const;
92 void setOpenPath(const QString &);
93 QString savePath() const;
94 void setSavePath(const QString &);
95 QStringList recent() const;
96 void setRecent(const QStringList &);
97 QStringList projects();
98 void setProjects(const QStringList &);
99 QString theme() const;
100 void setTheme(const QString &);
101 QThread::Priority jobPriority() const;
102 void setJobPriority(const QString &);
103 bool showTitleBars() const;
104 void setShowTitleBars(bool);
105 bool showToolBar() const;
106 void setShowToolBar(bool);
107 bool textUnderIcons() const;
108 void setTextUnderIcons(bool);
109 bool smallIcons() const;
110 void setSmallIcons(bool);
111 QByteArray windowGeometry() const;
112 void setWindowGeometry(const QByteArray &);
113 QByteArray windowGeometryDefault() const;
114 void setWindowGeometryDefault(const QByteArray &);
115 QByteArray windowState() const;
116 void setWindowState(const QByteArray &);
117 QByteArray windowStateDefault() const;
118 void setWindowStateDefault(const QByteArray &);
119 QString viewMode() const;
120 void setViewMode(const QString &viewMode);
121 QString exportFrameSuffix() const;
122 void setExportFrameSuffix(const QString &suffix);
123 bool convertAdvanced() const;
124 void setConvertAdvanced(bool);
125
126 // encode
127 QString encodePath() const;
128 void setEncodePath(const QString &);
129 bool encodeFreeSpaceCheck() const;
130 void setEncodeFreeSpaceCheck(bool);
131 bool encodeUseHardware() const;
132 void setEncodeUseHardware(bool);
133 QStringList encodeHardware() const;
134 void setEncodeHardware(const QStringList &);
135 bool encodeAdvanced() const;
136 void setEncodeAdvanced(bool);
137 bool showConvertClipDialog() const;
138 void setShowConvertClipDialog(bool);
139 bool encodeParallelProcessing() const;
140 void setEncodeParallelProcessing(bool);
141
142 // player
143 int playerAudioChannels() const;
144 void setPlayerAudioChannels(int);
145 QString playerDeinterlacer() const;
146 void setPlayerDeinterlacer(const QString &);
147 QString playerExternal() const;
148 void setPlayerExternal(const QString &);
149 bool playerGPU() const;
150 void setPlayerGPU(bool);
151 bool playerWarnGPU() const;
152 QString playerInterpolation() const;
153 void setPlayerInterpolation(const QString &);
154 bool playerJACK() const;
155 void setPlayerJACK(bool);
156 int playerKeyerMode() const;
157 void setPlayerKeyerMode(int);
158 bool playerMuted() const;
159 void setPlayerMuted(bool);
160 QString playerProfile() const;
161 void setPlayerProfile(const QString &);
162 bool playerProgressive() const;
163 void setPlayerProgressive(bool);
164 bool playerRealtime() const;
165 void setPlayerRealtime(bool);
166 bool playerScrubAudio() const;
167 void setPlayerScrubAudio(bool);
168 int playerVolume() const;
169 void setPlayerVolume(int);
170 float playerZoom() const;
171 void setPlayerZoom(float);
172 int playerPreviewScale() const;
173 void setPlayerPreviewScale(int);
174 int playerVideoDelayMs() const;
175 void setPlayerVideoDelayMs(int);
176 double playerJumpSeconds() const;
177 void setPlayerJumpSeconds(double);
178 QString playerAudioDriver() const;
179 void setPlayerAudioDriver(const QString &s);
180 bool playerPauseAfterSeek() const;
181 void setPlayerPauseAfterSeek(bool);
182
183 // playlist
184 QString playlistThumbnails() const;
185 void setPlaylistThumbnails(const QString &);
186 bool playlistAutoplay() const;
187 void setPlaylistAutoplay(bool);
188 bool playlistShowColumn(const QString &);
189 void setPlaylistShowColumn(const QString &, bool);
190
191 // timeline
192 bool timelineDragScrub() const;
193 void setTimelineDragScrub(bool);
194 bool timelineShowWaveforms() const;
195 void setTimelineShowWaveforms(bool);
196 bool timelineShowThumbnails() const;
197 void setTimelineShowThumbnails(bool);
198 bool timelineRipple() const;
199 void setTimelineRipple(bool);
200 bool timelineRippleAllTracks() const;
201 void setTimelineRippleAllTracks(bool);
202 bool timelineRippleMarkers() const;
203 void setTimelineRippleMarkers(bool);
204 bool timelineSnap() const;
205 void setTimelineSnap(bool);
206 int timelineTrackHeight() const;
207 void setTimelineTrackHeight(int);
208 bool timelineScrollZoom() const;
209 void setTimelineScrollZoom(bool);
210 bool timelineFramebufferWaveform() const;
211 void setTimelineFramebufferWaveform(bool);
212 int audioReferenceTrack() const;
213 void setAudioReferenceTrack(int);
214 double audioReferenceSpeedRange() const;
215 void setAudioReferenceSpeedRange(double);
216 bool timelinePreviewTransition() const;
217 void setTimelinePreviewTransition(bool);
218 void setTimelineScrolling(TimelineScrolling value);
219 TimelineScrolling timelineScrolling() const;
220 bool timelineAutoAddTracks() const;
221 void setTimelineAutoAddTracks(bool);
222 bool timelineRectangleSelect() const;
223 void setTimelineRectangleSelect(bool);
224
225 // filter
226 QString filterFavorite(const QString &filterName);
227 void setFilterFavorite(const QString &filterName, const QString &value);
228 double audioInDuration() const;
229 void setAudioInDuration(double);
230 double audioOutDuration() const;
231 void setAudioOutDuration(double);
232 double videoInDuration() const;
233 void setVideoInDuration(double);
234 double videoOutDuration() const;
235 void setVideoOutDuration(double);
236 int audioInCurve() const;
237 void setAudioInCurve(int);
238 int audioOutCurve() const;
239 void setAudioOutCurve(int);
240 bool askOutputFilter() const;
241 void setAskOutputFilter(bool);
242
243 // scope
244 bool loudnessScopeShowMeter(const QString &meter) const;
245 void setLoudnessScopeShowMeter(const QString &meter, bool b);
246
247 // Markers
248 void setMarkerColor(const QColor &color);
249 QColor markerColor() const;
250 void setMarkersShowColumn(const QString &column, bool b);
251 bool markersShowColumn(const QString &column) const;
252 void setMarkerSort(int column, Qt::SortOrder order);
253 int getMarkerSortColumn();
254 Qt::SortOrder getMarkerSortOrder();
255
256 // general continued
257 int drawMethod() const;
258 void setDrawMethod(int);
259 bool noUpgrade() const;
260 void setNoUpgrade(bool value);
261 bool checkUpgradeAutomatic();
262 void setCheckUpgradeAutomatic(bool b);
263 bool askUpgradeAutomatic();
264 void setAskUpgradeAutomatic(bool b);
265 bool askChangeVideoMode();
266 void setAskChangeVideoMode(bool b);
267
268 void sync();
269 QString appDataLocation() const;
270 static void setAppDataForSession(const QString &location);
271 void setAppDataLocally(const QString &location);
272
273 // layout
274 QStringList layouts() const;
275 bool setLayout(const QString &name, const QByteArray &geometry, const QByteArray &state);
276 QByteArray layoutGeometry(const QString &name);
277 QByteArray layoutState(const QString &name);
278 bool removeLayout(const QString &name);
279 int layoutMode() const;
280 void setLayoutMode(int mode = 0);
281
282 // general continued
283 bool clearRecent() const;
284 void setClearRecent(bool);
285 QString projectsFolder() const;
286 void setProjectsFolder(const QString &path);
287 QString audioInput() const;
288 void setAudioInput(const QString &name);
289 QString videoInput() const;
290 void setVideoInput(const QString &name);
291 QString glaxnimatePath() const;
292 void setGlaxnimatePath(const QString &path);
293 bool exportRangeMarkers() const;
294 void setExportRangeMarkers(bool);
295 int undoLimit() const;
296 bool warnLowMemory() const;
297 int backupPeriod() const;
298 void setBackupPeriod(int i);
299 mlt_time_format timeFormat() const;
300 void setTimeFormat(int format);
301
302 // proxy
303 bool proxyEnabled() const;
304 void setProxyEnabled(bool);
305 QString proxyFolder() const;
306 void setProxyFolder(const QString &path);
307 bool proxyUseProjectFolder() const;
308 void setProxyUseProjectFolder(bool);
309 bool proxyUseHardware() const;
310 void setProxyUseHardware(bool);
311
312 // Shortcuts
313 void clearShortcuts(const QString &name);
314 void setShortcuts(const QString &name, const QList<QKeySequence> &shortcuts);
315 QList<QKeySequence> shortcuts(const QString &name);
316
317 // Slideshow
318 double slideshowClipDuration(double defaultClipDuration) const;
319 void setSlideshowClipDuration(double clipDuration);
320 int slideshowAspectConversion(int defaultAspectConversion) const;
321 void setSlideshowAspectConversion(int aspectConversion);
322 int slideshowZoomPercent(int defaultZoomPercent) const;
323 void setSlideshowZoomPercent(int zoomPercent);
324 double slideshowTransitionDuration(double defaultTransitionDuration) const;
325 void setSlideshowTransitionDuration(double transitionDuration);
326 int slideshowTransitionStyle(int defaultTransitionStyle) const;
327 void setSlideshowTransitionStyle(int transitionStyle);
328 int slideshowTransitionSoftness(int defaultTransitionSoftness) const;
329 void setSlideshowTransitionSoftness(int transitionSoftness);
330
331 // Keyframes
332 bool keyframesDragScrub() const;
333 void setKeyframesDragScrub(bool);
334
335 // Subtitles
336 void setSubtitlesShowColumn(const QString &column, bool b);
337 bool subtitlesShowColumn(const QString &column) const;
338 void setSubtitlesTrackTimeline(bool b);
339 bool subtitlesTrackTimeline() const;
340 void setSubtitlesShowPrevNext(bool b);
341 bool subtitlesShowPrevNext() const;
342 void setWhisperExe(const QString &path);
343 QString whisperExe();
344 void setWhisperModel(const QString &path);
345 QString whisperModel();
346
347 // Notes
348 void setNotesZoom(int zoom);
349 int notesZoom() const;
350
351 // Files
352 QString filesViewMode() const;
353 void setFilesViewMode(const QString &viewMode);
354 QStringList filesLocations() const;
355 QString filesLocationPath(const QString &name) const;
356 bool setFilesLocation(const QString &name, const QString &path);
357 bool removeFilesLocation(const QString &name);
358 QStringList filesOpenOther(const QString &type) const;
359 void setFilesOpenOther(const QString &type, const QString &filePath);
360 bool removeFilesOpenOther(const QString &type, const QString &filePath);
361 QString filesCurrentDir() const;
362 void setFilesCurrentDir(const QString &s);
363 bool filesFoldersOpen() const;
364 void setFilesFoldersOpen(bool b);
365
366public slots:
367 void reset();
368
369signals:
370 void openPathChanged();
371 void savePathChanged();
372 void timelineDragScrubChanged();
373 void timelineShowWaveformsChanged();
374 void timelineShowThumbnailsChanged();
375 void timelineRippleChanged();
376 void timelineRippleAllTracksChanged();
377 void timelineRippleMarkersChanged();
378 void timelineSnapChanged();
379 void timelineScrollZoomChanged();
380 void timelineFramebufferWaveformChanged();
381 void playerAudioChannelsChanged(int);
382 void playerGpuChanged();
383 void audioInDurationChanged();
384 void audioOutDurationChanged();
385 void videoInDurationChanged();
386 void videoOutDurationChanged();
387 void audioInCurveChanged();
388 void audioOutCurveChanged();
389 void playlistThumbnailsChanged();
390 void viewModeChanged();
391 void filesViewModeChanged();
392 void smallIconsChanged();
393 void askOutputFilterChanged();
394 void timelineScrollingChanged();
395 void timelineAutoAddTracksChanged();
396 void timelineRectangleSelectChanged();
397 void timeFormatChanged();
398 void keyframesDragScrubChanged();
399
400private:
401 explicit ShotcutSettings();
402 explicit ShotcutSettings(const QString &appDataLocation);
403 void migrateRecent();
404 void migrateLayout();
405
406 QSettings settings;
407 QString m_appDataLocation;
408 QSettings m_recent;
409};
410
411#define Settings ShotcutSettings::singleton()
412
413#endif // SETTINGS_H