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