[LyX/master] Movable minimised Quick Search Widget

Juergen Spitzmueller spitz at lyx.org
Sun Oct 31 11:44:22 UTC 2021


commit ce8b4e3a218fcff0200e18f67db542acc04eaf8f
Author: Daniel Ramoeller <d.lyx at web.de>
Date:   Fri Mar 19 07:37:11 2021 +0100

    Movable minimised Quick Search Widget
    
    Fix for bug #12207.
---
 src/frontends/qt/GuiSearch.cpp |   27 +++++++++++++++++++++++++++
 src/frontends/qt/GuiSearch.h   |    5 +++++
 2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/src/frontends/qt/GuiSearch.cpp b/src/frontends/qt/GuiSearch.cpp
index 32a8fd1..88edf53 100644
--- a/src/frontends/qt/GuiSearch.cpp
+++ b/src/frontends/qt/GuiSearch.cpp
@@ -564,6 +564,33 @@ GuiSearch::GuiSearch(GuiView & parent, Qt::DockWidgetArea area, Qt::WindowFlags
 	connect(widget_, SIGNAL(needSizeUpdate()), this, SLOT(updateSize()));
 }
 
+
+void GuiSearch::mousePressEvent(QMouseEvent *event)
+{
+    if (isFloating() && event->button() == Qt::LeftButton) {
+        dragPosition = event->globalPos() - frameGeometry().topLeft();
+        event->accept();
+    }
+}
+
+
+void GuiSearch::mouseMoveEvent(QMouseEvent *event)
+{
+    if (isFloating() && event->buttons() & Qt::LeftButton) {
+        move(event->globalPos() - dragPosition);
+        event->accept();
+    }
+}
+
+
+void GuiSearch::mouseDoubleClickEvent(QMouseEvent *event)
+{
+    if (event->button() == Qt::LeftButton) {
+        setFloating(!isFloating());
+    }
+}
+
+
 void GuiSearch::onBufferViewChanged()
 {
 	widget_->setEnabled(static_cast<bool>(bufferview()));
diff --git a/src/frontends/qt/GuiSearch.h b/src/frontends/qt/GuiSearch.h
index a6d1fd8..579e989 100644
--- a/src/frontends/qt/GuiSearch.h
+++ b/src/frontends/qt/GuiSearch.h
@@ -127,6 +127,9 @@ public:
 
 protected:
 	bool wantInitialFocus() const override { return true; }
+    void mouseMoveEvent(QMouseEvent * event) override;
+    void mousePressEvent(QMouseEvent * event) override;
+	void mouseDoubleClickEvent(QMouseEvent *event) override;
 
 public Q_SLOTS:
 	///
@@ -141,6 +144,8 @@ private Q_SLOTS:
 private:
 	/// The encapsulated widget.
 	GuiSearchWidget * widget_;
+	///
+    QPoint dragPosition;
 };
 
 } // namespace frontend


More information about the lyx-cvs mailing list