mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-21 18:50:47 +03:00
Replace timeline with empty qml view
This commit is contained in:
parent
dc173581f1
commit
8e611abe87
8 changed files with 163 additions and 53 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,8 +1,11 @@
|
|||
build
|
||||
/build*
|
||||
tags
|
||||
cscope*
|
||||
.clang_complete
|
||||
*wintoastlib*
|
||||
/.ccls-cache
|
||||
/.exrc
|
||||
.gdb_history
|
||||
|
||||
# GTAGS
|
||||
GTAGS
|
||||
|
|
|
@ -69,7 +69,7 @@ include(LMDB)
|
|||
#
|
||||
# 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)
|
||||
|
||||
if (APPLE)
|
||||
|
@ -191,13 +191,14 @@ set(SRC_FILES
|
|||
src/emoji/Provider.cpp
|
||||
|
||||
# Timeline
|
||||
src/timeline/TimelineViewManager.cpp
|
||||
src/timeline/TimelineItem.cpp
|
||||
src/timeline/TimelineView.cpp
|
||||
src/timeline/widgets/AudioItem.cpp
|
||||
src/timeline/widgets/FileItem.cpp
|
||||
src/timeline/widgets/ImageItem.cpp
|
||||
src/timeline/widgets/VideoItem.cpp
|
||||
src/timeline2/TimelineViewManager.cpp
|
||||
#src/timeline/TimelineViewManager.cpp
|
||||
#src/timeline/TimelineItem.cpp
|
||||
#src/timeline/TimelineView.cpp
|
||||
#src/timeline/widgets/AudioItem.cpp
|
||||
#src/timeline/widgets/FileItem.cpp
|
||||
#src/timeline/widgets/ImageItem.cpp
|
||||
#src/timeline/widgets/VideoItem.cpp
|
||||
|
||||
# UI components
|
||||
src/ui/Avatar.cpp
|
||||
|
@ -333,13 +334,14 @@ qt5_wrap_cpp(MOC_HEADERS
|
|||
src/emoji/PickButton.h
|
||||
|
||||
# Timeline
|
||||
src/timeline/TimelineItem.h
|
||||
src/timeline/TimelineView.h
|
||||
src/timeline/TimelineViewManager.h
|
||||
src/timeline/widgets/AudioItem.h
|
||||
src/timeline/widgets/FileItem.h
|
||||
src/timeline/widgets/ImageItem.h
|
||||
src/timeline/widgets/VideoItem.h
|
||||
src/timeline2/TimelineViewManager.h
|
||||
#src/timeline/TimelineItem.h
|
||||
#src/timeline/TimelineView.h
|
||||
#src/timeline/TimelineViewManager.h
|
||||
#src/timeline/widgets/AudioItem.h
|
||||
#src/timeline/widgets/FileItem.h
|
||||
#src/timeline/widgets/ImageItem.h
|
||||
#src/timeline/widgets/VideoItem.h
|
||||
|
||||
# UI components
|
||||
src/ui/Avatar.h
|
||||
|
@ -405,6 +407,8 @@ set(COMMON_LIBS
|
|||
Qt5::Svg
|
||||
Qt5::Concurrent
|
||||
Qt5::Multimedia
|
||||
Qt5::Qml
|
||||
Qt5::QuickControls2
|
||||
nlohmann_json::nlohmann_json)
|
||||
|
||||
if(APPVEYOR_BUILD)
|
||||
|
|
11
resources/qml/TimelineView.qml
Normal file
11
resources/qml/TimelineView.qml
Normal 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
|
||||
}
|
||||
}
|
|
@ -114,4 +114,7 @@
|
|||
<file>styles/nheko.qss</file>
|
||||
<file>styles/nheko-dark.qss</file>
|
||||
</qresource>
|
||||
<qresource prefix="/">
|
||||
<file>qml/TimelineView.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
|
||||
#include "dialogs/ReadReceipts.h"
|
||||
#include "popups/UserMentions.h"
|
||||
#include "timeline/TimelineViewManager.h"
|
||||
#include "timeline2/TimelineViewManager.h"
|
||||
|
||||
// TODO: Needs to be updated with an actual 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);
|
||||
|
||||
contentLayout_->addWidget(top_bar_);
|
||||
contentLayout_->addWidget(view_manager_);
|
||||
contentLayout_->addWidget(view_manager_->getWidget());
|
||||
|
||||
connect(this,
|
||||
&ChatPage::removeTimelineEvent,
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "ChatPage.h"
|
||||
#include "Logging.h"
|
||||
#include "UserMentions.h"
|
||||
#include "timeline/TimelineItem.h"
|
||||
//#include "timeline/TimelineItem.h"
|
||||
|
||||
using namespace popups;
|
||||
|
||||
|
@ -116,39 +116,46 @@ UserMentions::pushItem(const QString &event_id,
|
|||
const QString &room_id,
|
||||
const QString ¤t_room_id)
|
||||
{
|
||||
setUpdatesEnabled(false);
|
||||
|
||||
// Add to the 'all' section
|
||||
TimelineItem *view_item = new TimelineItem(
|
||||
mtx::events::MessageType::Text, user_id, body, true, room_id, all_scroll_widget_);
|
||||
view_item->setEventId(event_id);
|
||||
view_item->hide();
|
||||
|
||||
all_scroll_layout_->addWidget(view_item);
|
||||
QTimer::singleShot(0, this, [view_item, this]() {
|
||||
view_item->show();
|
||||
view_item->adjustSize();
|
||||
setUpdatesEnabled(true);
|
||||
});
|
||||
|
||||
// if it matches the current room... add it to the current room as well.
|
||||
if (QString::compare(room_id, current_room_id, Qt::CaseInsensitive) == 0) {
|
||||
// Add to the 'local' section
|
||||
TimelineItem *local_view_item = new TimelineItem(mtx::events::MessageType::Text,
|
||||
user_id,
|
||||
body,
|
||||
true,
|
||||
room_id,
|
||||
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)event_id;
|
||||
(void)user_id;
|
||||
(void)body;
|
||||
(void)room_id;
|
||||
(void)current_room_id;
|
||||
// setUpdatesEnabled(false);
|
||||
//
|
||||
// // Add to the 'all' section
|
||||
// TimelineItem *view_item = new TimelineItem(
|
||||
// mtx::events::MessageType::Text, user_id, body, true, room_id,
|
||||
// all_scroll_widget_);
|
||||
// view_item->setEventId(event_id);
|
||||
// view_item->hide();
|
||||
//
|
||||
// all_scroll_layout_->addWidget(view_item);
|
||||
// QTimer::singleShot(0, this, [view_item, this]() {
|
||||
// view_item->show();
|
||||
// view_item->adjustSize();
|
||||
// setUpdatesEnabled(true);
|
||||
// });
|
||||
//
|
||||
// // if it matches the current room... add it to the current room as well.
|
||||
// if (QString::compare(room_id, current_room_id, Qt::CaseInsensitive) == 0) {
|
||||
// // Add to the 'local' section
|
||||
// TimelineItem *local_view_item = new
|
||||
// TimelineItem(mtx::events::MessageType::Text,
|
||||
// user_id,
|
||||
// body,
|
||||
// true,
|
||||
// room_id,
|
||||
// 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
|
||||
|
@ -158,4 +165,4 @@ UserMentions::paintEvent(QPaintEvent *)
|
|||
opt.init(this);
|
||||
QPainter p(this);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||
}
|
||||
}
|
||||
|
|
10
src/timeline2/TimelineViewManager.cpp
Normal file
10
src/timeline2/TimelineViewManager.cpp
Normal 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);
|
||||
}
|
72
src/timeline2/TimelineViewManager.h
Normal file
72
src/timeline2/TimelineViewManager.h
Normal 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
|
Loading…
Reference in a new issue