From 4f4529ae09452299661327ce7092b6d169fd9774 Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Sat, 18 Aug 2012 15:39:11 +0000 Subject: [PATCH] (trunk, qt) #4624 "Inconsistent behavior when clicking on items at the torrent list" -- apply a nice patch by dirleyrls --- qt/mainwin.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/qt/mainwin.cc b/qt/mainwin.cc index 3c0f0d392..ab5ca851a 100644 --- a/qt/mainwin.cc +++ b/qt/mainwin.cc @@ -46,6 +46,27 @@ #define PREFS_KEY "prefs-key"; + +/** + * This is a proxy-style for that forces it to be always disabled. + * We use this to make our torrent list view behave consistently on + * both GTK and Qt implementations. + */ +class ListViewProxyStyle: public QProxyStyle +{ + public: + int styleHint(StyleHint hint, + const QStyleOption *option = 0, + const QWidget *widget = 0, + QStyleHintReturn *returnData = 0) const + { + if (hint == QStyle::SH_ItemView_ActivateItemOnSingleClick) + return 0; + return QProxyStyle::styleHint(hint, option, widget, returnData); + } +}; + + QIcon TrMainWindow :: getStockIcon( const QString& name, int fallback ) { @@ -106,6 +127,8 @@ TrMainWindow :: TrMainWindow( Session& session, Prefs& prefs, TorrentModel& mode int i = style->pixelMetric( QStyle::PM_SmallIconSize, 0, this ); const QSize smallIconSize( i, i ); + ui.listView->setStyle(new ListViewProxyStyle); + // icons ui.action_OpenFile->setIcon( getStockIcon( "folder-open", QStyle::SP_DialogOpenButton ) ); ui.action_New->setIcon( getStockIcon( "document-new", QStyle::SP_DesktopIcon ) ); @@ -171,6 +194,7 @@ TrMainWindow :: TrMainWindow( Session& session, Prefs& prefs, TorrentModel& mode connect( ui.action_SetLocation, SIGNAL(triggered()), this, SLOT(setLocation())); connect( ui.action_Properties, SIGNAL(triggered()), this, SLOT(openProperties())); connect( ui.action_SessionDialog, SIGNAL(triggered()), mySessionDialog, SLOT(show())); + connect( ui.listView, SIGNAL(activated(const QModelIndex&)), ui.action_Properties, SLOT(trigger())); // signals