Fixed icon theme initial loading bug, added middle mouse link navigation.

This commit is contained in:
Martin Rotter 2013-07-23 20:42:06 +02:00
parent eb604bb848
commit d1c2b9aa84
6 changed files with 302 additions and 266 deletions

View File

@ -28,8 +28,7 @@ void BaseWebView::onLoadFinished(bool ok) {
}
void BaseWebView::createConnections() {
connect(this, &BaseWebView::loadFinished,
this, &BaseWebView::onLoadFinished);
connect(this, &BaseWebView::loadFinished, this, &BaseWebView::onLoadFinished);
}
void BaseWebView::setupIcons() {
@ -98,6 +97,30 @@ void BaseWebView::contextMenuEvent(QContextMenuEvent *event) {
context_menu.exec(mapToGlobal(event->pos()));
}
void BaseWebView::mousePressEvent(QMouseEvent *event) {
if (event->buttons() & Qt::MiddleButton) {
QWebHitTestResult hit_result = page()->mainFrame()->hitTestContent(event->pos());
// Check if user clicked with middle mouse button on some
// hyperlink.
if (hit_result.linkUrl().isValid()) {
emit linkMiddleClicked(hit_result.linkUrl());
// No more handling of event is now needed. Return.
return;
}
}
// TODO: Add mouse gestures (from quite-rss).
QWebView::mousePressEvent(event);
}
void BaseWebView::mouseReleaseEvent(QMouseEvent *event) {
QWebView::mousePressEvent(event);
}
void BaseWebView::paintEvent(QPaintEvent *event) {
QWebView::paintEvent(event);

View File

@ -18,6 +18,11 @@ class BaseWebView : public QWebView {
void setupIcons();
signals:
// Is emitted if user wants to open some hyperlink in new
// web browser tab.
void linkMiddleClicked(const QUrl &link_url);
protected slots:
// Executes if loading of any page is done.
void onLoadFinished(bool ok);
@ -37,6 +42,10 @@ class BaseWebView : public QWebView {
// Provides custom context menu.
void contextMenuEvent(QContextMenuEvent *event);
// Provides custom mouse actions.
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
private:
BaseWebPage *m_page;

View File

@ -96,6 +96,11 @@ void FormSettings::onProxyTypeChanged(int index) {
m_ui->m_txtProxyUsername->setEnabled(is_proxy_selected);
m_ui->m_spinProxyPort->setEnabled(is_proxy_selected);
m_ui->m_checkShowPassword->setEnabled(is_proxy_selected);
m_ui->m_lblProxyHost->setEnabled(is_proxy_selected);
m_ui->m_lblProxyInfo->setEnabled(is_proxy_selected);
m_ui->m_lblProxyPassword->setEnabled(is_proxy_selected);
m_ui->m_lblProxyPort->setEnabled(is_proxy_selected);
m_ui->m_lblProxyUsername->setEnabled(is_proxy_selected);
}
void FormSettings::loadProxy() {

View File

@ -14,58 +14,10 @@
<string>Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QListWidget" name="m_listSettings">
<property name="maximumSize">
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<property name="currentRow">
<number>0</number>
</property>
<item>
<property name="text">
<string>General</string>
</property>
</item>
<item>
<property name="text">
<string>Keyboard shortcuts</string>
</property>
</item>
<item>
<property name="text">
<string>User interface</string>
</property>
</item>
<item>
<property name="text">
<string>Language</string>
</property>
</item>
<item>
<property name="text">
<string>Proxy</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QDialogButtonBox" name="m_buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QStackedWidget" name="m_stackedSettings">
<property name="currentIndex">
<number>2</number>
<number>4</number>
</property>
<widget class="QWidget" name="m_pageGeneral">
<layout class="QFormLayout" name="formLayout_5">
@ -163,7 +115,7 @@
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>2</number>
<number>1</number>
</property>
<widget class="QWidget" name="m_tabIconSkin">
<attribute name="title">
@ -209,14 +161,14 @@
<item row="0" column="0" colspan="2">
<widget class="QRadioButton" name="m_radioTrayOff">
<property name="text">
<string>disable</string>
<string>Disable</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QRadioButton" name="m_radioTrayOn">
<property name="text">
<string>enable</string>
<string>Enable</string>
</property>
<property name="checked">
<bool>true</bool>
@ -256,53 +208,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="m_tabWebBrowser">
<attribute name="title">
<string>Web browser</string>
</attribute>
<layout class="QFormLayout" name="formLayout_7">
<item row="1" column="0">
<widget class="QLabel" name="m_lblBrowserProgressColor">
<property name="text">
<string>Color of website loading progress bar</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="indent">
<number>20</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="m_btnBrowserProgressColor">
<property name="text">
<string>&amp;Change...</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="m_checkBrowserProgressColor">
<property name="text">
<string>Use custom color for web browser progress bar</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="m_tabMisc">
<attribute name="title">
<string>Miscellaneous</string>
</attribute>
<layout class="QFormLayout" name="formLayout_4">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
</layout>
</widget>
</widget>
</item>
</layout>
@ -346,7 +251,7 @@
</layout>
</widget>
<widget class="QWidget" name="m_pageProxy">
<layout class="QFormLayout" name="formLayout_6">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="leftMargin">
<number>0</number>
</property>
@ -359,133 +264,258 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="m_lblProxyType">
<property name="text">
<string>Type</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="m_cmbProxyType"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="m_lblProxyHost">
<property name="text">
<string>Host</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLineEdit" name="m_txtProxyHost">
<property name="enabled">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>Hostname or IP of your proxy server</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="m_lblProxyPort">
<property name="text">
<string>Port</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="m_spinProxyPort">
<property name="enabled">
<bool>true</bool>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>80</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="m_lblProxyUsername">
<property name="text">
<string>Username</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="m_txtProxyUsername">
<property name="enabled">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>Your username for proxy server authentication</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="m_lblProxyPassword">
<property name="text">
<string>Password</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="m_txtProxyPassword">
<property name="enabled">
<bool>true</bool>
</property>
<property name="echoMode">
<enum>QLineEdit::PasswordEchoOnEdit</enum>
</property>
<property name="placeholderText">
<string>Your password for proxy server authentication</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="m_checkShowPassword">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Display password</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="m_lblProxyInfo">
<property name="text">
<string>Password is stored in plain string in RSS Guard configuration file.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Web browser</string>
</attribute>
<layout class="QFormLayout" name="formLayout_4">
<item row="0" column="0">
<widget class="QCheckBox" name="m_checkBrowserProgressColor">
<property name="text">
<string>Use custom color for web browser progress bar</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="m_lblBrowserProgressColor">
<property name="text">
<string>Color of website loading progress bar</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="indent">
<number>20</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="m_btnBrowserProgressColor">
<property name="text">
<string>&amp;Change...</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="m_checkMouseGestures">
<property name="text">
<string>Enable mouse gestures</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="m_lblMouseGestures">
<property name="text">
<string>Mouse gestures work with left mouse button. Possible gestures are:
&lt;ul&gt;
&lt;li&gt;previous web page (drag mouse left)&lt;/li&gt;
&lt;li&gt;next web page (drag mouse right)&lt;/li&gt;
&lt;li&gt;reload current web page (drag mouse up)&lt;/li&gt;
&lt;li&gt;open new web browser tab (drag mouse down)&lt;/li&gt;
&lt;/ul&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="indent">
<number>20</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Proxy</string>
</attribute>
<layout class="QFormLayout" name="formLayout_6">
<item row="0" column="0">
<widget class="QLabel" name="m_lblProxyType">
<property name="text">
<string>Type</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="m_cmbProxyType"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="m_lblProxyHost">
<property name="text">
<string>Host</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLineEdit" name="m_txtProxyHost">
<property name="enabled">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>Hostname or IP of your proxy server</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="m_lblProxyPort">
<property name="text">
<string>Port</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="m_spinProxyPort">
<property name="enabled">
<bool>true</bool>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>80</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="m_lblProxyUsername">
<property name="text">
<string>Username</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="m_txtProxyUsername">
<property name="enabled">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>Your username for proxy server authentication</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="m_lblProxyPassword">
<property name="text">
<string>Password</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="m_txtProxyPassword">
<property name="enabled">
<bool>true</bool>
</property>
<property name="echoMode">
<enum>QLineEdit::PasswordEchoOnEdit</enum>
</property>
<property name="placeholderText">
<string>Your password for proxy server authentication</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="m_checkShowPassword">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Display password</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="m_lblProxyInfo">
<property name="text">
<string>Password is stored in plain string in RSS Guard configuration file.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="0" column="0">
<widget class="QListWidget" name="m_listSettings">
<property name="maximumSize">
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<property name="currentRow">
<number>-1</number>
</property>
<item>
<property name="text">
<string>General</string>
</property>
</item>
<item>
<property name="text">
<string>Keyboard shortcuts</string>
</property>
</item>
<item>
<property name="text">
<string>User interface</string>
</property>
</item>
<item>
<property name="text">
<string>Language</string>
</property>
</item>
<item>
<property name="text">
<string>Web browser &amp; proxy</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QDialogButtonBox" name="m_buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
@ -550,7 +580,7 @@
<sender>m_radioTrayOn</sender>
<signal>toggled(bool)</signal>
<receiver>m_lblTrayClose</receiver>
<slot>setVisible(bool)</slot>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>370</x>
@ -566,7 +596,7 @@
<sender>m_radioTrayOn</sender>
<signal>toggled(bool)</signal>
<receiver>m_cmbTrayClose</receiver>
<slot>setVisible(bool)</slot>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>370</x>
@ -582,7 +612,7 @@
<sender>m_radioTrayOn</sender>
<signal>toggled(bool)</signal>
<receiver>m_checkHidden</receiver>
<slot>setVisible(bool)</slot>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>417</x>
@ -594,37 +624,5 @@
</hint>
</hints>
</connection>
<connection>
<sender>m_checkBrowserProgressColor</sender>
<signal>toggled(bool)</signal>
<receiver>m_btnBrowserProgressColor</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>416</x>
<y>48</y>
</hint>
<hint type="destinationlabel">
<x>519</x>
<y>74</y>
</hint>
</hints>
</connection>
<connection>
<sender>m_checkBrowserProgressColor</sender>
<signal>toggled(bool)</signal>
<receiver>m_lblBrowserProgressColor</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>416</x>
<y>48</y>
</hint>
<hint type="destinationlabel">
<x>275</x>
<y>73</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -71,19 +71,20 @@ void ThemeFactory::loadCurrentIconTheme() {
if (!installed_themes.contains(theme_name)) {
qDebug("Icon theme '%s' cannot be loaded because it is not installed.",
qPrintable(theme_name));
return;
}
else {
qDebug("Loading theme '%s'.", qPrintable(theme_name));
QIcon::setThemeName(theme_name);
}
// In Linux, we need to deliver custom event for all widgets
// to make sure they get a chance to redraw their icons.
// NOTE: This is NOT necessarily needed on Windows.
foreach (QWidget *widget, QtSingleApplication::allWidgets()) {
QtSingleApplication::postEvent((QObject*) widget,
new ThemeFactoryEvent());
}
// We need to deliver custom event for all widgets
// to make sure they get a chance to setup their icons.
// NOTE: Event is delivered even if custom icon theme is not set
// as active, because all widgets need to do initial
// icons initialization based in the event receival.
foreach (QWidget *widget, QtSingleApplication::allWidgets()) {
QtSingleApplication::postEvent((QObject*) widget,
new ThemeFactoryEvent());
}
}

View File

@ -91,7 +91,7 @@ void WebBrowser::navigateToUrl(const QString &textual_url) {
QUrl extracted_url = QUrl::fromUserInput(textual_url);
if (extracted_url.isValid()) {
m_webView->setUrl(extracted_url);
m_webView->load(extracted_url);
}
}