diff options
Diffstat (limited to 'src/libaudqt/treeview.cc')
-rw-r--r-- | src/libaudqt/treeview.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/libaudqt/treeview.cc b/src/libaudqt/treeview.cc index 4e8bfaf..188175d 100644 --- a/src/libaudqt/treeview.cc +++ b/src/libaudqt/treeview.cc @@ -21,13 +21,44 @@ #include <QKeyEvent> #include <QMouseEvent> +#include <QProxyStyle> + #include <libaudcore/index.h> namespace audqt { +/* + * On some platforms (mainly KDE), there is a feature where + * clicking on icons makes them work like hyperlinks. Unfortunately, + * the way this is implemented is by making all QAbstractItemView + * widgets behave in this way. + * + * In all situations, it makes no sense for audqt::TreeView + * widgets to behave in this way. So we override that feature + * with a QProxyStyle. + */ +class TreeViewStyleOverrides : public QProxyStyle +{ +public: + int styleHint(StyleHint hint, + const QStyleOption * option = nullptr, + const QWidget * widget = nullptr, + QStyleHintReturn * returnData = nullptr) const override + { + if (hint == QStyle::SH_ItemView_ActivateItemOnSingleClick) + return 0; + + return QProxyStyle::styleHint(hint, option, widget, returnData); + } +}; + EXPORT TreeView::TreeView(QWidget * parent) : QTreeView(parent) { + auto style = new TreeViewStyleOverrides; + connect(this, &QObject::destroyed, [style]() { delete style; }); + setStyle(style); + // activate() is perhaps a bit redundant with activated() connect(this, &QTreeView::activated, this, &TreeView::activate); } |