1 /* This file is part of the KDE libraries
2 Copyright (C) 2005 Stephan Binner <binner@kde.org>
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.
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.
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.
20 #include "kpreviewprops.h"
21 #include <kio/previewjob.h>
23 #include <QtGui/QLayout>
25 #include <kfilemetapreview.h>
26 #include <kglobalsettings.h>
29 class KPreviewPropsPlugin::KPreviewPropsPluginPrivate
32 KPreviewPropsPluginPrivate() {}
33 ~KPreviewPropsPluginPrivate() {}
36 KPreviewPropsPlugin::KPreviewPropsPlugin(KPropertiesDialog
* props
)
37 : KPropertiesDialogPlugin(props
),d(new KPreviewPropsPluginPrivate
)
40 if (properties
->items().count()>1)
46 void KPreviewPropsPlugin::createLayout()
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
);
53 QVBoxLayout
* tmp
= new QVBoxLayout(topframe
);
57 preview
= new KFileMetaPreview(topframe
);
59 tmp
->addWidget(preview
) ;
60 connect( properties
, SIGNAL( currentPageChanged( KPageWidgetItem
*, KPageWidgetItem
* ) ), SLOT( currentPageChanged( KPageWidgetItem
*, KPageWidgetItem
* ) ) );
63 KPreviewPropsPlugin::~KPreviewPropsPlugin()
68 bool KPreviewPropsPlugin::supports( const KFileItemList
&_items
)
70 if ( _items
.count() != 1 )
72 bool metaDataEnabled
= KGlobalSettings::showFilePreview(_items
.first().url());
75 const KMimeType::Ptr mime
= _items
.first().mimeTypePtr();
76 const QStringList supportedMimeTypes
= KIO::PreviewJob::supportedMimeTypes();
77 foreach(const QString
& supportedMime
, supportedMimeTypes
) {
78 if (mime
->is(supportedMime
))
84 void KPreviewPropsPlugin::currentPageChanged( KPageWidgetItem
*current
, KPageWidgetItem
* )
86 if ( current
->widget() != preview
->parent() )
89 disconnect( properties
, SIGNAL( currentPageChanged( KPageWidgetItem
*, KPageWidgetItem
* ) ), this, SLOT( currentPageChanged( KPageWidgetItem
*, KPageWidgetItem
* ) ) );
90 preview
->showPreview(properties
->item().url());
93 #include "kpreviewprops.moc"