diff --git a/CMakeLists.txt b/CMakeLists.txt index a1ffaca7..b3934095 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,124 +1,131 @@ project(krusader) cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) set (QT_MIN_VERSION "5.2.0") set(VERSION "2.5.1-beta" ) set(RELEASE_NAME "Clear Skies") # Manages plugin loading. For more details it can be seen https://www.kde.org/announcements/kde-frameworks-5.5.0.php # https://github.com/KDE/partitionmanager/blob/master/CMakeLists.txt http://commits.kde.org/kimtoy/1e62777affb0e072f3462e80bc271f3cba661104 set(KDE_INSTALL_USE_QT_SYS_PATHS ON CACHE BOOL "Install mkspecs files, Plugins and Imports to the Qt 5 install dir" FORCE) find_package(ECM 1.1.0 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) include(ECMOptionalAddSubdirectory) include(ECMInstallIcons) include(ECMSetupVersion) include(ECMMarkNonGuiExecutable) include(ECMGenerateHeaders) include(GenerateExportHeader) include(CMakePackageConfigHelpers) include(FeatureSummary) include(WriteBasicConfigVersionFile) include(CheckFunctionExists) include(CheckIncludeFiles) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) find_package(Qt5 CONFIG REQUIRED Core Gui DBus Widgets PrintSupport Xml ) # determine kf5 version is at least 5.23 message(STATUS "Searching for KF5KIO version 5.23 or newer...") find_package(KF5 5.23 QUIET COMPONENTS KIO ) if(KF5_FOUND) set(KRARC_QUERY_ENABLED TRUE) add_definitions( "-DKRARC_QUERY_ENABLED" ) else(KF5_FOUND) message(STATUS "KF5KIO version 5.23 or newer not found, some krarc:/ functionality will be disabled.") set(KRARC_QUERY_ENABLED FALSE) endif(KF5_FOUND) find_package(KF5 REQUIRED COMPONENTS Archive Bookmarks Codecs Completion CoreAddons Config DocTools I18n IconThemes ItemViews KIO Notifications Parts Solid TextWidgets Wallet WidgetsAddons WindowSystem XmlGui GuiAddons ) # Synchronizer is enabled by default, unless disabled from the command line (-DENABLE_SYNCHRONIZER=OFF) option(ENABLE_SYNCHRONIZER "Enable Synchronizer" ON) # if an old setting is being used, use the setting that complies with the structure of other Krusader settings if(ENABLE_SYNCHRONIZER) set(SYNCHRONIZER_ENABLED TRUE) add_definitions( "-DSYNCHRONIZER_ENABLED" ) else() set(SYNCHRONIZER_ENABLED FALSE) endif() +# For security reasons, absolute kdesu path is set at build time and is not +# configurable. +if(NOT KDESU_PATH) + set(KDESU_PATH "${KDE_INSTALL_FULL_LIBEXECDIR_KF5}/kdesu") +endif() +add_definitions( -DKDESU_PATH="${KDESU_PATH}" ) + add_definitions(${QT_DEFINITIONS} ${KF5_DEFINITIONS}) add_definitions( "-DKRARC_ENABLED" ) add_definitions( "-DQT_NO_URL_CAST_FROM_STRING" ) check_include_files(attr/libattr.h HAVE_ATTR_LIBATTR_H) check_include_files(sys/xattr.h HAVE_SYS_XATTR_H) check_include_files(sys/acl.h HAVE_SYS_ACL_H) check_include_files(acl/libacl.h HAVE_ACL_LIBACL_H) if (HAVE_ATTR_LIBATTR_H AND HAVE_SYS_XATTR_H AND HAVE_SYS_ACL_H AND HAVE_ACL_LIBACL_H) set(ACL_HEADERS_FOUND TRUE) endif(HAVE_ATTR_LIBATTR_H AND HAVE_SYS_XATTR_H AND HAVE_SYS_ACL_H AND HAVE_ACL_LIBACL_H) if (ACL_HEADERS_FOUND) find_library(ACL_LIBS NAMES acl ) find_library(ATTR_LIBS NAMES attr ) endif(ACL_HEADERS_FOUND) if (ACL_HEADERS_FOUND AND ACL_LIBS AND ATTR_LIBS) set(ACL_FOUND TRUE) set(ACL_LIBS ${ACL_LIBS} ${ATTR_LIBS}) message(STATUS "Found ACL support: ${ACL_LIBS}") add_definitions(-DHAVE_POSIX_ACL) endif(ACL_HEADERS_FOUND AND ACL_LIBS AND ATTR_LIBS) #include(ConfigureChecks.cmake) add_subdirectory(krusader) add_subdirectory(pics) add_subdirectory(doc-extras) add_subdirectory(krArc) add_subdirectory(iso) add_subdirectory(doc) #add_subdirectory(virt) - not used feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/INSTALL b/INSTALL index e3177ca8..670348a4 100644 --- a/INSTALL +++ b/INSTALL @@ -1,338 +1,340 @@ --------------------------------------------------- Krusader installation instructions for KDE Plasma 5 --------------------------------------------------- --- Note Krusader-2.5.0 versions and higher are for KDE Plasma 5 only and will not work anymore on KDE Plasma 4 or 3. --- Supported Platforms * All POSIX (Linux®/BSD/UNIX®-like OSes), Solaris™ At the moment, there are no KDE Plasma 5 ports for Windows or Mac® OS X, which means these platforms are not supported. ======================================== Installation on Linux® and BSD platforms ======================================== --- Krusader dependencies The next packages are needed when running the Krusader binary. This is a list of the package names that Kubuntu/Ubuntu 16.04 use, other Linux distros will probably use similar names: - plasma-framework Plasma Runtime components - libc6 GNU C Library: Shared libraries - libgcc1 GCC support library - libqt5dbus5 Qt 5 D-Bus module - libqt5xml5 Qt 5 XML module - libqt5core5 Qt 5 core module - libqt5gui5 Qt 5 GUI module - libqt5printsupport5 Qt 5 print support module - libstdc++6 The GNU Standard C++ Library v3 - zlib1g compression library - runtime --- Suggested packages The next packages are optional but they will make Krusader much more powerful and useful. This is a list of the package names that Debian/Ubuntu/Kubuntu 16.04 use, other Linux distros will probably use similar names: - arj archiver for .arj files - ark archive utility for KDE - bzip2 high-quality block-sorting file compressor - utilities - cpio GNU cpio -- a program to manage archives of files - kate Powerful Text Editor -- kde-cli-tools allows editing file types from Properties dialog - -- kdesu graphical sudo tool, required to run Krusader in root -or kdesudo mode +- kde-cli-tools tools required to edit file types from Properties dialog + or run Krusader in root mode - kio-extras Enables transparent handling of various archive types such as .tar and network protocols like SFTP - kmail KDE Email client - kdiff3 compares and merges 2 or 3 files or directories (at moment of writing: no version available) or kompare file difference viewer or xxdiff a graphical file and directories comparison and merge tool - konsole X terminal emulator - krename Powerful batch renamer for KDE (at moment of writing: still based on KDE4) - lhasa lzh archiver - md5deep enhanced message digest calculator or cfv versatile file checksum creator and verifier - p7zip 7zr file archiver with high compression ratio - rpm Red Hat package manager - unace extract, test and view .ace archives - unrar Unarchiver for .rar files (non-free version) or unrar-free Unarchiver for .rar files or rar Archiver for .rar files - unzip De-archiver for .zip files - zip Archiver for .zip files --- Compilation requirements The next packages are needed for compiling the Krusader sourcecode, if you only run the Krusader binary you don't need to install these packages. - build-essential a group of packages needed to compile source code - cmake a cross-platform, open-source make system - extra-cmake-modules extra cmake modules for compiling KDE Frameworks - qt5-default development files for the Qt5 libraries - gettext GNU Internationalization utilities - plasma-framework-dev development files for plasma-framework The following packages should install (through dependencies) all the packages you need to compile a KDE 5 software - kio-dev resource and network access abstraction - libkf5archive-dev development files for karchive - libkf5parts-dev development files for kparts - libkf5wallet-dev development files for kwallet-framework - libkf5xmlgui-dev user configurable main windows - kdoctools-dev development files for kdoctools5 --- Krusader development download Krusader is developed in KDE Extragear. If someone wants to download and use the latest available Krusader sourcecode with git: $ git clone http://anongit.kde.org/krusader Otherwise, if someone wants to use a .tar.gz version: $ tar xvf krusader-xx.xx.tar.gz --- Some CMake options. Cmake execution -DCMAKE_INSTALL_PREFIX=/usr is the location where Krusader will be installed with the make command. Another example is: -DCMAKE_INSTALL_PRFIX=/opt/krusader to install the compiled Krusader in an other directory to not overwrite the Krusader version installed by your package manager. -DCMAKE_CXX_FLAGS="-O2 -fPIC" this flag is required if you have a 64 bit system -DQT_PLUGIN_INSTALL_DIR= many system force this path to keep kde4 plugins separated from the kde5 ones +-DKDESU_PATH=/foo/bar/kdesu + this needs to be set on distributions that override default kdesu installation + path (libexec/kf5/kdesu) or if your install prefix doesn't match KDE's. + -DENABLE_SYNCHRONIZER=OFF disables building the Synchronizer module. This module caused data loss, now it is fixed, but we treat it as the thin ice. CMake may be executed this way: $ mkdir krusader-build $ cd krusader-build $ cmake ../krusader -DCMAKE_INSTALL_PREFIX=/usr/ -DCMAKE_C_FLAGS="-O2 -fPIC" -DCMAKE_CXX_FLAGS="-O2 -fPIC" Note: In this document there's an appendix 1 that may help. --- Compilation and installation Compilation will take about 5 to 10 minutes depending on your CPU speed. Execute: # Note: On a multi cpu/core system you might want to speed up the compile process by increasing the number of jobs (e.g. `make -j4`) $ make # At the beginning of the following command: `sudo` must be added if Kubuntu, Ubuntu, Debian, or similar is being used $ su -c "make install" Note: In this document there's an appendix 2 that may help. --- To achieve that Krusader uses another language There is a list of translation files in the [10n.kde.org Krusader page](https://l10n.kde.org/stats/gui/trunk-kf5/po/krusader.po/index.html). In that list anyone can look for his desired translation file, hover the mouse cursor over its link, see its tooltip to look up the appropriate LANGUAGE_CODE (which is shown between parentheses, e.g. if on the tooltip it's seen "German (de)" that means that LANGUAGE_CODE is: de), click on the link (in order to download the proper krusader.po file), and execute: # Transform the downloaded file msgfmt krusader.po -o krusader.mo # At the beginning of the following command: `sudo` must be added if Kubuntu, Ubuntu, Debian, or similar is being used. # In the following command, the text XXXXXXX must be replaced by the LANGUAGE_CODE that was previously found su -c "cp -a krusader.mo /usr/share/locale/XXXXXXX/LC_MESSAGES/" Note: If, in the future, someone would need to automate the downloading of a krusader.po file, he could use: # In the following command, the text XXXXXXX must be replaced by the LANGUAGE_CODE that was previously found $ wget -U "Mozilla/5.0" https://websvn.kde.org/*checkout*/trunk/l10n-kf5/XXXXXXX/messages/extragear-utils/krusader.po --- Execution Finally, Krusader can be executed this way: $ krusader --- Uninstall # At the beginning of the following command: `sudo` must be added if Kubuntu, Ubuntu, Debian, or similar is being used $ su -c "make uninstall" --- Appendix 1 If it can be useful, this is the output of cmake on Kubuntu 15.04: ubuntu@ubuntu-VirtualBox:~/src/krusader/build$ cmake -DCMAKE_INSTALL_PREFIX=/usr .. -- The C compiler identification is GNU 4.9.2 -- The CXX compiler identification is GNU 4.9.2 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Looking for __GLIBC__ -- Looking for __GLIBC__ - found -- Performing Test _OFFT_IS_64BIT -- Performing Test _OFFT_IS_64BIT - Success -- Found KF5Archive: /usr/lib/x86_64-linux-gnu/cmake/KF5Archive/KF5ArchiveConfig.cmake (found version "5.9.0") -- Found KF5Bookmarks: /usr/lib/x86_64-linux-gnu/cmake/KF5Bookmarks/KF5BookmarksConfig.cmake (found version "5.9.0") -- Found KF5Codecs: /usr/lib/x86_64-linux-gnu/cmake/KF5Codecs/KF5CodecsConfig.cmake (found version "5.9.0") -- Found KF5Completion: /usr/lib/x86_64-linux-gnu/cmake/KF5Completion/KF5CompletionConfig.cmake (found version "5.9.0") -- Found KF5CoreAddons: /usr/lib/x86_64-linux-gnu/cmake/KF5CoreAddons/KF5CoreAddonsConfig.cmake (found version "5.9.0") -- Found KF5Config: /usr/lib/x86_64-linux-gnu/cmake/KF5Config/KF5ConfigConfig.cmake (found version "5.9.0") -- Found KF5DocTools: /usr/lib/x86_64-linux-gnu/cmake/KF5DocTools/KF5DocToolsConfig.cmake (found version "5.9.0") -- Found Gettext: /usr/bin/msgmerge (found version "0.19.2") -- Found PythonInterp: /usr/bin/python (found version "2.7.9") -- Found KF5I18n: /usr/lib/x86_64-linux-gnu/cmake/KF5I18n/KF5I18nConfig.cmake (found version "5.9.0") -- Found KF5IconThemes: /usr/lib/x86_64-linux-gnu/cmake/KF5IconThemes/KF5IconThemesConfig.cmake (found version "5.9.0") -- Found KF5ItemViews: /usr/lib/x86_64-linux-gnu/cmake/KF5ItemViews/KF5ItemViewsConfig.cmake (found version "5.9.0") -- Found KF5KIO: /usr/lib/x86_64-linux-gnu/cmake/KF5KIO/KF5KIOConfig.cmake (found version "5.9.0") -- Found KF5Notifications: /usr/lib/x86_64-linux-gnu/cmake/KF5Notifications/KF5NotificationsConfig.cmake (found version "5.9.0") -- Found KF5Parts: /usr/lib/x86_64-linux-gnu/cmake/KF5Parts/KF5PartsConfig.cmake (found version "5.9.0") -- Found KF5Solid: /usr/lib/x86_64-linux-gnu/cmake/KF5Solid/KF5SolidConfig.cmake (found version "5.9.0") -- Found KF5TextWidgets: /usr/lib/x86_64-linux-gnu/cmake/KF5TextWidgets/KF5TextWidgetsConfig.cmake (found version "5.9.0") -- Found KF5Wallet: /usr/lib/x86_64-linux-gnu/cmake/KF5Wallet/KF5WalletConfig.cmake (found version "5.9.0") -- Found KF5WidgetsAddons: /usr/lib/x86_64-linux-gnu/cmake/KF5WidgetsAddons/KF5WidgetsAddonsConfig.cmake (found version "5.9.0") -- Found KF5WindowSystem: /usr/lib/x86_64-linux-gnu/cmake/KF5WindowSystem/KF5WindowSystemConfig.cmake (found version "5.9.0") -- Found KF5XmlGui: /usr/lib/x86_64-linux-gnu/cmake/KF5XmlGui/KF5XmlGuiConfig.cmake (found version "5.9.0") -- Found KF5: success (found version "5.9.0") found components: Archive Bookmarks Codecs Completion CoreAddons Config DocTools I18n IconThemes ItemViews KIO Notifications Parts Solid TextWidgets Wallet WidgetsAddons WindowSystem XmlGui -- Looking for include file attr/libattr.h -- Looking for include file attr/libattr.h - found -- Looking for include file sys/xattr.h -- Looking for include file sys/xattr.h - found -- Looking for include file sys/acl.h -- Looking for include file sys/acl.h - found -- Looking for include file acl/libacl.h -- Looking for include file acl/libacl.h - found -- Found ACL support: /usr/lib/libacl.so;/lib/x86_64-linux-gnu/libattr.so -- libkonq library not found -- /home/ubuntu/src/krusader/krusader: skipped subdir $(KRJSDIR) -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8") -- -- The following REQUIRED packages have been found: * ECM (required version >= 1.1.0) * Qt5Core * Qt5Gui * Qt5DBus * Qt5Widgets * Qt5PrintSupport * Qt5Xml * Qt5 * KF5Archive * KF5Bookmarks * KF5Codecs * KF5Completion * KF5CoreAddons * KF5Config * KF5DocTools * Gettext * PythonInterp * KF5I18n * KF5IconThemes * KF5ItemViews * KF5KIO * KF5Notifications * KF5Parts * KF5Solid * KF5TextWidgets * KF5Wallet * KF5WidgetsAddons * KF5WindowSystem * KF5XmlGui * KF5 -- Configuring done -- Generating done -- Build files have been written to: /home/ubuntu/src/krusader/build --- Appendix 2 If it can be useful, this is a (partial) output of make on Kubuntu 15.04: ubuntu@ubuntu-VirtualBox:~/src/krusader/build$ make [ 1%] Automatic moc for target krusader Generating moc_actionsbase.cpp Generating moc_kractions.cpp Generating moc_krslots.cpp Generating moc_krtrashhandler.cpp Generating moc_krusader.cpp Generating moc_krusaderview.cpp Generating moc_panelmanager.cpp Generating moc_paneltabbar.cpp Generating moc_tabactions.cpp [ 1%] Built target krusader_automoc [ 1%] Automatic moc for target ActionMan Generating moc_actionman.cpp Generating moc_actionproperty.cpp Generating moc_addplaceholderpopup.cpp Generating moc_useractionlistview.cpp Generating moc_useractionpage.cpp [ 1%] Built target ActionMan_automoc [ 1%] Generating ui_actionproperty.h Scanning dependencies of target ActionMan [ 1%] Building CXX object krusader/ActionMan/CMakeFiles/ActionMan.dir/actionman.cpp.o [ 2%] Building CXX object krusader/ActionMan/CMakeFiles/ActionMan.dir/actionproperty.cpp.o ... ... ... [ 95%] Built target kio_krarc Scanning dependencies of target kio_iso_automoc [ 95%] Automatic moc for target kio_iso [ 95%] Built target kio_iso_automoc Scanning dependencies of target kio_iso [ 96%] Building CXX object iso/CMakeFiles/kio_iso.dir/kisodirectory.cpp.o [ 96%] Building CXX object iso/CMakeFiles/kio_iso.dir/kisofile.cpp.o [ 97%] Building CXX object iso/CMakeFiles/kio_iso.dir/qfilehack.cpp.o [ 97%] Building CXX object iso/CMakeFiles/kio_iso.dir/kiso.cpp.o [ 98%] Building CXX object iso/CMakeFiles/kio_iso.dir/iso.cpp.o [ 98%] Building C object iso/CMakeFiles/kio_iso.dir/libisofs/isofs.c.o [ 99%] Building CXX object iso/CMakeFiles/kio_iso.dir/kio_iso_automoc.cpp.o Linking CXX shared library libkio_iso.so [ 99%] Built target kio_iso Scanning dependencies of target doc-index-cache-bz2 [100%] Generating index.cache.bz2 [100%] Built target doc-index-cache-bz2 Scanning dependencies of target doc-krusader-1 [100%] Generating krusader.1 Note: Writing krusader.1 [100%] Built target doc-krusader-1 diff --git a/krusader/Konfigurator/kgdependencies.cpp b/krusader/Konfigurator/kgdependencies.cpp index 7a15d305..2eeb10a9 100644 --- a/krusader/Konfigurator/kgdependencies.cpp +++ b/krusader/Konfigurator/kgdependencies.cpp @@ -1,187 +1,185 @@ /*************************************************************************** kgdependencies.cpp - description ------------------- copyright : (C) 2004 by Csaba Karai e-mail : krusader@users.sourceforge.net web site : http://krusader.sourceforge.net --------------------------------------------------------------------------- Description *************************************************************************** A db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD S o u r c e F i l e *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "kgdependencies.h" #include "../krservices.h" #include "../krglobal.h" // QtCore #include // QtWidgets #include #include #include #include #include #include #define PAGE_GENERAL 0 #define PAGE_PACKERS 1 #define PAGE_CHECKSUM 2 KgDependencies::KgDependencies(bool first, QWidget* parent) : KonfiguratorPage(first, parent) { QGridLayout *kgDependenciesLayout = new QGridLayout(this); kgDependenciesLayout->setSpacing(6); // ---------------------------- GENERAL TAB ------------------------------------- tabWidget = new QTabWidget(this); QWidget *general_tab = new QWidget(tabWidget); QScrollArea* general_scroll = new QScrollArea(tabWidget); general_scroll->setFrameStyle(QFrame::NoFrame); general_scroll->setWidget(general_tab); // this also sets scrollacrea as the new parent for widget general_scroll->setWidgetResizable(true); // let the widget use every space available tabWidget->addTab(general_scroll, i18n("General")); QGridLayout *pathsGrid = new QGridLayout(general_tab); pathsGrid->setSpacing(6); pathsGrid->setContentsMargins(11, 11, 11, 11); pathsGrid->setAlignment(Qt::AlignTop); - addApplication("kdesu", pathsGrid, 0, general_tab, PAGE_GENERAL); - addApplication("kget", pathsGrid, 1, general_tab, PAGE_GENERAL); - addApplication("mailer", pathsGrid, 2, general_tab, PAGE_GENERAL); - addApplication("diff utility", pathsGrid, 3, general_tab, PAGE_GENERAL); - addApplication("krename", pathsGrid, 4, general_tab, PAGE_GENERAL); - addApplication("krusader", pathsGrid, 5, general_tab, PAGE_GENERAL); - addApplication("locate", pathsGrid, 6, general_tab, PAGE_GENERAL); - addApplication("mount", pathsGrid, 7, general_tab, PAGE_GENERAL); - addApplication("umount", pathsGrid, 8, general_tab, PAGE_GENERAL); - addApplication("updatedb", pathsGrid, 9, general_tab, PAGE_GENERAL); + addApplication("kget", pathsGrid, 0, general_tab, PAGE_GENERAL); + addApplication("mailer", pathsGrid, 1, general_tab, PAGE_GENERAL); + addApplication("diff utility", pathsGrid, 2, general_tab, PAGE_GENERAL); + addApplication("krename", pathsGrid, 3, general_tab, PAGE_GENERAL); + addApplication("krusader", pathsGrid, 4, general_tab, PAGE_GENERAL); + addApplication("locate", pathsGrid, 5, general_tab, PAGE_GENERAL); + addApplication("mount", pathsGrid, 6, general_tab, PAGE_GENERAL); + addApplication("umount", pathsGrid, 7, general_tab, PAGE_GENERAL); + addApplication("updatedb", pathsGrid, 8, general_tab, PAGE_GENERAL); // ---------------------------- PACKERS TAB ------------------------------------- QWidget *packers_tab = new QWidget(tabWidget); QScrollArea* packers_scroll = new QScrollArea(tabWidget); packers_scroll->setFrameStyle(QFrame::NoFrame); packers_scroll->setWidget(packers_tab); // this also sets scrollacrea as the new parent for widget packers_scroll->setWidgetResizable(true); // let the widget use every space available tabWidget->addTab(packers_scroll, i18n("Packers")); QGridLayout *archGrid1 = new QGridLayout(packers_tab); archGrid1->setSpacing(6); archGrid1->setContentsMargins(11, 11, 11, 11); archGrid1->setAlignment(Qt::AlignTop); addApplication("7z", archGrid1, 0, packers_tab, PAGE_PACKERS, "7za"); addApplication("arj", archGrid1, 1, packers_tab, PAGE_PACKERS); addApplication("bzip2", archGrid1, 2, packers_tab, PAGE_PACKERS); addApplication("cpio", archGrid1, 3, packers_tab, PAGE_PACKERS); addApplication("dpkg", archGrid1, 4, packers_tab, PAGE_PACKERS); addApplication("gzip", archGrid1, 5, packers_tab, PAGE_PACKERS); addApplication("lha", archGrid1, 6, packers_tab, PAGE_PACKERS); addApplication("lzma", archGrid1, 7, packers_tab, PAGE_PACKERS); addApplication("rar", archGrid1, 8, packers_tab, PAGE_PACKERS); addApplication("tar", archGrid1, 9, packers_tab, PAGE_PACKERS); addApplication("unace", archGrid1, 10, packers_tab, PAGE_PACKERS); addApplication("unarj", archGrid1, 11, packers_tab, PAGE_PACKERS); addApplication("unrar", archGrid1, 12, packers_tab, PAGE_PACKERS); addApplication("unzip", archGrid1, 13, packers_tab, PAGE_PACKERS); addApplication("zip", archGrid1, 14, packers_tab, PAGE_PACKERS); addApplication("xz", archGrid1, 15, packers_tab, PAGE_PACKERS); // ---------------------------- CHECKSUM TAB ------------------------------------- QWidget *checksum_tab = new QWidget(tabWidget); QScrollArea* checksum_scroll = new QScrollArea(tabWidget); checksum_scroll->setFrameStyle(QFrame::NoFrame); checksum_scroll->setWidget(checksum_tab); // this also sets scrollacrea as the new parent for widget checksum_scroll->setWidgetResizable(true); // let the widget use every space available tabWidget->addTab(checksum_scroll, i18n("Checksum Utilities")); QGridLayout *archGrid2 = new QGridLayout(checksum_tab); archGrid2->setSpacing(6); archGrid2->setContentsMargins(11, 11, 11, 11); archGrid2->setAlignment(Qt::AlignTop); addApplication("md5sum", archGrid2, 0, checksum_tab, PAGE_CHECKSUM); addApplication("sha1sum", archGrid2, 1, checksum_tab, PAGE_CHECKSUM); addApplication("sha224sum", archGrid2, 2, checksum_tab, PAGE_CHECKSUM); addApplication("sha256sum", archGrid2, 3, checksum_tab, PAGE_CHECKSUM); addApplication("sha384sum", archGrid2, 4, checksum_tab, PAGE_CHECKSUM); addApplication("sha512sum", archGrid2, 5, checksum_tab, PAGE_CHECKSUM); addApplication("md5deep", archGrid2, 6, checksum_tab, PAGE_CHECKSUM); addApplication("sha1deep", archGrid2, 7, checksum_tab, PAGE_CHECKSUM); addApplication("sha256deep", archGrid2, 8, checksum_tab, PAGE_CHECKSUM); addApplication("tigerdeep", archGrid2, 9, checksum_tab, PAGE_CHECKSUM); addApplication("whirlpooldeep", archGrid2, 10, checksum_tab, PAGE_CHECKSUM); addApplication("cfv", archGrid2, 11, checksum_tab, PAGE_CHECKSUM); kgDependenciesLayout->addWidget(tabWidget, 0, 0); } void KgDependencies::addApplication(QString name, QGridLayout *grid, int row, QWidget *parent, int page, QString additionalList) { QString dflt = KrServices::fullPathName(name); /* try to autodetect the full path name */ if (dflt.isEmpty()) { QStringList list = additionalList.split(',', QString::SkipEmptyParts); for (int i = 0; i != list.count(); i++) if (!KrServices::fullPathName(list[ i ]).isEmpty()) { dflt = KrServices::fullPathName(list[ i ]); break; } } addLabel(grid, row, 0, name, parent); KonfiguratorURLRequester *fullPath = createURLRequester("Dependencies", name, dflt, parent, false, page); connect(fullPath->extension(), SIGNAL(applyManually(QObject *, QString, QString)), this, SLOT(slotApply(QObject *, QString, QString))); grid->addWidget(fullPath, row, 1); } void KgDependencies::slotApply(QObject *obj, QString cls, QString name) { KonfiguratorURLRequester *urlRequester = (KonfiguratorURLRequester *) obj; KConfigGroup group(krConfig, cls); group.writeEntry(name, urlRequester->url().toDisplayString(QUrl::PreferLocalFile)); QString usedPath = KrServices::fullPathName(name); if (urlRequester->url().toDisplayString(QUrl::PreferLocalFile) != usedPath) { group.writeEntry(name, usedPath); if (usedPath.isEmpty()) KMessageBox::error(this, i18n("The %1 path is incorrect, no valid path found.", urlRequester->url().toDisplayString(QUrl::PreferLocalFile))); else KMessageBox::error(this, i18n("The %1 path is incorrect, %2 used instead.", urlRequester->url().toDisplayString(QUrl::PreferLocalFile), usedPath)); urlRequester->setUrl(QUrl::fromLocalFile(usedPath)); } } int KgDependencies::activeSubPage() { return tabWidget->currentIndex(); } - diff --git a/krusader/Konfigurator/krresulttable.cpp b/krusader/Konfigurator/krresulttable.cpp index 85158e75..0f1727d4 100644 --- a/krusader/Konfigurator/krresulttable.cpp +++ b/krusader/Konfigurator/krresulttable.cpp @@ -1,419 +1,413 @@ /***************************************************************************** * Copyright (C) 2005 Dirk Eschler * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This package is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this package; if not, write to the Free Software * * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ #include "krresulttable.h" #include // QtCore #include // QtGui #include #include // QtWidgets #include #include #include #include "../krservices.h" #include "../Archive/krarchandler.h" using namespace std; #define PS(x) _supported.contains(x)>0 KrResultTable::KrResultTable(QWidget* parent) : QWidget(parent), _numRows(1) { } KrResultTable::~KrResultTable() { } QGridLayout* KrResultTable::initTable() { _grid = new QGridLayout(this); _grid->setColumnStretch(_numColumns - 1, 1); // stretch last column _grid->setContentsMargins(0, 0, 0, 0); _grid->setSpacing(0); // +++ Build and add table header +++ int column = 0; for (QStringList::Iterator it = _tableHeaders.begin(); it != _tableHeaders.end(); ++it) { _label = new QLabel(*it, this); _label->setContentsMargins(5, 5, 5, 5); _grid->addWidget(_label, 0, column); // Set font QFont defFont = QFontDatabase::systemFont(QFontDatabase::GeneralFont); defFont.setPointSize(defFont.pointSize() - 1); defFont.setBold(true); _label->setFont(defFont); ++column; } return _grid; } void KrResultTable::adjustRow(QGridLayout* grid) { int i = 0; QLayoutItem *child; int col = 0; while ((child = grid->itemAt(i)) != 0) { // Add some space between columns child->widget()->setMinimumWidth(child->widget()->sizeHint().width() + 15); // Paint uneven rows in alternate color if (((col / _numColumns) % 2)) { child->widget()->setAutoFillBackground(true); QPalette p = QGuiApplication::palette(); QPalette pal = child->widget()->palette(); pal.setColor(child->widget()->backgroundRole(), p.color(QPalette::Active, QPalette::AlternateBase)); child->widget()->setPalette(pal); } ++i; ++col; } } // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- KrArchiverResultTable::KrArchiverResultTable(QWidget* parent) : KrResultTable(parent) { _supported = KRarcHandler::supportedPackers(); // get list of available packers Archiver* tar = new Archiver("tar", "http://www.gnu.org", PS("tar"), true, true); Archiver* gzip = new Archiver("gzip", "http://www.gnu.org", PS("gzip"), true, true); Archiver* bzip2 = new Archiver("bzip2", "http://www.gnu.org", PS("bzip2"), true, true); Archiver* lzma = new Archiver("lzma", "http://tukaani.org/lzma", PS("lzma"), true, true); Archiver* xz = new Archiver("xz", "http://tukaani.org/xz", PS("xz"), true, true); Archiver* lha = new Archiver("lha", "http://www.gnu.org", PS("lha"), true, true); Archiver* zip = new Archiver("zip", "http://www.info-zip.org", PS("zip"), true, false); Archiver* unzip = new Archiver("unzip", "http://www.info-zip.org", PS("unzip"), false, true); Archiver* arj = new Archiver("arj", "http://www.arjsoftware.com", PS("arj"), true, true); Archiver* unarj = new Archiver("unarj", "http://www.arjsoftware.com", PS("unarj"), false, true); Archiver* unace = new Archiver("unace", "http://www.winace.com", PS("unace"), false, true); Archiver* rar = new Archiver("rar", "http://www.rarsoft.com", PS("rar"), true, true); Archiver* unrar = new Archiver("unrar", "http://www.rarsoft.com", PS("unrar"), false, true); Archiver* rpm = new Archiver("rpm", "http://www.gnu.org", PS("rpm"), false, true); Archiver* dpkg = new Archiver("dpkg", "http://www.dpkg.org", PS("dpkg"), false, true); Archiver* _7z = new Archiver("7z", "http://www.7-zip.org", PS("7z"), true, true); // Special case: arj can unpack, but unarj is preferred if (PS("arj") && PS("unarj")) arj->setIsUnpacker(false); if (PS("arj") && !PS("unarj")) unarj->setNote(i18n("unarj not found, but arj found, which will be used for unpacking")); // Special case: rar can unpack, but unrar is preferred if (PS("rar") && PS("unrar")) rar->setIsUnpacker(false); // Special case: rpm needs cpio for unpacking if (PS("rpm") && !PS("cpio")) rpm->setNote(i18n("rpm found, but cpio not found which is required for unpacking")); _tableHeaders.append(i18n("Name")); _tableHeaders.append(i18n("Found")); _tableHeaders.append(i18n("Packing")); _tableHeaders.append(i18n("Unpacking")); _tableHeaders.append(i18n("Note")); _numColumns = _tableHeaders.size(); _grid = initTable(); addRow(tar, _grid); addRow(gzip, _grid); addRow(bzip2, _grid); addRow(lzma, _grid); addRow(xz, _grid); addRow(lha, _grid); addRow(zip, _grid); addRow(unzip, _grid); addRow(arj, _grid); addRow(unarj, _grid); addRow(unace, _grid); addRow(rar, _grid); addRow(unrar, _grid); addRow(rpm, _grid); addRow(dpkg, _grid); addRow(_7z, _grid); delete tar; delete gzip; delete bzip2; delete lzma; delete xz; delete lha; delete zip; delete unzip; delete arj; delete unarj; delete unace; delete rar; delete unrar; delete rpm; delete dpkg; delete _7z; } KrArchiverResultTable::~KrArchiverResultTable() { } bool KrArchiverResultTable::addRow(SearchObject* search, QGridLayout* grid) { Archiver* arch = dynamic_cast(search); // Name column _label = new KUrlLabel(arch->getWebsite(), arch->getSearchName(), this); _label->setContentsMargins(5, 5, 5, 5); _label->setAlignment(Qt::AlignTop); grid->addWidget(_label, _numRows, 0); connect(_label, SIGNAL(leftClickedUrl(const QString&)), SLOT(website(const QString&))); // Found column _label = new QLabel(arch->getPath(), this); _label->setContentsMargins(5, 5, 5, 5); grid->addWidget(_label, _numRows, 1); // Packing column _label = new QLabel(this); _label->setContentsMargins(5, 5, 5, 5); _label->setAlignment(Qt::AlignTop); if (arch->getIsPacker() && arch->getFound()) { _label->setText(i18n("enabled")); QPalette pal = _label->palette(); pal.setColor(_label->foregroundRole(), "darkgreen"); _label->setPalette(pal); } else if (arch->getIsPacker() && !arch->getFound()) { _label->setText(i18n("disabled")); QPalette pal = _label->palette(); pal.setColor(_label->foregroundRole(), "red"); _label->setPalette(pal); } else _label->setText(""); grid->addWidget(_label, _numRows, 2); // Unpacking column _label = new QLabel(this); _label->setContentsMargins(5, 5, 5, 5); _label->setAlignment(Qt::AlignTop); if (arch->getIsUnpacker() && arch->getFound()) { _label->setText(i18n("enabled")); QPalette pal = _label->palette(); pal.setColor(_label->foregroundRole(), "darkgreen"); _label->setPalette(pal); } else if (arch->getIsUnpacker() && !arch->getFound()) { _label->setText(i18n("disabled")); QPalette pal = _label->palette(); pal.setColor(_label->foregroundRole(), "red"); _label->setPalette(pal); } else _label->setText(""); grid->addWidget(_label, _numRows, 3); // Note column _label = new QLabel(arch->getNote(), this); _label->setContentsMargins(5, 5, 5, 5); _label->setAlignment(Qt::AlignTop); _label->setWordWrap(true); // wrap words grid->addWidget(_label, _numRows, 4); // Apply shared design elements adjustRow(_grid); // Ensure the last column takes more space _label->setMinimumWidth(300); ++_numRows; return true; } void KrArchiverResultTable::website(const QString& url) { (void) new KRun(QUrl(url), this); } // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- KrToolResultTable::KrToolResultTable(QWidget* parent) : KrResultTable(parent) { _supported = KrServices::supportedTools(); // get list of available tools - QList vecDiff, vecMail, vecRename, vecSudo, vecChecksum; + QList vecDiff, vecMail, vecRename, vecChecksum; Application* kdiff3 = new Application("kdiff3", "http://kdiff3.sourceforge.net/", KrServices::cmdExist("kdiff3")); Application* kompare = new Application("kompare", "http://www.caffeinated.me.uk/kompare/", KrServices::cmdExist("kompare")); Application* xxdiff = new Application("xxdiff", "http://xxdiff.sourceforge.net/", KrServices::cmdExist("xxdiff")); Application* thunderbird = new Application("thunderbird", "http://www.mozilla.org/", KrServices::cmdExist("thunderbird")); Application* kmail = new Application("kmail", "http://kmail.kde.org/", KrServices::cmdExist("kmail")); Application* krename = new Application("krename", "http://www.krename.net/", KrServices::cmdExist("krename")); - Application* kdesu = new Application("kdesu", "https://docs.kde.org/stable5/en/kde-workspace/kdesu/", KrServices::cmdExist("kdesu")); Application* md5sum = new Application("md5sum", "http://www.gnu.org/software/textutils/textutils.html", KrServices::cmdExist("md5sum")); Application* md5deep = new Application("md5deep", "http://md5deep.sourceforge.net/", KrServices::cmdExist("md5deep")); Application* sha1deep = new Application("sha1deep", "http://md5deep.sourceforge.net/", KrServices::cmdExist("sha1deep")); Application* sha256deep = new Application("sha256deep", "http://md5deep.sourceforge.net/", KrServices::cmdExist("sha256deep")); Application* tigerdeep = new Application("tigerdeep", "http://md5deep.sourceforge.net/", KrServices::cmdExist("tigerdeep")); Application* whirlpooldeep = new Application("whirlpooldeep", "http://md5deep.sourceforge.net/", KrServices::cmdExist("whirlpooldeep")); Application* cfv = new Application("cfv", "http://cfv.sourceforge.net/", KrServices::cmdExist("cfv")); vecDiff.push_back(kdiff3); vecDiff.push_back(kompare); vecDiff.push_back(xxdiff); vecMail.push_back(thunderbird); vecMail.push_back(kmail); vecRename.push_back(krename); - vecSudo.push_back(kdesu); vecChecksum.push_back(md5sum); vecChecksum.push_back(md5deep); vecChecksum.push_back(sha1deep); vecChecksum.push_back(sha256deep); vecChecksum.push_back(tigerdeep); vecChecksum.push_back(whirlpooldeep); vecChecksum.push_back(cfv); ApplicationGroup* diff = new ApplicationGroup(i18n("diff utility"), PS("DIFF"), vecDiff); ApplicationGroup* mail = new ApplicationGroup(i18n("email client"), PS("MAIL"), vecMail); ApplicationGroup* rename = new ApplicationGroup(i18n("batch renamer"), PS("RENAME"), vecRename); - ApplicationGroup* sudo = new ApplicationGroup(i18n("graphical sudo"), PS("KDESU"), vecSudo); ApplicationGroup* checksum = new ApplicationGroup(i18n("checksum utility"), PS("MD5"), vecChecksum); _tableHeaders.append(i18n("Group")); _tableHeaders.append(i18n("Tool")); _tableHeaders.append(i18n("Found")); _tableHeaders.append(i18n("Status")); _numColumns = _tableHeaders.size(); _grid = initTable(); addRow(diff, _grid); addRow(mail, _grid); addRow(rename, _grid); - addRow(sudo, _grid); addRow(checksum, _grid); delete thunderbird; delete kmail; delete kompare; delete kdiff3; delete xxdiff; delete krename; - delete kdesu; delete md5sum; delete md5deep; delete sha1deep; delete sha256deep; delete tigerdeep; delete whirlpooldeep; delete cfv; delete diff; delete mail; delete rename; - delete sudo; delete checksum; } KrToolResultTable::~KrToolResultTable() { } bool KrToolResultTable::addRow(SearchObject* search, QGridLayout* grid) { ApplicationGroup* appGroup = dynamic_cast(search); QList _apps = appGroup->getAppVec(); // Name column _label = new QLabel(appGroup->getSearchName(), this); _label->setContentsMargins(5, 5, 5, 5); _label->setAlignment(Qt::AlignTop); grid->addWidget(_label, _numRows, 0); // Tool column QWidget* toolBoxWidget = new QWidget(this); QVBoxLayout * toolBox = new QVBoxLayout(toolBoxWidget); for (QList::Iterator it = _apps.begin(); it != _apps.end(); ++it) { KUrlLabel* l = new KUrlLabel((*it)->getWebsite(), (*it)->getAppName(), toolBoxWidget); toolBox->addWidget(l); l->setAlignment(Qt::AlignLeft | Qt::AlignTop); l->setContentsMargins(5, 5, 5, 5); connect(l, SIGNAL(leftClickedUrl(const QString&)), SLOT(website(const QString&))); } grid->addWidget(toolBoxWidget, _numRows, 1); // Found column QWidget* vboxWidget = new QWidget(this); QVBoxLayout * vbox = new QVBoxLayout(vboxWidget); for (QList::Iterator it = _apps.begin(); it != _apps.end(); ++it) { _label = new QLabel((*it)->getPath(), vboxWidget); _label->setContentsMargins(5, 5, 5, 5); _label->setAlignment(Qt::AlignTop); vbox->addWidget(_label); } grid->addWidget(vboxWidget, _numRows, 2); // Status column _label = new QLabel(this); _label->setContentsMargins(5, 5, 5, 5); _label->setAlignment(Qt::AlignTop); if (appGroup->getFoundGroup()) { _label->setText(i18n("enabled")); QPalette pal = _label->palette(); pal.setColor(_label->foregroundRole(), "darkgreen"); _label->setPalette(pal); } else { _label->setText(i18n("disabled")); QPalette pal = _label->palette(); pal.setColor(_label->foregroundRole(), "red"); _label->setPalette(pal); } grid->addWidget(_label, _numRows, 3); // Apply shared design elements adjustRow(_grid); // Ensure the last column takes more space _label->setMinimumWidth(300); ++_numRows; return true; } void KrToolResultTable::website(const QString& url) { (void) new KRun(QUrl(url), this); } diff --git a/krusader/krservices.cpp b/krusader/krservices.cpp index 2682c637..ee8b8e4f 100644 --- a/krusader/krservices.cpp +++ b/krusader/krservices.cpp @@ -1,295 +1,296 @@ /***************************************************************************** * Copyright (C) 2002 Shie Erlich * * Copyright (C) 2002 Rafi Yanai * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This package is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this package; if not, write to the Free Software * * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ #include "krservices.h" // QtCore #include #include #include #include #include "krglobal.h" #include "defaults.h" QMap* KrServices::slaveMap = 0; QSet KrServices::krarcArchiveMimetypes = KrServices::generateKrarcArchiveMimetypes(); #ifdef KRARC_QUERY_ENABLED QSet KrServices::isoArchiveMimetypes = QSet::fromList(KProtocolInfo::archiveMimetypes("iso")); #else QSet KrServices::isoArchiveMimetypes; #endif QSet KrServices::generateKrarcArchiveMimetypes() { // Hard-code these proven mimetypes openable by krarc protocol. // They cannot be listed in krarc.protocol itself // because it would baffle other file managers (like Dolphin). QSet mimes; mimes += QString("application/x-deb"); mimes += QString("application/x-debian-package"); mimes += QString("application/vnd.debian.binary-package"); mimes += QString("application/x-java-archive"); mimes += QString("application/x-rpm"); mimes += QString("application/x-source-rpm"); mimes += QString("application/vnd.oasis.opendocument.chart"); mimes += QString("application/vnd.oasis.opendocument.database"); mimes += QString("application/vnd.oasis.opendocument.formula"); mimes += QString("application/vnd.oasis.opendocument.graphics"); mimes += QString("application/vnd.oasis.opendocument.presentation"); mimes += QString("application/vnd.oasis.opendocument.spreadsheet"); mimes += QString("application/vnd.oasis.opendocument.text"); mimes += QString("application/vnd.openxmlformats-officedocument.presentationml.presentation"); mimes += QString("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); mimes += QString("application/vnd.openxmlformats-officedocument.wordprocessingml.document"); mimes += QString("application/x-cbz"); mimes += QString("application/x-cbr"); mimes += QString("application/epub+zip"); mimes += QString("application/x-webarchive"); mimes += QString("application/x-plasma"); mimes += QString("application/vnd.rar"); #ifdef KRARC_QUERY_ENABLED mimes += QSet::fromList(KProtocolInfo::archiveMimetypes("krarc")); #endif return mimes; } bool KrServices::cmdExist(QString cmdName) { KConfigGroup group(krConfig, "Dependencies"); if (QFile(group.readEntry(cmdName, QString())).exists()) return true; return !QStandardPaths::findExecutable(cmdName).isEmpty(); } QString KrServices::fullPathName(QString name, QString confName) { QString supposedName; if (confName.isNull()) confName = name; KConfigGroup config(krConfig, "Dependencies"); if (QFile(supposedName = config.readEntry(confName, QString())).exists()) return supposedName; if ((supposedName = QStandardPaths::findExecutable(name)).isEmpty()) return ""; config.writeEntry(confName, supposedName); return supposedName; } QString KrServices::chooseFullPathName(QStringList names, QString confName) { foreach(const QString &name, names) { QString foundTool = KrServices::fullPathName(name, confName); if (! foundTool.isEmpty()) { return foundTool; } } return ""; } +bool KrServices::isExecutable(const QString &path) +{ + QFileInfo info(path); + return info.isFile() && info.isExecutable(); +} + QString KrServices::registeredProtocol(QString mimetype) { if (slaveMap == 0) { slaveMap = new QMap(); KConfigGroup group(krConfig, "Protocols"); QStringList protList = group.readEntry("Handled Protocols", QStringList()); for (QStringList::Iterator it = protList.begin(); it != protList.end(); ++it) { QStringList mimes = group.readEntry(QString("Mimes For %1").arg(*it), QStringList()); for (QStringList::Iterator it2 = mimes.begin(); it2 != mimes.end(); ++it2) (*slaveMap)[*it2] = *it; } } QString protocol = (*slaveMap)[mimetype]; if (protocol.isEmpty()) { if (krarcArchiveMimetypes.contains(mimetype)) { return "krarc"; } protocol = KProtocolManager::protocolForArchiveMimetype(mimetype); } return protocol; } bool KrServices::isoSupported(QString mimetype) { return isoArchiveMimetypes.contains(mimetype); } void KrServices::clearProtocolCache() { if (slaveMap) delete slaveMap; slaveMap = 0; } bool KrServices::fileToStringList(QTextStream *stream, QStringList& target, bool keepEmptyLines) { if (!stream) return false; QString line; while (!stream->atEnd()) { line = stream->readLine().trimmed(); if (keepEmptyLines || !line.isEmpty()) target.append(line); } return true; } bool KrServices::fileToStringList(QFile *file, QStringList& target, bool keepEmptyLines) { QTextStream stream(file); return fileToStringList(&stream, target, keepEmptyLines); } QString KrServices::quote(QString name) { if (!name.contains('\'')) return '\'' + name + '\''; if (!name.contains('"') && !name.contains('$')) return "\"" + name + "\""; return escape(name); } QStringList KrServices::quote(const QStringList& names) { QStringList result; for (int i = 0; i < names.size(); ++i) result.append(quote(names[i])); return result; } QList KrServices::toUrlList(const QStringList &list) { QList result; for (QStringList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it) { result.append(QUrl::fromUserInput(*it, QDir::currentPath(), QUrl::AssumeLocalFile)); } return result; } QStringList KrServices::toStringList(const QList &list) { QStringList result; for(QList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it) { result.append(it->toString()); } return result; } // Adds one tool to the list in the supportedTools method void supportedTool(QStringList &tools, QString toolType, QStringList names, QString confName) { QString foundTool = KrServices::chooseFullPathName(names, confName); if (! foundTool.isEmpty()) { tools.append(toolType); tools.append(foundTool); } } // return a list in the format of TOOLS,PATH. for example // DIFF,kdiff,TERMINAL,konsole,... // // currently supported tools: DIFF, MAIL, RENAME // // to use it: QStringList lst = supportedTools(); // int i = lst.indexOf("DIFF"); // if (i!=-1) pathToDiff=lst[i+1]; QStringList KrServices::supportedTools() { QStringList tools; // first, a diff program: kdiff supportedTool(tools, "DIFF", QStringList() << "kdiff3" << "kompare" << "xxdiff", "diff utility"); // a mailer: kmail or thunderbird supportedTool(tools, "MAIL", QStringList() << "thunderbird" << "kmail", "mailer"); // rename tool: krename supportedTool(tools, "RENAME", QStringList() << "krename", "krename"); - // graphical sudo: kdesu or kdesudo - supportedTool(tools, "KDESU", - QStringList() << "kdesu" << "kdesudo", - "kdesu"); - // checksum utility supportedTool(tools, "MD5", QStringList() << "md5deep" << "md5sum" << "sha1deep" << "sha256deep" << "tigerdeep" << "whirlpooldeep" << "cfv", "checksum utility"); return tools; } QString KrServices::escape(QString name) { const QString evilstuff = "\\\"'`()[]{}!?;$&<>| \t\r\n"; // stuff that should get escaped for (int i = 0; i < evilstuff.length(); ++i) name.replace(evilstuff[ i ], ('\\' + evilstuff[ i ])); return name; } QString KrServices::escapeFileUrl(QString urlString) { // Avoid that if a path contains a '#' then what follows the '#' be interpreted as the fragment identifier of // the URL and not a part of the file path; for more information https://bugs.kde.org/show_bug.cgi?id=270150 can be seen return urlString.replace("#", "%23").replace("?", "%3F"); } QUrl KrServices::escapeFileUrl(const QUrl &url) { return QUrl(KrServices::escapeFileUrl(url.toString())); } QString KrServices::urlToLocalPath(const QUrl &url) { QUrl fileUrl = QUrl(url); // QUrl::toLocalFile() does not work if the protocol is "file" e.g. when opening an archive fileUrl.setScheme("file"); QString path = fileUrl.toLocalFile(); REPLACE_DIR_SEP2(path); #ifdef Q_WS_WIN if (path.startsWith(DIR_SEPARATOR)) { int p = 1; while (p < path.length() && path[ p ] == DIR_SEPARATOR_CHAR) p++; /* /C:/Folder */ if (p + 2 <= path.length() && path[ p ].isLetter() && path[ p + 1 ] == ':') { path = path.mid(p); } } #endif return path; } diff --git a/krusader/krservices.h b/krusader/krservices.h index e54a0a60..56378941 100644 --- a/krusader/krservices.h +++ b/krusader/krservices.h @@ -1,68 +1,69 @@ /***************************************************************************** * Copyright (C) 2002 Shie Erlich * * Copyright (C) 2002 Rafi Yanai * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This package is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this package; if not, write to the Free Software * * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ #ifndef KRSERVICES_H #define KRSERVICES_H // QtCore #include #include #include #include class QTextStream; class QFile; class KrServices { public: static bool cmdExist(QString cmdName); static QString chooseFullPathName(QStringList names, QString confName); static QString fullPathName(QString name, QString confName = QString()); + static bool isExecutable(const QString &path); static QString registeredProtocol(QString mimetype); static bool isoSupported(QString mimetype); static QString urlToLocalPath(const QUrl &url); static void clearProtocolCache(); static bool fileToStringList(QTextStream *stream, QStringList& target, bool keepEmptyLines = false); static bool fileToStringList(QFile *file, QStringList& target, bool keepEmptyLines = false); static QString quote(QString name); static QStringList quote(const QStringList& names); static QList toUrlList(const QStringList &list); static QStringList toStringList(const QList &list); static QStringList supportedTools(); // find supported tools static QString escapeFileUrl(QString urlString); static QUrl escapeFileUrl(const QUrl &url); protected: static QString escape(QString name); private: KrServices() {} ~KrServices() {} static QSet generateKrarcArchiveMimetypes(); static QMap* slaveMap; static QSet krarcArchiveMimetypes; static QSet isoArchiveMimetypes; }; // TODO: make KrServices a namespace and move it there #endif diff --git a/krusader/krslots.cpp b/krusader/krslots.cpp index b1b2d0d3..cc1b7c7e 100644 --- a/krusader/krslots.cpp +++ b/krusader/krslots.cpp @@ -1,738 +1,737 @@ /*************************************************************************** krslots.cpp ------------------- copyright : (C) 2001 by Shie Erlich & Rafi Yanai email : krusader@users.sourceforge.net web site : http://krusader.sourceforge.net --------------------------------------------------------------------------- Description *************************************************************************** A db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD S o u r c e F i l e *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "krslots.h" // QtCore #include #include #include #include #include #include // QtGui #include #include // QtWidgets #include #include #include #include #include #include #include #ifdef __KJSEMBED__ #include #include "KrJS/krjs.h" #endif #include "KViewer/krviewer.h" #include "Panel/krviewfactory.h" #include "krusader.h" #include "kractions.h" #include "krusaderview.h" #include "Panel/listpanel.h" #include "Panel/krselectionmode.h" #include "Dialogs/krdialogs.h" #include "Dialogs/krspwidgets.h" #include "GUI/krusaderstatus.h" #include "Panel/panelfunc.h" #include "Konfigurator/konfigurator.h" #include "MountMan/kmountman.h" #include "defaults.h" #include "GUI/kfnkeys.h" #include "GUI/kcmdline.h" #include "GUI/terminaldock.h" #include "GUI/syncbrowsebutton.h" #include "GUI/mediabutton.h" #include "GUI/dirhistorybutton.h" #include "FileSystem/krquery.h" #include "Search/krsearchmod.h" #include "Search/krsearchdialog.h" #include "Locate/locate.h" #include "FileSystem/filesystem.h" #include "FileSystem/fileitem.h" #include "panelmanager.h" #include "Splitter/splittergui.h" #include "Splitter/splitter.h" #include "Splitter/combiner.h" #include "ActionMan/actionman.h" #include "Panel/panelpopup.h" #include "Dialogs/krspecialwidgets.h" #include "DiskUsage/diskusagegui.h" #include "krservices.h" #include "Panel/krviewitem.h" #include "krtrashhandler.h" #include "BookMan/krbookmarkhandler.h" #include "BookMan/krbookmarkbutton.h" #ifdef SYNCHRONIZER_ENABLED #include "Synchronizer/synchronizergui.h" #endif #define ACTIVE_VIEW _mainWindow->activeView() KRslots::KRslots(QObject *parent) : QObject(parent), _mainWindow(krApp) { } void KRslots::sendFileByEmail(const QList &urls) { if (urls.count() == 0) { KMessageBox::error(0, i18n("No selected files to send.")); return; } QString mailProg; QStringList lst = KrServices::supportedTools(); if (lst.contains("MAIL")) mailProg = lst[lst.indexOf("MAIL") + 1]; else { KMessageBox::error(0, i18n("Krusader cannot find a supported mail client. Please install one to your path. Hint: Krusader supports KMail.")); return; } QString subject, separator; foreach(const QUrl &url, urls) { subject += separator + url.fileName(); separator = ','; } subject = i18np("Sending file: %2", "Sending files: %2", urls.count(), subject); KProcess proc; QString executable = QUrl::fromLocalFile(mailProg).fileName(); if (executable == QStringLiteral("kmail")) { proc << mailProg << "--subject" << subject; foreach(const QUrl &url2, urls) proc << "--attach" << url2.toDisplayString(); } else if (executable == QStringLiteral("thunderbird")) { QString param = "attachment=\'"; separator = ""; foreach(const QUrl &url2, urls) { param += separator + url2.toDisplayString(); separator = ','; } param += "\',subject=\'" + subject + "\'"; proc << mailProg << "--compose" << param; } else if (executable == QStringLiteral("evolution")) { QString param = "mailto:?cc=&subject=" + subject + "&attach="; separator = ""; foreach(const QUrl &url2, urls) { param += separator + url2.toDisplayString(); separator = "&attach="; } proc << mailProg << param + ""; } if (!proc.startDetached()) KMessageBox::error(0, i18n("Error executing %1.", mailProg)); } void KRslots::compareContent() { const QStringList lstLeft = LEFT_PANEL->getSelectedNames(); const QStringList lstRight = RIGHT_PANEL->getSelectedNames(); const QStringList lstActive = ACTIVE_PANEL->gui->isLeft() ? lstLeft : lstRight; QUrl name1, name2; if (lstLeft.count() == 1 && lstRight.count() == 1) { // first, see if we've got exactly 1 selected file in each panel: name1 = LEFT_PANEL->func->files()->getUrl(lstLeft[0]); name2 = RIGHT_PANEL->func->files()->getUrl(lstRight[0]); } else if (lstActive.count() == 2) { // next try: are in the current panel exacty 2 files selected? name1 = ACTIVE_PANEL->func->files()->getUrl(lstActive[0]); name2 = ACTIVE_PANEL->func->files()->getUrl(lstActive[1]); } else if (ACTIVE_PANEL->otherPanel()->func->files()->getFileItem(ACTIVE_VIEW->getCurrentItem())) { // next try: is in the other panel a file with the same name? name1 = ACTIVE_PANEL->func->files()->getUrl(ACTIVE_VIEW->getCurrentItem()); name2 = ACTIVE_PANEL->otherPanel()->func->files()->getUrl(ACTIVE_VIEW->getCurrentItem()); } else { // if we got here, then we can't be sure what file to diff KMessageBox::detailedError(0, i18n("Do not know which files to compare."), "" + i18n("To compare two files by content, you can either:
  • Select one file in the left panel, and one in the right panel.
  • Select exactly two files in the active panel.
  • Make sure there is a file in the other panel, with the same name as the current file in the active panel.
") + "
"); return; } // else implied: all ok, let's call an external program to compare files // but if any of the files isn't local, download it first compareContent(name1, name2); } bool downloadToTemp(const QUrl &url, QString &dest) { QTemporaryFile tmpFile; tmpFile.setAutoRemove(false); if (tmpFile.open()) { dest = tmpFile.fileName(); KIO::Job* job = KIO::file_copy(url, QUrl::fromLocalFile(dest), -1, KIO::Overwrite | KIO::HideProgressInfo); if(!job->exec()) { KMessageBox::error(krApp, i18n("Krusader is unable to download %1", url.fileName())); return false; } return true; } return false; } void KRslots::compareContent(QUrl url1, QUrl url2) { QString diffProg; QStringList lst = KrServices::supportedTools(); if (lst.contains("DIFF")) diffProg = lst[lst.indexOf("DIFF") + 1]; else { KMessageBox::error(0, i18n("Krusader cannot find any of the supported diff-frontends. Please install one to your path. Hint: Krusader supports Kompare, KDiff3 and Xxdiff.")); return; } QString tmp1; QString tmp2; // kdiff3 sucks with spaces if (QUrl::fromLocalFile(diffProg).fileName() == "kdiff3" && !url1.toDisplayString().contains(" ") && !url2.toDisplayString().contains(" ")) { tmp1 = url1.toDisplayString(); tmp2 = url2.toDisplayString(); } else { if (!url1.isLocalFile()) { if (!downloadToTemp(url1, tmp1)) { return; } } else tmp1 = url1.path(); if (!url2.isLocalFile()) { if (!downloadToTemp(url2, tmp2)) { if (tmp1 != url1.path()) QFile::remove(tmp1); return; } } else tmp2 = url2.path(); } KrProcess *p = new KrProcess(tmp1 != url1.path() ? tmp1 : QString(), tmp2 != url2.path() ? tmp2 : QString()); *p << diffProg << tmp1 << tmp2; p->start(); if (!p->waitForStarted()) KMessageBox::error(0, i18n("Error executing %1.", diffProg)); } // GUI toggle slots void KRslots::toggleFnkeys() { if (MAIN_VIEW->fnKeys()->isVisible()) MAIN_VIEW->fnKeys()->hide(); else MAIN_VIEW->fnKeys()->show(); } void KRslots::toggleCmdline() { if (MAIN_VIEW->cmdLine()->isVisible()) MAIN_VIEW->cmdLine()->hide(); else MAIN_VIEW->cmdLine()->show(); } void KRslots::updateStatusbarVisibility() { krApp->statusBar()->setVisible(KrActions::actShowStatusBar->isChecked()); } void KRslots::toggleTerminal() { MAIN_VIEW->setTerminalEmulator(KrActions::actToggleTerminal->isChecked()); } void KRslots::insertFileName(bool full_path) { QString filename = ACTIVE_VIEW->getCurrentItem(); if (filename.isEmpty()) { return; } if (full_path) { QString path = FileSystem::ensureTrailingSlash(ACTIVE_FUNC->files()->currentDirectory()).toDisplayString(QUrl::PreferLocalFile); filename = path + filename; } filename = KrServices::quote(filename); if (MAIN_VIEW->cmdLine()->isVisible() || !MAIN_VIEW->terminalDock()->isTerminalVisible()) { QString current = MAIN_VIEW->cmdLine()->text(); if (current.length() != 0 && !current.endsWith(' ')) current += ' '; MAIN_VIEW->cmdLine()->setText(current + filename); MAIN_VIEW->cmdLine()->setFocus(); } else if (MAIN_VIEW->terminalDock()->isTerminalVisible()) { filename = QChar(' ') + filename + QChar(' '); MAIN_VIEW->terminalDock()->sendInput(filename, false); MAIN_VIEW->terminalDock()->setFocus(); } } void KRslots::refresh(const QUrl &u) { ACTIVE_FUNC->openUrl(u); } void KRslots::runKonfigurator(bool firstTime) { Konfigurator *konfigurator = new Konfigurator(firstTime); connect(konfigurator, SIGNAL(configChanged(bool)), SLOT(configChanged(bool))); //FIXME - no need to exec konfigurator->exec(); delete konfigurator; } void KRslots::configChanged(bool isGUIRestartNeeded) { krConfig->sync(); if (isGUIRestartNeeded) { krApp->setUpdatesEnabled(false); KConfigGroup group(krConfig, "Look&Feel"); FileItem::loadUserDefinedFolderIcons(group.readEntry("Load User Defined Folder Icons", _UserDefinedFolderIcons)); bool leftActive = ACTIVE_PANEL->gui->isLeft(); MAIN_VIEW->leftManager()->slotRecreatePanels(); MAIN_VIEW->rightManager()->slotRecreatePanels(); if(leftActive) LEFT_PANEL->slotFocusOnMe(); else RIGHT_PANEL->slotFocusOnMe(); MAIN_VIEW->fnKeys()->updateShortcuts(); KrSelectionMode::resetSelectionHandler(); krApp->setUpdatesEnabled(true); } // really ugly, but reload the Fn keys just in case - csaba: any better idea? MAIN_VIEW->fnKeys()->updateShortcuts(); bool showHidden = KConfigGroup(krConfig, "Look&Feel").readEntry("Show Hidden", KrActions::actToggleHidden->isChecked()); if (showHidden != KrActions::actToggleHidden->isChecked()) { KrActions::actToggleHidden->setChecked(showHidden); MAIN_VIEW->leftManager()->refreshAllTabs(); MAIN_VIEW->rightManager()->refreshAllTabs(); } } void KRslots::showHiddenFiles(bool show) { KConfigGroup group(krConfig, "Look&Feel"); group.writeEntry("Show Hidden", show); MAIN_VIEW->leftManager()->refreshAllTabs(); MAIN_VIEW->rightManager()->refreshAllTabs(); } void KRslots::swapPanels() { QUrl leftURL = LEFT_PANEL->func->files()->currentDirectory(); QUrl rightURL = RIGHT_PANEL->func->files()->currentDirectory(); LEFT_PANEL->func->openUrl(rightURL); RIGHT_PANEL->func->openUrl(leftURL); } void KRslots::toggleSwapSides() { MAIN_VIEW->swapSides(); } void KRslots::search() { if (KrSearchDialog::SearchDialog != 0) { KConfigGroup group(krConfig, "Search"); if (group.readEntry("Window Maximized", false)) KrSearchDialog::SearchDialog->showMaximized(); else KrSearchDialog::SearchDialog->showNormal(); KrSearchDialog::SearchDialog->raise(); KrSearchDialog::SearchDialog->activateWindow(); } else KrSearchDialog::SearchDialog = new KrSearchDialog(); } void KRslots::locate() { if (!KrServices::cmdExist("locate")) { KMessageBox::error(krApp, i18n("Cannot find the 'locate' command. Please install the " "findutils-locate package of GNU, or set its dependencies in " "Konfigurator")); return; } if (LocateDlg::LocateDialog != 0) { LocateDlg::LocateDialog->showNormal(); LocateDlg::LocateDialog->raise(); LocateDlg::LocateDialog->activateWindow(); LocateDlg::LocateDialog->reset(); } else LocateDlg::LocateDialog = new LocateDlg(); } void KRslots::runTerminal(const QString & dir) { KProcess proc; proc.setWorkingDirectory(dir); KConfigGroup group(krConfig, "General"); QString term = group.readEntry("Terminal", _Terminal); QStringList sepdArgs = KShell::splitArgs(term, KShell::TildeExpand); if (sepdArgs.isEmpty()) { KMessageBox::error(krMainWindow, i18nc("Arg is a string containing the bad quoting.", "Bad quoting in terminal command:\n%1", term)); return; } for (int i = 0; i < sepdArgs.size(); i++) { if (sepdArgs[i] == "%d") { sepdArgs[i] = dir; } } proc << sepdArgs; if (!proc.startDetached()) KMessageBox::sorry(krApp, i18n("Error executing %1.", term)); } void KRslots::homeTerminal() { runTerminal(QDir::homePath()); } void KRslots::multiRename() { QStringList lst = KrServices::supportedTools(); int i = lst.indexOf("RENAME"); if (i == -1) { KMessageBox::sorry(krApp, i18n("Cannot find a batch rename tool.\nYou can get KRename at http://www.krename.net")); return; } QString pathToRename = lst[i+1]; const QStringList names = ACTIVE_PANEL->gui->getSelectedNames(); if (names.isEmpty()) { return; } KProcess proc; proc << pathToRename; for (const QString name: names) { FileItem *file = ACTIVE_FUNC->files()->getFileItem(name); if (!file) continue; const QUrl url = file->getUrl(); // KRename only supports the recursive option combined with a local directory path if (file->isDir() && url.scheme() == "file") { proc << "-r" << url.path(); } else { proc << url.toString(); } } if (!proc.startDetached()) KMessageBox::error(0, i18n("Error executing '%1'.", proc.program().join(" "))); } void KRslots::rootKrusader() { - if (!KrServices::cmdExist("krusader") || !KrServices::cmdExist("kdesu")) { + if (!KrServices::cmdExist("krusader") || !KrServices::isExecutable(KDESU_PATH)) { KMessageBox::sorry(krApp, i18n("Cannot start root mode Krusader, because Krusader or kdesu is missing from the path. Please configure the dependencies in Konfigurator.")); return; } KProcess proc; - proc << KrServices::fullPathName("kdesu") << "-c" << KrServices::fullPathName("krusader") + proc << KDESU_PATH << "-c" << KrServices::fullPathName("krusader") + " --left=" + KrServices::quote(LEFT_PANEL->func->files()->currentDirectory().toDisplayString(QUrl::PreferLocalFile)) + " --right=" + KrServices::quote(RIGHT_PANEL->func->files()->currentDirectory().toDisplayString(QUrl::PreferLocalFile)); if (!proc.startDetached()) KMessageBox::error(0, i18n("Error executing %1.", proc.program()[0])); } void KRslots::slotSplit() { const QStringList list = ACTIVE_PANEL->gui->getSelectedNames(); QString name; // first, see if we've got exactly 1 selected file, if not, try the current one if (list.count() == 1) name = list[0]; if (name.isEmpty()) { // if we got here, then one of the panel can't be sure what file to diff KMessageBox::error(0, i18n("Do not know which file to split.")); return; } QUrl fileURL = ACTIVE_FUNC->files()->getUrl(name); if (fileURL.isEmpty()) return; if (ACTIVE_FUNC->files()->getFileItem(name)->isDir()) { KMessageBox::sorry(krApp, i18n("You cannot split a folder.")); return ; } QUrl destDir = ACTIVE_PANEL->otherPanel()->func->files()->currentDirectory(); SplitterGUI splitterGUI(MAIN_VIEW, fileURL, destDir); if (splitterGUI.exec() == QDialog::Accepted) { bool splitToOtherPanel = splitterGUI.getDestinationDir().matches(ACTIVE_PANEL->otherPanel()->virtualPath(), QUrl::StripTrailingSlash); Splitter split(MAIN_VIEW, fileURL, splitterGUI.getDestinationDir(), splitterGUI.overWriteFiles()); split.split(splitterGUI.getSplitSize()); if (splitToOtherPanel) ACTIVE_PANEL->otherPanel()->func->refresh(); } } void KRslots::slotCombine() { const QStringList list = ACTIVE_PANEL->gui->getSelectedNames(); if (list.isEmpty()) { KMessageBox::error(0, i18n("Do not know which files to combine.")); return; } QUrl baseURL; bool unixStyle = false; bool windowsStyle = false; QString commonName; int commonLength = 0; /* checking splitter names */ for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it) { QUrl url = ACTIVE_FUNC->files()->getUrl(*it); if (url.isEmpty()) return; if (ACTIVE_FUNC->files()->getFileItem(*it)->isDir()) { KMessageBox::sorry(krApp, i18n("You cannot combine a folder.")); return ; } if (!unixStyle) { QString name = url.fileName(); int extPos = name.lastIndexOf('.'); QString ext = name.mid(extPos + 1); name.truncate(extPos); url = url.adjusted(QUrl::RemoveFilename); url.setPath(url.path() + name); bool isExtInt; ext.toInt(&isExtInt, 10); if (extPos < 1 || ext.isEmpty() || (ext != "crc" && !isExtInt)) { if (windowsStyle) { KMessageBox::error(0, i18n("Not a split file: %1.", url.toDisplayString(QUrl::PreferLocalFile))); return; } unixStyle = true; } else { if (ext != "crc") windowsStyle = true; if (baseURL.isEmpty()) baseURL = url; else if (baseURL != url) { KMessageBox::error(0, i18n("Select only one split file.")); return; } } } if (unixStyle) { bool error = true; do { QString shortName = *it; QChar lastChar = shortName.at(shortName.length() - 1); if (lastChar.isLetter()) { char fillLetter = (lastChar.toUpper() == lastChar) ? 'A' : 'a'; if (commonName.isNull()) { commonLength = shortName.length(); commonName = shortName; while (commonName.length()) { QString shorter = commonName.left(commonName.length() - 1); QString testFile = shorter.leftJustified(commonLength, fillLetter); if (ACTIVE_FUNC->files()->getFileItem(testFile) == 0) break; else { commonName = shorter; baseURL = ACTIVE_FUNC->files()->currentDirectory().adjusted(QUrl::StripTrailingSlash); baseURL.setPath(baseURL.path() + '/' + (testFile)); } } error = (commonName == shortName); } else if (commonLength == shortName.length() && shortName.startsWith(commonName)) error = false; } } while (false); if (error) { KMessageBox::error(0, i18n("Not a split file: %1.", url.toDisplayString(QUrl::PreferLocalFile))); return; } } } // ask the user for the copy dest QUrl dest = KChooseDir::getDir(i18n("Combining %1.* to folder:", baseURL.toDisplayString(QUrl::PreferLocalFile)), ACTIVE_PANEL->otherPanel()->virtualPath(), ACTIVE_PANEL->virtualPath()); if (dest.isEmpty()) return ; // the user canceled bool combineToOtherPanel = (dest.matches(ACTIVE_PANEL->otherPanel()->virtualPath(), QUrl::StripTrailingSlash)); Combiner combine(MAIN_VIEW, baseURL, dest, unixStyle); combine.combine(); if (combineToOtherPanel) ACTIVE_PANEL->otherPanel()->func->refresh(); } void KRslots::manageUseractions() { ActionMan actionMan(MAIN_VIEW); } #ifdef SYNCHRONIZER_ENABLED void KRslots::slotSynchronizeDirs(QStringList selected) { new SynchronizerGUI(0, LEFT_PANEL->func->files()->currentDirectory(), RIGHT_PANEL->func->files()->currentDirectory(), selected); } #endif void KRslots::compareSetup() { for (int i = 0; KrActions::compareArray[i] != 0; i++) if ((*KrActions::compareArray[i])->isChecked()) { KConfigGroup group(krConfig, "Private"); group.writeEntry("Compare Mode", i); break; } } /** called by actions actExec* to choose the built-in command line mode */ void KRslots::execTypeSetup() { for (int i = 0; KrActions::execTypeArray[i] != 0; i++) if ((*KrActions::execTypeArray[i])->isChecked()) { if (*KrActions::execTypeArray[i] == KrActions::actExecTerminalEmbedded) { // if commands are to be executed in the TE, it must be loaded MAIN_VIEW->terminalDock()->initialise(); } KConfigGroup grp(krConfig, "Private"); grp.writeEntry("Command Execution Mode", i); break; } } void KRslots::slotDiskUsage() { DiskUsageGUI du(ACTIVE_FUNC->files()->currentDirectory(), MAIN_VIEW); } void KRslots::applicationStateChanged() { if (MAIN_VIEW == 0) { /* CRASH FIX: it's possible that the method is called after destroying the main view */ return; } if(qApp->applicationState() == Qt::ApplicationActive) { LEFT_PANEL->panelActive(); RIGHT_PANEL->panelActive(); } else { LEFT_PANEL->panelInactive(); RIGHT_PANEL->panelInactive(); } } void KRslots::emptyTrash() { KrTrashHandler::emptyTrash(); } #define OPEN_ID 100001 #define EMPTY_TRASH_ID 100002 void KRslots::trashPopupMenu() { QMenu trashMenu(krApp); QAction * act = trashMenu.addAction(krLoader->loadIcon("document-open", KIconLoader::Panel), i18n("Open trash bin")); act->setData(QVariant(OPEN_ID)); act = trashMenu.addAction(krLoader->loadIcon("trash-empty", KIconLoader::Panel), i18n("Empty trash bin")); act->setData(QVariant(EMPTY_TRASH_ID)); int result = -1; QAction *res = trashMenu.exec(QCursor::pos()); if (res && res->data().canConvert ()) result = res->data().toInt(); if (result == OPEN_ID) { ACTIVE_FUNC->openUrl(QUrl(QStringLiteral("trash:/"))); } else if (result == EMPTY_TRASH_ID) { KrTrashHandler::emptyTrash(); } } //shows the JavaScript-Console void KRslots::jsConsole() { #ifdef __KJSEMBED__ if (! krJS) krJS = new KrJS(); krJS->view()->show(); #endif } void KRslots::addBookmark() { krBookMan->bookmarkCurrent(ACTIVE_PANEL->virtualPath()); } void KRslots::cmdlinePopup() { MAIN_VIEW->cmdLine()->popup(); } -