Skip to content

Commit f880ec3

Browse files
committed
Allow build with qt6
1 parent 9a16be0 commit f880ec3

File tree

9 files changed

+43
-17
lines changed

9 files changed

+43
-17
lines changed

lib/src/abstractvoicecallhandler.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323

2424
#include <QObject>
2525
#include <QDateTime>
26-
26+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
27+
Q_MOC_INCLUDE("abstractvoicecallprovider.h");
28+
#endif
2729
class AbstractVoiceCallProvider;
2830

2931
class AbstractVoiceCallHandler : public QObject

plugins/declarative/src/src.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ TARGET = voicecall
99
uri = org.nemomobile.voicecall
1010

1111
enable-ngf {
12-
PKGCONFIG += ngf-qt5
12+
PKGCONFIG += ngf-qt$${QT_MAJOR_VERSION}
1313
DEFINES += WITH_NGF
1414
}
1515

plugins/declarative/src/voicecallaudiorecorder.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
#include "voicecallaudiorecorder.h"
3636

37+
#include <QAudioFormat>
3738
#include <QDateTime>
3839
#include <QDBusConnection>
3940
#include <QDBusMessage>
@@ -44,7 +45,10 @@
4445
#include <QDataStream>
4546
#include <QStandardPaths>
4647
#include <QtDebug>
47-
48+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
49+
#include <QAudioDevice>
50+
#include <QMediaDevices>
51+
#endif
4852
#include <unistd.h>
4953

5054
namespace {
@@ -69,17 +73,25 @@ QAudioFormat getRecordingFormat()
6973
QAudioFormat format;
7074

7175
format.setChannelCount(ChannelCount);
76+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
77+
format.setSampleFormat(QAudioFormat::Int16);
7278
format.setSampleRate(SampleRate);
79+
80+
QAudioDevice device(QMediaDevices::defaultAudioInput());
81+
if (!device.isFormatSupported(format)) {
82+
format = device.preferredFormat();
83+
}
84+
#else
7385
format.setSampleSize(SampleBits);
7486
format.setCodec(QStringLiteral("audio/pcm"));
7587
format.setByteOrder(QAudioFormat::LittleEndian);
7688
format.setSampleType(QAudioFormat::UnSignedInt);
77-
7889
QAudioDeviceInfo info(QAudioDeviceInfo::defaultInputDevice());
90+
7991
if (!info.isFormatSupported(format)) {
8092
format = info.nearestFormat(format);
8193
}
82-
94+
#endif
8395
return format;
8496
}
8597

@@ -241,11 +253,13 @@ void VoiceCallAudioRecorder::featuresCallFinished(QDBusPendingCallWatcher *watch
241253
void VoiceCallAudioRecorder::inputStateChanged(QAudio::State state)
242254
{
243255
if (state == QAudio::StoppedState) {
256+
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
244257
if (input) {
245258
if (input->error() != QAudio::NoError) {
246259
qWarning() << "Recording stopped due to error:" << input->error();
247260
}
248261
}
262+
#endif
249263
terminateRecording();
250264
}
251265
}
@@ -295,10 +309,13 @@ bool VoiceCallAudioRecorder::initiateRecording(const QString &fileName)
295309
}
296310

297311
output.swap(file);
298-
312+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
313+
input.reset(new QAudioSource(recordingFormat));
314+
connect(input.data(), &QAudioSource::stateChanged, this, &VoiceCallAudioRecorder::inputStateChanged);
315+
#else
299316
input.reset(new QAudioInput(recordingFormat));
300317
connect(input.data(), &QAudioInput::stateChanged, this, &VoiceCallAudioRecorder::inputStateChanged);
301-
318+
#endif
302319
input->start(output.data());
303320
active = true;
304321
emit recordingChanged();

plugins/declarative/src/voicecallaudiorecorder.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@
3434

3535
#ifndef VOICECALLAUDIORECORDER_H
3636
#define VOICECALLAUDIORECORDER_H
37-
37+
#include <QtCore>
38+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
39+
#include <QAudioSource>
40+
#else
3841
#include <QAudioInput>
42+
#endif
3943
#include <QFile>
4044
#include <QScopedPointer>
4145
#include <QDBusPendingCallWatcher>
@@ -85,8 +89,11 @@ private slots:
8589
private:
8690
bool initiateRecording(const QString &fileName);
8791
void terminateRecording();
88-
92+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
93+
QScopedPointer<QAudioSource> input;
94+
#else
8995
QScopedPointer<QAudioInput> input;
96+
#endif
9097
QScopedPointer<QFile> output;
9198
QString label;
9299
bool featureAvailable;

plugins/declarative/src/voicecallhandler.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
#include <QDBusInterface>
88
#include <QDBusPendingCallWatcher>
99

10+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
11+
Q_MOC_INCLUDE("voicecallmodel.h");
12+
#endif
13+
1014
class VoiceCallModel;
1115

1216
class VoiceCallHandler : public QObject

plugins/ngf/src/src.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include(../../plugin.pri)
22
TARGET = voicecall-ngf-plugin
33

4-
PKGCONFIG += ngf-qt5
4+
PKGCONFIG += ngf-qt$${QT_MAJOR_VERSION}
55

66
DEFINES += PLUGIN_NAME=\\\"ngf-plugin\\\"
77

plugins/plugin.pri

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
TEMPLATE = lib
22
QT = core
3-
CONFIG += plugin link_pkgconfig c++11
4-
5-
QMAKE_CXXFLAGS += -std=c++0x
3+
CONFIG += plugin link_pkgconfig
64

75
# includes are ok all the time, yes, really.
86
# it's only used for some macros.
97
INCLUDEPATH += $$PWD/../lib/src
108

11-
LIBS += -L$$PWD/../lib/src -lvoicecall
12-
139
target.path = $$[QT_INSTALL_LIBS]/voicecall/plugins
1410
INSTALLS += target

plugins/providers/ofono/src/src.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ include(../../../plugin.pri)
22
TARGET = voicecall-ofono-plugin
33
QT += dbus
44

5-
PKGCONFIG += qofono-qt5
5+
PKGCONFIG += qofono-qt$${QT_MAJOR_VERSION}
66

77
HEADERS += \
88
ofonovoicecallhandler.h \

src/src.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ INCLUDEPATH += ../lib/src
88
DEFINES += VOICECALL_PLUGIN_DIRECTORY=\"\\\"$$[QT_INSTALL_LIBS]/voicecall/plugins\\\"\"
99

1010
enable-nemo-devicelock {
11-
PKGCONFIG += libresourceqt5 nemodevicelock
11+
PKGCONFIG += libresourceqt$${QT_MAJOR_VERSION} nemodevicelock
1212
DEFINES += WITH_NEMO_DEVICELOCK
1313
}
1414

0 commit comments

Comments
 (0)