diff --git a/asset/img/icon.png b/asset/img/icon.png new file mode 100644 index 000000000..42e50cc4f Binary files /dev/null and b/asset/img/icon.png differ diff --git a/matrix/matriqueroom.cpp b/matrix/matriqueroom.cpp deleted file mode 100644 index 0672de244..000000000 --- a/matrix/matriqueroom.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include "matriqueroom.h" - -#include "events/roommessageevent.h" - -#include "user.h" - -using namespace QMatrixClient; - -MatriqueRoom::MatriqueRoom(Connection* connection, QString roomId, - JoinState joinState) - : Room(connection, roomId, joinState) -{ - connect(this, &MatriqueRoom::notificationCountChanged, this, &MatriqueRoom::countChanged); - connect(this, &MatriqueRoom::highlightCountChanged, this, &MatriqueRoom::countChanged); -} - -const QString& MatriqueRoom::cachedInput() const -{ - return m_cachedInput; -} - -void MatriqueRoom::setCachedInput(const QString& input) -{ - m_cachedInput = input; -} - -bool MatriqueRoom::isEventHighlighted(RoomEvent* e) const -{ - return highlights.contains(e); -} - -int MatriqueRoom::savedTopVisibleIndex() const -{ - return firstDisplayedMarker() == timelineEdge() ? 0 : - firstDisplayedMarker() - messageEvents().rbegin(); -} - -int MatriqueRoom::savedBottomVisibleIndex() const -{ - return lastDisplayedMarker() == timelineEdge() ? 0 : - lastDisplayedMarker() - messageEvents().rbegin(); -} - -void MatriqueRoom::saveViewport(int topIndex, int bottomIndex) -{ - if (bottomIndex == savedBottomVisibleIndex() && - (bottomIndex == 0 || topIndex == savedTopVisibleIndex())) - return; - if (bottomIndex == 0) - { - qDebug() << "Saving viewport as the latest available"; - setFirstDisplayedEventId({}); setLastDisplayedEventId({}); - return; - } - qDebug() << "Saving viewport:" << topIndex << "thru" << bottomIndex; - setFirstDisplayedEvent(maxTimelineIndex() - topIndex); - setLastDisplayedEvent(maxTimelineIndex() - bottomIndex); -} - -void MatriqueRoom::countChanged() -{ - if(displayed() && !hasUnreadMessages()) - { - resetNotificationCount(); - resetHighlightCount(); - } -} - -void MatriqueRoom::onAddNewTimelineEvents(timeline_iter_t from) -{ - std::for_each(from, messageEvents().cend(), - [this] (const TimelineItem& ti) { checkForHighlights(ti); }); -} - -void MatriqueRoom::onAddHistoricalTimelineEvents(rev_iter_t from) -{ - std::for_each(from, messageEvents().crend(), - [this] (const TimelineItem& ti) { checkForHighlights(ti); }); -} - -void MatriqueRoom::checkForHighlights(const QMatrixClient::TimelineItem& ti) -{ - auto localUserId = localUser()->id(); - if (ti->senderId() == localUserId) - return; - if (ti->type() == EventType::RoomMessage) - { - auto* rme = static_cast(ti.event()); - if (rme->plainBody().contains(localUserId) || - rme->plainBody().contains(roomMembername(localUserId))) - highlights.insert(ti.event()); - } -} diff --git a/matrix/matriqueroom.h b/matrix/matriqueroom.h deleted file mode 100644 index c402159d7..000000000 --- a/matrix/matriqueroom.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef MATRIQUEROOM_H -#define MATRIQUEROOM_H - -#include "room.h" - -class MatriqueRoom: public QMatrixClient::Room -{ - Q_OBJECT - public: - MatriqueRoom(QMatrixClient::Connection* connection, - QString roomId, QMatrixClient::JoinState joinState); - - const QString& cachedInput() const; - void setCachedInput(const QString& input); - - bool isEventHighlighted(QMatrixClient::RoomEvent* e) const; - - Q_INVOKABLE int savedTopVisibleIndex() const; - Q_INVOKABLE int savedBottomVisibleIndex() const; - Q_INVOKABLE void saveViewport(int topIndex, int bottomIndex); - - private slots: - void countChanged(); - - private: - QSet highlights; - QString m_cachedInput; - - void onAddNewTimelineEvents(timeline_iter_t from) override; - void onAddHistoricalTimelineEvents(rev_iter_t from) override; - - void checkForHighlights(const QMatrixClient::TimelineItem& ti); -}; - -#endif // MATRIQUEROOM_H diff --git a/qml/component/MaterialIcon.qml b/qml/component/MaterialIcon.qml new file mode 100644 index 000000000..bd8745052 --- /dev/null +++ b/qml/component/MaterialIcon.qml @@ -0,0 +1,20 @@ +import QtQuick 2.10 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.3 + +Item { + property alias icon: iconText.text + property var color: "white" + + id: item + + Text { + id: iconText + anchors.fill: parent + font.pointSize: 16 + font.family: materialFont.name + color: item.color + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } +}