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

[LocationBar] Set cursor position at start when showing long url

Also disable animations for Oxygen style, it breaks when changing
text to completely different one (eg. loading foo.com and then bar.com)
and the url is too long to fit in line
This commit is contained in:
nowrep 2014-03-16 11:21:24 +01:00
parent caabbc237f
commit 6e53add7d7
3 changed files with 18 additions and 8 deletions

View File

@ -23,7 +23,6 @@
#include <QStyleOption>
#include <QPainter>
#include <QFocusEvent>
#include <QApplication>
SideWidget::SideWidget(QWidget* parent)
: QWidget(parent)
@ -157,8 +156,8 @@ void LineEdit::setTextFormat(const LineEdit::TextFormat &format)
attributes.append(QInputMethodEvent::Attribute(type, start, length, value));
}
QInputMethodEvent event(QString(), attributes);
QApplication::sendEvent(this, &event);
QInputMethodEvent ev(QString(), attributes);
event(&ev);
}
void LineEdit::clearTextFormat()

View File

@ -55,6 +55,7 @@
#include <QDesktopServices>
#include <QSqlDatabase>
#include <QTranslator>
#include <QThreadPool>
#include <QSettings>
#include <QProcess>
#include <QDebug>
@ -268,11 +269,14 @@ MainApplication::MainApplication(int &argc, char** argv)
MainApplication::~MainApplication()
{
IconProvider::instance()->saveIconsToDatabase();
// Wait for all QtConcurrent jobs to finish
QThreadPool::globalInstance()->waitForDone();
// Delete all classes that are saving data in destructor
delete m_bookmarks;
delete m_cookieJar;
IconProvider::instance()->saveIconsToDatabase();
}
bool MainApplication::isClosing() const

View File

@ -62,6 +62,9 @@ LocationBar::LocationBar(BrowserWindow* window)
setObjectName("locationbar");
setDragEnabled(true);
// Disable Oxygen QLineEdit transitions, it breaks with setText() && home()
setProperty("_kde_no_animations", QVariant(true));
m_bookmarkIcon = new BookmarksIcon(this);
m_goIcon = new GoIcon(this);
m_rssIcon = new RssIcon(this);
@ -70,7 +73,6 @@ LocationBar::LocationBar(BrowserWindow* window)
DownIcon* down = new DownIcon(this);
addWidget(m_siteIcon, LineEdit::LeftSide);
addWidget(m_autofillIcon, LineEdit::RightSide);
addWidget(m_bookmarkIcon, LineEdit::RightSide);
addWidget(m_rssIcon, LineEdit::RightSide);
@ -311,11 +313,16 @@ void LocationBar::showUrl(const QUrl &url)
const QString stringUrl = convertUrlToText(url);
if (stringUrl == text()) {
if (text() == stringUrl) {
home(false);
return;
}
setText(stringUrl);
// Set converted url as text
setText(convertUrlToText(url));
// Move cursor to the start
home(false);
hideGoButton();
m_bookmarkIcon->checkBookmark(url);