mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
Merge remote-tracking branch 'origin/KDE/4.13'
This commit is contained in:
commit
4e574ffae5
|
@ -538,11 +538,10 @@ bool KItemListController::mousePressEvent(QGraphicsSceneMouseEvent* event, const
|
|||
m_pressedIndex = m_view->itemAt(m_pressedMousePos);
|
||||
emit mouseButtonPressed(m_pressedIndex, event->buttons());
|
||||
|
||||
if ((event->buttons() & (Qt::XButton1 | Qt::XButton2)) && m_pressedIndex < 0) {
|
||||
// Do not select items when clicking the empty part of the view with
|
||||
// the back/forward buttons, see https://bugs.kde.org/show_bug.cgi?id=327412.
|
||||
// Note that clicking an item with these buttons selects it, see comment in
|
||||
// DolphinView::slotMouseButtonPressed(int, Qt::MouseButtons).
|
||||
// TODO: Qt5: Replace Qt::XButton1 by Qt::BackButton and Qt::XButton2 by Qt::ForwardButton
|
||||
if (event->buttons() & (Qt::XButton1 | Qt::XButton2)) {
|
||||
// Do not select items when clicking the back/forward buttons, see
|
||||
// https://bugs.kde.org/show_bug.cgi?id=327412.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -952,8 +951,13 @@ bool KItemListController::hoverMoveEvent(QGraphicsSceneHoverEvent* event, const
|
|||
|
||||
if (newHoveredWidget) {
|
||||
newHoveredWidget->setHovered(true);
|
||||
const QPointF mappedPos = newHoveredWidget->mapFromItem(m_view, pos);
|
||||
newHoveredWidget->setHoverPosition(mappedPos);
|
||||
emit itemHovered(newHoveredWidget->index());
|
||||
}
|
||||
} else if (oldHoveredWidget) {
|
||||
const QPointF mappedPos = oldHoveredWidget->mapFromItem(m_view, pos);
|
||||
oldHoveredWidget->setHoverPosition(mappedPos);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -279,6 +279,13 @@ bool KItemListWidget::isHovered() const
|
|||
return m_hovered;
|
||||
}
|
||||
|
||||
void KItemListWidget::setHoverPosition(const QPointF& pos)
|
||||
{
|
||||
if (m_selectionToggle) {
|
||||
m_selectionToggle->setHovered(m_selectionToggle->contains(pos));
|
||||
}
|
||||
}
|
||||
|
||||
void KItemListWidget::setAlternateBackground(bool enable)
|
||||
{
|
||||
if (m_alternateBackground != enable) {
|
||||
|
|
|
@ -108,6 +108,8 @@ public:
|
|||
void setHovered(bool hovered);
|
||||
bool isHovered() const;
|
||||
|
||||
void setHoverPosition(const QPointF& pos);
|
||||
|
||||
void setAlternateBackground(bool enable);
|
||||
bool alternateBackground() const;
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ KItemListSelectionToggle::KItemListSelectionToggle(QGraphicsItem* parent) :
|
|||
m_checked(false),
|
||||
m_hovered(false)
|
||||
{
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
|
||||
KItemListSelectionToggle::~KItemListSelectionToggle()
|
||||
|
@ -51,6 +50,15 @@ bool KItemListSelectionToggle::isChecked() const
|
|||
return m_checked;
|
||||
}
|
||||
|
||||
void KItemListSelectionToggle::setHovered(bool hovered)
|
||||
{
|
||||
if (m_hovered != hovered) {
|
||||
m_hovered = hovered;
|
||||
m_pixmap = QPixmap();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void KItemListSelectionToggle::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
|
@ -65,20 +73,6 @@ void KItemListSelectionToggle::paint(QPainter* painter, const QStyleOptionGraphi
|
|||
painter->drawPixmap(x, y, m_pixmap);
|
||||
}
|
||||
|
||||
void KItemListSelectionToggle::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
|
||||
{
|
||||
QGraphicsWidget::hoverEnterEvent(event);
|
||||
m_hovered = true;
|
||||
m_pixmap = QPixmap();
|
||||
}
|
||||
|
||||
void KItemListSelectionToggle::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
|
||||
{
|
||||
QGraphicsWidget::hoverLeaveEvent(event);
|
||||
m_hovered = false;
|
||||
m_pixmap = QPixmap();
|
||||
}
|
||||
|
||||
void KItemListSelectionToggle::resizeEvent(QGraphicsSceneResizeEvent* event)
|
||||
{
|
||||
QGraphicsWidget::resizeEvent(event);
|
||||
|
@ -97,12 +91,9 @@ void KItemListSelectionToggle::resizeEvent(QGraphicsSceneResizeEvent* event)
|
|||
|
||||
void KItemListSelectionToggle::updatePixmap()
|
||||
{
|
||||
const char* icon = m_checked ? "list-remove" : "list-add";
|
||||
m_pixmap = KIconLoader::global()->loadIcon(QLatin1String(icon), KIconLoader::NoGroup, iconSize());
|
||||
|
||||
if (m_hovered) {
|
||||
KIconLoader::global()->iconEffect()->apply(m_pixmap, KIconLoader::Desktop, KIconLoader::ActiveState);
|
||||
}
|
||||
const QString icon = m_checked ? "list-remove" : "list-add";
|
||||
const KIconLoader::States state = m_hovered ? KIconLoader::ActiveState : KIconLoader::DisabledState;
|
||||
m_pixmap = KIconLoader::global()->loadIcon(icon, KIconLoader::Desktop, iconSize(), state);
|
||||
}
|
||||
|
||||
int KItemListSelectionToggle::iconSize() const
|
||||
|
|
|
@ -41,11 +41,11 @@ public:
|
|||
void setChecked(bool checked);
|
||||
bool isChecked() const;
|
||||
|
||||
void setHovered(bool hovered);
|
||||
|
||||
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
|
||||
|
||||
protected:
|
||||
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event);
|
||||
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
|
||||
virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
|
||||
|
||||
private:
|
||||
|
|
|
@ -1046,6 +1046,7 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
|
|||
if (op && destUrl == url()) {
|
||||
// Mark the dropped urls as selected.
|
||||
m_clearSelectionBeforeSelectingNewItems = true;
|
||||
m_markFirstNewlySelectedItemAsCurrent = true;
|
||||
connect(op, SIGNAL(aboutToCreate(KUrl::List)), this, SLOT(slotAboutToCreate(KUrl::List)));
|
||||
}
|
||||
|
||||
|
@ -1070,17 +1071,15 @@ void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* prev
|
|||
|
||||
void DolphinView::slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons)
|
||||
{
|
||||
Q_UNUSED(itemIndex);
|
||||
|
||||
hideToolTip();
|
||||
|
||||
if (itemIndex < 0) {
|
||||
// Trigger the history navigation only when clicking on the viewport:
|
||||
// Above an item the XButtons provide a simple way to select items in
|
||||
// the singleClick mode.
|
||||
if (buttons & Qt::XButton1) {
|
||||
emit goBackRequested();
|
||||
} else if (buttons & Qt::XButton2) {
|
||||
emit goForwardRequested();
|
||||
}
|
||||
// TODO: Qt5: Replace Qt::XButton1 by Qt::BackButton and Qt::XButton2 by Qt::ForwardButton
|
||||
if (buttons & Qt::XButton1) {
|
||||
emit goBackRequested();
|
||||
} else if (buttons & Qt::XButton2) {
|
||||
emit goForwardRequested();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue