Skip to content

Allow build with qt6 #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/src/abstractvoicecallhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@

#include <QObject>
#include <QDateTime>

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
Q_MOC_INCLUDE("abstractvoicecallprovider.h");
#endif
class AbstractVoiceCallProvider;

class AbstractVoiceCallHandler : public QObject
Expand Down
2 changes: 1 addition & 1 deletion plugins/declarative/src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ TARGET = voicecall
uri = org.nemomobile.voicecall

enable-ngf {
PKGCONFIG += ngf-qt5
PKGCONFIG += ngf-qt$${QT_MAJOR_VERSION}
DEFINES += WITH_NGF
}

Expand Down
27 changes: 22 additions & 5 deletions plugins/declarative/src/voicecallaudiorecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#include "voicecallaudiorecorder.h"

#include <QAudioFormat>
#include <QDateTime>
#include <QDBusConnection>
#include <QDBusMessage>
Expand All @@ -44,7 +45,10 @@
#include <QDataStream>
#include <QStandardPaths>
#include <QtDebug>

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <QAudioDevice>
#include <QMediaDevices>
#endif
#include <unistd.h>

namespace {
Expand All @@ -69,17 +73,25 @@ QAudioFormat getRecordingFormat()
QAudioFormat format;

format.setChannelCount(ChannelCount);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
format.setSampleFormat(QAudioFormat::Int16);
format.setSampleRate(SampleRate);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now missing on qt5 case.


QAudioDevice device(QMediaDevices::defaultAudioInput());
if (!device.isFormatSupported(format)) {
format = device.preferredFormat();
}
#else
format.setSampleSize(SampleBits);
format.setCodec(QStringLiteral("audio/pcm"));
format.setByteOrder(QAudioFormat::LittleEndian);
format.setSampleType(QAudioFormat::UnSignedInt);

QAudioDeviceInfo info(QAudioDeviceInfo::defaultInputDevice());

if (!info.isFormatSupported(format)) {
format = info.nearestFormat(format);
}

#endif
return format;
}

Expand Down Expand Up @@ -241,11 +253,13 @@ void VoiceCallAudioRecorder::featuresCallFinished(QDBusPendingCallWatcher *watch
void VoiceCallAudioRecorder::inputStateChanged(QAudio::State state)
{
if (state == QAudio::StoppedState) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (input) {
if (input->error() != QAudio::NoError) {
qWarning() << "Recording stopped due to error:" << input->error();
}
}
#endif
terminateRecording();
}
}
Expand Down Expand Up @@ -295,10 +309,13 @@ bool VoiceCallAudioRecorder::initiateRecording(const QString &fileName)
}

output.swap(file);

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
input.reset(new QAudioSource(recordingFormat));
connect(input.data(), &QAudioSource::stateChanged, this, &VoiceCallAudioRecorder::inputStateChanged);
#else
input.reset(new QAudioInput(recordingFormat));
connect(input.data(), &QAudioInput::stateChanged, this, &VoiceCallAudioRecorder::inputStateChanged);

#endif
input->start(output.data());
active = true;
emit recordingChanged();
Expand Down
11 changes: 9 additions & 2 deletions plugins/declarative/src/voicecallaudiorecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@

#ifndef VOICECALLAUDIORECORDER_H
#define VOICECALLAUDIORECORDER_H

#include <QtCore>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole QtCore? Why?

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <QAudioSource>
#else
#include <QAudioInput>
#endif
#include <QFile>
#include <QScopedPointer>
#include <QDBusPendingCallWatcher>
Expand Down Expand Up @@ -85,8 +89,11 @@ private slots:
private:
bool initiateRecording(const QString &fileName);
void terminateRecording();

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QScopedPointer<QAudioSource> input;
#else
QScopedPointer<QAudioInput> input;
#endif
QScopedPointer<QFile> output;
QString label;
bool featureAvailable;
Expand Down
4 changes: 4 additions & 0 deletions plugins/declarative/src/voicecallhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include <QDBusInterface>
#include <QDBusPendingCallWatcher>

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
Q_MOC_INCLUDE("voicecallmodel.h");
#endif

class VoiceCallModel;

class VoiceCallHandler : public QObject
Expand Down
2 changes: 1 addition & 1 deletion plugins/ngf/src/src.pro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include(../../plugin.pri)
TARGET = voicecall-ngf-plugin

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

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

Expand Down
6 changes: 1 addition & 5 deletions plugins/plugin.pri
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
TEMPLATE = lib
QT = core
CONFIG += plugin link_pkgconfig c++11

QMAKE_CXXFLAGS += -std=c++0x
CONFIG += plugin link_pkgconfig

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

LIBS += -L$$PWD/../lib/src -lvoicecall

target.path = $$[QT_INSTALL_LIBS]/voicecall/plugins
INSTALLS += target
2 changes: 1 addition & 1 deletion plugins/providers/ofono/src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include(../../../plugin.pri)
TARGET = voicecall-ofono-plugin
QT += dbus

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

HEADERS += \
ofonovoicecallhandler.h \
Expand Down
2 changes: 1 addition & 1 deletion src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ INCLUDEPATH += ../lib/src
DEFINES += VOICECALL_PLUGIN_DIRECTORY=\"\\\"$$[QT_INSTALL_LIBS]/voicecall/plugins\\\"\"

enable-nemo-devicelock {
PKGCONFIG += libresourceqt5 nemodevicelock
PKGCONFIG += libresourceqt$${QT_MAJOR_VERSION} nemodevicelock
DEFINES += WITH_NEMO_DEVICELOCK
}

Expand Down