mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
Folders Panel: Activate folders on single-click
Even if double-click is used as default setting, the folders panel should open folders with a single-click. BUG: 289971 FIXED-IN: 4.8.0
This commit is contained in:
parent
af93bc46bc
commit
7a364cbf48
3 changed files with 24 additions and 2 deletions
|
@ -41,6 +41,7 @@
|
||||||
|
|
||||||
KItemListController::KItemListController(QObject* parent) :
|
KItemListController::KItemListController(QObject* parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
|
m_singleClickActivation(KGlobalSettings::singleClick()),
|
||||||
m_selectionTogglePressed(false),
|
m_selectionTogglePressed(false),
|
||||||
m_selectionBehavior(NoSelection),
|
m_selectionBehavior(NoSelection),
|
||||||
m_model(0),
|
m_model(0),
|
||||||
|
@ -142,6 +143,16 @@ int KItemListController::autoActivationDelay() const
|
||||||
return m_autoActivationTimer->interval();
|
return m_autoActivationTimer->interval();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KItemListController::setSingleClickActivation(bool singleClick)
|
||||||
|
{
|
||||||
|
m_singleClickActivation = singleClick;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KItemListController::singleClickActivation() const
|
||||||
|
{
|
||||||
|
return m_singleClickActivation;
|
||||||
|
}
|
||||||
|
|
||||||
bool KItemListController::showEvent(QShowEvent* event)
|
bool KItemListController::showEvent(QShowEvent* event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
|
@ -577,7 +588,7 @@ bool KItemListController::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, con
|
||||||
} else if (shiftOrControlPressed) {
|
} else if (shiftOrControlPressed) {
|
||||||
// The mouse click should only update the selection, not trigger the item
|
// The mouse click should only update the selection, not trigger the item
|
||||||
emitItemActivated = false;
|
emitItemActivated = false;
|
||||||
} else if (!KGlobalSettings::singleClick()) {
|
} else if (!m_singleClickActivation) {
|
||||||
emitItemActivated = false;
|
emitItemActivated = false;
|
||||||
}
|
}
|
||||||
if (emitItemActivated) {
|
if (emitItemActivated) {
|
||||||
|
@ -598,7 +609,7 @@ bool KItemListController::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event,
|
||||||
const QPointF pos = transform.map(event->pos());
|
const QPointF pos = transform.map(event->pos());
|
||||||
const int index = m_view->itemAt(pos);
|
const int index = m_view->itemAt(pos);
|
||||||
|
|
||||||
bool emitItemActivated = !KGlobalSettings::singleClick() &&
|
bool emitItemActivated = !m_singleClickActivation &&
|
||||||
(event->button() & Qt::LeftButton) &&
|
(event->button() & Qt::LeftButton) &&
|
||||||
index >= 0 && index < m_model->count();
|
index >= 0 && index < m_model->count();
|
||||||
if (emitItemActivated) {
|
if (emitItemActivated) {
|
||||||
|
|
|
@ -104,6 +104,15 @@ public:
|
||||||
void setAutoActivationDelay(int delay);
|
void setAutoActivationDelay(int delay);
|
||||||
int autoActivationDelay() const;
|
int autoActivationDelay() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
void setSingleClickActivation(bool singleClick);
|
||||||
|
bool singleClickActivation() const;
|
||||||
|
|
||||||
virtual bool showEvent(QShowEvent* event);
|
virtual bool showEvent(QShowEvent* event);
|
||||||
virtual bool hideEvent(QHideEvent* event);
|
virtual bool hideEvent(QHideEvent* event);
|
||||||
virtual bool keyPressEvent(QKeyEvent* event);
|
virtual bool keyPressEvent(QKeyEvent* event);
|
||||||
|
@ -249,6 +258,7 @@ private:
|
||||||
qreal keyboardAnchorPos(int index) const;
|
qreal keyboardAnchorPos(int index) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool m_singleClickActivation;
|
||||||
bool m_selectionTogglePressed;
|
bool m_selectionTogglePressed;
|
||||||
SelectionBehavior m_selectionBehavior;
|
SelectionBehavior m_selectionBehavior;
|
||||||
KItemModelBase* m_model;
|
KItemModelBase* m_model;
|
||||||
|
|
|
@ -174,6 +174,7 @@ void FoldersPanel::showEvent(QShowEvent* event)
|
||||||
m_controller->setModel(model);
|
m_controller->setModel(model);
|
||||||
m_controller->setSelectionBehavior(KItemListController::SingleSelection);
|
m_controller->setSelectionBehavior(KItemListController::SingleSelection);
|
||||||
m_controller->setAutoActivationDelay(750);
|
m_controller->setAutoActivationDelay(750);
|
||||||
|
m_controller->setSingleClickActivation(true);
|
||||||
|
|
||||||
connect(m_controller, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int)));
|
connect(m_controller, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int)));
|
||||||
connect(m_controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));
|
connect(m_controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));
|
||||||
|
|
Loading…
Reference in a new issue