Commit 865c595d authored by Ronan's avatar Ronan

feat(app): refactoring & provide Units module

parent 79e27ca6
......@@ -109,7 +109,6 @@ set(SOURCES
src/components/camera/MSFunctions.cpp
src/components/chat/ChatModel.cpp
src/components/chat/ChatProxyModel.cpp
src/components/clipboard/Clipboard.cpp
src/components/codecs/AbstractCodecsModel.cpp
src/components/codecs/AudioCodecsModel.cpp
src/components/codecs/VideoCodecsModel.cpp
......@@ -123,6 +122,9 @@ set(SOURCES
src/components/core/CoreHandlers.cpp
src/components/core/CoreManager.cpp
src/components/notifier/Notifier.cpp
src/components/other/clipboard/Clipboard.cpp
src/components/other/text-to-speech/TextToSpeech.cpp
src/components/other/units/Units.cpp
src/components/presence/OwnPresenceModel.cpp
src/components/presence/Presence.cpp
src/components/settings/AccountSettingsModel.cpp
......@@ -132,12 +134,11 @@ set(SOURCES
src/components/sip-addresses/SipAddressObserver.cpp
src/components/sound-player/SoundPlayer.cpp
src/components/telephone-numbers/TelephoneNumbersModel.cpp
src/components/text-to-speech/TextToSpeech.cpp
src/components/timeline/TimelineModel.cpp
src/externals/single-application/SingleApplication.cpp
src/main.cpp
src/LinphoneUtils.cpp
src/Utils.cpp
src/utils/LinphoneUtils.cpp
src/utils/Utils.cpp
)
set(HEADERS
......@@ -158,7 +159,6 @@ set(HEADERS
src/components/camera/MSFunctions.hpp
src/components/chat/ChatModel.hpp
src/components/chat/ChatProxyModel.hpp
src/components/clipboard/Clipboard.cpp
src/components/codecs/AbstractCodecsModel.hpp
src/components/codecs/AudioCodecsModel.hpp
src/components/codecs/VideoCodecsModel.hpp
......@@ -173,6 +173,9 @@ set(HEADERS
src/components/core/CoreHandlers.hpp
src/components/core/CoreManager.hpp
src/components/notifier/Notifier.hpp
src/components/other/clipboard/Clipboard.cpp
src/components/other/text-to-speech/TextToSpeech.hpp
src/components/other/units/Units.hpp
src/components/presence/OwnPresenceModel.hpp
src/components/presence/Presence.hpp
src/components/settings/AccountSettingsModel.hpp
......@@ -182,12 +185,11 @@ set(HEADERS
src/components/sip-addresses/SipAddressObserver.hpp
src/components/sound-player/SoundPlayer.hpp
src/components/telephone-numbers/TelephoneNumbersModel.hpp
src/components/text-to-speech/TextToSpeech.hpp
src/components/timeline/TimelineModel.hpp
src/externals/single-application/SingleApplication.hpp
src/externals/single-application/SingleApplicationPrivate.hpp
src/LinphoneUtils.hpp
src/Utils.hpp
src/utils/LinphoneUtils.hpp
src/utils/Utils.hpp
)
set(QRC_RESOURCES resources.qrc)
......
......@@ -31,7 +31,7 @@
#include "gitversion.h"
#include "../components/Components.hpp"
#include "../Utils.hpp"
#include "../utils/Utils.hpp"
#include "cli/Cli.hpp"
#include "logger/Logger.hpp"
......@@ -187,6 +187,7 @@ void App::initContentApp () {
registerTypes();
registerSharedTypes();
registerToolTypes();
// Enable notifications.
createNotifier();
......@@ -332,8 +333,8 @@ void registerMetaType (const char *name) {
template<class T>
void registerSingletonType (const char *name) {
qmlRegisterSingletonType<T>("Linphone", 1, 0, name, [](QQmlEngine *, QJSEngine *) -> QObject *{
return new T();
qmlRegisterSingletonType<T>("Linphone", 1, 0, name, [](QQmlEngine *engine, QJSEngine *) -> QObject *{
return new T(engine);
});
}
......@@ -342,6 +343,13 @@ void registerType (const char *name) {
qmlRegisterType<T>("Linphone", 1, 0, name);
}
template<class T>
void registerToolType (const char *name) {
qmlRegisterSingletonType<T>(name, 1, 0, name, [](QQmlEngine *engine, QJSEngine *) -> QObject *{
return new T(engine);
});
}
void App::registerTypes () {
qInfo() << QStringLiteral("Registering types...");
......@@ -360,10 +368,8 @@ void App::registerTypes () {
registerType<TelephoneNumbersModel>("TelephoneNumbersModel");
registerSingletonType<AudioCodecsModel>("AudioCodecsModel");
registerSingletonType<Clipboard>("Clipboard");
registerSingletonType<OwnPresenceModel>("OwnPresenceModel");
registerSingletonType<Presence>("Presence");
registerSingletonType<TextToSpeech>("TextToSpeech");
registerSingletonType<TimelineModel>("TimelineModel");
registerSingletonType<VideoCodecsModel>("VideoCodecsModel");
......@@ -388,6 +394,14 @@ void App::registerSharedTypes () {
registerSharedSingletonType(ContactsListModel, "ContactsListModel", CoreManager::getInstance()->getContactsListModel);
}
void App::registerToolTypes () {
qInfo() << QStringLiteral("Registering tool types...");
registerToolType<Clipboard>("Clipboard");
registerToolType<TextToSpeech>("TextToSpeech");
registerToolType<Units>("Units");
}
#undef registerUncreatableType
#undef registerSharedSingletonType
......
......@@ -92,6 +92,8 @@ private:
void registerTypes ();
void registerSharedTypes ();
void registerToolTypes ();
void setTrayIcon ();
void createNotifier ();
......
......@@ -22,10 +22,8 @@
#include <stdexcept>
#include <QObject>
#include "../../components/core/CoreManager.hpp"
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "../App.hpp"
#include "Cli.hpp"
......
......@@ -29,6 +29,8 @@
// =============================================================================
class Cli : public QObject {
Q_OBJECT;
typedef void (*Function)(const QHash<QString, QString> &);
enum ArgumentType {
......
......@@ -25,7 +25,7 @@
#include <QDateTime>
#include <QThread>
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "../paths/Paths.hpp"
#include "Logger.hpp"
......
......@@ -27,7 +27,7 @@
#include <QStandardPaths>
#include <QtDebug>
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "config.h"
#include "Paths.hpp"
......
......@@ -20,7 +20,7 @@
* Author: Ronan Abhamon
*/
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "../paths/Paths.hpp"
#include "AvatarProvider.hpp"
......
......@@ -20,7 +20,7 @@
* Author: Ronan Abhamon
*/
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "../paths/Paths.hpp"
#include "ThumbnailProvider.hpp"
......
......@@ -30,7 +30,6 @@
#include "camera/Camera.hpp"
#include "camera/CameraPreview.hpp"
#include "chat/ChatProxyModel.hpp"
#include "clipboard/Clipboard.hpp"
#include "codecs/AudioCodecsModel.hpp"
#include "codecs/VideoCodecsModel.hpp"
#include "conference/ConferenceAddModel.hpp"
......@@ -41,7 +40,10 @@
#include "sip-addresses/SipAddressesProxyModel.hpp"
#include "sound-player/SoundPlayer.hpp"
#include "telephone-numbers/TelephoneNumbersModel.hpp"
#include "text-to-speech/TextToSpeech.hpp"
#include "timeline/TimelineModel.hpp"
#include "other/clipboard/Clipboard.hpp"
#include "other/text-to-speech/TextToSpeech.hpp"
#include "other/units/Units.hpp"
#endif // COMPONENTS_H_
......@@ -21,8 +21,8 @@
*/
#include "../../app/paths/Paths.hpp"
#include "../../LinphoneUtils.hpp"
#include "../../Utils.hpp"
#include "../../utils/LinphoneUtils.hpp"
#include "../../utils/Utils.hpp"
#include "../core/CoreManager.hpp"
#include "AssistantModel.hpp"
......
......@@ -20,7 +20,7 @@
* Author: Ronan Abhamon
*/
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "../core/CoreManager.hpp"
#include "AuthenticationNotifier.hpp"
......
......@@ -25,7 +25,7 @@
#include <QTimer>
#include "../../app/App.hpp"
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "../core/CoreManager.hpp"
#include "CallModel.hpp"
......
......@@ -24,7 +24,7 @@
#include <QTimer>
#include "../../app/App.hpp"
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "../conference/ConferenceHelperModel.hpp"
#include "../core/CoreManager.hpp"
......
......@@ -33,7 +33,7 @@
#include "../../app/App.hpp"
#include "../../app/paths/Paths.hpp"
#include "../../app/providers/ThumbnailProvider.hpp"
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "../core/CoreManager.hpp"
#include "ChatModel.hpp"
......
......@@ -20,7 +20,7 @@
* Author: Ronan Abhamon
*/
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "../core/CoreManager.hpp"
#include "AbstractCodecsModel.hpp"
......
......@@ -20,7 +20,7 @@
* Author: Ronan Abhamon
*/
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "../core/CoreManager.hpp"
#include "ConferenceAddModel.hpp"
......
......@@ -22,7 +22,7 @@
#include <QDateTime>
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "../core/CoreManager.hpp"
#include "ConferenceModel.hpp"
......
......@@ -29,7 +29,7 @@
#include "../../app/App.hpp"
#include "../../app/paths/Paths.hpp"
#include "../../app/providers/AvatarProvider.hpp"
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "../core/CoreManager.hpp"
#include "VcardModel.hpp"
......
......@@ -23,7 +23,7 @@
#include <QtDebug>
#include "../../app/App.hpp"
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "../core/CoreManager.hpp"
#include "ContactsListModel.hpp"
......
......@@ -24,7 +24,7 @@
#include <QDebug>
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "../core/CoreManager.hpp"
#include "ContactsListProxyModel.hpp"
......
......@@ -26,7 +26,7 @@
#include <QTimer>
#include "../../app/App.hpp"
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "CoreManager.hpp"
#include "CoreHandlers.hpp"
......
......@@ -25,7 +25,7 @@
#include <QTimer>
#include "../../app/paths/Paths.hpp"
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "CoreManager.hpp"
......
......@@ -27,7 +27,7 @@
#include <QTimer>
#include "../../app/App.hpp"
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "../core/CoreManager.hpp"
#include "Notifier.hpp"
......
/*
* Units.cpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: June 8, 2017
* Author: Ronan Abhamon
*/
#include "Units.hpp"
// =============================================================================
Units::Units (QObject *parent) : QObject(parent) {}
float Units::getDp () const {
return 1.0;
}
/*
* Units.hpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: June 8, 2017
* Author: Ronan Abhamon
*/
#ifndef UNITS_H_
#define UNITS_H_
#include <QObject>
// =============================================================================
class Units : public QObject {
Q_OBJECT;
Q_PROPERTY(float dp READ getDp NOTIFY dpChanged);
public:
Units (QObject *parent = Q_NULLPTR);
~Units () = default;
signals:
void dpChanged ();
private:
float getDp () const;
};
#endif // UNITS_H_
......@@ -22,7 +22,7 @@
#include <QtDebug>
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "../core/CoreManager.hpp"
#include "OwnPresenceModel.hpp"
......
......@@ -22,7 +22,7 @@
#include <QtDebug>
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "../core/CoreManager.hpp"
#include "AccountSettingsModel.hpp"
......
......@@ -23,7 +23,7 @@
#include <QDir>
#include "../../app/paths/Paths.hpp"
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "../core/CoreManager.hpp"
#include "SettingsModel.hpp"
......
......@@ -24,8 +24,8 @@
#include <QSet>
#include <QtDebug>
#include "../../LinphoneUtils.hpp"
#include "../../Utils.hpp"
#include "../../utils/LinphoneUtils.hpp"
#include "../../utils/Utils.hpp"
#include "../chat/ChatModel.hpp"
#include "../core/CoreManager.hpp"
......
......@@ -22,7 +22,7 @@
#include <QTimer>
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "../core/CoreManager.hpp"
#include "SoundPlayer.hpp"
......
......@@ -43,7 +43,7 @@
#include <lmcons.h>
#endif // ifdef Q_OS_WIN
#include "../../Utils.hpp"
#include "../../utils/Utils.hpp"
#include "SingleApplication.hpp"
#include "SingleApplicationPrivate.hpp"
......
......@@ -24,7 +24,7 @@ Item {
}
color: DialogStyle.description.color
font.pointSize: DialogStyle.description.fontSize
font.pointSize: DialogStyle.description.pointSize
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
wrapMode: Text.WordWrap
......
......@@ -65,7 +65,7 @@ Item {
color: _getTextColor()
font {
bold: true
pointSize: AbstractTextButtonStyle.text.fontSize
pointSize: AbstractTextButtonStyle.text.pointSize
}
elide: Text.ElideRight
......
......@@ -24,7 +24,7 @@ Button {
}
contentItem: Text {
color: SmallButtonStyle.text.color
font.pointSize: SmallButtonStyle.text.fontSize
font.pointSize: SmallButtonStyle.text.pointSize
horizontalAlignment: Text.AlignHCenter
text: button.text
verticalAlignment: Text.AlignVCenter
......
......@@ -30,7 +30,7 @@ CheckBox {
verticalAlignment: Text.AlignVCenter
}
font.pointSize: CheckBoxTextStyle.fontSize
font.pointSize: CheckBoxTextStyle.pointSize
hoverEnabled: true
indicator: Rectangle {
......
......@@ -50,7 +50,7 @@ ComboBox {
color: ComboBoxStyle.contentItem.text.color
elide: Text.ElideRight
font.pointSize: ComboBoxStyle.contentItem.text.fontSize
font.pointSize: ComboBoxStyle.contentItem.text.pointSize
rightPadding: comboBox.indicator.width + comboBox.spacing
text: Logic.getSelectedEntryText()
......@@ -123,7 +123,7 @@ ComboBox {
font {
bold: comboBox.currentIndex === index
pointSize: ComboBoxStyle.delegate.contentItem.text.fontSize
pointSize: ComboBoxStyle.delegate.contentItem.text.pointSize
}
text: item.flattenedModel[textRole] || modelData
......
......@@ -4,7 +4,6 @@ import QtQuick.Dialogs 1.2
import Common 1.0
import Common.Styles 1.0
import Utils 1.0
// =============================================================================
......@@ -65,7 +64,7 @@ Item {
}
color: DroppableTextAreaStyle.text.color
font.pointSize: DroppableTextAreaStyle.text.fontSize
font.pointSize: DroppableTextAreaStyle.text.pointSize
rightPadding: fileChooserButton.width +
fileChooserButton.anchors.rightMargin +
DroppableTextAreaStyle.fileChooserButton.margins
......@@ -132,7 +131,7 @@ Item {
Text {
anchors.centerIn: parent
color: DroppableTextAreaStyle.hoverContent.text.color
font.pointSize: DroppableTextAreaStyle.hoverContent.text.fontSize
font.pointSize: DroppableTextAreaStyle.hoverContent.text.pointSize
text: qsTr('dropYourAttachment')
}
}
......
......@@ -74,7 +74,7 @@ TextField {
contentItem: Text {
color: NumericFieldStyle.tools.button.text.color
text: buttonInstance.text
font.pointSize: NumericFieldStyle.tools.button.text.fontSize
font.pointSize: NumericFieldStyle.tools.button.text.pointSize
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
......
......@@ -35,7 +35,7 @@ Flickable {
}
color: TextAreaFieldStyle.text.color
font.pointSize: TextAreaFieldStyle.text.fontSize
font.pointSize: TextAreaFieldStyle.text.pointSize
selectByMouse: true
wrapMode: TextArea.Wrap
......
......@@ -60,7 +60,7 @@ Controls.TextField {
}
color: TextFieldStyle.text.color
font.pointSize: TextFieldStyle.text.fontSize
font.pointSize: TextFieldStyle.text.pointSize
rightPadding: TextFieldStyle.text.rightPadding + toolsContainer.width
selectByMouse: true
......
......@@ -71,7 +71,7 @@ RowLayout {
font {
bold: true
pointSize: ListFormStyle.titleArea.text.fontSize
pointSize: ListFormStyle.titleArea.text.pointSize
}
}
}
......@@ -89,7 +89,7 @@ RowLayout {
font {
italic: true
pointSize: ListFormStyle.value.placeholder.fontSize
pointSize: ListFormStyle.value.placeholder.pointSize
}
padding: ListFormStyle.value.text.padding
......
......@@ -27,7 +27,7 @@ Column {
color: FormStyle.header.title.color
font {
bold: true
pointSize: FormStyle.header.title.fontSize
pointSize: FormStyle.header.title.pointSize
}
}
......
......@@ -24,7 +24,7 @@ RowLayout {
color: FormHGroupStyle.legend.color
elide: Text.ElideRight
font.pointSize: FormHGroupStyle.legend.fontSize
font.pointSize: FormHGroupStyle.legend.pointSize
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
......