-/***************************************************************************
- * Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com> *
- * *
- * Based on the Itemviews NG project from Trolltech Labs *
- * *
- * This program 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 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program 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 this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
- ***************************************************************************/
+/*
+ * SPDX-FileCopyrightText: 2011 Peter Penz <peter.penz19@gmail.com>
+ *
+ * Based on the Itemviews NG project from Trolltech Labs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
#include "kitemlistwidget.h"
#include "kitemlistview.h"
#include "private/kitemlistselectiontoggle.h"
+#include <KConfigGroup>
+#include <KSharedConfig>
+
#include <QApplication>
#include <QPainter>
#include <QPropertyAnimation>
m_hoverOpacity(0),
m_hoverCache(nullptr),
m_hoverAnimation(nullptr),
+ m_hoverSequenceIndex(0),
m_selectionToggle(nullptr),
m_editedRole()
{
+ connect(&m_hoverSequenceTimer, &QTimer::timeout, this, &KItemListWidget::slotHoverSequenceTimerTimeout);
}
KItemListWidget::~KItemListWidget()
m_data = data;
dataChanged(m_data);
} else {
- foreach (const QByteArray& role, roles) {
+ for (const QByteArray& role : roles) {
m_data[role] = data[role];
}
dataChanged(m_data, roles);
}
m_hoverAnimation->stop();
+ m_hoverSequenceIndex = 0;
+
if (hovered) {
const qreal startValue = qMax(hoverOpacity(), qreal(0.1));
m_hoverAnimation->setStartValue(startValue);
if (m_enabledSelectionToggle && !(QApplication::mouseButtons() & Qt::LeftButton)) {
initializeSelectionToggle();
}
+
+ hoverSequenceStarted();
+
+ const KConfigGroup globalConfig(KSharedConfig::openConfig(), "PreviewSettings");
+ const int interval = globalConfig.readEntry("HoverSequenceInterval", 700);
+
+ m_hoverSequenceTimer.start(interval);
} else {
m_hoverAnimation->setStartValue(hoverOpacity());
m_hoverAnimation->setEndValue(0.0);
+
+ hoverSequenceEnded();
+ m_hoverSequenceTimer.stop();
}
m_hoverAnimation->start();
}
}
+void KItemListWidget::hoverSequenceStarted()
+{
+}
+
+void KItemListWidget::hoverSequenceIndexChanged(int sequenceIndex)
+{
+ Q_UNUSED(sequenceIndex);
+}
+
+void KItemListWidget::hoverSequenceEnded()
+{
+}
+
qreal KItemListWidget::hoverOpacity() const
{
return m_hoverOpacity;
}
+int KItemListWidget::hoverSequenceIndex() const
+{
+ return m_hoverSequenceIndex;
+}
+
void KItemListWidget::slotHoverAnimationFinished()
{
if (!m_hovered && m_selectionToggle) {
}
}
+void KItemListWidget::slotHoverSequenceTimerTimeout()
+{
+ m_hoverSequenceIndex++;
+ hoverSequenceIndexChanged(m_hoverSequenceIndex);
+}
+
void KItemListWidget::initializeSelectionToggle()
{
Q_ASSERT(m_enabledSelectionToggle);