1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-14 11:02:19 +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 <QStyleOption>
#include <QPainter> #include <QPainter>
#include <QFocusEvent> #include <QFocusEvent>
#include <QApplication>
SideWidget::SideWidget(QWidget* parent) SideWidget::SideWidget(QWidget* parent)
: QWidget(parent) : QWidget(parent)
@ -157,8 +156,8 @@ void LineEdit::setTextFormat(const LineEdit::TextFormat &format)
attributes.append(QInputMethodEvent::Attribute(type, start, length, value)); attributes.append(QInputMethodEvent::Attribute(type, start, length, value));
} }
QInputMethodEvent event(QString(), attributes); QInputMethodEvent ev(QString(), attributes);
QApplication::sendEvent(this, &event); event(&ev);
} }
void LineEdit::clearTextFormat() void LineEdit::clearTextFormat()

View File

@ -55,6 +55,7 @@
#include <QDesktopServices> #include <QDesktopServices>
#include <QSqlDatabase> #include <QSqlDatabase>
#include <QTranslator> #include <QTranslator>
#include <QThreadPool>
#include <QSettings> #include <QSettings>
#include <QProcess> #include <QProcess>
#include <QDebug> #include <QDebug>
@ -268,11 +269,14 @@ MainApplication::MainApplication(int &argc, char** argv)
MainApplication::~MainApplication() 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 all classes that are saving data in destructor
delete m_bookmarks; delete m_bookmarks;
delete m_cookieJar; delete m_cookieJar;
IconProvider::instance()->saveIconsToDatabase();
} }
bool MainApplication::isClosing() const bool MainApplication::isClosing() const

View File

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