fix #LINQT-1565 button icon color

fix #LINQT-1582 auto save audio/video settings when changed in call
This commit is contained in:
Gaelle Braud 2025-01-22 09:48:55 +01:00
parent 860fc22aa5
commit 45b2a4f484
10 changed files with 114 additions and 129 deletions

View file

@ -169,14 +169,6 @@ CallCore::CallCore(const std::shared_ptr<linphone::Call> &call) : QObject(nullpt
mRecording = call->getParams() && call->getParams()->isRecording();
mRemoteRecording = call->getRemoteParams() && call->getRemoteParams()->isRecording();
auto settingsModel = SettingsModel::getInstance();
mSpeakerVolumeGain = mCallModel->getSpeakerVolumeGain();
if (mSpeakerVolumeGain < 0) {
mSpeakerVolumeGain = settingsModel->getPlaybackGain();
}
mMicrophoneVolumeGain = call->getMicrophoneVolumeGain();
if (mMicrophoneVolumeGain < 0) {
mMicrophoneVolumeGain = settingsModel->getCaptureGain();
}
mMicrophoneVolume = call->getRecordVolume();
mRecordable = mState == LinphoneEnums::CallState::StreamsRunning;
mConferenceVideoLayout = LinphoneEnums::fromLinphone(SettingsModel::getInstance()->getDefaultConferenceLayout());
@ -263,12 +255,6 @@ void CallCore::setSelf(QSharedPointer<CallCore> me) {
mCallModelConnection->makeConnectToModel(&CallModel::qualityUpdated, [this](float quality) {
mCallModelConnection->invokeToCore([this, quality]() { setCurrentQuality(quality); });
});
mCallModelConnection->makeConnectToModel(&CallModel::speakerVolumeGainChanged, [this](float volume) {
mCallModelConnection->invokeToCore([this, volume]() { setSpeakerVolumeGain(volume); });
});
mCallModelConnection->makeConnectToModel(&CallModel::microphoneVolumeGainChanged, [this](float volume) {
mCallModelConnection->invokeToCore([this, volume]() { setMicrophoneVolumeGain(volume); });
});
mCallModelConnection->makeConnectToModel(&CallModel::microphoneVolumeChanged, [this](float volume) {
mCallModelConnection->invokeToCore([this, volume]() { setMicrophoneVolume(volume); });
});
@ -277,23 +263,9 @@ void CallCore::setSelf(QSharedPointer<CallCore> me) {
mCallModelConnection->makeConnectToModel(&CallModel::stateChanged, [this](std::shared_ptr<linphone::Call> call,
linphone::Call::State state,
const std::string &message) {
double speakerVolume = mSpeakerVolumeGain;
double micVolumeGain = mMicrophoneVolumeGain;
bool isConf = call && call->getConference() != nullptr;
if (state == linphone::Call::State::StreamsRunning) {
speakerVolume = mCallModel->getSpeakerVolumeGain();
if (speakerVolume < 0) {
speakerVolume = CoreModel::getInstance()->getCore()->getPlaybackGainDb();
}
micVolumeGain = mCallModel->getMicrophoneVolumeGain();
if (micVolumeGain < 0) {
micVolumeGain = CoreModel::getInstance()->getCore()->getMicGainDb();
}
}
auto subject = call->getConference() ? Utils::coreStringToAppString(call->getConference()->getSubject()) : "";
mCallModelConnection->invokeToCore([this, state, speakerVolume, micVolumeGain, subject, isConf]() {
setSpeakerVolumeGain(speakerVolume);
setMicrophoneVolumeGain(micVolumeGain);
mCallModelConnection->invokeToCore([this, state, subject, isConf]() {
setRecordable(state == linphone::Call::State::StreamsRunning);
setPaused(state == linphone::Call::State::Paused || state == linphone::Call::State::PausedByRemote);
if (mConference) mConference->setSubject(subject);
@ -357,18 +329,7 @@ void CallCore::setSelf(QSharedPointer<CallCore> me) {
mCallModelConnection->invokeToCore([this, zrtpStats]() { setZrtpStats(zrtpStats); });
}
});
mCallModelConnection->makeConnectToCore(&CallCore::lSetSpeakerVolumeGain, [this](float gain) {
mCallModelConnection->invokeToModel([this, gain]() { mCallModel->setSpeakerVolumeGain(gain); });
});
mCallModelConnection->makeConnectToModel(&CallModel::speakerVolumeGainChanged, [this](float gain) {
mCallModelConnection->invokeToCore([this, gain]() { setSpeakerVolumeGain(gain); });
});
mCallModelConnection->makeConnectToCore(&CallCore::lSetMicrophoneVolumeGain, [this](float gain) {
mCallModelConnection->invokeToModel([this, gain]() { mCallModel->setMicrophoneVolumeGain(gain); });
});
mCallModelConnection->makeConnectToModel(&CallModel::microphoneVolumeGainChanged, [this](float gain) {
mCallModelConnection->invokeToCore([this, gain]() { setMicrophoneVolumeGain(gain); });
});
mCallModelConnection->makeConnectToCore(&CallCore::lSetInputAudioDevice, [this](QString id) {
mCallModelConnection->invokeToModel([this, id]() {
auto device = ToolModel::findAudioDevice(id, linphone::AudioDevice::Capabilities::CapabilityRecord);
@ -735,16 +696,6 @@ void CallCore::setRecordable(bool recordable) {
}
}
float CallCore::getSpeakerVolumeGain() const {
return mSpeakerVolumeGain;
}
void CallCore::setSpeakerVolumeGain(float gain) {
if (mSpeakerVolumeGain != gain) {
mSpeakerVolumeGain = gain;
emit speakerVolumeGainChanged();
}
}
float CallCore::getMicrophoneVolume() const {
return mMicrophoneVolume;
}
@ -755,16 +706,6 @@ void CallCore::setMicrophoneVolume(float vol) {
}
}
float CallCore::getMicrophoneVolumeGain() const {
return mMicrophoneVolumeGain;
}
void CallCore::setMicrophoneVolumeGain(float gain) {
if (mMicrophoneVolumeGain != gain) {
mMicrophoneVolumeGain = gain;
emit microphoneVolumeGainChanged();
}
}
LinphoneEnums::CallState CallCore::getTransferState() const {
return mTransferState;
}

View file

@ -122,10 +122,6 @@ public:
Q_PROPERTY(bool recording READ getRecording WRITE setRecording NOTIFY recordingChanged)
Q_PROPERTY(bool remoteRecording READ getRemoteRecording WRITE setRemoteRecording NOTIFY remoteRecordingChanged)
Q_PROPERTY(bool recordable READ getRecordable WRITE setRecordable NOTIFY recordableChanged)
Q_PROPERTY(
float speakerVolumeGain READ getSpeakerVolumeGain WRITE setSpeakerVolumeGain NOTIFY speakerVolumeGainChanged)
Q_PROPERTY(float microphoneVolumeGain READ getMicrophoneVolumeGain WRITE setMicrophoneVolumeGain NOTIFY
microphoneVolumeGainChanged)
Q_PROPERTY(float microVolume READ getMicrophoneVolume WRITE setMicrophoneVolume NOTIFY microphoneVolumeChanged)
Q_PROPERTY(LinphoneEnums::CallState transferState READ getTransferState NOTIFY transferStateChanged)
Q_PROPERTY(ConferenceGui *conference READ getConferenceGui NOTIFY conferenceChanged)
@ -214,12 +210,6 @@ public:
bool getRecordable() const;
void setRecordable(bool recordable);
float getSpeakerVolumeGain() const;
void setSpeakerVolumeGain(float gain);
float getMicrophoneVolumeGain() const;
void setMicrophoneVolumeGain(float gain);
float getMicrophoneVolume() const;
void setMicrophoneVolume(float vol);
@ -268,9 +258,7 @@ signals:
void recordingChanged();
void remoteRecordingChanged();
void recordableChanged();
void speakerVolumeGainChanged();
void microphoneVolumeChanged();
void microphoneVolumeGainChanged();
void conferenceChanged();
void isConferenceChanged();
void conferenceVideoLayoutChanged();
@ -296,8 +284,6 @@ signals:
void lStopRecording();
void lCheckAuthenticationTokenSelected(const QString &token);
void lSkipZrtpAuthentication();
void lSetSpeakerVolumeGain(float gain);
void lSetMicrophoneVolumeGain(float gain);
void lSetInputAudioDevice(QString id);
void lSetOutputAudioDevice(QString id);
void lSetConferenceVideoLayout(LinphoneEnums::ConferenceLayout layout);
@ -354,9 +340,7 @@ private:
bool mIsConference = false;
QString mLocalToken;
QStringList mRemoteTokens;
float mSpeakerVolumeGain;
float mMicrophoneVolume;
float mMicrophoneVolumeGain;
QSharedPointer<SafeConnection<CallCore, CallModel>> mCallModelConnection;
ZrtpStats mZrtpStats;
AudioStats mAudioStats;

View file

@ -216,10 +216,22 @@ void SettingsCore::setSelf(QSharedPointer<SettingsCore> me) {
});
// Audio device(s)
mSettingsModelConnection->makeConnectToCore(&SettingsCore::lSetCaptureDevice, [this](QVariantMap device) {
mSettingsModelConnection->invokeToModel([this, device]() {
mAutoSaved = true;
SettingsModel::getInstance()->setCaptureDevice(device);
});
});
mSettingsModelConnection->makeConnectToModel(&SettingsModel::captureDeviceChanged, [this](QVariantMap device) {
mSettingsModelConnection->invokeToCore([this, device]() { setCaptureDevice(device); });
});
mSettingsModelConnection->makeConnectToCore(&SettingsCore::lSetPlaybackDevice, [this](QVariantMap device) {
mSettingsModelConnection->invokeToModel([this, device]() {
mAutoSaved = true;
SettingsModel::getInstance()->setPlaybackDevice(device);
});
});
mSettingsModelConnection->makeConnectToModel(&SettingsModel::playbackDeviceChanged, [this](QVariantMap device) {
mSettingsModelConnection->invokeToCore([this, device]() { setPlaybackDevice(device); });
});
@ -228,10 +240,22 @@ void SettingsCore::setSelf(QSharedPointer<SettingsCore> me) {
mSettingsModelConnection->invokeToCore([this, device]() { setRingerDevice(device); });
});
mSettingsModelConnection->makeConnectToCore(&SettingsCore::lSetPlaybackGain, [this](const float value) {
mSettingsModelConnection->invokeToModel([this, value]() {
mAutoSaved = true;
SettingsModel::getInstance()->setPlaybackGain(value);
});
});
mSettingsModelConnection->makeConnectToModel(&SettingsModel::playbackGainChanged, [this](const float value) {
mSettingsModelConnection->invokeToCore([this, value]() { setPlaybackGain(value); });
});
mSettingsModelConnection->makeConnectToCore(&SettingsCore::lSetCaptureGain, [this](const float value) {
mSettingsModelConnection->invokeToModel([this, value]() {
mAutoSaved = true;
SettingsModel::getInstance()->setCaptureGain(value);
});
});
mSettingsModelConnection->makeConnectToModel(&SettingsModel::captureGainChanged, [this](const float value) {
mSettingsModelConnection->invokeToCore([this, value]() { setCaptureGain(value); });
});
@ -252,10 +276,25 @@ void SettingsCore::setSelf(QSharedPointer<SettingsCore> me) {
});
// Video device(s)
mSettingsModelConnection->makeConnectToCore(&SettingsCore::lSetVideoDevice, [this](QString id) {
mSettingsModelConnection->invokeToModel([this, id]() {
mAutoSaved = true;
SettingsModel::getInstance()->setVideoDevice(id);
});
});
mSettingsModelConnection->makeConnectToModel(&SettingsModel::videoDeviceChanged, [this](const QString device) {
mSettingsModelConnection->invokeToCore([this, device]() { setVideoDevice(device); });
});
mSettingsModelConnection->makeConnectToCore(&SettingsCore::lSetConferenceLayout, [this](QVariantMap layout) {
auto linLayout = LinphoneEnums::toLinphone(LinphoneEnums::ConferenceLayout(layout["id"].toInt()));
mSettingsModelConnection->invokeToModel([this, linLayout]() {
mAutoSaved = true;
SettingsModel::getInstance()->setDefaultConferenceLayout(linLayout);
});
});
mSettingsModelConnection->makeConnectToModel(&SettingsModel::conferenceLayoutChanged, [this]() {
auto layout = LinphoneEnums::fromLinphone(SettingsModel::getInstance()->getDefaultConferenceLayout());
mSettingsModelConnection->invokeToCore(
@ -546,7 +585,11 @@ void SettingsCore::setVideoDevice(QString device) {
if (mVideoDevice != device) {
mVideoDevice = device;
emit videoDeviceChanged();
setIsSaved(false);
if (mAutoSaved) {
mAutoSaved = false;
} else {
setIsSaved(false);
}
}
}
@ -554,7 +597,6 @@ void SettingsCore::setVideoDevices(QStringList devices) {
if (mVideoDevices != devices) {
mVideoDevices = devices;
emit videoDevicesChanged();
setIsSaved(false);
}
}
@ -578,7 +620,11 @@ void SettingsCore::setCaptureGain(float gain) {
if (mCaptureGain != gain) {
mCaptureGain = gain;
emit captureGainChanged(gain);
setIsSaved(false);
if (mAutoSaved) {
mAutoSaved = false;
} else {
setIsSaved(false);
}
}
}
@ -590,7 +636,11 @@ void SettingsCore::setConferenceLayout(QVariantMap layout) {
if (mConferenceLayout["id"] != layout["id"]) {
mConferenceLayout = layout;
emit conferenceLayoutChanged();
setIsSaved(false);
if (mAutoSaved) {
mAutoSaved = false;
} else {
setIsSaved(false);
}
}
}
@ -614,7 +664,11 @@ void SettingsCore::setPlaybackGain(float gain) {
if (mPlaybackGain != gain) {
mPlaybackGain = gain;
emit playbackGainChanged(gain);
setIsSaved(false);
if (mAutoSaved) {
mAutoSaved = false;
} else {
setIsSaved(false);
}
}
}
@ -626,7 +680,11 @@ void SettingsCore::setCaptureDevice(QVariantMap device) {
if (mCaptureDevice["id"] != device["id"]) {
mCaptureDevice = device;
emit captureDeviceChanged(device);
setIsSaved(false);
if (mAutoSaved) {
mAutoSaved = false;
} else {
setIsSaved(false);
}
}
}
@ -638,7 +696,11 @@ void SettingsCore::setPlaybackDevice(QVariantMap device) {
if (mPlaybackDevice["id"] != device["id"]) {
mPlaybackDevice = device;
emit playbackDeviceChanged(device);
setIsSaved(false);
if (mAutoSaved) {
mAutoSaved = false;
} else {
setIsSaved(false);
}
}
}

View file

@ -232,7 +232,9 @@ signals:
void captureGraphRunningChanged(bool running);
void lSetPlaybackGain(float gain);
void playbackGainChanged(float gain);
void lSetCaptureGain(float gain);
void captureGainChanged(float gain);
void captureDevicesChanged(const QVariantList &devices);
@ -241,8 +243,10 @@ signals:
void conferenceLayoutsChanged(const QVariantList &layouts);
void mediaEncryptionsChanged(const QVariantList &encryptions);
void lSetCaptureDevice(QVariantMap device);
void captureDeviceChanged(const QVariantMap &device);
void lSetConferenceLayout(QVariantMap layout);
void conferenceLayoutChanged();
void mediaEncryptionChanged();
@ -251,10 +255,12 @@ signals:
void isSavedChanged();
void lSetPlaybackDevice(QVariantMap device);
void playbackDeviceChanged(const QVariantMap &device);
void ringerDeviceChanged(const QVariantMap &device);
void lSetVideoDevice(QString id);
void videoDeviceChanged();
void videoDevicesChanged();
@ -327,6 +333,7 @@ private:
bool mDndEnabled;
bool mIsSaved = true;
bool mAutoSaved = false;
QSettings mAppSettings;
QSharedPointer<SafeConnection<SettingsCore, SettingsModel>> mSettingsModelConnection;

View file

@ -42,11 +42,6 @@ CallModel::CallModel(const std::shared_ptr<linphone::Call> &call, QObject *paren
connect(&mMicroVolumeTimer, &QTimer::timeout, this,
[this]() { this->microphoneVolumeChanged(Utils::computeVu(mMonitor->getRecordVolume())); });
mMicroVolumeTimer.start();
// connect(this, &CallModel::stateChanged, this, [this] {
// auto state = mMonitor->getState();
// if (state == linphone::Call::State::Paused) setPaused(true);
// });
}
CallModel::~CallModel() {
@ -166,30 +161,6 @@ void CallModel::setRecordFile(const std::string &path) {
mMonitor->update(params);
}
void CallModel::setSpeakerVolumeGain(float gain) {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
mMonitor->setSpeakerVolumeGain(gain);
emit speakerVolumeGainChanged(gain);
}
float CallModel::getSpeakerVolumeGain() const {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
auto gain = mMonitor->getSpeakerVolumeGain();
return gain;
}
void CallModel::setMicrophoneVolumeGain(float gain) {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
mMonitor->setMicrophoneVolumeGain(gain);
emit microphoneVolumeGainChanged(gain);
}
float CallModel::getMicrophoneVolumeGain() const {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
auto gain = mMonitor->getMicrophoneVolumeGain();
return gain;
}
float CallModel::getMicrophoneVolume() const {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
auto volume = mMonitor->getRecordVolume();

View file

@ -48,8 +48,6 @@ public:
void startRecording();
void stopRecording();
void setRecordFile(const std::string &path);
void setSpeakerVolumeGain(float gain);
void setMicrophoneVolumeGain(float gain);
void setInputAudioDevice(const std::shared_ptr<linphone::AudioDevice> &id);
std::shared_ptr<const linphone::AudioDevice> getInputAudioDevice() const;
void setOutputAudioDevice(const std::shared_ptr<linphone::AudioDevice> &id);
@ -64,9 +62,7 @@ public:
void transferToAnother(const std::shared_ptr<linphone::Call> &call);
void terminateAllCalls();
float getMicrophoneVolumeGain() const;
float getMicrophoneVolume() const;
float getSpeakerVolumeGain() const;
std::string getRecordFile() const;
std::shared_ptr<const linphone::Address> getRemoteAddress();
bool getAuthenticationTokenVerified() const;

View file

@ -360,7 +360,7 @@ QVariantMap SettingsModel::getRingerDevice() const {
return ToolModel::createVariant(audioDevice);
}
void SettingsModel::setRingerDevice(const QVariantMap &device) {
void SettingsModel::setRingerDevice(QVariantMap device) {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
CoreModel::getInstance()->getCore()->setRingerDevice(Utils::appStringToCoreString(device["id"].toString()));
emit ringerDeviceChanged(device);
@ -373,7 +373,7 @@ QString SettingsModel::getVideoDevice() const {
return Utils::coreStringToAppString(CoreModel::getInstance()->getCore()->getVideoDevice());
}
void SettingsModel::setVideoDevice(const QString &device) {
void SettingsModel::setVideoDevice(QString device) {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
CoreModel::getInstance()->getCore()->setVideoDevice(Utils::appStringToCoreString(device));
emit videoDeviceChanged(device);

View file

@ -103,10 +103,10 @@ public:
void setMediaEncryptionMandatory(bool mandatory);
QVariantMap getRingerDevice() const;
void setRingerDevice(const QVariantMap &device);
void setRingerDevice(QVariantMap device);
QString getVideoDevice() const;
void setVideoDevice(const QString &device);
void setVideoDevice(QString device);
void startEchoCancellerCalibration();
int getEchoCancellationCalibration() const;

View file

@ -86,16 +86,23 @@ ColumnLayout {
propertyName: "playbackDevice"
propertyOwner: SettingsCpp
textRole: 'display_name'
Connections {
enabled: mainItem.call
target: outputAudioDeviceCBox
function onCurrentValueChanged() {
SettingsCpp.lSetPlaybackDevice(outputAudioDeviceCBox.currentValue)
}
}
}
Slider {
id: speakerVolume
Layout.fillWidth: true
from: 0.0
to: 1.0
value: mainItem.call ? mainItem.call.core.speakerVolumeGain : SettingsCpp.playbackGain
value: SettingsCpp.playbackGain
onMoved: {
if (mainItem.call) mainItem.call.core.lSetSpeakerVolumeGain(value)
SettingsCpp.playbackGain = value
if (mainItem.call) SettingsCpp.lSetPlaybackGain(value)
else SettingsCpp.playbackGain = value
}
}
}
@ -126,16 +133,23 @@ ColumnLayout {
propertyName: "captureDevice"
propertyOwner: SettingsCpp
textRole: 'display_name'
Connections {
enabled: mainItem.call
target: inputAudioDeviceCBox
function onCurrentValueChanged() {
SettingsCpp.lSetCaptureDevice(inputAudioDeviceCBox.currentValue)
}
}
}
Slider {
id: microVolume
Layout.fillWidth: true
from: 0.0
to: 1.0
value: mainItem.call ? mainItem.call.core.microphoneVolumeGain : SettingsCpp.captureGain
value: SettingsCpp.captureGain
onMoved: {
if (mainItem.call) mainItem.call.core.lSetMicrophoneVolumeGain(value)
SettingsCpp.captureGain = value
if (mainItem.call) SettingsCpp.lSetCaptureGain(value)
else SettingsCpp.captureGain = value
}
}
Timer {
@ -144,8 +158,7 @@ ColumnLayout {
repeat: true
running: false
onTriggered: {
if (mainItem.call) audioTestSlider.value = mainItem.call.core.microVolume
else SettingsCpp.updateMicVolume()
SettingsCpp.updateMicVolume()
}
}
Slider {
@ -204,6 +217,13 @@ ColumnLayout {
entries: SettingsCpp.videoDevices
propertyName: "videoDevice"
propertyOwner: SettingsCpp
Connections {
enabled: mainItem.call
target: videoDevicesCbox
function onCurrentValueChanged() {
SettingsCpp.lSetVideoDevice(videoDevicesCbox.currentValue)
}
}
}
}
Connections {

View file

@ -13,6 +13,10 @@
text: {
normal: Linphone.DefaultStyle.grey_0,
pressed: Linphone.DefaultStyle.grey_0
},
image: {
normal: Linphone.DefaultStyle.grey_0,
pressed: Linphone.DefaultStyle.grey_0
}
}