]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/information/informationpanel.h
Add settings page for Panels
[dolphin.git] / src / panels / information / informationpanel.h
1 /*
2 * SPDX-FileCopyrightText: 2006-2009 Peter Penz <peter.penz19@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef INFORMATIONPANEL_H
8 #define INFORMATIONPANEL_H
9
10 #include "panels/panel.h"
11
12 #include <KFileItem>
13
14 class InformationPanelContent;
15 namespace KIO
16 {
17 class Job;
18 }
19
20 /**
21 * @brief Panel for showing meta information of one ore more selected items.
22 */
23 class InformationPanel : public Panel
24 {
25 Q_OBJECT
26
27 public:
28 explicit InformationPanel(QWidget *parent = nullptr);
29 ~InformationPanel() override;
30
31 /**
32 * Refreshes the view to get synchronized with the settings (e.g. icons size,
33 * font, ...).
34 */
35 void readSettings() override;
36
37 Q_SIGNALS:
38 void urlActivated(const QUrl &url);
39
40 public Q_SLOTS:
41 /**
42 * This is invoked to inform the panel that the user has selected a new
43 * set of items.
44 */
45 void setSelection(const KFileItemList &selection);
46
47 /**
48 * Does a delayed request of information for the item \a item.
49 * If within this delay InformationPanel::setUrl() or InformationPanel::setSelection()
50 * are invoked, then the request will be skipped. Requesting a delayed item information
51 * makes sense when hovering items.
52 */
53 void requestDelayedItemInfo(const KFileItem &item);
54
55 void slotFilesItemChanged(const KFileItemList &changedFileItems);
56
57 protected:
58 /** @see Panel::urlChanged() */
59 bool urlChanged() override;
60
61 /** @see QWidget::showEvent() */
62 void showEvent(QShowEvent *event) override;
63
64 /** @see QWidget::resizeEvent() */
65 void resizeEvent(QResizeEvent *event) override;
66
67 /** @see QWidget::contextMenuEvent() */
68 void contextMenuEvent(QContextMenuEvent *event) override;
69
70 private Q_SLOTS:
71 /**
72 * Shows the information for the item of the URL which has been provided by
73 * InformationPanel::requestDelayedItemInfo() and provides default actions.
74 */
75 void showItemInfo();
76
77 /**
78 * Shows the information for the currently displayed folder as a result from
79 * a stat job issued in showItemInfo().
80 */
81 void slotFolderStatFinished(KJob *job);
82
83 /**
84 * Triggered if the request for item information has timed out.
85 * @see InformationPanel::requestDelayedItemInfo()
86 */
87 void slotInfoTimeout();
88
89 /**
90 * Resets the information panel to show the current
91 * URL (InformationPanel::url()). Is called by
92 * DolphinInformationPanel::markUrlAsInvalid().
93 */
94 void reset();
95
96 void slotFileRenamed(const QString &source, const QString &dest);
97 void slotFilesAdded(const QString &directory);
98 void slotFilesChanged(const QStringList &files);
99 void slotFilesRemoved(const QStringList &files);
100 void slotEnteredDirectory(const QString &directory);
101 void slotLeftDirectory(const QString &directory);
102
103 private:
104 /** Assures that any pending item information request is cancelled. */
105 void cancelRequest();
106
107 /**
108 * Returns true, if \a url is equal to the shown URL m_shownUrl.
109 */
110 bool isEqualToShownUrl(const QUrl &url) const;
111
112 /**
113 * Marks the URL as invalid and will reset the Information Panel
114 * after a short delay. The reset is not done synchronously to
115 * prevent expensive updates during temporary invalid URLs by
116 * e. g. changing the directory.
117 */
118 void markUrlAsInvalid();
119
120 /**
121 * Opens a menu which allows to configure which meta information
122 * should be shown.
123 */
124 void showContextMenu(const QPoint &point);
125
126 void init();
127
128 private:
129 bool m_initialized;
130 QTimer *m_infoTimer;
131 QTimer *m_urlChangedTimer;
132 QTimer *m_resetUrlTimer;
133
134 // URL that is currently shown in the Information Panel.
135 QUrl m_shownUrl;
136
137 // URL candidate that will replace m_shownURL after a delay.
138 // Used to remember URLs when hovering items.
139 QUrl m_urlCandidate;
140
141 // URL candidate that is marked as invalid (e. g. because the directory
142 // has been deleted or the shown item has been renamed). The Information
143 // Panel will be reset asynchronously to prevent unnecessary resets when
144 // a directory has been changed.
145 QUrl m_invalidUrlCandidate;
146
147 KFileItem m_hoveredItem;
148 KFileItemList m_selection;
149
150 KIO::Job *m_folderStatJob;
151
152 InformationPanelContent *m_content;
153 bool m_inConfigurationMode = false;
154 };
155
156 #endif // INFORMATIONPANEL_H