mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
Fixes in inline completion + enter completed text with left arrow key.
This commit is contained in:
parent
77aa5b0f07
commit
49ed4d05c4
@ -54,6 +54,11 @@ bool LocationCompleter::showingMostVisited() const
|
||||
return m_showingMostVisited;
|
||||
}
|
||||
|
||||
bool LocationCompleter::isPopupSelected() const
|
||||
{
|
||||
return s_view->currentIndex().isValid();
|
||||
}
|
||||
|
||||
bool LocationCompleter::isPopupVisible() const
|
||||
{
|
||||
return s_view->isVisible();
|
||||
|
@ -38,6 +38,7 @@ public:
|
||||
|
||||
QString domainCompletion() const;
|
||||
bool showingMostVisited() const;
|
||||
bool isPopupSelected() const;
|
||||
bool isPopupVisible() const;
|
||||
void closePopup();
|
||||
|
||||
|
@ -89,11 +89,6 @@ bool LocationCompleterView::eventFilter(QObject* object, QEvent* event)
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::Key_Left:
|
||||
case Qt::Key_Right:
|
||||
close();
|
||||
break;
|
||||
|
||||
case Qt::Key_Escape:
|
||||
close();
|
||||
return false;
|
||||
|
@ -55,6 +55,7 @@ LocationBar::LocationBar(QupZilla* mainClass)
|
||||
, m_loadProgress(0)
|
||||
, m_progressVisible(false)
|
||||
, m_forcePaintEvent(false)
|
||||
, m_inlineCompletionVisible(false)
|
||||
, m_drawCursor(true)
|
||||
, m_popupClosed(false)
|
||||
{
|
||||
@ -135,6 +136,8 @@ void LocationBar::updatePlaceHolderText()
|
||||
|
||||
void LocationBar::showCompletion(const QString &newText)
|
||||
{
|
||||
m_inlineCompletionVisible = false;
|
||||
|
||||
LineEdit::setText(newText);
|
||||
|
||||
// Move cursor to the end
|
||||
@ -143,6 +146,7 @@ void LocationBar::showCompletion(const QString &newText)
|
||||
|
||||
void LocationBar::completionPopupClosed()
|
||||
{
|
||||
m_inlineCompletionVisible = false;
|
||||
m_popupClosed = true;
|
||||
m_drawCursor = true;
|
||||
}
|
||||
@ -163,8 +167,7 @@ QUrl LocationBar::createUrl()
|
||||
}
|
||||
}
|
||||
|
||||
// Is inline domain completion active?
|
||||
if (m_completer.isPopupVisible() && !m_completer.domainCompletion().isEmpty()) {
|
||||
if (m_inlineCompletionVisible) {
|
||||
urlToLoad = WebView::guessUrlFromString(text() + m_completer.domainCompletion());
|
||||
}
|
||||
|
||||
@ -211,6 +214,7 @@ void LocationBar::textEdit()
|
||||
{
|
||||
if (!text().isEmpty()) {
|
||||
m_completer.complete(text());
|
||||
m_inlineCompletionVisible = true;
|
||||
}
|
||||
else {
|
||||
m_completer.closePopup();
|
||||
@ -453,6 +457,27 @@ void LocationBar::keyPressEvent(QKeyEvent* event)
|
||||
m_completer.complete(text());
|
||||
break;
|
||||
|
||||
case Qt::Key_End:
|
||||
case Qt::Key_Right:
|
||||
if (m_inlineCompletionVisible) {
|
||||
m_inlineCompletionVisible = false;
|
||||
|
||||
setText(text() + m_completer.domainCompletion());
|
||||
setCursorPosition(text().size());
|
||||
m_completer.closePopup();
|
||||
}
|
||||
|
||||
if (m_completer.isPopupVisible()) {
|
||||
m_completer.closePopup();
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::Key_Left:
|
||||
if (m_completer.isPopupVisible()) {
|
||||
m_completer.closePopup();
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::Key_Escape:
|
||||
m_webView->setFocus();
|
||||
showUrl(m_webView->url());
|
||||
@ -600,7 +625,7 @@ void LocationBar::paintEvent(QPaintEvent* event)
|
||||
QTextOption opt;
|
||||
opt.setWrapMode(QTextOption::NoWrap);
|
||||
|
||||
if (hasFocus() && m_completer.isPopupVisible()) {
|
||||
if (hasFocus() && m_inlineCompletionVisible) {
|
||||
// Draw inline domain completion if available
|
||||
const QString &completionText = m_completer.domainCompletion();
|
||||
|
||||
|
@ -125,6 +125,7 @@ private:
|
||||
QColor m_progressColor;
|
||||
|
||||
bool m_forcePaintEvent;
|
||||
bool m_inlineCompletionVisible;
|
||||
bool m_drawCursor;
|
||||
bool m_popupClosed;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user