1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-28 19:21:50 +03:00

support removing internal tasks separator

This commit is contained in:
Michail Vourlakos 2017-04-27 20:23:08 +03:00
parent f24da87b19
commit 92f214d552
8 changed files with 95 additions and 10 deletions

View File

@ -284,7 +284,6 @@ void DockConfigView::addPanelSpacer()
void DockConfigView::addTasksSeparator()
{
const auto &applets = m_dockView->containment()->applets();
for (auto *applet : applets) {
@ -321,7 +320,46 @@ void DockConfigView::addTasksSeparator()
}
}
}
}
void DockConfigView::removeTasksSeparator()
{
const auto &applets = m_dockView->containment()->applets();
for (auto *applet : applets) {
KPluginMetaData meta = applet->kPackage().metadata();
if (meta.pluginId() == "org.kde.latte.plasmoid") {
if (QQuickItem *appletInterface = applet->property("_plasma_graphicObject").value<QQuickItem *>()) {
const auto &childItems = appletInterface->childItems();
if (childItems.isEmpty()) {
continue;
}
for (QQuickItem *item : childItems) {
if (auto *metaObject = item->metaObject()) {
// not using QMetaObject::invokeMethod to avoid warnings when calling
// this on applets that don't have it or other child items since this
// is pretty much trial and error.
// Also, "var" arguments are treated as QVariant in QMetaObject
int methodIndex = metaObject->indexOfMethod("removeSeparator(QVariant)");
if (methodIndex == -1) {
continue;
}
QMetaMethod method = metaObject->method(methodIndex);
if (method.invoke(item, Q_ARG(QVariant, QString(m_dockView->corona()->kPackage().filePath("separator0"))))) {
return;
}
}
}
}
}
}
}

View File

@ -54,6 +54,7 @@ public:
public slots:
Q_INVOKABLE void addPanelSpacer();
Q_INVOKABLE void addTasksSeparator();
Q_INVOKABLE void removeTasksSeparator();
Q_INVOKABLE void hideConfigWindow();
Q_INVOKABLE void setSticker(bool blockFocusLost);
Q_INVOKABLE void syncGeometry();

View File

@ -172,5 +172,8 @@
<entry name="showOnlyCurrentActivity" type="Bool">
<default>true</default>
</entry>
<entry name="hasInternalSeparator" type="Bool">
<default>false</default>
</entry>
</group>
</kcfg>

View File

@ -945,9 +945,11 @@ Item {
else{
if(layoutsContainer.hoveredIndex<container.index){
latteApplet.updateScale(0, nScale, step);
//disabled because of the internal tasks separator
latteApplet.updateScale(1, 1, 0);
} else if(layoutsContainer.hoveredIndex>container.index) {
latteApplet.updateScale(root.tasksCount-1, nScale, step);
//disabled because of the internal tasks separator
latteApplet.updateScale(root.tasksCount-2, 1, 0);
}
}

View File

@ -76,6 +76,8 @@ DragDrop.DropArea {
property bool smallAutomaticIconJumps: true
property bool useThemePanel: noApplets === 0 ? true : plasmoid.configuration.useThemePanel
property alias hoveredIndex: layoutsContainer.hoveredIndex
property int actionsBlockHiding: 0 //actions that block hiding
property int animationsNeedBothAxis:0 //animations need space in both axes, e.g zooming a task
@ -212,6 +214,8 @@ DragDrop.DropArea {
property int latteAppletHoveredIndex: latteApplet ? latteApplet.hoveredIndex : -1
property int tasksCount: latteApplet ? latteApplet.tasksCount : 0
property bool hasInternalSeparator: latteApplet ? latteApplet.hasInternalSeparator : false
property real durationTime: {
if (plasmoid.configuration.durationTime === 0 || plasmoid.configuration.durationTime === 2 )
return plasmoid.configuration.durationTime;
@ -600,6 +604,11 @@ DragDrop.DropArea {
// dndSpacer.parent = root;
}
//! it is used in order to provide to config window the internalSeparator state
onHasInternalSeparatorChanged: {
plasmoid.configuration.hasInternalSeparator = root.hasInternalSeparator;
}
onLatteAppletChanged: {
if (latteApplet) {
latteApplet.signalAnimationsNeedBothAxis.connect(slotAnimationsNeedBothAxis);

View File

@ -471,8 +471,15 @@ MouseArea{
//activate messages to update the the neighbour scales
root.updateScale(index+1, rightScale, 0);
root.updateScale(index-1, leftScale, 0);
// root.updateScale(index+2, 1, 0);
// root.updateScale(index-2, 1, 0);
/* if (index>1)
root.updateScale(-1, 1, 0);
if (index<icList.tasksCount-2)
root.updateScale(root.tasksCount, 1, 0);*/
if(!root.hasInternalSeparator) {
root.updateScale(index+2, 1, 0);
root.updateScale(index-2, 1, 0);
}
//Left hiddenSpacer
if(((index === 0 )&&(icList.count > 1)) && !root.disableLeftSpacer){
@ -502,7 +509,8 @@ MouseArea{
}
if ((index === nIndex) && mainItemContainer.isSeparator){
if (icList.hoveredIndex<index)
// console.log(nIndex + " - " + icList.hoveredIndex + " - " + (icList.tasksCount-1));
if (icList.hoveredIndex<index && icList.hoveredIndex >= 0)
root.updateScale(index+1, nScale, step);
else if (icList.hoveredIndex>index)
root.updateScale(index-1, nScale, step);

View File

@ -57,6 +57,7 @@ Item {
property bool editMode: plasmoid.userConfiguring
property bool disableRestoreZoom: false //blocks restore animation in rightClick
property bool dropNewLauncher: false
property bool hasInternalSeparator: false
property bool initializationStep: false //true
property bool initializatedBuffers: true // noInitCreatedBuffers >= tasksStarting ? true : false
property bool isHovered: false
@ -120,6 +121,7 @@ Item {
property bool smartLaunchersEnabled: latteDock ? latteDock.smartLaunchersEnabled : plasmoid.configuration.smartLaunchersEnabled
property bool threeColorsWindows: latteDock ? latteDock.threeColorsWindows : plasmoid.configuration.threeColorsWindows
property int dockHoveredIndex : latteDock ? latteDock.hoveredIndex : -1
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
@ -339,6 +341,13 @@ Item {
ActivitiesTools.updateLaunchers(launchers);*/
}
onDockHoveredIndexChanged: {
if (dockHoveredIndex >= 0) {
icList.hoveredIndex = -1;
checkListHovered.startNormal();
}
}
onDragSourceChanged: {
if (dragSource == null) {
root.draggingFinished();
@ -475,7 +484,16 @@ Item {
onLauncherListChanged: {
plasmoid.configuration.launchers59 = launcherList;
// ActivitiesTools.updateLaunchers(launcherList);
var hasSep = false;
for(var i=0; i<launcherList.length; ++i){
var rec1 = launcherList[i];
if (rec1.indexOf("latte-separator.desktop") >= 0) {
hasSep = true;
break;
}
}
root.hasInternalSeparator = hasSep;
}
onGroupingAppIdBlacklistChanged: {
@ -841,7 +859,7 @@ Item {
property int hoveredIndex : -1
property int previousCount : 0
property int tasksCount: contentItem.children.length
property int tasksCount: tasksModel.count
property bool delayingRemoval: false
property bool directRender: false
@ -1217,8 +1235,11 @@ Item {
//! it is used to add the fake desktop file which represents
//! the separator (fake launcher)
function addSeparator(filepath){
console.log(filepath);
addLauncher(filepath);
tasksModel.requestAddLauncher(filepath);
}
function removeSeparator(filepath){
tasksModel.requestRemoveLauncher(filepath);
}
function outsideContainsMouse(){

View File

@ -215,14 +215,17 @@ PlasmaComponents.Page {
}
}
PlasmaComponents.Button {
iconSource: "add"
iconSource: plasmoid.configuration.hasInternalSeparator ? "remove" : "add"
text: i18n("Tasks Separator")
Layout.alignment: Qt.AlignLeft
visible: dock.tasksPresent()
// tooltip: i18n("Add a separator for tasks")
onClicked: {
dockConfig.addTasksSeparator();
if (plasmoid.configuration.hasInternalSeparator)
dockConfig.removeTasksSeparator();
else
dockConfig.addTasksSeparator();
}
}
PlasmaComponents.Button {