File indexing completed on 2024-04-28 09:40:58
0001 /* 0002 * SPDX-FileCopyrightText: 2015 Ashish Bansal <bansal.ashish096@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef GLOBAL_H 0008 #define GLOBAL_H 0009 0010 #include <QList> 0011 #include <QUrl> 0012 #include <QWidget> 0013 0014 class KConfigGroup; 0015 class OrgKdeDolphinMainWindowInterface; 0016 0017 namespace Dolphin 0018 { 0019 QList<QUrl> validateUris(const QStringList &uriList); 0020 0021 /** 0022 * Returns the home url which is defined in General Settings 0023 */ 0024 QUrl homeUrl(); 0025 0026 enum class OpenNewWindowFlag { None = 0, Select = 1 << 1 }; 0027 Q_DECLARE_FLAGS(OpenNewWindowFlags, OpenNewWindowFlag) 0028 0029 /** 0030 * Opens a new Dolphin window 0031 */ 0032 void openNewWindow(const QList<QUrl> &urls = {}, QWidget *window = nullptr, const OpenNewWindowFlags &flags = OpenNewWindowFlag::None); 0033 0034 /** 0035 * Attaches URLs to an existing Dolphin instance if possible. 0036 * If @p preferredService is a valid dbus service, it will be tried first. 0037 * @p preferredService needs to support the org.kde.dolphin.MainWindow dbus interface with the /dolphin/Dolphin_1 path. 0038 * Returns true if the URLs were successfully attached. 0039 */ 0040 bool attachToExistingInstance(const QList<QUrl> &inputUrls, bool openFiles, bool splitView, const QString &preferredService, const QString &activationToken); 0041 0042 /** 0043 * Returns a QVector with all GUI-capable Dolphin instances 0044 */ 0045 QVector<QPair<QSharedPointer<OrgKdeDolphinMainWindowInterface>, QStringList>> dolphinGuiInstances(const QString &preferredService); 0046 0047 QPair<QString, Qt::SortOrder> sortOrderForUrl(QUrl &url); 0048 0049 /** 0050 * TODO: Move this somewhere global to all KDE apps, not just Dolphin 0051 */ 0052 const int VERTICAL_SPACER_HEIGHT = 12; 0053 const int LAYOUT_SPACING_SMALL = 2; 0054 } 0055 0056 enum Animated { WithAnimation, WithoutAnimation }; 0057 0058 class GlobalConfig : public QObject 0059 { 0060 Q_OBJECT 0061 0062 public: 0063 GlobalConfig() = delete; 0064 0065 /** 0066 * @return a value from the global KDE config that should be 0067 * multiplied with every animation duration once. 0068 * 0.0 is returned if animations are globally turned off. 0069 * 1.0 is the default value. 0070 */ 0071 static double animationDurationFactor(); 0072 0073 private: 0074 static void updateAnimationDurationFactor(const KConfigGroup &group, const QByteArrayList &names); 0075 0076 private: 0077 static double s_animationDurationFactor; 0078 }; 0079 0080 #endif //GLOBAL_H