From: Scott Kostyshak Date: Thu, 21 Jul 2016 23:16:19 +0000 (-0400) Subject: Factor out useful code into a function X-Git-Tag: 2.3.0alpha1~1224 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=b236450e617b2b2e9baf8091f4a70803e88300c5;p=features.git Factor out useful code into a function This code will be shared by TabWorkArea::mouseReleaseEvent, which will be implemented shortly. --- diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index e397a80c38..72a043e0bf 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -1628,6 +1628,15 @@ void TabWorkArea::paintEvent(QPaintEvent * event) } +bool TabWorkArea::posIsTab(QPoint position) +{ + for (int i = 0; i < count(); ++i) + if (tabBar()->tabRect(i).contains(position)) + return true; + return false; +} + + void TabWorkArea::mouseDoubleClickEvent(QMouseEvent * event) { if (event->button() != Qt::LeftButton) @@ -1640,9 +1649,8 @@ void TabWorkArea::mouseDoubleClickEvent(QMouseEvent * event) // leave this code for now. (skostysh, 2016-07-21) // // return early if double click on existing tabs - for (int i = 0; i < count(); ++i) - if (tabBar()->tabRect(i).contains(event->pos())) - return; + if (posIsTab(event->pos())) + return; dispatch(FuncRequest(LFUN_BUFFER_NEW)); } diff --git a/src/frontends/qt4/GuiWorkArea.h b/src/frontends/qt4/GuiWorkArea.h index df4b0c1177..9e4b1ab7a4 100644 --- a/src/frontends/qt4/GuiWorkArea.h +++ b/src/frontends/qt4/GuiWorkArea.h @@ -234,7 +234,9 @@ private Q_SLOTS: void mouseDoubleClickEvent(QMouseEvent * event); private: - /// + /// true if position is a tab (rather than the blank space in tab bar) + bool posIsTab(QPoint position); + int clicked_tab_; /// QToolButton * closeBufferButton;