Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions panels/dock/OverflowContainer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

import QtQuick 2.15
import QtQuick.Layouts 2.15
import QtQuick.Controls 2.15

Item {
id: root
required property bool useColumnLayout
property bool atViewBeginning: useColumnLayout ? listView.atYBeginning : listView.atXBeginning
property bool atViewEnd: useColumnLayout ? listView.atYEnd : listView.atXEnd
property alias model: listView.model
property alias delegate: listView.delegate
property alias spacing: listView.spacing
Expand All @@ -16,13 +19,49 @@ Item {
property alias remove: listView.remove
property alias move: listView.move
property alias displaced: listView.displaced
property alias interactive: listView.interactive
property alias header: listView.header
property alias footer: listView.footer

function forceLayout() {
listView.forceLayout()
}

function scrollIncrease() {
if (useColumnLayout) {
vsb.increase()
} else {
hsb.increase()
}
}

function scrollDecrease() {
if (useColumnLayout) {
vsb.decrease()
} else {
hsb.decrease()
}
}

ListView {
id: listView
anchors.fill: parent
orientation: useColumnLayout ? ListView.Vertical : ListView.Horizontal
orientation: root.useColumnLayout ? ListView.Vertical : ListView.Horizontal
layoutDirection: Qt.LeftToRight
verticalLayoutDirection: ListView.TopToBottom
boundsBehavior: Flickable.StopAtBounds
interactive: false
cacheBuffer: 100
ScrollBar.horizontal: ScrollBar {
id: hsb
enabled: !root.useColumnLayout
policy: ScrollBar.AlwaysOff
}
ScrollBar.vertical: ScrollBar {
id: vsb
enabled: root.useColumnLayout
policy: ScrollBar.AlwaysOff
}
}

function calculateImplicitWidth(prev, current) {
Expand Down Expand Up @@ -52,7 +91,7 @@ Item {
for (let child of listView.contentItem.visibleChildren) {
width = calculateImplicitWidth(width, child.implicitWidth)
}
// TODO: abvoe qt6.8 implicitSize to 0 will make size to 0 default.
// TODO: above qt6.8 implicitSize to 0 will make size to 0 default.
// so make minimum implicitSize to 1, find why and remove below
return Math.max(width, 1)
}
Expand Down
11 changes: 0 additions & 11 deletions panels/dock/taskmanager/abstractwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,6 @@ class AbstractWindow : public QObject
Q_PROPERTY(bool shouldSkip READ shouldSkip NOTIFY shouldSkipChanged FINAL)

public:
enum Roles {
winIdRole = Qt::UserRole + 1,
pidRole,
identityRole,
winIconRole,
winTitleRole,
activieRole,
shouldSkipRole
};
Q_ENUM(Roles)

virtual ~AbstractWindow() {};

virtual uint32_t id() = 0;
Expand Down
129 changes: 90 additions & 39 deletions panels/dock/taskmanager/abstractwindowmonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,83 @@

#include "abstractwindowmonitor.h"
#include "abstractwindow.h"
#include "globals.h"
#include "taskmanager.h"

namespace dock {
AbstractWindowMonitor::AbstractWindowMonitor(QObject* parent)
AbstractWindowMonitor::AbstractWindowMonitor(QObject *parent)
: QAbstractListModel(parent)
, AbstractTaskManagerInterface(nullptr)
{
}

QHash<int, QByteArray> AbstractWindowMonitor::roleNames() const
{
return {
{AbstractWindow::winIdRole, "winId"},
{AbstractWindow::pidRole, "pid"},
{AbstractWindow::identityRole, "identity"},
{AbstractWindow::winIconRole, "icon"},
{AbstractWindow::winTitleRole, "title"},
{AbstractWindow::activieRole, "isActive"},
{AbstractWindow::shouldSkipRole, "shouldSkip"}
};
return {{TaskManager::WinIdRole, MODEL_WINID},
{TaskManager::PidRole, MODEL_PID},
{TaskManager::IdentityRole, MODEL_IDENTIFY},
{TaskManager::WinIconRole, MODEL_WINICON},
{TaskManager::WinTitleRole, MODEL_TITLE},
{TaskManager::ActiveRole, MODEL_ACTIVE},
{TaskManager::ShouldSkipRole, MODEL_SHOULDSKIP}};
}

int AbstractWindowMonitor::rowCount(const QModelIndex &parent) const
{
return m_trackedWindows.size();
}

void AbstractWindowMonitor::requestActivate(const QModelIndex &index) const
{
auto window = m_trackedWindows.value(index.row(), nullptr);
if (nullptr == window)
return;

if (window->isActive()) {
window->minimize();
} else {
window->activate();
}
}

void AbstractWindowMonitor::requestOpenUrls(const QModelIndex &index, const QList<QUrl> &urls) const
{
}

void AbstractWindowMonitor::requestNewInstance(const QModelIndex &index, const QString &action) const
{
}

void AbstractWindowMonitor::requestClose(const QModelIndex &index, bool force) const
{
auto window = m_trackedWindows.value(index.row(), nullptr);
if (nullptr == window)
return;
if (force) {
window->killClient();
} else {
window->close();
}
}

void AbstractWindowMonitor::requestUpdateWindowGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate) const
{
}

void AbstractWindowMonitor::requestPreview(const QModelIndexList &indexes,
QObject *relativePositionItem,
int32_t previewXoffset,
int32_t previewYoffset,
uint32_t direction) const
{
qDebug() << indexes;
}

void AbstractWindowMonitor::requestWindowsView(const QModelIndexList &indexes) const
{
qDebug() << indexes;
}

QVariant AbstractWindowMonitor::data(const QModelIndex &index, int role) const
{
auto pos = index.row();
Expand All @@ -37,65 +89,65 @@ QVariant AbstractWindowMonitor::data(const QModelIndex &index, int role) const
auto window = m_trackedWindows[pos];

switch (role) {
case AbstractWindow::winIdRole:
return window->id();
case AbstractWindow::pidRole:
return window->pid();
case AbstractWindow::identityRole:
return window->identity();
case AbstractWindow::winIconRole:
return window->icon();
case AbstractWindow::winTitleRole:
return window->title();
case AbstractWindow::activieRole:
return window->isActive();
case AbstractWindow::shouldSkipRole:
return window->shouldSkip();
case TaskManager::WinIdRole:
return window->id();
case TaskManager::PidRole:
return window->pid();
case TaskManager::IdentityRole:
return window->identity();
case TaskManager::WinIconRole:
return window->icon();
case TaskManager::WinTitleRole:
return window->title();
case TaskManager::ActiveRole:
return window->isActive();
case TaskManager::ShouldSkipRole:
return window->shouldSkip();
}

return QVariant();
}

void AbstractWindowMonitor::trackWindow(AbstractWindow* window)
void AbstractWindowMonitor::trackWindow(AbstractWindow *window)
{
beginInsertRows(QModelIndex(), m_trackedWindows.size(), m_trackedWindows.size());
m_trackedWindows.append(window);
endInsertRows();

connect(window, &AbstractWindow::pidChanged, this, [this, window](){
connect(window, &AbstractWindow::pidChanged, this, [this, window]() {
auto pos = m_trackedWindows.indexOf(window);
auto modelIndex = index(pos);
Q_EMIT dataChanged(modelIndex, modelIndex, {AbstractWindow::pidRole});
Q_EMIT dataChanged(modelIndex, modelIndex, {TaskManager::PidRole});
});
connect(window, &AbstractWindow::identityChanged, this, [this, window](){
connect(window, &AbstractWindow::identityChanged, this, [this, window]() {
auto pos = m_trackedWindows.indexOf(window);
auto modelIndex = index(pos);
Q_EMIT dataChanged(modelIndex, modelIndex, {AbstractWindow::identityRole});
Q_EMIT dataChanged(modelIndex, modelIndex, {TaskManager::IdentityRole});
});
connect(window, &AbstractWindow::iconChanged, this, [this, window](){
connect(window, &AbstractWindow::iconChanged, this, [this, window]() {
auto pos = m_trackedWindows.indexOf(window);
auto modelIndex = index(pos);
Q_EMIT dataChanged(modelIndex, modelIndex, {AbstractWindow::winIconRole});
Q_EMIT dataChanged(modelIndex, modelIndex, {TaskManager::WinIconRole});
});
connect(window, &AbstractWindow::titleChanged, this, [this, window](){
connect(window, &AbstractWindow::titleChanged, this, [this, window]() {
auto pos = m_trackedWindows.indexOf(window);
auto modelIndex = index(pos);
Q_EMIT dataChanged(modelIndex, modelIndex, {AbstractWindow::winTitleRole});
Q_EMIT dataChanged(modelIndex, modelIndex, {TaskManager::WinTitleRole});
});

connect(window, &AbstractWindow::isActiveChanged, this, [this, window](){
connect(window, &AbstractWindow::stateChanged, this, [this, window]() {
auto pos = m_trackedWindows.indexOf(window);
auto modelIndex = index(pos);
Q_EMIT dataChanged(modelIndex, modelIndex, {AbstractWindow::activieRole});
Q_EMIT dataChanged(modelIndex, modelIndex, {TaskManager::ActiveRole, TaskManager::AttentionRole});
});
connect(window, &AbstractWindow::shouldSkipChanged, this, [this, window](){
connect(window, &AbstractWindow::shouldSkipChanged, this, [this, window]() {
auto pos = m_trackedWindows.indexOf(window);
auto modelIndex = index(pos);
Q_EMIT dataChanged(modelIndex, modelIndex, {AbstractWindow::shouldSkipRole});
Q_EMIT dataChanged(modelIndex, modelIndex, {TaskManager::ShouldSkipRole});
});
}

void AbstractWindowMonitor::destroyWindow(AbstractWindow * window)
void AbstractWindowMonitor::destroyWindow(AbstractWindow *window)
{
auto pos = m_trackedWindows.indexOf(window);
if (pos == -1)
Expand All @@ -106,5 +158,4 @@ void AbstractWindowMonitor::destroyWindow(AbstractWindow * window)
endRemoveRows();
}


}
20 changes: 17 additions & 3 deletions panels/dock/taskmanager/abstractwindowmonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,25 @@

#pragma once

#include "abstracttaskmanagerinterface.h"
#include "abstractwindow.h"
#include "taskmanager.h"

#include <cstdint>

Check warning on line 11 in panels/dock/taskmanager/abstractwindowmonitor.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <cstdint> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <QObject>
#include <QAbstractListModel>

namespace dock {
class AppItem;
class AbstractWindowMonitor : public QAbstractListModel
class AbstractWindowMonitor : public QAbstractListModel, public AbstractTaskManagerInterface
{
Q_OBJECT

public:
QHash<int, QByteArray> roleNames() const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = AbstractWindow::winIdRole) const override;
QVariant data(const QModelIndex &index, int role = TaskManager::WinIdRole) const override;

void trackWindow(AbstractWindow* window);
void destroyWindow(AbstractWindow * window);
Expand All @@ -33,9 +35,21 @@
// TODO: remove this when Modelized finizhed.
virtual QPointer<AbstractWindow> getWindowByWindowId(ulong windowId) = 0;

void requestActivate(const QModelIndex &index) const override;
void requestOpenUrls(const QModelIndex &index, const QList<QUrl> &urls) const override;
void requestNewInstance(const QModelIndex &index, const QString &action) const override;
void requestClose(const QModelIndex &index, bool force = false) const override;
void requestUpdateWindowGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate = nullptr) const override;

void requestPreview(const QModelIndexList &indexes,
QObject *relativePositionItem,
int32_t previewXoffset,
int32_t previewYoffset,
uint32_t direction) const override;
void requestWindowsView(const QModelIndexList &indexes) const override;

virtual void presentWindows(QList<uint32_t> windowsId) = 0;

virtual void showItemPreview(const QPointer<AppItem>& item, QObject* relativePositionItem, int32_t previewXoffset, int32_t previewYoffset, uint32_t direction) = 0;
virtual void hideItemPreview() = 0;

Q_SIGNALS:
Expand Down
3 changes: 2 additions & 1 deletion panels/dock/taskmanager/dockcombinemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ QVariant DockCombineModel::data(const QModelIndex &index, int role) const
return res;
}
case TaskManager::IconNameRole: {
QString winTitle = RoleCombineModel::data(index, m_roleMaps.value(TaskManager::WinIconRole)).toString();
auto icon = RoleCombineModel::data(index, m_roleMaps.value(TaskManager::IconNameRole)).toString();
if (icon.isEmpty()) {
icon = RoleCombineModel::data(index, m_roleMaps.value(TaskManager::WinIconRole)).toString();
Expand All @@ -71,4 +72,4 @@ QVariant DockCombineModel::data(const QModelIndex &index, int role) const

return QVariant();
}
}
}
3 changes: 1 addition & 2 deletions panels/dock/taskmanager/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

#pragma once

#include <QString>
#include <QRegularExpression>

Check warning on line 7 in panels/dock/taskmanager/globals.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QRegularExpression> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <QString>

Check warning on line 8 in panels/dock/taskmanager/globals.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QString> not found. Please note: Cppcheck does not need standard library headers to get proper results.
namespace dock {

// actions
Expand Down
Loading
Loading