Commit 978cc65a authored by Edric Milaret's avatar Edric Milaret

Revert "ui: fixes for combar and smartlist"

This reverts commit 6a419d8c.

Change-Id: I9a0229428181e576bde1063dc9f1cec294fde815
parent 6a419d8c
...@@ -58,6 +58,8 @@ CallWidget::CallWidget(QWidget* parent) : ...@@ -58,6 +58,8 @@ 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);
...@@ -158,8 +160,6 @@ CallWidget::CallWidget(QWidget* parent) : ...@@ -158,8 +160,6 @@ 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,9 +473,6 @@ CallWidget::on_cancelButton_clicked() ...@@ -473,9 +473,6 @@ 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 "ui_combar.h"
#include "combar.h" #include "combar.h"
#include "ui_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,10 +31,9 @@ public: ...@@ -31,10 +31,9 @@ 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>578</width> <width>30</width>
<height>112</height> <height>30</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
...@@ -30,24 +30,11 @@ ...@@ -30,24 +30,11 @@
<number>0</number> <number>0</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>5</number> <number>0</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">
...@@ -68,9 +55,6 @@ ...@@ -68,9 +55,6 @@
<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> #include <qevent.h>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <QScrollBar> #include <QScrollBar>
...@@ -26,29 +26,15 @@ ...@@ -26,29 +26,15 @@
#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
...@@ -56,6 +42,8 @@ SmartList::enterEvent(QEvent* event) ...@@ -56,6 +42,8 @@ SmartList::enterEvent(QEvent* event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
verticalScrollBar()->show(); verticalScrollBar()->show();
repaint(0, 0, width(), height());
} }
void void
...@@ -63,40 +51,71 @@ SmartList::leaveEvent(QEvent* event) ...@@ -63,40 +51,71 @@ SmartList::leaveEvent(QEvent* event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
smartListDelegate_->setRowHighlighted(-1);
currentRow_ = -1;
if (smartListDelegate_)
smartListDelegate_->setRowHighlighted(currentRow_);
verticalScrollBar()->hide(); verticalScrollBar()->hide();
removeCombar(); comBar_->hide();
} }
void void
SmartList::setSmartListItemDelegate(SmartListDelegate* delegate) SmartList::wheelEvent(QWheelEvent* event)
{ {
if (delegate) currentRow_ = -1;
{
setItemDelegate(delegate); comBar_->hide();
smartListDelegate_ = delegate;
} smartListDelegate_->setRowHighlighted(currentRow_);
repaint(0, 0, width(), height());
QTreeView::wheelEvent(event);
} }
bool void
SmartList::eventFilter(QObject* watched, QEvent* event) SmartList::paintEvent(QPaintEvent* event)
{ {
QTreeView::paintEvent(event);
if (qobject_cast<QScrollBar*>(watched) && event->type() == QEvent::Enter) { if (currentRow_ > -1)
removeCombar(); comBar_->show();
return true; else
} comBar_->hide();
return QObject::eventFilter(watched, event);
} }
void void
SmartList::removeCombar() SmartList::mouseMoveEvent(QMouseEvent* event)
{ {
if(not hoveredRow_.isValid()) QModelIndex index = indexAt(event->pos());
return;
repaint(0, 0, width(), height());
currentRow_ = index.row();
if (auto widget = indexWidget(hoveredRow_)) { if (smartListDelegate_)
widget->setVisible(false); {
smartListDelegate_->setRowHighlighted(currentRow_);
if (currentRow_ > -1)
comBar_->show();
else
comBar_->hide();
}
QTreeView::mouseMoveEvent(event);
}
void
SmartList::setSmartListItemDelegate(SmartListDelegate* delegate)
{
if (delegate)
{
setItemDelegate(delegate);
smartListDelegate_ = delegate;
connect(smartListDelegate_ , &SmartListDelegate::rowSelected , comBar_, &ComBar::moveToRow);
} }
} }
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <QTreeView> #include <QTreeView>
class SmartListDelegate; class SmartListDelegate;
class ComBar;
class SmartList : public QTreeView class SmartList : public QTreeView
{ {
...@@ -33,13 +34,13 @@ public: ...@@ -33,13 +34,13 @@ public:
protected: protected:
void enterEvent(QEvent* event); void enterEvent(QEvent* event);
void leaveEvent(QEvent* event); void leaveEvent(QEvent* event);
bool eventFilter(QObject* watched, QEvent* event); void mouseMoveEvent(QMouseEvent* event);
void wheelEvent(QWheelEvent* event);
void paintEvent(QPaintEvent* event);
private: private:
SmartListDelegate* smartListDelegate_; int currentRow_ = -1;
QPersistentModelIndex hoveredRow_; SmartListDelegate* smartListDelegate_;
void removeCombar(); ComBar* comBar_;
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