• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KIO

  • sources
  • kde-4.14
  • kdelibs
  • kio
  • kfile
kpreviewprops.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2005 Stephan Binner <binner@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 
18  */
19 
20 #include "kpreviewprops.h"
21 #include <kio/previewjob.h>
22 
23 #include <QtGui/QLayout>
24 
25 #include <kfilemetapreview.h>
26 #include <kglobalsettings.h>
27 #include <klocale.h>
28 
29 class KPreviewPropsPlugin::KPreviewPropsPluginPrivate
30 {
31 public:
32  KPreviewPropsPluginPrivate() {}
33  ~KPreviewPropsPluginPrivate() {}
34 };
35 
36 KPreviewPropsPlugin::KPreviewPropsPlugin(KPropertiesDialog* props)
37  : KPropertiesDialogPlugin(props),d(new KPreviewPropsPluginPrivate)
38 {
39 
40  if (properties->items().count()>1)
41  return;
42 
43  createLayout();
44 }
45 
46 void KPreviewPropsPlugin::createLayout()
47 {
48  // let the dialog create the page frame
49  QFrame* topframe = new QFrame();
50  properties->addPage(topframe, i18n("P&review"));
51  topframe->setFrameStyle(QFrame::NoFrame);
52 
53  QVBoxLayout* tmp = new QVBoxLayout(topframe);
54  tmp->setMargin(0);
55 
56  preview = new KFileMetaPreview(topframe);
57 
58  tmp->addWidget(preview) ;
59  connect( properties, SIGNAL(currentPageChanged(KPageWidgetItem*,KPageWidgetItem*)), SLOT(currentPageChanged(KPageWidgetItem*,KPageWidgetItem*)) );
60 }
61 
62 KPreviewPropsPlugin::~KPreviewPropsPlugin()
63 {
64  delete d;
65 }
66 
67 bool KPreviewPropsPlugin::supports( const KFileItemList &_items )
68 {
69  if ( _items.count() != 1 )
70  return false;
71  bool metaDataEnabled = KGlobalSettings::showFilePreview(_items.first().url());
72  if (!metaDataEnabled)
73  return false;
74  const KMimeType::Ptr mime = _items.first().mimeTypePtr();
75  const QStringList supportedMimeTypes = KIO::PreviewJob::supportedMimeTypes();
76  foreach(const QString& supportedMime, supportedMimeTypes) {
77  if (mime->is(supportedMime))
78  return true;
79  }
80  return false;
81 }
82 
83 void KPreviewPropsPlugin::currentPageChanged( KPageWidgetItem *current, KPageWidgetItem * )
84 {
85  if ( current->widget() != preview->parent() )
86  return;
87 
88  disconnect( properties, SIGNAL(currentPageChanged(KPageWidgetItem*,KPageWidgetItem*)), this, SLOT(currentPageChanged(KPageWidgetItem*,KPageWidgetItem*)) );
89  preview->showPreview(properties->item().url());
90 }
91 
92 #include "kpreviewprops.moc"
i18n
QString i18n(const char *text)
KPropertiesDialog::items
KFileItemList items() const
Definition: kpropertiesdialog.cpp:404
kglobalsettings.h
kfilemetapreview.h
kpreviewprops.h
QFrame::setFrameStyle
void setFrameStyle(int style)
KPropertiesDialogPlugin::properties
KPropertiesDialog * properties
Pointer to the dialog.
Definition: kpropertiesdialog.h:393
klocale.h
QObject::disconnect
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
KPreviewPropsPlugin::KPreviewPropsPlugin
KPreviewPropsPlugin(KPropertiesDialog *_props)
Definition: kpreviewprops.cpp:36
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QList::count
int count(const T &value) const
KPropertiesDialogPlugin
A Plugin in the Properties dialog This is an abstract class.
Definition: kpropertiesdialog.h:347
previewjob.h
KFileItemList
List of KFileItems, which adds a few helper methods to QList.
Definition: kfileitem.h:674
KPreviewPropsPlugin::supports
static bool supports(const KFileItemList &_items)
Tests whether a preview for the first item should be shown.
Definition: kpreviewprops.cpp:67
QVBoxLayout
KPropertiesDialog::item
KFileItem & item()
Definition: kpropertiesdialog.cpp:399
QList::first
T & first()
QString
QLayout::setMargin
void setMargin(int margin)
QStringList
KPropertiesDialog
The main properties dialog class.
Definition: kpropertiesdialog.h:57
KPageWidgetItem::widget
QWidget * widget() const
QFrame
KPreviewPropsPlugin::~KPreviewPropsPlugin
virtual ~KPreviewPropsPlugin()
Definition: kpreviewprops.cpp:62
KFileMetaPreview
Definition: kfilemetapreview.h:18
KFileMetaPreview::showPreview
virtual void showPreview(const KUrl &url)
Definition: kfilemetapreview.cpp:138
KPageWidgetItem
KGlobalSettings::showFilePreview
static bool showFilePreview(const KUrl &)
KIO::PreviewJob::supportedMimeTypes
static QStringList supportedMimeTypes()
Returns a list of all supported MIME types.
Definition: previewjob.cpp:745
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject::parent
QObject * parent() const
KFileItem::url
KUrl url() const
Returns the url of the file.
Definition: kfileitem.cpp:1543
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:53 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal