Commit f8591ca6 authored by Pavel Karelin's avatar Pavel Karelin

Reset selection items when click to any place when CTRL/SHIFT not pressed

Added the ability reset selection of items when click to any place
when option "Shift/Ctrl-Left mouse button selects"
or "Shift/Ctrl-Right mouse button selects" is checked
parent ce871144
......@@ -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("Reset selection items when click to any place"), true,
i18n("Reset selection of items when click to any place when option \"Shift/Ctrl-Left mouse button selects\" or \"Shift/Ctrl-Right mouse button selects\" is checked") },
};
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()
......
......@@ -195,6 +195,23 @@ bool KrMouseHandler::mouseReleaseEvent(QMouseEvent *e)
item->setSelected(true);
}
}
if (KrSelectionMode::getSelectionHandler()->resetSelectionItems())
{
// For LMB clicking
if ((e->button() == Qt::LeftButton) && (e->modifiers() == Qt::NoModifier) &&
!KrSelectionMode::getSelectionHandler()->leftButtonSelects() &&
KrSelectionMode::getSelectionHandler()->shiftCtrlLeftButtonSelects()) {
// clear the current selection
_view->changeSelection(KrQuery("*"), false, true);
}
// For RMB clicking
else if ((e->button() == Qt::RightButton) && (e->modifiers() == Qt::NoModifier) &&
!KrSelectionMode::getSelectionHandler()->rightButtonSelects() &&
KrSelectionMode::getSelectionHandler()->shiftCtrlRightButtonSelects()) {
// clear the current selection
_view->changeSelection(KrQuery("*"), false, true);
}
}
if (e->button() == Qt::RightButton) {
_rightClickedItem = nullptr;
......
......@@ -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