Commit dd470bb2 authored by Lukáš Tinkl's avatar Lukáš Tinkl
Browse files

port to QFileDialog

parent acc368e8
......@@ -31,9 +31,7 @@
#include <KLocalizedString>
#include <KActionCollection>
#include <KStandardAction>
#include <KFileDialog>
#include <KRecentFilesAction>
#include <KGlobal>
#include <KDebug>
#include <KEditToolBar>
#include <KShortcutsDialog>
......@@ -43,6 +41,8 @@
#include <QDragEnterEvent>
#include <QDragMoveEvent>
#include <QWeakPointer>
#include <QFileDialog>
#include <QMimeData>
static bool isValidArchiveDrag(const QMimeData *data)
{
......@@ -83,8 +83,7 @@ void MainWindow::dragEnterEvent(QDragEnterEvent * event)
return;
}
if ((event->source() == NULL) &&
(isValidArchiveDrag(event->mimeData()))) {
if (!event->source() && isValidArchiveDrag(event->mimeData())) {
event->acceptProposedAction();
}
return;
......@@ -222,10 +221,14 @@ void MainWindow::openArchive()
{
Interface *iface = qobject_cast<Interface*>(m_part);
Q_ASSERT(iface);
const QUrl url = KFileDialog::getOpenUrl(QUrl("kfiledialog:///ArkOpenDir"),
Kerfuffle::supportedMimeTypes().join( QLatin1String( " " )),
this);
openUrl(url);
QFileDialog dlg(this, i18nc("to open an archive", "Open Archive"));
dlg.setMimeTypeFilters(Kerfuffle::supportedMimeTypes());
dlg.setFileMode(QFileDialog::ExistingFile);
dlg.setAcceptMode(QFileDialog::AcceptOpen);
if (dlg.exec() == QDialog::Accepted) {
openUrl(dlg.selectedUrls().first());
}
}
void MainWindow::openUrl(const QUrl& url)
......@@ -264,13 +267,14 @@ void MainWindow::newArchive()
kDebug() << "Supported mimetypes are" << mimeTypes.join( QLatin1String( " " ));
const QUrl saveFileUrl = KFileDialog::getSaveUrl(QUrl("kfiledialog:///ArkNewDir"),
mimeTypes.join(QLatin1String(" ")));
m_openArgs.metaData()[QLatin1String( "createNewArchive" )] = QLatin1String( "true" );
openUrl(saveFileUrl);
m_openArgs.metaData().remove(QLatin1String( "showExtractDialog" ));
m_openArgs.metaData().remove(QLatin1String( "createNewArchive" ));
QFileDialog dlg(this);
dlg.setMimeTypeFilters(mimeTypes);
dlg.setFileMode(QFileDialog::ExistingFile);
dlg.setAcceptMode(QFileDialog::AcceptSave);
if (dlg.exec() == QDialog::Accepted) {
m_openArgs.metaData()[QLatin1String( "createNewArchive" )] = QLatin1String( "true" );
openUrl(dlg.selectedUrls().first());
m_openArgs.metaData().remove(QLatin1String( "showExtractDialog" ));
m_openArgs.metaData().remove(QLatin1String( "createNewArchive" ));
}
}
......@@ -116,7 +116,7 @@ void AddToArchive::start()
// TODO: If this class should ever be called outside main.cpp,
// the returns should be preceded by emitResult().
void AddToArchive::slotStartJob(void)
void AddToArchive::slotStartJob()
{
kDebug();
......
......@@ -37,7 +37,6 @@
#include <KActionCollection>
#include <KConfigGroup>
#include <KDebug>
#include <KFileDialog>
#include <KGuiItem>
#include <KIO/Job>
#include <KIO/NetAccess>
......@@ -62,6 +61,7 @@
#include <QVBoxLayout>
#include <QWeakPointer>
#include <QtDBus/QtDBus>
#include <QFileDialog>
#include <QIcon>
#include <QInputDialog>
......@@ -775,17 +775,15 @@ void Part::slotAddFiles()
// non-modal state).
// When KFileDialog::exec() is called, the widget is already shown
// and nothing happens.
const QStringList filesToAdd =
KFileDialog::getOpenFileNames(QUrl("kfiledialog:///ArkAddFiles"),
QString(), widget()->parentWidget(),
i18nc("@title:window", "Add Files"));
const QStringList filesToAdd = QFileDialog::getOpenFileNames(widget(), i18nc("@title:window", "Add Files"));
slotAddFiles(filesToAdd);
}
void Part::slotAddDir()
{
const QString dirToAdd = KFileDialog::getExistingDirectory(QUrl("kfiledialog:///ArkAddFiles"), widget(), i18nc("@title:window", "Add Folder"));
const QString dirToAdd = QFileDialog::getExistingDirectory(widget(), i18nc("@title:window", "Add Folder"));
if (!dirToAdd.isEmpty()) {
slotAddFiles(QStringList() << dirToAdd);
......@@ -852,7 +850,7 @@ void Part::saveSplitterSizes()
void Part::slotSaveAs()
{
QUrl saveUrl = KFileDialog::getSaveUrl(QUrl(QLatin1String( "kfiledialog:///ArkSaveAs/" ) + url().fileName()), QString(), widget());
QUrl saveUrl = QFileDialog::getSaveFileUrl(widget(), i18nc("@title:window", "Save Archive As"), url().adjusted(QUrl::RemoveFilename));
if ((saveUrl.isValid()) && (!saveUrl.isEmpty())) {
if (KIO::NetAccess::exists(saveUrl, KIO::NetAccess::DestinationSide, widget())) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment