mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-24 07:08:07 +00:00
fix(app): many changes, expose locale and use it with dates, use qmlRegisterSingletonType instead of context properties
This commit is contained in:
parent
bfe32c4404
commit
37c15e9f8b
5 changed files with 53 additions and 20 deletions
|
|
@ -70,19 +70,43 @@ void App::registerTypes () {
|
|||
"Linphone", 1, 0, "Presence", "Presence is uncreatable"
|
||||
);
|
||||
|
||||
qmlRegisterSingletonType<App>(
|
||||
"Linphone", 1, 0, "App",
|
||||
[](QQmlEngine *, QJSEngine *) -> QObject *{
|
||||
return App::getInstance();
|
||||
}
|
||||
);
|
||||
|
||||
qmlRegisterSingletonType<CoreManager>(
|
||||
"Linphone", 1, 0, "CoreManager",
|
||||
[](QQmlEngine *, QJSEngine *) -> QObject *{
|
||||
return CoreManager::getInstance();
|
||||
}
|
||||
);
|
||||
|
||||
ContactsListProxyModel::initContactsListModel(new ContactsListModel());
|
||||
qmlRegisterType<ContactsListProxyModel>("Linphone", 1, 0, "ContactsListProxyModel");
|
||||
|
||||
// Expose the static functions of ContactsListModel.
|
||||
qmlRegisterSingletonType<ContactsListModel>(
|
||||
"Linphone", 1, 0, "ContactsListModel",
|
||||
[](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject *{
|
||||
Q_UNUSED(engine);
|
||||
Q_UNUSED(scriptEngine);
|
||||
|
||||
[](QQmlEngine *, QJSEngine *) -> QObject *{
|
||||
return ContactsListProxyModel::getContactsListModel();
|
||||
}
|
||||
);
|
||||
|
||||
qmlRegisterSingletonType<AccountSettingsModel>(
|
||||
"Linphone", 1, 0, "AccountSettingsModel",
|
||||
[](QQmlEngine *, QJSEngine *) -> QObject *{
|
||||
return new AccountSettingsModel();
|
||||
}
|
||||
);
|
||||
|
||||
qmlRegisterSingletonType<TimelineModel>(
|
||||
"Linphone", 1, 0, "TimelineModel",
|
||||
[](QQmlEngine *, QJSEngine *) -> QObject *{
|
||||
return new TimelineModel();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void App::addContextProperties () {
|
||||
|
|
@ -96,13 +120,6 @@ void App::addContextProperties () {
|
|||
//context->setContextProperty("CallsWindow", component.create());
|
||||
}
|
||||
|
||||
// Models.
|
||||
context->setContextProperty("AccountSettingsModel", new AccountSettingsModel());
|
||||
context->setContextProperty("TimelineModel", new TimelineModel());
|
||||
|
||||
// Other.
|
||||
context->setContextProperty("CoreManager", CoreManager::getInstance());
|
||||
|
||||
m_notifier = new Notifier();
|
||||
context->setContextProperty("Notifier", m_notifier);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
// ===================================================================
|
||||
|
||||
class App : public QApplication {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
static void init (int &argc, char **argv) {
|
||||
if (!m_instance) {
|
||||
|
|
@ -28,6 +30,11 @@ public:
|
|||
return &m_engine;
|
||||
}
|
||||
|
||||
public slots:
|
||||
QString locale () const {
|
||||
return m_locale;
|
||||
}
|
||||
|
||||
private:
|
||||
App (int &argc, char **argv);
|
||||
|
||||
|
|
@ -43,6 +50,7 @@ private:
|
|||
QTranslator m_translator;
|
||||
|
||||
Notifier *m_notifier = nullptr;
|
||||
QString m_locale;
|
||||
|
||||
static App *m_instance;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -80,7 +80,11 @@ TimelineModel::TimelineModel (QObject *parent): QAbstractListModel(parent) {
|
|||
m_entries.insert(search_entry(map), map);
|
||||
else if (map["timestamp"] > (*it)["timestamp"]) {
|
||||
// Remove old entry and insert.
|
||||
it = m_entries.erase(it) - 1;
|
||||
it = m_entries.erase(it);
|
||||
|
||||
if (it != m_entries.cbegin())
|
||||
it--;
|
||||
|
||||
m_entries.insert(search_entry(map, &it), map);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import QtQuick 2.7
|
|||
|
||||
MouseArea {
|
||||
property alias text: tooltip.text
|
||||
property var toolTipParent: this
|
||||
property var tooltipParent: this
|
||||
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
|
|
@ -14,7 +14,7 @@ MouseArea {
|
|||
Tooltip {
|
||||
id: tooltip
|
||||
|
||||
parent: toolTipParent
|
||||
parent: tooltipParent
|
||||
visible: containsMouse
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,13 +97,17 @@ ColumnLayout {
|
|||
: TimelineStyle.contact.username.color.normal
|
||||
}
|
||||
|
||||
Loader {
|
||||
anchors.fill: parent
|
||||
sourceComponent: TooltipArea {
|
||||
text: $timelineEntry.timestamp.toLocaleString(
|
||||
Qt.locale(App.locale()), Locale.ShortFormat
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: containsMouse
|
||||
? Qt.PointingHandCursor
|
||||
: Qt.ArrowCursor
|
||||
hoverEnabled: true
|
||||
|
||||
onClicked: {
|
||||
view.currentIndex = index
|
||||
timeline.entrySelected(parent.contact)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue