Commit d51f0d7b authored by Toni Asensi Esteve's avatar Toni Asensi Esteve
Browse files

Solve the problem of Libreoffice not being launched when the user utilizes the...

Solve the problem of Libreoffice not being launched when the user utilizes the "browse archives as directories" mode and double clicks (or presses Enter) on a .odt file, other cases using other kinds of files. Solve a bug searching inside 7z files.

REVIEW: 127369

There was the problem of Krusader not launching e.g. Libreoffice when the user utilized the "browse archives as directories" mode and double clicked (or pressed Enter) on a .ods file (because it was really a .zip file, as it happened in other cases). The function
    // returns true if the right unpacker exist in the system
    KRarcHandler::arcSupported(QString type)
was improved (it has to be improved anyway) and is used so e.g. an .ods file will not be browsed because KRarcHandler::arcSupported() returns false in the case of an .ods file.

Krusader users, in the "browse archives as directories" mode, were also enabled to browse .odt, .docx, .iso, .ods, .xlsx, etc. files using:
    - in the detailed view: the right arrow key, or the "Browse" action available when pressing the secondary button of the mouse.
    - in the brief view: the "Browse" action available when pressing the secondary button of the mouse.
Note: In the "browse archives as directories" mode the forementioned "Browse" action does not appear in the case of e.g. a zip file because there's already an "Open" action that accomplishes that objective.

With those changes one bug was also solved: if e.g. a 7z archive contains a file named "a.txt", the user opens the search tool of Krusader, he specifies that he wants to search for the file "a.txt", he enables the "Search in archives" checkbox, and he clicks on the "Search button" -> now the "a.txt" file is found inside the 7z archive.

Tests done: Browsed zip, rar, tar, tar.bz2, tar.gz, tar.xz, 7z, odt, docx, iso, ods and xlsx files in Krusader, and opened them externally, using combinations of: the detailed view or the brief view, the right arrow key or the primary button of the mouse (in some cases that action launched an external program) or the secondary button of the mouse (its option "Open" or its option "Browse" when it was available), and having the option "browse archives as directories" enabled or disabled.
parent 351c0fcf
......@@ -43,6 +43,7 @@
#include "../krusaderview.h"
#include "../panelmanager.h"
#include "../krtrashhandler.h"
#include "../VFS/krarchandler.h"
#ifdef __LIBKONQ__
#include <konq_popupmenu.h>
......@@ -110,7 +111,7 @@ KrPopupMenu::KrPopupMenu(KrPanel *thePanel, QWidget *parent) : QMenu(parent), pa
bool ArchivesAsDirectories = KConfigGroup(krConfig, "Archives").readEntry("ArchivesAsDirectories", _ArchivesAsDirectories);
QUrl arcPath = panel->func->browsableArchivePath(vf->vfile_getName());
if (!arcPath.isEmpty() && !ArchivesAsDirectories) {
if (!arcPath.isEmpty() && !(ArchivesAsDirectories && KRarcHandler::arcSupported(vf->vfile_getMime()))) {
QAction *browseAct = addAction(i18n("Browse"));
browseAct->setIcon(krLoader->loadIcon("", KIconLoader::Panel));
......@@ -162,7 +162,7 @@ void ListPanelFunc::openFileNameInternal(const QString &name, bool canExecuteFil
bool ArchivesAsDirectories = KConfigGroup(krConfig, "Archives").readEntry("ArchivesAsDirectories", _ArchivesAsDirectories);
QUrl arcPath = browsableArchivePath(name);
if (!arcPath.isEmpty() && (ArchivesAsDirectories || !canExecuteFile)) {
if (!arcPath.isEmpty() && ((ArchivesAsDirectories && KRarcHandler::arcSupported(mime)) || !canExecuteFile)) {
......@@ -159,11 +159,7 @@ void KRSearchMod::scanLocalDir(QUrl urlToScan)
if (query->searchInArchives()) {
QString type = mime.right(4);
if (mime.contains("-rar")) type = "-rar";
if (mime.endsWith("/zip")) type = "-zip";
if (KRarcHandler::arcSupported(type)) {
if (KRarcHandler::arcSupported(mime)) {
QUrl archiveURL = url;
bool encrypted;
QString realType = arcHandler.getType(encrypted, url.path(), mime);
......@@ -126,7 +126,21 @@ bool KRarcHandler::arcSupported(QString type)
KConfigGroup group(krConfig, "Archives");
QStringList lst = group.readEntry("Supported Packers", QStringList());
if (type == "-zip" && lst.contains("unzip"))
// Normalize the type of the file
if (type.length() > 4) {
// 7zip files are a not a normal case because their mimetype does not
// follow the norm of other types: zip, tar, lha, ace, arj, etc.
if (type == "application/x-7z-compressed")
type = "-7z";
// If it's a rar file but its mimetype isn't "application/x-rar"
if (type == "application/x-rar-compressed")
type = "-rar";
type = type.right(4);
if ((type == "-zip" || type == "/zip") && lst.contains("unzip"))
return true;
else if (type == "-tar" && lst.contains("tar"))
return true;
......@@ -242,7 +242,7 @@ bool KRQuery::checkPerm(QString filePerm) const
bool KRQuery::checkType(QString mime) const
if (type == mime) return true;
if (type == i18n("Archives")) return KRarcHandler::arcSupported(mime.right(4));
if (type == i18n("Archives")) return KRarcHandler::arcSupported(mime);
if (type == i18n("Directories")) return mime.contains("directory");
if (type == i18n("Image Files")) return mime.contains("image/");
if (type == i18n("Text Files")) return mime.contains("text/");
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