mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
New option to show loading progress in address bar.
- enable it in Preferences -> Tabs -> Address Bar - patch by Franz Fellner closes #236
This commit is contained in:
parent
2acc6021aa
commit
dd84a84bc0
@ -39,6 +39,7 @@
|
||||
#include "qzsettings.h"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QTimer>
|
||||
|
||||
LocationBar::LocationBar(QupZilla* mainClass)
|
||||
: LineEdit(mainClass)
|
||||
@ -48,6 +49,8 @@ LocationBar::LocationBar(QupZilla* mainClass)
|
||||
, m_pasteAndGoAction(0)
|
||||
, m_clearAction(0)
|
||||
, m_holdingAlt(false)
|
||||
, m_loadProgress(0)
|
||||
, m_loadFinished(true)
|
||||
{
|
||||
setObjectName("locationbar");
|
||||
setDragEnabled(true);
|
||||
@ -86,6 +89,14 @@ LocationBar::LocationBar(QupZilla* mainClass)
|
||||
updatePlaceHolderText();
|
||||
}
|
||||
|
||||
void LocationBar::setWebView(TabbedWebView* view)
|
||||
{
|
||||
m_webView = view;
|
||||
|
||||
connect(m_webView, SIGNAL(loadProgress(int)), SLOT(onLoadProgress(int)));
|
||||
connect(m_webView, SIGNAL(loadFinished(bool)), SLOT(onLoadFinished()));
|
||||
}
|
||||
|
||||
void LocationBar::setText(const QString &text)
|
||||
{
|
||||
LineEdit::setText(text);
|
||||
@ -484,3 +495,75 @@ LocationBar::~LocationBar()
|
||||
{
|
||||
delete m_bookmarkIcon;
|
||||
}
|
||||
|
||||
void LocationBar::onLoadProgress(int progress)
|
||||
{
|
||||
if (qzSettings->showLoadingProgress) {
|
||||
m_loadFinished = false;
|
||||
m_loadProgress = progress;
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
void LocationBar::onLoadFinished()
|
||||
{
|
||||
if (qzSettings->showLoadingProgress) {
|
||||
m_loadFinished = false;
|
||||
QTimer::singleShot(700, this, SLOT(hideProgress()));
|
||||
}
|
||||
}
|
||||
|
||||
void LocationBar::hideProgress()
|
||||
{
|
||||
if (qzSettings->showLoadingProgress) {
|
||||
m_loadFinished = true;
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
void LocationBar::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
if (hasFocus() || !qzSettings->showLoadingProgress || m_loadFinished) {
|
||||
LineEdit::paintEvent(event);
|
||||
return;
|
||||
}
|
||||
|
||||
QStyleOptionFrameV3 option;
|
||||
initStyleOption(&option);
|
||||
|
||||
QPainter p(this);
|
||||
p.setRenderHint(QPainter::Antialiasing, true);
|
||||
p.setRenderHint(QPainter::TextAntialiasing, true);
|
||||
|
||||
style()->drawPrimitive(QStyle::PE_PanelLineEdit, &option, &p, this);
|
||||
|
||||
QRect contentsRect = style()->subElementRect(QStyle::SE_LineEditContents, &option, this);
|
||||
int lm, tm, rm, bm;
|
||||
getTextMargins(&lm, &tm, &rm, &bm);
|
||||
contentsRect.adjust(lm, tm, -rm, -bm);
|
||||
QFontMetrics fm = fontMetrics();
|
||||
const int x = contentsRect.x() + 3;
|
||||
const int y = contentsRect.y() + (contentsRect.height() - fm.height() + 1) / 2;
|
||||
const int width = contentsRect.width() - 6;
|
||||
const int height = fm.height();
|
||||
QRect textRect(x, y, width, height);
|
||||
|
||||
QColor bg = palette().color(QPalette::Base);
|
||||
if (!bg.isValid() || bg.alpha() == 0) {
|
||||
bg = p_QupZilla->palette().color(QPalette::Base);
|
||||
}
|
||||
bg = bg.darker(110);
|
||||
p.setBrush(QBrush(bg));
|
||||
|
||||
QPen oldPen = p.pen();
|
||||
QPen outlinePen(bg.darker(110), 0.8);
|
||||
p.setPen(outlinePen);
|
||||
|
||||
QRect bar = textRect.adjusted(-3, 0, 6 - (textRect.width() * (100.0 - m_loadProgress) / 100), 0);
|
||||
const int roundness = bar.height() / 4.0;
|
||||
p.drawRoundedRect(bar, roundness, roundness);
|
||||
|
||||
p.setPen(oldPen);
|
||||
// Qt::Alignment va = QStyle::visualAlignment(QApplication::layoutDirection(), QFlag(alignment()));
|
||||
p.drawText(textRect, text());
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
explicit LocationBar(QupZilla* mainClass);
|
||||
~LocationBar();
|
||||
|
||||
void setWebView(TabbedWebView* view) { m_webView = view; }
|
||||
void setWebView(TabbedWebView* view);
|
||||
TabbedWebView* webView() { return m_webView; }
|
||||
|
||||
signals:
|
||||
@ -55,6 +55,9 @@ public slots:
|
||||
void showUrl(const QUrl &url);
|
||||
void setText(const QString &text);
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent* event);
|
||||
|
||||
private slots:
|
||||
void siteIconChanged();
|
||||
void setPrivacy(bool state);
|
||||
@ -70,6 +73,10 @@ private slots:
|
||||
void updatePlaceHolderText();
|
||||
void showCompletion(const QString &newText);
|
||||
|
||||
void onLoadProgress(int progress);
|
||||
void onLoadFinished();
|
||||
void hideProgress();
|
||||
|
||||
private:
|
||||
void contextMenuEvent(QContextMenuEvent* event);
|
||||
void focusOutEvent(QFocusEvent* e);
|
||||
@ -100,6 +107,8 @@ private:
|
||||
|
||||
bool m_rssIconVisible;
|
||||
bool m_holdingAlt;
|
||||
int m_loadProgress;
|
||||
bool m_loadFinished;
|
||||
};
|
||||
|
||||
#endif // LOCATIONBAR_H
|
||||
|
@ -30,6 +30,7 @@ void QzSettings::loadSettings()
|
||||
selectAllOnDoubleClick = settings.value("SelectAllTextOnDoubleClick", true).toBool();
|
||||
selectAllOnClick = settings.value("SelectAllTextOnClick", false).toBool();
|
||||
addCountryWithAlt = settings.value("AddCountryDomainWithAltKey", true).toBool();
|
||||
showLoadingProgress = settings.value("ShowLoadingProgress", false).toBool();
|
||||
showLocationSuggestions = settings.value("showSuggestions", 0).toInt();
|
||||
settings.endGroup();
|
||||
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
bool selectAllOnDoubleClick;
|
||||
bool selectAllOnClick;
|
||||
bool addCountryWithAlt;
|
||||
bool showLoadingProgress;
|
||||
int showLocationSuggestions;
|
||||
|
||||
// SearchEngines
|
||||
|
@ -182,6 +182,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
|
||||
ui->selectAllOnFocus->setChecked(settings.value("SelectAllTextOnDoubleClick", true).toBool());
|
||||
ui->selectAllOnClick->setChecked(settings.value("SelectAllTextOnClick", false).toBool());
|
||||
ui->addCountryWithAlt->setChecked(settings.value("AddCountryDomainWithAltKey", true).toBool());
|
||||
ui->showLoadingInAddressBar->setChecked(settings.value("ShowLoadingProgress", false).toBool());
|
||||
settings.endGroup();
|
||||
|
||||
//BROWSING
|
||||
@ -867,6 +868,7 @@ void Preferences::saveSettings()
|
||||
settings.setValue("SelectAllTextOnDoubleClick", ui->selectAllOnFocus->isChecked());
|
||||
settings.setValue("SelectAllTextOnClick", ui->selectAllOnClick->isChecked());
|
||||
settings.setValue("AddCountryDomainWithAltKey", ui->addCountryWithAlt->isChecked());
|
||||
settings.setValue("ShowLoadingProgress", ui->showLoadingInAddressBar->isChecked());
|
||||
settings.endGroup();
|
||||
|
||||
//Languages
|
||||
|
@ -602,147 +602,18 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="stackedWidgetPage3">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
<string><b>Tabs behavior</b></string>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget_3">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer_9">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_16">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QCheckBox" name="hideTabsOnTab">
|
||||
<property name="text">
|
||||
<string>Hide tabs when there is only one tab</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QCheckBox" name="activateLastTab">
|
||||
<property name="text">
|
||||
<string>Activate last tab when closing active tab</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="QCheckBox" name="openNewTabAfterActive">
|
||||
<property name="text">
|
||||
<string>Open new tabs after active tab</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="1">
|
||||
<widget class="QCheckBox" name="dontQuitOnTab">
|
||||
<property name="text">
|
||||
<string>Don't quit upon closing last tab</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="1">
|
||||
<widget class="QCheckBox" name="askWhenClosingMultipleTabs">
|
||||
<property name="text">
|
||||
<string>Ask when closing multiple tabs</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="14" column="1">
|
||||
<widget class="QCheckBox" name="closedInsteadOpened">
|
||||
<property name="text">
|
||||
<string>Closed tabs list instead of opened in tab bar</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="15" column="1">
|
||||
<spacer name="verticalSpacer_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="16" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_25">
|
||||
<property name="text">
|
||||
<string><b>Address Bar behaviour</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="18" column="1" colspan="2">
|
||||
<widget class="QCheckBox" name="selectAllOnFocus">
|
||||
<property name="text">
|
||||
<string>Select all text by double clicking in address bar</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="19" column="1">
|
||||
<widget class="QCheckBox" name="selectAllOnClick">
|
||||
<property name="text">
|
||||
<string>Select all text by clicking in address bar</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="20" column="1">
|
||||
<widget class="QCheckBox" name="addCountryWithAlt">
|
||||
<property name="text">
|
||||
<string>Add .co.uk domain by pressing ALT key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="21" column="1">
|
||||
<spacer name="verticalSpacer_8">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="11" column="1">
|
||||
<widget class="QCheckBox" name="switchToNewTabs">
|
||||
<property name="text">
|
||||
<string>Automatically switch to newly opened tab</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QWidget" name="tab_6">
|
||||
<attribute name="title">
|
||||
<string>Tabs behavior</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_15">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="showTabPreviews">
|
||||
@ -774,9 +645,91 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_16">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>63</width>
|
||||
<height>13</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="17" column="1" colspan="2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="hideTabsOnTab">
|
||||
<property name="text">
|
||||
<string>Hide tabs when there is only one tab</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="activateLastTab">
|
||||
<property name="text">
|
||||
<string>Activate last tab when closing active tab</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="openNewTabAfterActive">
|
||||
<property name="text">
|
||||
<string>Open new tabs after active tab</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="switchToNewTabs">
|
||||
<property name="text">
|
||||
<string>Automatically switch to newly opened tab</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="dontQuitOnTab">
|
||||
<property name="text">
|
||||
<string>Don't quit upon closing last tab</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="askWhenClosingMultipleTabs">
|
||||
<property name="text">
|
||||
<string>Ask when closing multiple tabs</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="closedInsteadOpened">
|
||||
<property name="text">
|
||||
<string>Closed tabs list instead of opened in tab bar</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_8">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_7">
|
||||
<attribute name="title">
|
||||
<string>Address Bar behavior</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_16">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_59">
|
||||
@ -833,6 +786,51 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="showLoadingInAddressBar">
|
||||
<property name="text">
|
||||
<string>Show loading progress in address bar</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="selectAllOnFocus">
|
||||
<property name="text">
|
||||
<string>Select all text by double clicking in address bar</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="selectAllOnClick">
|
||||
<property name="text">
|
||||
<string>Select all text by clicking in address bar</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="addCountryWithAlt">
|
||||
<property name="text">
|
||||
<string>Add .co.uk domain by pressing ALT key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="stackedWidgetPage4">
|
||||
|
@ -49,7 +49,7 @@ TabbedWebView::TabbedWebView(QupZilla* mainClass, WebTab* webTab)
|
||||
, m_rssChecked(false)
|
||||
{
|
||||
connect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted()));
|
||||
connect(this, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int)));
|
||||
connect(this, SIGNAL(loadProgress(int)), this, SLOT(loadProgress(int)));
|
||||
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished()));
|
||||
|
||||
connect(this, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl)));
|
||||
@ -128,7 +128,7 @@ void TabbedWebView::urlChanged(const QUrl &url)
|
||||
}
|
||||
}
|
||||
|
||||
void TabbedWebView::slotLoadProgress(int prog)
|
||||
void TabbedWebView::loadProgress(int prog)
|
||||
{
|
||||
if (prog > 60) {
|
||||
checkRss();
|
||||
|
@ -63,7 +63,7 @@ public slots:
|
||||
void showIcon();
|
||||
|
||||
void slotLoadStarted();
|
||||
void slotLoadProgress(int prog);
|
||||
void loadProgress(int prog);
|
||||
|
||||
void userLoadAction(const QUrl &url);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user