Commit 7850a0aa authored by Elvis Angelaccio's avatar Elvis Angelaccio
Browse files

Implement configuration dialog

This patch implements the standard configuration dialog (using
KConfigDialog) in Ark, as expected from a KDE application.

The widgets showed in the config dialog are provided by Kerfuffle, through the
Ark Part interface. This should help to show the Ark settings in, for
instance, Konqueror's config dialog.

REVIEW: 121997
BUG: 165314
FIXED-IN: 15.08
GUI:
parent 991c7238
......@@ -24,6 +24,7 @@
#include "logging.h"
#include "mainwindow.h"
#include "kerfuffle/archive_kerfuffle.h"
#include "kerfuffle/settingspage.h"
#include "part/interface.h"
#include <KPluginFactory>
......@@ -36,7 +37,9 @@
#include <KShortcutsDialog>
#include <KService>
#include <KSharedConfig>
#include <KConfigDialog>
#include <KConfigGroup>
#include <KConfigSkeleton>
#include <KXMLGUIFactory>
#include <QDebug>
......@@ -175,6 +178,7 @@ void MainWindow::setupActions()
KStandardAction::configureToolbars(this, SLOT(editToolbars()), actionCollection());
KStandardAction::keyBindings(this, SLOT(editKeyBindings()), actionCollection());
KStandardAction::preferences(this, SLOT(showSettings()), actionCollection());
}
void MainWindow::updateActions()
......@@ -270,6 +274,30 @@ void MainWindow::quit()
close();
}
void MainWindow::showSettings()
{
Interface *iface = qobject_cast<Interface*>(m_part);
Q_ASSERT(iface);
KConfigDialog *dialog = new KConfigDialog(this, QLatin1String("settings"), iface->config());
foreach (Kerfuffle::SettingsPage *page, iface->settingsPages(this)) {
dialog->addPage(page, page->name(), page->iconName());
}
// Hide the icons list if only one page has been added.
dialog->setFaceType(KPageDialog::Auto);
connect(dialog, SIGNAL(settingsChanged(QString)), this, SLOT(writeSettings()));
dialog->show();
}
void MainWindow::writeSettings()
{
Interface *iface = qobject_cast<Interface*>(m_part);
Q_ASSERT(iface);
iface->config()->save();
}
void MainWindow::newArchive()
{
qCDebug(ARK) << "Creating new archive";
......
......@@ -49,6 +49,8 @@ private slots:
void newArchive();
void openArchive();
void quit();
void showSettings();
void writeSettings();
void editKeyBindings();
void editToolbars();
......
......@@ -3,6 +3,9 @@
set(kerfuffle_SRCS
archive_kerfuffle.cpp
archiveinterface.cpp
extractionsettingspage.cpp
previewsettingspage.cpp
settingspage.cpp
jobs.cpp
extractiondialog.cpp
adddialog.cpp
......@@ -14,6 +17,8 @@ set(kerfuffle_SRCS
kconfig_add_kcfg_files(kerfuffle_SRCS settings.kcfgc)
ki18n_wrap_ui(kerfuffle_SRCS extractiondialog.ui adddialog.ui )
ki18n_wrap_ui(kerfuffle_SRCS extractionsettings.ui)
ki18n_wrap_ui(kerfuffle_SRCS previewsettings.ui)
add_library(kerfuffle SHARED ${kerfuffle_SRCS})
generate_export_header(kerfuffle BASE_NAME kerfuffle)
......
......@@ -27,12 +27,14 @@
<label>Whether to show the information panel.</label>
<default>true</default>
</entry>
</group>
<group name="Preview">
<entry name="limitPreviewFileSize" type="Bool">
<label>Limit preview file size</label>
<label>Whether to limit the preview according to file size.</label>
<default>true</default>
</entry>
<entry name="previewFileSizeLimit" type="Int">
<label>Preview file size limit in megabytes</label>
<label>Preview file size limit in megabytes.</label>
<default>200</default>
</entry>
</group>
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExtractionSettings</class>
<widget class="QWidget" name="ExtractionSettings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>544</width>
<height>487</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="kcfg_openDestinationFolderAfterExtraction">
<property name="text">
<string>Open destination folder after extraction</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_closeAfterExtraction">
<property name="text">
<string>Close Ark after extraction</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_preservePaths">
<property name="text">
<string>Preserve paths when extracting</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>388</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
/*
* ark -- archiver for the KDE project
*
* Copyright (C) 2015 Elvis Angelaccio <elvis.angelaccio@kdemail.net>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "extractionsettingspage.h"
namespace Kerfuffle
{
ExtractionSettingsPage::ExtractionSettingsPage(QWidget *parent, const QString &name, const QString &iconName)
: SettingsPage(parent, name, iconName)
{
setupUi(this);
}
}
/*
* ark -- archiver for the KDE project
*
* Copyright (C) 2015 Elvis Angelaccio <elvis.angelaccio@kdemail.net>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef EXTRACTIONSETTINGSPAGE_H
#define EXTRACTIONSETTINGSPAGE_H
#include "settingspage.h"
#include "ui_extractionsettings.h"
namespace Kerfuffle
{
class KERFUFFLE_EXPORT ExtractionSettingsPage : public SettingsPage, public Ui::ExtractionSettings
{
Q_OBJECT
public:
explicit ExtractionSettingsPage(QWidget *parent = 0, const QString &name = QString(), const QString &iconName = QString());
};
}
#endif
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PreviewSettings</class>
<widget class="QWidget" name="PreviewSettings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>547</width>
<height>487</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="sizeLimitWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="kcfg_limitPreviewFileSize">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Disable preview for files larger than:</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="kcfg_previewFileSizeLimit">
<property name="suffix">
<string> megabytes</string>
</property>
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
<property name="value">
<number>200</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
/*
* ark -- archiver for the KDE project
*
* Copyright (C) 2015 Elvis Angelaccio <elvis.angelaccio@kdemail.net>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "previewsettingspage.h"
namespace Kerfuffle
{
PreviewSettingsPage::PreviewSettingsPage(QWidget *parent, const QString &name, const QString &iconName)
: SettingsPage(parent, name, iconName)
{
setupUi(this);
connect(kcfg_limitPreviewFileSize, &QCheckBox::toggled, this, &PreviewSettingsPage::slotToggled);
}
void PreviewSettingsPage::slotToggled(bool enabled)
{
kcfg_previewFileSizeLimit->setEnabled(enabled);
}
}
/*
* ark -- archiver for the KDE project
*
* Copyright (C) 2015 Elvis Angelaccio <elvis.angelaccio@kdemail.net>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef PREVIEWSETTINGSPAGE_H
#define PREVIEWSETTINGSPAGE_H
#include "settingspage.h"
#include "ui_previewsettings.h"
namespace Kerfuffle
{
class KERFUFFLE_EXPORT PreviewSettingsPage : public SettingsPage, public Ui::PreviewSettings
{
Q_OBJECT
public:
explicit PreviewSettingsPage(QWidget *parent = 0, const QString &name = QString(), const QString &iconName = QString());
private slots:
void slotToggled(bool enabled);
};
}
#endif
/*
* ark -- archiver for the KDE project
*
* Copyright (C) 2015 Elvis Angelaccio <elvis.angelaccio@kdemail.net>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "settingspage.h"
namespace Kerfuffle
{
SettingsPage::SettingsPage(QWidget *parent, const QString &name, const QString &iconName)
: QWidget(parent),
m_name(name),
m_iconName(iconName)
{}
QString SettingsPage::name() const
{
return m_name;
}
QString SettingsPage::iconName() const
{
return m_iconName;
}
}
/*
* ark -- archiver for the KDE project
*
* Copyright (C) 2015 Elvis Angelaccio <elvis.angelaccio@kdemail.net>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SETTINGSPAGE_H
#define SETTINGSPAGE_H
#include "kerfuffle_export.h"
#include <QWidget>
namespace Kerfuffle
{
class KERFUFFLE_EXPORT SettingsPage : public QWidget
{
Q_OBJECT
public:
explicit SettingsPage(QWidget *parent = 0, const QString &name = QString(), const QString &iconName = QString());
QString name() const;
QString iconName() const;
private:
QString m_name;
QString m_iconName;
};
}
#endif
......@@ -24,14 +24,23 @@
#include <QStringList>
#include <QtPlugin>
namespace Kerfuffle
{
class SettingsPage;
}
class KConfigSkeleton;
class Interface
{
public:
virtual ~Interface() {}
virtual bool isBusy() const = 0;
virtual KConfigSkeleton *config() const = 0;
virtual QList<Kerfuffle::SettingsPage*> settingsPages(QWidget *parent) const = 0;
};
Q_DECLARE_INTERFACE(Interface, "org.kde.kerfuffle.partinterface/0.42")
Q_DECLARE_INTERFACE(Interface, "org.kde.kerfuffle.partinterface/0.43")
#endif // INTERFACE_H
......@@ -31,8 +31,10 @@
#include "jobtracker.h"
#include "kerfuffle/archive_kerfuffle.h"
#include "kerfuffle/extractiondialog.h"
#include "kerfuffle/extractionsettingspage.h"
#include "kerfuffle/jobs.h"
#include "kerfuffle/settings.h"
#include "kerfuffle/previewsettingspage.h"
#include <KAboutData>
#include <KActionCollection>
......@@ -525,6 +527,20 @@ bool Part::isBusy() const
return m_busy;
}
KConfigSkeleton *Part::config() const
{
return ArkSettings::self();
}
QList<Kerfuffle::SettingsPage*> Part::settingsPages(QWidget *parent) const
{
static QList<SettingsPage*> pages;
pages.append(new ExtractionSettingsPage(parent, i18n("Extraction settings"), QLatin1String("archive-extract")));
pages.append(new PreviewSettingsPage(parent, i18n("Preview settings"), QLatin1String("document-preview-archive")));
return pages;
}
void Part::slotLoadingStarted()
{
}
......
......@@ -68,6 +68,8 @@ public:
bool saveFile() Q_DECL_OVERRIDE;
bool isBusy() const Q_DECL_OVERRIDE;
KConfigSkeleton *config() const Q_DECL_OVERRIDE;
QList<Kerfuffle::SettingsPage*> settingsPages(QWidget *parent) const Q_DECL_OVERRIDE;
public slots:
void extractSelectedFilesTo(const QString& localPath);
......
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