]>
cloud.milkyroute.net Git - dolphin.git/blob - src/settings/general/configurepreviewplugindialog.cpp
1 /***************************************************************************
2 * Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #include "configurepreviewplugindialog.h"
24 #include <KIO/NetAccess>
25 #include <kio/thumbcreator.h>
27 #include <QApplication>
29 #include <QVBoxLayout>
31 ConfigurePreviewPluginDialog::ConfigurePreviewPluginDialog(const QString
& pluginName
,
32 const QString
& desktopEntryName
,
35 m_configurationWidget(0),
38 KLibrary
library(desktopEntryName
);
40 newCreator create
= (newCreator
)library
.resolveFunction("new_creator");
42 m_previewPlugin
= dynamic_cast<ThumbCreatorV2
*>(create());
46 setCaption(i18nc("@title:window", "Configure Preview for %1", pluginName
));
48 setButtons(Ok
| Cancel
);
51 QWidget
* mainWidget
= new QWidget(this);
52 mainWidget
->setSizePolicy(QSizePolicy::Preferred
, QSizePolicy::Minimum
);
53 QVBoxLayout
* layout
= new QVBoxLayout(mainWidget
);
54 if (m_previewPlugin
) {
55 m_configurationWidget
= m_previewPlugin
->createConfigurationWidget();
56 layout
->addWidget(m_configurationWidget
);
58 layout
->addStretch(1);
60 setMainWidget(mainWidget
);
62 connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
65 ConfigurePreviewPluginDialog::~ConfigurePreviewPluginDialog()
69 void ConfigurePreviewPluginDialog::slotOk()
71 m_previewPlugin
->writeConfiguration(m_configurationWidget
);
72 // TODO: It would be great having a mechanism to tell PreviewJob that only previews
73 // for a specific MIME-type should be regenerated. As this is not available yet we
74 // delete the whole thumbnails directory.
75 QApplication::changeOverrideCursor(Qt::BusyCursor
);
76 KIO::NetAccess::del(QString(QDir::homePath() + "/.thumbnails/"), this);
77 QApplication::restoreOverrideCursor();
81 #include "configurepreviewplugindialog.moc"