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

KIO

  • 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
29class KPreviewPropsPlugin::KPreviewPropsPluginPrivate
30{
31public:
32 KPreviewPropsPluginPrivate() {}
33 ~KPreviewPropsPluginPrivate() {}
34};
35
36KPreviewPropsPlugin::KPreviewPropsPlugin(KPropertiesDialog* props)
37 : KPropertiesDialogPlugin(props),d(new KPreviewPropsPluginPrivate)
38{
39
40 if (properties->items().count()>1)
41 return;
42
43 createLayout();
44}
45
46void 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
62KPreviewPropsPlugin::~KPreviewPropsPlugin()
63{
64 delete d;
65}
66
67bool 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
83void 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"
KFileItemList
List of KFileItems, which adds a few helper methods to QList<KFileItem>.
Definition: kfileitem.h:675
KFileItem::url
KUrl url() const
Returns the url of the file.
Definition: kfileitem.cpp:1543
KFileMetaPreview
Definition: kfilemetapreview.h:19
KFileMetaPreview::showPreview
virtual void showPreview(const KUrl &url)
Definition: kfilemetapreview.cpp:138
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
KPageDialog::addPage
void addPage(KPageWidgetItem *item)
KPageWidgetItem
KPageWidgetItem::widget
QWidget * widget() const
KPreviewPropsPlugin::KPreviewPropsPlugin
KPreviewPropsPlugin(KPropertiesDialog *_props)
Definition: kpreviewprops.cpp:36
KPreviewPropsPlugin::supports
static bool supports(const KFileItemList &_items)
Tests whether a preview for the first item should be shown.
Definition: kpreviewprops.cpp:67
KPreviewPropsPlugin::~KPreviewPropsPlugin
virtual ~KPreviewPropsPlugin()
Definition: kpreviewprops.cpp:62
KPropertiesDialogPlugin
A Plugin in the Properties dialog This is an abstract class.
Definition: kpropertiesdialog.h:348
KPropertiesDialogPlugin::properties
KPropertiesDialog * properties
Pointer to the dialog.
Definition: kpropertiesdialog.h:393
KPropertiesDialog
The main properties dialog class.
Definition: kpropertiesdialog.h:58
KPropertiesDialog::item
KFileItem & item()
Definition: kpropertiesdialog.cpp:399
KPropertiesDialog::items
KFileItemList items() const
Definition: kpropertiesdialog.cpp:404
KSharedPtr< KMimeType >
QFrame
kfilemetapreview.h
kglobalsettings.h
klocale.h
i18n
QString i18n(const char *text)
kpreviewprops.h
previewjob.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
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