Commit 6a419d8c authored by Nicolas Jager's avatar Nicolas Jager

ui: fixes for combar and smartlist

- the background under item hovered is now correct.

- using wheel mouse over the smartlist is fixed.

- the combar has the good behaviour when using the scrollbar of the smartlist

Change-Id: I5086f585aba4bb127783e19ff4307cff5eff7918
Tuleap: #286
Tuleap: #288
Tuleap: #289
parent 389a2296
...@@ -58,8 +58,6 @@ CallWidget::CallWidget(QWidget* parent) : ...@@ -58,8 +58,6 @@ CallWidget::CallWidget(QWidget* parent) :
menu_(new QMenu()), menu_(new QMenu()),
imDelegate_(new ImDelegate()) imDelegate_(new ImDelegate())
{ {
setMouseTracking(true);
ui->setupUi(this); ui->setupUi(this);
welcomePageAnim_ = new QPropertyAnimation(ui->welcomePage, "pos", this); welcomePageAnim_ = new QPropertyAnimation(ui->welcomePage, "pos", this);
...@@ -160,6 +158,8 @@ CallWidget::CallWidget(QWidget* parent) : ...@@ -160,6 +158,8 @@ CallWidget::CallWidget(QWidget* parent) :
setupOutOfCallIM(); setupOutOfCallIM();
setupSmartListMenu(); setupSmartListMenu();
connect(ui->smartList, &SmartList::btnVideoClicked, this, &CallWidget::on_btnvideo_clicked);
} catch (const std::exception& e) { } catch (const std::exception& e) {
qDebug() << "INIT ERROR" << e.what(); qDebug() << "INIT ERROR" << e.what();
} }
...@@ -473,6 +473,9 @@ CallWidget::on_cancelButton_clicked() ...@@ -473,6 +473,9 @@ CallWidget::on_cancelButton_clicked()
void void
CallWidget::on_smartList_doubleClicked(const QModelIndex& index) CallWidget::on_smartList_doubleClicked(const QModelIndex& index)
{ {
ui->smartList->reset();
ui->smartList->setCurrentIndex(index);
auto realIndex = RecentModel::instance().peopleProxy()->mapToSource(index); auto realIndex = RecentModel::instance().peopleProxy()->mapToSource(index);
if (RecentModel::instance().hasActiveCall(realIndex)) if (RecentModel::instance().hasActiveCall(realIndex))
return; return;
......
...@@ -16,24 +16,24 @@ ...@@ -16,24 +16,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * * along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/ **************************************************************************/
#include "combar.h"
#include "ui_combar.h" #include "ui_combar.h"
#include "combar.h"
ComBar::ComBar(QWidget* parent) : ComBar::ComBar(QWidget* parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::ComBar) ui(new Ui::ComBar)
{ {
ui->setupUi(this); ui->setupUi(this);
connect(ui->btnvideo, &QPushButton::clicked , this , [=](){
emit btnVideoClicked();
});
} }
ComBar::~ComBar() ComBar::~ComBar()
{ {
disconnect(this);
delete ui; delete ui;
} }
void
ComBar::moveToRow(const QRect& rect)
{
move(rect.right() - width() - 5,
rect.bottom() - height() - (rect.height()/4));
}
/*************************************************************************** /***************************************************************************
* Copyright (C) 2015-2016 by Savoir-faire Linux * * Copyright (C) 2015-2016 by Savoir-faire Linux *
* Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> * * Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
...@@ -31,9 +31,10 @@ public: ...@@ -31,9 +31,10 @@ public:
explicit ComBar(QWidget* parent = 0); explicit ComBar(QWidget* parent = 0);
~ComBar(); ~ComBar();
public slots:
void moveToRow(const QRect& rect);
private: private:
Ui::ComBar* ui; Ui::ComBar* ui;
signals:
void btnVideoClicked() const;
}; };
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>30</width> <width>578</width>
<height>30</height> <height>112</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
...@@ -30,11 +30,24 @@ ...@@ -30,11 +30,24 @@
<number>0</number> <number>0</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>5</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QPushButton" name="btnvideo"> <widget class="QPushButton" name="btnvideo">
<property name="sizePolicy"> <property name="sizePolicy">
...@@ -55,6 +68,9 @@ ...@@ -55,6 +68,9 @@
<height>30</height> <height>30</height>
</size> </size>
</property> </property>
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
**************************************************************************/ **************************************************************************/
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
#include <qevent.h> #include <QEvent>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <QScrollBar> #include <QScrollBar>
...@@ -26,15 +26,29 @@ ...@@ -26,15 +26,29 @@
#include "smartlist.h" #include "smartlist.h"
SmartList::SmartList(QWidget *parent) : SmartList::SmartList(QWidget *parent) :
QTreeView(parent), QTreeView(parent)
comBar_(new ComBar(this))
{ {
verticalScrollBar()->hide(); verticalScrollBar()->hide();
connect(this, &QAbstractItemView::entered, [this](const QModelIndex & index) {
removeCombar();
if (auto widget = indexWidget(index)) {
widget->setVisible(true);
} else {
ComBar* bar = new ComBar();
setIndexWidget(index, bar);
connect(bar, &ComBar::btnVideoClicked, this, [=](){ emit btnVideoClicked(); });
}
hoveredRow_ = index;
});
setVerticalScrollMode(ScrollPerPixel);
} }
SmartList::~SmartList() SmartList::~SmartList()
{ {
delete comBar_;
} }
void void
...@@ -42,8 +56,6 @@ SmartList::enterEvent(QEvent* event) ...@@ -42,8 +56,6 @@ SmartList::enterEvent(QEvent* event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
verticalScrollBar()->show(); verticalScrollBar()->show();
repaint(0, 0, width(), height());
} }
void void
...@@ -51,71 +63,40 @@ SmartList::leaveEvent(QEvent* event) ...@@ -51,71 +63,40 @@ SmartList::leaveEvent(QEvent* event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
smartListDelegate_->setRowHighlighted(-1);
currentRow_ = -1;
if (smartListDelegate_)
smartListDelegate_->setRowHighlighted(currentRow_);
verticalScrollBar()->hide(); verticalScrollBar()->hide();
comBar_->hide(); removeCombar();
} }
void void
SmartList::wheelEvent(QWheelEvent* event) SmartList::setSmartListItemDelegate(SmartListDelegate* delegate)
{
currentRow_ = -1;
comBar_->hide();
smartListDelegate_->setRowHighlighted(currentRow_);
repaint(0, 0, width(), height());
QTreeView::wheelEvent(event);
}
void
SmartList::paintEvent(QPaintEvent* event)
{ {
QTreeView::paintEvent(event); if (delegate)
{
if (currentRow_ > -1) setItemDelegate(delegate);
comBar_->show(); smartListDelegate_ = delegate;
else }
comBar_->hide();
} }
void bool
SmartList::mouseMoveEvent(QMouseEvent* event) SmartList::eventFilter(QObject* watched, QEvent* event)
{ {
QModelIndex index = indexAt(event->pos());
repaint(0, 0, width(), height());
currentRow_ = index.row(); if (qobject_cast<QScrollBar*>(watched) && event->type() == QEvent::Enter) {
removeCombar();
if (smartListDelegate_) return true;
{
smartListDelegate_->setRowHighlighted(currentRow_);
if (currentRow_ > -1)
comBar_->show();
else
comBar_->hide();
} }
QTreeView::mouseMoveEvent(event);
return QObject::eventFilter(watched, event);
} }
void void
SmartList::setSmartListItemDelegate(SmartListDelegate* delegate) SmartList::removeCombar()
{ {
if (delegate) if(not hoveredRow_.isValid())
{ return;
setItemDelegate(delegate);
smartListDelegate_ = delegate; if (auto widget = indexWidget(hoveredRow_)) {
connect(smartListDelegate_ , &SmartListDelegate::rowSelected , comBar_, &ComBar::moveToRow); widget->setVisible(false);
} }
} }
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include <QTreeView> #include <QTreeView>
class SmartListDelegate; class SmartListDelegate;
class ComBar;
class SmartList : public QTreeView class SmartList : public QTreeView
{ {
...@@ -34,13 +33,13 @@ public: ...@@ -34,13 +33,13 @@ public:
protected: protected:
void enterEvent(QEvent* event); void enterEvent(QEvent* event);
void leaveEvent(QEvent* event); void leaveEvent(QEvent* event);
void mouseMoveEvent(QMouseEvent* event); bool eventFilter(QObject* watched, QEvent* event);
void wheelEvent(QWheelEvent* event);
void paintEvent(QPaintEvent* event);
private: private:
int currentRow_ = -1; SmartListDelegate* smartListDelegate_;
SmartListDelegate* smartListDelegate_; QPersistentModelIndex hoveredRow_;
ComBar* comBar_; void removeCombar();
signals:
void btnVideoClicked() const;
}; };
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment