2 * SPDX-FileCopyrightText: 2006-2012 Peter Penz <peter.penz19@gmail.com>
4 * SPDX-License-Identifier: GPL-2.0-or-later
7 #ifndef DOLPHINSTATUSBAR_H
8 #define DOLPHINSTATUSBAR_H
10 #include "animatedheightwidget.h"
12 #include <KMessageWidget>
17 class StatusBarSpaceInfo
;
23 class KSqueezedTextLabel
;
27 * @brief Represents the statusbar of a Dolphin view.
29 * The statusbar allows to show messages, progress
30 * information and space-information of a disk.
32 class DolphinStatusBar
: public AnimatedHeightWidget
37 explicit DolphinStatusBar(QWidget
*parent
);
38 ~DolphinStatusBar() override
;
42 enum class CancelLoading
{
47 * Shows progress for a task on the status bar.
49 * Allows us to inform the user about various tasks progressing in the background.
50 * This method can be called from various places in any order but only the most recent call will be displayed.
51 * @param currentlyRunningTaskTitle The task that is currently progressing.
52 * @param progressPercent The percent value shown in a progress bar next to the @p currentlyRunningTaskTitle.
53 * A negative @p progressPercent value will be interpreted as indeterminate/unknown progress.
54 * The progress is shown delayed by 500 milliseconds: If the progress does reach 100 % within 500 milliseconds,
55 * the progress is not shown at all.
56 * @param cancelLoading Whether a "Stop" button for cancelling the task should be available next to the progress reporting.
58 * @note Make sure you also hide the progress information by calling this with a @p progressPercent equal or greater than 100.
60 void showProgress(const QString
¤tlyRunningTaskTitle
, int progressPercent
, CancelLoading cancelLoading
= CancelLoading::Allowed
);
61 QString
progressText() const;
65 * Replaces the text set by setText() by the text that
66 * has been set by setDefaultText(). DolphinStatusBar::text()
67 * will return an empty string after the reset has been done.
69 void resetToDefaultText();
72 * Sets the default text, which is shown if the status bar
73 * is rest by DolphinStatusBar::resetToDefaultText().
75 void setDefaultText(const QString
&text
);
76 QString
defaultText() const;
79 int zoomLevel() const;
82 * Refreshes the status bar to get synchronized with the (updated) Dolphin settings.
87 * Refreshes the disk space information.
89 void updateSpaceInfo();
92 * Changes the statusbar between disabled, small, and full width
93 * depending on settings enabled.
98 * Updates the statusbar width to fit all content.
100 void updateWidthToContent();
103 * @return The amount of clipping done to the small statusbar side and bottom.
105 int clippingAmount() const;
108 void setText(const QString
&text
);
109 void setUrl(const QUrl
&url
);
110 void setZoomLevel(int zoomLevel
);
114 * Is emitted if the stop-button has been pressed during showing a progress.
118 void zoomLevelChanged(int zoomLevel
);
121 * Requests for @p message with the given @p messageType to be shown to the user in a non-modal way.
123 void showMessage(const QString
&message
, KMessageWidget::MessageType messageType
);
126 * Emitted when statusbar mode is changed.
131 * Emitted when statusbar width is updated to fit content.
136 * Emitted when statusbar url has changed.
141 void contextMenuEvent(QContextMenuEvent
*event
) override
;
142 void paintEvent(QPaintEvent
*paintEvent
) override
;
145 void showZoomSliderToolTip(int zoomLevel
);
147 void updateProgressInfo();
150 * Updates the text for m_label and does an eliding in
151 * case if the text does not fit into the available width.
153 void updateLabelText();
156 * Updates the text of the zoom slider tooltip to show
157 * the currently used size.
159 void updateZoomSliderToolTip(int zoomLevel
);
163 * Makes the space information widget and zoom slider widget
164 * visible, if \a visible is true and the settings allow to show
165 * the widgets. showUnknownProgressIf \a visible is false, it is assured that both
166 * widgets are hidden.
168 void setExtensionsVisible(bool visible
);
170 void updateContentsMargins();
172 /** @see AnimatedHeightWidget::preferredHeight() */
173 int preferredHeight() const override
;
177 QString m_defaultText
;
178 KSqueezedTextLabel
*m_label
;
180 StatusBarSpaceInfo
*m_spaceInfo
;
182 QSlider
*m_zoomSlider
;
184 QLabel
*m_progressTextLabel
;
185 CancelLoading m_cancelLoading
= CancelLoading::Allowed
;
186 QProgressBar
*m_progressBar
;
187 QToolButton
*m_stopButton
;
189 QTimer
*m_showProgressBarTimer
;
191 QTimer
*m_delayUpdateTimer
;
192 QTime m_textTimestamp
;
194 QHBoxLayout
*m_topLayout
;