Commit 10af0555 authored by Simon Persson's avatar Simon Persson
Browse files

Move Krusader::supportedTools to KrServices

This is an effort to untangle the big criss cross of includes across modules. So it changes some other things also. The idea was to try to reduce the number of frameworks each module needs to mention in it's target_link_libraries (in CMakeLists.txt...). Also gives benefit of not having to recompile so many other modules after changing a header file. There is still much to do, this was just a start... things that I came across today.
parent 1ac2029a
......@@ -34,7 +34,6 @@ A
#include "krmaskchoice.h"
#include "newftpgui.h"
#include "../krglobal.h"
#include "../MountMan/kmountman.h"
#include <QtGui/QKeyEvent>
#include <QtGui/QPaintEvent>
......
......@@ -39,6 +39,7 @@
#include <KConfigCore/KSharedConfig>
#include <KI18n/KLocalizedString>
#include <KIconThemes/KIconLoader>
#include "../kicons.h"
#include "../krglobal.h"
......
......@@ -46,6 +46,7 @@
#include <KConfigCore/KSharedConfig>
#include <KI18n/KLocalizedString>
#include <KIconThemes/KIconLoader>
#include "../krglobal.h"
#include "../kicons.h"
......
......@@ -34,6 +34,8 @@
#include <KHtml/KHTMLPart>
#include <KCoreAddons/KProcess>
#include <KConfigCore/KSharedConfig>
#include <KI18n/KLocalizedString>
#include <KIconThemes/KIconLoader>
#include <KIOCore/KFileItem>
#include <KXmlGui/KToolBar>
#include <KConfigWidgets/KStandardAction>
......
......@@ -40,6 +40,7 @@
#include <KConfigCore/KSharedConfig>
#include <KI18n/KLocalizedString>
#include <KIconThemes/KIconLoader>
#include <KWidgetsAddons/KMessageBox>
#include "krresulttabledialog.h"
......
......@@ -28,8 +28,6 @@
#include <KConfigWidgets/KColorScheme>
#include <KI18n/KLocalizedString>
#include "../krusader.h"
using namespace std;
#define PS(x) _supported.contains(x)>0
......@@ -263,7 +261,7 @@ void KrArchiverResultTable::website(const QString& url)
KrToolResultTable::KrToolResultTable(QWidget* parent)
: KrResultTable(parent)
{
_supported = Krusader::supportedTools(); // get list of available tools
_supported = KrServices::supportedTools(); // get list of available tools
QList<Application*> vecDiff, vecMail, vecRename, vecChecksum;
Application* kdiff3 = new Application("kdiff3", "http://kdiff3.sourceforge.net/", KrServices::cmdExist("kdiff3"));
......
......@@ -26,7 +26,6 @@
#include <QtWidgets/QLayout>
#include <QtWidgets/QGridLayout>
#include <KIconThemes/KIconLoader>
#include <KIOWidgets/KRun>
#include <KWidgetsAddons/KSeparator>
#include <KWidgetsAddons/KUrlLabel>
......
......@@ -26,6 +26,7 @@
#include <QtWidgets/QVBoxLayout>
#include <KConfigWidgets/KHelpClient>
#include <KIconThemes/KIconLoader>
KrResultTableDialog::KrResultTableDialog(QWidget *parent, DialogType type,
const QString& caption, const QString& heading, const QString& headerIcon,
......
......@@ -54,6 +54,7 @@ A
#include <KConfigCore/KSharedConfig>
#include <KI18n/KLocalizedString>
#include <KIconThemes/KIconLoader>
#include <KWidgetsAddons/KMessageBox>
#include <KWidgetsAddons/KGuiItem>
#include <KIOCore/KDiskFreeSpaceInfo>
......
......@@ -234,7 +234,7 @@ KrPopupMenu::KrPopupMenu(KrPanel *thePanel, QWidget *parent) : QMenu(parent), pa
}
// --------- send by mail
if (Krusader::supportedTools().contains("MAIL") && !vf->vfile_isDir()) {
if (KrServices::supportedTools().contains("MAIL") && !vf->vfile_isDir()) {
addAction(i18n("Send by Email"))->setData(QVariant(SEND_BY_EMAIL_ID));
}
......
......@@ -21,6 +21,7 @@
#define __KRSORT_H__
#include "krview.h"
#include "../VFS/vfile.h"
#include <QtCore/QString>
#include <QtCore/QVector>
......
......@@ -55,6 +55,7 @@
#include <KConfigCore/KSharedConfig>
#include <KI18n/KLocalizedString>
#include <KIconThemes/KIconLoader>
#define VF getVfile()
......
......@@ -40,7 +40,6 @@
#include <QtGui/QDropEvent>
#include "../krglobal.h"
#include "../VFS/vfile.h"
#include "../VFS/krquery.h"
#include "../Filter/filtersettings.h"
......
......@@ -52,6 +52,7 @@
#include <KConfigWidgets/KColorScheme>
#include <KCompletion/KComboBox>
#include <KI18n/KLocalizedString>
#include <KIconThemes/KIconLoader>
#include <KIOWidgets/KDirLister>
#include <KIOWidgets/KDirModel>
#include <KIOWidgets/KFileItemDelegate>
......
......@@ -35,13 +35,14 @@
#include <QtCore/QFile>
#include <QtWidgets/QApplication>
#include <KConfigCore/KSharedConfig>
#include <KI18n/KLocalizedString>
#include <KWallet/KWallet>
#include <KWidgetsAddons/KMessageBox>
#include <KWidgetsAddons/KPasswordDialog>
#include <KArchive/KTar>
#include <KIO/Global>
#include "../krusader.h"
#include "../krglobal.h"
#include "../defaults.h"
#include "../krservices.h"
......
......@@ -38,7 +38,10 @@
#include <QtCore/QUrl>
#include <KCoreAddons/KProcess>
#include <KWallet/KWallet>
namespace KWallet {
class Wallet;
}
class KRarcObserver : public QObject
{
......
......@@ -37,11 +37,11 @@
#include <KIO/Job>
#include <KConfigCore/KConfigGroup>
#include "vfile.h"
class KFileItem;
class QTextCodec;
class vfile;
class KRQuery : public QObject
{
Q_OBJECT
......
......@@ -45,6 +45,7 @@
#include "../krglobal.h"
#include "../defaults.h"
#include "../MountMan/kmountman.h"
#include "kiojobwrapper.h"
vfs::vfs(QObject* panel, bool quiet) : VfileContainer(0),
......@@ -285,6 +286,10 @@ void vfs::vfs_requestDelete()
deleteRequested = true;
}
void vfs::setMountMan(KMountMan *mtMan) {
mountMan = mtMan;
}
/// to be implemented
void vfs::slotKdsResult(KJob* job)
{
......
......@@ -43,7 +43,8 @@
#include "vfile.h"
#include "preservingcopyjob.h"
#include "krquery.h"
#include "../MountMan/kmountman.h"
class KMountMan;
/**
* The vfs class is an extendable class which by itself does (almost)
......@@ -147,9 +148,7 @@ public:
parentWindow = widget;
}
// set the mount manager
void setMountMan(KMountMan *mtMan) {
mountMan = mtMan;
}
void setMountMan(KMountMan *mtMan);
static QUrl ensureTrailingSlash(const QUrl &url);
......
......@@ -36,7 +36,6 @@
#include <QtGui/QKeySequence>
#include <KConfigCore/KConfigGroup>
#include <KIconThemes/KIconLoader>
#define krOut qDebug()
......
......@@ -153,6 +153,52 @@ QStringList KrServices::toStringList(const QList<QUrl> &list)
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");
// 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
......
......@@ -46,6 +46,8 @@ public:
static QStringList quote(const QStringList& names);
static QList<QUrl> toUrlList(const QStringList &list);
static QStringList toStringList(const QList<QUrl> &list);
static QStringList supportedTools(); // find supported tools
protected:
static QString escape(QString name);
......
......@@ -43,6 +43,7 @@
#include <KConfigCore/KSharedConfig>
#include <KCoreAddons/KShell>
#include <KI18n/KLocalizedString>
#include <KIconThemes/KIconLoader>
#include <KWidgetsAddons/KToggleAction>
#include <KWidgetsAddons/KMessageBox>
#include <KXmlGui/KEditToolBar>
......@@ -116,7 +117,7 @@ void KRslots::sendFileByEmail(const QList<QUrl> &urls)
}
QString mailProg;
QStringList lst = Krusader::supportedTools();
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."));
......@@ -214,7 +215,7 @@ bool downloadToTemp(const QUrl &url, QString &dest) {
void KRslots::compareContent(QUrl url1, QUrl url2)
{
QString diffProg;
QStringList lst = Krusader::supportedTools();
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."));
......@@ -462,7 +463,7 @@ void KRslots::sysInfo()
void KRslots::multiRename()
{
QStringList lst = Krusader::supportedTools();
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"));
......
......@@ -43,6 +43,7 @@ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
#include <KCoreAddons/KRandom>
#include <KConfigCore/KSharedConfig>
#include <KI18n/KLocalizedString>
#include <KIconThemes/KIconLoader>
#include <KXmlGui/KActionCollection>
#include <KXmlGui/KXMLGUIFactory>
#include <KXmlGui/KToolBar>
......@@ -51,6 +52,7 @@ YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD
#include <KWidgetsAddons/KMessageBox>
#include <KWidgetsAddons/KToggleAction>
#include <KWidgetsAddons/KToolBarPopupAction>
#include <KWindowSystem/KStartupInfo>
#include <KWindowSystem/KWindowSystem>
#include "krusaderversion.h"
......@@ -557,51 +559,6 @@ void Krusader::updateGUI(bool enforce) {
_popularUrls->load();
}
// Adds one tool to the list in the supportedTools method
void Krusader::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 Krusader::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");
// checksum utility
supportedTool(tools, "MD5",
QStringList() << "md5deep" << "md5sum" << "sha1deep" << "sha256deep"
<< "tigerdeep" << "whirlpooldeep" << "cfv",
"checksum utility");
return tools;
}
QString Krusader::getTempDir() {
// try to make krusader temp dir
KConfigGroup group(krConfig, "General");
......
......@@ -51,7 +51,6 @@
#include <KConfigWidgets/KStandardAction>
#include <KConfigCore/KConfig>
#include <KConfigCore/KConfigGroup>
#include <KWindowSystem/KStartupInfo>
#include "VFS/kiojobwrapper.h"
......@@ -59,6 +58,9 @@
class KrJS;
#endif
class KStartupInfoData;
class KStartupInfoId;
class KrusaderStatus;
class KRPleaseWaitHandler;
class UserMenu;
......@@ -113,7 +115,6 @@ public:
* @return a character string with the specitif icon-name
*/
static const char* privIcon();
static QStringList supportedTools(); // find supported tools
public slots:
......@@ -171,9 +172,6 @@ signals:
void shutdown();
private:
static void supportedTool(QStringList &tools, QString toolType,
QStringList names, QString confName);
KrActions *_krActions;
ViewActions *_viewActions;
ListPanelActions *_listPanelActions;
......
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