utf32_string = text.toUcs4();
- for (auto &code : utf32_string)
- if(codepointIsVisible(code) && !Utils::codepointIsEmoji(code))
- return false;
- return true;
-}
-
-
-QString Utils::encodeTextToQmlRichFormat(const QString& text, const QVariantMap& options){
- //QString images;
- //QStringList imageFormat;
- //for(auto format : QImageReader::supportedImageFormats())
-// imageFormat.append(QString::fromLatin1(format).toUpper());
-
- QStringList formattedText;
- bool lastWasUrl = false;
-
- if(options.contains("noLink") && options["noLink"].toBool()){
- formattedText.append(encodeEmojiToQmlRichFormat(text));
- }else{
- auto primaryColor = App::getInstance()->getColorListModel()->getColor("i")->getColor();
- auto iriParsed = UriTools::parseIri(text);
-
- for(int i = 0 ; i < iriParsed.size() ; ++i){
- QString iri = iriParsed[i].second.replace('&', "&")
- .replace('<', "\u2063<")
- .replace('>', "\u2063>")
- .replace('"', """)
- .replace('\'', "'");
- if(!iriParsed[i].first){
- if(lastWasUrl){
- lastWasUrl = false;
- if(iri.front() != ' ')
- iri.push_front(' ');
- }
- formattedText.append(encodeEmojiToQmlRichFormat(iri));
- }else{
- QString uri = iriParsed[i].second.left(3) == "www" ? "http://"+iriParsed[i].second : iriParsed[i].second
-;
- /* TODO : preview from link
- //int extIndex = iriParsed[i].second.lastIndexOf('.');
- //QString ext;
- //if( extIndex >= 0)
- // ext = iriParsed[i].second.mid(extIndex+1).toUpper();
- //if(imageFormat.contains(ext.toLatin1())){// imagesHeight is not used because of bugs on display (blank
-image if set without width)
- // images += "
"+uri+"";
- //}else{
- formattedText.append( "" + iri +
-""); lastWasUrl = true;
- //}
- }
- }
- }
- if(lastWasUrl && formattedText.last().back() != ' '){
- formattedText.push_back(" ");
- }
- return "" + formattedText.join("") + "
";
-}
-
-QString Utils::getFileContent(const QString& filePath){
- QString contents;
- QFile file(filePath);
- if (!file.open(QFile::ReadOnly | QFile::Text))
- return "";
- return file.readAll();
-}
-static QStringList gDbPaths;
-
-void Utils::deleteAllUserData(){
-// Store usable data like custom folders
- gDbPaths.clear();
- gDbPaths.append(Utils::coreStringToAppString(linphone::Factory::get()->getDataDir(nullptr)));
- gDbPaths.append(Utils::coreStringToAppString(linphone::Factory::get()->getConfigDir(nullptr)));
-// Exit with a delete code
- App::getInstance()->exit(App::DeleteDataCode);
-}
-
-void Utils::deleteAllUserDataOffline(){
- qWarning() << "Deleting all data! ";
- for(int i = 0 ; i < gDbPaths.size() ; ++i){
- QDir dir(gDbPaths[i]);
- qWarning() << "Deleting " << gDbPaths[i] << " : " << (dir.removeRecursively() ? "Successfully" : "Failed");
- }
-}
-
-//-------------------------------------------------------------------------------------------------------
-// WIDGETS
-//-------------------------------------------------------------------------------------------------------
-
-bool Utils::openWithPdfViewer(ContentModel * contentModel, const QString& filePath, const int& width, const int& height)
-{ #ifdef PDF_ENABLED PdfWidget *view = new PdfWidget(contentModel); view->setMinimumSize(QSize(width, height));
- view->show();
- view->open(filePath);
- return true;
-#else
- return false;
-#endif
-}
-
-void Utils::setFamilyFont(QAction * dest, const QString& family){
- QFont font(dest->font());
- font.setFamily(family);
- dest->setFont(font);
-}
-void Utils::setFamilyFont(QWidget * dest, const QString& family){
- QFont font(dest->font());
- font.setFamily(family);
- dest->setFont(font);
-}
-QPixmap Utils::getMaskedPixmap(const QString& name, const QColor& color){
- QSize size;
- QPixmap img = ImageProvider::computePixmap(name, &size);
- QPixmap pxr( img.size() );
- pxr.fill( color );
- pxr.setMask( img.createMaskFromColor( Qt::transparent ) );
- return pxr;
-}
-*/
diff --git a/Linphone/tool/Utils.hpp b/Linphone/tool/Utils.hpp
index 4942415ed..33e3cec08 100644
--- a/Linphone/tool/Utils.hpp
+++ b/Linphone/tool/Utils.hpp
@@ -21,18 +21,11 @@
#ifndef UTILS_H_
#define UTILS_H_
-#include
-#include
-#include
#include
#include
#include "Constants.hpp"
-class QAction;
-class QWidget;
-class DateModel;
-
// =============================================================================
/*
@@ -47,75 +40,12 @@ class DateModel;
#endif // if defined(__GNUC__) && __GNUC__ >= 7
#endif // ifndef UTILS_NO_BREAK
-class ContentModel;
-
class Utils : public QObject {
Q_OBJECT
public:
Utils(QObject *parent = nullptr) : QObject(parent) {
}
- /*
- typedef enum{
- SIP_DISPLAY_USERNAME = 0,
- SIP_DISPLAY_ALL = -1
- }SipDisplayMode;
- Q_ENUM(SipDisplayMode)
- // Qt interfaces
- Q_INVOKABLE static bool hasCapability(const QString& address, const LinphoneEnums::FriendCapability& capability,
- bool defaultCapability = true);
- // ***** DATE TIME
- Q_INVOKABLE static QDateTime addMinutes(QDateTime date, const int& min);
- static QDateTime getOffsettedUTC(const QDateTime& date);
- Q_INVOKABLE static QString toDateTimeString(QDateTime date, const QString& format = "yyyy/MM/dd hh:mm:ss");
- Q_INVOKABLE static QString toTimeString(QDateTime date, const QString& format = "hh:mm:ss");
- Q_INVOKABLE static QString toDateString(QDateTime date, const QString& format = "");
- Q_INVOKABLE static QString toDateString(QDate date, const QString& format = "");
- Q_INVOKABLE static QString toDisplayString(const QString& str, SipDisplayMode displayMode = SIP_DISPLAY_ALL);
- Q_INVOKABLE static QDate getCurrentDate();
- Q_INVOKABLE static DateModel* getCurrentDateModel();
- Q_INVOKABLE static QDate getMinDate();
- Q_INVOKABLE static DateModel* getMinDateModel();
- Q_INVOKABLE static QDate toDate(const QString& str, const QString& format = "yyyy/MM/dd");
- Q_INVOKABLE static QDate getDate(int year, int month, int day);
- Q_INVOKABLE static DateModel* toDateModel(const QString& str, const QString& format = "yyyy/MM/dd");
- Q_INVOKABLE static DateModel* getDateModel(int year, int month, int day);
- Q_INVOKABLE static int getFullYear(const QDate& date);
- Q_INVOKABLE static int getMonth(const QDate& date);
- Q_INVOKABLE static int getDay(const QDate& date);
- Q_INVOKABLE static int getDayOfWeek(const QDate& date);
- Q_INVOKABLE static bool equals(const QDate& d1, const QDate& d2); // Override JS '==' operator
- Q_INVOKABLE static bool isGreatherThan(const QDate& d1, const QDate& d2); // Override JS '>=' operator
- //*****
- static void cleanDisplayNameCache(const QString& address = "");// if "", clean all cache
- Q_INVOKABLE static QString getDisplayName(const QString& address);
- Q_INVOKABLE static QString getInitials(const QString& username); // Support UTF32
- Q_INVOKABLE static QString toString(const LinphoneEnums::TunnelMode& mode);
- Q_INVOKABLE static bool isMe(const QString& address);
- Q_INVOKABLE static bool isAnimatedImage(const QString& path);
- Q_INVOKABLE static bool isImage(const QString& path);
- Q_INVOKABLE static bool isVideo(const QString& path);
- Q_INVOKABLE static bool isPdf(const QString& path);
- Q_INVOKABLE static bool isSupportedForDisplay(const QString& path);
- Q_INVOKABLE static bool canHaveThumbnail(const QString& path);
- Q_INVOKABLE static bool isPhoneNumber(const QString& txt);
- Q_INVOKABLE static bool isUsername(const QString& txt); // Check with Regex
- Q_INVOKABLE static bool isValidUrl(const QString& url);
- Q_INVOKABLE QSize getImageSize(const QString& url);
- Q_INVOKABLE static QPoint getCursorPosition();
- Q_INVOKABLE static QString getFileChecksum(const QString& filePath);
- static bool codepointIsEmoji(uint code);
- static bool codepointIsVisible(uint code);
- Q_INVOKABLE static bool isOnlyEmojis(const QString& text);
- Q_INVOKABLE static QString encodeEmojiToQmlRichFormat(const QString &body);
- Q_INVOKABLE static QString encodeTextToQmlRichFormat(const QString& text, const QVariantMap& options =
- QVariantMap()); Q_INVOKABLE static QString getFileContent(const QString& filePath);
-
- Q_INVOKABLE static bool openWithPdfViewer(ContentModel *contentModel, const QString& filePath, const int& width,
- const int& height); // return true if PDF is enabled
-
- //----------------------------------------------------------------------------------
- */
static inline QString coreStringToAppString(const std::string &str) {
if (Constants::LinphoneLocaleEncoding == QString("UTF-8")) return QString::fromStdString(str);
else
@@ -131,75 +61,10 @@ public:
// Reverse function of strstr.
static char *rstrstr(const char *a, const char *b);
- /*
- // Return the path if it is an image else an empty path.
- static QImage getImage(const QString &pUri);
- // Returns the same path given in parameter if `filePath` exists.
- // Otherwise returns a safe path with a unique number before the extension.
- static QString getSafeFilePath (const QString &filePath, bool *soFarSoGood = nullptr);
- static std::shared_ptr getMatchingLocalAddress(std::shared_ptr
- p_localAddress); static QString cleanSipAddress (const QString &sipAddress);// Return at most : sip:username@domain
- // Test if the process exists
- static bool processExists(const quint64& p_processId);
-
- // Connect once to a member function.
- template
- static inline QMetaObject::Connection connectOnce (
- typename QtPrivate::FunctionPointer::Object *sender,
- Func1 signal,
- typename QtPrivate::FunctionPointer::Object *receiver,
- Func2 slot
- ) {
- QMetaObject::Connection connection = QObject::connect(sender, signal, receiver, slot);
- QMetaObject::Connection *deleter = new QMetaObject::Connection();
-
- *deleter = QObject::connect(sender, signal, [connection, deleter] {
- QObject::disconnect(connection);
- QObject::disconnect(*deleter);
- delete deleter;
- });
-
- return connection;
+ template
+ static std::shared_ptr makeQObject_ptr(Args &&...args) {
+ return std::shared_ptr(new T(args...), [](T *obj) { obj->deleteLater(); });
}
-
- // Connect once to a function.
- template
- static inline QMetaObject::Connection connectOnce (
- typename QtPrivate::FunctionPointer::Object *sender,
- Func1 signal,
- const QObject *receiver,
- Func2 slot
- ) {
- QMetaObject::Connection connection = QObject::connect(sender, signal, receiver, slot);
- QMetaObject::Connection *deleter = new QMetaObject::Connection();
-
- *deleter = QObject::connect(sender, signal, [connection, deleter] {
- QObject::disconnect(connection);
- QObject::disconnect(*deleter);
- delete deleter;
- });
-
- return connection;
- }
- static std::shared_ptr interpretUrl(const QString& address);
-
-
- static QString getCountryName(const QLocale::Country& country);
- static void copyDir(QString from, QString to);// Copy a folder recursively without erasing old file
- static QString getDisplayName(const std::shared_ptr& address); // Get the displayname from
- addres in this order : Friends, Contact, Display address, Username address static std::shared_ptr
- getConfigIfExists (const QString& configPath); static QString getApplicationProduct(); static QString
- getOsProduct(); static QString computeUserAgent(const std::shared_ptr& config);
-
- static bool isMe(const std::shared_ptr& address);
-
- static void deleteAllUserData();
- static void deleteAllUserDataOffline();// When we are out of all events and core is not running (aka in main())
-
- static void setFamilyFont(QAction * dest, const QString& family);
- static void setFamilyFont(QWidget * dest, const QString& family);
- static QPixmap getMaskedPixmap(const QString& name, const QColor& color);
-*/
};
#endif // UTILS_H_
diff --git a/Linphone/view/CMakeLists.txt b/Linphone/view/CMakeLists.txt
index 6ce235d3d..37e2788c2 100644
--- a/Linphone/view/CMakeLists.txt
+++ b/Linphone/view/CMakeLists.txt
@@ -17,7 +17,8 @@ list(APPEND _LINPHONEAPP_QML_FILES
view/Page/Login/WelcomePage.qml
# Prototypes
- view/Prototype/PhoneNumberItem.qml
+ view/Prototype/PhoneNumberPrototype.qml
+ view/Prototype/AccountsPrototype.qml
)
list(APPEND _LINPHONEAPP_QML_SINGLETONS
diff --git a/Linphone/view/Prototype/AccountsPrototype.qml b/Linphone/view/Prototype/AccountsPrototype.qml
new file mode 100644
index 000000000..5b569c1f9
--- /dev/null
+++ b/Linphone/view/Prototype/AccountsPrototype.qml
@@ -0,0 +1,64 @@
+import QtQuick 2.15
+import QtQuick.Layouts 1.0
+import QtQuick.Controls as Control
+import Linphone
+// Snippet
+
+ListView{
+ id: mainItem
+ model: AccountProxy{}
+ function printObject(o) {
+ var out = '';
+ for (var p in o) {
+ out += p + ': ' + o[p] + '\n';
+ }
+ if(!o)
+ return 'Empty'
+ else
+ return out;
+}
+
+ delegate: Rectangle{
+ height: 50
+ width: mainItem.width
+ RowLayout{
+ anchors.fill: parent
+ Rectangle{
+ Layout.preferredHeight: 50
+ Layout.preferredWidth: 50
+ //color: '#111111'
+ Image{
+ id: avatar
+ anchors.fill: parent
+ source: $modelData.pictureUri
+ }
+ }
+ Text{
+ text: $modelData.identityAddress
+ }
+ Text{
+ text: $modelData.registrationState == LinphoneEnums.RegistrationState.Ok
+ ? 'Online'
+ : $modelData.registrationState == LinphoneEnums.RegistrationState.Failed
+ ? 'Error'
+ : $modelData.registrationState == LinphoneEnums.RegistrationState.Progress || $modelData.registrationState == LinphoneEnums.RegistrationState.Refreshing
+ ? 'Connecting'
+ : 'Offline'
+
+ }
+ }
+ MouseArea{
+ anchors.fill: parent
+ property int clickCount : 0
+ onClicked: {
+ if(++clickCount % 2 == 0)
+ $modelData.pictureUri = AppIcons.loginImage;
+ else
+ $modelData.pictureUri = AppIcons.eyeShow;
+ console.log(printObject($modelData))
+ console.debug("[ProtoAccounts] Account Select: " +$modelData.contactAddress +" / "+$modelData.identityAddress + " / " +$modelData.pictureUri + " / " +$modelData.registrationState)
+ }
+ }
+ }
+}
+
diff --git a/Linphone/view/Prototype/PhoneNumberItem.qml b/Linphone/view/Prototype/PhoneNumberPrototype.qml
similarity index 100%
rename from Linphone/view/Prototype/PhoneNumberItem.qml
rename to Linphone/view/Prototype/PhoneNumberPrototype.qml