Commit c00c0bcd authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/views/App/Settings/SettingsVideo): supports video size

parent a7534951
...@@ -177,6 +177,38 @@ void SettingsModel::setVideoFramerate (int framerate) { ...@@ -177,6 +177,38 @@ void SettingsModel::setVideoFramerate (int framerate) {
emit videoFramerateChanged(framerate); emit videoFramerateChanged(framerate);
} }
// -----------------------------------------------------------------------------
inline QVariantMap createMapFromVideoDefinition (const shared_ptr<const linphone::VideoDefinition> &definition) {
QVariantMap map;
map["name"] = ::Utils::linphoneStringToQString(definition->getName());
map["width"] = definition->getWidth();
map["height"] = definition->getHeight();
map["__definition"] = QVariant::fromValue(definition);
return map;
}
QVariantList SettingsModel::getSupportedVideoDefinitions () const {
QVariantList list;
for (const auto &definition : linphone::Factory::get()->getSupportedVideoDefinitions())
list << createMapFromVideoDefinition(definition);
return list;
}
QVariantMap SettingsModel::getVideoDefinition () const {
return createMapFromVideoDefinition(CoreManager::getInstance()->getCore()->getPreferredVideoDefinition());
}
void SettingsModel::setVideoDefinition (const QVariantMap &definition) {
CoreManager::getInstance()->getCore()->setPreferredVideoDefinition(
definition.value("__definition").value<shared_ptr<const linphone::VideoDefinition> >()->clone()
);
emit videoDefinitionChanged(definition);
}
// ============================================================================= // =============================================================================
// Chat & calls. // Chat & calls.
// ============================================================================= // =============================================================================
......
...@@ -56,6 +56,10 @@ class SettingsModel : public QObject { ...@@ -56,6 +56,10 @@ class SettingsModel : public QObject {
Q_PROPERTY(QString videoPreset READ getVideoPreset WRITE setVideoPreset NOTIFY videoPresetChanged); Q_PROPERTY(QString videoPreset READ getVideoPreset WRITE setVideoPreset NOTIFY videoPresetChanged);
Q_PROPERTY(int videoFramerate READ getVideoFramerate WRITE setVideoFramerate NOTIFY videoFramerateChanged); Q_PROPERTY(int videoFramerate READ getVideoFramerate WRITE setVideoFramerate NOTIFY videoFramerateChanged);
Q_PROPERTY(QVariantList supportedVideoDefinitions READ getSupportedVideoDefinitions CONSTANT);
Q_PROPERTY(QVariantMap videoDefinition READ getVideoDefinition WRITE setVideoDefinition NOTIFY videoDefinitionChanged);
// Chat & calls. ------------------------------------------------------------- // Chat & calls. -------------------------------------------------------------
Q_PROPERTY(bool autoAnswerStatus READ getAutoAnswerStatus WRITE setAutoAnswerStatus NOTIFY autoAnswerStatusChanged); Q_PROPERTY(bool autoAnswerStatus READ getAutoAnswerStatus WRITE setAutoAnswerStatus NOTIFY autoAnswerStatusChanged);
...@@ -164,6 +168,11 @@ public: ...@@ -164,6 +168,11 @@ public:
int getVideoFramerate () const; int getVideoFramerate () const;
void setVideoFramerate (int framerate); void setVideoFramerate (int framerate);
QVariantList getSupportedVideoDefinitions () const;
QVariantMap getVideoDefinition () const;
void setVideoDefinition (const QVariantMap &definition);
// Chat & calls. ------------------------------------------------------------- // Chat & calls. -------------------------------------------------------------
bool getAutoAnswerStatus () const; bool getAutoAnswerStatus () const;
...@@ -271,6 +280,8 @@ signals: ...@@ -271,6 +280,8 @@ signals:
void videoPresetChanged (const QString &preset); void videoPresetChanged (const QString &preset);
void videoFramerateChanged (int framerate); void videoFramerateChanged (int framerate);
void videoDefinitionChanged (const QVariantMap &definition);
// Chat & calls. ------------------------------------------------------------- // Chat & calls. -------------------------------------------------------------
void autoAnswerStatusChanged (bool status); void autoAnswerStatusChanged (bool status);
...@@ -318,4 +329,6 @@ private: ...@@ -318,4 +329,6 @@ private:
std::shared_ptr<linphone::Config> mConfig; std::shared_ptr<linphone::Config> mConfig;
}; };
Q_DECLARE_METATYPE(std::shared_ptr<const linphone::VideoDefinition> );
#endif // SETTINGS_MODEL_H_ #endif // SETTINGS_MODEL_H_
...@@ -44,33 +44,25 @@ TabContainer { ...@@ -44,33 +44,25 @@ TabContainer {
currentIndex: { currentIndex: {
var preset = SettingsModel.videoPreset var preset = SettingsModel.videoPreset
return Number(Utils.findIndex([ 'default', 'high-fps', 'custom' ], function (value) { return Number(Utils.findIndex(model, function (value) {
return preset === value return preset === value.value
})) }))
} }
model: ListModel { model: [{
id: presets key: qsTr('presetDefault'),
ListElement {
key: qsTr('presetDefault')
value: 'default' value: 'default'
} }, {
key: qsTr('presetHighFps'),
ListElement {
key: qsTr('presetHighFps')
value: 'high-fps' value: 'high-fps'
} }, {
key: qsTr('presetCustom'),
ListElement {
key: qsTr('presetCustom')
value: 'custom' value: 'custom'
} }]
}
textRole: 'key' textRole: 'key'
onActivated: SettingsModel.videoPreset = presets.get(index).value onActivated: SettingsModel.videoPreset = model[index].value
} }
} }
} }
...@@ -80,7 +72,19 @@ TabContainer { ...@@ -80,7 +72,19 @@ TabContainer {
label: qsTr('videoSizeLabel') label: qsTr('videoSizeLabel')
ComboBox { ComboBox {
// TODO currentIndex: Utils.findIndex(model, function (definition) {
return definition.value.name === SettingsModel.videoDefinition.name
})
model: SettingsModel.supportedVideoDefinitions.map(function (definition) {
return {
key: definition.name + ' (' + definition.width + 'x' + definition.height + ')',
value: definition
}
})
textRole: 'key'
onActivated: SettingsModel.videoDefinition = model[index].value
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment