summary refs log tree commit diff
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2017-05-19 17:23:36 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-05-19 17:23:36 +0300
commit30fce321613b234934512dd06a7ef8f4b0929d7b (patch)
tree1e57c4612cb860f0f6d2d164033cccf2171fb630
parentReverse colors on selection for the unread message bubble (diff)
downloadnheko-30fce321613b234934512dd06a7ef8f4b0929d7b.tar.xz
Remove RoomList UI form
-rw-r--r--CMakeLists.txt5
-rw-r--r--forms/RoomList.ui157
-rw-r--r--include/RoomList.h14
-rw-r--r--src/RoomList.cc41
4 files changed, 37 insertions, 180 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt

index e2337fed..e45c3560 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -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 diff --git a/forms/RoomList.ui b/forms/RoomList.ui deleted file mode 100644
index b56a75ab..00000000 --- a/forms/RoomList.ui +++ /dev/null
@@ -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> diff --git a/include/RoomList.h b/include/RoomList.h
index 34067430..489083d1 100644 --- a/include/RoomList.h +++ b/include/RoomList.h
@@ -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_; diff --git a/src/RoomList.cc b/src/RoomList.cc
index 58053bbd..c3fe16a2 100644 --- a/src/RoomList.cc +++ b/src/RoomList.cc
@@ -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())