diff --git a/CHANGELOG b/CHANGELOG index 84473e136..d32e10c3d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ Version 1.4.1 * not yet released + * fixed websearchbar not respecting select all on click settings * fixed certificates from custom path disappearing on saving preferences * fixed showing empty back/forward history menu upon restoring session * fixed duplicating current url in history when restoring session diff --git a/src/lib/3rdparty/lineedit.cpp b/src/lib/3rdparty/lineedit.cpp index 934d5ff95..1cea04072 100644 --- a/src/lib/3rdparty/lineedit.cpp +++ b/src/lib/3rdparty/lineedit.cpp @@ -42,6 +42,7 @@ LineEdit::LineEdit(QWidget* parent) , m_leftLayout(0) , m_rightLayout(0) , m_leftMargin(-1) + , m_ignoreMousePress(false) { init(); } @@ -117,7 +118,7 @@ void LineEdit::init() bool LineEdit::event(QEvent* event) { if (event->type() == QEvent::LayoutDirectionChange) { - //by this we undo reversing of layout when direction is RTL. + // By this we undo reversing of layout when direction is RTL. if (isRightToLeft()) { mainLayout->setDirection(QBoxLayout::RightToLeft); m_leftLayout->setDirection(QBoxLayout::RightToLeft); @@ -191,13 +192,22 @@ void LineEdit::updateTextMargins() int top = 0; int bottom = 0; setTextMargins(left, top, right, bottom); - // updateSideWidgetLocations(); +} + +void LineEdit::focusInEvent(QFocusEvent* event) +{ + if (event->reason() == Qt::MouseFocusReason && qzSettings->selectAllOnClick) { + m_ignoreMousePress = true; + selectAll(); + } + + QLineEdit::focusInEvent(event); } void LineEdit::mousePressEvent(QMouseEvent* event) { - if (cursorPosition() == 0 && qzSettings->selectAllOnClick) { - selectAll(); + if (m_ignoreMousePress) { + m_ignoreMousePress = false; return; } diff --git a/src/lib/3rdparty/lineedit.h b/src/lib/3rdparty/lineedit.h index c9a11adaa..2b33e19c6 100644 --- a/src/lib/3rdparty/lineedit.h +++ b/src/lib/3rdparty/lineedit.h @@ -89,15 +89,14 @@ public slots: void updateTextMargins(); protected: + void focusInEvent(QFocusEvent* event); void mousePressEvent(QMouseEvent* event); void mouseReleaseEvent(QMouseEvent* event); void mouseDoubleClickEvent(QMouseEvent* event); -// void resizeEvent(QResizeEvent* event); bool event(QEvent* event); private: void init(); -// void updateSideWidgetLocations(); SideWidget* m_leftWidget; SideWidget* m_rightWidget; @@ -106,6 +105,7 @@ private: QHBoxLayout* mainLayout; int m_leftMargin; + bool m_ignoreMousePress; }; diff --git a/src/lib/navigation/locationbar.cpp b/src/lib/navigation/locationbar.cpp index 961c89556..40fb51142 100644 --- a/src/lib/navigation/locationbar.cpp +++ b/src/lib/navigation/locationbar.cpp @@ -385,7 +385,7 @@ void LocationBar::dropEvent(QDropEvent* event) emit loadUrl(dropUrl); QFocusEvent event(QFocusEvent::FocusOut); - QLineEdit::focusOutEvent(&event); + LineEdit::focusOutEvent(&event); return; } } @@ -398,17 +398,18 @@ void LocationBar::dropEvent(QDropEvent* event) emit loadUrl(dropUrl); QFocusEvent event(QFocusEvent::FocusOut); - QLineEdit::focusOutEvent(&event); + LineEdit::focusOutEvent(&event); return; } } - QLineEdit::dropEvent(event); + + LineEdit::dropEvent(event); } void LocationBar::focusOutEvent(QFocusEvent* event) { - QLineEdit::focusOutEvent(event); + LineEdit::focusOutEvent(event); if (event->reason() == Qt::PopupFocusReason || (!selectedText().isEmpty() && event->reason() != Qt::TabFocusReason)) { diff --git a/src/lib/navigation/websearchbar.cpp b/src/lib/navigation/websearchbar.cpp index dafa1d53c..83fe755dd 100644 --- a/src/lib/navigation/websearchbar.cpp +++ b/src/lib/navigation/websearchbar.cpp @@ -66,11 +66,11 @@ WebSearchBar::WebSearchBar(QupZilla* mainClass) m_boxSearchType = new ButtonWithMenu(this); m_boxSearchType->setObjectName("websearchbar-searchprovider-comobobox"); - //RTL Support - ////if we don't add 'm_boxSearchType' by following code, then we should use suitable padding-left value - //// but then, when typing RTL text the layout dynamically changed and within RTL layout direction - //// padding-left is equivalent to padding-right and vice versa, and because style sheet is - //// not changed dynamically this create padding problems. + // RTL Support + // If we don't add 'm_boxSearchType' by following code, then we should use suitable padding-left value + // but then, when typing RTL text the layout dynamically changed and within RTL layout direction + // padding-left is equivalent to padding-right and vice versa, and because style sheet is + // not changed dynamically this create padding problems. addWidget(m_boxSearchType, LineEdit::LeftSide); addWidget(m_buttonSearch, LineEdit::RightSide); @@ -195,7 +195,6 @@ void WebSearchBar::searchChanged(const ButtonWithMenu::Item &item) void WebSearchBar::instantSearchChanged(bool enable) { - Settings settings; settings.beginGroup("SearchEngines"); settings.setValue("SearchOnEngineChange", enable); @@ -332,18 +331,8 @@ void WebSearchBar::focusOutEvent(QFocusEvent* e) QString search = m_boxSearchType->currentItem().text; setPlaceholderText(search); } - QLineEdit::focusOutEvent(e); -} -void WebSearchBar::focusInEvent(QFocusEvent* e) -{ - QString search = m_boxSearchType->toolTip(); - - if (text() == search) { - clear(); - } - - QLineEdit::focusInEvent(e); + LineEdit::focusOutEvent(e); } void WebSearchBar::dropEvent(QDropEvent* event) @@ -354,10 +343,11 @@ void WebSearchBar::dropEvent(QDropEvent* event) search(); QFocusEvent event(QFocusEvent::FocusOut); - QLineEdit::focusOutEvent(&event); + LineEdit::focusOutEvent(&event); return; } - QLineEdit::dropEvent(event); + + LineEdit::dropEvent(event); } void WebSearchBar::keyPressEvent(QKeyEvent* event) diff --git a/src/lib/navigation/websearchbar.h b/src/lib/navigation/websearchbar.h index 14ca26c40..19588cb90 100644 --- a/src/lib/navigation/websearchbar.h +++ b/src/lib/navigation/websearchbar.h @@ -72,7 +72,6 @@ private slots: void instantSearchChanged(bool); private: - void focusInEvent(QFocusEvent* e); void focusOutEvent(QFocusEvent* e); void dropEvent(QDropEvent* event); void keyPressEvent(QKeyEvent* event);