Skip to content

Commit 459e3e3

Browse files
committed
Add ExportPage
1 parent 7fbb6ae commit 459e3e3

4 files changed

Lines changed: 183 additions & 0 deletions

File tree

src/plugins/audio/internal/AudioPlugin.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <audio/internal/AudioOutputPage.h>
2424
#include <audio/internal/AudioPreference.h>
2525
#include <audio/internal/AudioClipAddOn.h>
26+
#include <audio/internal/ExportPage.h>
2627
#include <audio/internal/ExportAudioAddOn.h>
2728
#include <audio/internal/ProjectAudioAddOn.h>
2829
#include <audio/internal/PlaybackAddOn.h>
@@ -95,6 +96,7 @@ namespace Audio::Internal {
9596
auto audioAndMidiPage = new AudioAndMidiPage;
9697
audioAndMidiPage->addPage(new AudioOutputPage);
9798
audioAndMidiPage->addPage(new PlaybackPage);
99+
audioAndMidiPage->addPage(new ExportPage);
98100
sc->addPage(audioAndMidiPage);
99101
}
100102

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#include "ExportPage.h"
2+
3+
#include <QLoggingCategory>
4+
#include <QQmlComponent>
5+
6+
#include <CoreApi/runtimeinterface.h>
7+
8+
#include <audio/internal/AudioPreference.h>
9+
10+
namespace Audio::Internal {
11+
12+
Q_STATIC_LOGGING_CATEGORY(lcExportPage, "diffscope.audio.exportpage")
13+
14+
ExportPage::ExportPage(QObject *parent) : Core::ISettingPage("audio.Export", parent) {
15+
setTitle(tr("Export"));
16+
setDescription(tr("Configure audio export behavior"));
17+
}
18+
19+
ExportPage::~ExportPage() {
20+
delete m_widget;
21+
}
22+
23+
bool ExportPage::matches(const QString &word) {
24+
return ISettingPage::matches(word) || widgetMatches(word);
25+
}
26+
27+
QString ExportPage::sortKeyword() const {
28+
return QStringLiteral("Export");
29+
}
30+
31+
QObject *ExportPage::widget() {
32+
if (m_widget)
33+
return m_widget;
34+
qCDebug(lcExportPage) << "Creating widget";
35+
QQmlComponent component(Core::RuntimeInterface::qmlEngine(), "DiffScope.Audio", "ExportPage");
36+
if (component.isError()) {
37+
qFatal() << component.errorString();
38+
}
39+
m_widget = component.createWithInitialProperties({{"pageHandle", QVariant::fromValue(this)}});
40+
m_widget->setParent(this);
41+
return m_widget;
42+
}
43+
44+
void ExportPage::beginSetting() {
45+
qCInfo(lcExportPage) << "Beginning setting";
46+
widget();
47+
m_widget->setProperty("audioExporterClippingCheckEnabled", AudioPreference::instance()->property("audioExporterClippingCheckEnabled"));
48+
qCDebug(lcExportPage) << "audioExporterClippingCheckEnabled" << m_widget->property("audioExporterClippingCheckEnabled");
49+
m_widget->setProperty("audioExporterUseTemporaryFile", AudioPreference::instance()->property("audioExporterUseTemporaryFile"));
50+
qCDebug(lcExportPage) << "audioExporterUseTemporaryFile" << m_widget->property("audioExporterUseTemporaryFile");
51+
m_widget->setProperty("shouldPlayNotificationSoundWhenExportCompleted", AudioPreference::instance()->property("shouldPlayNotificationSoundWhenExportCompleted"));
52+
qCDebug(lcExportPage) << "shouldPlayNotificationSoundWhenExportCompleted" << m_widget->property("shouldPlayNotificationSoundWhenExportCompleted");
53+
m_widget->setProperty("started", true);
54+
ISettingPage::beginSetting();
55+
}
56+
57+
bool ExportPage::accept() {
58+
qCInfo(lcExportPage) << "Accepting";
59+
qCDebug(lcExportPage) << "audioExporterClippingCheckEnabled" << m_widget->property("audioExporterClippingCheckEnabled");
60+
AudioPreference::instance()->setProperty("audioExporterClippingCheckEnabled", m_widget->property("audioExporterClippingCheckEnabled"));
61+
qCDebug(lcExportPage) << "audioExporterUseTemporaryFile" << m_widget->property("audioExporterUseTemporaryFile");
62+
AudioPreference::instance()->setProperty("audioExporterUseTemporaryFile", m_widget->property("audioExporterUseTemporaryFile"));
63+
qCDebug(lcExportPage) << "shouldPlayNotificationSoundWhenExportCompleted" << m_widget->property("shouldPlayNotificationSoundWhenExportCompleted");
64+
AudioPreference::instance()->setProperty("shouldPlayNotificationSoundWhenExportCompleted", m_widget->property("shouldPlayNotificationSoundWhenExportCompleted"));
65+
AudioPreference::instance()->save();
66+
return ISettingPage::accept();
67+
}
68+
69+
void ExportPage::endSetting() {
70+
qCInfo(lcExportPage) << "Ending setting";
71+
m_widget->setProperty("started", false);
72+
ISettingPage::endSetting();
73+
}
74+
75+
bool ExportPage::widgetMatches(const QString &word) {
76+
widget();
77+
auto matcher = m_widget->property("matcher").value<QObject *>();
78+
bool ret = false;
79+
QMetaObject::invokeMethod(matcher, "matches", qReturnArg(ret), word);
80+
return ret;
81+
}
82+
83+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#ifndef DIFFSCOPE_AUDIOPLUGIN_EXPORTPAGE_H
2+
#define DIFFSCOPE_AUDIOPLUGIN_EXPORTPAGE_H
3+
4+
#include <CoreApi/isettingpage.h>
5+
6+
namespace Audio::Internal {
7+
8+
class ExportPage : public Core::ISettingPage {
9+
Q_OBJECT
10+
public:
11+
explicit ExportPage(QObject *parent = nullptr);
12+
~ExportPage() override;
13+
14+
bool matches(const QString &word) override;
15+
QString sortKeyword() const override;
16+
QObject *widget() override;
17+
void beginSetting() override;
18+
bool accept() override;
19+
void endSetting() override;
20+
21+
private:
22+
bool widgetMatches(const QString &word);
23+
QObject *m_widget{};
24+
};
25+
26+
}
27+
28+
#endif // DIFFSCOPE_AUDIOPLUGIN_EXPORTPAGE_H
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import QtQml
2+
import QtQuick
3+
import QtQuick.Controls
4+
import QtQuick.Layouts
5+
6+
import SVSCraft
7+
import SVSCraft.UIComponents
8+
9+
ScrollView {
10+
id: page
11+
12+
required property QtObject pageHandle
13+
property bool started: false
14+
15+
property bool audioExporterClippingCheckEnabled
16+
property bool audioExporterUseTemporaryFile
17+
property bool shouldPlayNotificationSoundWhenExportCompleted
18+
19+
onAudioExporterClippingCheckEnabledChanged: if (started) pageHandle.markDirty()
20+
onAudioExporterUseTemporaryFileChanged: if (started) pageHandle.markDirty()
21+
onShouldPlayNotificationSoundWhenExportCompletedChanged: if (started) pageHandle.markDirty()
22+
23+
anchors.fill: parent
24+
contentWidth: availableWidth
25+
26+
readonly property TextMatcher matcher: TextMatcher {}
27+
28+
ColumnLayout {
29+
width: page.width
30+
ColumnLayout {
31+
Layout.fillWidth: true
32+
Layout.margins: 12
33+
spacing: 32
34+
GroupBox {
35+
title: qsTr("Export")
36+
TextMatcherItem on title {
37+
matcher: page.matcher
38+
}
39+
Layout.fillWidth: true
40+
ColumnLayout {
41+
anchors.fill: parent
42+
CheckBox {
43+
text: qsTr("Check clipping when exporting audio")
44+
TextMatcherItem on text {
45+
matcher: page.matcher
46+
}
47+
checked: page.audioExporterClippingCheckEnabled
48+
onClicked: page.audioExporterClippingCheckEnabled = checked
49+
}
50+
CheckBox {
51+
text: qsTr("Use temporary file when exporting audio")
52+
TextMatcherItem on text {
53+
matcher: page.matcher
54+
}
55+
checked: page.audioExporterUseTemporaryFile
56+
onClicked: page.audioExporterUseTemporaryFile = checked
57+
}
58+
CheckBox {
59+
text: qsTr("Play notification sound when export completes")
60+
TextMatcherItem on text {
61+
matcher: page.matcher
62+
}
63+
checked: page.shouldPlayNotificationSoundWhenExportCompleted
64+
onClicked: page.shouldPlayNotificationSoundWhenExportCompleted = checked
65+
}
66+
}
67+
}
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)