Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

kdebase-dolphin-klook-4.9.80.patch

By: a guest on Nov 21st, 2012  |  syntax: Diff  |  size: 32.46 KB  |  views: 74  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. diff --git a/dolphin/src/CMakeLists.txt b/dolphin/src/CMakeLists.txt
  2. index 1a121f8..61ba0b6 100644
  3. --- a/dolphin/src/CMakeLists.txt
  4. +++ b/dolphin/src/CMakeLists.txt
  5. @@ -27,6 +27,7 @@ set(dolphinprivate_LIB_SRCS
  6.      kitemviews/kitemlistgroupheader.cpp
  7.      kitemviews/kitemlistheader.cpp
  8.      kitemviews/kitemlistselectionmanager.cpp
  9. +    kitemviews/kitemlistklooktoggle.cpp
  10.      kitemviews/kitemliststyleoption.cpp
  11.      kitemviews/kitemlistview.cpp
  12.      kitemviews/kitemlistwidget.cpp
  13. diff --git a/dolphin/src/dolphinmainwindow.cpp b/dolphin/src/dolphinmainwindow.cpp
  14. index d83c9de..9921d9f 100644
  15. --- a/dolphin/src/dolphinmainwindow.cpp
  16. +++ b/dolphin/src/dolphinmainwindow.cpp
  17. @@ -85,6 +85,8 @@
  18.  #include <QClipboard>
  19.  #include <QToolButton>
  20.  #include <QSplitter>
  21. +#include <QProcess>
  22. +#include <QApplication>
  23.  
  24.  namespace {
  25.      // Used for GeneralSettings::version() to determine whether
  26. @@ -118,7 +120,8 @@ DolphinMainWindow::DolphinMainWindow() :
  27.      m_settingsDialog(),
  28.      m_controlButton(0),
  29.      m_updateToolBarTimer(0),
  30. -    m_lastHandleUrlStatJob(0)
  31. +    m_lastHandleUrlStatJob(0),
  32. +    m_isFocusOnTerminal(false)
  33.  {
  34.      // Workaround for a X11-issue in combination with KModifierInfo
  35.      // (see DolphinContextMenu::initializeModifierKeyInfo() for
  36. @@ -236,6 +239,8 @@ DolphinMainWindow::DolphinMainWindow() :
  37.      if (!showMenu) {
  38.          createControlButton();
  39.      }
  40. +
  41. +    connect (qApp, SIGNAL(focusChanged(QWidget*,QWidget*)), this, SLOT(focusChanged(QWidget*,QWidget*)));
  42.  }
  43.  
  44.  DolphinMainWindow::~DolphinMainWindow()
  45. @@ -400,6 +405,15 @@ void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection)
  46.          compareFilesAction->setEnabled(false);
  47.      }
  48.  
  49. +
  50. +    //KLook
  51. +    QAction* openInKLook = actionCollection()->action("open_in_KLook");
  52. +    if ((selectedUrlsCount > 0) && (!m_isFocusOnTerminal)){
  53. +        openInKLook->setEnabled(true);
  54. +    } else {
  55. +        openInKLook->setEnabled(false);
  56. +    }
  57. +
  58.      emit selectionChanged(selection);
  59.  }
  60.  
  61. @@ -1651,6 +1665,14 @@ void DolphinMainWindow::setupActions()
  62.      openInNewWindow->setText(i18nc("@action:inmenu", "Open in New Window"));
  63.      openInNewWindow->setIcon(KIcon("window-new"));
  64.      connect(openInNewWindow, SIGNAL(triggered()), this, SLOT(openInNewWindow()));
  65. +
  66. +    // KLook
  67. +    KAction* openInKLook = actionCollection()->addAction("open_in_KLook");
  68. +    openInKLook->setText(i18nc("@action:inmenu", "Preview"));
  69. +    openInKLook->setShortcut(Qt::Key_Space);
  70. +    openInKLook->setIcon(KIcon("klook"));
  71. +    openInKLook->setEnabled(false);
  72. +    connect(openInKLook, SIGNAL(triggered()), this, SLOT(previewItem()));
  73.  }
  74.  
  75.  void DolphinMainWindow::setupDockWidgets()
  76. @@ -1986,6 +2008,9 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
  77.              this, SLOT(goBack()));
  78.      connect(view, SIGNAL(goForwardRequested()),
  79.              this, SLOT(goForward()));
  80. +    connect(view, SIGNAL(klookTrigger()),
  81. +            this, SLOT(previewItem()));
  82. +
  83.  
  84.      const KUrlNavigator* navigator = container->urlNavigator();
  85.      connect(navigator, SIGNAL(urlChanged(KUrl)),
  86. @@ -2130,4 +2155,51 @@ void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job* job)
  87.      }
  88.  }
  89.  
  90. +void DolphinMainWindow::previewItem()
  91. +{
  92. +    KFileItemList list;
  93. +    int index = 0;
  94. +    if ( m_activeViewContainer->view()->selectedItemsCount() > 1) {
  95. +        list = m_activeViewContainer->view()->selectedItems();
  96. +    } else {
  97. +        list = m_activeViewContainer->view()->sortedItems();
  98. +        index = list.indexOf( m_activeViewContainer->view()->selectedItems().at(0));
  99. +    }
  100. +    QStringList urlList;
  101. +    foreach(KFileItem item, list)
  102. +    {
  103. +        urlList.append(item.url().path());
  104. +    }
  105. +    urlList.append("-i " + QString::number(index , 10));
  106. +    if (!list.isEmpty())
  107. +    {
  108. +        QProcess* process = new QProcess();
  109. +        connect(process,SIGNAL(finished(int)),process,SLOT(deleteLater()));
  110. +        process->start(QString("klook"), urlList);
  111. +    }
  112. +}
  113. +
  114. +void DolphinMainWindow::focusChanged(QWidget *old, QWidget *now)
  115. +{
  116. +#ifndef Q_OS_WIN
  117. +    if (now)
  118. +    {
  119. +        if (QString(now->metaObject()->className()).contains("Konsole::TerminalDisplay"))
  120. +        {
  121. +            QAction* openInKLook = actionCollection()->action("open_in_KLook");
  122. +            m_isFocusOnTerminal = true;
  123. +            openInKLook->setEnabled(false);
  124. +        }
  125. +    }
  126. +    if (old)
  127. +    {
  128. +        if (QString(old->metaObject()->className()).contains("Konsole::TerminalDisplay"))
  129. +        {
  130. +            QAction* openInKLook = actionCollection()->action("open_in_KLook");
  131. +            m_isFocusOnTerminal = false;
  132. +            openInKLook->setEnabled(true);
  133. +        }
  134. +    }
  135. +#endif
  136. +}
  137.  #include "dolphinmainwindow.moc"
  138. diff --git a/dolphin/src/dolphinmainwindow.h b/dolphin/src/dolphinmainwindow.h
  139. index ab79fb0..f61f173 100644
  140. --- a/dolphin/src/dolphinmainwindow.h
  141. +++ b/dolphin/src/dolphinmainwindow.h
  142. @@ -36,6 +36,7 @@
  143.  
  144.  typedef KIO::FileUndoManager::CommandType CommandType;
  145.  
  146. +class DolphinDockWidget;
  147.  class DolphinViewActionHandler;
  148.  class DolphinApplication;
  149.  class DolphinSettingsDialog;
  150. @@ -51,6 +52,7 @@ class KUrl;
  151.  class QSplitter;
  152.  class QToolButton;
  153.  class QVBoxLayout;
  154. +class Panel;
  155.  
  156.  /**
  157.   * @short Main window for Dolphin.
  158. @@ -102,6 +104,8 @@ public:
  159.       */
  160.      KNewFileMenu* newFileMenu() const;
  161.  
  162. +    void focusChanged(QWidget *old, QWidget *now);
  163. +
  164.  public slots:
  165.      /**
  166.       * Pastes the clipboard data into the currently selected folder
  167. @@ -367,6 +371,12 @@ private slots:
  168.      void openInNewTab();
  169.  
  170.      /**
  171. +     * Opens the selected files in KLook.
  172. +     */
  173. +
  174. +    void previewItem();
  175. +
  176. +    /**
  177.       * Opens the selected folder in a new window.
  178.       */
  179.      void openInNewWindow();
  180. @@ -588,6 +598,7 @@ private:
  181.      QTimer* m_updateToolBarTimer;
  182.  
  183.      KIO::Job* m_lastHandleUrlStatJob;
  184. +    bool m_isFocusOnTerminal;
  185.  };
  186.  
  187.  inline DolphinViewContainer* DolphinMainWindow::activeViewContainer() const
  188. diff --git a/dolphin/src/kitemviews/kfileitemlistwidget.cpp b/dolphin/src/kitemviews/kfileitemlistwidget.cpp
  189. index 3a77241..b816fb8 100644
  190. --- a/dolphin/src/kitemviews/kfileitemlistwidget.cpp
  191. +++ b/dolphin/src/kitemviews/kfileitemlistwidget.cpp
  192. @@ -70,6 +70,44 @@ QString KFileItemListWidgetInformant::roleText(const QByteArray& role,
  193.      return text;
  194.  }
  195.  
  196. +QRectF KFileItemListWidget::klookToggleRect() const
  197. +{
  198. +    const_cast<KFileItemListWidget *>(this)->triggerCacheRefreshing();
  199. +
  200. +    const int iconHeight = styleOption().iconSize;
  201. +
  202. +    int toggleSize = KIconLoader::SizeSmall;
  203. +    if (iconHeight >= KIconLoader::SizeEnormous) {
  204. +        toggleSize = KIconLoader::SizeMedium;
  205. +    } else if (iconHeight >= KIconLoader::SizeLarge) {
  206. +        toggleSize = KIconLoader::SizeSmallMedium;
  207. +    }
  208. +
  209. +    QPointF pos = QPointF(iconRect().topRight().rx() - toggleSize, iconRect().topRight().ry());
  210. +
  211. +    // If the selection toggle has a very small distance to the
  212. +    // widget borders, the size of the selection toggle will get
  213. +    // increased to prevent an accidental clicking of the item
  214. +    // when trying to hit the toggle.
  215. +
  216. +    const int widgetHeight = size().height();
  217. +    const int widgetWidth = size().width();
  218. +    const int minMargin = 2;
  219. +
  220. +    if (toggleSize + minMargin * 2 >= widgetHeight) {
  221. +        pos.rx() -= (widgetHeight - toggleSize) / 2;
  222. +        toggleSize = widgetHeight;
  223. +        pos.setY(0);
  224. +    }
  225. +    if (toggleSize + minMargin * 2 >= widgetWidth) {
  226. +        pos.ry() -= (widgetWidth - toggleSize) / 2;
  227. +        toggleSize = widgetWidth;
  228. +        pos.setX(0);
  229. +    }
  230. +
  231. +    return QRectF(pos, QSizeF(toggleSize, toggleSize));
  232. +}
  233. +
  234.  KFileItemListWidget::KFileItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent) :
  235.      KStandardItemListWidget(informant, parent)
  236.  {
  237. diff --git a/dolphin/src/kitemviews/kfileitemlistwidget.h b/dolphin/src/kitemviews/kfileitemlistwidget.h
  238. index 24c6778..aea5636 100644
  239. --- a/dolphin/src/kitemviews/kfileitemlistwidget.h
  240. +++ b/dolphin/src/kitemviews/kfileitemlistwidget.h
  241. @@ -43,6 +43,7 @@ public:
  242.      virtual ~KFileItemListWidget();
  243.  
  244.      static KItemListWidgetInformant* createInformant();
  245. +    virtual QRectF klookToggleRect() const;
  246.  
  247.  protected:
  248.      virtual bool isRoleRightAligned(const QByteArray& role) const;
  249. diff --git a/dolphin/src/kitemviews/kitemlistcontroller.cpp b/dolphin/src/kitemviews/kitemlistcontroller.cpp
  250. index 88f5d9f..c3c1d3d 100644
  251. --- a/dolphin/src/kitemviews/kitemlistcontroller.cpp
  252. +++ b/dolphin/src/kitemviews/kitemlistcontroller.cpp
  253. @@ -510,6 +510,13 @@ bool KItemListController::mousePressEvent(QGraphicsSceneMouseEvent* event, const
  254.          m_selectionManager->beginAnchoredSelection(m_pressedIndex);
  255.          return true;
  256.      }
  257. +    if (m_view->isAboveKlookToggle(m_pressedIndex, m_pressedMousePos)){
  258. +        m_selectionManager->setSelected(m_pressedIndex, 1, KItemListSelectionManager::Select);
  259. +        m_selectionManager->setCurrentItem(m_pressedIndex);
  260. +        m_selectionManager->beginAnchoredSelection(m_pressedIndex);
  261. +        emit klookTrigger();
  262. +        return true;
  263. +    }
  264.  
  265.      const bool shiftPressed = event->modifiers() & Qt::ShiftModifier;
  266.      const bool controlPressed = event->modifiers() & Qt::ControlModifier;
  267. diff --git a/dolphin/src/kitemviews/kitemlistcontroller.h b/dolphin/src/kitemviews/kitemlistcontroller.h
  268. index a881526..0d4be2f 100644
  269. --- a/dolphin/src/kitemviews/kitemlistcontroller.h
  270. +++ b/dolphin/src/kitemviews/kitemlistcontroller.h
  271. @@ -216,6 +216,8 @@ signals:
  272.      void modelChanged(KItemModelBase* current, KItemModelBase* previous);
  273.      void viewChanged(KItemListView* current, KItemListView* previous);
  274.  
  275. +    void klookTrigger();
  276. +
  277.  private slots:
  278.      void slotViewScrollOffsetChanged(qreal current, qreal previous);
  279.  
  280. diff --git a/dolphin/src/kitemviews/kitemlistklooktoggle.cpp b/dolphin/src/kitemviews/kitemlistklooktoggle.cpp
  281. new file mode 100644
  282. index 0000000..ea5200e
  283. --- /dev/null
  284. +++ b/dolphin/src/kitemviews/kitemlistklooktoggle.cpp
  285. @@ -0,0 +1,106 @@
  286. +/***************************************************************************
  287. + *   Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com>             *
  288. + *                                                                         *
  289. + *   This program is free software; you can redistribute it and/or modify  *
  290. + *   it under the terms of the GNU General Public License as published by  *
  291. + *   the Free Software Foundation; either version 2 of the License, or     *
  292. + *   (at your option) any later version.                                   *
  293. + *                                                                         *
  294. + *   This program is distributed in the hope that it will be useful,       *
  295. + *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
  296. + *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
  297. + *   GNU General Public License for more details.                          *
  298. + *                                                                         *
  299. + *   You should have received a copy of the GNU General Public License     *
  300. + *   along with this program; if not, write to the                         *
  301. + *   Free Software Foundation, Inc.,                                       *
  302. + *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
  303. + ***************************************************************************/
  304. +
  305. +#include "kitemlistklooktoggle_p.h"
  306. +
  307. +#include <KIconEffect>
  308. +#include <KIconLoader>
  309. +#include <QPainter>
  310. +
  311. +#include <KDebug>
  312. +
  313. +KItemListKlookToggle::KItemListKlookToggle(QGraphicsItem* parent) :
  314. +    QGraphicsWidget(parent, 0),    
  315. +    m_hovered(false)
  316. +{
  317. +    setAcceptHoverEvents(true);
  318. +}
  319. +
  320. +KItemListKlookToggle::~KItemListKlookToggle()
  321. +{
  322. +}
  323. +/*
  324. +void KItemListKlookToggle::setChecked(bool checked)
  325. +{
  326. +    if (m_checked != checked) {
  327. +        m_checked = checked;
  328. +        m_pixmap = QPixmap();
  329. +        update();
  330. +    }
  331. +}
  332. +*/
  333. +/*
  334. +bool KItemListKlookToggle::isChecked() const
  335. +{
  336. +    return m_checked;
  337. +}
  338. +*/
  339. +void KItemListKlookToggle::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
  340. +{
  341. +    Q_UNUSED(option);
  342. +    Q_UNUSED(widget);
  343. +
  344. +    if (m_pixmap.isNull()) {
  345. +        updatePixmap();
  346. +    }
  347. +
  348. +    const qreal x = (size().width()  - qreal(m_pixmap.width()))  / 2;
  349. +    const qreal y = (size().height() - qreal(m_pixmap.height())) / 2;
  350. +    painter->drawPixmap(x, y, m_pixmap);
  351. +}
  352. +
  353. +void KItemListKlookToggle::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
  354. +{
  355. +    QGraphicsWidget::hoverEnterEvent(event);
  356. +    m_hovered = true;
  357. +    m_pixmap = QPixmap();
  358. +}
  359. +
  360. +void KItemListKlookToggle::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
  361. +{
  362. +    QGraphicsWidget::hoverLeaveEvent(event);
  363. +    m_hovered = false;
  364. +    m_pixmap = QPixmap();
  365. +}
  366. +
  367. +void KItemListKlookToggle::updatePixmap()
  368. +{
  369. +    const char* icon = "klook";
  370. +
  371. +    int iconSize = qMin(size().width(), size().height());
  372. +    if (iconSize < KIconLoader::SizeSmallMedium) {
  373. +        iconSize = KIconLoader::SizeSmall;
  374. +    } else if (iconSize < KIconLoader::SizeMedium) {
  375. +        iconSize = KIconLoader::SizeSmallMedium;
  376. +    } else if (iconSize < KIconLoader::SizeLarge) {
  377. +        iconSize = KIconLoader::SizeMedium;
  378. +    } else if (iconSize < KIconLoader::SizeHuge) {
  379. +        iconSize = KIconLoader::SizeLarge;
  380. +    } else if (iconSize < KIconLoader::SizeEnormous) {
  381. +        iconSize = KIconLoader::SizeHuge;
  382. +    }
  383. +
  384. +    m_pixmap = KIconLoader::global()->loadIcon(QLatin1String(icon), KIconLoader::NoGroup, iconSize);
  385. +
  386. +    if (m_hovered) {
  387. +        KIconLoader::global()->iconEffect()->apply(m_pixmap, KIconLoader::Desktop, KIconLoader::ActiveState);
  388. +    }
  389. +}
  390. +
  391. +#include "kitemlistklooktoggle_p.moc"
  392. diff --git a/dolphin/src/kitemviews/kitemlistklooktoggle_p.h b/dolphin/src/kitemviews/kitemlistklooktoggle_p.h
  393. new file mode 100644
  394. index 0000000..bf5923e
  395. --- /dev/null
  396. +++ b/dolphin/src/kitemviews/kitemlistklooktoggle_p.h
  397. @@ -0,0 +1,61 @@
  398. +/***************************************************************************
  399. + *   Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com>             *
  400. + *                                                                         *
  401. + *   This program is free software; you can redistribute it and/or modify  *
  402. + *   it under the terms of the GNU General Public License as published by  *
  403. + *   the Free Software Foundation; either version 2 of the License, or     *
  404. + *   (at your option) any later version.                                   *
  405. + *                                                                         *
  406. + *   This program is distributed in the hope that it will be useful,       *
  407. + *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
  408. + *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
  409. + *   GNU General Public License for more details.                          *
  410. + *                                                                         *
  411. + *   You should have received a copy of the GNU General Public License     *
  412. + *   along with this program; if not, write to the                         *
  413. + *   Free Software Foundation, Inc.,                                       *
  414. + *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
  415. + ***************************************************************************/
  416. +
  417. +#ifndef KITEMLISTKLOOKTOGGLE_H
  418. +#define KITEMLISTKLOOKTOGGLE_H
  419. +
  420. +#include <libdolphin_export.h>
  421. +
  422. +#include <QGraphicsWidget>
  423. +#include <QPixmap>
  424. +
  425. +class QPropertyAnimation;
  426. +
  427. +/**
  428. + * @brief Allows to launch klook by clicking on icon overlay
  429. + */
  430. +class LIBDOLPHINPRIVATE_EXPORT KItemListKlookToggle : public QGraphicsWidget
  431. +{
  432. +    Q_OBJECT
  433. +
  434. +public:
  435. +    KItemListKlookToggle(QGraphicsItem* parent);
  436. +    virtual ~KItemListKlookToggle();
  437. +
  438. +    //void setChecked(bool checked);
  439. +    //bool isChecked() const;
  440. +
  441. +    virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
  442. +
  443. +protected:
  444. +    virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event);
  445. +    virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
  446. +
  447. +private:
  448. +    void updatePixmap();
  449. +
  450. +private:
  451. +    //bool m_checked;
  452. +    bool m_hovered;
  453. +    QPixmap m_pixmap;
  454. +};
  455. +
  456. +#endif
  457. +
  458. +
  459. diff --git a/dolphin/src/kitemviews/kitemlistview.cpp b/dolphin/src/kitemviews/kitemlistview.cpp
  460. index 72b3fd8..1519923 100644
  461. --- a/dolphin/src/kitemviews/kitemlistview.cpp
  462. +++ b/dolphin/src/kitemviews/kitemlistview.cpp
  463. @@ -55,6 +55,7 @@ namespace {
  464.  KItemListView::KItemListView(QGraphicsWidget* parent) :
  465.      QGraphicsWidget(parent),
  466.      m_enabledSelectionToggles(false),
  467. +    m_enabledKlookToggles(false),
  468.      m_grouped(false),
  469.      m_supportsItemExpanding(false),
  470.      m_editingRole(false),
  471. @@ -269,6 +270,25 @@ bool KItemListView::enabledSelectionToggles() const
  472.      return m_enabledSelectionToggles;
  473.  }
  474.  
  475. +void KItemListView::setEnabledKlookToggles(bool enabled)
  476. +{
  477. +    if (m_enabledKlookToggles != enabled) {
  478. +        m_enabledKlookToggles = enabled;
  479. +
  480. +        QHashIterator<int, KItemListWidget*> it(m_visibleItems);
  481. +        while (it.hasNext()) {
  482. +            it.next();
  483. +            it.value()->setEnabledKlookToggle(enabled);
  484. +        }
  485. +    }
  486. +}
  487. +
  488. +bool KItemListView::enabledKlookToggles() const
  489. +{
  490. +    return m_enabledKlookToggles;
  491. +}
  492. +
  493. +
  494.  KItemListController* KItemListView::controller() const
  495.  {
  496.      return m_controller;
  497. @@ -411,6 +431,25 @@ bool KItemListView::isAboveExpansionToggle(int index, const QPointF& pos) const
  498.      return false;
  499.  }
  500.  
  501. +bool KItemListView::isAboveKlookToggle(int index, const QPointF& pos) const
  502. +{
  503. +
  504. +    if (!m_enabledKlookToggles) {
  505. +        return false;
  506. +    }
  507. +
  508. +    const KItemListWidget* widget = m_visibleItems.value(index);
  509. +    if (widget) {
  510. +        const QRectF selectionToggleRect = widget->klookToggleRect();
  511. +        if (!selectionToggleRect.isEmpty()) {
  512. +            const QPointF mappedPos = widget->mapFromItem(this, pos);
  513. +            return selectionToggleRect.contains(mappedPos);
  514. +        }
  515. +    }
  516. +    return false;
  517. +}
  518. +
  519. +
  520.  int KItemListView::firstVisibleIndex() const
  521.  {
  522.      return m_layouter->firstVisibleIndex();
  523. @@ -1880,6 +1919,7 @@ void KItemListView::updateWidgetProperties(KItemListWidget* widget, int index)
  524.      widget->setSelected(selectionManager->isSelected(index));
  525.      widget->setHovered(false);
  526.      widget->setEnabledSelectionToggle(enabledSelectionToggles());
  527. +    widget->setEnabledKlookToggle(enabledKlookToggles());
  528.      widget->setIndex(index);
  529.      widget->setData(m_model->data(index));
  530.      widget->setSiblingsInformation(QBitArray());
  531. diff --git a/dolphin/src/kitemviews/kitemlistview.h b/dolphin/src/kitemviews/kitemlistview.h
  532. index 5723b9a..b8c956e 100644
  533. --- a/dolphin/src/kitemviews/kitemlistview.h
  534. +++ b/dolphin/src/kitemviews/kitemlistview.h
  535. @@ -110,6 +110,9 @@ public:
  536.      void setEnabledSelectionToggles(bool enabled);
  537.      bool enabledSelectionToggles() const;
  538.  
  539. +    void setEnabledKlookToggles(bool enabled);
  540. +    bool enabledKlookToggles() const;
  541. +
  542.      /**
  543.       * @return Controller of the item-list. The controller gets
  544.       *         initialized by KItemListController::setView() and will
  545. @@ -173,6 +176,7 @@ public:
  546.      bool isAboveSelectionToggle(int index, const QPointF& pos) const;
  547.      bool isAboveExpansionToggle(int index, const QPointF& pos) const;
  548.  
  549. +    bool isAboveKlookToggle(int index, const QPointF& pos) const;
  550.      /**
  551.       * @return Index of the first item that is at least partly visible.
  552.       *         -1 is returned if the model contains no items.
  553. @@ -683,6 +687,7 @@ private:
  554.  
  555.  private:
  556.      bool m_enabledSelectionToggles;
  557. +    bool m_enabledKlookToggles;
  558.      bool m_grouped;
  559.      bool m_supportsItemExpanding;
  560.      bool m_editingRole;
  561. diff --git a/dolphin/src/kitemviews/kitemlistwidget.cpp b/dolphin/src/kitemviews/kitemlistwidget.cpp
  562. index 6a7111a..d4f70e1 100644
  563. --- a/dolphin/src/kitemviews/kitemlistwidget.cpp
  564. +++ b/dolphin/src/kitemviews/kitemlistwidget.cpp
  565. @@ -22,6 +22,7 @@
  566.  
  567.  #include "kitemlistwidget.h"
  568.  
  569. +#include "kitemlistklooktoggle_p.h"
  570.  #include "kitemlistview.h"
  571.  #include "kitemmodelbase.h"
  572.  
  573. @@ -52,6 +53,7 @@ KItemListWidget::KItemListWidget(KItemListWidgetInformant* informant, QGraphicsI
  574.      m_hovered(false),
  575.      m_alternateBackground(false),
  576.      m_enabledSelectionToggle(false),
  577. +    m_enabledKlookToggle(false),
  578.      m_data(),
  579.      m_visibleRoles(),
  580.      m_columnWidths(),
  581. @@ -61,7 +63,8 @@ KItemListWidget::KItemListWidget(KItemListWidgetInformant* informant, QGraphicsI
  582.      m_hoverCache(0),
  583.      m_hoverAnimation(0),
  584.      m_selectionToggle(0),
  585. -    m_editedRole()
  586. +    m_editedRole(),
  587. +    m_klookToggle(0)
  588.  {
  589.  }
  590.  
  591. @@ -76,6 +79,9 @@ void KItemListWidget::setIndex(int index)
  592.          delete m_selectionToggle;
  593.          m_selectionToggle = 0;
  594.  
  595. +        delete m_klookToggle;
  596. +        m_klookToggle = 0;
  597. +
  598.          if (m_hoverAnimation) {
  599.              m_hoverAnimation->stop();
  600.              m_hoverOpacity = 0;
  601. @@ -263,6 +269,9 @@ void KItemListWidget::setHovered(bool hovered)
  602.          if (m_enabledSelectionToggle && !(QApplication::mouseButtons() & Qt::LeftButton)) {
  603.              initializeSelectionToggle();
  604.          }
  605. +        if (m_enabledKlookToggle && !(QApplication::mouseButtons() & Qt::LeftButton)) {
  606. +            initializeKlookToggle();
  607. +        }
  608.      } else {
  609.          m_hoverAnimation->setStartValue(hoverOpacity());
  610.          m_hoverAnimation->setEndValue(0.0);
  611. @@ -306,6 +315,19 @@ bool KItemListWidget::enabledSelectionToggle() const
  612.      return m_enabledSelectionToggle;
  613.  }
  614.  
  615. +void KItemListWidget::setEnabledKlookToggle(bool enable)
  616. +{
  617. +    if (m_enabledKlookToggle != enable) {
  618. +        m_enabledKlookToggle = enable;
  619. +        update();
  620. +    }
  621. +}
  622. +
  623. +bool KItemListWidget::enabledKlookToggle() const
  624. +{
  625. +    return m_enabledKlookToggle;
  626. +}
  627. +
  628.  void KItemListWidget::setSiblingsInformation(const QBitArray& siblings)
  629.  {
  630.      const QBitArray previous = m_siblingsInfo;
  631. @@ -355,6 +377,12 @@ QRectF KItemListWidget::selectionToggleRect() const
  632.      return QRectF();
  633.  }
  634.  
  635. +QRectF KItemListWidget::klookToggleRect() const
  636. +{
  637. +    return QRectF();
  638. +}
  639. +
  640. +
  641.  QRectF KItemListWidget::expansionToggleRect() const
  642.  {
  643.      return QRectF();
  644. @@ -463,6 +491,8 @@ void KItemListWidget::slotHoverAnimationFinished()
  645.      if (!m_hovered) {
  646.          delete m_selectionToggle;
  647.          m_selectionToggle = 0;
  648. +        delete m_klookToggle;
  649. +        m_klookToggle = 0;
  650.      }
  651.  }
  652.  
  653. @@ -481,12 +511,29 @@ void KItemListWidget::initializeSelectionToggle()
  654.      m_selectionToggle->setChecked(isSelected());
  655.  }
  656.  
  657. +void KItemListWidget::initializeKlookToggle()
  658. +{
  659. +    Q_ASSERT(m_enabledKlookToggle);
  660. +
  661. +    if (!m_klookToggle) {
  662. +        m_klookToggle = new KItemListKlookToggle(this);
  663. +    }
  664. +
  665. +    const QRectF toggleRect = klookToggleRect();;
  666. +    m_klookToggle->setPos(toggleRect.topLeft());
  667. +    m_klookToggle->resize(toggleRect.size());
  668. +
  669. +}
  670. +
  671.  void KItemListWidget::setHoverOpacity(qreal opacity)
  672.  {
  673.      m_hoverOpacity = opacity;
  674.      if (m_selectionToggle) {
  675.          m_selectionToggle->setOpacity(opacity);
  676.      }
  677. +    if (m_klookToggle) {
  678. +        m_klookToggle->setOpacity(opacity);
  679. +    }
  680.  
  681.      if (m_hoverOpacity <= 0.0) {
  682.          delete m_hoverCache;
  683. diff --git a/dolphin/src/kitemviews/kitemlistwidget.h b/dolphin/src/kitemviews/kitemlistwidget.h
  684. index 55181fa..7fd593c 100644
  685. --- a/dolphin/src/kitemviews/kitemlistwidget.h
  686. +++ b/dolphin/src/kitemviews/kitemlistwidget.h
  687. @@ -33,6 +33,7 @@
  688.  
  689.  class KItemListSelectionToggle;
  690.  class KItemListView;
  691. +class KItemListKlookToggle;
  692.  class QPropertyAnimation;
  693.  
  694.  /**
  695. @@ -114,6 +115,9 @@ public:
  696.      void setEnabledSelectionToggle(bool enabled);
  697.      bool enabledSelectionToggle() const;
  698.  
  699. +    void setEnabledKlookToggle(bool enable);
  700. +    bool enabledKlookToggle() const;
  701. +
  702.      /**
  703.       * Sets the sibling information for the item and all of its parents.
  704.       * The sibling information of the upper most parent is represented by
  705. @@ -181,6 +185,12 @@ public:
  706.       */
  707.      virtual QPixmap createDragPixmap(const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
  708.  
  709. +     /**
  710. +     * @return Rectangle for the klook-toggle that is used for item preview.
  711. +     */
  712. +    virtual QRectF klookToggleRect() const;
  713. +
  714. +
  715.  signals:
  716.      void roleEditingCanceled(int index, const QByteArray& role, const QVariant& value);
  717.      void roleEditingFinished(int index, const QByteArray& role, const QVariant& value);
  718. @@ -211,6 +221,7 @@ private slots:
  719.  
  720.  private:
  721.      void initializeSelectionToggle();
  722. +    void initializeKlookToggle();
  723.      void setHoverOpacity(qreal opacity);
  724.      void clearHoverCache();
  725.      void drawItemStyleOption(QPainter* painter, QWidget* widget, QStyle::State styleState);
  726. @@ -225,6 +236,7 @@ private:
  727.      bool m_hovered;
  728.      bool m_alternateBackground;
  729.      bool m_enabledSelectionToggle;
  730. +    bool m_enabledKlookToggle;
  731.      QHash<QByteArray, QVariant> m_data;
  732.      QList<QByteArray> m_visibleRoles;
  733.      QHash<QByteArray, qreal> m_columnWidths;
  734. @@ -238,6 +250,8 @@ private:
  735.      KItemListSelectionToggle* m_selectionToggle;
  736.  
  737.      QByteArray m_editedRole;
  738. +    
  739. +    KItemListKlookToggle* m_klookToggle;
  740.  };
  741.  
  742.  inline const KItemListWidgetInformant* KItemListWidget::informant() const
  743. diff --git a/dolphin/src/kitemviews/kstandarditemlistwidget.h b/dolphin/src/kitemviews/kstandarditemlistwidget.h
  744. index 787722d..3bc9228 100644
  745. --- a/dolphin/src/kitemviews/kstandarditemlistwidget.h
  746. +++ b/dolphin/src/kitemviews/kstandarditemlistwidget.h
  747. @@ -157,6 +157,7 @@ protected:
  748.      virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
  749.      virtual void showEvent(QShowEvent* event);
  750.      virtual void hideEvent(QHideEvent* event);
  751. +    void triggerCacheRefreshing();
  752.  
  753.  private slots:
  754.      void slotCutItemsChanged();
  755. @@ -164,7 +165,6 @@ private slots:
  756.      void slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value);
  757.  
  758.  private:
  759. -    void triggerCacheRefreshing();
  760.      void updateExpansionArea();
  761.      void updatePixmapCache();
  762.  
  763. diff --git a/dolphin/src/settings/dolphin_generalsettings.kcfg b/dolphin/src/settings/dolphin_generalsettings.kcfg
  764. index 9f261dc..67d9c30 100644
  765. --- a/dolphin/src/settings/dolphin_generalsettings.kcfg
  766. +++ b/dolphin/src/settings/dolphin_generalsettings.kcfg
  767. @@ -56,6 +56,10 @@
  768.              <label>Show selection toggle</label>
  769.              <default>true</default>
  770.          </entry>
  771. +        <entry name="ShowKlookToggle" type="Bool">
  772. +            <label>Show preview toggle</label>
  773. +            <default>false</default>
  774. +        </entry>
  775.          <entry name="ShowToolTips" type="Bool">
  776.              <label>Show tooltips</label>
  777.              <default>false</default>
  778. diff --git a/dolphin/src/settings/general/behaviorsettingspage.cpp b/dolphin/src/settings/general/behaviorsettingspage.cpp
  779. index 1ade93c..0f3ed6f 100644
  780. --- a/dolphin/src/settings/general/behaviorsettingspage.cpp
  781. +++ b/dolphin/src/settings/general/behaviorsettingspage.cpp
  782. @@ -42,7 +42,8 @@ BehaviorSettingsPage::BehaviorSettingsPage(const KUrl& url, QWidget* parent) :
  783.      m_showToolTips(0),
  784.      m_showSelectionToggle(0),
  785.      m_naturalSorting(0),
  786. -    m_renameInline(0)
  787. +    m_renameInline(0),
  788. +    m_showKlookToggle(0)
  789.  {
  790.      QVBoxLayout* topLayout = new QVBoxLayout(this);
  791.  
  792. @@ -67,8 +68,13 @@ BehaviorSettingsPage::BehaviorSettingsPage(const KUrl& url, QWidget* parent) :
  793.      m_naturalSorting = new QCheckBox(i18nc("option:check", "Natural sorting of items"), this);
  794.  
  795.      topLayout->addWidget(viewPropsBox);
  796. +
  797. +       // 'Show klook toggle'
  798. +     m_showKlookToggle = new QCheckBox(i18nc("@option:check", "Show preview marker"), this);
  799. +
  800.      topLayout->addWidget(m_showToolTips);
  801.      topLayout->addWidget(m_showSelectionToggle);
  802. +    topLayout->addWidget(m_showKlookToggle);
  803.      topLayout->addWidget(m_naturalSorting);
  804.      topLayout->addStretch();
  805.  
  806. @@ -78,6 +84,7 @@ BehaviorSettingsPage::BehaviorSettingsPage(const KUrl& url, QWidget* parent) :
  807.      connect(m_globalViewProps, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
  808.      connect(m_showToolTips, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
  809.      connect(m_showSelectionToggle, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
  810. +    connect(m_showKlookToggle, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
  811.      connect(m_naturalSorting, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
  812.  }
  813.  
  814. @@ -106,6 +113,7 @@ void BehaviorSettingsPage::applySettings()
  815.          globalProps.setDirProperties(props);
  816.      }
  817.  
  818. +    settings->setShowKlookToggle(m_showKlookToggle->isChecked());
  819.      const bool naturalSorting = m_naturalSorting->isChecked();
  820.      if (KGlobalSettings::naturalSorting() != naturalSorting) {
  821.          KConfigGroup group(KGlobal::config(), "KDE");
  822. @@ -130,6 +138,7 @@ void BehaviorSettingsPage::loadSettings()
  823.  
  824.      m_showToolTips->setChecked(GeneralSettings::showToolTips());
  825.      m_showSelectionToggle->setChecked(GeneralSettings::showSelectionToggle());
  826. +    m_showKlookToggle->setChecked(GeneralSettings::showKlookToggle());
  827.      m_naturalSorting->setChecked(KGlobalSettings::naturalSorting());
  828.  }
  829.  
  830. diff --git a/dolphin/src/settings/general/behaviorsettingspage.h b/dolphin/src/settings/general/behaviorsettingspage.h
  831. index 3989862..8e810fe 100644
  832. --- a/dolphin/src/settings/general/behaviorsettingspage.h
  833. +++ b/dolphin/src/settings/general/behaviorsettingspage.h
  834. @@ -58,6 +58,7 @@ private:
  835.      QCheckBox* m_showSelectionToggle;
  836.      QCheckBox* m_naturalSorting;
  837.      QCheckBox* m_renameInline;
  838. +    QCheckBox* m_showKlookToggle;
  839.  };
  840.  
  841.  #endif
  842. diff --git a/dolphin/src/views/dolphinitemlistview.cpp b/dolphin/src/views/dolphinitemlistview.cpp
  843. index 039b5f2..81694dc 100644
  844. --- a/dolphin/src/views/dolphinitemlistview.cpp
  845. +++ b/dolphin/src/views/dolphinitemlistview.cpp
  846. @@ -41,6 +41,7 @@ DolphinItemListView::DolphinItemListView(QGraphicsWidget* parent) :
  847.      KFileItemListView(parent),
  848.      m_zoomLevel(0)
  849.  {
  850. +    setEnabledKlookToggles(GeneralSettings::showKlookToggle());
  851.      updateFont();
  852.      updateGridSize();
  853.  }
  854. @@ -89,6 +90,7 @@ void DolphinItemListView::readSettings()
  855.      beginTransaction();
  856.  
  857.      setEnabledSelectionToggles(GeneralSettings::showSelectionToggle());
  858. +    setEnabledKlookToggles(GeneralSettings::showKlookToggle());
  859.  
  860.      const bool expandableFolders = (itemLayout() == KFileItemListView::DetailsLayout) &&
  861.                                     DetailsModeSettings::expandableFolders();
  862. diff --git a/dolphin/src/views/dolphinview.cpp b/dolphin/src/views/dolphinview.cpp
  863. index 8050415..86dff91 100644
  864. --- a/dolphin/src/views/dolphinview.cpp
  865. +++ b/dolphin/src/views/dolphinview.cpp
  866. @@ -148,6 +148,7 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) :
  867.      connect(controller, SIGNAL(itemUnhovered(int)), this, SLOT(slotItemUnhovered(int)));
  868.      connect(controller, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent*)));
  869.      connect(controller, SIGNAL(modelChanged(KItemModelBase*,KItemModelBase*)), this, SLOT(slotModelChanged(KItemModelBase*,KItemModelBase*)));
  870. +    connect(controller, SIGNAL(klookTrigger()), this, SIGNAL(klookTrigger()));
  871.  
  872.      connect(m_model, SIGNAL(directoryLoadingStarted()),       this, SLOT(slotDirectoryLoadingStarted()));
  873.      connect(m_model, SIGNAL(directoryLoadingCompleted()),     this, SLOT(slotDirectoryLoadingCompleted()));
  874. @@ -1528,4 +1529,14 @@ KUrl DolphinView::viewPropertiesUrl() const
  875.      return url;
  876.  }
  877.  
  878. +KFileItemList DolphinView::sortedItems() const
  879. +{
  880. +    KFileItemList  list;
  881. +    for (int i = 0; i < m_model->count(); i++) {
  882. +        list.append(m_model->fileItem(i));
  883. +    }
  884. +    return list;
  885. +}
  886. +
  887. +
  888.  #include "dolphinview.moc"
  889. diff --git a/dolphin/src/views/dolphinview.h b/dolphin/src/views/dolphinview.h
  890. index 10f63c5..a53ee8a 100644
  891. --- a/dolphin/src/views/dolphinview.h
  892. +++ b/dolphin/src/views/dolphinview.h
  893. @@ -295,6 +295,8 @@ public:
  894.       */
  895.      void setViewPropertiesContext(const QString& context);
  896.      QString viewPropertiesContext() const;
  897. +    
  898. +    KFileItemList sortedItems() const;
  899.  
  900.  public slots:
  901.      /**
  902. @@ -506,6 +508,8 @@ signals:
  903.       */
  904.      void writeStateChanged(bool isFolderWritable);
  905.  
  906. +    void klookTrigger();
  907. +
  908.      /**
  909.       * Is emitted if the URL should be changed to the previous URL of the
  910.       * history (e.g. because the "back"-mousebutton has been pressed).