1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 09:42:10 +02: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
* 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

View File

@ -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;
}

View File

@ -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;
};

View File

@ -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)) {

View File

@ -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)

View File

@ -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);