diff options
author | Fabian Müller <fmueller@owncloud.com> | 2022-09-14 17:41:47 +0300 |
---|---|---|
committer | Fabian Müller <fmueller@owncloud.com> | 2022-09-16 17:11:47 +0300 |
commit | d4be3b9ccdfb00eff940f2377fa044eebc790fac (patch) | |
tree | 935ca67024a2c12b8c2efe01b9902cd73727e884 | |
parent | c8f69a83a3ec148c7873270cb140abef650da47b (diff) |
Improve opening spaces' web URLswork/spacesdelegate2
-rw-r--r-- | src/gui/spaces/spacesdelegate.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/gui/spaces/spacesdelegate.cpp b/src/gui/spaces/spacesdelegate.cpp index 21256c0a8..e2ace017a 100644 --- a/src/gui/spaces/spacesdelegate.cpp +++ b/src/gui/spaces/spacesdelegate.cpp @@ -21,6 +21,7 @@ #include "spacesmodel.h" #include <QApplication> +#include <QDebug> #include <QDesktopServices> #include <QMouseEvent> #include <QPainter> @@ -28,6 +29,8 @@ using namespace OCC::Spaces; +Q_LOGGING_CATEGORY(lcSpacesDelegate, "spaces.delegate") + void SpacesDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { const auto *style = option.widget->style(); @@ -131,14 +134,19 @@ bool SpacesDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const // TODO: simulate "click on button" visually, too (i.e., render button accordingly) if (event->type() == QEvent::MouseButtonRelease) { auto opt = openBrowserButtonRect(option); + auto *mouseEvent = static_cast<QMouseEvent *>(event); // we need to make sure the mouse click is within the button's boundary box if (opt.rect.contains(mouseEvent->localPos().toPoint())) { const auto url = index.data().toUrl(); - if (url.isValid()) { - QDesktopServices::openUrl(index.data().toUrl()); + // we only display the button when the URL is valid (see above) + Q_ASSERT(url.isValid()); + + // log when opening fails + if (!QDesktopServices::openUrl(url)) { + qCWarning(lcSpacesDelegate) << "failed to open browser for URL" << url; } return true; |