blob: 7b4434539c47141d1bc424f228d819c0514dea01 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
/*
* SPDX-FileCopyrightText: 2006-2012 Peter Penz <[email protected]>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef DOLPHINSTATUSBAR_H
#define DOLPHINSTATUSBAR_H
#include <QTime>
#include <QWidget>
class QUrl;
class StatusBarSpaceInfo;
class QLabel;
class QProgressBar;
class QToolButton;
class QSlider;
class QTimer;
class KSqueezedTextLabel;
/**
* @brief Represents the statusbar of a Dolphin view.
*
* The statusbar allows to show messages, progress
* information and space-information of a disk.
*/
class DolphinStatusBar : public QWidget
{
Q_OBJECT
public:
explicit DolphinStatusBar(QWidget* parent);
~DolphinStatusBar() override;
QString text() const;
/**
* Sets the text for the progress information.
* DolphinStatusBar::setProgress() should be invoked
* afterwards each time the progress changes.
*/
void setProgressText(const QString& text);
QString progressText() const;
/**
* Sets the progress in percent (0 - 100). The
* progress is shown delayed by 500 milliseconds:
* If the progress does reach 100 % within 500 milliseconds,
* the progress is not shown at all.
*/
void setProgress(int percent);
int progress() const;
/**
* Replaces the text set by setText() by the text that
* has been set by setDefaultText(). DolphinStatusBar::text()
* will return an empty string after the reset has been done.
*/
void resetToDefaultText();
/**
* Sets the default text, which is shown if the status bar
* is rest by DolphinStatusBar::resetToDefaultText().
*/
void setDefaultText(const QString& text);
QString defaultText() const;
QUrl url() const;
int zoomLevel() const;
/**
* Refreshes the status bar to get synchronized with the (updated) Dolphin settings.
*/
void readSettings();
/**
* Refreshes the disk space information.
*/
void updateSpaceInfo();
public Q_SLOTS:
void setText(const QString& text);
void setUrl(const QUrl& url);
void setZoomLevel(int zoomLevel);
Q_SIGNALS:
/**
* Is emitted if the stop-button has been pressed during showing a progress.
*/
void stopPressed();
void zoomLevelChanged(int zoomLevel);
protected:
void contextMenuEvent(QContextMenuEvent* event) override;
private Q_SLOTS:
void showZoomSliderToolTip(int zoomLevel);
void updateProgressInfo();
/**
* Updates the text for m_label and does an eliding in
* case if the text does not fit into the available width.
*/
void updateLabelText();
/**
* Updates the text of the zoom slider tooltip to show
* the currently used size.
*/
void updateZoomSliderToolTip(int zoomLevel);
private:
/**
* Makes the space information widget and zoom slider widget
* visible, if \a visible is true and the settings allow to show
* the widgets. showUnknownProgressIf \a visible is false, it is assured that both
* widgets are hidden.
*/
void setExtensionsVisible(bool visible);
private:
QString m_text;
QString m_defaultText;
KSqueezedTextLabel* m_label;
QLabel* m_zoomLabel;
StatusBarSpaceInfo* m_spaceInfo;
QSlider* m_zoomSlider;
QLabel* m_progressTextLabel;
QProgressBar* m_progressBar;
QToolButton* m_stopButton;
int m_progress;
QTimer* m_showProgressBarTimer;
QTimer* m_delayUpdateTimer;
QTime m_textTimestamp;
};
#endif
|