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 
29 class 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 
79 public:
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 playerDecklinkGamma() const;
157  void setPlayerDecklinkGamma(int);
158  int playerKeyerMode() const;
159  void setPlayerKeyerMode(int);
160  bool playerMuted() const;
161  void setPlayerMuted(bool);
162  QString playerProfile() const;
163  void setPlayerProfile(const QString &);
164  bool playerProgressive() const;
165  void setPlayerProgressive(bool);
166  bool playerRealtime() const;
167  void setPlayerRealtime(bool);
168  bool playerScrubAudio() const;
169  void setPlayerScrubAudio(bool);
170  int playerVolume() const;
171  void setPlayerVolume(int);
172  float playerZoom() const;
173  void setPlayerZoom(float);
174  int playerPreviewScale() const;
175  void setPlayerPreviewScale(int);
176  int playerVideoDelayMs() const;
177  void setPlayerVideoDelayMs(int);
178  double playerJumpSeconds() const;
179  void setPlayerJumpSeconds(double);
180  QString playerAudioDriver() const;
181  void setPlayerAudioDriver(const QString &s);
182  bool playerPauseAfterSeek() const;
183  void setPlayerPauseAfterSeek(bool);
184 
185  // playlist
186  QString playlistThumbnails() const;
187  void setPlaylistThumbnails(const QString &);
188  bool playlistAutoplay() const;
189  void setPlaylistAutoplay(bool);
190  bool playlistShowColumn(const QString &);
191  void setPlaylistShowColumn(const QString &, bool);
192 
193  // timeline
194  bool timelineDragScrub() const;
195  void setTimelineDragScrub(bool);
196  bool timelineShowWaveforms() const;
197  void setTimelineShowWaveforms(bool);
198  bool timelineShowThumbnails() const;
199  void setTimelineShowThumbnails(bool);
200  bool timelineRipple() const;
201  void setTimelineRipple(bool);
202  bool timelineRippleAllTracks() const;
203  void setTimelineRippleAllTracks(bool);
204  bool timelineRippleMarkers() const;
205  void setTimelineRippleMarkers(bool);
206  bool timelineSnap() const;
207  void setTimelineSnap(bool);
208  int timelineTrackHeight() const;
209  void setTimelineTrackHeight(int);
210  bool timelineScrollZoom() const;
211  void setTimelineScrollZoom(bool);
212  bool timelineFramebufferWaveform() const;
213  void setTimelineFramebufferWaveform(bool);
214  int audioReferenceTrack() const;
215  void setAudioReferenceTrack(int);
216  double audioReferenceSpeedRange() const;
217  void setAudioReferenceSpeedRange(double);
218  bool timelinePreviewTransition() const;
219  void setTimelinePreviewTransition(bool);
220  void setTimelineScrolling(TimelineScrolling value);
221  TimelineScrolling timelineScrolling() const;
222  bool timelineAutoAddTracks() const;
223  void setTimelineAutoAddTracks(bool);
224  bool timelineRectangleSelect() const;
225  void setTimelineRectangleSelect(bool);
226 
227  // filter
228  QString filterFavorite(const QString &filterName);
229  void setFilterFavorite(const QString &filterName, const QString &value);
230  double audioInDuration() const;
231  void setAudioInDuration(double);
232  double audioOutDuration() const;
233  void setAudioOutDuration(double);
234  double videoInDuration() const;
235  void setVideoInDuration(double);
236  double videoOutDuration() const;
237  void setVideoOutDuration(double);
238  int audioInCurve() const;
239  void setAudioInCurve(int);
240  int audioOutCurve() const;
241  void setAudioOutCurve(int);
242  bool askOutputFilter() const;
243  void setAskOutputFilter(bool);
244 
245  // scope
246  bool loudnessScopeShowMeter(const QString &meter) const;
247  void setLoudnessScopeShowMeter(const QString &meter, bool b);
248 
249  // Markers
250  void setMarkerColor(const QColor &color);
251  QColor markerColor() const;
252  void setMarkersShowColumn(const QString &column, bool b);
253  bool markersShowColumn(const QString &column) const;
254  void setMarkerSort(int column, Qt::SortOrder order);
255  int getMarkerSortColumn();
256  Qt::SortOrder getMarkerSortOrder();
257 
258  // general continued
259  int drawMethod() const;
260  void setDrawMethod(int);
261  bool noUpgrade() const;
262  void setNoUpgrade(bool value);
263  bool checkUpgradeAutomatic();
264  void setCheckUpgradeAutomatic(bool b);
265  bool askUpgradeAutomatic();
266  void setAskUpgradeAutomatic(bool b);
267  bool askChangeVideoMode();
268  void setAskChangeVideoMode(bool b);
269 
270  void sync();
271  QString appDataLocation() const;
272  static void setAppDataForSession(const QString &location);
273  void setAppDataLocally(const QString &location);
274 
275  // layout
276  QStringList layouts() const;
277  bool setLayout(const QString &name, const QByteArray &geometry, const QByteArray &state);
278  QByteArray layoutGeometry(const QString &name);
279  QByteArray layoutState(const QString &name);
280  bool removeLayout(const QString &name);
281  int layoutMode() const;
282  void setLayoutMode(int mode = 0);
283 
284  // general continued
285  bool clearRecent() const;
286  void setClearRecent(bool);
287  QString projectsFolder() const;
288  void setProjectsFolder(const QString &path);
289  QString audioInput() const;
290  void setAudioInput(const QString &name);
291  QString videoInput() const;
292  void setVideoInput(const QString &name);
293  QString glaxnimatePath() const;
294  void setGlaxnimatePath(const QString &path);
295  bool exportRangeMarkers() const;
296  void setExportRangeMarkers(bool);
297  int undoLimit() const;
298  bool warnLowMemory() const;
299  int backupPeriod() const;
300  void setBackupPeriod(int i);
301  mlt_time_format timeFormat() const;
302  void setTimeFormat(int format);
303 
304  // proxy
305  bool proxyEnabled() const;
306  void setProxyEnabled(bool);
307  QString proxyFolder() const;
308  void setProxyFolder(const QString &path);
309  bool proxyUseProjectFolder() const;
310  void setProxyUseProjectFolder(bool);
311  bool proxyUseHardware() const;
312  void setProxyUseHardware(bool);
313 
314  // Shortcuts
315  void clearShortcuts(const QString &name);
316  void setShortcuts(const QString &name, const QList<QKeySequence> &shortcuts);
317  QList<QKeySequence> shortcuts(const QString &name);
318 
319  // Slideshow
320  double slideshowClipDuration(double defaultClipDuration) const;
321  void setSlideshowClipDuration(double clipDuration);
322  int slideshowAspectConversion(int defaultAspectConversion) const;
323  void setSlideshowAspectConversion(int aspectConversion);
324  int slideshowZoomPercent(int defaultZoomPercent) const;
325  void setSlideshowZoomPercent(int zoomPercent);
326  double slideshowTransitionDuration(double defaultTransitionDuration) const;
327  void setSlideshowTransitionDuration(double transitionDuration);
328  int slideshowTransitionStyle(int defaultTransitionStyle) const;
329  void setSlideshowTransitionStyle(int transitionStyle);
330  int slideshowTransitionSoftness(int defaultTransitionSoftness) const;
331  void setSlideshowTransitionSoftness(int transitionSoftness);
332 
333  // Keyframes
334  bool keyframesDragScrub() const;
335  void setKeyframesDragScrub(bool);
336 
337  // Subtitles
338  void setSubtitlesShowColumn(const QString &column, bool b);
339  bool subtitlesShowColumn(const QString &column) const;
340  void setSubtitlesTrackTimeline(bool b);
341  bool subtitlesTrackTimeline() const;
342  void setSubtitlesShowPrevNext(bool b);
343  bool subtitlesShowPrevNext() const;
344  void setWhisperExe(const QString &path);
345  QString whisperExe();
346  void setWhisperModel(const QString &path);
347  QString whisperModel();
348 
349  // Notes
350  void setNotesZoom(int zoom);
351  int notesZoom() const;
352 
353  // Files
354  QString filesViewMode() const;
355  void setFilesViewMode(const QString &viewMode);
356  QStringList filesLocations() const;
357  QString filesLocationPath(const QString &name) const;
358  bool setFilesLocation(const QString &name, const QString &path);
359  bool removeFilesLocation(const QString &name);
360  QStringList filesOpenOther(const QString &type) const;
361  void setFilesOpenOther(const QString &type, const QString &filePath);
362  bool removeFilesOpenOther(const QString &type, const QString &filePath);
363  QString filesCurrentDir() const;
364  void setFilesCurrentDir(const QString &s);
365  bool filesFoldersOpen() const;
366  void setFilesFoldersOpen(bool b);
367 
368 public slots:
369  void reset();
370 
371 signals:
372  void openPathChanged();
373  void savePathChanged();
374  void timelineDragScrubChanged();
375  void timelineShowWaveformsChanged();
376  void timelineShowThumbnailsChanged();
377  void timelineRippleChanged();
378  void timelineRippleAllTracksChanged();
379  void timelineRippleMarkersChanged();
380  void timelineSnapChanged();
381  void timelineScrollZoomChanged();
382  void timelineFramebufferWaveformChanged();
383  void playerAudioChannelsChanged(int);
384  void playerGpuChanged();
385  void audioInDurationChanged();
386  void audioOutDurationChanged();
387  void videoInDurationChanged();
388  void videoOutDurationChanged();
389  void audioInCurveChanged();
390  void audioOutCurveChanged();
391  void playlistThumbnailsChanged();
392  void viewModeChanged();
393  void filesViewModeChanged();
394  void smallIconsChanged();
395  void askOutputFilterChanged();
396  void timelineScrollingChanged();
397  void timelineAutoAddTracksChanged();
398  void timelineRectangleSelectChanged();
399  void timeFormatChanged();
400  void keyframesDragScrubChanged();
401 
402 private:
403  explicit ShotcutSettings();
404  explicit ShotcutSettings(const QString &appDataLocation);
405  void migrateRecent();
406  void migrateLayout();
407 
408  QSettings settings;
409  QString m_appDataLocation;
410  QSettings m_recent;
411 };
412 
413 #define Settings ShotcutSettings::singleton()
414 
415 #endif // SETTINGS_H