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
{ Allowed
, Disallowed
};
44 * Shows progress for a task on the status bar.
46 * Allows us to inform the user about various tasks progressing in the background.
47 * This method can be called from various places in any order but only the most recent call will be displayed.
48 * @param currentlyRunningTaskTitle The task that is currently progressing.
49 * @param progressPercent The percent value shown in a progress bar next to the @p currentlyRunningTaskTitle.
50 * A negative @p progressPercent value will be interpreted as indeterminate/unknown progress.
51 * The progress is shown delayed by 500 milliseconds: If the progress does reach 100 % within 500 milliseconds,
52 * the progress is not shown at all.
53 * @param cancelLoading Whether a "Stop" button for cancelling the task should be available next to the progress reporting.
55 * @note Make sure you also hide the progress information by calling this with a @p progressPercent equal or greater than 100.
57 void showProgress(const QString
¤tlyRunningTaskTitle
, int progressPercent
, CancelLoading cancelLoading
= CancelLoading::Allowed
);
58 QString
progressText() const;
62 * Replaces the text set by setText() by the text that
63 * has been set by setDefaultText(). DolphinStatusBar::text()
64 * will return an empty string after the reset has been done.
66 void resetToDefaultText();
69 * Sets the default text, which is shown if the status bar
70 * is rest by DolphinStatusBar::resetToDefaultText().
72 void setDefaultText(const QString
&text
);
73 QString
defaultText() const;
76 int zoomLevel() const;
79 * Refreshes the status bar to get synchronized with the (updated) Dolphin settings.
84 * Refreshes the disk space information.
86 void updateSpaceInfo();
89 void setText(const QString
&text
);
90 void setUrl(const QUrl
&url
);
91 void setZoomLevel(int zoomLevel
);
95 * Is emitted if the stop-button has been pressed during showing a progress.
99 void zoomLevelChanged(int zoomLevel
);
102 * Requests for @p message with the given @p messageType to be shown to the user in a non-modal way.
104 void showMessage(const QString
&message
, KMessageWidget::MessageType messageType
);
107 void contextMenuEvent(QContextMenuEvent
*event
) override
;
108 void paintEvent(QPaintEvent
*paintEvent
) override
;
111 void showZoomSliderToolTip(int zoomLevel
);
113 void updateProgressInfo();
116 * Updates the text for m_label and does an eliding in
117 * case if the text does not fit into the available width.
119 void updateLabelText();
122 * Updates the text of the zoom slider tooltip to show
123 * the currently used size.
125 void updateZoomSliderToolTip(int zoomLevel
);
129 * Makes the space information widget and zoom slider widget
130 * visible, if \a visible is true and the settings allow to show
131 * the widgets. showUnknownProgressIf \a visible is false, it is assured that both
132 * widgets are hidden.
134 void setExtensionsVisible(bool visible
);
136 void updateContentsMargins();
138 /** @see AnimatedHeightWidget::preferredHeight() */
139 int preferredHeight() const override
;
143 QString m_defaultText
;
144 KSqueezedTextLabel
*m_label
;
146 StatusBarSpaceInfo
*m_spaceInfo
;
148 QSlider
*m_zoomSlider
;
150 QLabel
*m_progressTextLabel
;
151 CancelLoading m_cancelLoading
= CancelLoading::Allowed
;
152 QProgressBar
*m_progressBar
;
153 QToolButton
*m_stopButton
;
155 QTimer
*m_showProgressBarTimer
;
157 QTimer
*m_delayUpdateTimer
;
158 QTime m_textTimestamp
;
160 QHBoxLayout
*m_topLayout
;