Commit c71f1590 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/views/App/Settings/SettingsUi): supports videos/screenshots paths

parent c30c3d16
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "../components/contacts/ContactsListProxyModel.hpp" #include "../components/contacts/ContactsListProxyModel.hpp"
#include "../components/core/CoreManager.hpp" #include "../components/core/CoreManager.hpp"
#include "../components/settings/AccountSettingsModel.hpp" #include "../components/settings/AccountSettingsModel.hpp"
#include "../components/settings/SettingsModel.hpp"
#include "../components/smart-search-bar/SmartSearchBarModel.hpp" #include "../components/smart-search-bar/SmartSearchBarModel.hpp"
#include "../components/timeline/TimelineModel.hpp" #include "../components/timeline/TimelineModel.hpp"
#include "../utils.hpp" #include "../utils.hpp"
...@@ -265,7 +264,7 @@ void App::registerTypes () { ...@@ -265,7 +264,7 @@ void App::registerTypes () {
qmlRegisterSingletonType<SettingsModel>( qmlRegisterSingletonType<SettingsModel>(
"Linphone", 1, 0, "SettingsModel", "Linphone", 1, 0, "SettingsModel",
[](QQmlEngine *, QJSEngine *) -> QObject *{ [](QQmlEngine *, QJSEngine *) -> QObject *{
return new SettingsModel(); return CoreManager::getInstance()->getSettingsModel();
} }
); );
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include <QtDebug> #include <QtDebug>
#include "../../app/App.hpp" #include "../../app/App.hpp"
#include "../../app/Paths.hpp"
#include "../../utils.hpp" #include "../../utils.hpp"
#include "../core/CoreManager.hpp" #include "../core/CoreManager.hpp"
...@@ -87,8 +86,8 @@ CallModel::CallModel (shared_ptr<linphone::Call> linphone_call) { ...@@ -87,8 +86,8 @@ CallModel::CallModel (shared_ptr<linphone::Call> linphone_call) {
void CallModel::setRecordFile (shared_ptr<linphone::CallParams> &call_params) { void CallModel::setRecordFile (shared_ptr<linphone::CallParams> &call_params) {
call_params->setRecordFile( call_params->setRecordFile(
Paths::getCapturesDirPath() +
::Utils::qStringToLinphoneString( ::Utils::qStringToLinphoneString(
CoreManager::getInstance()->getSettingsModel()->getSavedVideosFolder() +
QDateTime::currentDateTime().toString("yyyy-MM-dd_hh:mm:ss") QDateTime::currentDateTime().toString("yyyy-MM-dd_hh:mm:ss")
) + ".mkv" ) + ".mkv"
); );
...@@ -150,7 +149,9 @@ void CallModel::takeSnapshot () { ...@@ -150,7 +149,9 @@ void CallModel::takeSnapshot () {
qInfo() << "Take snapshot of call:" << &m_linphone_call; qInfo() << "Take snapshot of call:" << &m_linphone_call;
m_linphone_call->takeVideoSnapshot( m_linphone_call->takeVideoSnapshot(
Paths::getCapturesDirPath() + ::Utils::qStringToLinphoneString(new_name) ::Utils::qStringToLinphoneString(
CoreManager::getInstance()->getSettingsModel()->getSavedScreenshotsFolder() + new_name
)
); );
} }
......
...@@ -57,6 +57,7 @@ void CoreManager::init (const QString &configPath) { ...@@ -57,6 +57,7 @@ void CoreManager::init (const QString &configPath) {
m_instance->m_calls_list_model = new CallsListModel(m_instance); m_instance->m_calls_list_model = new CallsListModel(m_instance);
m_instance->m_contacts_list_model = new ContactsListModel(m_instance); m_instance->m_contacts_list_model = new ContactsListModel(m_instance);
m_instance->m_sip_addresses_model = new SipAddressesModel(m_instance); m_instance->m_sip_addresses_model = new SipAddressesModel(m_instance);
m_instance->m_settings_model = new SettingsModel(m_instance);
QTimer *timer = m_instance->m_cbs_timer = new QTimer(m_instance); QTimer *timer = m_instance->m_cbs_timer = new QTimer(m_instance);
timer->setInterval(20); timer->setInterval(20);
...@@ -88,7 +89,9 @@ void CoreManager::setResourcesPaths () { ...@@ -88,7 +89,9 @@ void CoreManager::setResourcesPaths () {
mspluginsdir.cd("lib/mediastreamer/plugins"); mspluginsdir.cd("lib/mediastreamer/plugins");
QDir datadir(dir); QDir datadir(dir);
datadir.cd("share"); datadir.cd("share");
linphone::Factory::get()->setMspluginsDir(::Utils::qStringToLinphoneString(mspluginsdir.absolutePath()));
linphone::Factory::get()->setTopResourcesDir(::Utils::qStringToLinphoneString(datadir.absolutePath())); shared_ptr<linphone::Factory> factory = linphone::Factory::get();
factory->setMspluginsDir(::Utils::qStringToLinphoneString(mspluginsdir.absolutePath()));
factory->setTopResourcesDir(::Utils::qStringToLinphoneString(datadir.absolutePath()));
} }
} }
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "../calls/CallsListModel.hpp" #include "../calls/CallsListModel.hpp"
#include "../contacts/ContactsListModel.hpp" #include "../contacts/ContactsListModel.hpp"
#include "../settings/SettingsModel.hpp"
#include "../sip-addresses/SipAddressesModel.hpp" #include "../sip-addresses/SipAddressesModel.hpp"
#include "CoreHandlers.hpp" #include "CoreHandlers.hpp"
...@@ -64,6 +65,10 @@ public: ...@@ -64,6 +65,10 @@ public:
return m_sip_addresses_model; return m_sip_addresses_model;
} }
SettingsModel *getSettingsModel () const {
return m_settings_model;
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Initialization. // Initialization.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -92,6 +97,7 @@ private: ...@@ -92,6 +97,7 @@ private:
CallsListModel *m_calls_list_model; CallsListModel *m_calls_list_model;
ContactsListModel *m_contacts_list_model; ContactsListModel *m_contacts_list_model;
SipAddressesModel *m_sip_addresses_model; SipAddressesModel *m_sip_addresses_model;
SettingsModel *m_settings_model;
QTimer *m_cbs_timer; QTimer *m_cbs_timer;
......
...@@ -20,9 +20,12 @@ ...@@ -20,9 +20,12 @@
* Author: Ronan Abhamon * Author: Ronan Abhamon
*/ */
#include "../../app/Paths.hpp"
#include "../../utils.hpp" #include "../../utils.hpp"
#include "../core/CoreManager.hpp" #include "../core/CoreManager.hpp"
#include <QDir>
#include "SettingsModel.hpp" #include "SettingsModel.hpp"
using namespace std; using namespace std;
...@@ -59,3 +62,37 @@ void SettingsModel::setFileTransferUrl (const QString &url) { ...@@ -59,3 +62,37 @@ void SettingsModel::setFileTransferUrl (const QString &url) {
::Utils::qStringToLinphoneString(url) ::Utils::qStringToLinphoneString(url)
); );
} }
// -----------------------------------------------------------------------------
QString SettingsModel::getSavedScreenshotsFolder () const {
return QDir::cleanPath(
::Utils::linphoneStringToQString(
m_config->getString(UI_SECTION, "saved_screenshots_folder", Paths::getCapturesDirPath())
)
) + QDir::separator();
}
void SettingsModel::setSavedScreenshotsFolder (const QString &folder) {
QString _folder = QDir::cleanPath(folder) + QDir::separator();
m_config->setString(UI_SECTION, "saved_screenshots_folder", ::Utils::qStringToLinphoneString(_folder));
emit savedScreenshotsFolderChanged(_folder);
}
// -----------------------------------------------------------------------------
QString SettingsModel::getSavedVideosFolder () const {
return QDir::cleanPath(
::Utils::linphoneStringToQString(
m_config->getString(UI_SECTION, "saved_videos_folder", Paths::getCapturesDirPath())
)
) + QDir::separator();
}
void SettingsModel::setSavedVideosFolder (const QString &folder) {
QString _folder = QDir::cleanPath(folder) + QDir::separator();
m_config->setString(UI_SECTION, "saved_videos_folder", ::Utils::qStringToLinphoneString(_folder));
emit savedVideosFolderChanged(_folder);
}
...@@ -34,22 +34,34 @@ class SettingsModel : public QObject { ...@@ -34,22 +34,34 @@ class SettingsModel : public QObject {
Q_PROPERTY(bool autoAnswerStatus READ getAutoAnswerStatus WRITE setAutoAnswerStatus NOTIFY autoAnswerStatusChanged); Q_PROPERTY(bool autoAnswerStatus READ getAutoAnswerStatus WRITE setAutoAnswerStatus NOTIFY autoAnswerStatusChanged);
Q_PROPERTY(QString fileTransferUrl READ getFileTransferUrl WRITE setFileTransferUrl NOTIFY fileTransferUrlChanged); Q_PROPERTY(QString fileTransferUrl READ getFileTransferUrl WRITE setFileTransferUrl NOTIFY fileTransferUrlChanged);
Q_PROPERTY(QString savedScreenshotsFolder READ getSavedScreenshotsFolder WRITE setSavedScreenshotsFolder NOTIFY savedScreenshotsFolderChanged);
Q_PROPERTY(QString savedVideosFolder READ getSavedVideosFolder WRITE setSavedVideosFolder NOTIFY savedVideosFolderChanged);
public: public:
SettingsModel (QObject *parent = Q_NULLPTR); SettingsModel (QObject *parent = Q_NULLPTR);
bool getAutoAnswerStatus () const;
void setAutoAnswerStatus (bool status);
QString getFileTransferUrl () const;
void setFileTransferUrl (const QString &url);
QString getSavedScreenshotsFolder () const;
void setSavedScreenshotsFolder (const QString &folder);
QString getSavedVideosFolder () const;
void setSavedVideosFolder (const QString &folder);
static const std::string UI_SECTION; static const std::string UI_SECTION;
signals: signals:
void autoAnswerStatusChanged (bool status); void autoAnswerStatusChanged (bool status);
void fileTransferUrlChanged (const QString &url); void fileTransferUrlChanged (const QString &url);
private: void savedScreenshotsFolderChanged (const QString &folder);
bool getAutoAnswerStatus () const; void savedVideosFolderChanged (const QString &folder);
void setAutoAnswerStatus (bool status);
QString getFileTransferUrl () const;
void setFileTransferUrl (const QString &url);
private:
std::shared_ptr<linphone::Config> m_config; std::shared_ptr<linphone::Config> m_config;
}; };
......
...@@ -89,7 +89,10 @@ TabContainer { ...@@ -89,7 +89,10 @@ TabContainer {
FileChooserButton { FileChooserButton {
id: savedScreenshotsFolder id: savedScreenshotsFolder
selectedFile: SettingsModel.savedScreenshotsFolder
selectFolder: true selectFolder: true
onAccepted: SettingsModel.savedScreenshotsFolder = selectedFile
} }
} }
...@@ -99,7 +102,10 @@ TabContainer { ...@@ -99,7 +102,10 @@ TabContainer {
FileChooserButton { FileChooserButton {
id: savedVideosFolder id: savedVideosFolder
selectedFile: SettingsModel.savedVideosFolder
selectFolder: true selectFolder: true
onAccepted: SettingsModel.savedVideosFolder = selectedFile
} }
} }
} }
......
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