Remove RoomList UI form

This commit is contained in:
Konstantinos Sideris 2017-05-19 17:23:36 +03:00
parent f2ff4772a7
commit 30fce32161
4 changed files with 37 additions and 180 deletions

View File

@ -149,10 +149,7 @@ include_directories(include/ui)
include_directories(include/events)
include_directories(include/events/messages)
qt5_wrap_ui (UI_HEADERS
forms/ChatPage.ui
forms/RoomList.ui
)
qt5_wrap_ui (UI_HEADERS forms/ChatPage.ui)
qt5_wrap_cpp(MOC_HEADERS
include/ChatPage.h

View File

@ -1,157 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RoomList</class>
<widget class="QWidget" name="RoomList">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>423</width>
<height>500</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>500</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">QWidget {
background-color: #f8fbfe;
color: #ebebeb;
}
QScrollBar:vertical {
background-color: #f8fbfe;
width: 8px;
border-radius: 20px;
margin: 0px 2px 0 2px;
}
QScrollBar::handle:vertical {
border-radius: 50px;
background-color: #d6dde3;
}
QScrollBar::add-line:vertical {
border: none;
background: none;
}
QScrollBar::sub-line:vertical {
border: none;
background: none;
}</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>419</width>
<height>496</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="scrollVerticalLayout">
<property name="spacing">
<number>0</number>
</property>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -17,9 +17,9 @@
#pragma once
#include <QImage>
#include <QScrollArea>
#include <QSharedPointer>
#include <QUrl>
#include <QVBoxLayout>
#include <QWidget>
#include "MatrixClient.h"
@ -27,11 +27,6 @@
#include "RoomState.h"
#include "Sync.h"
namespace Ui
{
class RoomList;
}
class RoomList : public QWidget
{
Q_OBJECT
@ -57,7 +52,10 @@ public slots:
private:
void calculateUnreadMessageCount();
Ui::RoomList *ui;
QVBoxLayout *topLayout_;
QVBoxLayout *contentsLayout_;
QScrollArea *scrollArea_;
QWidget *scrollAreaContents_;
QMap<QString, QSharedPointer<RoomInfoListItem>> rooms_;

View File

@ -15,11 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ui_RoomList.h"
#include <QDebug>
#include <QJsonArray>
#include <QLabel>
#include <QRegularExpression>
#include "RoomInfoListItem.h"
@ -28,16 +25,39 @@
RoomList::RoomList(QSharedPointer<MatrixClient> client, QWidget *parent)
: QWidget(parent)
, ui(new Ui::RoomList)
, client_(client)
{
ui->setupUi(this);
ui->scrollVerticalLayout->addStretch(1);
setStyleSheet(
"QWidget { border: none; }"
"QScrollBar:vertical { width: 4px; margin: 2px 0; }");
QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
setSizePolicy(sizePolicy);
setMinimumSize(QSize(0, 500));
topLayout_ = new QVBoxLayout(this);
topLayout_->setSpacing(0);
topLayout_->setMargin(0);
scrollArea_ = new QScrollArea(this);
scrollArea_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollArea_->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
scrollArea_->setWidgetResizable(true);
scrollArea_->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignVCenter);
scrollAreaContents_ = new QWidget();
contentsLayout_ = new QVBoxLayout(scrollAreaContents_);
contentsLayout_->setSpacing(0);
contentsLayout_->setMargin(0);
contentsLayout_->addStretch(1);
scrollArea_->setWidget(scrollAreaContents_);
topLayout_->addWidget(scrollArea_);
connect(client_.data(),
SIGNAL(roomAvatarRetrieved(const QString &, const QPixmap &)),
this,
@ -46,7 +66,6 @@ RoomList::RoomList(QSharedPointer<MatrixClient> client, QWidget *parent)
RoomList::~RoomList()
{
delete ui;
}
void RoomList::clear()
@ -87,13 +106,13 @@ void RoomList::setInitialRooms(const QMap<QString, RoomState> &states)
if (!state.avatar.content().url().toString().isEmpty())
client_->fetchRoomAvatar(room_id, state.avatar.content().url());
RoomInfoListItem *room_item = new RoomInfoListItem(state, room_id, ui->scrollArea);
RoomInfoListItem *room_item = new RoomInfoListItem(state, room_id, scrollArea_);
connect(room_item, &RoomInfoListItem::clicked, this, &RoomList::highlightSelectedRoom);
rooms_.insert(room_id, QSharedPointer<RoomInfoListItem>(room_item));
int pos = ui->scrollVerticalLayout->count() - 1;
ui->scrollVerticalLayout->insertWidget(pos, room_item);
int pos = contentsLayout_->count() - 1;
contentsLayout_->insertWidget(pos, room_item);
}
if (rooms_.isEmpty())