#include <QPainter>
#include <QLineEdit>
#include <QSettings>
+#include <QHideEvent>
#include <QShowEvent>
#include "QSizePolicy"
#if QT_VERSION >= 0x050000
}
-GuiSearchWidget::GuiSearchWidget(QWidget * parent)
- : QWidget(parent)
+GuiSearchWidget::GuiSearchWidget(QWidget * parent, GuiView & view)
+ : QWidget(parent), view_(view)
{
setupUi(this);
}
if (ev->key() == Qt::Key_Escape) {
dispatch(FuncRequest(LFUN_DIALOG_HIDE, "findreplace"));
+ view_.setFocus();
+ bv_->buffer().updateBuffer();
return;
}
}
+void GuiSearchWidget::hideEvent(QHideEvent *)
+{
+ dispatch(FuncRequest(LFUN_DIALOG_HIDE, "findreplace"));
+ view_.setFocus();
+ // update toolbar status
+ if (bv_)
+ bv_->buffer().updateBuffer();
+}
+
+
void GuiSearchWidget::findBufferChanged()
{
docstring search = theClipboard().getFindBuffer();
act_wholewords_->setChecked(settings.value(session_key + "/words", false).toBool());
instantSearchCB->setChecked(settings.value(session_key + "/instant", false).toBool());
act_immediate_->setChecked(settings.value(session_key + "/instant", false).toBool());
- wrapCB->setChecked(settings.value(session_key + "/wrap", false).toBool());
- act_wrap_->setChecked(settings.value(session_key + "/wrap", false).toBool());
+ wrapCB->setChecked(settings.value(session_key + "/wrap", true).toBool());
+ act_wrap_->setChecked(settings.value(session_key + "/wrap", true).toBool());
selectionCB->setChecked(settings.value(session_key + "/selection", false).toBool());
act_selection_->setChecked(settings.value(session_key + "/selection", false).toBool());
minimized_ = settings.value(session_key + "/minimized", false).toBool();
GuiSearch::GuiSearch(GuiView & parent, Qt::DockWidgetArea area, Qt::WindowFlags flags)
: DockView(parent, "findreplace", qt_("Search and Replace"), area, flags),
- widget_(new GuiSearchWidget(this))
+ widget_(new GuiSearchWidget(this, parent))
{
setWidget(widget_);
widget_->setBufferView(bufferview());
}
-void GuiSearch::mousePressEvent(QMouseEvent *event)
+void GuiSearch::mousePressEvent(QMouseEvent * event)
{
- if (isFloating() && event->button() == Qt::LeftButton) {
- dragPosition = event->globalPos() - frameGeometry().topLeft();
- event->accept();
- }
+ if (isFloating() && event->button() == Qt::LeftButton) {
+#if QT_VERSION >= 0x060000
+ dragPosition = event->globalPosition().toPoint() - frameGeometry().topLeft();
+#else
+ dragPosition = event->globalPos() - frameGeometry().topLeft();
+#endif
+ event->accept();
+ } else
+ DockView::mousePressEvent(event);
}
-void GuiSearch::mouseMoveEvent(QMouseEvent *event)
+void GuiSearch::mouseMoveEvent(QMouseEvent * event)
{
- if (isFloating() && event->buttons() & Qt::LeftButton) {
- move(event->globalPos() - dragPosition);
- event->accept();
- }
+ if (isFloating() && event->buttons() & Qt::LeftButton) {
+#if QT_VERSION >= 0x060000
+ move(event->globalPosition().toPoint() - dragPosition);
+#else
+ move(event->globalPos() - dragPosition);
+#endif
+ event->accept();
+ } else
+ DockView::mouseMoveEvent(event);
}
-void GuiSearch::mouseDoubleClickEvent(QMouseEvent *event)
+void GuiSearch::mouseDoubleClickEvent(QMouseEvent * event)
{
- if (event->button() == Qt::LeftButton) {
- setFloating(!isFloating());
- }
+ if (event->button() == Qt::LeftButton)
+ setFloating(!isFloating());
+ else
+ DockView::mouseDoubleClickEvent(event);
}
// remove title bar
setTitleBarWidget(new QWidget());
titleBarWidget()->hide();
- } else
+ } else if (titleBarWidget()) {
// restore title bar
setTitleBarWidget(nullptr);
+ }
}