mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-27 14:50:21 +03:00
fix #215, support a modifier action
--a modifier action in now supported.The user can set the modifier,the click and the action that will be executed
This commit is contained in:
parent
81aa9267fc
commit
aa0c2b9bda
@ -81,6 +81,32 @@
|
||||
</choices>
|
||||
<default>2</default>
|
||||
</entry>
|
||||
<entry name="modifierClickAction" type="Enum">
|
||||
<choices>
|
||||
<choice name="None"/>
|
||||
<choice name="Close"/>
|
||||
<choice name="NewInstance"/>
|
||||
<choice name="ToggleMinimized"/>
|
||||
</choices>
|
||||
<default>0</default>
|
||||
</entry>
|
||||
<entry name="modifier" type="Enum">
|
||||
<choices>
|
||||
<choice name="Shift"/>
|
||||
<choice name="Control"/>
|
||||
<choice name="Alt"/>
|
||||
<choice name="Meta"/>
|
||||
</choices>
|
||||
<default>1</default>
|
||||
</entry>
|
||||
<entry name="modifierClick" type="Enum">
|
||||
<choices>
|
||||
<choice name="LeftClick"/>
|
||||
<choice name="MiddleClick"/>
|
||||
<choice name="RightClick"/>
|
||||
</choices>
|
||||
<default>0</default>
|
||||
</entry>
|
||||
<!-- Config properties -->
|
||||
<entry name="configurationSticker" type="Bool">
|
||||
<default>false</default>
|
||||
|
@ -95,6 +95,10 @@ DragDrop.DropArea {
|
||||
: height * (plasmoid.configuration.maxLength/100)
|
||||
|
||||
property int middleClickAction: plasmoid.configuration.middleClickAction
|
||||
property int modifier: plasmoid.configuration.modifier
|
||||
property int modifierClickAction: plasmoid.configuration.modifierClickAction
|
||||
property int modifierClick: plasmoid.configuration.modifierClick
|
||||
|
||||
property int panelEdgeSpacing: iconSize / 3
|
||||
property int totalPanelEdgeSpacing: 0 //this is set by PanelBox
|
||||
//FIXME: this is not needed any more probably
|
||||
|
@ -60,6 +60,20 @@ public:
|
||||
};
|
||||
Q_ENUM(SessionType)
|
||||
|
||||
enum Modifier {
|
||||
Shift = 0,
|
||||
Ctrl,
|
||||
Alt,
|
||||
Meta
|
||||
};
|
||||
Q_ENUM(Modifier)
|
||||
|
||||
enum ClickAction {
|
||||
LeftClick = 0,
|
||||
MiddleClick,
|
||||
RightClick
|
||||
};
|
||||
Q_ENUM(ClickAction)
|
||||
};
|
||||
|
||||
}//end of namespace
|
||||
|
@ -664,16 +664,18 @@ MouseArea{
|
||||
windowsPreviewDlg.hide(2);
|
||||
}
|
||||
|
||||
if ((mouse.button == Qt.LeftButton)||(mouse.button == Qt.MidButton)) {
|
||||
var modAccepted = modifierAccepted(mouse);
|
||||
|
||||
if ((mouse.button == Qt.LeftButton)||(mouse.button == Qt.MidButton) || modAccepted) {
|
||||
lastButtonClicked = mouse.button;
|
||||
pressed = true;
|
||||
pressX = mouse.x;
|
||||
pressY = mouse.y;
|
||||
|
||||
if(draggingResistaner == null)
|
||||
if(draggingResistaner == null && !modAccepted)
|
||||
draggingResistaner = resistanerTimerComponent.createObject(mainItemContainer);
|
||||
}
|
||||
else if (mouse.button == Qt.RightButton){
|
||||
else if (mouse.button == Qt.RightButton && !modAccepted){
|
||||
root.createContextMenu(mainItemContainer).show();
|
||||
}
|
||||
|
||||
@ -692,7 +694,18 @@ MouseArea{
|
||||
}
|
||||
|
||||
if(pressed && !inBlockingAnimation){
|
||||
if (mouse.button == Qt.MidButton){
|
||||
|
||||
if (modifierAccepted(mouse)){
|
||||
if( !mainItemContainer.isLauncher){
|
||||
if (root.modifierClickAction == TaskManagerApplet.Backend.NewInstance) {
|
||||
tasksModel.requestNewInstance(modelIndex());
|
||||
} else if (root.modifierClickAction == TaskManagerApplet.Backend.Close) {
|
||||
tasksModel.requestClose(modelIndex());
|
||||
} else if (root.modifierClickAction == TaskManagerApplet.Backend.ToggleMinimized) {
|
||||
tasksModel.requestToggleMinimized(modelIndex());
|
||||
}
|
||||
}
|
||||
}else if (mouse.button == Qt.MidButton){
|
||||
if( !mainItemContainer.isLauncher){
|
||||
if (root.middleClickAction == TaskManagerApplet.Backend.NewInstance) {
|
||||
tasksModel.requestNewInstance(modelIndex());
|
||||
@ -909,6 +922,17 @@ MouseArea{
|
||||
return tasksModel.makeModelIndex(index);
|
||||
}
|
||||
|
||||
function modifierAccepted(mouse){
|
||||
if (mouse.modifiers & root.modifierQt){
|
||||
if ((mouse.button === Qt.LeftButton && root.modifierClick === Latte.Dock.LeftClick)
|
||||
|| (mouse.button === Qt.MiddleButton && root.modifierClick === Latte.Dock.MiddleClick)
|
||||
|| (mouse.button === Qt.RightButton && root.modifierClick === Latte.Dock.RightClick))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function setBlockingAnimation(value){
|
||||
inBlockingAnimation = value;
|
||||
}
|
||||
|
@ -113,6 +113,21 @@ Item {
|
||||
property int iconMargin: latteDock ? latteDock.iconMargin : 0.12*iconSize
|
||||
property int iconSize: latteDock ? latteDock.iconSize : Math.max(plasmoid.configuration.iconSize, 16)
|
||||
property int middleClickAction: latteDock ? latteDock.middleClickAction : plasmoid.configuration.middleClickAction
|
||||
property int modifier: latteDock ? latteDock.modifier : -1
|
||||
property int modifierClickAction: latteDock ? latteDock.modifierClickAction : -1
|
||||
property int modifierClick: latteDock ? latteDock.modifierClick : -1
|
||||
property int modifierQt:{
|
||||
if (modifier === Latte.Dock.Shift)
|
||||
return Qt.ShiftModifier;
|
||||
else if (modifier === Latte.Dock.Ctrl)
|
||||
return Qt.ControlModifier;
|
||||
else if (modifier === Latte.Dock.Alt)
|
||||
return Qt.AltModifier;
|
||||
else if (modifier === Latte.Dock.Meta)
|
||||
return Qt.MetaModifier;
|
||||
else return -1;
|
||||
}
|
||||
|
||||
//decouple iconMargin which now is used only for length calculations with thickMargins
|
||||
//which are used for thickness calculations
|
||||
property int thickMarginBase: latteDock ? latteDock.thickMarginBase : Math.ceil(iconMargin/2)
|
||||
|
@ -163,6 +163,46 @@ PlasmaComponents.Page {
|
||||
onCurrentIndexChanged: plasmoid.configuration.middleClickAction = currentIndex
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.leftMargin: units.smallSpacing * 2
|
||||
spacing: units.smallSpacing
|
||||
|
||||
PlasmaComponents.ComboBox {
|
||||
id: modifier
|
||||
Layout.maximumWidth: theme.mSize(theme.defaultFont).width * 5
|
||||
model: ["Shift", "Ctrl", "Alt", "Meta"]
|
||||
|
||||
currentIndex: plasmoid.configuration.modifier
|
||||
onCurrentIndexChanged: plasmoid.configuration.modifier = currentIndex
|
||||
}
|
||||
|
||||
PlasmaComponents.Label {
|
||||
text: "+"
|
||||
}
|
||||
|
||||
PlasmaComponents.ComboBox {
|
||||
id: modifierClick
|
||||
Layout.maximumWidth: theme.mSize(theme.defaultFont).width * 8
|
||||
model: [i18n("Left Click"), i18n("Middle Click"), i18n("Right Click")]
|
||||
|
||||
currentIndex: plasmoid.configuration.modifierClick
|
||||
onCurrentIndexChanged: plasmoid.configuration.modifierClick = currentIndex
|
||||
}
|
||||
|
||||
PlasmaComponents.Label {
|
||||
text: "="
|
||||
}
|
||||
|
||||
PlasmaComponents.ComboBox {
|
||||
id: modifierClickAction
|
||||
Layout.fillWidth: true
|
||||
model: [i18nc("The click action", "None"), i18n("Close Window or Group"), i18n("New Instance"), i18n("Minimize/Restore Window or Group")]
|
||||
|
||||
currentIndex: plasmoid.configuration.modifierClickAction
|
||||
onCurrentIndexChanged: plasmoid.configuration.modifierClickAction = currentIndex
|
||||
}
|
||||
}
|
||||
}
|
||||
//! END: Tasks Interaction
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user