mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-23 13:33:50 +03:00
Tasks:introduce Tasks.Dialog
--this is just a subclass of PlasmaQuick::Dialog that provides "containsMouse" property
This commit is contained in:
parent
3018bd0fff
commit
00127f28c0
@ -1764,11 +1764,13 @@ Item {
|
||||
interval: 90
|
||||
|
||||
onTriggered: {
|
||||
if (latteApplet && (latteApplet.previewContainsMouse() || latteApplet.contextMenu))
|
||||
if (latteApplet && (latteApplet.previewContainsMouse() || latteApplet.contextMenu)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (latteView.contextMenuIsShown)
|
||||
if (latteView.contextMenuIsShown) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mouseInHoverableArea()) {
|
||||
setGlobalDirectRender(false);
|
||||
|
@ -5,6 +5,7 @@ configure_file(metadata.desktop.cmake ${CMAKE_CURRENT_SOURCE_DIR}/package/metada
|
||||
plasma_install_package(package org.kde.latte.plasmoid)
|
||||
|
||||
set(tasks_SRCS
|
||||
plugin/dialog.cpp
|
||||
plugin/types.cpp
|
||||
plugin/lattetasksplugin.cpp
|
||||
)
|
||||
@ -13,7 +14,9 @@ add_library(lattetasksplugin SHARED ${tasks_SRCS})
|
||||
|
||||
target_link_libraries(lattetasksplugin
|
||||
Qt5::Core
|
||||
Qt5::Qml)
|
||||
Qt5::Qml
|
||||
KF5::Plasma
|
||||
KF5::PlasmaQuick)
|
||||
|
||||
install(TARGETS lattetasksplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/latte/private/tasks)
|
||||
install(FILES plugin/qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/latte/private/tasks)
|
||||
|
@ -525,7 +525,7 @@ Item {
|
||||
|
||||
////BEGIN interfaces
|
||||
|
||||
PlasmaCore.Dialog{
|
||||
LatteTasks.Dialog{
|
||||
id: windowsPreviewDlg
|
||||
// hideOnWindowDeactivate: false
|
||||
type: PlasmaCore.Dialog.Tooltip
|
||||
@ -540,16 +540,31 @@ Item {
|
||||
|
||||
Component.onCompleted: mainItem.visible = true;
|
||||
|
||||
onContainsMouseChanged: {
|
||||
//! Orchestrate restore zoom and previews window hiding. Both should be
|
||||
//! triggered together.
|
||||
if (containsMouse) {
|
||||
stopCheckRestoreZoomTimer();
|
||||
hidePreviewWinTimer.stop();
|
||||
} else {
|
||||
hide(7.3);
|
||||
}
|
||||
}
|
||||
|
||||
function hide(debug){
|
||||
// console.log("on hide previews event called: "+debug);
|
||||
if (containsMouse || !visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (latteView && signalSent) {
|
||||
//it is used to unblock dock hiding
|
||||
signalSent = false;
|
||||
}
|
||||
|
||||
if (!root.contextMenu)
|
||||
if (!root.contextMenu) {
|
||||
root.disableRestoreZoom = false;
|
||||
}
|
||||
|
||||
hidePreviewWinTimer.start();
|
||||
}
|
||||
@ -591,11 +606,17 @@ Item {
|
||||
//! Delay windows previews hiding
|
||||
Timer {
|
||||
id: hidePreviewWinTimer
|
||||
interval: 350
|
||||
interval: 300
|
||||
onTriggered: {
|
||||
windowsPreviewDlg.visible = false;
|
||||
windowsPreviewDlg.mainItem.visible = false;
|
||||
windowsPreviewDlg.activeItem = null;
|
||||
//! Orchestrate restore zoom and previews window hiding. Both should be
|
||||
//! triggered together.
|
||||
if (!windowsPreviewDlg.containsMouse
|
||||
&& !(windowsPreviewDlg.activeItem && windowsPreviewDlg.activeItem.containsMouse)) {
|
||||
windowsPreviewDlg.visible = false;
|
||||
windowsPreviewDlg.mainItem.visible = false;
|
||||
windowsPreviewDlg.activeItem = null;
|
||||
startCheckRestoreZoomTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1773,11 +1794,7 @@ Item {
|
||||
}
|
||||
|
||||
function previewContainsMouse() {
|
||||
if(toolTipDelegate && toolTipDelegate.containsMouse && toolTipDelegate.parentTask) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return windowsPreviewDlg.containsMouse;
|
||||
}
|
||||
|
||||
function containsMouse(){
|
||||
@ -1817,8 +1834,9 @@ Item {
|
||||
disableRestoreZoom = false;
|
||||
}
|
||||
|
||||
if (!previewContainsMouse())
|
||||
if (!previewContainsMouse()) {
|
||||
windowsPreviewDlg.hide(4.2);
|
||||
}
|
||||
|
||||
if (!latteView) {
|
||||
initializeHoveredIndex();
|
||||
@ -1874,6 +1892,7 @@ Item {
|
||||
|
||||
function startCheckRestoreZoomTimer(duration) {
|
||||
if (latteView) {
|
||||
|
||||
latteView.startCheckRestoreZoomTimer();
|
||||
} else {
|
||||
if (duration > 0) {
|
||||
|
@ -53,8 +53,6 @@ PlasmaExtras.ScrollArea {
|
||||
property bool isLauncher
|
||||
property bool isMinimizedParent
|
||||
|
||||
property bool containsMouse: false
|
||||
|
||||
// Needed for generateSubtext()
|
||||
property string displayParent
|
||||
property string genericName
|
||||
@ -111,17 +109,6 @@ PlasmaExtras.ScrollArea {
|
||||
}
|
||||
} //! DropArea
|
||||
|
||||
//! Underneath MouseArea
|
||||
MouseArea {
|
||||
id: contentItemMouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
|
||||
onContainsMouseChanged: {
|
||||
mainToolTip.mouseIsInside();
|
||||
}
|
||||
}//! MouseArea
|
||||
|
||||
Loader {
|
||||
id: contentItem
|
||||
active: mainToolTip.rootIndex !== undefined
|
||||
@ -161,38 +148,6 @@ PlasmaExtras.ScrollArea {
|
||||
} //! Loader
|
||||
} //! Item
|
||||
|
||||
//! Central Functionality
|
||||
function mouseIsInside(){
|
||||
var isInside = contentItemMouseArea.containsMouse || instancesContainMouse();
|
||||
|
||||
if (isInside){
|
||||
mainToolTip.containsMouse = true;
|
||||
|
||||
if(!root.latteView)
|
||||
checkListHovered.stop();
|
||||
} else {
|
||||
mainToolTip.containsMouse = false;
|
||||
|
||||
if(!root.latteView)
|
||||
checkListHovered.startDuration(100);
|
||||
else
|
||||
root.latteView.startCheckRestoreZoomTimer();
|
||||
}
|
||||
}
|
||||
|
||||
function instancesContainMouse() {
|
||||
var previewInstances = isGroup ? contentItem.children[0].children : contentItem.children;
|
||||
var instancesLength = previewInstances.length;
|
||||
|
||||
for(var i=instancesLength-1; i>=0; --i) {
|
||||
if( (typeof(previewInstances[i].containsMouse) === "function") //ignore unrelevant objects
|
||||
&& previewInstances[i].containsMouse())
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function instanceAtPos(x, y){
|
||||
var previewInstances = isGroup ? contentItem.children[0].children : contentItem.children;
|
||||
var instancesLength = previewInstances.length;
|
||||
|
@ -84,11 +84,6 @@ Column {
|
||||
readonly property string albumArt: currentMetadata["mpris:artUrl"] || ""
|
||||
|
||||
//
|
||||
function containsMouse() {
|
||||
return closeButton.hovered || area2.containsMouse
|
||||
|| (playbackLoader.active && playbackLoader.item.containsMouse());
|
||||
}
|
||||
|
||||
function isTaskActive() {
|
||||
return (isGroup ? isActive : (parentTask ? parentTask.isActive : false));
|
||||
}
|
||||
@ -162,7 +157,6 @@ Column {
|
||||
backend.cancelHighlightWindows();
|
||||
tasksModel.requestClose(submodelIndex);
|
||||
}
|
||||
onHoveredChanged: mainToolTip.mouseIsInside()
|
||||
}
|
||||
}
|
||||
|
||||
@ -278,10 +272,6 @@ Column {
|
||||
// onClicked: mpris2Source.raise(mprisSourceName)
|
||||
// }
|
||||
|
||||
function containsMouse() {
|
||||
return area3.containsMouse || canGoBackButton.hovered || playingButton.hovered || canGoNextButton.hovered;
|
||||
}
|
||||
|
||||
Item {
|
||||
id: playerControlsFrostedGlass
|
||||
anchors.fill: parent
|
||||
@ -313,9 +303,6 @@ Column {
|
||||
MouseArea {
|
||||
id: area3
|
||||
anchors.fill: playerControlsRow
|
||||
|
||||
hoverEnabled: true
|
||||
onContainsMouseChanged: mainToolTip.mouseIsInside();
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
@ -359,7 +346,6 @@ Column {
|
||||
enabled: canGoBack
|
||||
iconSource: LayoutMirroring.enabled ? "media-skip-forward" : "media-skip-backward"
|
||||
onClicked: mpris2Source.goPrevious(mprisSourceName)
|
||||
onHoveredChanged: mainToolTip.mouseIsInside()
|
||||
}
|
||||
|
||||
PlasmaComponents.ToolButton {
|
||||
@ -373,7 +359,6 @@ Column {
|
||||
mpris2Source.pause(mprisSourceName);
|
||||
}
|
||||
}
|
||||
onHoveredChanged: mainToolTip.mouseIsInside()
|
||||
}
|
||||
|
||||
PlasmaComponents.ToolButton {
|
||||
@ -381,7 +366,6 @@ Column {
|
||||
enabled: canGoNext
|
||||
iconSource: LayoutMirroring.enabled ? "media-skip-backward" : "media-skip-forward"
|
||||
onClicked: mpris2Source.goNext(mprisSourceName)
|
||||
onHoveredChanged: mainToolTip.mouseIsInside()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -57,7 +57,6 @@ MouseArea {
|
||||
}
|
||||
|
||||
onContainsMouseChanged: {
|
||||
mainToolTip.mouseIsInside();
|
||||
root.windowsHovered([winId], containsMouse);
|
||||
}
|
||||
}
|
||||
|
58
plasmoid/plugin/dialog.cpp
Normal file
58
plasmoid/plugin/dialog.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2020 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/>.
|
||||
*/
|
||||
|
||||
#include "dialog.h"
|
||||
|
||||
|
||||
namespace Latte {
|
||||
namespace Quick {
|
||||
|
||||
Dialog::Dialog(QQuickItem *parent)
|
||||
: PlasmaQuick::Dialog(parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool Dialog::containsMouse() const
|
||||
{
|
||||
return m_containsMouse;
|
||||
}
|
||||
|
||||
void Dialog::setContainsMouse(bool contains)
|
||||
{
|
||||
if (m_containsMouse == contains) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_containsMouse = contains;
|
||||
emit containsMouseChanged();
|
||||
}
|
||||
|
||||
bool Dialog::event(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::Enter) {
|
||||
setContainsMouse(true);
|
||||
} else if (e->type() == QEvent::Leave) {
|
||||
setContainsMouse(false);
|
||||
}
|
||||
|
||||
return PlasmaQuick::Dialog::event(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
60
plasmoid/plugin/dialog.h
Normal file
60
plasmoid/plugin/dialog.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2020 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/>.
|
||||
*/
|
||||
|
||||
#ifndef LATTEDIALOG_H
|
||||
#define LATTEDIALOG_H
|
||||
|
||||
// Qt
|
||||
#include <QEvent>
|
||||
#include <QObject>
|
||||
|
||||
// Plasma
|
||||
#include <PlasmaQuick/Dialog>
|
||||
|
||||
namespace Latte {
|
||||
namespace Quick {
|
||||
|
||||
class Dialog : public PlasmaQuick::Dialog {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY (bool containsMouse READ containsMouse NOTIFY containsMouseChanged)
|
||||
|
||||
public:
|
||||
explicit Dialog(QQuickItem *parent = nullptr);
|
||||
|
||||
bool containsMouse() const;
|
||||
|
||||
signals:
|
||||
void containsMouseChanged();
|
||||
|
||||
protected:
|
||||
bool event(QEvent *e) override;
|
||||
|
||||
private slots:
|
||||
void setContainsMouse(bool contains);
|
||||
|
||||
private:
|
||||
bool m_containsMouse{false};
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -20,14 +20,17 @@
|
||||
#include "lattetasksplugin.h"
|
||||
|
||||
// local
|
||||
#include "dialog.h"
|
||||
#include "types.h"
|
||||
|
||||
// Qt
|
||||
#include <QtQml>
|
||||
|
||||
|
||||
void LatteTasksPlugin::registerTypes(const char *uri)
|
||||
{
|
||||
Q_ASSERT(uri == QLatin1String("org.kde.latte.private.tasks"));
|
||||
qmlRegisterUncreatableType<Latte::Tasks::Types>(uri, 0, 1, "Types", "Latte Tasks Types uncreatable");
|
||||
qmlRegisterType<Latte::Quick::Dialog>(uri, 0, 1, "Dialog");
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,9 @@
|
||||
// Qt
|
||||
#include <QQmlExtensionPlugin>
|
||||
|
||||
// Plasma
|
||||
#include <PlasmaQuick/Dialog>
|
||||
|
||||
class LatteTasksPlugin : public QQmlExtensionPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
Loading…
Reference in New Issue
Block a user