mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-21 10:50:30 +03:00
expose to qml builtin activity/vds switching
--tested that this fixes also the Latte crash on exit as PagerModel is not used any more in Latte internal code
This commit is contained in:
parent
d312598f60
commit
1051372e04
@ -109,5 +109,26 @@ void WindowsTracker::setWindowOnActivities(QWindow &window, const QStringList &a
|
||||
m_wm->setWindowOnActivities(window, activities);
|
||||
}
|
||||
|
||||
//! Environment Functions
|
||||
void WindowsTracker::switchToNextActivity()
|
||||
{
|
||||
m_wm->switchToNextActivity();
|
||||
}
|
||||
|
||||
void WindowsTracker::switchToPreviousActivity()
|
||||
{
|
||||
m_wm->switchToPreviousActivity();
|
||||
}
|
||||
|
||||
void WindowsTracker::switchToNextVirtualDesktop()
|
||||
{
|
||||
m_wm->switchToNextVirtualDesktop();
|
||||
}
|
||||
|
||||
void WindowsTracker::switchToPreviousVirtualDesktop()
|
||||
{
|
||||
m_wm->switchToPreviousVirtualDesktop();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -66,6 +66,12 @@ public:
|
||||
Latte::View *view() const;
|
||||
WindowSystem::AbstractWindowInterface *wm() const;
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE void switchToNextActivity();
|
||||
Q_INVOKABLE void switchToPreviousActivity();
|
||||
Q_INVOKABLE void switchToNextVirtualDesktop();
|
||||
Q_INVOKABLE void switchToPreviousVirtualDesktop();
|
||||
|
||||
signals:
|
||||
void enabledChanged();
|
||||
void activeWindowDraggingStarted();
|
||||
|
@ -145,6 +145,7 @@ void XWindowInterface::setViewStruts(QWindow &view, const QRect &rect
|
||||
void XWindowInterface::switchToNextVirtualDesktop() const
|
||||
{
|
||||
int desktops = KWindowSystem::numberOfDesktops();
|
||||
|
||||
if (desktops <= 1) {
|
||||
return;
|
||||
}
|
||||
@ -152,8 +153,8 @@ void XWindowInterface::switchToNextVirtualDesktop() const
|
||||
int curPos = KWindowSystem::currentDesktop();
|
||||
int nextPos = curPos + 1;
|
||||
|
||||
if (curPos == desktops -1) {
|
||||
nextPos = 0;
|
||||
if (curPos == desktops) {
|
||||
nextPos = 1;
|
||||
}
|
||||
|
||||
KWindowSystem::setCurrentDesktop(nextPos);
|
||||
@ -169,8 +170,8 @@ void XWindowInterface::switchToPreviousVirtualDesktop() const
|
||||
int curPos = KWindowSystem::currentDesktop();
|
||||
int nextPos = curPos - 1;
|
||||
|
||||
if (curPos == 0) {
|
||||
nextPos = desktops - 1;
|
||||
if (curPos == 1) {
|
||||
nextPos = desktops;
|
||||
}
|
||||
|
||||
KWindowSystem::setCurrentDesktop(nextPos);
|
||||
|
@ -125,44 +125,24 @@ Loader {
|
||||
var angle = delta / 8;
|
||||
|
||||
if (angle>10) {
|
||||
if (pagerLoader.active) {
|
||||
var next;
|
||||
if (pagerLoader.item.model.currentPage === pagerLoader.item.count - 1){
|
||||
next = 0;
|
||||
} else {
|
||||
next = Math.min(pagerLoader.item.model.currentPage + 1, pagerLoader.item.count - 1);
|
||||
}
|
||||
|
||||
if (pagerLoader.item.count > 1){
|
||||
//console.log("+++ changing from: " + pagerLoader.item.model.currentPage + " to ::: " + next);
|
||||
pagerLoader.item.model.changePage(next);
|
||||
}
|
||||
if (root.scrollAction === Latte.Types.ScrollDesktops) {
|
||||
latteView.windowsTracker.switchToNextVirtualDesktop();
|
||||
} else if (root.scrollAction === Latte.Types.ScrollActivities) {
|
||||
latteView.windowsTracker.switchToNextActivity();
|
||||
} else if (tasksLoader.active) {
|
||||
tasksLoader.item.activateNextPrevTask(true);
|
||||
}
|
||||
} else if (angle<-10) {
|
||||
if (pagerLoader.active) {
|
||||
var prev;
|
||||
if (pagerLoader.item.model.currentPage === 0){
|
||||
prev = pagerLoader.item.count - 1;
|
||||
} else {
|
||||
prev = Math.max(pagerLoader.item.model.currentPage - 1, 0);
|
||||
}
|
||||
|
||||
if (pagerLoader.item.count > 1){
|
||||
//console.log("--- changing from: " + pagerLoader.item.model.currentPage + " to ::: " + prev);
|
||||
pagerLoader.item.model.changePage(prev);
|
||||
}
|
||||
if (root.scrollAction === Latte.Types.ScrollDesktops) {
|
||||
latteView.windowsTracker.switchToPreviousVirtualDesktop();
|
||||
} else if (root.scrollAction === Latte.Types.ScrollActivities) {
|
||||
latteView.windowsTracker.switchToPreviousActivity();
|
||||
} else if (tasksLoader.active) {
|
||||
tasksLoader.item.activateNextPrevTask(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loaders.Pager{
|
||||
id: pagerLoader
|
||||
}
|
||||
|
||||
Loaders.Tasks{
|
||||
id: tasksLoader
|
||||
}
|
||||
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 Michail Vourlakos <mvourlakos@gmail.com>
|
||||
*
|
||||
* This file is part of Latte-Dock
|
||||
*
|
||||
* Latte-Dock is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Latte-Dock is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import QtQuick 2.7
|
||||
|
||||
import org.kde.plasma.plasmoid 2.0
|
||||
import org.kde.plasma.private.pager 2.0
|
||||
|
||||
import org.kde.latte 0.2 as Latte
|
||||
|
||||
Loader {
|
||||
id: pagerLoader
|
||||
active: root.scrollAction === Latte.Types.ScrollDesktops || root.scrollAction === Latte.Types.ScrollActivities
|
||||
sourceComponent: Item{
|
||||
readonly property int count: repeater.count
|
||||
readonly property QtObject model: pagerModel
|
||||
|
||||
PagerModel {
|
||||
id: pagerModel
|
||||
enabled: true
|
||||
showDesktop: true
|
||||
showOnlyCurrentScreen: true
|
||||
screenGeometry: latteView ? latteView.screenGeometry : plasmoid.screenGeometry
|
||||
pagerType: root.scrollAction === Latte.Types.ScrollDesktops ? PagerModel.VirtualDesktops : PagerModel.Activities
|
||||
}
|
||||
|
||||
Repeater{
|
||||
id: repeater
|
||||
model: pagerModel
|
||||
|
||||
Item{}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user