diff --git a/callwidget.cpp b/callwidget.cpp
index be76d4fa0857ec437c1da69b9dc671d25a9c155d..516354a146c2ab31d776a72548b4ccf99884e325 100644
--- a/callwidget.cpp
+++ b/callwidget.cpp
@@ -58,8 +58,6 @@ CallWidget::CallWidget(QWidget* parent) :
menu_(new QMenu()),
imDelegate_(new ImDelegate())
{
- setMouseTracking(true);
-
ui->setupUi(this);
welcomePageAnim_ = new QPropertyAnimation(ui->welcomePage, "pos", this);
@@ -160,6 +158,8 @@ CallWidget::CallWidget(QWidget* parent) :
setupOutOfCallIM();
setupSmartListMenu();
+ connect(ui->smartList, &SmartList::btnVideoClicked, this, &CallWidget::on_btnvideo_clicked);
+
} catch (const std::exception& e) {
qDebug() << "INIT ERROR" << e.what();
}
@@ -473,6 +473,9 @@ CallWidget::on_cancelButton_clicked()
void
CallWidget::on_smartList_doubleClicked(const QModelIndex& index)
{
+ ui->smartList->reset();
+ ui->smartList->setCurrentIndex(index);
+
auto realIndex = RecentModel::instance().peopleProxy()->mapToSource(index);
if (RecentModel::instance().hasActiveCall(realIndex))
return;
diff --git a/combar.cpp b/combar.cpp
index d21c145478b5c417478016d1e61ae503b86c34ce..23bf47e9c1ba0af5895aa696121fb007fbb59434 100644
--- a/combar.cpp
+++ b/combar.cpp
@@ -16,24 +16,24 @@
* along with this program. If not, see . *
**************************************************************************/
-#include "combar.h"
#include "ui_combar.h"
+#include "combar.h"
+
+
ComBar::ComBar(QWidget* parent) :
QWidget(parent),
ui(new Ui::ComBar)
{
ui->setupUi(this);
+ connect(ui->btnvideo, &QPushButton::clicked , this , [=](){
+ emit btnVideoClicked();
+ });
+
}
ComBar::~ComBar()
{
+ disconnect(this);
delete ui;
}
-
-void
-ComBar::moveToRow(const QRect& rect)
-{
- move(rect.right() - width() - 5,
- rect.bottom() - height() - (rect.height()/4));
-}
diff --git a/combar.h b/combar.h
index 3465c940cdcd98dc92ccc2a11e9312fa8adba8d5..dd9a706ce1670ce4b248ae191727574e8137a311 100644
--- a/combar.h
+++ b/combar.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2015-2016 by Savoir-faire Linux *
+ * Copyright (C) 2015-2016 by Savoir-faire Linux *
* Author: Jäger Nicolas *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -31,9 +31,10 @@ public:
explicit ComBar(QWidget* parent = 0);
~ComBar();
-public slots:
- void moveToRow(const QRect& rect);
-
private:
Ui::ComBar* ui;
+
+signals:
+ void btnVideoClicked() const;
+
};
diff --git a/combar.ui b/combar.ui
index e8f7e49cb3515487bc2a52e21a508ba5c7c5e64d..7e8f2b14b15fc85f7312111516087e0a68a675a6 100644
--- a/combar.ui
+++ b/combar.ui
@@ -6,8 +6,8 @@
0
0
- 30
- 30
+ 578
+ 112
@@ -30,11 +30,24 @@
0
- 0
+ 5
0
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
-
@@ -55,6 +68,9 @@
30
+
+ true
+
diff --git a/smartlist.cpp b/smartlist.cpp
index 36230aee637c53631f810d9b317723c32ee0207a..fef1b1cbd1f0812120d42ab4b0efe1b5c6c4e5fe 100644
--- a/smartlist.cpp
+++ b/smartlist.cpp
@@ -17,7 +17,7 @@
**************************************************************************/
#include
-#include
+#include
#include
#include
@@ -26,15 +26,29 @@
#include "smartlist.h"
SmartList::SmartList(QWidget *parent) :
- QTreeView(parent),
- comBar_(new ComBar(this))
+ QTreeView(parent)
{
+
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()
{
- delete comBar_;
+
}
void
@@ -42,8 +56,6 @@ SmartList::enterEvent(QEvent* event)
{
Q_UNUSED(event);
verticalScrollBar()->show();
-
- repaint(0, 0, width(), height());
}
void
@@ -51,71 +63,40 @@ SmartList::leaveEvent(QEvent* event)
{
Q_UNUSED(event);
- smartListDelegate_->setRowHighlighted(-1);
-
- currentRow_ = -1;
-
- if (smartListDelegate_)
- smartListDelegate_->setRowHighlighted(currentRow_);
-
verticalScrollBar()->hide();
- comBar_->hide();
+ removeCombar();
}
void
-SmartList::wheelEvent(QWheelEvent* event)
-{
- currentRow_ = -1;
-
- comBar_->hide();
-
- smartListDelegate_->setRowHighlighted(currentRow_);
-
- repaint(0, 0, width(), height());
-
- QTreeView::wheelEvent(event);
-}
-
-void
-SmartList::paintEvent(QPaintEvent* event)
+SmartList::setSmartListItemDelegate(SmartListDelegate* delegate)
{
- QTreeView::paintEvent(event);
-
- if (currentRow_ > -1)
- comBar_->show();
- else
- comBar_->hide();
+ if (delegate)
+ {
+ setItemDelegate(delegate);
+ smartListDelegate_ = delegate;
+ }
}
-void
-SmartList::mouseMoveEvent(QMouseEvent* event)
+bool
+SmartList::eventFilter(QObject* watched, QEvent* event)
{
- QModelIndex index = indexAt(event->pos());
-
- repaint(0, 0, width(), height());
- currentRow_ = index.row();
-
- if (smartListDelegate_)
- {
- smartListDelegate_->setRowHighlighted(currentRow_);
-
- if (currentRow_ > -1)
- comBar_->show();
- else
- comBar_->hide();
+ if (qobject_cast(watched) && event->type() == QEvent::Enter) {
+ removeCombar();
+ return true;
}
- QTreeView::mouseMoveEvent(event);
+
+ return QObject::eventFilter(watched, event);
}
void
-SmartList::setSmartListItemDelegate(SmartListDelegate* delegate)
+SmartList::removeCombar()
{
- if (delegate)
- {
- setItemDelegate(delegate);
- smartListDelegate_ = delegate;
- connect(smartListDelegate_ , &SmartListDelegate::rowSelected , comBar_, &ComBar::moveToRow);
+ if(not hoveredRow_.isValid())
+ return;
+
+ if (auto widget = indexWidget(hoveredRow_)) {
+ widget->setVisible(false);
}
}
diff --git a/smartlist.h b/smartlist.h
index d2f587cbcda143183036319c518d6e2fc2e79e0e..3394d2d276d470b0618afbc3a7dc01f3942129be 100644
--- a/smartlist.h
+++ b/smartlist.h
@@ -21,7 +21,6 @@
#include
class SmartListDelegate;
-class ComBar;
class SmartList : public QTreeView
{
@@ -34,13 +33,13 @@ public:
protected:
void enterEvent(QEvent* event);
void leaveEvent(QEvent* event);
- void mouseMoveEvent(QMouseEvent* event);
- void wheelEvent(QWheelEvent* event);
- void paintEvent(QPaintEvent* event);
+ bool eventFilter(QObject* watched, QEvent* event);
private:
- int currentRow_ = -1;
- SmartListDelegate* smartListDelegate_;
- ComBar* comBar_;
+ SmartListDelegate* smartListDelegate_;
+ QPersistentModelIndex hoveredRow_;
+ void removeCombar();
+signals:
+ void btnVideoClicked() const;
};