Commit a54ab3a6 authored by Elvis Angelaccio's avatar Elvis Angelaccio

Merge branch 'Applications/16.04'

* Applications/16.04:
  GIT_SILENT Add comment for previous commit.
  Fix opening tar archives whose name ends with a number
  libarchive: properly stop all jobs
  Fix preview windows covering the main window
  Add missing text for main toolbar
  GIT_SILENT Upgrade KDE Applications version to 16.04.0.
  SVN_SILENT made messages (.desktop file)
  SVN_SILENT made messages (.desktop file)
  GIT_SILENT Upgrade KDE Applications version to 16.03.90.
  SVN_SILENT made messages (.desktop file)
  SVN_SILENT made messages (.desktop file)
  SVN_SILENT made messages (.desktop file)
  SVN_SILENT made messages (.desktop file)
  Properly fix lrzip support
  Fix lrzip support in libarchiveplugin
  SVN_SILENT made messages (.desktop file)
  SVN_SILENT made messages (.desktop file)
  SVN_SILENT made messages (.desktop file)
  SVN_SILENT made messages (.desktop file)
parents 661f8a49 dcb03a8a
......@@ -98,6 +98,7 @@ Name[tr]=Buraya (TAR.GZ olarak)
Name[uk]=Сюди (як TAR.GZ)
Name[x-test]=xxHere (as TAR.GZ)xx
Name[zh_CN]=此处 (作为 TAR.GZ)
Name[zh_TW]=在此壓成 TAR.GZ 壓縮檔
Icon=ark
Exec=ark --changetofirstpath --add --autofilename tar.gz %F
......@@ -134,6 +135,7 @@ Name[tr]=Buraya (ZIP olarak)
Name[uk]=Сюди (як ZIP)
Name[x-test]=xxHere (as ZIP)xx
Name[zh_CN]=此处 (作为 ZIP)
Name[zh_TW]=在此壓成 ZIP 壓縮檔
Icon=ark
Exec=ark --changetofirstpath --add --autofilename zip %F
......@@ -171,5 +173,6 @@ Name[tr]=Sıkıştır...
Name[uk]=Стиснути…
Name[x-test]=xxCompress to...xx
Name[zh_CN]=压缩到...
Name[zh_TW]=壓縮為...
Icon=ark
Exec=ark --add --changetofirstpath --dialog %F
......@@ -89,6 +89,7 @@ Name[sv]=Packa upp arkiv här
Name[uk]=Видобути архів сюди
Name[x-test]=xxExtract archive herexx
Name[zh_CN]=在此解压缩归档
Name[zh_TW]=在此解壓縮
Icon=ark
Exec=ark --batch --autodestination %F
......@@ -124,6 +125,7 @@ Name[sv]=Packa upp arkiv i...
Name[uk]=Видобути архів до…
Name[x-test]=xxExtract archive to...xx
Name[zh_CN]=解压缩归档到...
Name[zh_TW]=解壓縮到...
Icon=ark
Exec=ark --batch --autodestination --dialog %F
......@@ -159,5 +161,6 @@ Name[sv]=Packa upp arkiv här, detektera underkatalog automatiskt
Name[uk]=Видобути архів сюди, автоматично визначити підтеку
Name[x-test]=xxExtract archive here, autodetect subfolderxx
Name[zh_CN]=在此解压缩归档,自动探测子文件夹
Name[zh_TW]=在此解壓縮,自動偵測子資料夾
Icon=ark
Exec=ark --batch --autodestination --autosubfolder %F
......@@ -45,6 +45,7 @@
#include <KConfigSkeleton>
#include <KXMLGUIFactory>
#include <QApplication>
#include <QDebug>
#include <QDragEnterEvent>
#include <QDragMoveEvent>
......@@ -256,6 +257,18 @@ void MainWindow::setShowExtractDialog(bool option)
}
}
void MainWindow::closeEvent(QCloseEvent *event)
{
Q_UNUSED(event)
// Preview windows don't have a parent, so we need to manually close them.
foreach (QWidget *widget, qApp->topLevelWidgets()) {
if (widget->isVisible()) {
widget->close();
}
}
}
void MainWindow::quit()
{
close();
......
......@@ -44,6 +44,9 @@ public slots:
void openUrl(const QUrl &url);
void setShowExtractDialog(bool);
protected:
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
private slots:
void updateActions();
void newArchive();
......
......@@ -188,3 +188,4 @@ Comment[tr]=Arşiv dosyaları ile çalış
Comment[uk]=Робота з файловими архівами
Comment[x-test]=xxWork with file archivesxx
Comment[zh_CN]=处理归档文件
Comment[zh_TW]=檔案壓縮工具
......@@ -70,6 +70,7 @@ void MimeTypeTest::testMimeTypeDetection_data()
QTest::newRow("zip with wrong extension") << QFINDTESTDATA("data/zip_with_wrong_extension.rar") << QStringLiteral("application/zip");
QTest::newRow("tar with special char in the extension") << QStringLiteral("foo.tar~1.gz") << compressedGzipTarMime;
QTest::newRow("another tar with special char in the extension") << QStringLiteral("foo.ta4r.gz") << compressedGzipTarMime;
QTest::newRow("tar downloaded by wget") << QFINDTESTDATA("data/wget-download.tar.gz.1") << compressedGzipTarMime;
// This ISO file may be detected-by-content as text/plain. See https://bugs.freedesktop.org/show_bug.cgi?id=80877
QTest::newRow("archlinux truncated ISO") << QFINDTESTDATA("data/archlinux-2015.09.01-dual_truncated.iso") << isoMimeType;
......
......@@ -175,8 +175,6 @@ void Job::onFinished(bool result)
{
qCDebug(ARK) << "Job finished, result:" << result << ", time:" << jobTimer.elapsed() << "ms";
archiveInterface()->disconnect(this);
emitResult();
}
......
......@@ -47,7 +47,14 @@ QMimeType determineMimeType(const QString& filename)
// we cannot rely on it when the archive extension is wrong; we need to validate by hand.
if (fileinfo.completeSuffix().toLower().remove(QRegularExpression(QStringLiteral("[^a-z\\.]"))).contains(QStringLiteral("tar."))) {
inputFile.chop(fileinfo.completeSuffix().length());
inputFile += fileinfo.completeSuffix().remove(QRegularExpression(QStringLiteral("[^a-zA-Z\\.]")));
// We remove non-alpha chars from the filename extension, but not periods.
// If the filename is e.g. "foo.tar.gz.1", we get the "foo.tar.gz." string,
// so we need to manually drop the last period character from it.
QString cleanExtension = fileinfo.completeSuffix().toLower().remove(QRegularExpression(QStringLiteral("[^a-z\\.]")));
if (cleanExtension.endsWith(QLatin1Char('.'))) {
cleanExtension.chop(1);
}
inputFile += cleanExtension;
qCDebug(ARK) << "Validated filename of compressed tar" << filename << "into filename" << inputFile;
}
......
<!DOCTYPE kpartgui>
<kpartgui name="ark_part" version="11">
<kpartgui name="ark_part" version="12">
<MenuBar>
<Menu name="archive">
<text>&amp;Archive</text>
......@@ -24,6 +24,7 @@
</Menu>
</MenuBar>
<ToolBar name="mainToolBar">
<text>Main Toolbar</text>
<Action name="extract"/>
<Action name="preview"/>
<Action name="openfile"/>
......
......@@ -40,11 +40,13 @@
#include <QPushButton>
#include <QMimeDatabase>
ArkViewer::ArkViewer(QWidget *parent, Qt::WindowFlags flags)
: QDialog(parent, flags)
ArkViewer::ArkViewer()
: QDialog()
{
qCDebug(ARK) << "ArkViewer opened";
setAttribute(Qt::WA_DeleteOnClose);
// Set a QVBoxLayout as main layout of dialog
m_mainLayout = new QVBoxLayout(this);
setLayout(m_mainLayout);
......@@ -93,7 +95,7 @@ void ArkViewer::dialogClosed()
}
}
void ArkViewer::view(const QString& fileName, QWidget *parent)
void ArkViewer::view(const QString& fileName)
{
QMimeDatabase db;
QMimeType mimeType = db.mimeTypeForFile(fileName);
......@@ -112,7 +114,7 @@ void ArkViewer::view(const QString& fileName, QWidget *parent)
const QList<QUrl> fileUrlList = {QUrl::fromLocalFile(fileName)};
// The last argument (tempFiles) set to true means that the temporary
// file will be removed when the viewer application exits.
KRun::runService(*viewer, fileUrlList, parent, true);
KRun::runService(*viewer, fileUrlList, Q_NULLPTR, true);
return;
}
......@@ -129,7 +131,7 @@ void ArkViewer::view(const QString& fileName, QWidget *parent)
// File has a defined MIME type, and not the default
// application/octet-stream. So it could be viewable as
// plain text, ask the user.
response = KMessageBox::warningContinueCancel(parent,
response = KMessageBox::warningContinueCancel(Q_NULLPTR,
xi18n("The internal viewer cannot preview this type of file<nl/>(%1).<nl/><nl/>Do you want to try to view it as plain text?", mimeType.name()),
i18nc("@title:window", "Cannot Preview File"),
KGuiItem(i18nc("@action:button", "Preview as Text"), QIcon::fromTheme(QStringLiteral("text-plain"))),
......@@ -141,7 +143,7 @@ void ArkViewer::view(const QString& fileName, QWidget *parent)
// There is still a possibility that it could be viewable as plain
// text, so ask the user. Not the same as the message/question
// above, because the wording and default are different.
response = KMessageBox::warningContinueCancel(parent,
response = KMessageBox::warningContinueCancel(Q_NULLPTR,
xi18n("The internal viewer cannot preview this unknown type of file.<nl/><nl/>Do you want to try to view it as plain text?"),
i18nc("@title:window", "Cannot Preview File"),
KGuiItem(i18nc("@action:button", "Preview as Text"), QIcon::fromTheme(QStringLiteral("text-plain"))),
......@@ -160,7 +162,7 @@ void ArkViewer::view(const QString& fileName, QWidget *parent)
if (viewInInternalViewer) {
qCDebug(ARK) << "Opening internal viewer";
ArkViewer *internalViewer = new ArkViewer(parent, Qt::Window);
ArkViewer *internalViewer = new ArkViewer();
internalViewer->show();
if (internalViewer->viewInInternalViewer(fileName, mimeType)) {
// The internal viewer is showing the file, and will
......@@ -169,7 +171,7 @@ void ArkViewer::view(const QString& fileName, QWidget *parent)
return;
}
else {
KMessageBox::sorry(parent, i18n("The internal viewer cannot preview this file."));
KMessageBox::sorry(Q_NULLPTR, i18n("The internal viewer cannot preview this file."));
delete internalViewer;
}
}
......
......@@ -39,13 +39,13 @@ public:
virtual ~ArkViewer();
QSize sizeHint() const Q_DECL_OVERRIDE;
static void view(const QString& fileName, QWidget* parent = 0);
static void view(const QString& fileName);
private slots:
void dialogClosed();
private:
explicit ArkViewer(QWidget* parent = 0, Qt::WindowFlags flags = 0);
explicit ArkViewer();
static KService::Ptr getViewer(const QString& mimeType);
bool viewInInternalViewer(const QString& fileName, const QMimeType& mimeType);
......
......@@ -802,7 +802,7 @@ void Part::slotOpenExtractedEntry(KJob *job)
switch (m_openFileMode) {
case Preview:
ArkViewer::view(fullName, widget());
ArkViewer::view(fullName);
break;
case OpenFile:
KRun::runUrl(QUrl::fromUserInput(fullName,
......
......@@ -21,6 +21,7 @@
"Name[ca]": "Connector per arxius RAR",
"Name[cs]": "Modul pro archiv RAR",
"Name[de]": "RAR-Archiv-Modul",
"Name[en_GB]": "RAR archive plugin",
"Name[es]": "Complemento de archivo RAR",
"Name[fi]": "RAR-pakkaustuki",
"Name[fr]": "Module externe d'archive « RAR »",
......@@ -42,6 +43,7 @@
"Name[uk]": "Додаток для архівів RAR",
"Name[x-test]": "xxRAR archive pluginxx",
"Name[zh_CN]": "RAR 归档插件",
"Name[zh_TW]": "RAR 壓縮檔外掛程式",
"ServiceTypes": [
"Kerfuffle/Plugin"
],
......
......@@ -21,6 +21,7 @@
"Name[ca]": "Connector de l'Unarchiver",
"Name[cs]": "Modul pro Unarchiver",
"Name[de]": "Unarchiver-Modul",
"Name[en_GB]": "The Unarchiver plugin",
"Name[es]": "El complemento de Unarchiver",
"Name[fi]": "Unarchiver-tuki",
"Name[it]": "Estensione The Unarchiver",
......@@ -38,6 +39,7 @@
"Name[uk]": "Додаток Unarchiver",
"Name[x-test]": "xxThe Unarchiver pluginxx",
"Name[zh_CN]": "Unarchiver 插件",
"Name[zh_TW]": "解壓縮外掛程式",
"ServiceTypes": [
"Kerfuffle/Plugin"
],
......
......@@ -216,7 +216,7 @@ bool LibarchivePlugin::copyFiles(const QVariantList& files, const QString& desti
QString fileBeingRenamed;
// Iterate through all entries in archive.
while (archive_read_next_header(arch.data(), &entry) == ARCHIVE_OK) {
while (!m_abortOperation && (archive_read_next_header(arch.data(), &entry) == ARCHIVE_OK)) {
if (!extractAll && remainingFiles.isEmpty()) {
break;
......@@ -412,6 +412,8 @@ bool LibarchivePlugin::copyFiles(const QVariantList& files, const QString& desti
} // While entries left to read in archive.
m_abortOperation = false;
qCDebug(ARK) << "Extracted" << no_entries << "entries";
return archive_read_close(arch.data()) == ARCHIVE_OK;
......
......@@ -79,6 +79,7 @@ protected:
typedef QScopedPointer<struct archive, ArchiveWriteCustomDeleter> ArchiveWrite;
ArchiveRead m_archiveReadDisk;
bool m_abortOperation;
private:
int extractionFlags() const;
......@@ -87,7 +88,6 @@ private:
qlonglong m_currentExtractedFilesSize;
bool m_emitNoEntries;
qlonglong m_extractedFilesSize;
bool m_abortOperation;
};
#endif // LIBARCHIVEPLUGIN_H
......@@ -98,6 +98,7 @@ bool ReadWriteLibarchivePlugin::addFiles(const QStringList& files, const Compres
archive_write_set_format_pax_restricted(arch_writer.data());
int ret;
bool isLrzip = false;
if (creatingNewFile) {
if (filename().right(2).toUpper() == QLatin1String("GZ")) {
qCDebug(ARK) << "Detected gzip compression for new file";
......@@ -123,6 +124,7 @@ bool ReadWriteLibarchivePlugin::addFiles(const QStringList& files, const Compres
} else if (filename().right(3).toUpper() == QLatin1String("LRZ")) {
qCDebug(ARK) << "Detected lrzip compression for new file";
ret = archive_write_add_filter_lrzip(arch_writer.data());
isLrzip = true;
} else if (filename().right(3).toUpper() == QLatin1String("TAR")) {
qCDebug(ARK) << "Detected no compression for new file (pure tar)";
ret = archive_write_add_filter_none(arch_writer.data());
......@@ -131,7 +133,9 @@ bool ReadWriteLibarchivePlugin::addFiles(const QStringList& files, const Compres
ret = archive_write_add_filter_gzip(arch_writer.data());
}
if (ret != ARCHIVE_OK) {
// Libarchive emits a warning for lrzip due to using external executable.
if ((isLrzip && ret != ARCHIVE_WARN) ||
(!isLrzip && ret != ARCHIVE_OK)) {
emit error(xi18nc("@info", "Setting the compression method failed with the following error:<nl/><message>%1</message>",
QLatin1String(archive_error_string(arch_writer.data()))));
return false;
......@@ -174,6 +178,7 @@ bool ReadWriteLibarchivePlugin::addFiles(const QStringList& files, const Compres
break;
case ARCHIVE_FILTER_LRZIP:
ret = archive_write_add_filter_lrzip(arch_writer.data());
isLrzip = true;
break;
case ARCHIVE_FILTER_NONE:
ret = archive_write_add_filter_none(arch_writer.data());
......@@ -184,7 +189,9 @@ bool ReadWriteLibarchivePlugin::addFiles(const QStringList& files, const Compres
return false;
}
if (ret != ARCHIVE_OK) {
// Libarchive emits a warning for lrzip due to using external executable.
if ((isLrzip && ret != ARCHIVE_WARN) ||
(!isLrzip && ret != ARCHIVE_OK)) {
emit error(xi18nc("@info", "Setting the compression method failed with the following error:<nl/><message>%1</message>",
QLatin1String(archive_error_string(arch_writer.data()))));
return false;
......@@ -202,6 +209,11 @@ bool ReadWriteLibarchivePlugin::addFiles(const QStringList& files, const Compres
qCDebug(ARK) << "Writing new entries";
int no_entries = 0;
foreach(const QString& selectedFile, files) {
if (m_abortOperation) {
break;
}
if (!writeFile(selectedFile, arch_writer.data())) {
return false;
}
......@@ -214,7 +226,7 @@ bool ReadWriteLibarchivePlugin::addFiles(const QStringList& files, const Compres
QDir::Hidden | QDir::NoDotAndDotDot,
QDirIterator::Subdirectories);
while (it.hasNext()) {
while (!m_abortOperation && it.hasNext()) {
QString path = it.next();
if ((it.fileName() == QLatin1String("..")) ||
......@@ -246,7 +258,7 @@ bool ReadWriteLibarchivePlugin::addFiles(const QStringList& files, const Compres
no_entries = 0;
// Copy old entries from previous archive to new archive.
while (archive_read_next_header(arch_reader.data(), &entry) == ARCHIVE_OK) {
while (!m_abortOperation && (archive_read_next_header(arch_reader.data(), &entry) == ARCHIVE_OK)) {
const QString entryName = QFile::decodeName(archive_entry_pathname(entry));
......@@ -283,6 +295,8 @@ bool ReadWriteLibarchivePlugin::addFiles(const QStringList& files, const Compres
qCDebug(ARK) << "Added" << no_entries << "old entries to archive";
}
m_abortOperation = false;
// In the success case, we need to manually close the archive_writer before
// calling QSaveFile::commit(), otherwise the latter will close() the
// file descriptor archive_writer is still working on.
......@@ -411,6 +425,8 @@ bool ReadWriteLibarchivePlugin::deleteFiles(const QVariantList& files)
}
qCDebug(ARK) << "Removed" << no_entries << "entries from archive";
m_abortOperation = false;
// In the success case, we need to manually close the archive_writer before
// calling QSaveFile::commit(), otherwise the latter will close() the
// file descriptor archive_writer is still working on.
......
......@@ -16,6 +16,7 @@
"Description[ca]": "Connector del libbz2 pel Kerfuffle",
"Description[cs]": "modul libbz2 pro Kerfuffle",
"Description[de]": "libgz2-Modul für Kerfuffle",
"Description[en_GB]": "libbz2 plugin for Kerfuffle",
"Description[es]": "Complemento libbz2 para Kerfuffle",
"Description[fi]": "libbz2-pakkaustuki",
"Description[it]": "Estensione libbz2 per Kerfuffle",
......@@ -34,6 +35,7 @@
"Description[uk]": "Додаток libbz2 для Kerfuffle",
"Description[x-test]": "xxlibbz2 plugin for Kerfufflexx",
"Description[zh_CN]": "Kerfuffle 的 libbz2 插件",
"Description[zh_TW]": "Kerfuffle 的 libbz2 外掛程式",
"Id": "kerfuffle_libbz2",
"License": "BSD",
"MimeTypes": [
......
......@@ -16,6 +16,7 @@
"Description[ca]": "Connector del libgz pel Kerfuffle",
"Description[cs]": "modul libgz pro Kerfuffle",
"Description[de]": "libgz-Modul für Kerfuffle",
"Description[en_GB]": "libgz plugin for Kerfuffle",
"Description[es]": "Complemento libgz para Kerfuffle",
"Description[fi]": "libgz-pakkaustuki",
"Description[it]": "Estensione libgz per Kerfuffle",
......@@ -34,6 +35,7 @@
"Description[uk]": "Додаток libgz для Kerfuffle",
"Description[x-test]": "xxlibgz plugin for Kerfufflexx",
"Description[zh_CN]": "Kerfuffle 的 libgz 插件",
"Description[zh_TW]": "Kerfuffle 的 libgz 外掛程式",
"Id": "kerfuffle_libgz",
"License": "BSD",
"MimeTypes": [
......
......@@ -16,6 +16,7 @@
"Description[ca]": "Connector del libxz pel Kerfuffle",
"Description[cs]": "modul libxz pro Kerfuffle",
"Description[de]": "libxz-Modul für Kerfuffle",
"Description[en_GB]": "libxz plugin for Kerfuffle",
"Description[es]": "Complemento libxz para Kerfuffle",
"Description[fi]": "libxz-pakkaustuki",
"Description[it]": "Estensione libxz per Kerfuffle",
......@@ -34,6 +35,7 @@
"Description[uk]": "Додаток libxz для Kerfuffle",
"Description[x-test]": "xxlibxz plugin for Kerfufflexx",
"Description[zh_CN]": "Kerfuffle 的 libxz 插件",
"Description[zh_TW]": "Kerfuffle 的 libxz 外掛程式",
"Id": "kerfuffle_libxz",
"License": "BSD",
"MimeTypes": [
......
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