Replace Simple View and Tree view by an icon view and compact view
AbandonedPublic

Authored by meven on May 19 2019, 8:25 AM.

Details

Reviewers
ngraham
Group Reviewers
Frameworks
Summary

Remove the simple view with the decoration position option, splitting the feature between an IconView and a Compact View (replacing the Tree view)

A step towards "Make the view modes match the ones in Dolphin (e.g. Icons, Compact, and Details, with an option for "Allow expansion" in the settings menu" of T8552

This may break users of fileWidgets if they relied on "Tree" or "Simple" view, so we might need to discuss this issue first.

Test Plan

Compact view:

Icon view:

Diff Detail

Repository
R241 KIO
Branch
icon-compact-views
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 11970
Build 11988: arc lint + arc unit
meven created this revision.May 19 2019, 8:25 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptMay 19 2019, 8:25 AM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
meven requested review of this revision.May 19 2019, 8:25 AM
meven edited the summary of this revision. (Show Details)May 19 2019, 8:27 AM
meven edited the test plan for this revision. (Show Details)
meven added a reviewer: ngraham.
meven updated this revision to Diff 58279.May 19 2019, 8:28 AM

Capitalization

meven updated this revision to Diff 58280.May 19 2019, 9:00 AM

Rename IconView kind Simple to Icon

meven updated this revision to Diff 58303.May 19 2019, 1:53 PM

Clean up reference to action decoration menu

meven updated this revision to Diff 58333.May 20 2019, 8:51 AM

Reword Icon View to Icons View

meven updated this revision to Diff 58334.May 20 2019, 9:11 AM

Extract KDirOperatorIconView to its own class

meven updated this revision to Diff 58336.May 20 2019, 9:19 AM

Keep DetailTree as default file view

meven edited the summary of this revision. (Show Details)May 20 2019, 9:24 AM
meven updated this revision to Diff 58337.May 20 2019, 9:27 AM

Clean up

meven added a comment.May 20 2019, 6:21 PM

This patch seems to me now inappropriate given the history of D12358 and D12326.

I only see a possibility in having Icons View and Compact view as Dolphin has without changing behavior and breaking things as adding more view types to KDirOperator (Icons and Compact), simply not using it in the KFileWidget.

I was working on this myself last month by implementing new modes that are an amalgamation of existing settings, so nobody gets broken and backwards compatibility is ensured. I gotpretty far, but I hit a frustrating wall and forgot about it. :/ Your work here reminded me about it so I've re-based the patch, cleaned it up a bit, and fixed the problem I was having before (sometimes you just need to sleep on it for a month, eh?). I'll gladly hand off the work I've done so far to you if you want to finish it up. The TODO in the diff is accurate.

1diff --git a/src/filewidgets/kdiroperator.cpp b/src/filewidgets/kdiroperator.cpp
2index 3dc2b8a6..0c9359f8 100644
3--- a/src/filewidgets/kdiroperator.cpp
4+++ b/src/filewidgets/kdiroperator.cpp
5@@ -212,6 +212,9 @@ public:
6 void _k_slotSortByType();
7 void _k_slotSortReversed(bool doReverse);
8 void _k_slotToggleDirsFirst();
9+ void _k_slotToggleIconsView();
10+ void _k_slotToggleCompactView();
11+ void _k_slotToggleDetailsView();
12 void _k_slotToggleIgnoreCase();
13 void _k_slotStarted();
14 void _k_slotProgress(int);
15@@ -712,6 +715,51 @@ void KDirOperator::Private::_k_slotToggleDirsFirst()
16 updateSorting(s);
17 }
18
19+void KDirOperator::Private::_k_slotToggleIconsView()
20+{
21+ // Switch to simple view
22+ KFile::FileView fileView = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Simple);
23+ parent->setView(fileView);
24+
25+ // Put the icons on top
26+ actionCollection->action(QStringLiteral("decorationAtTop"))->setChecked(true);
27+ decorationPosition = QStyleOptionViewItem::Top;
28+
29+ QListView *listView = qobject_cast<QListView *>(itemView);
30+ listView->setFlow(QListView::LeftToRight);
31+
32+ updateListViewGrid();
33+ listView->update();
34+}
35+
36+void KDirOperator::Private::_k_slotToggleCompactView()
37+{
38+ // Switch to simple view
39+ KFile::FileView fileView = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Simple);
40+ parent->setView(fileView);
41+
42+ // Put the icons on the side
43+ actionCollection->action(QStringLiteral("decorationAtLeft"))->setChecked(true);
44+ decorationPosition = QStyleOptionViewItem::Left;
45+
46+ QListView *listView = qobject_cast<QListView *>(itemView);
47+ listView->setFlow(QListView::TopToBottom);
48+
49+ updateListViewGrid();
50+ listView->update();
51+}
52+
53+void KDirOperator::Private::_k_slotToggleDetailsView()
54+{
55+ KFile::FileView view;
56+ if (true) {
57+ view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::DetailTree);
58+ } else {
59+ view = static_cast<KFile::FileView>((viewKind & ~allViews()) | KFile::Detail);
60+ }
61+ parent->setView(view);
62+}
63+
64 void KDirOperator::Private::_k_slotToggleIgnoreCase()
65 {
66 // TODO: port to Qt4's QAbstractItemView
67@@ -2000,6 +2048,34 @@ void KDirOperator::setupActions()
68 d->actionCollection->addAction(QStringLiteral("dirs first"), dirsFirstAction);
69 connect(dirsFirstAction, SIGNAL(triggered(bool)), this, SLOT(_k_slotToggleDirsFirst()));
70
71+ // View modes that match those of Dolphin
72+ /*
73+ TODO:
74+ - Make buttons reflect current state when opening in icons or compact view
75+ - Make compact view use a smaller icon size by default, like detailed tree view does
76+ - Implement "Allow Expansion" option for the configure menu in the corner that toggles between detailed view and detailed tree view
77+*/
78+ KToggleAction *iconsViewAction = new KToggleAction(i18n("Icons View"), this);
79+ iconsViewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-list-icons")));
80+ d->actionCollection->addAction(QStringLiteral("icons view"), iconsViewAction);
81+ connect(iconsViewAction, SIGNAL(triggered(bool)), this, SLOT(_k_slotToggleIconsView()));
82+
83+ KToggleAction *compactViewAction = new KToggleAction(i18n("Compact View"), this);
84+ compactViewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-list-details")));
85+ d->actionCollection->addAction(QStringLiteral("compact view"), compactViewAction);
86+ connect(compactViewAction, SIGNAL(triggered(bool)), this, SLOT(_k_slotToggleCompactView()));
87+
88+ KToggleAction *detailsViewAction = new KToggleAction(i18n("Details View"), this);
89+ detailsViewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-list-tree")));
90+ d->actionCollection->addAction(QStringLiteral("details view"), detailsViewAction);
91+ connect(detailsViewAction, SIGNAL(triggered(bool)), this, SLOT(_k_slotToggleDetailsView()));
92+
93+ QActionGroup *viewModeGroup = new QActionGroup(this);
94+ viewModeGroup->setExclusive(true);
95+ iconsViewAction->setActionGroup(viewModeGroup);
96+ compactViewAction->setActionGroup(viewModeGroup);
97+ detailsViewAction->setActionGroup(viewModeGroup);
98+
99 d->decorationMenu = new KActionMenu(i18n("Icon Position"), this);
100 d->actionCollection->addAction(QStringLiteral("decoration menu"), d->decorationMenu);
101
102@@ -2015,6 +2091,7 @@ void KDirOperator::setupActions()
103 d->decorationMenu->addAction(topAction);
104
105 QActionGroup *decorationGroup = new QActionGroup(this);
106+ decorationGroup->setExclusive(true);
107 d->leftAction->setActionGroup(decorationGroup);
108 topAction->setActionGroup(decorationGroup);
109
110@@ -2181,6 +2258,8 @@ void KDirOperator::updateViewActions()
111 d->actionCollection->action(QStringLiteral("detailed view"))->setChecked(KFile::isDetailView(fv));
112 d->actionCollection->action(QStringLiteral("tree view"))->setChecked(KFile::isTreeView(fv));
113 d->actionCollection->action(QStringLiteral("detailed tree view"))->setChecked(KFile::isDetailTreeView(fv));
114+
115+ d->actionCollection->action(QStringLiteral("details view"))->setChecked(KFile::isDetailTreeView(fv) || KFile::isDetailView(fv));
116 }
117
118 void KDirOperator::readConfig(const KConfigGroup &configGroup)
119diff --git a/src/filewidgets/kdiroperator.h b/src/filewidgets/kdiroperator.h
120index 5fd1a93c..5e1d98c1 100644
121--- a/src/filewidgets/kdiroperator.h
122+++ b/src/filewidgets/kdiroperator.h
123@@ -936,6 +936,9 @@ private:
124 Q_PRIVATE_SLOT(d, void _k_slotSortByType())
125 Q_PRIVATE_SLOT(d, void _k_slotSortReversed(bool))
126 Q_PRIVATE_SLOT(d, void _k_slotToggleDirsFirst())
127+ Q_PRIVATE_SLOT(d, void _k_slotToggleIconsView())
128+ Q_PRIVATE_SLOT(d, void _k_slotToggleCompactView())
129+ Q_PRIVATE_SLOT(d, void _k_slotToggleDetailsView())
130 Q_PRIVATE_SLOT(d, void _k_slotToggleIgnoreCase())
131 Q_PRIVATE_SLOT(d, void _k_slotStarted())
132 Q_PRIVATE_SLOT(d, void _k_slotProgress(int))
133diff --git a/src/filewidgets/kfilewidget.cpp b/src/filewidgets/kfilewidget.cpp
134index 39020c39..3dc150bc 100644
135--- a/src/filewidgets/kfilewidget.cpp
136+++ b/src/filewidgets/kfilewidget.cpp
137@@ -487,6 +487,7 @@ KFileWidget::KFileWidget(const QUrl &_startDir, QWidget *parent)
138 connect(showBookmarksAction, SIGNAL(toggled(bool)),
139 SLOT(_k_toggleBookmarks(bool)));
140
141+ // Build the settings menu
142 KActionMenu *menu = new KActionMenu(QIcon::fromTheme(QStringLiteral("configure")), i18n("Options"), this);
143 coll->addAction(QStringLiteral("extra menu"), menu);
144 menu->setWhatsThis(i18n("<qt>This is the preferences menu for the file dialog. "
145@@ -497,12 +498,8 @@ KFileWidget::KFileWidget(const QUrl &_startDir, QWidget *parent)
146 "<li>the Places panel</li>"
147 "<li>file previews</li>"
148 "<li>separating folders from files</li></ul></qt>"));
149- menu->addAction(coll->action(QStringLiteral("view menu")));
150- menu->addSeparator();
151- menu->addAction(coll->action(QStringLiteral("decoration menu")));
152- menu->addSeparator();
153+
154 menu->addAction(coll->action(QStringLiteral("show hidden")));
155- menu->addSeparator();
156 menu->addAction(showSidebarAction);
157 menu->addAction(showBookmarksAction);
158 menu->addAction(coll->action(QStringLiteral("preview")));
159@@ -543,6 +540,10 @@ KFileWidget::KFileWidget(const QUrl &_startDir, QWidget *parent)
160 d->toolbar->addAction(coll->action(QStringLiteral("up")));
161 d->toolbar->addAction(coll->action(QStringLiteral("reload")));
162 d->toolbar->addSeparator();
163+ d->toolbar->addAction(coll->action(QStringLiteral("icons view")));
164+ d->toolbar->addAction(coll->action(QStringLiteral("compact view")));
165+ d->toolbar->addAction(coll->action(QStringLiteral("details view")));
166+ d->toolbar->addSeparator();
167 d->toolbar->addAction(coll->action(QStringLiteral("inline preview")));
168 d->toolbar->addAction(coll->action(QStringLiteral("sorting menu")));
169 d->toolbar->addWidget(midSpacer);

meven abandoned this revision.May 21 2019, 6:56 AM

Thanks I'd be happy to take over.
Some of the changes I did seem to me nice to have like moving class kdiroperatoriconview out of kdiroperator.cpp file and I am thinking about doing it again.