1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-19 15:29:42 +01:00

Fix jumpy scrolling in Account Settings.

This commit is contained in:
Teo Mrnjavac 2013-01-17 11:46:17 +01:00
parent 3d94dc13e7
commit e7014caecb
6 changed files with 92 additions and 8 deletions

View File

@ -61,6 +61,7 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
SocialWidget.cpp
widgets/ContainedMenuButton.cpp
widgets/AccountListView.cpp
widgets/AccountListWidget.cpp
widgets/AccountModelFactoryProxy.cpp
widgets/AccountWidget.cpp

View File

@ -55,7 +55,7 @@
</layout>
</item>
<item>
<widget class="QListView" name="accountsView">
<widget class="AccountListView" name="accountsView">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
@ -76,6 +76,11 @@
<header>thirdparty/Qocoa/qbutton.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>AccountListView</class>
<extends>QListView</extends>
<header>widgets/AccountListView.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@ -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 )

View File

@ -23,6 +23,14 @@
#include <QStyledItemDelegate>
#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

View File

@ -0,0 +1,38 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "AccountListView.h"
#include "accounts/AccountDelegate.h"
#include <QScrollBar>
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 );
}

View File

@ -0,0 +1,38 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef ACCOUNTLISTVIEW_H
#define ACCOUNTLISTVIEW_H
#include <QListView>
/**
* @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