1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

[Fix] WebSearchBar not respecting "select all on click" option

Closes #752
This commit is contained in:
nowrep 2013-03-15 11:46:07 +01:00
parent f95cf48f0e
commit d4c6dbd6c2
6 changed files with 31 additions and 30 deletions

View File

@ -1,5 +1,6 @@
Version 1.4.1 Version 1.4.1
* not yet released * not yet released
* fixed websearchbar not respecting select all on click settings
* fixed certificates from custom path disappearing on saving preferences * fixed certificates from custom path disappearing on saving preferences
* fixed showing empty back/forward history menu upon restoring session * fixed showing empty back/forward history menu upon restoring session
* fixed duplicating current url in history when restoring session * fixed duplicating current url in history when restoring session

View File

@ -42,6 +42,7 @@ LineEdit::LineEdit(QWidget* parent)
, m_leftLayout(0) , m_leftLayout(0)
, m_rightLayout(0) , m_rightLayout(0)
, m_leftMargin(-1) , m_leftMargin(-1)
, m_ignoreMousePress(false)
{ {
init(); init();
} }
@ -117,7 +118,7 @@ void LineEdit::init()
bool LineEdit::event(QEvent* event) bool LineEdit::event(QEvent* event)
{ {
if (event->type() == QEvent::LayoutDirectionChange) { 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()) { if (isRightToLeft()) {
mainLayout->setDirection(QBoxLayout::RightToLeft); mainLayout->setDirection(QBoxLayout::RightToLeft);
m_leftLayout->setDirection(QBoxLayout::RightToLeft); m_leftLayout->setDirection(QBoxLayout::RightToLeft);
@ -191,13 +192,22 @@ void LineEdit::updateTextMargins()
int top = 0; int top = 0;
int bottom = 0; int bottom = 0;
setTextMargins(left, top, right, bottom); 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) void LineEdit::mousePressEvent(QMouseEvent* event)
{ {
if (cursorPosition() == 0 && qzSettings->selectAllOnClick) { if (m_ignoreMousePress) {
selectAll(); m_ignoreMousePress = false;
return; return;
} }

View File

@ -89,15 +89,14 @@ public slots:
void updateTextMargins(); void updateTextMargins();
protected: protected:
void focusInEvent(QFocusEvent* event);
void mousePressEvent(QMouseEvent* event); void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event); void mouseReleaseEvent(QMouseEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event); void mouseDoubleClickEvent(QMouseEvent* event);
// void resizeEvent(QResizeEvent* event);
bool event(QEvent* event); bool event(QEvent* event);
private: private:
void init(); void init();
// void updateSideWidgetLocations();
SideWidget* m_leftWidget; SideWidget* m_leftWidget;
SideWidget* m_rightWidget; SideWidget* m_rightWidget;
@ -106,6 +105,7 @@ private:
QHBoxLayout* mainLayout; QHBoxLayout* mainLayout;
int m_leftMargin; int m_leftMargin;
bool m_ignoreMousePress;
}; };

View File

@ -385,7 +385,7 @@ void LocationBar::dropEvent(QDropEvent* event)
emit loadUrl(dropUrl); emit loadUrl(dropUrl);
QFocusEvent event(QFocusEvent::FocusOut); QFocusEvent event(QFocusEvent::FocusOut);
QLineEdit::focusOutEvent(&event); LineEdit::focusOutEvent(&event);
return; return;
} }
} }
@ -398,17 +398,18 @@ void LocationBar::dropEvent(QDropEvent* event)
emit loadUrl(dropUrl); emit loadUrl(dropUrl);
QFocusEvent event(QFocusEvent::FocusOut); QFocusEvent event(QFocusEvent::FocusOut);
QLineEdit::focusOutEvent(&event); LineEdit::focusOutEvent(&event);
return; return;
} }
} }
QLineEdit::dropEvent(event);
LineEdit::dropEvent(event);
} }
void LocationBar::focusOutEvent(QFocusEvent* event) void LocationBar::focusOutEvent(QFocusEvent* event)
{ {
QLineEdit::focusOutEvent(event); LineEdit::focusOutEvent(event);
if (event->reason() == Qt::PopupFocusReason if (event->reason() == Qt::PopupFocusReason
|| (!selectedText().isEmpty() && event->reason() != Qt::TabFocusReason)) { || (!selectedText().isEmpty() && event->reason() != Qt::TabFocusReason)) {

View File

@ -66,11 +66,11 @@ WebSearchBar::WebSearchBar(QupZilla* mainClass)
m_boxSearchType = new ButtonWithMenu(this); m_boxSearchType = new ButtonWithMenu(this);
m_boxSearchType->setObjectName("websearchbar-searchprovider-comobobox"); m_boxSearchType->setObjectName("websearchbar-searchprovider-comobobox");
//RTL Support // RTL Support
////if we don't add 'm_boxSearchType' by following code, then we should use suitable padding-left value // 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 // 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 // padding-left is equivalent to padding-right and vice versa, and because style sheet is
//// not changed dynamically this create padding problems. // not changed dynamically this create padding problems.
addWidget(m_boxSearchType, LineEdit::LeftSide); addWidget(m_boxSearchType, LineEdit::LeftSide);
addWidget(m_buttonSearch, LineEdit::RightSide); addWidget(m_buttonSearch, LineEdit::RightSide);
@ -195,7 +195,6 @@ void WebSearchBar::searchChanged(const ButtonWithMenu::Item &item)
void WebSearchBar::instantSearchChanged(bool enable) void WebSearchBar::instantSearchChanged(bool enable)
{ {
Settings settings; Settings settings;
settings.beginGroup("SearchEngines"); settings.beginGroup("SearchEngines");
settings.setValue("SearchOnEngineChange", enable); settings.setValue("SearchOnEngineChange", enable);
@ -332,18 +331,8 @@ void WebSearchBar::focusOutEvent(QFocusEvent* e)
QString search = m_boxSearchType->currentItem().text; QString search = m_boxSearchType->currentItem().text;
setPlaceholderText(search); setPlaceholderText(search);
} }
QLineEdit::focusOutEvent(e);
}
void WebSearchBar::focusInEvent(QFocusEvent* e) LineEdit::focusOutEvent(e);
{
QString search = m_boxSearchType->toolTip();
if (text() == search) {
clear();
}
QLineEdit::focusInEvent(e);
} }
void WebSearchBar::dropEvent(QDropEvent* event) void WebSearchBar::dropEvent(QDropEvent* event)
@ -354,10 +343,11 @@ void WebSearchBar::dropEvent(QDropEvent* event)
search(); search();
QFocusEvent event(QFocusEvent::FocusOut); QFocusEvent event(QFocusEvent::FocusOut);
QLineEdit::focusOutEvent(&event); LineEdit::focusOutEvent(&event);
return; return;
} }
QLineEdit::dropEvent(event);
LineEdit::dropEvent(event);
} }
void WebSearchBar::keyPressEvent(QKeyEvent* event) void WebSearchBar::keyPressEvent(QKeyEvent* event)

View File

@ -72,7 +72,6 @@ private slots:
void instantSearchChanged(bool); void instantSearchChanged(bool);
private: private:
void focusInEvent(QFocusEvent* e);
void focusOutEvent(QFocusEvent* e); void focusOutEvent(QFocusEvent* e);
void dropEvent(QDropEvent* event); void dropEvent(QDropEvent* event);
void keyPressEvent(QKeyEvent* event); void keyPressEvent(QKeyEvent* event);