mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 11:28:07 +00:00
to fix : text not translated if in combobox filled with QVariantMap list
This commit is contained in:
parent
62884832c4
commit
07439e0a98
12 changed files with 864 additions and 626 deletions
|
|
@ -496,6 +496,7 @@ void App::initCore() {
|
|||
else mCallList->lUpdate();
|
||||
if (!mSettings) {
|
||||
mSettings = settings;
|
||||
mSettings->setMediaEncryptions(new MediaEncryptionList());
|
||||
setLocale(settings->getConfigLocale());
|
||||
setAutoStart(settings->getAutoStart());
|
||||
setQuitOnLastWindowClosed(settings->getExitOnClose());
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
#include "SettingsCore.hpp"
|
||||
#include "core/App.hpp"
|
||||
#include "core/path/Paths.hpp"
|
||||
#include "model/tool/ToolModel.hpp"
|
||||
#include "tool/Utils.hpp"
|
||||
|
||||
#include <QUrl>
|
||||
|
|
@ -31,6 +30,40 @@ DEFINE_ABSTRACT_OBJECT(SettingsCore)
|
|||
|
||||
// =============================================================================
|
||||
|
||||
MediaEncryptionList::MediaEncryptionList(QObject *parent) {
|
||||
mList = {LinphoneEnums::MediaEncryption::None, LinphoneEnums::MediaEncryption::Srtp,
|
||||
LinphoneEnums::MediaEncryption::Zrtp, LinphoneEnums::MediaEncryption::Dtls};
|
||||
}
|
||||
MediaEncryptionList::~MediaEncryptionList(){}
|
||||
|
||||
LinphoneEnums::MediaEncryption MediaEncryptionList::getAt(const int& index) const {
|
||||
if (index < mList.size()) {
|
||||
return mList[index];
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> MediaEncryptionList::roleNames() const {
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[Qt::DisplayRole] = "display_name";
|
||||
roles[Qt::DisplayRole+1] = "id";
|
||||
return roles;
|
||||
}
|
||||
QVariant MediaEncryptionList::data(const QModelIndex &index, int role) const {
|
||||
if(!checkIndex(index)){
|
||||
return QVariant();
|
||||
}
|
||||
auto encryption = mList.at(index.row());
|
||||
if(role == Qt::DisplayRole){
|
||||
return LinphoneEnums::toString(encryption);
|
||||
} else if(role == Qt::DisplayRole+1) {
|
||||
return QVariant::fromValue(encryption);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
|
||||
QSharedPointer<SettingsCore> SettingsCore::create() {
|
||||
auto sharedPointer = QSharedPointer<SettingsCore>(new SettingsCore(), &QObject::deleteLater);
|
||||
sharedPointer->setSelf(sharedPointer);
|
||||
|
|
@ -63,7 +96,6 @@ SettingsCore::SettingsCore(QObject *parent) : QObject(parent) {
|
|||
mConferenceLayout =
|
||||
LinphoneEnums::toVariant(LinphoneEnums::fromLinphone(settingsModel->getDefaultConferenceLayout()));
|
||||
|
||||
mMediaEncryptions = LinphoneEnums::mediaEncryptionsToVariant();
|
||||
mMediaEncryption =
|
||||
LinphoneEnums::toVariant(LinphoneEnums::fromLinphone(settingsModel->getDefaultMediaEncryption()));
|
||||
|
||||
|
|
@ -444,7 +476,6 @@ void SettingsCore::reset(const SettingsCore &settingsCore) {
|
|||
setConferenceLayouts(settingsCore.mConferenceLayouts);
|
||||
setConferenceLayout(settingsCore.mConferenceLayout);
|
||||
|
||||
setMediaEncryptions(settingsCore.mMediaEncryptions);
|
||||
setMediaEncryption(settingsCore.mMediaEncryption);
|
||||
|
||||
setMediaEncryptionMandatory(settingsCore.mMediaEncryptionMandatory);
|
||||
|
|
@ -571,13 +602,12 @@ void SettingsCore::setConferenceLayouts(QVariantList layouts) {
|
|||
emit conferenceLayoutsChanged(layouts);
|
||||
}
|
||||
|
||||
QVariantList SettingsCore::getMediaEncryptions() const {
|
||||
return mMediaEncryptions;
|
||||
MediaEncryptionList *SettingsCore::getMediaEncryptions() const {
|
||||
return mMediaEncryptions.get();
|
||||
}
|
||||
|
||||
void SettingsCore::setMediaEncryptions(QVariantList encryptions) {
|
||||
mMediaEncryptions = encryptions;
|
||||
emit mediaEncryptionsChanged(encryptions);
|
||||
void SettingsCore::setMediaEncryptions(MediaEncryptionList* encryptions) {
|
||||
mMediaEncryptions = QSharedPointer<MediaEncryptionList>(encryptions);
|
||||
}
|
||||
|
||||
bool SettingsCore::isMediaEncryptionMandatory() const {
|
||||
|
|
|
|||
|
|
@ -18,9 +18,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SETTINGS_CORE_H_
|
||||
#define SETTINGS_CORE_H_
|
||||
|
||||
#include "core/proxy/AbstractListProxy.hpp"
|
||||
#include "model/setting/SettingsModel.hpp"
|
||||
#include "tool/thread/SafeConnection.hpp"
|
||||
|
||||
|
|
@ -29,6 +28,24 @@
|
|||
#include <QSettings>
|
||||
#include <QVariantMap>
|
||||
|
||||
#ifndef MEDIA_ENCRYPTION_LIST_H_
|
||||
#define MEDIA_ENCRYPTION_LIST_H_
|
||||
|
||||
class MediaEncryptionList : public AbstractListProxy<LinphoneEnums::MediaEncryption> {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MediaEncryptionList(QObject *parent = Q_NULLPTR);
|
||||
~MediaEncryptionList();
|
||||
|
||||
Q_INVOKABLE LinphoneEnums::MediaEncryption getAt(const int& index) const;
|
||||
virtual QHash<int, QByteArray> roleNames() const override;
|
||||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef SETTINGS_CORE_H_
|
||||
#define SETTINGS_CORE_H_
|
||||
|
||||
class SettingsCore : public QObject, public AbstractObject {
|
||||
Q_OBJECT
|
||||
|
||||
|
|
@ -51,7 +68,7 @@ public:
|
|||
Q_PROPERTY(QVariantList playbackDevices READ getPlaybackDevices NOTIFY playbackDevicesChanged)
|
||||
Q_PROPERTY(QVariantList ringerDevices READ getRingerDevices NOTIFY ringerDevicesChanged)
|
||||
Q_PROPERTY(QVariantList conferenceLayouts READ getConferenceLayouts NOTIFY conferenceLayoutsChanged)
|
||||
Q_PROPERTY(QVariantList mediaEncryptions READ getMediaEncryptions NOTIFY mediaEncryptionsChanged)
|
||||
Q_PROPERTY(MediaEncryptionList* mediaEncryptions READ getMediaEncryptions NOTIFY mediaEncryptionsChanged)
|
||||
|
||||
Q_PROPERTY(float playbackGain READ getPlaybackGain WRITE setPlaybackGain NOTIFY playbackGainChanged)
|
||||
Q_PROPERTY(float captureGain READ getCaptureGain WRITE setCaptureGain NOTIFY captureGainChanged)
|
||||
|
|
@ -139,8 +156,8 @@ public:
|
|||
void setRingerDevices(QVariantList devices);
|
||||
QVariantList getConferenceLayouts() const;
|
||||
void setConferenceLayouts(QVariantList layouts);
|
||||
QVariantList getMediaEncryptions() const;
|
||||
void setMediaEncryptions(QVariantList encryptions);
|
||||
MediaEncryptionList* getMediaEncryptions() const;
|
||||
void setMediaEncryptions(MediaEncryptionList* encryptions);
|
||||
|
||||
QVariantMap getCaptureDevice() const;
|
||||
void setCaptureDevice(QVariantMap device);
|
||||
|
|
@ -302,7 +319,7 @@ private:
|
|||
|
||||
// Security
|
||||
bool mVfsEnabled;
|
||||
QVariantList mMediaEncryptions;
|
||||
QSharedPointer<MediaEncryptionList> mMediaEncryptions;
|
||||
QVariantMap mMediaEncryption;
|
||||
bool mMediaEncryptionMandatory;
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -57,11 +57,14 @@ LinphoneEnums::MediaEncryption LinphoneEnums::fromLinphone(const linphone::Media
|
|||
QString LinphoneEnums::toString(LinphoneEnums::MediaEncryption encryption) {
|
||||
switch (encryption) {
|
||||
case LinphoneEnums::MediaEncryption::Dtls:
|
||||
return QObject::tr("DTLS");
|
||||
//: DTLS
|
||||
return QObject::tr("media_encryption_dtls");
|
||||
case LinphoneEnums::MediaEncryption::None:
|
||||
return QObject::tr("None");
|
||||
//: None
|
||||
return QObject::tr("media_encryption_none");
|
||||
case LinphoneEnums::MediaEncryption::Srtp:
|
||||
return QObject::tr("SRTP");
|
||||
//: SRTP
|
||||
return QObject::tr("media_encryption_srtp");
|
||||
case LinphoneEnums::MediaEncryption::Zrtp:
|
||||
//: "ZRTP - Post quantique"
|
||||
return QObject::tr("media_encryption_post_quantum");
|
||||
|
|
@ -224,11 +227,11 @@ QVariantList LinphoneEnums::conferenceLayoutsToVariant(QList<LinphoneEnums::Conf
|
|||
QVariantMap LinphoneEnums::toVariant(LinphoneEnums::ConferenceLayout layout) {
|
||||
QVariantMap map;
|
||||
if (layout == LinphoneEnums::ConferenceLayout::ActiveSpeaker) {
|
||||
map.insert("id", QVariant::fromValue(layout));
|
||||
map.insert("display_name", toString(layout));
|
||||
map.insert("valueRole", QVariant::fromValue(layout));
|
||||
map.insert("textRole", toString(layout));
|
||||
} else {
|
||||
map.insert("id", QVariant::fromValue(layout));
|
||||
map.insert("display_name", toString(layout));
|
||||
map.insert("valueRole", QVariant::fromValue(layout));
|
||||
map.insert("textRole", toString(layout));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ Control.ComboBox {
|
|||
id: mainItem
|
||||
// Usage : each item of the model list must be {text: …, img: …}
|
||||
// If string list, only text part of the delegate will be filled
|
||||
// readonly property string currentText: selectedItemText.text
|
||||
property alias listView: listView
|
||||
property string constantImageSource
|
||||
property real pixelSize: Typography.p1.pixelSize
|
||||
|
|
@ -19,24 +18,25 @@ Control.ComboBox {
|
|||
property string flagRole// Specific case if flag is shown (special font)
|
||||
|
||||
onConstantImageSourceChanged: if (constantImageSource) selectedItemImg.imageSource = constantImageSource
|
||||
onCurrentIndexChanged: {
|
||||
var item = model[currentIndex]
|
||||
if (!item) item = model.getAt(currentIndex)
|
||||
if (!item) return
|
||||
selectedItemText.text = mainItem.textRole
|
||||
? item[mainItem.textRole]
|
||||
: item.text
|
||||
? item.text
|
||||
: item
|
||||
? item
|
||||
: ""
|
||||
if(mainItem.flagRole) selectedItemFlag.text = item[mainItem.flagRole]
|
||||
selectedItemImg.imageSource = constantImageSource
|
||||
? constantImageSource
|
||||
: item.img
|
||||
? item.img
|
||||
: ""
|
||||
}
|
||||
onCurrentIndexChanged: {
|
||||
var item = model[currentIndex]
|
||||
if (!item) item = model.getAt(currentIndex)
|
||||
if (!item) return
|
||||
console.log("select item", item)
|
||||
selectedItemText.text = mainItem.textRole
|
||||
? item[mainItem.textRole]
|
||||
: item.text
|
||||
? item.text
|
||||
: item
|
||||
? item
|
||||
: ""
|
||||
if(mainItem.flagRole) selectedItemFlag.text = item[mainItem.flagRole]
|
||||
selectedItemImg.imageSource = constantImageSource
|
||||
? constantImageSource
|
||||
: item.img
|
||||
? item.img
|
||||
: ""
|
||||
}
|
||||
|
||||
Keys.onPressed: (event)=>{
|
||||
if(!mainItem.contentItem.activeFocus && (event.key == Qt.Key_Space || event.key == Qt.Key_Enter || event.key == Qt.Key_Return)){
|
||||
|
|
@ -168,7 +168,10 @@ Control.ComboBox {
|
|||
height: mainItem.height
|
||||
// anchors.left: listView.left
|
||||
// anchors.right: listView.right
|
||||
RowLayout{
|
||||
property string img: delegateImg.imageSource
|
||||
property string flag: delegateFlag.text
|
||||
property string text: delegateText.text
|
||||
RowLayout{
|
||||
anchors.fill: parent
|
||||
EffectImage {
|
||||
id: delegateImg
|
||||
|
|
@ -181,6 +184,7 @@ Control.ComboBox {
|
|||
}
|
||||
|
||||
Text {
|
||||
id: delegateFlag
|
||||
Layout.preferredWidth: implicitWidth
|
||||
Layout.leftMargin: delegateImg.visible ? 0 : Math.round(5 * DefaultStyle.dp)
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
|
|
@ -197,21 +201,24 @@ Control.ComboBox {
|
|||
: ""
|
||||
}
|
||||
Text {
|
||||
id: delegateText
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: delegateImg.visible ? 0 : Math.round(5 * DefaultStyle.dp)
|
||||
Layout.rightMargin: Math.round(20 * DefaultStyle.dp)
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
text: typeof(modelData) != "undefined"
|
||||
? mainItem.textRole
|
||||
? modelData[mainItem.textRole]
|
||||
: modelData.text
|
||||
? modelData.text
|
||||
: modelData
|
||||
: $modelData
|
||||
? mainItem.textRole
|
||||
? $modelData[mainItem.textRole]
|
||||
: $modelData
|
||||
: ""
|
||||
text: typeof(modelData) != "undefined"
|
||||
? mainItem.textRole
|
||||
? modelData[mainItem.textRole]
|
||||
: modelData.text
|
||||
? modelData.text
|
||||
: modelData
|
||||
: typeof($modelData) != "undefined"
|
||||
? mainItem.textRole
|
||||
? $modelData[mainItem.textRole]
|
||||
: $modelData
|
||||
: mainItem.texRole
|
||||
? mainItem.texRole
|
||||
: ""
|
||||
elide: Text.ElideRight
|
||||
maximumLineCount: 1
|
||||
wrapMode: Text.WrapAnywhere
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ ComboBox {
|
|||
else
|
||||
return Utils.equalObject(entry,propertyOwner[propertyName])
|
||||
})
|
||||
onCurrentIndexChanged: console.log("current index changed =======================", currentIndex)
|
||||
onCurrentValueChanged: {
|
||||
if(propertyOwnerGui) {
|
||||
binding.when = !Utils.equalObject(currentValue,propertyOwnerGui.core[propertyName])
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ ColumnLayout {
|
|||
RowLayout {
|
||||
anchors.fill: parent
|
||||
CountryIndicatorCombobox {
|
||||
RectangleTest{anchors.fill: parent}
|
||||
id: combobox
|
||||
implicitWidth: Math.round(110 * DefaultStyle.dp)
|
||||
defaultCallingCode: mainItem.defaultCallingCode
|
||||
|
|
|
|||
|
|
@ -120,10 +120,18 @@ AbstractSettingsLayout {
|
|||
ComboSetting {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredWidth: parent.width
|
||||
entries: SettingsCpp.mediaEncryptions
|
||||
// model: SettingsCpp.mediaEncryptions
|
||||
// Somehow translations do not work when coming from a QVariantList
|
||||
model: [
|
||||
{id: LinphoneEnums.MediaEncryption.None, display_name: qsTr("media_encryption_none")},
|
||||
{id: LinphoneEnums.MediaEncryption.Srtp, display_name: qsTr("media_encryption_srtp")},
|
||||
{id: LinphoneEnums.MediaEncryption.Zrtp, display_name: qsTr("media_encryption_zrtp")},
|
||||
{id: LinphoneEnums.MediaEncryption.Dtls, display_name: qsTr("media_encryption_dtls")}
|
||||
]
|
||||
propertyName: "mediaEncryption"
|
||||
textRole: 'display_name'
|
||||
propertyOwner: SettingsCpp
|
||||
textRole: "display_name"
|
||||
valueRole: "id"
|
||||
propertyOwner: SettingsCpp
|
||||
}
|
||||
}
|
||||
SwitchSetting {
|
||||
|
|
|
|||
|
|
@ -48,10 +48,15 @@ AbstractSettingsLayout {
|
|||
Layout.fillWidth: true
|
||||
Layout.topMargin: Math.round(12 * DefaultStyle.dp)
|
||||
Layout.preferredWidth: parent.width
|
||||
entries: SettingsCpp.conferenceLayouts
|
||||
model: [
|
||||
{id: LinphoneEnums.ConferenceLayout.ActiveSpeaker, display_name: qsTr("conference_layout_active_speaker")},
|
||||
{id: LinphoneEnums.ConferenceLayout.Grid, display_name: qsTr("conference_layout_grid")}
|
||||
]
|
||||
// entries: SettingsCpp.conferenceLayouts
|
||||
propertyName: "conferenceLayout"
|
||||
propertyOwner: SettingsCpp
|
||||
textRole: 'display_name'
|
||||
textRole: 'display_name'
|
||||
valueRole: "id"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue