mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-17 15:31:20 +00:00
Merge remote-tracking branch 'origin/KDE/4.10'
This commit is contained in:
commit
ced9de5b82
|
@ -44,7 +44,7 @@
|
|||
|
||||
KItemListController::KItemListController(KItemModelBase* model, KItemListView* view, QObject* parent) :
|
||||
QObject(parent),
|
||||
m_singleClickActivation(KGlobalSettings::singleClick()),
|
||||
m_singleClickActivationEnforced(false),
|
||||
m_selectionTogglePressed(false),
|
||||
m_clearSelectionIfItemsAreNotDragged(false),
|
||||
m_selectionBehavior(NoSelection),
|
||||
|
@ -190,14 +190,14 @@ int KItemListController::autoActivationDelay() const
|
|||
return m_autoActivationTimer->interval();
|
||||
}
|
||||
|
||||
void KItemListController::setSingleClickActivation(bool singleClick)
|
||||
void KItemListController::setSingleClickActivationEnforced(bool singleClick)
|
||||
{
|
||||
m_singleClickActivation = singleClick;
|
||||
m_singleClickActivationEnforced = singleClick;
|
||||
}
|
||||
|
||||
bool KItemListController::singleClickActivation() const
|
||||
bool KItemListController::singleClickActivationEnforced() const
|
||||
{
|
||||
return m_singleClickActivation;
|
||||
return m_singleClickActivationEnforced;
|
||||
}
|
||||
|
||||
bool KItemListController::showEvent(QShowEvent* event)
|
||||
|
@ -756,7 +756,7 @@ bool KItemListController::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, con
|
|||
} else if (shiftOrControlPressed) {
|
||||
// The mouse click should only update the selection, not trigger the item
|
||||
emitItemActivated = false;
|
||||
} else if (!m_singleClickActivation) {
|
||||
} else if (!(KGlobalSettings::singleClick() || m_singleClickActivationEnforced)) {
|
||||
emitItemActivated = false;
|
||||
}
|
||||
if (emitItemActivated) {
|
||||
|
@ -786,7 +786,7 @@ bool KItemListController::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event,
|
|||
}
|
||||
}
|
||||
|
||||
bool emitItemActivated = !m_singleClickActivation &&
|
||||
bool emitItemActivated = !(KGlobalSettings::singleClick() || m_singleClickActivationEnforced) &&
|
||||
(event->button() & Qt::LeftButton) &&
|
||||
index >= 0 && index < m_model->count();
|
||||
if (emitItemActivated) {
|
||||
|
|
|
@ -129,12 +129,11 @@ public:
|
|||
|
||||
/**
|
||||
* If set to true, the signals itemActivated() and itemsActivated() are emitted
|
||||
* after a single-click of the left mouse button. If set to false, a double-click
|
||||
* is required. Per default the setting from KGlobalSettings::singleClick() is
|
||||
* used.
|
||||
* after a single-click of the left mouse button. If set to false (the default),
|
||||
* the setting from KGlobalSettings::singleClick() is used.
|
||||
*/
|
||||
void setSingleClickActivation(bool singleClick);
|
||||
bool singleClickActivation() const;
|
||||
void setSingleClickActivationEnforced(bool singleClick);
|
||||
bool singleClickActivationEnforced() const;
|
||||
|
||||
virtual bool showEvent(QShowEvent* event);
|
||||
virtual bool hideEvent(QHideEvent* event);
|
||||
|
@ -301,7 +300,7 @@ private:
|
|||
void updateExtendedSelectionRegion();
|
||||
|
||||
private:
|
||||
bool m_singleClickActivation;
|
||||
bool m_singleClickActivationEnforced;
|
||||
bool m_selectionTogglePressed;
|
||||
bool m_clearSelectionIfItemsAreNotDragged;
|
||||
SelectionBehavior m_selectionBehavior;
|
||||
|
|
|
@ -152,7 +152,7 @@ void FoldersPanel::showEvent(QShowEvent* event)
|
|||
m_controller->setAutoActivationBehavior(KItemListController::ExpansionOnly);
|
||||
m_controller->setMouseDoubleClickAction(KItemListController::ActivateAndExpandItem);
|
||||
m_controller->setAutoActivationDelay(750);
|
||||
m_controller->setSingleClickActivation(true);
|
||||
m_controller->setSingleClickActivationEnforced(true);
|
||||
|
||||
connect(m_controller, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int)));
|
||||
connect(m_controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));
|
||||
|
|
|
@ -110,7 +110,7 @@ void PlacesPanel::showEvent(QShowEvent* event)
|
|||
|
||||
m_controller = new KItemListController(m_model, m_view, this);
|
||||
m_controller->setSelectionBehavior(KItemListController::SingleSelection);
|
||||
m_controller->setSingleClickActivation(true);
|
||||
m_controller->setSingleClickActivationEnforced(true);
|
||||
|
||||
readSettings();
|
||||
|
||||
|
|
|
@ -29,6 +29,11 @@
|
|||
#include "kitemviews/private/kitemlistviewlayouter.h"
|
||||
#include "testdir.h"
|
||||
|
||||
#include <KConfigGroup>
|
||||
#include <KGlobalSettings>
|
||||
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
||||
namespace {
|
||||
const int DefaultTimeout = 2000;
|
||||
};
|
||||
|
@ -51,6 +56,7 @@ private slots:
|
|||
|
||||
void testKeyboardNavigation_data();
|
||||
void testKeyboardNavigation();
|
||||
void testMouseClickActivation();
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -506,6 +512,108 @@ void KItemListControllerTest::testKeyboardNavigation()
|
|||
}
|
||||
}
|
||||
|
||||
void KItemListControllerTest::testMouseClickActivation()
|
||||
{
|
||||
m_view->setItemLayout(KFileItemListView::IconsLayout);
|
||||
|
||||
// Make sure that we have a large window, such that
|
||||
// the items are visible and clickable.
|
||||
adjustGeometryForColumnCount(5);
|
||||
|
||||
// Make sure that the first item is visible in the view.
|
||||
QTest::keyClick(m_container, Qt::Key_End, Qt::NoModifier);
|
||||
QTest::keyClick(m_container, Qt::Key_Home, Qt::NoModifier);
|
||||
while (m_view->firstVisibleIndex() > 0) {
|
||||
QTest::qWait(50);
|
||||
}
|
||||
|
||||
const QPointF pos = m_view->itemContextRect(0).center();
|
||||
|
||||
// Save the "single click" setting.
|
||||
const bool restoreKGlobalSettingsSingleClick = KGlobalSettings::singleClick();
|
||||
|
||||
KConfig config("kcminputrc");
|
||||
KConfigGroup group = config.group("KDE");
|
||||
|
||||
QGraphicsSceneMouseEvent mousePressEvent(QEvent::GraphicsSceneMousePress);
|
||||
mousePressEvent.setPos(pos);
|
||||
mousePressEvent.setButton(Qt::LeftButton);
|
||||
mousePressEvent.setButtons(Qt::LeftButton);
|
||||
|
||||
QGraphicsSceneMouseEvent mouseReleaseEvent(QEvent::GraphicsSceneMouseRelease);
|
||||
mouseReleaseEvent.setPos(pos);
|
||||
mouseReleaseEvent.setButton(Qt::LeftButton);
|
||||
mouseReleaseEvent.setButtons(Qt::NoButton);
|
||||
|
||||
QSignalSpy spyItemActivated(m_controller, SIGNAL(itemActivated(int)));
|
||||
|
||||
// Default setting: single click activation.
|
||||
group.writeEntry("SingleClick", true, KConfig::Persistent|KConfig::Global);
|
||||
config.sync();
|
||||
KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged, KGlobalSettings::SETTINGS_MOUSE);
|
||||
while (!KGlobalSettings::singleClick()) {
|
||||
QTest::qWait(50);
|
||||
}
|
||||
m_view->event(&mousePressEvent);
|
||||
m_view->event(&mouseReleaseEvent);
|
||||
QCOMPARE(spyItemActivated.count(), 1);
|
||||
spyItemActivated.clear();
|
||||
|
||||
// Set the global setting to "double click activation".
|
||||
group.writeEntry("SingleClick", false, KConfig::Persistent|KConfig::Global);
|
||||
config.sync();
|
||||
KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged, KGlobalSettings::SETTINGS_MOUSE);
|
||||
while (KGlobalSettings::singleClick()) {
|
||||
QTest::qWait(50);
|
||||
}
|
||||
m_view->event(&mousePressEvent);
|
||||
m_view->event(&mouseReleaseEvent);
|
||||
QCOMPARE(spyItemActivated.count(), 0);
|
||||
spyItemActivated.clear();
|
||||
|
||||
// Enforce single click activation in the controller.
|
||||
m_controller->setSingleClickActivationEnforced(true);
|
||||
m_view->event(&mousePressEvent);
|
||||
m_view->event(&mouseReleaseEvent);
|
||||
QCOMPARE(spyItemActivated.count(), 1);
|
||||
spyItemActivated.clear();
|
||||
|
||||
// Do not enforce single click activation in the controller.
|
||||
m_controller->setSingleClickActivationEnforced(false);
|
||||
m_view->event(&mousePressEvent);
|
||||
m_view->event(&mouseReleaseEvent);
|
||||
QCOMPARE(spyItemActivated.count(), 0);
|
||||
spyItemActivated.clear();
|
||||
|
||||
// Set the global setting back to "single click activation".
|
||||
group.writeEntry("SingleClick", true, KConfig::Persistent|KConfig::Global);
|
||||
config.sync();
|
||||
KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged, KGlobalSettings::SETTINGS_MOUSE);
|
||||
while (!KGlobalSettings::singleClick()) {
|
||||
QTest::qWait(50);
|
||||
}
|
||||
m_view->event(&mousePressEvent);
|
||||
m_view->event(&mouseReleaseEvent);
|
||||
QCOMPARE(spyItemActivated.count(), 1);
|
||||
spyItemActivated.clear();
|
||||
|
||||
// Enforce single click activation in the controller.
|
||||
m_controller->setSingleClickActivationEnforced(true);
|
||||
m_view->event(&mousePressEvent);
|
||||
m_view->event(&mouseReleaseEvent);
|
||||
QCOMPARE(spyItemActivated.count(), 1);
|
||||
spyItemActivated.clear();
|
||||
|
||||
// Restore previous settings.
|
||||
m_controller->setSingleClickActivationEnforced(true);
|
||||
group.writeEntry("SingleClick", restoreKGlobalSettingsSingleClick, KConfig::Persistent|KConfig::Global);
|
||||
config.sync();
|
||||
KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged, KGlobalSettings::SETTINGS_MOUSE);
|
||||
while (KGlobalSettings::singleClick() != restoreKGlobalSettingsSingleClick) {
|
||||
QTest::qWait(50);
|
||||
}
|
||||
}
|
||||
|
||||
void KItemListControllerTest::adjustGeometryForColumnCount(int count)
|
||||
{
|
||||
const QSize size = m_view->itemSize().toSize();
|
||||
|
|
Loading…
Reference in a new issue