fix popup window mouse area event error

Change-Id: I9892864ebeaa5a5b5180511567ab0f95b34690aa
This commit is contained in:
石博文 2016-07-19 15:08:16 +08:00 committed by Hualet Wang
parent 6cd10fa3cf
commit a916bf5af9
4 changed files with 36 additions and 8 deletions

View File

@ -17,6 +17,10 @@ DockPopupWindow::DockPopupWindow(QWidget *parent)
connect(m_mouseInter, &DBusXMouseArea::ButtonRelease, this, &DockPopupWindow::globalMouseRelease); connect(m_mouseInter, &DBusXMouseArea::ButtonRelease, this, &DockPopupWindow::globalMouseRelease);
} }
DockPopupWindow::~DockPopupWindow()
{
}
bool DockPopupWindow::model() const bool DockPopupWindow::model() const
{ {
return m_model; return m_model;
@ -28,22 +32,38 @@ void DockPopupWindow::show(const QPoint &pos, const bool model)
DArrowRectangle::show(pos.x(), pos.y()); DArrowRectangle::show(pos.x(), pos.y());
if (model) if (!model && !m_mouseAreaKey.isEmpty())
{
m_mouseInter->UnregisterArea(m_mouseAreaKey);
m_mouseAreaKey.clear();
}
if (model && m_mouseAreaKey.isEmpty())
m_mouseAreaKey = m_mouseInter->RegisterFullScreen(); m_mouseAreaKey = m_mouseInter->RegisterFullScreen();
} }
void DockPopupWindow::hide()
{
if (!m_mouseAreaKey.isEmpty())
{
m_mouseInter->UnregisterArea(m_mouseAreaKey);
m_mouseAreaKey.clear();
}
DArrowRectangle::hide();
}
void DockPopupWindow::mousePressEvent(QMouseEvent *e) void DockPopupWindow::mousePressEvent(QMouseEvent *e)
{ {
DArrowRectangle::mousePressEvent(e); DArrowRectangle::mousePressEvent(e);
if (e->button() == Qt::LeftButton) // if (e->button() == Qt::LeftButton)
m_acceptDelayTimer->start(); // m_acceptDelayTimer->start();
} }
void DockPopupWindow::globalMouseRelease() void DockPopupWindow::globalMouseRelease()
{ {
if (!m_model) Q_ASSERT(m_model);
return;
const QRect rect = QRect(pos(), size()); const QRect rect = QRect(pos(), size());
const QPoint pos = QCursor::pos(); const QPoint pos = QCursor::pos();
@ -54,4 +74,5 @@ void DockPopupWindow::globalMouseRelease()
emit accept(); emit accept();
m_mouseInter->UnregisterArea(m_mouseAreaKey); m_mouseInter->UnregisterArea(m_mouseAreaKey);
m_mouseAreaKey.clear();
} }

View File

@ -11,11 +11,13 @@ class DockPopupWindow : public Dtk::Widget::DArrowRectangle
public: public:
explicit DockPopupWindow(QWidget *parent = 0); explicit DockPopupWindow(QWidget *parent = 0);
~DockPopupWindow();
bool model() const; bool model() const;
public slots: public slots:
void show(const QPoint &pos, const bool model = false); void show(const QPoint &pos, const bool model = false);
void hide();
signals: signals:
void accept() const; void accept() const;

View File

@ -1,10 +1,15 @@
#include "diskcontrolwidget.h" #include "diskcontrolwidget.h"
DiskControlWidget::DiskControlWidget(QWidget *parent) DiskControlWidget::DiskControlWidget(QWidget *parent)
: QWidget(parent), : QScrollArea(parent),
m_diskInter(new DBusDiskMount(this)) m_diskInter(new DBusDiskMount(this))
{ {
setFixedWidth(300);
setFrameStyle(QFrame::NoFrame);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setStyleSheet("background-color:transparent;");
connect(m_diskInter, &DBusDiskMount::DiskListChanged, this, &DiskControlWidget::diskListChanged); connect(m_diskInter, &DBusDiskMount::DiskListChanged, this, &DiskControlWidget::diskListChanged);

View File

@ -3,9 +3,9 @@
#include "dbus/dbusdiskmount.h" #include "dbus/dbusdiskmount.h"
#include <QWidget> #include <QScrollArea>
class DiskControlWidget : public QWidget class DiskControlWidget : public QScrollArea
{ {
Q_OBJECT Q_OBJECT