summarylogtreecommitdiffstats
path: root/dolphin-klook.patch
blob: efe2e300d3781d13ded054e0ea31166ef02e48cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
diff --unified --recursive --text --color a/src/CMakeLists.txt b/src/CMakeLists.txt
--- a/src/CMakeLists.txt	2020-07-05 09:22:47.000000000 -0600
+++ b/src/CMakeLists.txt	2020-07-09 21:12:28.520719832 -0600
@@ -62,6 +62,7 @@
     kitemviews/kitemlistgroupheader.cpp
     kitemviews/kitemlistheader.cpp
     kitemviews/kitemlistselectionmanager.cpp
+    kitemviews/kitemlistklooktoggle.cpp
     kitemviews/kitemliststyleoption.cpp
     kitemviews/kitemlistview.cpp
     kitemviews/kitemlistviewaccessible.cpp
diff --unified --recursive --text --color a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
--- a/src/dolphinmainwindow.cpp	2020-07-05 09:22:47.000000000 -0600
+++ b/src/dolphinmainwindow.cpp	2020-07-09 21:31:09.427720693 -0600
@@ -84,9 +84,11 @@
 #include <QMenu>
 #include <QMenuBar>
 #include <QPushButton>
+#include <QProcess>
 #include <QShowEvent>
 #include <QStandardPaths>
 #include <QTimer>
+#include <QtGlobal>
 #include <QToolButton>
 #include <QWhatsThisClickedEvent>
 
@@ -116,11 +118,13 @@
     m_terminalPanel(nullptr),
     m_placesPanel(nullptr),
     m_tearDownFromPlacesRequested(false),
+    m_isFocusOnTerminal(false),
     m_backAction(nullptr),
     m_forwardAction(nullptr)
 {
     Q_INIT_RESOURCE(dolphin);
 
+
     new MainWindowAdaptor(this);
 
 #ifndef Q_OS_WIN
@@ -197,6 +201,8 @@
         createControlButton();
     }
 
+    connect(qApp, &QApplication::focusChanged, this, &DolphinMainWindow::focusChanged);
+
     // enable middle-click on back/forward/up to open in a new tab
     auto *middleClickEventFilter = new MiddleClickActionEventFilter(this);
     connect(middleClickEventFilter, &MiddleClickActionEventFilter::actionMiddleClicked, this, &DolphinMainWindow::slotToolBarActionMiddleClicked);
@@ -334,6 +340,14 @@
         compareFilesAction->setEnabled(false);
     }
 
+    // KLook
+    QAction* openInKLook = actionCollection()->action("open_in_KLook");
+    if ((selectedUrlsCount > 0) && (!m_isFocusOnTerminal)) {
+        openInKLook->setEnabled(true);
+    } else {
+        openInKLook->setEnabled(false);
+    }
+
     emit selectionChanged(selection);
 }
 
@@ -1632,6 +1646,14 @@
     openInNewWindow->setText(i18nc("@action:inmenu", "Open in New Window"));
     openInNewWindow->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
     connect(openInNewWindow, &QAction::triggered, this, &DolphinMainWindow::openInNewWindow);
+
+    // KLook
+    QAction* openInKLook = actionCollection()->addAction("open_in_KLook");
+    openInKLook->setText(i18nc("@action:inmenu", "Preview"));
+    actionCollection()->setDefaultShortcut(openInKLook, Qt::Key_Space);
+    openInKLook->setIcon(QIcon::fromTheme(QStringLiteral("preview")));
+    openInKLook->setEnabled(false);
+    connect(openInKLook, &QAction::triggered, this, &DolphinMainWindow::previewItem);
 }
 
 void DolphinMainWindow::setupDockWidgets()
@@ -2050,6 +2072,8 @@
             this, &DolphinMainWindow::goBack);
     connect(view, &DolphinView::goForwardRequested,
             this, &DolphinMainWindow::goForward);
+    connect(view, &DolphinView::klookTrigger,
+            this, &DolphinMainWindow::previewItem);
     connect(view, &DolphinView::urlActivated,
             this, &DolphinMainWindow::handleUrl);
 
@@ -2328,6 +2352,54 @@
     }
 }
 
+void DolphinMainWindow::previewItem()
+{
+    KFileItemList list;
+    int index = 0;
+    if ( m_activeViewContainer->view()->selectedItemsCount() > 1) {
+        list = m_activeViewContainer->view()->selectedItems();
+    } else {
+        list = m_activeViewContainer->view()->sortedItems();
+        index = list.indexOf( m_activeViewContainer->view()->selectedItems().at(0));
+    }
+    QStringList urlList;
+    foreach(KFileItem item, list)
+    {
+        urlList.append(item.url().url());
+    }
+    urlList.append("-i " + QString::number(index, 10));
+    if (!list.isEmpty())
+    {
+        QProcess* process = new QProcess();
+        connect(process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), process, &QProcess::deleteLater);
+        process->start(QString("klook"), urlList);
+    }
+}
+
+void DolphinMainWindow::focusChanged(QWidget *old, QWidget *now)
+{
+#ifndef Q_OS_WIN
+    if (now)
+    {
+        if (QString(now->metaObject()->className()).contains("Konsole::TerminalDisplay"))
+        {
+            QAction* openInKLook = actionCollection()->action("open_in_KLook");
+            m_isFocusOnTerminal = true;
+            openInKLook->setEnabled(false);
+        }
+    }
+if (old)
+    {
+        if (QString(old->metaObject()->className()).contains("Konsole::TerminalDisplay"))
+        {
+            QAction* openInKLook = actionCollection()->action("open_in_KLook");
+            m_isFocusOnTerminal = false;
+            openInKLook->setEnabled(true);
+        }
+    }
+#endif
+}
+
 bool DolphinMainWindow::isUrlOpen(const QString& url)
 {
     return m_tabWidget->isUrlOpen(QUrl::fromUserInput((url)));
diff --unified --recursive --text --color a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h
--- a/src/dolphinmainwindow.h	2020-07-05 09:22:47.000000000 -0600
+++ b/src/dolphinmainwindow.h	2020-07-09 21:33:49.805487110 -0600
@@ -38,6 +38,7 @@
 typedef KIO::FileUndoManager::CommandType CommandType;
 
 class DolphinBookmarkHandler;
+class DolphinDockWidget;
 class DolphinViewActionHandler;
 class DolphinSettingsDialog;
 class DolphinViewContainer;
@@ -53,6 +54,8 @@
 class QIcon;
 class PlacesPanel;
 class TerminalPanel;
+class Panel;
+class QWidget;
 
 /**
  * @short Main window for Dolphin.
@@ -101,6 +104,9 @@
      */
     KNewFileMenu* newFileMenu() const;
 
+    // KLook needs this
+    void focusChanged(QWidget *old, QWidget *now);
+
     void setTabsToHomeIfMountPathOpen(const QString& mountPath);
 
 public slots:
@@ -411,6 +417,11 @@
     void openInNewTab();
 
     /**
+     * Opens the selected files in KLook
+     */
+    void previewItem();
+
+    /**
      * Opens the selected folder in a new window.
      */
     void openInNewWindow();
@@ -649,6 +660,7 @@
     TerminalPanel* m_terminalPanel;
     PlacesPanel* m_placesPanel;
     bool m_tearDownFromPlacesRequested;
+    bool m_isFocusOnTerminal;
 
     KToolBarPopupAction* m_backAction;
     KToolBarPopupAction* m_forwardAction;
diff --unified --recursive --text --color a/src/kitemviews/kfileitemlistwidget.cpp b/src/kitemviews/kfileitemlistwidget.cpp
--- a/src/kitemviews/kfileitemlistwidget.cpp	2020-07-05 09:22:47.000000000 -0600
+++ b/src/kitemviews/kfileitemlistwidget.cpp	2020-07-09 21:35:51.852968051 -0600
@@ -23,6 +23,7 @@
 
 #include <KFormat>
 #include <KLocalizedString>
+#include <KIconLoader>
 
 #include <QMimeDatabase>
 
@@ -102,6 +103,44 @@
     return font;
 }
 
+QRectF KFileItemListWidget::klookToggleRect() const
+{
+    const_cast<KFileItemListWidget *>(this)->triggerCacheRefreshing();
+
+    const int iconHeight = styleOption().iconSize;
+
+    int toggleSize = KIconLoader::SizeSmall;
+    if (iconHeight >= KIconLoader::SizeEnormous) {
+        toggleSize = KIconLoader::SizeMedium;
+    } else if (iconHeight >= KIconLoader::SizeLarge) {
+        toggleSize = KIconLoader::SizeSmallMedium;
+    }
+
+    QPointF pos = QPointF(iconRect().topRight().rx() - toggleSize, iconRect().topRight().ry());
+
+    // If the selection toggle has a very small distance to the
+    // widget borders, the size of the selection toggle will get
+    // increased to prevent an accidental clicking of the item
+    // when trying to hit the toggle.
+
+    const int widgetHeight = size().height();
+    const int widgetWidth = size().width();
+    const int minMargin = 2;
+
+    if (toggleSize + minMargin * 2 >= widgetHeight) {
+        pos.rx() -= (widgetHeight - toggleSize) / 2;
+        toggleSize = widgetHeight;
+        pos.setY(0);
+    }
+    if (toggleSize + minMargin * 2 >= widgetWidth) {
+        pos.ry() -= (widgetWidth - toggleSize) / 2;
+        toggleSize = widgetWidth;
+        pos.setX(0);
+    }
+
+    return QRectF(pos, QSizeF(toggleSize, toggleSize));
+}
+
 
 KFileItemListWidget::KFileItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent) :
     KStandardItemListWidget(informant, parent)
diff --unified --recursive --text --color a/src/kitemviews/kfileitemlistwidget.h b/src/kitemviews/kfileitemlistwidget.h
--- a/src/kitemviews/kfileitemlistwidget.h	2020-07-05 09:22:47.000000000 -0600
+++ b/src/kitemviews/kfileitemlistwidget.h	2020-07-09 21:36:32.293234379 -0600
@@ -45,6 +45,7 @@
     ~KFileItemListWidget() override;
 
     static KItemListWidgetInformant* createInformant();
+    virtual QRectF klookToggleRect() const override;
 
 protected:
     bool isRoleRightAligned(const QByteArray& role) const override;
diff --unified --recursive --text --color a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp
--- a/src/kitemviews/kitemlistcontroller.cpp	2020-07-05 09:22:47.000000000 -0600
+++ b/src/kitemviews/kitemlistcontroller.cpp	2020-07-09 21:40:08.884637357 -0600
@@ -560,6 +560,14 @@
         m_selectionManager->setCurrentItem(m_pressedIndex);
         m_selectionManager->beginAnchoredSelection(m_pressedIndex);
         return true;
+
+        if (m_view->isAboveKlookToggle(m_pressedIndex, m_pressedMousePos)){
+            m_selectionManager->setSelected(m_pressedIndex, 1, KItemListSelectionManager::Select);
+            m_selectionManager->setCurrentItem(m_pressedIndex);
+            m_selectionManager->beginAnchoredSelection(m_pressedIndex);
+            emit klookTrigger();
+            return true;
+        }
     }
 
     const bool shiftPressed = event->modifiers() & Qt::ShiftModifier;
diff --unified --recursive --text --color a/src/kitemviews/kitemlistcontroller.h b/src/kitemviews/kitemlistcontroller.h
--- a/src/kitemviews/kitemlistcontroller.h	2020-07-05 09:22:47.000000000 -0600
+++ b/src/kitemviews/kitemlistcontroller.h	2020-07-09 21:40:42.294850902 -0600
@@ -221,6 +221,8 @@
 
     void selectedItemTextPressed(int index);
 
+    void klookTrigger();
+
 private slots:
     void slotViewScrollOffsetChanged(qreal current, qreal previous);
 
Only in b/src/kitemviews: kitemlistklooktoggle.cpp
Only in b/src/kitemviews: kitemlistklooktoggle.h
diff --unified --recursive --text --color a/src/kitemviews/kitemlistview.cpp b/src/kitemviews/kitemlistview.cpp
--- a/src/kitemviews/kitemlistview.cpp	2020-07-05 09:22:47.000000000 -0600
+++ b/src/kitemviews/kitemlistview.cpp	2020-07-09 21:46:10.790255371 -0600
@@ -68,6 +68,7 @@
 KItemListView::KItemListView(QGraphicsWidget* parent) :
     QGraphicsWidget(parent),
     m_enabledSelectionToggles(false),
+    m_enabledKlookToggles(false),
     m_grouped(false),
     m_supportsItemExpanding(false),
     m_editingRole(false),
@@ -291,6 +292,25 @@
     return m_enabledSelectionToggles;
 }
 
+void KItemListView::setEnabledKlookToggles(bool enabled)
+{
+    if (m_enabledKlookToggles != enabled) {
+        m_enabledKlookToggles = enabled;
+
+        QHashIterator<int, KItemListWidget*> it(m_visibleItems);
+        while (it.hasNext()) {
+            it.next();
+            it.value()->setEnabledKlookToggle(enabled);
+        }
+    }
+}
+
+bool KItemListView::enabledKlookToggles() const
+{
+    return m_enabledKlookToggles;
+}
+
+
 KItemListController* KItemListView::controller() const
 {
     return m_controller;
@@ -451,6 +471,24 @@
     return false;
 }
 
+bool KItemListView::isAboveKlookToggle(int index, const QPointF& pos) const
+{
+
+    if (!m_enabledKlookToggles) {
+        return false;
+    }
+
+    const KItemListWidget* widget = m_visibleItems.value(index);
+    if (widget) {
+        const QRectF selectionToggleRect = widget->klookToggleRect();
+        if (!selectionToggleRect.isEmpty()) {
+            const QPointF mappedPos = widget->mapFromItem(this, pos);
+            return selectionToggleRect.contains(mappedPos);
+        }
+    }
+    return false;
+}
+
 int KItemListView::firstVisibleIndex() const
 {
     return m_layouter->firstVisibleIndex();
@@ -2007,6 +2045,7 @@
     widget->setSelected(selectionManager->isSelected(index));
     widget->setHovered(false);
     widget->setEnabledSelectionToggle(enabledSelectionToggles());
+    widget->setEnabledKlookToggle(enabledKlookToggles());
     widget->setIndex(index);
     widget->setData(m_model->data(index));
     widget->setSiblingsInformation(QBitArray());
diff --unified --recursive --text --color a/src/kitemviews/kitemlistview.h b/src/kitemviews/kitemlistview.h
--- a/src/kitemviews/kitemlistview.h	2020-07-05 09:22:47.000000000 -0600
+++ b/src/kitemviews/kitemlistview.h	2020-07-09 21:47:46.836230989 -0600
@@ -110,6 +110,9 @@
     void setEnabledSelectionToggles(bool enabled);
     bool enabledSelectionToggles() const;
 
+    void setEnabledKlookToggles(bool enabled);
+    bool enabledKlookToggles() const;
+
     /**
      * @return Controller of the item-list. The controller gets
      *         initialized by KItemListController::setView() and will
@@ -167,6 +170,8 @@
      */
     qreal verticalPageStep() const;
 
+    bool isAboveKlookToggle(int index, const QPointF& pos) const;
+
     /**
      * @return Index of the item that is below the point \a pos.
      *         The position is relative to the upper right of
@@ -701,6 +706,7 @@
 
 private:
     bool m_enabledSelectionToggles;
+    bool m_enabledKlookToggles;
     bool m_grouped;
     bool m_supportsItemExpanding;
     bool m_editingRole;
diff --unified --recursive --text --color a/src/kitemviews/kitemlistwidget.cpp b/src/kitemviews/kitemlistwidget.cpp
--- a/src/kitemviews/kitemlistwidget.cpp	2020-07-05 09:22:47.000000000 -0600
+++ b/src/kitemviews/kitemlistwidget.cpp	2020-07-09 22:49:04.570195666 -0600
@@ -23,6 +23,7 @@
 
 #include "kitemlistview.h"
 #include "private/kitemlistselectiontoggle.h"
+#include "kitemlistklooktoggle.h"
 
 #include <QApplication>
 #include <QPainter>
@@ -46,6 +47,7 @@
     m_hovered(false),
     m_alternateBackground(false),
     m_enabledSelectionToggle(false),
+    m_enabledKlookToggle(false),
     m_data(),
     m_visibleRoles(),
     m_columnWidths(),
@@ -55,7 +57,8 @@
     m_hoverCache(nullptr),
     m_hoverAnimation(nullptr),
     m_selectionToggle(nullptr),
-    m_editedRole()
+    m_editedRole(),
+    m_klookToggle(nullptr)
 {
 }
 
@@ -70,6 +73,9 @@
         delete m_selectionToggle;
         m_selectionToggle = nullptr;
 
+        delete m_klookToggle;
+        m_klookToggle = nullptr;
+
         if (m_hoverAnimation) {
             m_hoverAnimation->stop();
             m_hoverOpacity = 0;
@@ -260,6 +266,10 @@
         if (m_enabledSelectionToggle && !(QApplication::mouseButtons() & Qt::LeftButton)) {
             initializeSelectionToggle();
         }
+        if (m_enabledKlookToggle && !(QApplication::mouseButtons() & Qt::LeftButton)) {
+            initializeKlookToggle();
+        }
+
     } else {
         m_hoverAnimation->setStartValue(hoverOpacity());
         m_hoverAnimation->setEndValue(0.0);
@@ -310,6 +320,19 @@
     return m_enabledSelectionToggle;
 }
 
+void KItemListWidget::setEnabledKlookToggle(bool enable)
+{
+    if (m_enabledKlookToggle != enable) {
+        m_enabledKlookToggle = enable;
+        update();
+    }
+}
+
+bool KItemListWidget::enabledKlookToggle() const
+{
+    return m_enabledKlookToggle;
+}
+
 void KItemListWidget::setSiblingsInformation(const QBitArray& siblings)
 {
     const QBitArray previous = m_siblingsInfo;
@@ -359,6 +382,11 @@
     return QRectF();
 }
 
+QRectF KItemListWidget::klookToggleRect() const
+{
+    return QRectF();
+}
+
 QRectF KItemListWidget::expansionToggleRect() const
 {
     return QRectF();
@@ -474,6 +502,8 @@
     if (!m_hovered && m_selectionToggle) {
         m_selectionToggle->deleteLater();
         m_selectionToggle = nullptr;
+        m_klookToggle->deleteLater();
+        m_klookToggle = nullptr;
     }
 }
 
@@ -492,6 +522,20 @@
     m_selectionToggle->setChecked(isSelected());
 }
 
+void KItemListWidget::initializeKlookToggle()
+{
+    Q_ASSERT(m_enabledKlookToggle);
+
+    if (!m_klookToggle) {
+        m_klookToggle = new KItemListKlookToggle(this);
+    }
+
+    const QRectF toggleRect = klookToggleRect();;
+    m_klookToggle->setPos(toggleRect.topLeft());
+    m_klookToggle->resize(toggleRect.size());
+
+}
+
 void KItemListWidget::setHoverOpacity(qreal opacity)
 {
     m_hoverOpacity = opacity;
@@ -499,6 +543,10 @@
         m_selectionToggle->setOpacity(opacity);
     }
 
+    if (m_klookToggle) {
+        m_klookToggle->setOpacity(opacity);
+    }
+
     if (m_hoverOpacity <= 0.0) {
         delete m_hoverCache;
         m_hoverCache = nullptr;
diff --unified --recursive --text --color a/src/kitemviews/kitemlistwidget.h b/src/kitemviews/kitemlistwidget.h
--- a/src/kitemviews/kitemlistwidget.h	2020-07-05 09:22:47.000000000 -0600
+++ b/src/kitemviews/kitemlistwidget.h	2020-07-09 21:56:43.778503200 -0600
@@ -31,6 +31,7 @@
 
 class KItemListSelectionToggle;
 class KItemListView;
+class KItemListKlookToggle;
 class QPropertyAnimation;
 
 /**
@@ -114,6 +115,9 @@
     void setEnabledSelectionToggle(bool enabled);
     bool enabledSelectionToggle() const;
 
+    void setEnabledKlookToggle(bool enable);
+    bool enabledKlookToggle() const;
+
     /**
      * Sets the sibling information for the item and all of its parents.
      * The sibling information of the upper most parent is represented by
@@ -186,6 +190,11 @@
      */
     virtual QPixmap createDragPixmap(const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr);
 
+    /**
+     * @return Rectangle for the klook-toggle that is used for item preview.
+     */
+    virtual QRectF klookToggleRect() const;
+
 signals:
     void roleEditingCanceled(int index, const QByteArray& role, const QVariant& value);
     void roleEditingFinished(int index, const QByteArray& role, const QVariant& value);
@@ -216,6 +225,7 @@
 
 private:
     void initializeSelectionToggle();
+    void initializeKlookToggle();
     void setHoverOpacity(qreal opacity);
     void clearHoverCache();
     void drawItemStyleOption(QPainter* painter, QWidget* widget, QStyle::State styleState);
@@ -230,6 +240,7 @@
     bool m_hovered;
     bool m_alternateBackground;
     bool m_enabledSelectionToggle;
+    bool m_enabledKlookToggle;
     QHash<QByteArray, QVariant> m_data;
     QList<QByteArray> m_visibleRoles;
     QHash<QByteArray, qreal> m_columnWidths;
@@ -243,6 +254,8 @@
     KItemListSelectionToggle* m_selectionToggle;
 
     QByteArray m_editedRole;
+
+    KItemListKlookToggle* m_klookToggle;
 };
 
 inline const KItemListWidgetInformant* KItemListWidget::informant() const
diff --unified --recursive --text --color a/src/kitemviews/kstandarditemlistwidget.h b/src/kitemviews/kstandarditemlistwidget.h
--- a/src/kitemviews/kstandarditemlistwidget.h	2020-07-05 09:22:47.000000000 -0600
+++ b/src/kitemviews/kstandarditemlistwidget.h	2020-07-09 23:22:01.853661784 -0600
@@ -184,6 +184,9 @@
     void hideEvent(QHideEvent* event) override;
     bool event(QEvent *event) override;
 
+    // TODO: KLook needs this(?)
+    void triggerCacheRefreshing();
+
 public slots:
     void finishRoleEditing();
 
@@ -193,7 +196,6 @@
     void slotRoleEditingFinished(const QByteArray& role, const QVariant& value);
 
 private:
-    void triggerCacheRefreshing();
     void updateExpansionArea();
     void updatePixmapCache();
 
diff --unified --recursive --text --color a/src/settings/dolphin_generalsettings.kcfg b/src/settings/dolphin_generalsettings.kcfg
--- a/src/settings/dolphin_generalsettings.kcfg	2020-07-05 09:22:47.000000000 -0600
+++ b/src/settings/dolphin_generalsettings.kcfg	2020-07-09 21:58:56.238193639 -0600
@@ -82,6 +82,10 @@
             <label>Close active pane when toggling off split view</label>
             <default>true</default>
         </entry>
+        <entry name="ShowKlookToggle" type="Bool">
+            <label>Show preview toggle</label>
+            <default>false</default>
+        </entry>
         <entry name="ShowToolTips" type="Bool">
             <label>Show tooltips</label>
             <default>false</default>
diff --unified --recursive --text --color a/src/settings/general/behaviorsettingspage.cpp b/src/settings/general/behaviorsettingspage.cpp
--- a/src/settings/general/behaviorsettingspage.cpp	2020-07-05 09:22:47.000000000 -0600
+++ b/src/settings/general/behaviorsettingspage.cpp	2020-07-09 23:21:40.910254952 -0600
@@ -39,6 +39,7 @@
     m_showToolTips(nullptr),
     m_showSelectionToggle(nullptr),
     m_naturalSorting(nullptr),
+    m_showKlookToggle(nullptr),
     m_caseSensitiveSorting(nullptr),
     m_caseInsensitiveSorting(nullptr),
     m_renameInline(nullptr),
@@ -101,6 +102,10 @@
     m_useTabForSplitViewSwitch = new QCheckBox(i18nc("option:check", "Switch between split views panes with tab key"));
     topLayout->addRow(QString(), m_useTabForSplitViewSwitch);
 
+    // 'Show KLook toggle'
+    m_showKlookToggle = new QCheckBox(i18nc("option:check", "Show preview marker"));
+    topLayout->addRow(QString(), m_showKlookToggle);
+
     // 'Close active pane when turning off split view'
     m_closeActiveSplitView = new QCheckBox(i18nc("option:check", "Turning off split view closes active pane"));
     topLayout->addRow(QString(), m_closeActiveSplitView);
@@ -114,6 +119,7 @@
     connect(m_showToolTips, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
 #endif
     connect(m_showSelectionToggle, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
+    connect(m_showKlookToggle, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
     connect(m_naturalSorting, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed);
     connect(m_caseInsensitiveSorting, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed);
     connect(m_caseSensitiveSorting, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed);
@@ -132,6 +138,7 @@
     ViewProperties props(m_url);  // read current view properties
 
     const bool useGlobalViewProps = m_globalViewProps->isChecked();
+    settings->setShowSelectionToggle(m_showKlookToggle->isChecked());
     settings->setGlobalViewProps(useGlobalViewProps);
 #ifdef HAVE_BALOO
     settings->setShowToolTips(m_showToolTips->isChecked());
@@ -171,6 +178,7 @@
     m_showToolTips->setChecked(GeneralSettings::showToolTips());
 #endif
     m_showSelectionToggle->setChecked(GeneralSettings::showSelectionToggle());
+    m_showKlookToggle->setChecked(GeneralSettings::showKlookToggle());
     m_renameInline->setChecked(GeneralSettings::renameInline());
     m_useTabForSplitViewSwitch->setChecked(GeneralSettings::useTabForSwitchingSplitView());
     m_closeActiveSplitView->setChecked(GeneralSettings::closeActiveSplitView());
diff --unified --recursive --text --color a/src/settings/general/behaviorsettingspage.h b/src/settings/general/behaviorsettingspage.h
--- a/src/settings/general/behaviorsettingspage.h	2020-07-05 09:22:47.000000000 -0600
+++ b/src/settings/general/behaviorsettingspage.h	2020-07-09 22:26:35.885140804 -0600
@@ -62,6 +62,7 @@
     QCheckBox* m_showSelectionToggle;
 
     QRadioButton* m_naturalSorting;
+    QCheckBox* m_showKlookToggle;
     QRadioButton* m_caseSensitiveSorting;
     QRadioButton* m_caseInsensitiveSorting;
 
diff --unified --recursive --text --color a/src/views/dolphinitemlistview.cpp b/src/views/dolphinitemlistview.cpp
--- a/src/views/dolphinitemlistview.cpp	2020-07-05 09:22:47.000000000 -0600
+++ b/src/views/dolphinitemlistview.cpp	2020-07-09 22:09:14.031844594 -0600
@@ -36,6 +36,7 @@
     KFileItemListView(parent),
     m_zoomLevel(0)
 {
+    setEnabledKlookToggles(GeneralSettings::showKlookToggle());
     updateFont();
     updateGridSize();
 }
@@ -84,6 +85,7 @@
     beginTransaction();
 
     setEnabledSelectionToggles(GeneralSettings::showSelectionToggle());
+    setEnabledKlookToggles(GeneralSettings::showKlookToggle());
     setSupportsItemExpanding(itemLayoutSupportsItemExpanding(itemLayout()));
 
     updateFont();
diff --unified --recursive --text --color a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
--- a/src/views/dolphinview.cpp	2020-07-05 09:22:47.000000000 -0600
+++ b/src/views/dolphinview.cpp	2020-07-09 22:10:23.588653480 -0600
@@ -146,6 +146,7 @@
     connect(controller, &KItemListController::itemDropEvent, this, &DolphinView::slotItemDropEvent);
     connect(controller, &KItemListController::escapePressed, this, &DolphinView::stopLoading);
     connect(controller, &KItemListController::modelChanged, this, &DolphinView::slotModelChanged);
+    connect(controller, &KItemListController::klookTrigger, this, &DolphinView::klookTrigger);
     connect(controller, &KItemListController::selectedItemTextPressed, this, &DolphinView::slotSelectedItemTextPressed);
 
     connect(m_model, &KFileItemModel::directoryLoadingStarted,       this, &DolphinView::slotDirectoryLoadingStarted);
@@ -1905,3 +1906,12 @@
     markUrlAsCurrent(current);
     markUrlsAsSelected(selected);
 }
+
+KFileItemList DolphinView::sortedItems() const
+{
+    KFileItemList  list;
+    for (int i = 0; i < m_model->count(); i++) {
+        list.append(m_model->fileItem(i));
+    }
+    return list;
+}
diff --unified --recursive --text --color a/src/views/dolphinview.h b/src/views/dolphinview.h
--- a/src/views/dolphinview.h	2020-07-05 09:22:47.000000000 -0600
+++ b/src/views/dolphinview.h	2020-07-09 22:11:04.718743599 -0600
@@ -304,6 +304,8 @@
     void setViewPropertiesContext(const QString& context);
     QString viewPropertiesContext() const;
 
+    KFileItemList sortedItems() const;
+
     /**
      * Checks if the given \a item can be opened as folder (e.g. archives).
      * This function will also adjust the \a url (e.g. change the protocol).
@@ -551,6 +553,8 @@
      */
     void writeStateChanged(bool isFolderWritable);
 
+    void klookTrigger();
+
     /**
      * Is emitted if the URL should be changed to the previous URL of the
      * history (e.g. because the "back"-mousebutton has been pressed).