]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/panel.h
SVN_SILENT made messages (.desktop file) - always resolve ours
[dolphin.git] / src / panels / panel.h
1 /*
2 * SPDX-FileCopyrightText: 2006 Cvetoslav Ludmiloff <ludmiloff@gmail.com>
3 * SPDX-FileCopyrightText: 2006-2010 Peter Penz <peter.penz19@gmail.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8 #ifndef PANEL_H
9 #define PANEL_H
10
11 #include <QUrl>
12 #include <QWidget>
13
14 /**
15 * @brief Base widget for all panels that can be docked on the window borders.
16 *
17 * Derived panels should provide a context menu that at least offers the
18 * actions from Panel::customContextMenuActions().
19 */
20 class Panel : public QWidget
21 {
22 Q_OBJECT
23
24 public:
25 explicit Panel(QWidget *parent = nullptr);
26 ~Panel() override;
27
28 /** Returns the current set URL of the active Dolphin view. */
29 QUrl url() const;
30
31 /**
32 * Sets custom context menu actions that are added to the panel specific
33 * context menu actions. Allows an application to apply custom actions to
34 * the panel.
35 */
36 void setCustomContextMenuActions(const QList<QAction *> &actions);
37 QList<QAction *> customContextMenuActions() const;
38
39 QSize sizeHint() const override;
40
41 public Q_SLOTS:
42 /**
43 * This is invoked every time the folder being displayed in the
44 * active Dolphin view changes.
45 */
46 void setUrl(const QUrl &url);
47
48 /**
49 * Refreshes the view to get synchronized with the settings.
50 */
51 virtual void readSettings();
52
53 protected:
54 /**
55 * Must be implemented by derived classes and is invoked when
56 * the URL has been changed (see Panel::setUrl()).
57 * @return True, if the new URL will get accepted by the derived
58 * class. If false is returned,
59 * the URL will be reset to the previous URL.
60 */
61 virtual bool urlChanged() = 0;
62
63 private:
64 QUrl m_url;
65 QList<QAction *> m_customContextMenuActions;
66 };
67
68 #endif // PANEL_H