]> cloud.milkyroute.net Git - dolphin.git/blob - src/global.h
Fix Wayland window activation when attaching to an existing instance
[dolphin.git] / src / global.h
1 /*
2 * SPDX-FileCopyrightText: 2015 Ashish Bansal <bansal.ashish096@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef GLOBAL_H
8 #define GLOBAL_H
9
10 #include <QList>
11 #include <QUrl>
12 #include <QWidget>
13
14 class KConfigGroup;
15 class OrgKdeDolphinMainWindowInterface;
16
17 namespace Dolphin {
18 QList<QUrl> validateUris(const QStringList& uriList);
19
20 /**
21 * Returns the home url which is defined in General Settings
22 */
23 QUrl homeUrl();
24
25 enum class OpenNewWindowFlag {
26 None = 0,
27 Select = 1<<1
28 };
29 Q_DECLARE_FLAGS(OpenNewWindowFlags, OpenNewWindowFlag)
30
31 /**
32 * Opens a new Dolphin window
33 */
34 void openNewWindow(const QList<QUrl> &urls = {}, QWidget *window = nullptr, const OpenNewWindowFlags &flags = OpenNewWindowFlag::None);
35
36 /**
37 * Attaches URLs to an existing Dolphin instance if possible.
38 * If @p preferredService is a valid dbus service, it will be tried first.
39 * @p preferredService needs to support the org.kde.dolphin.MainWindow dbus interface with the /dolphin/Dolphin_1 path.
40 * Returns true if the URLs were successfully attached.
41 */
42 bool attachToExistingInstance(const QList<QUrl>& inputUrls, bool openFiles, bool splitView, const QString& preferredService, const QString &activationToken);
43
44 /**
45 * Returns a QVector with all GUI-capable Dolphin instances
46 */
47 QVector<QPair<QSharedPointer<OrgKdeDolphinMainWindowInterface>, QStringList>> dolphinGuiInstances(const QString& preferredService);
48
49 QPair<QString, Qt::SortOrder> sortOrderForUrl(QUrl &url);
50
51 /**
52 * TODO: Move this somewhere global to all KDE apps, not just Dolphin
53 */
54 const int VERTICAL_SPACER_HEIGHT = 12;
55 const int LAYOUT_SPACING_SMALL = 2;
56 }
57
58 enum Animated {
59 WithAnimation,
60 WithoutAnimation
61 };
62
63 class GlobalConfig : public QObject
64 {
65 Q_OBJECT
66
67 public:
68 GlobalConfig() = delete;
69
70 /**
71 * @return a value from the global KDE config that should be
72 * multiplied with every animation duration once.
73 * 0.0 is returned if animations are globally turned off.
74 * 1.0 is the default value.
75 */
76 static double animationDurationFactor();
77
78 private:
79 static void updateAnimationDurationFactor(const KConfigGroup &group, const QByteArrayList &names);
80
81 private:
82 static double s_animationDurationFactor;
83 };
84
85 #endif //GLOBAL_H