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