mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
parent
018a4d5d7b
commit
cdf73b01b5
@ -206,7 +206,6 @@ void AdBlockDialog::itemChanged(QTreeWidgetItem* item)
|
|||||||
m_itemChangingBlock = false;
|
m_itemChangingBlock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AdBlockDialog::addCustomRule()
|
void AdBlockDialog::addCustomRule()
|
||||||
{
|
{
|
||||||
QString newRule = QInputDialog::getText(this, tr("Add Custom Rule"), tr("Please write your rule here:"));
|
QString newRule = QInputDialog::getText(this, tr("Add Custom Rule"), tr("Please write your rule here:"));
|
||||||
|
@ -1376,13 +1376,13 @@ void QupZilla::searchOnPage()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
search->searchLine()->setFocus();
|
search->focusSearchLine();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchToolBar* search = new SearchToolBar(this);
|
SearchToolBar* search = new SearchToolBar(this);
|
||||||
m_mainLayout->insertWidget(3, search);
|
m_mainLayout->insertWidget(3, search);
|
||||||
search->searchLine()->setFocus();
|
search->focusSearchLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QupZilla::openFile()
|
void QupZilla::openFile()
|
||||||
|
@ -169,7 +169,8 @@ SOURCES += \
|
|||||||
other/checkboxdialog.cpp \
|
other/checkboxdialog.cpp \
|
||||||
network/schemehandler.cpp \
|
network/schemehandler.cpp \
|
||||||
tools/plaineditwithlines.cpp \
|
tools/plaineditwithlines.cpp \
|
||||||
webview/websettings.cpp
|
webview/websettings.cpp \
|
||||||
|
tools/focusselectlineedit.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
webview/tabpreview.h \
|
webview/tabpreview.h \
|
||||||
@ -311,7 +312,8 @@ HEADERS += \
|
|||||||
network/schemehandler.h \
|
network/schemehandler.h \
|
||||||
tools/plaineditwithlines.h \
|
tools/plaineditwithlines.h \
|
||||||
sidebar/sidebarinterface.h \
|
sidebar/sidebarinterface.h \
|
||||||
webview/websettings.h
|
webview/websettings.h \
|
||||||
|
tools/focusselectlineedit.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
preferences/autofillmanager.ui \
|
preferences/autofillmanager.ui \
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="lineEdit">
|
<widget class="FocusSelectLineEdit" name="lineEdit">
|
||||||
<property name="placeholderText">
|
<property name="placeholderText">
|
||||||
<string>Search...</string>
|
<string>Search...</string>
|
||||||
</property>
|
</property>
|
||||||
@ -97,6 +97,13 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>FocusSelectLineEdit</class>
|
||||||
|
<extends>QLineEdit</extends>
|
||||||
|
<header>focusselectlineedit.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
51
src/lib/tools/focusselectlineedit.cpp
Normal file
51
src/lib/tools/focusselectlineedit.cpp
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/* ============================================================
|
||||||
|
* QupZilla - WebKit based browser
|
||||||
|
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* ============================================================ */
|
||||||
|
#include "focusselectlineedit.h"
|
||||||
|
|
||||||
|
#include <QFocusEvent>
|
||||||
|
|
||||||
|
FocusSelectLineEdit::FocusSelectLineEdit(QWidget *parent)
|
||||||
|
: QLineEdit(parent)
|
||||||
|
, m_mouseFocusReason(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void FocusSelectLineEdit::setFocus()
|
||||||
|
{
|
||||||
|
selectAll();
|
||||||
|
|
||||||
|
QLineEdit::setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FocusSelectLineEdit::focusInEvent(QFocusEvent *event)
|
||||||
|
{
|
||||||
|
m_mouseFocusReason = event->reason() == Qt::MouseFocusReason;
|
||||||
|
selectAll();
|
||||||
|
|
||||||
|
QLineEdit::focusInEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FocusSelectLineEdit::mousePressEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (m_mouseFocusReason) {
|
||||||
|
m_mouseFocusReason = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QLineEdit::mousePressEvent(event);
|
||||||
|
}
|
40
src/lib/tools/focusselectlineedit.h
Normal file
40
src/lib/tools/focusselectlineedit.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/* ============================================================
|
||||||
|
* QupZilla - WebKit based browser
|
||||||
|
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* ============================================================ */
|
||||||
|
#ifndef FOCUSSELECTLINEEDIT_H
|
||||||
|
#define FOCUSSELECTLINEEDIT_H
|
||||||
|
|
||||||
|
#include <QLineEdit>
|
||||||
|
|
||||||
|
class FocusSelectLineEdit : public QLineEdit
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit FocusSelectLineEdit(QWidget *parent = 0);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setFocus();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void focusInEvent(QFocusEvent *event);
|
||||||
|
void mousePressEvent(QMouseEvent *event);
|
||||||
|
|
||||||
|
bool m_mouseFocusReason;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FOCUSSELECTLINEEDIT_H
|
@ -55,9 +55,9 @@ SearchToolBar::SearchToolBar(QupZilla* mainClass, QWidget* parent)
|
|||||||
mainClass->installEventFilter(this);
|
mainClass->installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
QLineEdit* SearchToolBar::searchLine()
|
void SearchToolBar::focusSearchLine()
|
||||||
{
|
{
|
||||||
return ui->lineEdit;
|
ui->lineEdit->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchToolBar::hide()
|
void SearchToolBar::hide()
|
||||||
@ -146,12 +146,13 @@ void SearchToolBar::searchText(const QString &text)
|
|||||||
|
|
||||||
bool SearchToolBar::eventFilter(QObject* obj, QEvent* event)
|
bool SearchToolBar::eventFilter(QObject* obj, QEvent* event)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(obj);
|
||||||
|
|
||||||
if (event->type() == QEvent::KeyPress && static_cast<QKeyEvent*>(event)->key() == Qt::Key_Escape) {
|
if (event->type() == QEvent::KeyPress && static_cast<QKeyEvent*>(event)->key() == Qt::Key_Escape) {
|
||||||
hide();
|
hide();
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return AnimatedWidget::eventFilter(obj, event);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchToolBar::~SearchToolBar()
|
SearchToolBar::~SearchToolBar()
|
||||||
|
@ -40,7 +40,7 @@ public:
|
|||||||
explicit SearchToolBar(QupZilla* mainClass, QWidget* parent = 0);
|
explicit SearchToolBar(QupZilla* mainClass, QWidget* parent = 0);
|
||||||
~SearchToolBar();
|
~SearchToolBar();
|
||||||
|
|
||||||
QLineEdit* searchLine();
|
void focusSearchLine();
|
||||||
bool eventFilter(QObject* obj, QEvent* event);
|
bool eventFilter(QObject* obj, QEvent* event);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="lineEdit">
|
<widget class="FocusSelectLineEdit" name="lineEdit">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>100</width>
|
<width>100</width>
|
||||||
@ -127,6 +127,13 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>FocusSelectLineEdit</class>
|
||||||
|
<extends>QLineEdit</extends>
|
||||||
|
<header>focusselectlineedit.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
Loading…
Reference in New Issue
Block a user