Skip to content

Commit

Permalink
feat: [workspace] minimum workspace plugin
Browse files Browse the repository at this point in the history
minimum workspace plugin

Log: add minimum workspace plugin
  • Loading branch information
Lighto-Ku authored and Johnson-zs committed Jun 20, 2024
1 parent f515ff9 commit 33ecafa
Show file tree
Hide file tree
Showing 25 changed files with 122 additions and 80 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ endif()
#CMake module
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(install_plugin_quick_module)
include(install_dconfig)

# Select major version.
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/dfm-base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ install(FILES ${AssetsPath}/log/viewer/dde-file-manager.json DESTINATION ${LogVi
set(LogDebugConfDir "${CMAKE_INSTALL_PREFIX}/share/deepin-debug-config/deepin-debug-config.d")
install(FILES ${AssetsPath}/log/debug/org.deepin.file-manager.json DESTINATION ${LogDebugConfDir})

include(${CMAKE_SOURCE_DIR}/install_dconfig.cmake)
# install dconfig files.
INSTALL_DCONFIG("org.deepin.dde.file-manager.json")
INSTALL_DCONFIG("org.deepin.dde.file-manager.plugins.json")
INSTALL_DCONFIG("org.deepin.dde.file-manager.view.json")
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/filemanager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ add_subdirectory(core/dfmplugin-core)
# add_subdirectory(core/dfmplugin-recent)
add_subdirectory(core/dfmplugin-sidebar)
add_subdirectory(core/dfmplugin-titlebar)
# add_subdirectory(core/dfmplugin-workspace)
add_subdirectory(core/dfmplugin-workspace)
add_subdirectory(core/dfmplugin-detailspace)
# add_subdirectory(core/dfmplugin-computer)
# add_subdirectory(core/dfmplugin-trash)
Expand Down
4 changes: 0 additions & 4 deletions src/plugins/filemanager/core/dfmplugin-core/FileWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ ApplicationWindow {
// For local module test
ActionMenu {
}

SplitView {
anchors.fill: parent

Expand All @@ -61,7 +60,6 @@ ApplicationWindow {
width: 200
}
}

ColumnLayout {
SplitView.fillHeight: true
SplitView.fillWidth: true
Expand All @@ -70,7 +68,6 @@ ApplicationWindow {
id: titlebar

}

RowLayout {
Layout.fillHeight: true
Layout.fillWidth: true
Expand All @@ -79,7 +76,6 @@ ApplicationWindow {
id: workspace

}

LayoutItemProxy {
id: detailspace

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ install(TARGETS
)

# install dconfig files.
include(${CMAKE_SOURCE_DIR}/install_dconfig.cmake)
INSTALL_DCONFIG("org.deepin.dde.file-manager.sidebar.json")

# install qml file
Expand Down
4 changes: 1 addition & 3 deletions src/plugins/filemanager/core/dfmplugin-sidebar/Sidebar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,15 @@ AppletItem {
text: fileName
}
}

FolderListModel {
id: folderModel

folder: "File:///home/uos"
folder: "File:///home"
nameFilters: ["*"]
showDirs: true
showDirsFirst: true
}
}

Text {
color: "lightgray"
font.pointSize: 36
Expand Down
20 changes: 5 additions & 15 deletions src/plugins/filemanager/core/dfmplugin-workspace/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,11 @@ project(dfmplugin-workspace)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# TODO(zhangs): remove private
FILE(GLOB WORKSPACE_FILES
FILE(GLOB_RECURSE WORKSPACE_FILES CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/utils/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/utils/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/events/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/events/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/menus/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/menus/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/views/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/views/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/models/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/models/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/views/private/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/views/private/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/models/private/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/models/private/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/*.json"
"${CMAKE_CURRENT_SOURCE_DIR}/*.qml"
)
find_package(Dtk${DTK_VERSION_MAJOR} COMPONENTS Widget REQUIRED)

Expand Down Expand Up @@ -51,3 +38,6 @@ install(TARGETS
DESTINATION
${DFM_PLUGIN_FILEMANAGER_CORE_DIR}
)

#Install qml file
INSTALL_PLUGIN_QUICK_MODULE(${DFM_PLUGIN_FILEMANAGER_CORE_DIR})
41 changes: 41 additions & 0 deletions src/plugins/filemanager/core/dfmplugin-workspace/Workspace.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import org.dfm.base

ContainmentItem {
property int widgetType: QuickUtils.WorkSpace

Layout.fillHeight: true
Layout.fillWidth: true

Component.onCompleted:
// do init Workspace
{
}

SplitView {
id: workspaceMainSpliteContainer

anchors.fill: parent

Rectangle {
id: tempViewRect

SplitView.fillWidth: true
SplitView.minimumWidth: 200
color: "lightblue"

Text {
anchors.centerIn: parent
color: "black"
font.pointSize: 36
text: "Workspace"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ WorkspaceEventReceiver::WorkspaceEventReceiver(QObject *parent)

WorkspaceEventReceiver::~WorkspaceEventReceiver()
{
dpfSignalDispatcher->unsubscribe("dfmplugin_trashcore", "signal_TrashCore_TrashStateChanged",
WorkspaceHelper::instance(), &WorkspaceHelper::trashStateChanged);
// dpfSignalDispatcher->unsubscribe("dfmplugin_trashcore", "signal_TrashCore_TrashStateChanged",
// WorkspaceHelper::instance(), &WorkspaceHelper::trashStateChanged);
}

WorkspaceEventReceiver *WorkspaceEventReceiver::instance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void BaseSortMenuScenePrivate::sortMenuActions(QMenu *menu, const QStringList &s

auto actions = menu->actions();
// sort
qSort(actions.begin(), actions.end(), [findIndex](QAction *act1, QAction *act2) {
std::sort(actions.begin(), actions.end(), [findIndex](QAction *act1, QAction *act2) {
const auto &property1 = act1->property(ActionID::kActionID).toString();
auto index1 = findIndex(property1);
if (index1 == -1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#include <dfm-base/dfm_menu_defines.h>
#include <dfm-base/interfaces/private/abstractmenuscene_p.h>

#include <QGSettings>

namespace dfmplugin_workspace {

class FileView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <dfm-io/dfmio_utils.h>

#include <QStandardPaths>
#include <QRegularExpression>

using namespace dfmplugin_workspace;
using namespace dfmbase::Global;
Expand Down Expand Up @@ -776,10 +777,10 @@ void FileSortWorker::checkNameFilters(const FileItemDataPointer itemData)
if (!itemData || itemData->data(Global::ItemRoles::kItemFileIsDirRole).toBool() || nameFilters.isEmpty())
return;

QRegExp re("", Qt::CaseInsensitive, QRegExp::Wildcard);
for (int i = 0; i < nameFilters.size(); ++i) {
re.setPattern(nameFilters.at(i));
if (re.exactMatch(itemData->data(kItemNameRole).toString())) {
QRegularExpression re(QRegularExpression::anchoredPattern(QRegularExpression::wildcardToRegularExpression(nameFilters.at(i))));
QRegularExpressionMatchIterator it = re.globalMatch(itemData->data(kItemNameRole).toString());
if (it.hasNext()) {
itemData->setAvailableState(true);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ void FileViewHelper::initStyleOption(QStyleOptionViewItem *option, const QModelI
setcolor1(option->palette, appPalette, QPalette::Shadow);

if ((option->state & QStyle::State_HasFocus) && option->showDecorationSelected && selectedIndexsCount() > 1) {
setcolor2(option->palette, appPalette, QPalette::Current, QPalette::Background);
setcolor2(option->palette, appPalette, QPalette::Current, QPalette::Window);
} else {
setcolor2(option->palette, appPalette, QPalette::Normal, QPalette::Background);
setcolor2(option->palette, appPalette, QPalette::Normal, QPalette::Window);
}

bool transp = isTransparent(index);
option->backgroundBrush = appPalette.brush(transp ? QPalette::Inactive : QPalette::Current, QPalette::Background);
option->backgroundBrush = appPalette.brush(transp ? QPalette::Inactive : QPalette::Current, QPalette::Window);

option->textElideMode = Qt::ElideLeft;
}
Expand Down Expand Up @@ -238,10 +238,11 @@ bool FileViewHelper::isEmptyArea(const QPoint &pos)
if (!(index.flags() & Qt::ItemIsSelectable))
return true;

QStyleOptionViewItem option = parent()->viewOptions();
option.rect = rect;
QStyleOptionViewItem *option = nullptr;
parent()->initViewItemOption(option);
option->rect = rect;

const QList<QRect> &geometryList = itemDelegate()->paintGeomertys(option, index);
const QList<QRect> &geometryList = itemDelegate()->paintGeomertys(*option, index);
auto ret = std::any_of(geometryList.begin(), geometryList.end(), [pos](const QRect &geometry) {
return geometry.contains(pos);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include <QPainter>
#include <QApplication>
#include <QTextCodec>
#include <QPainterPath>

#include <cmath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ QPixmap ViewDrawHelper::renderDragPixmap(dfmbase::Global::ViewMode mode, QModelI
indexes.removeAll(topIndex);

const qreal scale = view->devicePixelRatioF();
QStyleOptionViewItem option = view->viewOptions();
option.state |= QStyle::State_Selected;
option.rect = option.rect.translated(kDragIconOutline, kDragIconOutline);
// QStyleOptionViewItem option = view->viewOptions();
QStyleOptionViewItem *option = nullptr;
view->initViewItemOption(option);
option->state |= QStyle::State_Selected;
option->rect = option->rect.translated(kDragIconOutline, kDragIconOutline);

if (mode == ViewMode::kIconMode) {
QRectF rect = view->visualRect(topIndex);
Expand All @@ -52,9 +54,9 @@ QPixmap ViewDrawHelper::renderDragPixmap(dfmbase::Global::ViewMode mode, QModelI

QPainter painter(&pixmap);

drawDragIcons(&painter, option, pixRect, indexes, topIndex);
drawDragIcons(&painter, *option, pixRect, indexes, topIndex);
if (dragCount != 1)
drawDragCount(&painter, topIndex, option, dragCount);
drawDragCount(&painter, topIndex, *option, dragCount);
else
drawDragText(&painter, topIndex, rect.width() - 2 * kIconModeTextPadding - 2 * kIconModeColumuPadding - kIconModeBackRadius);

Expand All @@ -72,11 +74,11 @@ QPixmap ViewDrawHelper::renderDragPixmap(dfmbase::Global::ViewMode mode, QModelI
QPainter painter(&pixmap);

if (indexes.isEmpty()) {
drawDragIcons(&painter, option, pixRect, indexes, topIndex);
drawDragIcons(&painter, *option, pixRect, indexes, topIndex);
drawDragText(&painter, topIndex, kListDragTextWidth);
} else {
drawDragIcons(&painter, option, pixRect, indexes, topIndex);
drawDragCount(&painter, topIndex, option, dragCount);
drawDragIcons(&painter, *option, pixRect, indexes, topIndex);
drawDragCount(&painter, topIndex, *option, dragCount);
}

return pixmap;
Expand Down
37 changes: 22 additions & 15 deletions src/plugins/filemanager/core/dfmplugin-workspace/views/fileview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ FileView::~FileView()
disconnect(model(), &FileViewModel::stateChanged, this, &FileView::onModelStateChanged);
disconnect(selectionModel(), &QItemSelectionModel::selectionChanged, this, &FileView::onSelectionChanged);

dpfSignalDispatcher->unsubscribe("dfmplugin_workspace", "signal_View_HeaderViewSectionChanged", this, &FileView::onHeaderViewSectionChanged);
dpfSignalDispatcher->unsubscribe("dfmplugin_filepreview", "signal_ThumbnailDisplay_Changed", this, &FileView::onWidgetUpdate);
// dpfSignalDispatcher->unsubscribe("dfmplugin_workspace", "signal_View_HeaderViewSectionChanged", this, &FileView::onHeaderViewSectionChanged);
// dpfSignalDispatcher->unsubscribe("dfmplugin_filepreview", "signal_ThumbnailDisplay_Changed", this, &FileView::onWidgetUpdate);
}

QWidget *FileView::widget() const
Expand Down Expand Up @@ -361,16 +361,18 @@ void FileView::onSectionHandleDoubleClicked(int logicalIndex)
if (rowCount < 1)
return;

QStyleOptionViewItem option = viewOptions();
QStyleOptionViewItem *option = nullptr;
initViewItemOption(option);
// QStyleOptionViewItem option = viewOptions();

option.rect.setWidth(QWIDGETSIZE_MAX);
option.rect.setHeight(itemSizeHint().height());
option->rect.setWidth(QWIDGETSIZE_MAX);
option->rect.setHeight(itemSizeHint().height());

int columnMaxWidth = 0;

for (int i = 0; i < rowCount; ++i) {
const QModelIndex &index = model()->index(i, 0, rootIndex());
const QList<QRect> &list = itemDelegate()->paintGeomertys(option, index, true);
const QList<QRect> &list = itemDelegate()->paintGeomertys(*option, index, true);

// 第0列为文件名列,此列比较特殊,因为前面还有文件图标占用了一部分空间
int width = 0;
Expand Down Expand Up @@ -490,7 +492,7 @@ void FileView::wheelEvent(QWheelEvent *event)
verticalScrollBar()->setSliderPosition(verticalScrollBar()->sliderPosition() - event->angleDelta().y());
#endif
}
} else if (event->modifiers() == Qt::AltModifier || event->orientation() == Qt::Horizontal) {
} else if (event->modifiers() == Qt::AltModifier || event->angleDelta().x() != 0) {
horizontalScrollBar()->setSliderPosition(horizontalScrollBar()->sliderPosition() - event->angleDelta().x());
} else {
#ifdef QT_SCROLL_WHEEL_ANI
Expand Down Expand Up @@ -767,9 +769,10 @@ void FileView::updateViewportContentsMargins(const QSize &itemSize)
bool FileView::indexInRect(const QRect &actualRect, const QModelIndex &index)
{
auto paintRect = visualRect(index);
auto opt = viewOptions();
opt.rect = paintRect;
auto rectList = itemDelegate()->itemGeomertys(opt, index);
QStyleOptionViewItem *opt = nullptr;
initViewItemOption(opt);
opt->rect = paintRect;
auto rectList = itemDelegate()->itemGeomertys(*opt, index);
for (const auto &rect : rectList) {
if (!(actualRect.left() > rect.right()
|| actualRect.top() > rect.bottom()
Expand Down Expand Up @@ -907,8 +910,11 @@ int FileView::itemCountForRow() const

QSize FileView::itemSizeHint() const
{
QStyleOptionViewItem *opt = nullptr;
initViewItemOption(opt);

if (itemDelegate())
return itemDelegate()->sizeHint(viewOptions(), rootIndex());
return itemDelegate()->sizeHint(*opt, rootIndex());

return QSize();
}
Expand Down Expand Up @@ -1074,9 +1080,10 @@ QModelIndex FileView::iconIndexAt(const QPoint &pos, const QSize &itemSize) cons

auto currentIndex = model()->index(index, 0, rootIndex());
auto paintRect = visualRect(currentIndex);
auto opt = viewOptions();
opt.rect = paintRect;
auto rectList = itemDelegate()->itemGeomertys(opt, currentIndex);
QStyleOptionViewItem *opt = nullptr;
initViewItemOption(opt);
opt->rect = paintRect;
auto rectList = itemDelegate()->itemGeomertys(*opt, currentIndex);
for (const auto &rect : rectList) {
if (rect.contains(pos))
return currentIndex;
Expand Down Expand Up @@ -1492,7 +1499,7 @@ void FileView::startDrag(Qt::DropActions supportedActions)
UniversalUtils::urlsTransformToLocal(treeSelectedUrl, &transformedUrls);
QByteArray ba;
for (const auto &url : transformedUrls) {
ba.append(url.toString() + "\n");
ba.append(QString(url.toString() + "\n").toLatin1());
}
data->setData(DFMGLOBAL_NAMESPACE::Mime::kDFMTreeUrlsKey, ba);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ void IconItemEditor::updateStyleSheet()
QString base = "IconItemEditor[showBackground=true] QTextEdit {background: %1; color: %2;}";

base.append("IconItemEditor QTextEdit {color: %3}");
base = base.arg(palette().color(QPalette::Background).name(QColor::HexArgb))
base = base.arg(palette().color(QPalette::Window).name(QColor::HexArgb))
.arg(palette().color(QPalette::BrightText).name(QColor::HexArgb))
.arg(palette().color(QPalette::Text).name(QColor::HexArgb));

Expand Down
Loading

0 comments on commit 33ecafa

Please sign in to comment.