Git commit 7e9360d913a4ca1d5d3f4e7a98441f864bdbfe54 by Jan Kundr?t. Committed on 27/11/2012 at 20:40. Pushed by jkt into branch 'master'.
GUI: show the URL where a hyperlink points to in the status bar It is surprisingly hard to do this as a tool tip -- at least my attempts have failed: - Calling QWidget::setToolTip on the SImplePartWidget has no visible effect. - Calling QToolTip::showText() indeed shows a tool tip, but it disappears after less than a second (and there *was* an if-clause to not set that upon seeing empty links). -> Showing that in the status bar is good enough. fixes #585 M +7 -0 src/Gui/MessageView.cpp M +2 -0 src/Gui/MessageView.h M +6 -0 src/Gui/SimplePartWidget.cpp M +2 -0 src/Gui/SimplePartWidget.h M +6 -0 src/Gui/Window.cpp M +1 -0 src/Gui/Window.h http://commits.kde.org/trojita/7e9360d913a4ca1d5d3f4e7a98441f864bdbfe54 diff --git a/src/Gui/MessageView.cpp b/src/Gui/MessageView.cpp index f82e1e4..bc7da67 100644 --- a/src/Gui/MessageView.cpp +++ b/src/Gui/MessageView.cpp @@ -518,4 +518,11 @@ void MessageView::partContextMenuRequested(const QPoint &point) } } +void MessageView::partLinkHovered(const QString &link, const QString &title, const QString &textContent) +{ + Q_UNUSED(title); + Q_UNUSED(textContent); + emit linkHovered(link); +} + } diff --git a/src/Gui/MessageView.h b/src/Gui/MessageView.h index b4aa6f9..80c13a6 100644 --- a/src/Gui/MessageView.h +++ b/src/Gui/MessageView.h @@ -83,8 +83,10 @@ private slots: void handleDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); void headerLinkActivated(QString); void partContextMenuRequested(const QPoint &point); + void partLinkHovered(const QString &link, const QString &title, const QString &textContent); signals: void messageChanged(); + void linkHovered(const QString &url); private: bool eventFilter(QObject *object, QEvent *event); Imap::Message::Envelope envelope() const; diff --git a/src/Gui/SimplePartWidget.cpp b/src/Gui/SimplePartWidget.cpp index dbeb7b7..774cd74 100644 --- a/src/Gui/SimplePartWidget.cpp +++ b/src/Gui/SimplePartWidget.cpp @@ -137,6 +137,12 @@ QList<QAction *> SimplePartWidget::contextMenuSpecificActions() const void SimplePartWidget::connectGuiInteractionEvents(QObject *guiInteractionTarget) { connect(this, SIGNAL(customContextMenuRequested(QPoint)), guiInteractionTarget, SLOT(partContextMenuRequested(QPoint))); + + // The targets expect the sender() of the signal to be a SimplePartWidget, not a QWebPage, + // which means we have to do this indirection + connect(page(), SIGNAL(linkHovered(QString,QString,QString)), this, SIGNAL(linkHovered(QString,QString,QString))); + connect(this, SIGNAL(linkHovered(QString,QString,QString)), + guiInteractionTarget, SLOT(partLinkHovered(QString,QString,QString))); } } diff --git a/src/Gui/SimplePartWidget.h b/src/Gui/SimplePartWidget.h index a1ce600..793eef6 100644 --- a/src/Gui/SimplePartWidget.h +++ b/src/Gui/SimplePartWidget.h @@ -61,6 +61,8 @@ private slots: void slotTransferError(const QString &errorString); void slotFileNameRequested(QString *fileName); void slotMarkupPlainText(); +signals: + void linkHovered(const QString &link, const QString &title, const QString &textContent); private: QAction *saveAction; Imap::Network::FileDownloadManager *fileDownloadManager; diff --git a/src/Gui/Window.cpp b/src/Gui/Window.cpp index a9a9b41..274826b 100644 --- a/src/Gui/Window.cpp +++ b/src/Gui/Window.cpp @@ -419,6 +419,7 @@ void MainWindow::createWidgets() area->setWidget(msgView); area->setWidgetResizable(true); connect(msgView, SIGNAL(messageChanged()), this, SLOT(scrollMessageUp())); + connect(msgView, SIGNAL(linkHovered(QString)), this, SLOT(slotShowLinkTarget(QString))); if (QSettings().value(Common::SettingsNames::appLoadHomepage, QVariant(true)).toBool() && !QSettings().value(Common::SettingsNames::imapStartOffline).toBool()) { msgView->setHomepageUrl(QUrl(QString::fromUtf8("http://welcome.trojita.flaska.net/%1").arg(QCoreApplication::applicationVersion()))); @@ -1208,6 +1209,11 @@ void MainWindow::showConnectionStatus(QObject *parser, Imap::ConnectionState sta statusBar()->showMessage(message, transient ? DURATION : 0); } +void MainWindow::slotShowLinkTarget(const QString &link) +{ + statusBar()->showMessage(tr("Link target: %1").arg(link)); +} + void MainWindow::slotShowAboutTrojita() { QMessageBox::about(this, trUtf8("About Trojit?"), diff --git a/src/Gui/Window.h b/src/Gui/Window.h index 3834fb3..2ac1b8d 100644 --- a/src/Gui/Window.h +++ b/src/Gui/Window.h @@ -124,6 +124,7 @@ private slots: void updateMessageFlags(const QModelIndex &index); void scrollMessageUp(); void showConnectionStatus(QObject *parser, Imap::ConnectionState state); + void slotShowLinkTarget(const QString &link); void slotShowAboutTrojita(); void slotDonateToTrojita();
