1 /*
2     SPDX-FileCopyrightText: 2008 Jean-Baptiste Mardelle <jb@kdenlive.org>
3 
4 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
5 */
6 
7 #ifndef KDENLIVESETTINGSDIALOG_H
8 #define KDENLIVESETTINGSDIALOG_H
9 
10 #include <KConfigDialog>
11 #include <KProcess>
12 #include <QMap>
13 #include <QListWidget>
14 
15 #include "ui_configcapture_ui.h"
16 #include "ui_configenv_ui.h"
17 #include "ui_configjogshuttle_ui.h"
18 #include "ui_configmisc_ui.h"
19 #include "ui_configproject_ui.h"
20 #include "ui_configproxy_ui.h"
21 #include "ui_configsdl_ui.h"
22 #include "ui_configtimeline_ui.h"
23 #include "ui_configtranscode_ui.h"
24 #include "ui_configcolors_ui.h"
25 #include "ui_configspeech_ui.h"
26 
27 class ProfileWidget;
28 class KJob;
29 
30 class SpeechList : public QListWidget
31 {
32     Q_OBJECT
33 
34 public:
35     SpeechList(QWidget *parent = nullptr);
36 
37 protected:
38     QStringList mimeTypes() const override;
39     void dropEvent(QDropEvent *event) override;
40 
41 signals:
42     void getDictionary(const QUrl url);
43 };
44 
45 class KdenliveSettingsDialog : public KConfigDialog
46 {
47     Q_OBJECT
48 
49 public:
50     KdenliveSettingsDialog(QMap<QString, QString> mappable_actions, bool gpuAllowed, QWidget *parent = nullptr);
51     ~KdenliveSettingsDialog() override;
52     void showPage(int page, int option);
53     void checkProfile();
54 
55 protected slots:
56     void updateSettings() override;
57     void updateWidgets() override;
58     bool hasChanged() override;
59     void accept() override;
60 
61 private slots:
62     void slotCheckShuttle(int state = 0);
63     void slotUpdateShuttleDevice(int ix = 0);
64     void slotEditImageApplication();
65     void slotEditAudioApplication();
66     void slotReadAudioDevices();
67     void slotUpdateGrabRegionStatus();
68     void slotSetFullscreenMonitor();
69     void slotCheckAlsaDriver();
70     void slotCheckAudioBackend();
71     void slotAddTranscode();
72     void slotDeleteTranscode();
73     /** @brief Update current transcoding profile. */
74     void slotUpdateTranscodingProfile();
75     /** @brief Enable / disable the update profile button. */
76     void slotEnableTranscodeUpdate();
77     /** @brief Update display of current transcoding profile parameters. */
78     void slotSetTranscodeProfile();
79     void slotShuttleModified();
80     void slotDialogModified();
81     void slotEnableCaptureFolder();
82     void slotEnableLibraryFolder();
83     void slotEnableVideoFolder();
84     void slotUpdatev4lDevice();
85     void slotUpdatev4lCaptureProfile();
86     void slotManageEncodingProfile();
87     void slotUpdateDecklinkProfile(int ix = 0);
88     void slotUpdateProxyProfile(int ix = 0);
89     void slotUpdatePreviewProfile(int ix = 0);
90     void slotUpdateV4lProfile(int ix = 0);
91     void slotUpdateGrabProfile(int ix = 0);
92     void slotEditVideo4LinuxProfile();
93     void slotReloadBlackMagic();
94     void slotReloadShuttleDevices();
95     void loadExternalProxyProfiles();
96     void slotUpdateAudioCaptureChannels(int index);
97     void slotUpdateAudioCaptureSampleRate(int index);
98     void slotParseVoskDictionaries();
99     void getDictionary(const QUrl sourceUrl = QUrl());
100     void removeDictionary();
101     void downloadModelFinished(KJob* job);
102     void processArchive(const QString path);
103     void checkVoskDependencies();
104     void doShowSpeechMessage(const QString &message, int messageType);
105 
106 private:
107     KPageWidgetItem *m_page1;
108     KPageWidgetItem *m_page2;
109     KPageWidgetItem *m_page3;
110     KPageWidgetItem *m_page4;
111     KPageWidgetItem *m_page5;
112     KPageWidgetItem *m_page6;
113     KPageWidgetItem *m_page7;
114     KPageWidgetItem *m_page8;
115     KPageWidgetItem *m_page10;
116     KPageWidgetItem *m_page11;
117     Ui::ConfigEnv_UI m_configEnv;
118     Ui::ConfigMisc_UI m_configMisc;
119     Ui::ConfigColors_UI m_configColors;
120     Ui::ConfigTimeline_UI m_configTimeline;
121     Ui::ConfigCapture_UI m_configCapture;
122     Ui::ConfigJogShuttle_UI m_configShuttle;
123     Ui::ConfigSdl_UI m_configSdl;
124     Ui::ConfigTranscode_UI m_configTranscode;
125     Ui::ConfigProject_UI m_configProject;
126     Ui::ConfigProxy_UI m_configProxy;
127     Ui::ConfigSpeech_UI m_configSpeech;
128     SpeechList *m_speechListWidget;
129     ProfileWidget *m_pw;
130     KProcess m_readProcess;
131     QAction *m_voskAction;
132     bool m_modified;
133     bool m_shuttleModified;
134     bool m_voskUpdated;
135     QMap<QString, QString> m_mappable_actions;
136     QVector<QComboBox *> m_shuttle_buttons;
137     void initDevices();
138     void loadTranscodeProfiles();
139     void saveTranscodeProfiles();
140     void loadCurrentV4lProfileInfo();
141     void saveCurrentV4lProfile();
142     void loadEncodingProfiles();
143     void setupJogshuttleBtns(const QString &device);
144     /** @brief Fill a combobox with the found blackmagic devices */
145     static bool getBlackMagicDeviceList(QComboBox *devicelist, bool force = false);
146     static bool getBlackMagicOutputDeviceList(QComboBox *devicelist, bool force = false);
147     /** @brief Init QtMultimedia audio record settings */
148     bool initAudioRecDevice();
149     /** @brief Init Speech to text settings */
150     void initSpeechPage();
151     /** @brief Check version of installed python modules for speech to text */
152     void checkVoskVersion(const QString pyExec);
153 
154 signals:
155     void customChanged();
156     void doResetConsumer(bool fullReset);
157     void updateCaptureFolder();
158     void updateLibraryFolder();
159     // Screengrab method changed between fullsceen and region, update rec monitor
160     void updateFullScreenGrab();
161     /** @brief A settings changed that requires a Kdenlive restart, trigger it */
162     void restartKdenlive(bool resetConfig = false);
163     void checkTabPosition();
164     /** @brief Switch between merged / separate channels for audio thumbs */
165     void audioThumbFormatChanged();
166     /** @brief An important timeline property changed, prepare for a reset */
167     void resetView();
168     /** @brief Monitor background color changed, update monitors */
169     void updateMonitorBg();
170     /** @brief Trigger parsing of the speech models folder */
171     void parseDictionaries();
172     /** @brief Show an info message regarding speech to text status */
173     void showSpeechMessage(const QString &message, int messageType);
174 };
175 
176 #endif
177