diff --git a/Linphone/core/App.cpp b/Linphone/core/App.cpp index 8f281ac41..e88600bdc 100644 --- a/Linphone/core/App.cpp +++ b/Linphone/core/App.cpp @@ -64,6 +64,9 @@ #include "core/participant/ParticipantDeviceProxy.hpp" #include "core/participant/ParticipantGui.hpp" #include "core/participant/ParticipantProxy.hpp" +#include "core/payload-type/PayloadTypeCore.hpp" +#include "core/payload-type/PayloadTypeGui.hpp" +#include "core/payload-type/PayloadTypeProxy.hpp" #include "core/phone-number/PhoneNumber.hpp" #include "core/phone-number/PhoneNumberProxy.hpp" #include "core/register/RegisterPage.hpp" @@ -598,6 +601,9 @@ void App::initCppInterfaces() { qmlRegisterType(Constants::MainQmlUri, 1, 0, "LdapProxy"); qmlRegisterType(Constants::MainQmlUri, 1, 0, "CarddavGui"); qmlRegisterType(Constants::MainQmlUri, 1, 0, "CarddavProxy"); + qmlRegisterType(Constants::MainQmlUri, 1, 0, "PayloadTypeGui"); + qmlRegisterType(Constants::MainQmlUri, 1, 0, "PayloadTypeProxy"); + qmlRegisterType(Constants::MainQmlUri, 1, 0, "PayloadTypeCore"); LinphoneEnums::registerMetaTypes(); } diff --git a/Linphone/core/CMakeLists.txt b/Linphone/core/CMakeLists.txt index d9db6c8f6..05134bf97 100644 --- a/Linphone/core/CMakeLists.txt +++ b/Linphone/core/CMakeLists.txt @@ -78,6 +78,11 @@ list(APPEND _LINPHONEAPP_SOURCES core/address-books/carddav/CarddavProxy.cpp core/address-books/carddav/CarddavList.cpp + core/payload-type/PayloadTypeCore.cpp + core/payload-type/PayloadTypeGui.cpp + core/payload-type/PayloadTypeProxy.cpp + core/payload-type/PayloadTypeList.cpp + ) ## Single Application diff --git a/Linphone/core/payload-type/PayloadTypeCore.cpp b/Linphone/core/payload-type/PayloadTypeCore.cpp new file mode 100644 index 000000000..6d0040452 --- /dev/null +++ b/Linphone/core/payload-type/PayloadTypeCore.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2010-2024 Belledonne Communications SARL. + * + * This file is part of linphone-desktop + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "PayloadTypeCore.hpp" +#include "core/App.hpp" + +DEFINE_ABSTRACT_OBJECT(PayloadTypeCore) + +QSharedPointer PayloadTypeCore::create(const std::shared_ptr &payloadType, + Family family) { + auto sharedPointer = + QSharedPointer(new PayloadTypeCore(payloadType, family), &QObject::deleteLater); + sharedPointer->setSelf(sharedPointer); + sharedPointer->moveToThread(App::getInstance()->thread()); + return sharedPointer; +} + +PayloadTypeCore::PayloadTypeCore(const std::shared_ptr &payloadType, Family family) + : QObject(nullptr) { + App::getInstance()->mEngine->setObjectOwnership(this, QQmlEngine::CppOwnership); + mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); + mPayloadTypeModel = Utils::makeQObject_ptr(payloadType); + mFamily = family; + INIT_CORE_MEMBER(Enabled, mPayloadTypeModel) + INIT_CORE_MEMBER(ClockRate, mPayloadTypeModel) + INIT_CORE_MEMBER(MimeType, mPayloadTypeModel) + INIT_CORE_MEMBER(RecvFmtp, mPayloadTypeModel) +} + +PayloadTypeCore::~PayloadTypeCore() { + mustBeInMainThread(log().arg(Q_FUNC_INFO)); +} + +void PayloadTypeCore::setSelf(QSharedPointer me) { + mPayloadTypeModelConnection = QSharedPointer>( + new SafeConnection(me, mPayloadTypeModel), &QObject::deleteLater); + DEFINE_CORE_GETSET_CONNECT(mPayloadTypeModelConnection, PayloadTypeCore, PayloadTypeModel, mPayloadTypeModel, bool, + enabled, Enabled) +} + +PayloadTypeCore::Family PayloadTypeCore::getFamily() { + return mFamily; +} + +QString PayloadTypeCore::getMimeType() { + return mMimeType; +} diff --git a/Linphone/core/payload-type/PayloadTypeCore.hpp b/Linphone/core/payload-type/PayloadTypeCore.hpp new file mode 100644 index 000000000..91af030eb --- /dev/null +++ b/Linphone/core/payload-type/PayloadTypeCore.hpp @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2010-2024 Belledonne Communications SARL. + * + * This file is part of linphone-desktop + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef PAYLOAD_TYPE_CORE_H_ +#define PAYLOAD_TYPE_CORE_H_ + +#include "model/payload-type/PayloadTypeModel.hpp" +#include "tool/AbstractObject.hpp" +#include "tool/thread/SafeConnection.hpp" +#include +#include +#include + +class PayloadTypeCore : public QObject, public AbstractObject { + Q_OBJECT + + Q_ENUMS(Family) + Q_PROPERTY(Family family MEMBER mFamily CONSTANT) + DECLARE_CORE_GETSET_MEMBER(bool, enabled, Enabled) + DECLARE_CORE_MEMBER(int, clockRate, ClockRate) + DECLARE_CORE_MEMBER(QString, mimeType, MimeType) + DECLARE_CORE_MEMBER(QString, recvFmtp, RecvFmtp) + +public: + + enum Family { None, Audio, Video, Text }; + + static QSharedPointer create(const std::shared_ptr &payloadType, + Family family); + PayloadTypeCore(const std::shared_ptr &payloadType, Family family); + ~PayloadTypeCore(); + void setSelf(QSharedPointer me); + Family getFamily(); + QString getMimeType(); + +private: + Family mFamily; + std::shared_ptr mPayloadTypeModel; + QSharedPointer> mPayloadTypeModelConnection; + + DECLARE_ABSTRACT_OBJECT +}; +Q_DECLARE_METATYPE(PayloadTypeCore *) +#endif diff --git a/Linphone/core/payload-type/PayloadTypeGui.cpp b/Linphone/core/payload-type/PayloadTypeGui.cpp new file mode 100644 index 000000000..016ca50ab --- /dev/null +++ b/Linphone/core/payload-type/PayloadTypeGui.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2010-2024 Belledonne Communications SARL. + * + * This file is part of linphone-desktop + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "PayloadTypeGui.hpp" +#include "core/App.hpp" + +DEFINE_ABSTRACT_OBJECT(PayloadTypeGui) + +PayloadTypeGui::PayloadTypeGui(QSharedPointer core) { + App::getInstance()->mEngine->setObjectOwnership(this, QQmlEngine::JavaScriptOwnership); + mCore = core; + if (isInLinphoneThread()) moveToThread(App::getInstance()->thread()); +} + +PayloadTypeGui::~PayloadTypeGui() { + mustBeInMainThread("~" + getClassName()); +} + +PayloadTypeCore *PayloadTypeGui::getCore() const { + return mCore.get(); +} diff --git a/Linphone/core/payload-type/PayloadTypeGui.hpp b/Linphone/core/payload-type/PayloadTypeGui.hpp new file mode 100644 index 000000000..0d7523fab --- /dev/null +++ b/Linphone/core/payload-type/PayloadTypeGui.hpp @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2010-2024 Belledonne Communications SARL. + * + * This file is part of linphone-desktop + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef PAYLOAD_TYPE_GUI_H_ +#define PAYLOAD_TYPE_GUI_H_ + +#include "PayloadTypeCore.hpp" +#include +#include + +class PayloadTypeGui : public QObject, public AbstractObject { + Q_OBJECT + + Q_PROPERTY(PayloadTypeCore *core READ getCore CONSTANT) + +public: + PayloadTypeGui(QSharedPointer core); + ~PayloadTypeGui(); + PayloadTypeCore *getCore() const; + QSharedPointer mCore; + DECLARE_ABSTRACT_OBJECT +}; + +#endif diff --git a/Linphone/core/payload-type/PayloadTypeList.cpp b/Linphone/core/payload-type/PayloadTypeList.cpp new file mode 100644 index 000000000..60710f006 --- /dev/null +++ b/Linphone/core/payload-type/PayloadTypeList.cpp @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2010-2024 Belledonne Communications SARL. + * + * This file is part of linphone-desktop + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "PayloadTypeList.hpp" +#include "PayloadTypeGui.hpp" +#include "core/App.hpp" +#include "model/object/VariantObject.hpp" +#include +#include + +// ============================================================================= + +DEFINE_ABSTRACT_OBJECT(PayloadTypeList) + +QSharedPointer PayloadTypeList::create() { + auto model = QSharedPointer(new PayloadTypeList(), &QObject::deleteLater); + model->moveToThread(App::getInstance()->thread()); + model->setSelf(model); + return model; +} + +PayloadTypeList::PayloadTypeList(QObject *parent) : ListProxy(parent) { + mustBeInMainThread(getClassName()); + App::getInstance()->mEngine->setObjectOwnership(this, QQmlEngine::CppOwnership); +} + +PayloadTypeList::~PayloadTypeList() { + mustBeInMainThread("~" + getClassName()); + mModelConnection = nullptr; +} + +void PayloadTypeList::setSelf(QSharedPointer me) { + mModelConnection = QSharedPointer>( + new SafeConnection(me, CoreModel::getInstance()), &QObject::deleteLater); + mModelConnection->makeConnectToCore(&PayloadTypeList::lUpdate, [this]() { + mModelConnection->invokeToModel([this]() { + QList> *payloadTypes = new QList>(); + mustBeInLinphoneThread(getClassName()); + for (auto payloadType : CoreModel::getInstance()->getCore()->getAudioPayloadTypes()) { + auto model = PayloadTypeCore::create(payloadType, PayloadTypeCore::Family::Audio); + payloadTypes->push_back(model); + } + for (auto payloadType : CoreModel::getInstance()->getCore()->getVideoPayloadTypes()) { + auto model = PayloadTypeCore::create(payloadType, PayloadTypeCore::Family::Video); + payloadTypes->push_back(model); + } + for (auto payloadType : CoreModel::getInstance()->getCore()->getTextPayloadTypes()) { + auto model = PayloadTypeCore::create(payloadType, PayloadTypeCore::Family::Text); + payloadTypes->push_back(model); + } + mModelConnection->invokeToCore([this, payloadTypes]() { + mustBeInMainThread(getClassName()); + resetData(); + add(*payloadTypes); + delete payloadTypes; + }); + }); + }); + QObject::connect(CoreModel::getInstance().get(), &CoreModel::configuringStatus, this, + [this](const std::shared_ptr &core, linphone::ConfiguringState status, + const std::string &message) { + mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); + if (status == linphone::ConfiguringState::Successful) emit lUpdate(); + }); + emit lUpdate(); +} + +QVariant PayloadTypeList::data(const QModelIndex &index, int role) const { + int row = index.row(); + if (!index.isValid() || row < 0 || row >= mList.count()) return QVariant(); + if (role == Qt::DisplayRole) { + return QVariant::fromValue(new PayloadTypeGui(mList[row].objectCast())); + } + return QVariant(); +} diff --git a/Linphone/core/payload-type/PayloadTypeList.hpp b/Linphone/core/payload-type/PayloadTypeList.hpp new file mode 100644 index 000000000..e3e3876eb --- /dev/null +++ b/Linphone/core/payload-type/PayloadTypeList.hpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2010-2024 Belledonne Communications SARL. + * + * This file is part of linphone-desktop + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef PAYLOAD_TYPE_LIST_H_ +#define PAYLOAD_TYPE_LIST_H_ + +#include "../proxy/ListProxy.hpp" +#include "PayloadTypeCore.hpp" +#include "tool/AbstractObject.hpp" +#include "tool/thread/SafeConnection.hpp" +#include + +class CoreModel; + +// ============================================================================= + +class PayloadTypeList : public ListProxy, public AbstractObject { + Q_OBJECT + +public: + static QSharedPointer create(); + + PayloadTypeList(QObject *parent = Q_NULLPTR); + ~PayloadTypeList(); + + void setSelf(QSharedPointer me); + + virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + +signals: + void lUpdate(); + +private: + QSharedPointer> mModelConnection; + DECLARE_ABSTRACT_OBJECT +}; + +#endif diff --git a/Linphone/core/payload-type/PayloadTypeProxy.cpp b/Linphone/core/payload-type/PayloadTypeProxy.cpp new file mode 100644 index 000000000..9d14cb970 --- /dev/null +++ b/Linphone/core/payload-type/PayloadTypeProxy.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2010-2024 Belledonne Communications SARL. + * + * This file is part of linphone-desktop + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "PayloadTypeProxy.hpp" +#include "PayloadTypeGui.hpp" +#include "PayloadTypeList.hpp" + +DEFINE_ABSTRACT_OBJECT(PayloadTypeProxy) + +PayloadTypeProxy::PayloadTypeProxy(QObject *parent) : SortFilterProxy(parent) { + mPayloadTypeList = PayloadTypeList::create(); + setSourceModel(mPayloadTypeList.get()); +} + +PayloadTypeProxy::~PayloadTypeProxy() { + setSourceModel(nullptr); +} + +bool PayloadTypeProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { + auto data = sourceModel()->data(sourceModel()->index(sourceRow, 0, sourceParent)).value(); + return data->getCore()->getFamily() == mFamily; +} + +bool PayloadTypeProxy::lessThan(const QModelIndex &left, const QModelIndex &right) const { + auto l = getItemAt(left.row()); + auto r = getItemAt(right.row()); + + return l->getMimeType() < r->getMimeType(); +} diff --git a/Linphone/core/payload-type/PayloadTypeProxy.hpp b/Linphone/core/payload-type/PayloadTypeProxy.hpp new file mode 100644 index 000000000..c4ceeab8c --- /dev/null +++ b/Linphone/core/payload-type/PayloadTypeProxy.hpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2010-2024 Belledonne Communications SARL. + * + * This file is part of linphone-desktop + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef PAYLOAD_TYPE_PROXY_H_ +#define PAYLOAD_TYPE_PROXY_H_ + +#include "../proxy/SortFilterProxy.hpp" +#include "PayloadTypeGui.hpp" +#include "PayloadTypeList.hpp" +#include "tool/AbstractObject.hpp" + +// ============================================================================= + +class PayloadTypeProxy : public SortFilterProxy, public AbstractObject { + Q_OBJECT + + Q_PROPERTY(PayloadTypeCore::Family family MEMBER mFamily) + +public: + PayloadTypeProxy(QObject *parent = Q_NULLPTR); + ~PayloadTypeProxy(); + +protected: + virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; + virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; + + PayloadTypeCore::Family mFamily; + QSharedPointer mPayloadTypeList; + + DECLARE_ABSTRACT_OBJECT +}; + +#endif diff --git a/Linphone/core/setting/SettingsCore.hpp b/Linphone/core/setting/SettingsCore.hpp index 909c29b95..53b7c1e80 100644 --- a/Linphone/core/setting/SettingsCore.hpp +++ b/Linphone/core/setting/SettingsCore.hpp @@ -164,6 +164,8 @@ public: DECLARE_CORE_GETSET(bool, exitOnClose, ExitOnClose) DECLARE_CORE_GETSET(bool, syncLdapContacts, SyncLdapContacts) DECLARE_CORE_GETSET_MEMBER(bool, ipv6Enabled, Ipv6Enabled) + DECLARE_CORE_GETSET_MEMBER(QVariantList, audioCodecs, AudioCodecs) + DECLARE_CORE_GETSET_MEMBER(QVariantList, videoCodecs, VideoCodecs) signals: diff --git a/Linphone/model/CMakeLists.txt b/Linphone/model/CMakeLists.txt index 256c9c444..e6bb79d24 100644 --- a/Linphone/model/CMakeLists.txt +++ b/Linphone/model/CMakeLists.txt @@ -43,6 +43,7 @@ list(APPEND _LINPHONEAPP_SOURCES model/address-books/ldap/LdapModel.cpp model/address-books/carddav/CarddavModel.cpp + model/payload-type/PayloadTypeModel.cpp ) diff --git a/Linphone/model/payload-type/PayloadTypeModel.cpp b/Linphone/model/payload-type/PayloadTypeModel.cpp new file mode 100644 index 000000000..1bee2d9b1 --- /dev/null +++ b/Linphone/model/payload-type/PayloadTypeModel.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2010-2024 Belledonne Communications SARL. + * + * This file is part of linphone-desktop + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "PayloadTypeModel.hpp" +#include "tool/Utils.hpp" + +DEFINE_ABSTRACT_OBJECT(PayloadTypeModel) + +PayloadTypeModel::PayloadTypeModel(const std::shared_ptr &payloadType, QObject *parent) { + mustBeInLinphoneThread(getClassName()); + mPayloadType = payloadType; +} + +PayloadTypeModel::~PayloadTypeModel() { + mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); +} + +DEFINE_GETSET_ENABLE(PayloadTypeModel, enabled, Enabled, mPayloadType) +DEFINE_GET(PayloadTypeModel, int, ClockRate, mPayloadType) +DEFINE_GET_STRING(PayloadTypeModel, MimeType, mPayloadType) +DEFINE_GET_STRING(PayloadTypeModel, RecvFmtp, mPayloadType) diff --git a/Linphone/model/payload-type/PayloadTypeModel.hpp b/Linphone/model/payload-type/PayloadTypeModel.hpp new file mode 100644 index 000000000..5e4affdb0 --- /dev/null +++ b/Linphone/model/payload-type/PayloadTypeModel.hpp @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2010-2024 Belledonne Communications SARL. + * + * This file is part of linphone-desktop + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef PAYLOAD_TYPE_MODEL_H_ +#define PAYLOAD_TYPE_MODEL_H_ + +#include "tool/AbstractObject.hpp" +#include +#include + +class PayloadTypeModel : public QObject, public AbstractObject { + Q_OBJECT + +public: + PayloadTypeModel(const std::shared_ptr &payloadType, QObject *parent = nullptr); + ~PayloadTypeModel(); + + int getClockRate() const; + QString getMimeType() const; + QString getRecvFmtp() const; + + DECLARE_GETSET(bool, enabled, Enabled) + +private: + std::shared_ptr mPayloadType; + + DECLARE_ABSTRACT_OBJECT +}; + +#endif diff --git a/Linphone/tool/AbstractObject.hpp b/Linphone/tool/AbstractObject.hpp index 506f90d34..ad4094399 100644 --- a/Linphone/tool/AbstractObject.hpp +++ b/Linphone/tool/AbstractObject.hpp @@ -38,7 +38,8 @@ } #define DECLARE_GUI_OBJECT \ -Q_SIGNALS : void qmlNameChanged(); \ +Q_SIGNALS: \ + void qmlNameChanged(); \ \ public: \ Q_PROPERTY(QString qmlName READ getQmlName WRITE setQmlName NOTIFY qmlNameChanged) \ @@ -154,6 +155,18 @@ public: } \ } +#define DEFINE_GET(Class, type, X, ownerNotNull) \ + type Class::get##X() const { \ + mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \ + return ownerNotNull->get##X(); \ + } + +#define DEFINE_GET_STRING(Class, X, ownerNotNull) \ + QString Class::get##X() const { \ + mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \ + return Utils::coreStringToAppString(ownerNotNull->get##X()); \ + } + #define DEFINE_GETSET_MODEL_STRING(Class, x, X, ownerNotNull) \ QString Class::get##X() const { \ mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \ @@ -180,6 +193,19 @@ public: } \ } +#define DEFINE_GETSET_ENABLE(Class, x, X, ownerNotNull) \ + bool Class::get##X() const { \ + mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \ + return ownerNotNull->enabled(); \ + } \ + void Class::set##X(bool data) { \ + mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \ + if (get##X() != data) { \ + ownerNotNull->enable(data); \ + emit x##Changed(data); \ + } \ + } + class AbstractObject { public: virtual QString getClassName() const = 0; diff --git a/Linphone/view/CMakeLists.txt b/Linphone/view/CMakeLists.txt index a54ae2903..eaef1db4a 100644 --- a/Linphone/view/CMakeLists.txt +++ b/Linphone/view/CMakeLists.txt @@ -8,6 +8,7 @@ list(APPEND _LINPHONEAPP_QML_FILES view/Control/Button/HelpIconLabelButton.qml view/Control/Button/IconLabelButton.qml view/Control/Button/MediumButton.qml + view/Control/Button/SmallButton.qml view/Control/Button/CountryIndicatorCombobox.qml view/Control/Button/PopupButton.qml view/Control/Button/RadioButton.qml @@ -110,6 +111,7 @@ list(APPEND _LINPHONEAPP_QML_FILES view/Page/Layout/Settings/CarddavSettingsLayout.qml view/Page/Layout/Settings/SecuritySettingsLayout.qml view/Page/Layout/Settings/NetworkSettingsLayout.qml + view/Page/Layout/Settings/AdvancedSettingsLayout.qml view/Page/Main/AbstractMainPage.qml view/Page/Main/Account/AccountListView.qml diff --git a/Linphone/view/Control/Button/MediumButton.qml b/Linphone/view/Control/Button/MediumButton.qml index 51b210964..4be5a13d4 100644 --- a/Linphone/view/Control/Button/MediumButton.qml +++ b/Linphone/view/Control/Button/MediumButton.qml @@ -6,8 +6,8 @@ import Linphone Button { id: mainItem - textSize: Typography.b2.pixelSize - textWeight: Typography.b2.weight + textSize: Typography.b3.pixelSize + textWeight: Typography.b3.weight color: DefaultStyle.main1_100 textColor: DefaultStyle.main1_500_main leftPadding: 16 * DefaultStyle.dp diff --git a/Linphone/view/Control/Button/SmallButton.qml b/Linphone/view/Control/Button/SmallButton.qml new file mode 100644 index 000000000..eb3eec220 --- /dev/null +++ b/Linphone/view/Control/Button/SmallButton.qml @@ -0,0 +1,17 @@ +import QtQuick 2.7 +import QtQuick.Controls.Basic 2.2 as Control +import QtQuick.Effects +import QtQuick.Layouts +import Linphone + +Button { + id: mainItem + textSize: Typography.b2.pixelSize + textWeight: Typography.b2.weight + color: DefaultStyle.main1_100 + textColor: DefaultStyle.main1_500_main + leftPadding: 12 * DefaultStyle.dp + rightPadding: 12 * DefaultStyle.dp + topPadding: 6 * DefaultStyle.dp + bottomPadding: 6 * DefaultStyle.dp +} diff --git a/Linphone/view/Control/Input/DecoratedTextField.qml b/Linphone/view/Control/Input/DecoratedTextField.qml index 3d9c76225..181bb0ec8 100644 --- a/Linphone/view/Control/Input/DecoratedTextField.qml +++ b/Linphone/view/Control/Input/DecoratedTextField.qml @@ -10,14 +10,18 @@ FormItemLayout { label: title mandatory: false enableErrorText: true - property string propertyName - property var propertyOwner + property string propertyName: "value" + property var propertyOwner: new Array property var title property var placeHolder property bool useTitleAsPlaceHolder: true property bool canBeEmpty: true property bool toValidate: false + function value() { + return propertyOwner[propertyName] + } + property alias hidden: textField.hidden property alias validator: textField.validator diff --git a/Linphone/view/Page/Layout/Settings/AdvancedSettingsLayout.qml b/Linphone/view/Page/Layout/Settings/AdvancedSettingsLayout.qml new file mode 100644 index 000000000..171161a1e --- /dev/null +++ b/Linphone/view/Page/Layout/Settings/AdvancedSettingsLayout.qml @@ -0,0 +1,167 @@ + +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls.Basic as Control +import SettingsCpp 1.0 +import UtilsCpp 1.0 +import Linphone +import 'qrc:/Linphone/view/Control/Tool/Helper/utils.js' as Utils + +AbstractSettingsLayout { + contentComponent: content + Component { + id: content + ColumnLayout { + width: parent.width + spacing: 5 * DefaultStyle.dp + RowLayout { + Layout.topMargin: 16 * DefaultStyle.dp + spacing: 5 * DefaultStyle.dp + ColumnLayout { + Layout.fillWidth: true + spacing: 5 * DefaultStyle.dp + ColumnLayout { + Layout.preferredWidth: 341 * DefaultStyle.dp + Layout.maximumWidth: 341 * DefaultStyle.dp + Layout.minimumWidth: 341 * DefaultStyle.dp + spacing: 5 * DefaultStyle.dp + Text { + Layout.fillWidth: true + text: qsTr("Configuration distante") + font: Typography.h4 + wrapMode: Text.WordWrap + color: DefaultStyle.main2_600 + } + } + Item { + Layout.fillHeight: true + } + } + ColumnLayout { + Layout.fillWidth: true + spacing: 20 * DefaultStyle.dp + Layout.rightMargin: 44 * DefaultStyle.dp + Layout.topMargin: 20 * DefaultStyle.dp + Layout.leftMargin: 64 * DefaultStyle.dp + DecoratedTextField { + Layout.fillWidth: true + id: configUri + title: qsTr("URL de configuration distante") + toValidate: true + } + SmallButton { + Layout.alignment: Qt.AlignRight + text: qsTr("Télécharger et appliquer") + onClicked: { + var url = configUri.value() + if (UtilsCpp.isValidURL(url)) + UtilsCpp.useFetchConfig(configUri.value()) + else + UtilsCpp.showInformationPopup(qsTr("Erreur"), qsTr("Format d'url invalide"), false, UtilsCpp.getMainWindow()) + } + } + } + } + Rectangle { + Layout.fillWidth: true + Layout.topMargin: 35 * DefaultStyle.dp + Layout.bottomMargin: 9 * DefaultStyle.dp + height: 1 * DefaultStyle.dp + color: DefaultStyle.main2_500main + } + RowLayout { + Layout.topMargin: 16 * DefaultStyle.dp + spacing: 5 * DefaultStyle.dp + ColumnLayout { + Layout.fillWidth: true + spacing: 5 * DefaultStyle.dp + ColumnLayout { + Layout.preferredWidth: 341 * DefaultStyle.dp + Layout.maximumWidth: 341 * DefaultStyle.dp + Layout.minimumWidth: 341 * DefaultStyle.dp + spacing: 5 * DefaultStyle.dp + Text { + Layout.fillWidth: true + text: qsTr("Codecs Audio") + font: Typography.h4 + wrapMode: Text.WordWrap + color: DefaultStyle.main2_600 + } + } + Item { + Layout.fillHeight: true + } + } + ColumnLayout { + Layout.fillWidth: true + spacing: 20 * DefaultStyle.dp + Layout.rightMargin: 44 * DefaultStyle.dp + Layout.topMargin: 20 * DefaultStyle.dp + Layout.leftMargin: 64 * DefaultStyle.dp + Repeater { + model: PayloadTypeProxy { + family: PayloadTypeCore.Audio + } + SwitchSetting { + Layout.fillWidth: true + titleText: Utils.capitalizeFirstLetter(modelData.core.mimeType) + subTitleText: modelData.core.clockRate + " Hz" + propertyName: "enabled" + propertyOwner: modelData.core + } + } + } + } + Rectangle { + Layout.fillWidth: true + Layout.topMargin: 35 * DefaultStyle.dp + Layout.bottomMargin: 9 * DefaultStyle.dp + height: 1 * DefaultStyle.dp + color: DefaultStyle.main2_500main + } + RowLayout { + Layout.topMargin: 16 * DefaultStyle.dp + spacing: 5 * DefaultStyle.dp + ColumnLayout { + Layout.fillWidth: true + spacing: 5 * DefaultStyle.dp + ColumnLayout { + Layout.preferredWidth: 341 * DefaultStyle.dp + Layout.maximumWidth: 341 * DefaultStyle.dp + Layout.minimumWidth: 341 * DefaultStyle.dp + spacing: 5 * DefaultStyle.dp + Text { + Layout.fillWidth: true + text: qsTr("Codecs Vidéo") + font: Typography.h4 + wrapMode: Text.WordWrap + color: DefaultStyle.main2_600 + } + } + Item { + Layout.fillHeight: true + } + } + ColumnLayout { + Layout.fillWidth: true + spacing: 20 * DefaultStyle.dp + Layout.rightMargin: 44 * DefaultStyle.dp + Layout.topMargin: 20 * DefaultStyle.dp + Layout.leftMargin: 64 * DefaultStyle.dp + Repeater { + model: PayloadTypeProxy { + family: PayloadTypeCore.Video + } + SwitchSetting { + Layout.fillWidth: true + titleText: Utils.capitalizeFirstLetter(modelData.core.mimeType) + subTitleText: modelData.core.recvFmtp + propertyName: "enabled" + propertyOwner: modelData.core + } + } + } + } + } + } +} diff --git a/Linphone/view/Style/Typography.qml b/Linphone/view/Style/Typography.qml index 4d77f4132..31c2cfd33 100644 --- a/Linphone/view/Style/Typography.qml +++ b/Linphone/view/Style/Typography.qml @@ -66,4 +66,11 @@ QtObject { weight: 600 * DefaultStyle.dp }) + // Button/B3 - Small Button + property font b3: Qt.font( { + family: DefaultStyle.defaultFont, + pixelSize: 13 * DefaultStyle.dp, + weight: 600 * DefaultStyle.dp + }) + }