1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

[Code] Use QTime::elapsed() for timing

This commit is contained in:
nowrep 2014-03-03 12:55:35 +01:00
parent 12948cd0a4
commit 82ca226127
3 changed files with 14 additions and 8 deletions

View File

@ -72,12 +72,14 @@ QList<BookmarkItem*> BookmarkItem::children() const
QIcon BookmarkItem::icon()
{
// Cache icon for 20 seconds
const int iconCacheTime = 20 * 1000;
switch (m_type) {
case Url:
// Cache icon for 20 seconds
if (m_iconTime < QTime::currentTime().addSecs(-20)) {
if (m_iconTime.isNull() || m_iconTime.elapsed() > iconCacheTime) {
m_icon = _iconForUrl(m_url);
m_iconTime = QTime::currentTime();
m_iconTime.restart();
}
return m_icon;
case Folder:

View File

@ -387,6 +387,7 @@ void WebPage::handleUnknownProtocol(const QUrl &url)
qzSettings->saveSettings();
}
QDesktopServices::openUrl(url);
break;
@ -406,10 +407,11 @@ void WebPage::handleUnknownProtocol(const QUrl &url)
void WebPage::desktopServicesOpen(const QUrl &url)
{
// Open same url only once in 2 secs
const int sameUrlTimeout = 2 * 1000;
if (s_lastUnsupportedUrl != url || QTime::currentTime() > s_lastUnsupportedUrlTime.addSecs(2)) {
if (s_lastUnsupportedUrl != url || s_lastUnsupportedUrlTime.isNull() || s_lastUnsupportedUrlTime.elapsed() > sameUrlTimeout) {
s_lastUnsupportedUrl = url;
s_lastUnsupportedUrlTime = QTime::currentTime();
s_lastUnsupportedUrlTime.restart();
QDesktopServices::openUrl(url);
}
else {

View File

@ -110,13 +110,15 @@ bool AKN_Handler::handleKeyPress(QObject* obj, QKeyEvent* event)
triggerShowAccessKeys();
}
else {
if (!m_lastKeyPressTime.isValid()) {
const int doublePressInterval = 500; // 500 msecs
if (m_lastKeyPressTime.isNull()) {
// It is the first press of our button
m_lastKeyPressTime = QTime::currentTime();
m_lastKeyPressTime.start();
}
else {
// It is the second press of our button
if (QTime(m_lastKeyPressTime).addMSecs(500) >= QTime::currentTime()) {
if (m_lastKeyPressTime.elapsed() <= doublePressInterval) {
triggerShowAccessKeys();
}
else {