mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
Select all on (double) click also available for websearchbar.
Closes #752
This commit is contained in:
parent
e069da55e3
commit
789b4c8600
60
src/lib/3rdparty/lineedit.cpp
vendored
60
src/lib/3rdparty/lineedit.cpp
vendored
@ -16,6 +16,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* ============================================================ */
|
* ============================================================ */
|
||||||
#include "lineedit.h"
|
#include "lineedit.h"
|
||||||
|
#include "qzsettings.h"
|
||||||
|
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
@ -23,7 +24,6 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QFocusEvent>
|
#include <QFocusEvent>
|
||||||
|
|
||||||
#include <qdebug.h>
|
|
||||||
SideWidget::SideWidget(QWidget* parent)
|
SideWidget::SideWidget(QWidget* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
@ -41,7 +41,7 @@ LineEdit::LineEdit(QWidget* parent)
|
|||||||
: QLineEdit(parent)
|
: QLineEdit(parent)
|
||||||
, m_leftLayout(0)
|
, m_leftLayout(0)
|
||||||
, m_rightLayout(0)
|
, m_rightLayout(0)
|
||||||
, m_leftMargin(0)
|
, m_leftMargin(-1)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@ -186,13 +186,7 @@ int LineEdit::textMargin(WidgetPosition position) const
|
|||||||
|
|
||||||
void LineEdit::updateTextMargins()
|
void LineEdit::updateTextMargins()
|
||||||
{
|
{
|
||||||
int left;
|
int left = m_leftMargin < 0 ? m_leftWidget->sizeHint().width() : m_leftMargin;
|
||||||
if (m_leftMargin == 0) {
|
|
||||||
left = m_leftWidget->sizeHint().width();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
left = m_leftMargin;
|
|
||||||
}
|
|
||||||
int right = m_rightWidget->sizeHint().width();
|
int right = m_rightWidget->sizeHint().width();
|
||||||
int top = 0;
|
int top = 0;
|
||||||
int bottom = 0;
|
int bottom = 0;
|
||||||
@ -200,6 +194,16 @@ void LineEdit::updateTextMargins()
|
|||||||
// updateSideWidgetLocations();
|
// updateSideWidgetLocations();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LineEdit::mousePressEvent(QMouseEvent* event)
|
||||||
|
{
|
||||||
|
if (cursorPosition() == 0 && qzSettings->selectAllOnClick) {
|
||||||
|
selectAll();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QLineEdit::mousePressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void LineEdit::mouseReleaseEvent(QMouseEvent* event)
|
void LineEdit::mouseReleaseEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
// Workaround issue in QLineEdit::setDragEnabled(true)
|
// Workaround issue in QLineEdit::setDragEnabled(true)
|
||||||
@ -224,34 +228,12 @@ void LineEdit::mouseReleaseEvent(QMouseEvent* event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//void LineEdit::updateSideWidgetLocations()
|
void LineEdit::mouseDoubleClickEvent(QMouseEvent* event)
|
||||||
//{
|
{
|
||||||
// QStyleOptionFrameV2 opt;
|
if (event->button() == Qt::LeftButton && qzSettings->selectAllOnDoubleClick) {
|
||||||
// initStyleOption(&opt);
|
selectAll();
|
||||||
// QRect textRect = style()->subElementRect(QStyle::SE_LineEditContents, &opt, this);
|
return;
|
||||||
// int spacing = m_rightLayout->spacing();
|
}
|
||||||
// textRect.adjust(spacing, 0, -spacing, 0);
|
|
||||||
|
|
||||||
// int left = textMargin(LineEdit::LeftSide);
|
QLineEdit::mouseDoubleClickEvent(event);
|
||||||
|
}
|
||||||
// int midHeight = textRect.center().y() + 1;
|
|
||||||
|
|
||||||
// if (m_leftLayout->count() > 0) {
|
|
||||||
// int leftHeight = midHeight - m_leftWidget->height() / 2;
|
|
||||||
// int leftWidth = m_leftWidget->width();
|
|
||||||
// if (leftWidth == 0) {
|
|
||||||
// leftHeight = midHeight - m_leftWidget->sizeHint().height() / 2;
|
|
||||||
// }
|
|
||||||
// m_leftWidget->move(textRect.x(), leftHeight);
|
|
||||||
// }
|
|
||||||
// textRect.setX(left);
|
|
||||||
// textRect.setY(midHeight - m_rightWidget->sizeHint().height() / 2);
|
|
||||||
// textRect.setHeight(m_rightWidget->sizeHint().height());
|
|
||||||
// m_rightWidget->setGeometry(textRect);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//void LineEdit::resizeEvent(QResizeEvent* event)
|
|
||||||
//{
|
|
||||||
// updateSideWidgetLocations();
|
|
||||||
// QLineEdit::resizeEvent(event);
|
|
||||||
//}
|
|
||||||
|
2
src/lib/3rdparty/lineedit.h
vendored
2
src/lib/3rdparty/lineedit.h
vendored
@ -89,7 +89,9 @@ public slots:
|
|||||||
void updateTextMargins();
|
void updateTextMargins();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void mousePressEvent(QMouseEvent* event);
|
||||||
void mouseReleaseEvent(QMouseEvent* event);
|
void mouseReleaseEvent(QMouseEvent* event);
|
||||||
|
void mouseDoubleClickEvent(QMouseEvent* event);
|
||||||
// void resizeEvent(QResizeEvent* event);
|
// void resizeEvent(QResizeEvent* event);
|
||||||
bool event(QEvent* event);
|
bool event(QEvent* event);
|
||||||
|
|
||||||
|
@ -410,26 +410,6 @@ void LocationBar::focusOutEvent(QFocusEvent* event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocationBar::mouseDoubleClickEvent(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
if (event->button() == Qt::LeftButton && qzSettings->selectAllOnDoubleClick) {
|
|
||||||
selectAll();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QLineEdit::mouseDoubleClickEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LocationBar::mousePressEvent(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
if (cursorPosition() == 0 && qzSettings->selectAllOnClick) {
|
|
||||||
selectAll();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
LineEdit::mousePressEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LocationBar::keyPressEvent(QKeyEvent* event)
|
void LocationBar::keyPressEvent(QKeyEvent* event)
|
||||||
{
|
{
|
||||||
switch (event->key()) {
|
switch (event->key()) {
|
||||||
|
@ -89,8 +89,6 @@ private:
|
|||||||
void contextMenuEvent(QContextMenuEvent* event);
|
void contextMenuEvent(QContextMenuEvent* event);
|
||||||
void focusInEvent(QFocusEvent* event);
|
void focusInEvent(QFocusEvent* event);
|
||||||
void focusOutEvent(QFocusEvent* event);
|
void focusOutEvent(QFocusEvent* event);
|
||||||
void mouseDoubleClickEvent(QMouseEvent* event);
|
|
||||||
void mousePressEvent(QMouseEvent* event);
|
|
||||||
void keyPressEvent(QKeyEvent* event);
|
void keyPressEvent(QKeyEvent* event);
|
||||||
void keyReleaseEvent(QKeyEvent* event);
|
void keyReleaseEvent(QKeyEvent* event);
|
||||||
void dropEvent(QDropEvent* event);
|
void dropEvent(QDropEvent* event);
|
||||||
|
Loading…
Reference in New Issue
Block a user