fix(taskManager):删除taskManager无用文件

This commit is contained in:
qiqi49 2024-11-18 17:47:39 +08:00 committed by iaom
parent b1a013b60e
commit 832236cda6
12 changed files with 0 additions and 979 deletions

View File

@ -44,7 +44,6 @@ set(ukuiTaskManager_SRC
utils.cpp utils.h
actions.cpp actions.h
task-manager-plugin.cpp task-manager-plugin.h
window-thumbnail-view.cpp window-thumbnail-view.h
task-manager-filter-model.cpp
task-manager-filter-model.h
widget-delegate.h widget-delegate.cpp

View File

@ -1,23 +0,0 @@
set(ukuiTaskManagerTest_SRCS
main.cpp
window-thumbnail-view.h
window-thumbnail-view.cpp
task-manager-view.h
task-manager-view.cpp
)
include_directories(../)
set(QRC_FILES qml/qml.qrc)
add_executable(ukui-task-manager-test ${QRC_FILES} ${ukuiTaskManagerTest_SRCS})
target_link_libraries(ukui-task-manager-test PRIVATE
Qt${QT_MAJOR_VERSION}::Core
Qt${QT_MAJOR_VERSION}::DBus
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Qml
Qt${QT_VERSION_MAJOR}::Quick
Qt${QT_VERSION_MAJOR}::X11Extras
kysdk-waylandhelper
ukui-task-manager
KF5::WindowSystem
)

View File

@ -1,36 +0,0 @@
/*
*
* * Copyright (C) 2023, KylinSoft Co., Ltd.
* *
* * This program 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 3 of the License, or
* * (at your option) any later version.
* *
* * This program 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 <https://www.gnu.org/licenses/>.
* *
* * Authors: iaom <zhangpengfei@kylinos.cn>
*
*/
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QObject>
#include <QQuickView>
#include "task-manager-view.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
TaskManagerView view;
view.show();
return app.exec();
}

View File

@ -1,95 +0,0 @@
/*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 <https://www.gnu.org/licenses/>.
*
* Authors: iaom <zhangpengfei@kylinos.cn>
* qiqi49 <qiqi@kylinos.cn>
*/
import QtQuick 2.12
import QtQuick.Layouts 1.12
import org.ukui.windowThumbnail 1.0
import org.ukui.quick.items 1.0
MouseArea {
width: childrenRect.width
height: childrenRect.height
hoverEnabled: true
onEntered: {
thumbnailView.viewShow = true;
}
onExited: {
thumbnailView.viewShow = false;
}
ListView {
width: childrenRect.width
height: 200
interactive: false
orientation: ListView.Horizontal
spacing: 20
onChildrenRectChanged: {
thumbnailView.width = childrenRect.width
}
model: thumbnailView.viewModel
delegate: MouseArea {
width: 300
height: 200
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
if (mouse.button === Qt.RightButton) {
thumbnailView.openMenu(modelData);
} else {
taskModel.activateWindow(modelData);
}
}
ColumnLayout {
anchors.fill: parent
RowLayout {
Layout.fillWidth: true
Layout.preferredHeight: 32
Layout.maximumHeight: 32
visible: windowThumbnail.thumbnailMprisModel.count <= 0
ThemeIcon {
Layout.preferredHeight: 32
Layout.preferredWidth: 32
source: taskModel.windowIcon(modelData)
}
Text {
Layout.fillHeight: true
Layout.fillWidth: true
text: taskModel.windowTitle(modelData)
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
}
}
WindowThumbnail {
id: windowThumbnail
Layout.fillWidth: true
Layout.fillHeight: true
winId: Number.parseInt(modelData)
}
}
}
}
}

View File

@ -1,200 +0,0 @@
/*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 <https://www.gnu.org/licenses/>.
*
* Authors: qiqi49 <qiqi@kylinos.cn>
* iaom <zhangpengfei@kylinos.cn>
*/
import QtQuick 2.15
import QtQml.Models 2.12
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12
import org.ukui.quick.items 1.0
Item {
id: root
width: childrenRect.width
height: childrenRect.height
ListView {
id: baseView
property int dragStartIndex: 0
property bool isBusy: false
property bool dragIsContain: true
width: childrenRect.width
height: 100
interactive: false
orientation: ListView.Horizontal
model: DelegateModel {
id: visualModel
model: proxyModel
delegate: DropArea {
id: dropArea
property int order: DelegateModel.itemsIndex
width: 100
height: 100
onEntered: {
if (drag.y > 95 || drag.y < 5) {
visualModel.items.move(baseView.count - 1, dropArea.order);
} else {
visualModel.items.move(drag.source.draggableOrder, dropArea.order);
}
}
onExited: {
if (drag.y > 95 || drag.y < 5) {
visualModel.items.move(drag.source.draggableOrder, baseView.count - 1);
}
}
Rectangle {
id: rect
width: 100
height: 100
ToolTip.text: model.Name
ToolTip.visible: mouseArea.containsMouse
ToolTip.delay: 300
color: "transparent"
Item {
id: draggableItem
property int draggableOrder: dropArea.order
width: 100
height: 100
Drag.supportedActions: Qt.CopyAction
Drag.dragType: Drag.Automatic
Drag.active: mouseArea.drag.active
Drag.hotSpot.x: icon.width / 2
Drag.hotSpot.y: icon.height / 2
Drag.onActiveChanged: {
if (Drag.active) {
draggableItem.parent = baseView;
draggableItem.opacity = 0;
}
}
function dragFinished() {
draggableItem.opacity = 1;
draggableItem.parent = rect;
draggableItem.x = 0;
draggableItem.y = 0;
proxyModel.setOrder(visualModel.model.index(baseView.dragStartIndex, 0), dropArea.order);
}
function grabImage() {
draggableItem.grabToImage(function(result) {
draggableItem.Drag.imageSource = result.url
return result;
})
}
ThemeIcon {
id: icon
width: 96
height: 96
source: model.Icon
anchors.centerIn: parent
}
MouseArea {
id: mouseArea
property point mousePressPoint: Qt.point(0, 0)
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton
drag.target: baseView.isBusy ? draggableItem : null
onPressed: {
draggableItem.grabImage();
baseView.isBusy = true;
baseView.dragStartIndex = draggableItem.draggableOrder;
}
onReleased: {
baseView.isBusy = false;
draggableItem.dragFinished();
}
onClicked: {
if (mouse.button === Qt.RightButton) {
taskView.openMenu(model.Actions, index);
} else {
if (CurrentDesktopWinIDList.length === 1) {
taskModel.activateWindow(CurrentDesktopWinIDList[0]);
}
}
}
onEntered: {
viewShowTimer.start();
viewHideTimer.stop();
}
onExited: {
viewHideTimer.start();
viewShowTimer.stop();
}
}
}
// *********Animation*********
PauseAnimation {
id: viewShowTimer
duration: 500
onFinished: {
if (CurrentDesktopWinIDList.length === 0) {
return;
}
if (baseView.isBusy) {
return;
}
var thumbnailPoint = mapToGlobal(width / 2, -8);
thumbnailView.viewPoint = thumbnailPoint;
thumbnailView.viewModel = CurrentDesktopWinIDList;
thumbnailView.show();
}
}
PauseAnimation {
id: viewHideTimer
duration: 300
onFinished: {
if (!thumbnailView.viewShow) {
thumbnailView.hide();
}
}
}
}
}
}
displaced: Transition {
NumberAnimation {
properties: "x,y"
easing.type: Easing.OutQuad
duration: 200
}
}
add: Transition {
NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 400 }
NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: 400 }
}
}
}

View File

@ -1,6 +0,0 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>ThumbnailView.qml</file>
</qresource>
</RCC>

View File

@ -1,85 +0,0 @@
/*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 <https://www.gnu.org/licenses/>.
*
* Authors: iaom <zhangpengfei@kylinos.cn>
*
*/
#include <QQmlEngine>
#include <QQmlContext>
#include <QDebug>
#include <QMenu>
#include <QQuickView>
#include <windowmanager/windowmanager.h>
#include <KWindowSystem>
#include "actions.h"
#include "task-manager-view.h"
#include "ukui-task-manager.h"
TaskManagerView::TaskManagerView(QWindow *parent)
{
initWindow();
}
void TaskManagerView::openMenu(const QVariant &modelActions, const int &index)
{
TaskManager::Actions actions;
if (modelActions.canConvert<TaskManager::Actions>()) {
actions = modelActions.value<TaskManager::Actions>();
} else {
qWarning() << "actions is not available!";
return;
}
if (m_contextMenu) {
m_contextMenu->close();
}
QMenu *menu = new QMenu;
menu->setAttribute(Qt::WA_DeleteOnClose);
for(const TaskManager::Action* action : actions) {
menu->addAction(action->internalAction());
}
if (menu->actions().isEmpty()) {
delete menu;
return;
}
m_contextMenu = menu;
menu->popup(QCursor::pos());
}
void TaskManagerView::initWindow()
{
setResizeMode(QQuickView::SizeViewToRootObject);
m_windowThumbnailView = new WindowThumbnailView();
engine()->rootContext()->setContextProperty("taskView", this);
engine()->rootContext()->setContextProperty("taskModel", &TaskManager::UkuiTaskManager::self());
engine()->rootContext()->setContextProperty("thumbnailView", m_windowThumbnailView);
setSource(QUrl("qrc:/main.qml"));
kdk::WindowManager::setSkipTaskBar(this, true);
// kdk::WindowManager::setSkipSwitcher(this, true);
//垃圾,不好使
// kdk::WindowManager::setOnAllDesktops(winId());
// KWindowSystem::setType(winId(), NET::Dock);
KWindowSystem::setOnAllDesktops(winId(), true);
}

View File

@ -1,48 +0,0 @@
/*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 <https://www.gnu.org/licenses/>.
*
* Authors: iaom <zhangpengfei@kylinos.cn>
*
*/
#ifndef TASKMANAGERVIEW_H
#define TASKMANAGERVIEW_H
#include <QQuickView>
#include <QMainWindow>
#include <QPointer>
#include "window-thumbnail-view.h"
#include "ukui-task-manager.h"
class TaskManagerView : public QQuickView
{
Q_OBJECT
public:
TaskManagerView(QWindow *parent = nullptr);
~TaskManagerView() = default;
Q_INVOKABLE void openMenu(const QVariant &modelActions, const int &index);
private:
void initWindow();
private:
WindowThumbnailView *m_windowThumbnailView = nullptr;
TaskManager::UkuiTaskManager *m_model = nullptr;
QPointer<QMenu> m_contextMenu;
};
#endif // TASKMANAGERVIEW_H

View File

@ -1,173 +0,0 @@
/*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 <https://www.gnu.org/licenses/>.
*
* Authors: iaom <zhangpengfei@kylinos.cn>
* qiqi49 <qiqi@kylinos.cn>
*/
#include <QQmlEngine>
#include <QQmlContext>
#include "window-thumbnail-view.h"
#include "ukui-task-manager.h"
#include "actions.h"
#include <windowmanager/windowmanager.h>
class MousePressHandler : public QObject
{
Q_OBJECT
public:
explicit MousePressHandler(WindowThumbnailView *parent = nullptr);
~MousePressHandler() = default;
private:
QRect m_windowGeometry;
WindowThumbnailView *m_windowThumbnailView;
protected:
bool eventFilter(QObject *watched, QEvent *event) override;
};
MousePressHandler::MousePressHandler(WindowThumbnailView *parent) : QObject(parent)
{
m_windowThumbnailView = parent;
m_windowGeometry = m_windowThumbnailView->geometry();
}
bool MousePressHandler::eventFilter(QObject *watched, QEvent *event)
{
if (event->type() == QEvent::MouseButtonPress) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
QPoint pos = mouseEvent->globalPos();
if (!m_windowGeometry.contains(pos)) {
m_windowThumbnailView->setMenuShow(false);
m_windowThumbnailView->setViewShow(false);
}
}
return QObject::eventFilter(watched, event);
}
WindowThumbnailView::WindowThumbnailView(QWindow *parent)
{
setResizeMode(QQuickView::SizeViewToRootObject);
setFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::WindowDoesNotAcceptFocus);
setColor("transparent");
// qmlRegisterType<XWindowThumbnail>("org.ukui.taskManager.core", 1, 0, "XWindowThumbnail");
engine()->rootContext()->setContextProperty("thumbnailView", this);
engine()->rootContext()->setContextProperty("taskModel", &TaskManager::UkuiTaskManager::self());
setSource(QUrl("qrc:/ThumbnailView.qml"));
}
QStringList WindowThumbnailView::viewModel() const
{
return m_viewModel;
}
void WindowThumbnailView::setViewModel(const QStringList &model)
{
m_viewModel.clear();
if (model.isEmpty()) {
return;
}
m_viewModel = model;
Q_EMIT viewModelChanged(m_viewModel);
}
QPoint WindowThumbnailView::viewPoint() const
{
return m_viewPoint;
}
void WindowThumbnailView::setViewPoint(const QPoint &point)
{
m_viewPoint = QPoint(point.x(), point.y() - height());
}
bool WindowThumbnailView::event(QEvent *event)
{
switch (event->type()) {
case QEvent::Expose: {
if (isExposed()) {
kdk::WindowManager::setSkipTaskBar(this, true);
kdk::WindowManager::setSkipSwitcher(this, true);
kdk::WindowManager::setGeometry(this, QRect(m_viewPoint, QSize(width(), height())));
}
break;
}
default:
break;
}
return QQuickWindow::event(event);
}
void WindowThumbnailView::setViewShow(const bool &viewShow)
{
m_viewShow = viewShow;
if (!m_menuShow && !m_viewShow) {
hide();
}
}
bool WindowThumbnailView::viewShow() const
{
return m_viewShow;
}
void WindowThumbnailView::openMenu(const QString &winId)
{
TaskManager::Actions menuActions = TaskManager::UkuiTaskManager::self().windowActions(winId);
setMenuShow(true);
if (m_contextMenu) {
m_contextMenu->close();
}
QMenu *menu = new QMenu;
MousePressHandler *mousePressHandle = new MousePressHandler(this);
menu->installEventFilter(mousePressHandle);
menu->setAttribute(Qt::WA_DeleteOnClose);
for (const TaskManager::Action* menuAction : menuActions) {
menu->addAction(menuAction->internalAction());
menuAction->internalAction()->setParent(menu);
}
if (menu->actions().isEmpty()) {
delete menu;
return;
}
connect(menu, &QMenu::aboutToHide, this, [this] {
setMenuShow(false);
});
m_contextMenu = menu;
menu->popup(QCursor::pos());
}
bool WindowThumbnailView::menuShow() const
{
return m_menuShow;
}
void WindowThumbnailView::setMenuShow(const bool &menuShow)
{
m_menuShow = menuShow;
}
#include "window-thumbnail-view.moc"

View File

@ -1,72 +0,0 @@
/*
* Copyright (C) 2024, KylinSoft Co., Ltd.
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 <https://www.gnu.org/licenses/>.
*
* Authors: iaom <zhangpengfei@kylinos.cn>
* qiqi49 <qiqi@kylinos.cn>
*
*/
#ifndef UKUI_TASK_MANAGER_TASKVIEW_H
#define UKUI_TASK_MANAGER_TASKVIEW_H
#include <QQuickView>
#include <QPointer>
#include <QMenu>
class WindowThumbnailView : public QQuickView
{
Q_OBJECT
Q_PROPERTY(bool viewShow READ viewShow WRITE setViewShow NOTIFY viewShowChanged)
Q_PROPERTY(bool menuShow READ menuShow WRITE setMenuShow NOTIFY menuShowChanged)
Q_PROPERTY(QPoint viewPoint READ viewPoint WRITE setViewPoint NOTIFY viewPointChanged)
Q_PROPERTY(QStringList viewModel READ viewModel WRITE setViewModel NOTIFY viewModelChanged)
public:
explicit WindowThumbnailView(QWindow *parent = nullptr);
~WindowThumbnailView() = default;
bool viewShow() const;
void setViewShow(const bool &viewShow);
bool menuShow() const;
void setMenuShow(const bool &menuShow);
QStringList viewModel() const;
void setViewModel(const QStringList &model);
QPoint viewPoint() const;
void setViewPoint(const QPoint &point);
Q_INVOKABLE void openMenu(const QString &winId);
protected:
bool event(QEvent *event);
private:
QStringList m_viewModel;
QPoint m_viewPoint;
QPointer<QMenu> m_contextMenu;
bool m_viewShow = false;
bool m_menuShow = false;
Q_SIGNALS:
void viewModelChanged(QStringList m_viewModel);
void viewPointChanged(QPoint m_viewPoint);
void viewShowChanged(bool m_viewShow);
void menuShowChanged(bool m_menuShow);
};
#endif //UKUI_TASK_MANAGER_TASKVIEW_H

View File

@ -1,163 +0,0 @@
/*
*
* * Copyright (C) 2023, KylinSoft Co., Ltd.
* *
* * This program 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 3 of the License, or
* * (at your option) any later version.
* *
* * This program 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 <https://www.gnu.org/licenses/>.
* *
* * Authors: qiqi49 <qiqi@kylinos.cn>
*
*/
#include <QQmlEngine>
#include <QQmlContext>
#include "window-thumbnail-view.h"
#include "ukui-task-manager.h"
#include "actions.h"
#include <windowmanager/windowmanager.h>
ThumbnailView &ThumbnailView::self()
{
static ThumbnailView s_self;
return s_self;
}
QStringList ThumbnailView::viewModel() const
{
return m_viewModel;
}
void ThumbnailView::setViewModel(const QStringList &model)
{
m_viewModel.clear();
if (model.isEmpty()) {
return;
}
m_viewModel = model;
Q_EMIT viewModelChanged(m_viewModel);
}
QPoint ThumbnailView::viewPoint() const
{
return m_viewPoint;
}
void ThumbnailView::setViewPoint(const QPoint &point)
{
m_viewPoint = QPoint(point.x(), point.y() - height());
}
bool ThumbnailView::event(QEvent *event)
{
switch (event->type()) {
case QEvent::Expose: {
if (isExposed()) {
kdk::WindowManager::setSkipTaskBar(this, true);
kdk::WindowManager::setSkipSwitcher(this, true);
kdk::WindowManager::setGeometry(this, QRect(m_viewPoint, QSize(width(), height())));
// kdk::WindowManager::setGeometry(this, QRect(QPoint(100, 100), QSize(200, 200)));
}
break;
}
case QEvent::MouseButtonPress: {
if (m_menuVisible) {
m_menu->hide();
return true;
}
break;
}
default:
break;
}
return QQuickWindow::event(event);
}
ThumbnailView::ThumbnailView(QWindow *parent)
{
setResizeMode(QQuickView::SizeViewToRootObject);
setFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::WindowDoesNotAcceptFocus);
setColor("transparent");
engine()->rootContext()->setContextProperty("thumbnailView", this);
engine()->rootContext()->setContextProperty("taskModel", &TaskManager::UkuiTaskManager::self());
setSource(QUrl("qrc:/org.ukui.panel.taskManager/qml/ThumbnailView.qml"));
}
void ThumbnailView::setViewVisible(const bool &viewVisible)
{
m_viewVisible = viewVisible;
if (!m_menuVisible && !m_viewVisible) {
TaskManager::UkuiTaskManager::self().activateWindowView({});
hide();
}
}
bool ThumbnailView::viewVisible() const
{
return m_viewVisible;
}
QString ThumbnailView::getWinId() const
{
return QString::number(QWindow::winId());
}
void ThumbnailView::openMenu(const QString &winId)
{
TaskManager::Actions menuActions = TaskManager::UkuiTaskManager::self().windowActions(winId);
setMenuVisible(true);
if (m_contextMenu) {
m_contextMenu->close();
}
m_menu = new QMenu;
m_menu->setAttribute(Qt::WA_DeleteOnClose);
for (const TaskManager::Action* menuAction : menuActions) {
m_menu->addAction(menuAction->internalAction());
menuAction->internalAction()->setParent(m_menu);
}
if (m_menu->actions().isEmpty()) {
delete m_menu;
return;
}
connect(m_menu, &QMenu::aboutToHide, this, [this] {
setMenuVisible(false);
if (!geometry().contains(QCursor::pos())) {
setViewVisible(false);
}
});
connect(m_menu, &QMenu::triggered, this, [this] {
setViewVisible(false);
});
m_contextMenu = m_menu;
m_menu->popup(QCursor::pos());
}
bool ThumbnailView::menuVisible() const
{
return m_menuVisible;
}
void ThumbnailView::setMenuVisible(const bool &menuVisible)
{
m_menuVisible = menuVisible;
}

View File

@ -1,77 +0,0 @@
/*
*
* * Copyright (C) 2023, KylinSoft Co., Ltd.
* *
* * This program 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 3 of the License, or
* * (at your option) any later version.
* *
* * This program 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 <https://www.gnu.org/licenses/>.
* *
* * Authors: qiqi49 <qiqi@kylinos.cn>
*
*/
#ifndef UKUI_TASK_MANAGER_TASKVIEW_H
#define UKUI_TASK_MANAGER_TASKVIEW_H
#include <QQuickView>
#include <QPointer>
#include <QMenu>
class ThumbnailView : public QQuickView
{
Q_OBJECT
Q_PROPERTY(bool viewVisible READ viewVisible WRITE setViewVisible NOTIFY viewVisibleChanged)
Q_PROPERTY(QPoint viewPoint READ viewPoint WRITE setViewPoint NOTIFY viewPointChanged)
Q_PROPERTY(QStringList viewModel READ viewModel WRITE setViewModel NOTIFY viewModelChanged)
Q_PROPERTY(bool menuVisible READ menuVisible WRITE setMenuVisible NOTIFY menuVisibleChanged)
Q_PROPERTY(QString winId READ getWinId)
public:
static ThumbnailView &self();
~ThumbnailView() = default;
bool viewVisible() const;
void setViewVisible(const bool &viewVisible);
QStringList viewModel() const;
void setViewModel(const QStringList &model);
QPoint viewPoint() const;
void setViewPoint(const QPoint &point);
QString getWinId() const;
bool menuVisible() const;
void setMenuVisible(const bool &menuVisible);
Q_INVOKABLE void openMenu(const QString &winId);
protected:
bool event(QEvent *event);
private:
explicit ThumbnailView(QWindow *parent = nullptr);
QStringList m_viewModel;
QPoint m_viewPoint;
bool m_viewVisible = false;
bool m_menuVisible = false;
QPointer<QMenu> m_contextMenu;
QMenu *m_menu;
Q_SIGNALS:
void viewModelChanged(QStringList m_viewModel);
void viewPointChanged(QPoint m_viewPoint);
void viewVisibleChanged(bool m_viewVisible);
void menuVisibleChanged(bool m_menuVisible);
};
#endif //UKUI_TASK_MANAGER_TASKVIEW_H