From d1c2b9aa84940a1f5469bbc7d705695136128c3e Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Tue, 23 Jul 2013 20:42:06 +0200 Subject: [PATCH] Fixed icon theme initial loading bug, added middle mouse link navigation. --- src/gui/basewebview.cpp | 27 ++- src/gui/basewebview.h | 9 + src/gui/formsettings.cpp | 5 + src/gui/formsettings.ui | 508 +++++++++++++++++++-------------------- src/gui/themefactory.cpp | 17 +- src/gui/webbrowser.cpp | 2 +- 6 files changed, 302 insertions(+), 266 deletions(-) diff --git a/src/gui/basewebview.cpp b/src/gui/basewebview.cpp index c08220c9f..fbceeff09 100644 --- a/src/gui/basewebview.cpp +++ b/src/gui/basewebview.cpp @@ -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); diff --git a/src/gui/basewebview.h b/src/gui/basewebview.h index 49060abe0..64173d3db 100644 --- a/src/gui/basewebview.h +++ b/src/gui/basewebview.h @@ -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; diff --git a/src/gui/formsettings.cpp b/src/gui/formsettings.cpp index b7bbcb6e8..8f9404d8a 100644 --- a/src/gui/formsettings.cpp +++ b/src/gui/formsettings.cpp @@ -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() { diff --git a/src/gui/formsettings.ui b/src/gui/formsettings.ui index 016499ea0..60e25903f 100644 --- a/src/gui/formsettings.ui +++ b/src/gui/formsettings.ui @@ -14,58 +14,10 @@ Settings - - - - - 150 - 16777215 - - - - 0 - - - - General - - - - - Keyboard shortcuts - - - - - User interface - - - - - Language - - - - - Proxy - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - 2 + 4 @@ -163,7 +115,7 @@ QTabWidget::North - 2 + 1 @@ -209,14 +161,14 @@ - disable + Disable - enable + Enable true @@ -256,53 +208,6 @@ - - - Web browser - - - - - - Color of website loading progress bar - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 20 - - - - - - - &Change... - - - - - - - Use custom color for web browser progress bar - - - true - - - - - - - - Miscellaneous - - - - QFormLayout::AllNonFixedFieldsGrow - - - @@ -346,7 +251,7 @@ - + 0 @@ -359,133 +264,258 @@ 0 - - - - Type - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - Host - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - true - - - Hostname or IP of your proxy server - - - - - - - Port - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - true - - - 65535 - - - 80 - - - - - - - - - Username - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - true - - - Your username for proxy server authentication - - - - - - - Password - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - true - - - QLineEdit::PasswordEchoOnEdit - - - Your password for proxy server authentication - - - - - - - true - - - Display password - - - - - - - Password is stored in plain string in RSS Guard configuration file. - - - true + + + + 0 + + + Web browser + + + + + + Use custom color for web browser progress bar + + + true + + + + + + + Color of website loading progress bar + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 20 + + + + + + + &Change... + + + + + + + Enable mouse gestures + + + + + + + Mouse gestures work with left mouse button. Possible gestures are: +<ul> +<li>previous web page (drag mouse left)</li> +<li>next web page (drag mouse right)</li> +<li>reload current web page (drag mouse up)</li> +<li>open new web browser tab (drag mouse down)</li> +</ul> + + + Qt::RichText + + + 20 + + + + + + + + Proxy + + + + + + Type + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Host + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + true + + + Hostname or IP of your proxy server + + + + + + + Port + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + true + + + 65535 + + + 80 + + + + + + + + + Username + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + true + + + Your username for proxy server authentication + + + + + + + Password + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + true + + + QLineEdit::PasswordEchoOnEdit + + + Your password for proxy server authentication + + + + + + + true + + + Display password + + + + + + + Password is stored in plain string in RSS Guard configuration file. + + + true + + + + + + + + + + 150 + 16777215 + + + + -1 + + + + General + + + + + Keyboard shortcuts + + + + + User interface + + + + + Language + + + + + Web browser & proxy + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + @@ -550,7 +580,7 @@ m_radioTrayOn toggled(bool) m_lblTrayClose - setVisible(bool) + setEnabled(bool) 370 @@ -566,7 +596,7 @@ m_radioTrayOn toggled(bool) m_cmbTrayClose - setVisible(bool) + setEnabled(bool) 370 @@ -582,7 +612,7 @@ m_radioTrayOn toggled(bool) m_checkHidden - setVisible(bool) + setEnabled(bool) 417 @@ -594,37 +624,5 @@ - - m_checkBrowserProgressColor - toggled(bool) - m_btnBrowserProgressColor - setVisible(bool) - - - 416 - 48 - - - 519 - 74 - - - - - m_checkBrowserProgressColor - toggled(bool) - m_lblBrowserProgressColor - setVisible(bool) - - - 416 - 48 - - - 275 - 73 - - - diff --git a/src/gui/themefactory.cpp b/src/gui/themefactory.cpp index 89a3a5446..8e4bb56ab 100644 --- a/src/gui/themefactory.cpp +++ b/src/gui/themefactory.cpp @@ -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()); } } diff --git a/src/gui/webbrowser.cpp b/src/gui/webbrowser.cpp index c2888cba9..5ae5f0daa 100644 --- a/src/gui/webbrowser.cpp +++ b/src/gui/webbrowser.cpp @@ -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); } }