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"
15 class StatusBarSpaceInfo
;
21 class KSqueezedTextLabel
;
25 * @brief Represents the statusbar of a Dolphin view.
27 * The statusbar allows to show messages, progress
28 * information and space-information of a disk.
30 class DolphinStatusBar
: public AnimatedHeightWidget
35 explicit DolphinStatusBar(QWidget
*parent
);
36 ~DolphinStatusBar() override
;
40 enum class CancelLoading
{ Allowed
, Disallowed
};
42 * Shows progress for a task on the status bar.
44 * Allows us to inform the user about various tasks progressing in the background.
45 * This method can be called from various places in any order but only the most recent call will be displayed.
46 * @param currentlyRunningTaskTitle The task that is currently progressing.
47 * @param progressPercent The percent value shown in a progress bar next to the @p currentlyRunningTaskTitle.
48 * A negative @p progressPercent value will be interpreted as indeterminate/unknown progress.
49 * The progress is shown delayed by 500 milliseconds: If the progress does reach 100 % within 500 milliseconds,
50 * the progress is not shown at all.
51 * @param cancelLoading Whether a "Stop" button for cancelling the task should be available next to the progress reporting.
53 * @note Make sure you also hide the progress information by calling this with a @p progressPercent equal or greater than 100.
55 void showProgress(const QString
¤tlyRunningTaskTitle
, int progressPercent
, CancelLoading cancelLoading
= CancelLoading::Allowed
);
56 QString
progressText() const;
60 * Replaces the text set by setText() by the text that
61 * has been set by setDefaultText(). DolphinStatusBar::text()
62 * will return an empty string after the reset has been done.
64 void resetToDefaultText();
67 * Sets the default text, which is shown if the status bar
68 * is rest by DolphinStatusBar::resetToDefaultText().
70 void setDefaultText(const QString
&text
);
71 QString
defaultText() const;
74 int zoomLevel() const;
77 * Refreshes the status bar to get synchronized with the (updated) Dolphin settings.
82 * Refreshes the disk space information.
84 void updateSpaceInfo();
87 void setText(const QString
&text
);
88 void setUrl(const QUrl
&url
);
89 void setZoomLevel(int zoomLevel
);
93 * Is emitted if the stop-button has been pressed during showing a progress.
97 void zoomLevelChanged(int zoomLevel
);
100 void contextMenuEvent(QContextMenuEvent
*event
) override
;
101 void paintEvent(QPaintEvent
*paintEvent
) override
;
104 void showZoomSliderToolTip(int zoomLevel
);
106 void updateProgressInfo();
109 * Updates the text for m_label and does an eliding in
110 * case if the text does not fit into the available width.
112 void updateLabelText();
115 * Updates the text of the zoom slider tooltip to show
116 * the currently used size.
118 void updateZoomSliderToolTip(int zoomLevel
);
122 * Makes the space information widget and zoom slider widget
123 * visible, if \a visible is true and the settings allow to show
124 * the widgets. showUnknownProgressIf \a visible is false, it is assured that both
125 * widgets are hidden.
127 void setExtensionsVisible(bool visible
);
129 void updateContentsMargins();
131 /** @see AnimatedHeightWidget::preferredHeight() */
132 int preferredHeight() const override
;
136 QString m_defaultText
;
137 KSqueezedTextLabel
*m_label
;
139 StatusBarSpaceInfo
*m_spaceInfo
;
141 QSlider
*m_zoomSlider
;
143 QLabel
*m_progressTextLabel
;
144 CancelLoading m_cancelLoading
= CancelLoading::Allowed
;
145 QProgressBar
*m_progressBar
;
146 QToolButton
*m_stopButton
;
148 QTimer
*m_showProgressBarTimer
;
150 QTimer
*m_delayUpdateTimer
;
151 QTime m_textTimestamp
;
153 QHBoxLayout
*m_topLayout
;