Replace timeline with empty qml view

This commit is contained in:
Nicolas Werner 2019-08-30 19:29:25 +02:00
parent dc173581f1
commit 8e611abe87
8 changed files with 163 additions and 53 deletions

5
.gitignore vendored
View file

@ -1,8 +1,11 @@
build /build*
tags tags
cscope* cscope*
.clang_complete .clang_complete
*wintoastlib* *wintoastlib*
/.ccls-cache
/.exrc
.gdb_history
# GTAGS # GTAGS
GTAGS GTAGS

View file

@ -69,7 +69,7 @@ include(LMDB)
# #
# Discover Qt dependencies. # Discover Qt dependencies.
# #
find_package(Qt5 COMPONENTS Core Widgets LinguistTools Concurrent Svg Multimedia REQUIRED) find_package(Qt5 COMPONENTS Core Widgets LinguistTools Concurrent Svg Multimedia Qml QuickControls2 REQUIRED)
find_package(Qt5DBus) find_package(Qt5DBus)
if (APPLE) if (APPLE)
@ -191,13 +191,14 @@ set(SRC_FILES
src/emoji/Provider.cpp src/emoji/Provider.cpp
# Timeline # Timeline
src/timeline/TimelineViewManager.cpp src/timeline2/TimelineViewManager.cpp
src/timeline/TimelineItem.cpp #src/timeline/TimelineViewManager.cpp
src/timeline/TimelineView.cpp #src/timeline/TimelineItem.cpp
src/timeline/widgets/AudioItem.cpp #src/timeline/TimelineView.cpp
src/timeline/widgets/FileItem.cpp #src/timeline/widgets/AudioItem.cpp
src/timeline/widgets/ImageItem.cpp #src/timeline/widgets/FileItem.cpp
src/timeline/widgets/VideoItem.cpp #src/timeline/widgets/ImageItem.cpp
#src/timeline/widgets/VideoItem.cpp
# UI components # UI components
src/ui/Avatar.cpp src/ui/Avatar.cpp
@ -333,13 +334,14 @@ qt5_wrap_cpp(MOC_HEADERS
src/emoji/PickButton.h src/emoji/PickButton.h
# Timeline # Timeline
src/timeline/TimelineItem.h src/timeline2/TimelineViewManager.h
src/timeline/TimelineView.h #src/timeline/TimelineItem.h
src/timeline/TimelineViewManager.h #src/timeline/TimelineView.h
src/timeline/widgets/AudioItem.h #src/timeline/TimelineViewManager.h
src/timeline/widgets/FileItem.h #src/timeline/widgets/AudioItem.h
src/timeline/widgets/ImageItem.h #src/timeline/widgets/FileItem.h
src/timeline/widgets/VideoItem.h #src/timeline/widgets/ImageItem.h
#src/timeline/widgets/VideoItem.h
# UI components # UI components
src/ui/Avatar.h src/ui/Avatar.h
@ -405,6 +407,8 @@ set(COMMON_LIBS
Qt5::Svg Qt5::Svg
Qt5::Concurrent Qt5::Concurrent
Qt5::Multimedia Qt5::Multimedia
Qt5::Qml
Qt5::QuickControls2
nlohmann_json::nlohmann_json) nlohmann_json::nlohmann_json)
if(APPVEYOR_BUILD) if(APPVEYOR_BUILD)

View file

@ -0,0 +1,11 @@
import QtQuick 2.1
Rectangle {
anchors.fill: parent
Text {
anchors.centerIn: parent
text: qsTr("No room open")
font.pointSize: 24
}
}

View file

@ -114,4 +114,7 @@
<file>styles/nheko.qss</file> <file>styles/nheko.qss</file>
<file>styles/nheko-dark.qss</file> <file>styles/nheko-dark.qss</file>
</qresource> </qresource>
<qresource prefix="/">
<file>qml/TimelineView.qml</file>
</qresource>
</RCC> </RCC>

View file

@ -44,7 +44,7 @@
#include "dialogs/ReadReceipts.h" #include "dialogs/ReadReceipts.h"
#include "popups/UserMentions.h" #include "popups/UserMentions.h"
#include "timeline/TimelineViewManager.h" #include "timeline2/TimelineViewManager.h"
// TODO: Needs to be updated with an actual secret. // TODO: Needs to be updated with an actual secret.
static const std::string STORAGE_SECRET_KEY("secret"); static const std::string STORAGE_SECRET_KEY("secret");
@ -113,7 +113,7 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
view_manager_ = new TimelineViewManager(this); view_manager_ = new TimelineViewManager(this);
contentLayout_->addWidget(top_bar_); contentLayout_->addWidget(top_bar_);
contentLayout_->addWidget(view_manager_); contentLayout_->addWidget(view_manager_->getWidget());
connect(this, connect(this,
&ChatPage::removeTimelineEvent, &ChatPage::removeTimelineEvent,

View file

@ -7,7 +7,7 @@
#include "ChatPage.h" #include "ChatPage.h"
#include "Logging.h" #include "Logging.h"
#include "UserMentions.h" #include "UserMentions.h"
#include "timeline/TimelineItem.h" //#include "timeline/TimelineItem.h"
using namespace popups; using namespace popups;
@ -116,39 +116,46 @@ UserMentions::pushItem(const QString &event_id,
const QString &room_id, const QString &room_id,
const QString &current_room_id) const QString &current_room_id)
{ {
setUpdatesEnabled(false); (void)event_id;
(void)user_id;
// Add to the 'all' section (void)body;
TimelineItem *view_item = new TimelineItem( (void)room_id;
mtx::events::MessageType::Text, user_id, body, true, room_id, all_scroll_widget_); (void)current_room_id;
view_item->setEventId(event_id); // setUpdatesEnabled(false);
view_item->hide(); //
// // Add to the 'all' section
all_scroll_layout_->addWidget(view_item); // TimelineItem *view_item = new TimelineItem(
QTimer::singleShot(0, this, [view_item, this]() { // mtx::events::MessageType::Text, user_id, body, true, room_id,
view_item->show(); // all_scroll_widget_);
view_item->adjustSize(); // view_item->setEventId(event_id);
setUpdatesEnabled(true); // view_item->hide();
}); //
// all_scroll_layout_->addWidget(view_item);
// if it matches the current room... add it to the current room as well. // QTimer::singleShot(0, this, [view_item, this]() {
if (QString::compare(room_id, current_room_id, Qt::CaseInsensitive) == 0) { // view_item->show();
// Add to the 'local' section // view_item->adjustSize();
TimelineItem *local_view_item = new TimelineItem(mtx::events::MessageType::Text, // setUpdatesEnabled(true);
user_id, // });
body, //
true, // // if it matches the current room... add it to the current room as well.
room_id, // if (QString::compare(room_id, current_room_id, Qt::CaseInsensitive) == 0) {
local_scroll_widget_); // // Add to the 'local' section
local_view_item->setEventId(event_id); // TimelineItem *local_view_item = new
local_view_item->hide(); // TimelineItem(mtx::events::MessageType::Text,
local_scroll_layout_->addWidget(local_view_item); // user_id,
// body,
QTimer::singleShot(0, this, [local_view_item]() { // true,
local_view_item->show(); // room_id,
local_view_item->adjustSize(); // local_scroll_widget_);
}); // local_view_item->setEventId(event_id);
} // local_view_item->hide();
// local_scroll_layout_->addWidget(local_view_item);
//
// QTimer::singleShot(0, this, [local_view_item]() {
// local_view_item->show();
// local_view_item->adjustSize();
// });
// }
} }
void void

View file

@ -0,0 +1,10 @@
#include "TimelineViewManager.h"
TimelineViewManager::TimelineViewManager(QWidget *parent)
{
view = new QQuickView();
container = QWidget::createWindowContainer(view, parent);
container->setMinimumSize(200, 200);
view->setSource(QUrl("qrc:///qml/TimelineView.qml"));
// view->rootContext()->setContextProperty(room);
}

View file

@ -0,0 +1,72 @@
#pragma once
#include <QQuickView>
#include <QWidget>
#include <mtx/responses.hpp>
#include "Cache.h"
#include "Utils.h"
// temporary for stubs
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
class TimelineViewManager : public QObject
{
Q_OBJECT
public:
TimelineViewManager(QWidget *parent = 0);
QWidget *getWidget() const { return container; }
void initialize(const mtx::responses::Rooms &rooms) {}
void addRoom(const QString &room_id) {}
void sync(const mtx::responses::Rooms &rooms) {}
void clearAll() {}
signals:
void clearRoomMessageCount(QString roomid);
void updateRoomsLastMessage(const QString &user, const DescInfo &info);
public slots:
void updateReadReceipts(const QString &room_id, const std::vector<QString> &event_ids) {}
void removeTimelineEvent(const QString &room_id, const QString &event_id) {}
void initWithMessages(const std::map<QString, mtx::responses::Timeline> &msgs) {}
void setHistoryView(const QString &room_id) {}
void queueTextMessage(const QString &msg) {}
void queueReplyMessage(const QString &reply, const RelatedInfo &related) {}
void queueEmoteMessage(const QString &msg) {}
void queueImageMessage(const QString &roomid,
const QString &filename,
const QString &url,
const QString &mime,
uint64_t dsize,
const QSize &dimensions)
{}
void queueFileMessage(const QString &roomid,
const QString &filename,
const QString &url,
const QString &mime,
uint64_t dsize)
{}
void queueAudioMessage(const QString &roomid,
const QString &filename,
const QString &url,
const QString &mime,
uint64_t dsize)
{}
void queueVideoMessage(const QString &roomid,
const QString &filename,
const QString &url,
const QString &mime,
uint64_t dsize)
{}
private:
QQuickView *view;
QWidget *container;
};
#pragma GCC diagnostic pop