File indexing completed on 2024-04-28 05:49:29

0001 /* This file is part of the KDE project
0002  *
0003  * SPDX-FileCopyrightText: 2018 Gregor Mi <codestruct@posteo.org>
0004  *
0005  * SPDX-License-Identifier: LGPL-2.0-or-later
0006  **/
0007 
0008 #pragma once
0009 
0010 #include "kateprivate_export.h"
0011 
0012 #include <utility>
0013 
0014 #include <QString>
0015 
0016 class QAction;
0017 class QMenu;
0018 class QWidget;
0019 class QUrl;
0020 namespace KTextEditor
0021 {
0022 class Document;
0023 }
0024 
0025 namespace KateFileActions
0026 {
0027 /**
0028  * Copies the file path to clipboard.
0029  * If the document has no file, the clipboard will be emptied.
0030  */
0031 KATE_PRIVATE_EXPORT void copyFilePathToClipboard(KTextEditor::Document *document);
0032 
0033 /**
0034  * Tries to open and highlight the underlying url in the filemanager
0035  */
0036 KATE_PRIVATE_EXPORT void openContainingFolder(KTextEditor::Document *document);
0037 
0038 /**
0039  * Shows a Rename dialog to rename the file associated with the document.
0040  * The document will be closed an reopened.
0041  *
0042  * Nothing is done if the document is nullptr or has no associated file.
0043  */
0044 KATE_PRIVATE_EXPORT void renameDocumentFile(QWidget *parent, KTextEditor::Document *document);
0045 
0046 KATE_PRIVATE_EXPORT void openFilePropertiesDialog(QWidget *parent, KTextEditor::Document *document);
0047 
0048 /**
0049  * Asks the user if the file should really be deleted. If yes, the file
0050  * is deleted from disk and the document closed.
0051  *
0052  * Nothing is done if the document is nullptr or has no associated file.
0053  */
0054 KATE_PRIVATE_EXPORT void deleteDocumentFile(QWidget *parent, KTextEditor::Document *document);
0055 
0056 /**
0057  * @returns a list of supported diff tools (names of the executables + paths to them, empty if not found in PATH)
0058  */
0059 QList<std::pair<QString, QString>> supportedDiffTools();
0060 
0061 /**
0062  * Runs an external program to compare the underlying files of two given documents.
0063  *
0064  * @p diffExecutable tested to work with "kdiff3", "kompare", and "meld"
0065  * @see supportedDiffTools()
0066  *
0067  * The parameters documentA and documentB must not be nullptr. Otherwise an assertion fails.
0068  *
0069  * If @p documentA or @p documentB have an empty url,
0070  * then an empty string is passed to the diff program instead of a local file path.
0071  *
0072  * @returns true if program was started successfully; otherwise false
0073  * (which can mean the program is not installed)
0074  *
0075  * IDEA for later: compare with unsaved buffer data instead of underlying file
0076  */
0077 bool compareWithExternalProgram(KTextEditor::Document *documentA, KTextEditor::Document *documentB, const QString &diffExecutable);
0078 
0079 /**
0080  * Prepares the open with menu
0081  */
0082 KATE_PRIVATE_EXPORT void prepareOpenWithMenu(const QUrl &url, QMenu *menu);
0083 
0084 /**
0085  * Prepares the open with menu
0086  */
0087 KATE_PRIVATE_EXPORT void showOpenWithMenu(QWidget *parent, const QUrl &url, QAction *action);
0088 }