File indexing completed on 2024-04-28 04:44:39
0001 // Copyright 2018-2020 Camilo Higuita <milo.h@aol.com> 0002 // Copyright 2018-2020 Nitrux Latinoamericana S.C. 0003 // 0004 // SPDX-License-Identifier: GPL-3.0-or-later 0005 0006 #pragma once 0007 0008 #include <QObject> 0009 #include <QUrl> 0010 #include <QStringList> 0011 0012 #if (defined Q_OS_LINUX || defined Q_OS_FREEBSD) && !defined Q_OS_ANDROID 0013 class OrgKdeIndexActionsInterface; 0014 0015 namespace IndexInstance 0016 { 0017 QVector<QPair<QSharedPointer<OrgKdeIndexActionsInterface>, QStringList>> appInstances(const QString& preferredService); 0018 0019 bool attachToExistingInstance(const QList<QUrl>& inputUrls, bool openFiles, bool splitView, const QString& preferredService = QString()); 0020 0021 bool registerService(); 0022 } 0023 #endif 0024 0025 class Index : public QObject 0026 { 0027 Q_OBJECT 0028 //#if (defined Q_OS_LINUX || defined Q_OS_FREEBSD) && !defined Q_OS_ANDROID 0029 Q_CLASSINFO("D-Bus Interface", "org.kde.index.Actions") 0030 //#endif 0031 0032 public: 0033 explicit Index(QObject *parent = nullptr); 0034 Q_INVOKABLE void openPaths(const QStringList &paths); 0035 void setQmlObject(QObject *object); 0036 0037 public Q_SLOTS: 0038 static QUrl cameraPath(); 0039 static QUrl screenshotsPath(); 0040 0041 /** 0042 * Opens each directory in \p dirs in a separate tab. If \a splitView is set, 0043 * 2 directories are collected within one tab. 0044 * \pre \a dirs must contain at least one url. 0045 * 0046 * @note this function is overloaded so that it is callable via DBus. 0047 */ 0048 void openDirectories(const QStringList &dirs, bool splitView); 0049 0050 /** 0051 * Opens the directories which contain the files \p files and selects all files. 0052 * If \a splitView is set, 2 directories are collected within one tab. 0053 * \pre \a files must contain at least one url. 0054 * 0055 * @note this is overloaded so that this function is callable via DBus. 0056 */ 0057 void openFiles(const QStringList &files, bool splitView); 0058 0059 0060 /** 0061 * Tries to raise/activate the Dolphin window. 0062 */ 0063 void activateWindow(); 0064 0065 /** 0066 * Determines if a URL is open in any tab. 0067 * @note Use of QString instead of QUrl is required to be callable via DBus. 0068 * 0069 * @param url URL to look for 0070 * @returns true if url is currently open in a tab, false otherwise. 0071 */ 0072 bool isUrlOpen(const QString &url); 0073 0074 0075 /** 0076 * Pastes the clipboard data into the currently selected folder 0077 * of the active view. If not exactly one folder is selected, 0078 * no pasting is done at all. 0079 */ 0080 void pasteIntoFolder(); 0081 0082 /** 0083 * Implementation of the MainWindowAdaptor/QDBusAbstractAdaptor interface. 0084 * Inform all affected dolphin components (panels, views) of an URL 0085 * change. 0086 */ 0087 void changeUrl(const QUrl& url); 0088 0089 /** 0090 * The current directory of the Terminal Panel has changed, probably because 0091 * the user entered a 'cd' command. This slot calls changeUrl(url) and makes 0092 * sure that the panel keeps the keyboard focus. 0093 */ 0094 void slotTerminalDirectoryChanged(const QUrl& url); 0095 0096 /** Stores all settings and quits Dolphin. */ 0097 void quit(); 0098 0099 /** 0100 * Opens a new tab in the background showing the URL \a url. 0101 */ 0102 void openNewTab(const QUrl& url); 0103 0104 /** 0105 * Opens a new tab showing the URL \a url and activate it. 0106 */ 0107 void openNewTabAndActivate(const QUrl &url); 0108 0109 /** 0110 * Opens a new window showing the URL \a url. 0111 */ 0112 void openNewWindow(const QUrl &url); 0113 0114 /** 0115 * @brief openTerminal 0116 * Open Terminal Windows 0117 * @param url 0118 * Path in which terminal should open 0119 */ 0120 static void openTerminal(const QUrl &url); 0121 0122 static QVariantList quickPaths(); 0123 0124 private: 0125 QObject* m_qmlObject = nullptr; 0126 0127 Q_SIGNALS: 0128 void openPath(QStringList paths); 0129 void activate(); 0130 }; 0131 0132