diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 07f014fdb..3c75fd18a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -61,6 +61,7 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui} SocialWidget.cpp widgets/ContainedMenuButton.cpp + widgets/AccountListView.cpp widgets/AccountListWidget.cpp widgets/AccountModelFactoryProxy.cpp widgets/AccountWidget.cpp diff --git a/src/Settings_Accounts.ui b/src/Settings_Accounts.ui index a0154bcba..54063e91d 100644 --- a/src/Settings_Accounts.ui +++ b/src/Settings_Accounts.ui @@ -55,7 +55,7 @@ - + true @@ -76,6 +76,11 @@
thirdparty/Qocoa/qbutton.h
1 + + AccountListView + QListView +
widgets/AccountListView.h
+
diff --git a/src/libtomahawk/accounts/AccountDelegate.cpp b/src/libtomahawk/accounts/AccountDelegate.cpp index ac64bd964..2786e33d2 100644 --- a/src/libtomahawk/accounts/AccountDelegate.cpp +++ b/src/libtomahawk/accounts/AccountDelegate.cpp @@ -39,12 +39,6 @@ #define PADDING_BETWEEN_STARS 2 #define STAR_SIZE 12 -#ifdef Q_OS_MAC -#define ROW_HEIGHT_MULTIPLIER 4.9 -#else -#define ROW_HEIGHT_MULTIPLIER 5.7 -#endif - #define ICONSIZE 40 #define WRENCH_SIZE 24 #define SMALL_WRENCH_SIZE 16 @@ -72,7 +66,7 @@ AccountDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex // Haven't calculated normal item height yet, do it once and save it QStyleOptionViewItemV4 opt( option ); initStyleOption( &opt, index ); - m_accountRowHeight = ROW_HEIGHT_MULTIPLIER * opt.fontMetrics.height(); + m_accountRowHeight = ACCOUNT_DELEGATE_ROW_HEIGHT_MULTIPLIER * opt.fontMetrics.height(); } if ( rowType == AccountModel::TopLevelAccount || rowType == AccountModel::UniqueFactory || rowType == AccountModel::CustomAccount ) diff --git a/src/libtomahawk/accounts/AccountDelegate.h b/src/libtomahawk/accounts/AccountDelegate.h index ab5cc86ef..d32fa4141 100644 --- a/src/libtomahawk/accounts/AccountDelegate.h +++ b/src/libtomahawk/accounts/AccountDelegate.h @@ -23,6 +23,14 @@ #include #include "accounts/AccountModel.h" + +#ifdef Q_OS_MAC +#define ACCOUNT_DELEGATE_ROW_HEIGHT_MULTIPLIER 4.9 +#else +#define ACCOUNT_DELEGATE_ROW_HEIGHT_MULTIPLIER 5.7 +#endif + + class AnimatedSpinner; namespace Tomahawk diff --git a/src/widgets/AccountListView.cpp b/src/widgets/AccountListView.cpp new file mode 100644 index 000000000..f60659290 --- /dev/null +++ b/src/widgets/AccountListView.cpp @@ -0,0 +1,38 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2013, Teo Mrnjavac + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#include "AccountListView.h" +#include "accounts/AccountDelegate.h" + +#include + +AccountListView::AccountListView( QWidget* parent ) + : QListView( parent ) +{} + +void +AccountListView::wheelEvent( QWheelEvent* e ) +{ + //HACK: Workaround for QTBUG-7232: Smooth scrolling (scroll per pixel) in ItemViews + // does not work as expected. +#ifdef Q_WS_X11 + verticalScrollBar()->setSingleStep( ACCOUNT_DELEGATE_ROW_HEIGHT_MULTIPLIER * fontMetrics().height() / 8 ); + // ^ scroll step is 1/8 of the estimated row height +#endif + QListView::wheelEvent( e ); +} diff --git a/src/widgets/AccountListView.h b/src/widgets/AccountListView.h new file mode 100644 index 000000000..63627e95e --- /dev/null +++ b/src/widgets/AccountListView.h @@ -0,0 +1,38 @@ +/* === This file is part of Tomahawk Player - === + * + * Copyright 2013, Teo Mrnjavac + * + * Tomahawk is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tomahawk is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tomahawk. If not, see . + */ + +#ifndef ACCOUNTLISTVIEW_H +#define ACCOUNTLISTVIEW_H + +#include + +/** + * @brief The AccountListView class does not add functionality, it just implements a + * much needed workaround that fixes a scrolling issue with large delegates. + */ +class AccountListView : public QListView +{ + Q_OBJECT +public: + explicit AccountListView( QWidget* parent = 0 ); + +protected: + void wheelEvent( QWheelEvent* ); +}; + +#endif // ACCOUNTLISTVIEW_H