mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 03:40:16 +02:00
Fix jumpy scrolling in Account Settings.
This commit is contained in:
@@ -61,6 +61,7 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
|
|||||||
SocialWidget.cpp
|
SocialWidget.cpp
|
||||||
|
|
||||||
widgets/ContainedMenuButton.cpp
|
widgets/ContainedMenuButton.cpp
|
||||||
|
widgets/AccountListView.cpp
|
||||||
widgets/AccountListWidget.cpp
|
widgets/AccountListWidget.cpp
|
||||||
widgets/AccountModelFactoryProxy.cpp
|
widgets/AccountModelFactoryProxy.cpp
|
||||||
widgets/AccountWidget.cpp
|
widgets/AccountWidget.cpp
|
||||||
|
@@ -55,7 +55,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListView" name="accountsView">
|
<widget class="AccountListView" name="accountsView">
|
||||||
<property name="alternatingRowColors">
|
<property name="alternatingRowColors">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
@@ -76,6 +76,11 @@
|
|||||||
<header>thirdparty/Qocoa/qbutton.h</header>
|
<header>thirdparty/Qocoa/qbutton.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>AccountListView</class>
|
||||||
|
<extends>QListView</extends>
|
||||||
|
<header>widgets/AccountListView.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
@@ -39,12 +39,6 @@
|
|||||||
#define PADDING_BETWEEN_STARS 2
|
#define PADDING_BETWEEN_STARS 2
|
||||||
#define STAR_SIZE 12
|
#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 ICONSIZE 40
|
||||||
#define WRENCH_SIZE 24
|
#define WRENCH_SIZE 24
|
||||||
#define SMALL_WRENCH_SIZE 16
|
#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
|
// Haven't calculated normal item height yet, do it once and save it
|
||||||
QStyleOptionViewItemV4 opt( option );
|
QStyleOptionViewItemV4 opt( option );
|
||||||
initStyleOption( &opt, index );
|
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 )
|
if ( rowType == AccountModel::TopLevelAccount || rowType == AccountModel::UniqueFactory || rowType == AccountModel::CustomAccount )
|
||||||
|
@@ -23,6 +23,14 @@
|
|||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
#include "accounts/AccountModel.h"
|
#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;
|
class AnimatedSpinner;
|
||||||
|
|
||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
|
38
src/widgets/AccountListView.cpp
Normal file
38
src/widgets/AccountListView.cpp
Normal 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 );
|
||||||
|
}
|
38
src/widgets/AccountListView.h
Normal file
38
src/widgets/AccountListView.h
Normal 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
|
Reference in New Issue
Block a user