Commit be4f76bf authored by Nikita Melnichenko's avatar Nikita Melnichenko

Added an option to reset file selection on a mouse click without modifiers

The option "A plain mouse button resets selection" reset selection
on a mouse click without modifiers (i.e. Shift or Ctrl).
Selection with Shift/Ctrl for the mouse button have to be enabled
for this setting to work.

ADDED: Option to reset file selection on a mouse click without modifiers
GUI: Added Konfigurator option for resetting file selection

Discussion: !25
parents 97755954 bccae8b6
......@@ -657,10 +657,12 @@ void KgPanel::setupMouseModeTab()
{"Custom Selection Mode", "Immediate Context Menu", _ImmediateContextMenu,
i18n("Right clicking pops context menu immediately"), true,
i18n("If checked, right clicking will result in an immediate showing of the context menu.\nOtherwise, user needs to click and hold the right mouse button for 500ms.") },
{"Custom Selection Mode", "Reset Selection Items", _ResetSelectionItems,
i18n("A plain mouse button resets selection"), true,
i18n("Reset selection on a mouse click without modifiers (i.e. Shift or Ctrl).\nSelection with Shift/Ctrl for the mouse button have to be enabled for this setting to work.") },
};
mouseCheckboxes = createCheckBoxGroup(1, 0, mouseCheckboxesParam, 11 /*count*/, mouseDetailGroup, PAGE_MOUSE);
mouseCheckboxes = createCheckBoxGroup(1, 0, mouseCheckboxesParam, 12 /*count*/, mouseDetailGroup, PAGE_MOUSE);
mouseDetailGrid->addWidget(mouseCheckboxes, 1, 0);
for (int i = 0; i < mouseCheckboxes->count(); i++)
......@@ -816,6 +818,7 @@ void KgPanel::slotSelectionModeChanged()
mouseCheckboxes->find("Space Calc Space")->setChecked(selectionMode->spaceCalculatesDiskSpace());
mouseCheckboxes->find("Insert Moves Down")->setChecked(selectionMode->insertMovesDown());
mouseCheckboxes->find("Immediate Context Menu")->setChecked(selectionMode->showContextMenu() == -1);
mouseCheckboxes->find("Reset Selection Items")->setChecked(selectionMode->resetSelectionItems());
}
void KgPanel::slotMouseCheckBoxChanged()
......
......@@ -66,7 +66,7 @@ bool KrMouseHandler::mousePressEvent(QMouseEvent *e)
_clickedItem = item;
else {
// clear the current selection
_view->changeSelection(KrQuery("*"), false, true);
_view->unselectAll();
item->setSelected(true);
}
}
......@@ -78,7 +78,7 @@ bool KrMouseHandler::mousePressEvent(QMouseEvent *e)
&& !KrSelectionMode::getSelectionHandler()->leftButtonPreservesSelection()) {
// clear the current selection
_view->changeSelection(KrQuery("*"), false, true);
_view->unselectAll();
}
}
e->accept();
......@@ -134,7 +134,7 @@ bool KrMouseHandler::mousePressEvent(QMouseEvent *e)
_clickedItem = item;
} else {
// clear the current selection
_view->changeSelection(KrQuery("*"), false, true);
_view->unselectAll();
item->setSelected(true);
}
}
......@@ -181,21 +181,36 @@ bool KrMouseHandler::mouseReleaseEvent(QMouseEvent *e)
{
if (e->button() == Qt::LeftButton)
_dragStartPos = QPoint(-1, -1);
KrViewItem * item = _view->getKrViewItemAt(e->pos());
auto mode = KrSelectionMode::getSelectionHandler();
if (item && item == _clickedItem) {
if (((e->button() == Qt::LeftButton) && (e->modifiers() == Qt::NoModifier) &&
(KrSelectionMode::getSelectionHandler()->leftButtonSelects()) &&
!(KrSelectionMode::getSelectionHandler()->leftButtonPreservesSelection())) ||
(mode->leftButtonSelects()) &&
!(mode->leftButtonPreservesSelection())) ||
((e->button() == Qt::RightButton) && (e->modifiers() == Qt::NoModifier) &&
(KrSelectionMode::getSelectionHandler()->rightButtonSelects()) &&
!(KrSelectionMode::getSelectionHandler()->rightButtonPreservesSelection()))) {
(mode->rightButtonSelects()) &&
!(mode->rightButtonPreservesSelection()))) {
// clear the current selection
_view->changeSelection(KrQuery("*"), false, true);
_view->unselectAll();
item->setSelected(true);
}
}
if (mode->resetSelectionItems()) {
bool leftButtonClicked = (e->button() == Qt::LeftButton) && (e->modifiers() == Qt::NoModifier);
bool rightButtonClicked = (e->button() == Qt::RightButton) && (e->modifiers() == Qt::NoModifier);
bool leftTriggerCondition = !mode->leftButtonSelects() && mode->shiftCtrlLeftButtonSelects();
bool rightTriggerCondition = !mode->rightButtonSelects() && mode->shiftCtrlRightButtonSelects();
if ((leftButtonClicked && leftTriggerCondition) || (rightButtonClicked && rightTriggerCondition)) {
// clear the current selection
_view->unselectAll();
}
}
if (e->button() == Qt::RightButton) {
_rightClickedItem = nullptr;
_contextMenuTimer.stop();
......
......@@ -97,5 +97,6 @@ void UserSelectionMode::init()
_spaceCalculatesDiskSpace = group.readEntry("Space Calc Space", _SpaceCalcSpace);
_insertMovesDown = group.readEntry("Insert Moves Down", _InsertMovesDown);
_showContextMenu = (group.readEntry("Immediate Context Menu", _ImmediateContextMenu) ? -1 : 500);
_resetSelectionItems = group.readEntry("Reset Selection Items", _ResetSelectionItems);
}
......@@ -76,6 +76,9 @@ public:
inline int showContextMenu() {
return _showContextMenu;
} // 0: no, -1: yes, n>0: after n milliseconds
inline int resetSelectionItems() {
return _resetSelectionItems;
}
virtual ~KrSelectionMode() {}
......@@ -84,6 +87,7 @@ protected:
bool _rightButtonSelects, _leftButtonSelects, _rightButtonPreservesSelection;
bool _leftButtonPreservesSelection, _shiftCtrlRightButtonSelects, _shiftCtrlLeftButtonSelects;
int _showContextMenu;
int _resetSelectionItems;
};
class KonqSelectionMode : public KrSelectionMode
......@@ -101,6 +105,7 @@ public:
_shiftCtrlRightButtonSelects = false;
_shiftCtrlLeftButtonSelects = false;
_showContextMenu = -1;
_resetSelectionItems = false;
}
};
......@@ -119,6 +124,7 @@ public:
_shiftCtrlRightButtonSelects = false;
_shiftCtrlLeftButtonSelects = false;
_showContextMenu = -1;
_resetSelectionItems = false;
}
};
......@@ -137,6 +143,7 @@ public:
_shiftCtrlRightButtonSelects = false;
_shiftCtrlLeftButtonSelects = true;
_showContextMenu = 500;
_resetSelectionItems = false;
}
};
......@@ -155,6 +162,7 @@ public:
_shiftCtrlRightButtonSelects = false;
_shiftCtrlLeftButtonSelects = true;
_showContextMenu = -1;
_resetSelectionItems = false;
}
};
......
......@@ -315,6 +315,8 @@
#define _InsertMovesDown true
// Immediate Context Menu
#define _ImmediateContextMenu true
// Reset selection items
#define _ResetSelectionItems false
// Root directory
#ifdef Q_OS_WIN
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment