Constructing a KColorScheme object is very expensive because of a number
of tint computations. When scrolling a big list more than 30 % of the
time was spent here. Instead, we can precompute and store the inactive
text color. (see https://git.reviewboard.kde.org/r/100826/)
Thanks to Samuel Rødal for the patch!
#include "dolphinmodel.h"
#include <KColorScheme>
#include <KFileItem>
#include "dolphinmodel.h"
#include <KColorScheme>
#include <KFileItem>
+#include <KGlobalSettings>
#include <KIcon>
#include <KIconLoader>
#include <KStringHandler>
#include <KIcon>
#include <KIconLoader>
#include <KStringHandler>
KFileItemDelegate(parent),
m_hasMinimizedNameColumn(false),
m_cachedSize(),
KFileItemDelegate(parent),
m_hasMinimizedNameColumn(false),
m_cachedSize(),
+ m_cachedEmblems(),
+ m_cachedInactiveTextColorDirty(true)
{
setJobTransfersVisible(true);
{
setJobTransfersVisible(true);
+ connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), this, SLOT(handleDisplayPaletteChange()));
}
DolphinFileItemDelegate::~DolphinFileItemDelegate()
}
DolphinFileItemDelegate::~DolphinFileItemDelegate()
// Use the inactive text color for all columns except the name column. This indicates for the user that
// hovering other columns does not change the actions context.
QPalette palette = opt.palette;
// Use the inactive text color for all columns except the name column. This indicates for the user that
// hovering other columns does not change the actions context.
QPalette palette = opt.palette;
- const QColor textColor = KColorScheme(QPalette::Active).foreground(KColorScheme::InactiveText).color();
- palette.setColor(QPalette::Text, textColor);
+ if (m_cachedInactiveTextColorDirty) {
+ m_cachedInactiveTextColor = KColorScheme(QPalette::Active).foreground(KColorScheme::InactiveText).color();
+ m_cachedInactiveTextColorDirty = false;
+ }
+ palette.setColor(QPalette::Text, m_cachedInactiveTextColor);
+void DolphinFileItemDelegate::handleDisplayPaletteChange()
+{
+ m_cachedInactiveTextColorDirty = true;
+}
+
void DolphinFileItemDelegate::adjustOptionWidth(QStyleOptionViewItemV4& option,
const QAbstractProxyModel* proxyModel,
const DolphinModel* dolphinModel,
void DolphinFileItemDelegate::adjustOptionWidth(QStyleOptionViewItemV4& option,
const QAbstractProxyModel* proxyModel,
const DolphinModel* dolphinModel,
*/
class DolphinFileItemDelegate : public KFileItemDelegate
{
*/
class DolphinFileItemDelegate : public KFileItemDelegate
{
public:
explicit DolphinFileItemDelegate(QObject* parent = 0);
virtual ~DolphinFileItemDelegate();
public:
explicit DolphinFileItemDelegate(QObject* parent = 0);
virtual ~DolphinFileItemDelegate();
*/
static int nameColumnWidth(const QString& name, const QStyleOptionViewItem& option);
*/
static int nameColumnWidth(const QString& name, const QStyleOptionViewItem& option);
+private slots:
+ void handleDisplayPaletteChange();
+
private:
static void adjustOptionWidth(QStyleOptionViewItemV4& option,
const QAbstractProxyModel* proxyModel,
private:
static void adjustOptionWidth(QStyleOptionViewItemV4& option,
const QAbstractProxyModel* proxyModel,
bool m_hasMinimizedNameColumn;
mutable QSize m_cachedSize;
mutable QPixmap m_cachedEmblems[KVersionControlPlugin::LocallyModifiedUnstagedVersion + 1];
bool m_hasMinimizedNameColumn;
mutable QSize m_cachedSize;
mutable QPixmap m_cachedEmblems[KVersionControlPlugin::LocallyModifiedUnstagedVersion + 1];
+ mutable QColor m_cachedInactiveTextColor;
+ mutable bool m_cachedInactiveTextColorDirty;
};
inline void DolphinFileItemDelegate::setMinimizedNameColumn(bool minimized)
};
inline void DolphinFileItemDelegate::setMinimizedNameColumn(bool minimized)